forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.ts
More file actions
77 lines (66 loc) · 2.34 KB
/
update.ts
File metadata and controls
77 lines (66 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// tslint:disable:no-global-tslint-disable no-any file-header
import { normalize } from '@angular-devkit/core';
import { CommandScope, Option } from '../models/command';
import { CoreSchematicOptions, SchematicCommand } from '../models/schematic-command';
import { findUp } from '../utilities/find-up';
export interface UpdateOptions extends CoreSchematicOptions {
next: boolean;
schematic?: boolean;
}
export default class UpdateCommand extends SchematicCommand {
public readonly name = 'update';
public readonly description = 'Updates your application and its dependencies.';
public static aliases: string[] = [];
public readonly scope = CommandScope.everywhere;
public arguments: string[] = [ 'packages' ];
public options: Option[] = [
// Remove the --force flag.
...this.coreOptions.filter(option => option.name !== 'force'),
];
public readonly allowMissingWorkspace = true;
private collectionName = '@schematics/update';
private schematicName = 'update';
private initialized = false;
public async initialize(options: any) {
if (this.initialized) {
return;
}
await super.initialize(options);
this.initialized = true;
const schematicOptions = await this.getOptions({
schematicName: this.schematicName,
collectionName: this.collectionName,
});
this.options = this.options.concat(schematicOptions.options);
this.arguments = this.arguments.concat(schematicOptions.arguments.map(a => a.name));
}
async validate(options: any) {
if (options._[0] == '@angular/cli'
&& options.migrateOnly === undefined
&& options.from === undefined) {
// Check for a 1.7 angular-cli.json file.
const oldConfigFileNames = [
normalize('.angular-cli.json'),
normalize('angular-cli.json'),
];
const oldConfigFilePath =
findUp(oldConfigFileNames, process.cwd())
|| findUp(oldConfigFileNames, __dirname);
if (oldConfigFilePath) {
options.migrateOnly = true;
options.from = '1.0.0';
}
}
return super.validate(options);
}
public async run(options: UpdateOptions) {
return this.runSchematic({
collectionName: this.collectionName,
schematicName: this.schematicName,
schematicOptions: options,
dryRun: options.dryRun,
force: false,
showNothingDone: false,
});
}
}