albatrosary's blog

Azure, Angular, CI 最近は Swagger も仲間入り

以前書いた Angular コードを v2 から v5 へアップデートした

以前作った Angular v2 で書かれたコードがあったので Angular v5 へアップデートした。書いたコードは https://angular.io/tutorial を少し変えたもの。これを ng update で変更してみた。

github.com

ちなみに変更前のライブラリはこちら:

  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.24",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "sass-lint": "^1.10.2",
    "ts-node": "1.2.1",
    "tslint": "^4.0.2",
    "typescript": "~2.0.3"
  }

angular-cli の削除

Angular v2 のころは angular-cli という名前だったので削除

$ yarn remove  angular-cli

@angular/cli のインストール

$ yarn add @angular/cli -D

ng serve で確認

ng serve コマンドで Angular のビルドを行うと angular-cli.json のエラーが出力されます。

$ ng serve
Environment configuration does not contain "environmentSource" entry.

A new environmentSource entry replaces the previous source entry inside environments.

To migrate angular-cli.json follow the example below:

Before:

"environments": {
  "source": "environments/environment.ts",
  "dev": "environments/environment.ts",
  "prod": "environments/environment.prod.ts"
}


After:

"environmentSource": "environments/environment.ts",
"environments": {
  "dev": "environments/environment.ts",
  "prod": "environments/environment.prod.ts"
}
$

コメントの通り書き直し再実行すると完了。

最後に

変更後のライブラリは

  "dependencies": {
    "@angular/common": "5.2.10",
    "@angular/compiler": "5.2.10",
    "@angular/core": "5.2.10",
    "@angular/forms": "5.2.10",
    "@angular/http": "5.2.10",
    "@angular/platform-browser": "5.2.10",
    "@angular/platform-browser-dynamic": "5.2.10",
    "@angular/router": "5.2.10",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.10",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "^1.7.4",
    "@angular/compiler-cli": "5.2.10",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "sass-lint": "^1.10.2",
    "ts-node": "1.2.1",
    "tslint": "^4.0.2",
    "typescript": "2.6.2"
  }

http 周りは当たり前だけど自力で変えて行く

おわり