UNPKG

3.69 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 return new (P || (P = Promise))(function (resolve, reject) {
4 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7 step((generator = generator.apply(thisArg, _arguments || [])).next());
8 });
9};
10Object.defineProperty(exports, "__esModule", { value: true });
11const core_1 = require("@angular-devkit/core");
12const command_1 = require("../models/command");
13const schematic_command_1 = require("../models/schematic-command");
14const find_up_1 = require("../utilities/find-up");
15class UpdateCommand extends schematic_command_1.SchematicCommand {
16 constructor() {
17 super(...arguments);
18 this.name = 'update';
19 this.description = 'Updates your application and its dependencies.';
20 this.scope = command_1.CommandScope.everywhere;
21 this.arguments = ['packages'];
22 this.options = [
23 // Remove the --force flag.
24 ...this.coreOptions.filter(option => option.name !== 'force'),
25 ];
26 this.allowMissingWorkspace = true;
27 this.collectionName = '@schematics/update';
28 this.schematicName = 'update';
29 this.initialized = false;
30 }
31 initialize(options) {
32 const _super = name => super[name];
33 return __awaiter(this, void 0, void 0, function* () {
34 if (this.initialized) {
35 return;
36 }
37 _super("initialize").call(this, options);
38 this.initialized = true;
39 const schematicOptions = yield this.getOptions({
40 schematicName: this.schematicName,
41 collectionName: this.collectionName,
42 });
43 this.options = this.options.concat(schematicOptions.options);
44 this.arguments = this.arguments.concat(schematicOptions.arguments.map(a => a.name));
45 });
46 }
47 validate(options) {
48 const _super = name => super[name];
49 return __awaiter(this, void 0, void 0, function* () {
50 if (options._[0] == '@angular/cli'
51 && options.migrateOnly === undefined
52 && options.from === undefined) {
53 // Check for a 1.7 angular-cli.json file.
54 const oldConfigFileNames = [
55 core_1.normalize('.angular-cli.json'),
56 core_1.normalize('angular-cli.json'),
57 ];
58 const oldConfigFilePath = find_up_1.findUp(oldConfigFileNames, process.cwd())
59 || find_up_1.findUp(oldConfigFileNames, __dirname);
60 if (oldConfigFilePath) {
61 options.migrateOnly = true;
62 options.from = '1.0.0';
63 }
64 }
65 return _super("validate").call(this, options);
66 });
67 }
68 run(options) {
69 return __awaiter(this, void 0, void 0, function* () {
70 return this.runSchematic({
71 collectionName: this.collectionName,
72 schematicName: this.schematicName,
73 schematicOptions: options,
74 dryRun: options.dryRun,
75 force: false,
76 showNothingDone: false,
77 });
78 });
79 }
80}
81UpdateCommand.aliases = [];
82exports.default = UpdateCommand;
83//# sourceMappingURL=/Users/hansl/Sources/hansl/angular-cli/commands/update.js.map
\No newline at end of file