Skip to content

Bug: ng update tries to apply original template to my existing code during upgrade #4360

Closed
@johnpapa

Description

@johnpapa

I'm sharing this full console output of when I tried to update an app written in angular-cli@beta.26 to @angular/cli@beta.29.

First, I had to manually edit the package.json to change the dependency name due to the name change. This is understandable as it is a one time name change, so no problem there. Once I did that, i ran ng update.

My Steps

  1. Ran ng update
  2. For every file I was promoted to overwrite, diff, or skip ... I did a diff
  3. After reviewing, I either skipped or overwrite

Problems

  1. Some files (the ones that came with original template) tried to append or overwrite my files. This was bad so I skipped these. There were several (as you can see below). This is a problem that should be fixed.

  2. The angular-cli.json had some valid new additions, but it also tried to remove some of mine. For this file I skipped it and then manually edited it. I think this may be OK ... wasn't hard, and I'm not sure how we can merge these without conflicts. Maybe the best course on this file is to just show the diff and ask the user to manually merge?

  3. ng lint now yields ... "No lint config(s) found. If this is not intended, run "ng update".
    " -- FIXED ... error was due to copying the lint section tot he wrong level in the angular-cli.json

Version Info

$ ng -v                             _                           _  _
  __ _  _ __    __ _  _   _ | |  __ _  _ __         ___ | |(_)
 / _` || '_ \  / _` || | | || | / _` || '__|_____  / __|| || |
| (_| || | | || (_| || |_| || || (_| || |  |_____|| (__ | || |
 \__,_||_| |_| \__, | \__,_||_| \__,_||_|          \___||_||_|
               |___/
@angular/cli: 1.0.0-beta.29
node: 6.9.1
os: darwin x64
@angular/common: 2.4.5
@angular/compiler: 2.4.5
@angular/core: 2.4.5
@angular/forms: 2.4.5
@angular/http: 2.4.5
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/router: 3.4.5
@angular/cli: 1.0.0-beta.29
@angular/compiler-cli: 2.4.5

ng update experience

$ @ ~/_git/angular-event-view-cli$ (master) 
$ ng update
installing ng2
? Overwrite README.md? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/README.md
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/README.md
+++ /Users/papaj015/_git/angular-event-view-cli/README.md
@@ -1,7 +1,7 @@
 # EventViewCli
 
-This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.26.
+This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.29.
 
 ## Development server
 Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
 

? Overwrite README.md? Yes, overwrite
? Overwrite src/app/app.component.css? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/src/app/app.component.css
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/src/app/app.component.css
+++ /Users/papaj015/_git/angular-event-view-cli/src/app/app.component.css
@@ -1,7 +1,0 @@
-.mdl-layout__content {
-  margin-top: 68px;
-}
-
-.page-content {
-  margin: 2em;
-}
\ No newline at end of file

? Overwrite src/app/app.component.css? Yes, overwrite
? Overwrite src/app/app.component.html? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/src/app/app.component.html
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/src/app/app.component.html
+++ /Users/papaj015/_git/angular-event-view-cli/src/app/app.component.html
@@ -1,13 +1,3 @@
-<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
-  <ev-nav></ev-nav>
-  <main class="mdl-layout__content">
-    <section>
-      <div class="page-content">
-        <router-outlet></router-outlet>
-      </div>
-    </section>
-  </main>
-  <ev-spinner></ev-spinner>
-  <ev-toast></ev-toast>
-  <ev-modal></ev-modal>
-</div>
+<h1>
+  {{title}}
+</h1>

? Overwrite src/app/app.component.html? No, skip
? Overwrite src/app/app.component.ts? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/src/app/app.component.ts
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/src/app/app.component.ts
+++ /Users/papaj015/_git/angular-event-view-cli/src/app/app.component.ts
@@ -1,9 +1,10 @@
 import { Component } from '@angular/core';
 
 @Component({
-  moduleId: module.id,
-  selector: 'ev-app',
+  selector: 'app-root',
   templateUrl: './app.component.html',
   styleUrls: ['./app.component.css']
 })
-export class AppComponent { }
+export class AppComponent {
+  title = 'app works!';
+}

? Overwrite src/app/app.component.ts? No, skip
? Overwrite src/app/app.module.ts? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/src/app/app.module.ts
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/src/app/app.module.ts
+++ /Users/papaj015/_git/angular-event-view-cli/src/app/app.module.ts
@@ -1,36 +1,20 @@
+import { BrowserModule } from '@angular/platform-browser';
 import { NgModule } from '@angular/core';
-import { BrowserModule } from '@angular/platform-browser';
-import { HttpModule, RequestOptions } from '@angular/http';
+import { FormsModule } from '@angular/forms';
+import { HttpModule } from '@angular/http';
 
-import './core/rxjs-extensions';
 import { AppComponent } from './app.component';
-import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
-import { InMemoryStoreService } from '../api/in-memory-store.service';
-import { AppRoutingModule } from './app-routing.module';
-import { SpeakerService } from './models';
-import { PageNotFoundComponent } from './page-not-found.component';
-import { CoreModule } from './core/core.module';
-import { LoginModule } from './login/login.module';
 
 @NgModule({
+  declarations: [
+    AppComponent
+  ],
   imports: [
     BrowserModule,
-    HttpModule,
-    LoginModule,
-    // Routes get loaded in order. It is important that login
-    // come before AppRoutingModule, as
-    // AppRoutingModule defines the catch-all ** route
-    AppRoutingModule,
-    CoreModule,
-    InMemoryWebApiModule.forRoot(InMemoryStoreService, { delay: 600 }),
+    FormsModule,
+    HttpModule
   ],
-  declarations: [AppComponent, PageNotFoundComponent],
-  providers: [SpeakerService],
-  bootstrap: [AppComponent],
+  providers: [],
+  bootstrap: [AppComponent]
 })
-export class AppModule {
-  constructor(requestOptions: RequestOptions) {
-    requestOptions.headers.set('Content-Type', 'application/json');
-  }
-}
-
+export class AppModule { }

? Overwrite src/app/app.module.ts? No, skip
? Overwrite src/index.html? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/src/index.html
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/src/index.html
+++ /Users/papaj015/_git/angular-event-view-cli/src/index.html
@@ -8,7 +8,7 @@
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="icon" type="image/x-icon" href="favicon.ico">
 </head>
 <body>
-  <ev-app>Loading...</ev-app>
+  <app-root>Loading...</app-root>
 </body>
 </html>

? Overwrite src/index.html? No, skip
? Overwrite src/main.ts? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/src/main.ts
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/src/main.ts
+++ /Users/papaj015/_git/angular-event-view-cli/src/main.ts
@@ -1,6 +1,4 @@
-import './polyfills.ts';
-
 import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
 import { enableProdMode } from '@angular/core';
 import { environment } from './environments/environment';
 import { AppModule } from './app/app.module';

? Overwrite src/main.ts? Yes, overwrite
? Overwrite src/polyfills.ts? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/src/polyfills.ts
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/src/polyfills.ts
+++ /Users/papaj015/_git/angular-event-view-cli/src/polyfills.ts
@@ -1,6 +1,6 @@
-// This file includes polyfills needed by Angular and is loaded before
-// the app. You can add your own extra polyfills to this file.
+// This file includes polyfills needed by Angular and is loaded before the app.
+// You can add your own extra polyfills to this file.
 import 'core-js/es6/symbol';
 import 'core-js/es6/object';
 import 'core-js/es6/function';
 import 'core-js/es6/parse-int';
@@ -16,4 +16,23 @@
 import 'core-js/es6/reflect';
 
 import 'core-js/es7/reflect';
 import 'zone.js/dist/zone';
+
+// If you need to support the browsers/features below, uncomment the import
+// and run `npm install import-name-here';
+// Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
+
+// Needed for: IE9
+// import 'classlist.js';
+
+// Animations
+// Needed for: All but Chrome and Firefox, Not supported in IE9
+// import 'web-animations-js';
+
+// Date, currency, decimal and percent pipes
+// Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
+// import 'intl';
+
+// NgClass on SVG elements
+// Needed for: IE10, IE11
+// import 'classlist.js';

? Overwrite src/polyfills.ts? Yes, overwrite
? Overwrite src/test.ts? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/src/test.ts
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/src/test.ts
+++ /Users/papaj015/_git/angular-event-view-cli/src/test.ts
@@ -1,8 +1,6 @@
 // This file is required by karma.conf.js and loads recursively all the .spec and framework files
 
-import './polyfills.ts';
-
 import 'zone.js/dist/long-stack-trace-zone';
 import 'zone.js/dist/proxy.js';
 import 'zone.js/dist/sync-test';
 import 'zone.js/dist/jasmine-patch';

? Overwrite src/test.ts? Yes, overwrite
? Overwrite angular-cli.json? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/angular-cli.json
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/angular-cli.json
+++ /Users/papaj015/_git/angular-event-view-cli/angular-cli.json
@@ -1,7 +1,7 @@
 {
   "project": {
-    "version": "1.0.0-beta.26",
+    "version": "1.0.0-beta.29",
     "name": "event-view-cli"
   },
   "apps": [
     {
@@ -12,22 +12,16 @@
         "favicon.ico"
       ],
       "index": "index.html",
       "main": "main.ts",
+      "polyfills": "polyfills.ts",
       "test": "test.ts",
       "tsconfig": "tsconfig.json",
-      "prefix": "ev",
-      "mobile": false,
+      "prefix": "app",
       "styles": [
-        "assets/material.min.css",
-        "assets/sprite-av-white.css",
-        "assets/animate.css",
-        "assets/app.css",
         "styles.css"
       ],
-      "scripts": [
-        "assets/material.min.js"
-      ],
+      "scripts": [],
       "environments": {
         "source": "environments/environment.ts",
         "dev": "environments/environment.ts",
         "prod": "environments/environment.prod.ts"
@@ -38,8 +32,18 @@
     "protractor": {
       "config": "./protractor.conf.js"
     }
   },
+  "lint": [
+    {
+      "files": "src/**/*.ts",
+      "project": "src/tsconfig.json"
+    },
+    {
+      "files": "e2e/**/*.ts",
+      "project": "e2e/tsconfig.json"
+    }
+  ],
   "test": {
     "karma": {
       "config": "./karma.conf.js"
     }

? Overwrite angular-cli.json? No, skip
? Overwrite karma.conf.js? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/karma.conf.js
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/karma.conf.js
+++ /Users/papaj015/_git/angular-event-view-cli/karma.conf.js
@@ -3,20 +3,20 @@
 
 module.exports = function (config) {
   config.set({
     basePath: '',
-    frameworks: ['jasmine', 'angular-cli'],
+    frameworks: ['jasmine', '@angular/cli'],
     plugins: [
       require('karma-jasmine'),
       require('karma-chrome-launcher'),
       require('karma-remap-istanbul'),
-      require('angular-cli/plugins/karma')
+      require('@angular/cli/plugins/karma')
     ],
     files: [
       { pattern: './src/test.ts', watched: false }
     ],
     preprocessors: {
-      './src/test.ts': ['angular-cli']
+      './src/test.ts': ['@angular/cli']
     },
     mime: {
       'text/x-typescript': ['ts','tsx']
     },

? Overwrite karma.conf.js? Yes, overwrite
? Overwrite package.json? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/package.json
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/package.json
+++ /Users/papaj015/_git/angular-event-view-cli/package.json
@@ -5,9 +5,8 @@
   "angular-cli": {},
   "scripts": {
     "ng": "ng",
     "start": "ng serve",
-    "lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
     "test": "ng test",
     "pree2e": "webdriver-manager update --standalone false --gecko false",
     "e2e": "protractor"
   },
@@ -20,16 +19,15 @@
     "@angular/http": "^2.3.1",
     "@angular/platform-browser": "^2.3.1",
     "@angular/platform-browser-dynamic": "^2.3.1",
     "@angular/router": "^3.3.1",
-    "angular-in-memory-web-api": "~0.2.4",
     "core-js": "^2.4.1",
     "rxjs": "^5.0.1",
     "ts-helpers": "^1.1.1",
     "zone.js": "^0.7.2"
   },
   "devDependencies": {
-    "@angular/cli": "^1.0.0-beta.29",
+    "@angular/cli": "1.0.0-beta.29",
     "@angular/compiler-cli": "^2.3.1",
     "@types/jasmine": "2.5.38",
     "@types/node": "^6.0.42",
     "codelyzer": "~2.0.0-beta.1",

? Overwrite package.json? No, skip
? Overwrite tslint.json? Diff
Index: /Users/papaj015/_git/angular-event-view-cli/tslint.json
===================================================================
--- /Users/papaj015/_git/angular-event-view-cli/tslint.json
+++ /Users/papaj015/_git/angular-event-view-cli/tslint.json
@@ -97,10 +97,10 @@
       "check-separator",
       "check-type"
     ],
 
-    "directive-selector": [true, "attribute", "ev", "camelCase"],
-    "component-selector": [true, "element", "ev", "kebab-case"],
+    "directive-selector": [true, "attribute", "app", "camelCase"],
+    "component-selector": [true, "element", "app", "kebab-case"],
     "use-input-property-decorator": true,
     "use-output-property-decorator": true,
     "use-host-property-decorator": true,
     "no-input-rename": true,

? Overwrite tslint.json? No, skip
  identical .editorconfig
  overwrite README.md
  overwrite src/app/app.component.css
  skip src/app/app.component.html
  identical src/app/app.component.spec.ts
  skip src/app/app.component.ts
  skip src/app/app.module.ts
  identical src/environments/environment.prod.ts
  identical src/environments/environment.ts
  skip src/index.html
  overwrite src/main.ts
  overwrite src/polyfills.ts
  identical src/styles.css
  overwrite src/test.ts
  identical src/tsconfig.json
  skip angular-cli.json
  identical e2e/app.e2e-spec.ts
  identical e2e/app.po.ts
  identical e2e/tsconfig.json
  identical .gitignore
  overwrite karma.conf.js
  skip package.json
  identical protractor.conf.js
  skip tslint.json
Directory is already under version control. Skipping initialization of git.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Project 'event-view-cli' successfully created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions