@angular/cli 14.0.0-next.5 → 14.0.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/postinstall/analytics-prompt.js +2 -2
- package/lib/config/schema.json +4 -4
- package/lib/config/workspace-schema.d.ts +1 -1
- package/lib/init.js +5 -1
- package/package.json +13 -13
- package/src/analytics/analytics-collector.js +5 -1
- package/{models/interface.js → src/analytics/analytics-environment-options.d.ts} +2 -2
- package/src/analytics/analytics-environment-options.js +20 -0
- package/src/analytics/analytics.d.ts +10 -23
- package/src/analytics/analytics.js +96 -182
- package/src/command-builder/architect-base-command-module.js +3 -5
- package/src/command-builder/architect-command-module.js +4 -6
- package/src/command-builder/command-module.d.ts +4 -1
- package/src/command-builder/command-module.js +9 -3
- package/src/command-builder/command-runner.js +9 -20
- package/src/command-builder/schematics-command-module.d.ts +18 -5
- package/src/command-builder/schematics-command-module.js +207 -29
- package/src/command-builder/utilities/command.d.ts +13 -0
- package/src/command-builder/utilities/command.js +27 -0
- package/src/command-builder/utilities/json-help.d.ts +16 -14
- package/src/command-builder/utilities/json-help.js +26 -22
- package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +0 -0
- package/{models → src/command-builder/utilities}/schematic-engine-host.js +0 -0
- package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
- package/src/command-builder/utilities/schematic-workflow.js +68 -0
- package/src/commands/add/cli.d.ts +11 -1
- package/src/commands/add/cli.js +325 -6
- package/src/commands/analytics/cli.d.ts +5 -10
- package/src/commands/analytics/cli.js +15 -50
- package/src/commands/analytics/info/cli.d.ts +16 -0
- package/src/commands/analytics/info/cli.js +26 -0
- package/src/commands/analytics/settings/cli.d.ts +35 -0
- package/src/commands/analytics/settings/cli.js +61 -0
- package/src/commands/config/cli.d.ts +4 -1
- package/src/commands/config/cli.js +126 -4
- package/src/commands/doc/cli.js +5 -1
- package/src/commands/generate/cli.d.ts +4 -2
- package/src/commands/generate/cli.js +37 -21
- package/src/commands/new/cli.d.ts +5 -3
- package/src/commands/new/cli.js +36 -6
- package/src/commands/update/cli.d.ts +30 -5
- package/src/commands/update/cli.js +680 -9
- package/src/commands/update/schematic/index.js +5 -1
- package/src/commands/version/cli.js +18 -23
- package/src/utilities/color.js +5 -1
- package/src/utilities/config.d.ts +1 -0
- package/src/utilities/config.js +36 -2
- package/src/utilities/find-up.js +5 -1
- package/src/utilities/package-metadata.js +5 -1
- package/src/utilities/package-tree.js +5 -1
- package/src/utilities/project.js +5 -1
- package/src/utilities/prompt.js +5 -1
- package/models/command.d.ts +0 -29
- package/models/command.js +0 -50
- package/models/interface.d.ts +0 -19
- package/models/schematic-command.d.ts +0 -43
- package/models/schematic-command.js +0 -378
- package/src/commands/add/add-impl.d.ts +0 -22
- package/src/commands/add/add-impl.js +0 -331
- package/src/commands/analytics/long-description.md +0 -10
- package/src/commands/config/config-impl.d.ts +0 -17
- package/src/commands/config/config-impl.js +0 -151
- package/src/commands/generate/generate-impl.d.ts +0 -19
- package/src/commands/generate/generate-impl.js +0 -49
- package/src/commands/new/new-impl.d.ts +0 -18
- package/src/commands/new/new-impl.js +0 -38
- package/src/commands/update/update-impl.d.ts +0 -40
- package/src/commands/update/update-impl.js +0 -728
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AnalyticsPromptModule = exports.AnalyticsEnableModule = exports.AnalyticsDisableModule = void 0;
|
|
11
|
+
const analytics_1 = require("../../../analytics/analytics");
|
|
12
|
+
const command_module_1 = require("../../../command-builder/command-module");
|
|
13
|
+
class AnalyticsSettingModule extends command_module_1.CommandModule {
|
|
14
|
+
builder(localYargs) {
|
|
15
|
+
return localYargs
|
|
16
|
+
.option('global', {
|
|
17
|
+
description: `Configure analytics gathering and reporting globally in the caller's home directory.`,
|
|
18
|
+
alias: ['g'],
|
|
19
|
+
type: 'boolean',
|
|
20
|
+
default: false,
|
|
21
|
+
})
|
|
22
|
+
.strict();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class AnalyticsDisableModule extends AnalyticsSettingModule {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.command = 'disable';
|
|
29
|
+
this.aliases = 'off';
|
|
30
|
+
this.describe = 'Disables analytics gathering and reporting for the user.';
|
|
31
|
+
}
|
|
32
|
+
async run({ global }) {
|
|
33
|
+
(0, analytics_1.setAnalyticsConfig)(global, false);
|
|
34
|
+
process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.AnalyticsDisableModule = AnalyticsDisableModule;
|
|
38
|
+
class AnalyticsEnableModule extends AnalyticsSettingModule {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this.command = 'enable';
|
|
42
|
+
this.aliases = 'on';
|
|
43
|
+
this.describe = 'Enables analytics gathering and reporting for the user.';
|
|
44
|
+
}
|
|
45
|
+
async run({ global }) {
|
|
46
|
+
(0, analytics_1.setAnalyticsConfig)(global, true);
|
|
47
|
+
process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.AnalyticsEnableModule = AnalyticsEnableModule;
|
|
51
|
+
class AnalyticsPromptModule extends AnalyticsSettingModule {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments);
|
|
54
|
+
this.command = 'prompt';
|
|
55
|
+
this.describe = 'Prompts the user to set the analytics gathering status interactively.';
|
|
56
|
+
}
|
|
57
|
+
async run({ global }) {
|
|
58
|
+
await (0, analytics_1.promptAnalytics)(global, true);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.AnalyticsPromptModule = AnalyticsPromptModule;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Argv } from 'yargs';
|
|
9
9
|
import { CommandModule, CommandModuleImplementation, Options } from '../../command-builder/command-module';
|
|
10
|
-
|
|
10
|
+
interface ConfigCommandArgs {
|
|
11
11
|
'json-path': string;
|
|
12
12
|
value?: string;
|
|
13
13
|
global?: boolean;
|
|
@@ -18,4 +18,7 @@ export declare class ConfigCommandModule extends CommandModule<ConfigCommandArgs
|
|
|
18
18
|
longDescriptionPath: string;
|
|
19
19
|
builder(localYargs: Argv): Argv<ConfigCommandArgs>;
|
|
20
20
|
run(options: Options<ConfigCommandArgs>): Promise<number | void>;
|
|
21
|
+
private get;
|
|
22
|
+
private set;
|
|
21
23
|
}
|
|
24
|
+
export {};
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.ConfigCommandModule = void 0;
|
|
11
11
|
const path_1 = require("path");
|
|
12
|
+
const uuid_1 = require("uuid");
|
|
12
13
|
const command_module_1 = require("../../command-builder/command-module");
|
|
13
|
-
const
|
|
14
|
+
const config_1 = require("../../utilities/config");
|
|
15
|
+
const json_file_1 = require("../../utilities/json-file");
|
|
14
16
|
class ConfigCommandModule extends command_module_1.CommandModule {
|
|
15
17
|
constructor() {
|
|
16
18
|
super(...arguments);
|
|
@@ -38,9 +40,129 @@ class ConfigCommandModule extends command_module_1.CommandModule {
|
|
|
38
40
|
})
|
|
39
41
|
.strict();
|
|
40
42
|
}
|
|
41
|
-
run(options) {
|
|
42
|
-
const
|
|
43
|
-
|
|
43
|
+
async run(options) {
|
|
44
|
+
const level = options.global ? 'global' : 'local';
|
|
45
|
+
const [config] = (0, config_1.getWorkspaceRaw)(level);
|
|
46
|
+
if (options.value == undefined) {
|
|
47
|
+
if (!config) {
|
|
48
|
+
this.context.logger.error('No config found.');
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
return this.get(config, options);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return this.set(options);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
get(jsonFile, options) {
|
|
58
|
+
const { logger } = this.context;
|
|
59
|
+
const value = options.jsonPath
|
|
60
|
+
? jsonFile.get(parseJsonPath(options.jsonPath))
|
|
61
|
+
: jsonFile.content;
|
|
62
|
+
if (value === undefined) {
|
|
63
|
+
logger.error('Value cannot be found.');
|
|
64
|
+
return 1;
|
|
65
|
+
}
|
|
66
|
+
else if (typeof value === 'string') {
|
|
67
|
+
logger.info(value);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
logger.info(JSON.stringify(value, null, 2));
|
|
71
|
+
}
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
async set(options) {
|
|
75
|
+
var _a, _b, _c;
|
|
76
|
+
if (!((_a = options.jsonPath) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
77
|
+
throw new command_module_1.CommandModuleError('Invalid Path.');
|
|
78
|
+
}
|
|
79
|
+
const validCliPaths = new Map([
|
|
80
|
+
['cli.warnings.versionMismatch', undefined],
|
|
81
|
+
['cli.defaultCollection', undefined],
|
|
82
|
+
['cli.packageManager', undefined],
|
|
83
|
+
['cli.analytics', undefined],
|
|
84
|
+
['cli.analyticsSharing.tracking', undefined],
|
|
85
|
+
['cli.analyticsSharing.uuid', (v) => (v === '' ? (0, uuid_1.v4)() : `${v}`)],
|
|
86
|
+
['cli.cache.enabled', undefined],
|
|
87
|
+
['cli.cache.environment', undefined],
|
|
88
|
+
['cli.cache.path', undefined],
|
|
89
|
+
]);
|
|
90
|
+
if (options.global &&
|
|
91
|
+
!options.jsonPath.startsWith('schematics.') &&
|
|
92
|
+
!validCliPaths.has(options.jsonPath)) {
|
|
93
|
+
throw new command_module_1.CommandModuleError('Invalid Path.');
|
|
94
|
+
}
|
|
95
|
+
const [config, configPath] = (0, config_1.getWorkspaceRaw)(options.global ? 'global' : 'local');
|
|
96
|
+
const { logger } = this.context;
|
|
97
|
+
if (!config || !configPath) {
|
|
98
|
+
throw new command_module_1.CommandModuleError('Confguration file cannot be found.');
|
|
99
|
+
}
|
|
100
|
+
const value = (_c = (_b = validCliPaths.get(options.jsonPath)) === null || _b === void 0 ? void 0 : _b(options.value)) !== null && _c !== void 0 ? _c : options.value;
|
|
101
|
+
const modified = config.modify(parseJsonPath(options.jsonPath), normalizeValue(value));
|
|
102
|
+
if (!modified) {
|
|
103
|
+
logger.error('Value cannot be found.');
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
await (0, config_1.validateWorkspace)((0, json_file_1.parseJson)(config.content));
|
|
107
|
+
config.save();
|
|
108
|
+
return 0;
|
|
44
109
|
}
|
|
45
110
|
}
|
|
46
111
|
exports.ConfigCommandModule = ConfigCommandModule;
|
|
112
|
+
/**
|
|
113
|
+
* Splits a JSON path string into fragments. Fragments can be used to get the value referenced
|
|
114
|
+
* by the path. For example, a path of "a[3].foo.bar[2]" would give you a fragment array of
|
|
115
|
+
* ["a", 3, "foo", "bar", 2].
|
|
116
|
+
* @param path The JSON string to parse.
|
|
117
|
+
* @returns {(string|number)[]} The fragments for the string.
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
function parseJsonPath(path) {
|
|
121
|
+
const fragments = (path || '').split(/\./g);
|
|
122
|
+
const result = [];
|
|
123
|
+
while (fragments.length > 0) {
|
|
124
|
+
const fragment = fragments.shift();
|
|
125
|
+
if (fragment == undefined) {
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
const match = fragment.match(/([^[]+)((\[.*\])*)/);
|
|
129
|
+
if (!match) {
|
|
130
|
+
throw new command_module_1.CommandModuleError('Invalid JSON path.');
|
|
131
|
+
}
|
|
132
|
+
result.push(match[1]);
|
|
133
|
+
if (match[2]) {
|
|
134
|
+
const indices = match[2]
|
|
135
|
+
.slice(1, -1)
|
|
136
|
+
.split('][')
|
|
137
|
+
.map((x) => (/^\d$/.test(x) ? +x : x.replace(/"|'/g, '')));
|
|
138
|
+
result.push(...indices);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return result.filter((fragment) => fragment != null);
|
|
142
|
+
}
|
|
143
|
+
function normalizeValue(value) {
|
|
144
|
+
const valueString = `${value}`.trim();
|
|
145
|
+
switch (valueString) {
|
|
146
|
+
case 'true':
|
|
147
|
+
return true;
|
|
148
|
+
case 'false':
|
|
149
|
+
return false;
|
|
150
|
+
case 'null':
|
|
151
|
+
return null;
|
|
152
|
+
case 'undefined':
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
if (isFinite(+valueString)) {
|
|
156
|
+
return +valueString;
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
// We use `JSON.parse` instead of `parseJson` because the latter will parse UUIDs
|
|
160
|
+
// and convert them into a numberic entities.
|
|
161
|
+
// Example: 73b61974-182c-48e4-b4c6-30ddf08c5c98 -> 73.
|
|
162
|
+
// These values should never contain comments, therefore using `JSON.parse` is safe.
|
|
163
|
+
return JSON.parse(valueString);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
}
|
package/src/commands/doc/cli.js
CHANGED
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
12
16
|
}) : (function(o, m, k, k2) {
|
|
13
17
|
if (k2 === undefined) k2 = k;
|
|
14
18
|
o[k2] = m[k];
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { Argv } from 'yargs';
|
|
9
9
|
import { CommandModuleImplementation, Options, OtherOptions } from '../../command-builder/command-module';
|
|
10
10
|
import { SchematicsCommandArgs, SchematicsCommandModule } from '../../command-builder/schematics-command-module';
|
|
11
|
-
|
|
11
|
+
interface GenerateCommandArgs extends SchematicsCommandArgs {
|
|
12
12
|
schematic?: string;
|
|
13
13
|
}
|
|
14
14
|
export declare class GenerateCommandModule extends SchematicsCommandModule implements CommandModuleImplementation<GenerateCommandArgs> {
|
|
@@ -17,7 +17,8 @@ export declare class GenerateCommandModule extends SchematicsCommandModule imple
|
|
|
17
17
|
describe: string;
|
|
18
18
|
longDescriptionPath?: string | undefined;
|
|
19
19
|
builder(argv: Argv): Promise<Argv<GenerateCommandArgs>>;
|
|
20
|
-
run(options: Options<GenerateCommandArgs> & OtherOptions):
|
|
20
|
+
run(options: Options<GenerateCommandArgs> & OtherOptions): Promise<number | void>;
|
|
21
|
+
private getCollectionName;
|
|
21
22
|
/**
|
|
22
23
|
* Generate a command string to be passed to the command builder.
|
|
23
24
|
*
|
|
@@ -25,3 +26,4 @@ export declare class GenerateCommandModule extends SchematicsCommandModule imple
|
|
|
25
26
|
*/
|
|
26
27
|
private generateCommandString;
|
|
27
28
|
}
|
|
29
|
+
export {};
|
|
@@ -10,37 +10,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.GenerateCommandModule = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
|
|
13
|
-
const
|
|
13
|
+
const command_1 = require("../../command-builder/utilities/command");
|
|
14
14
|
class GenerateCommandModule extends schematics_command_module_1.SchematicsCommandModule {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
|
-
this.command = 'generate
|
|
17
|
+
this.command = 'generate';
|
|
18
18
|
this.aliases = 'g';
|
|
19
19
|
this.describe = 'Generates and/or modifies files based on a schematic.';
|
|
20
20
|
}
|
|
21
21
|
async builder(argv) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
// When we do know the schematic name we need to add the 'schematic'
|
|
30
|
-
// positional option as the schematic will be accessable as a subcommand.
|
|
31
|
-
let localYargs = schematicNameFromArgs
|
|
32
|
-
? baseYargs
|
|
33
|
-
: baseYargs.positional('schematic', {
|
|
34
|
-
describe: 'The schematic or collection:schematic to generate.',
|
|
22
|
+
let localYargs = (await super.builder(argv)).command({
|
|
23
|
+
command: '$0 <schematic>',
|
|
24
|
+
describe: 'Run the provided schematic.',
|
|
25
|
+
builder: (localYargs) => localYargs
|
|
26
|
+
.positional('schematic', {
|
|
27
|
+
describe: 'The [collection:schematic] to run.',
|
|
35
28
|
type: 'string',
|
|
36
29
|
demandOption: true,
|
|
37
|
-
})
|
|
30
|
+
})
|
|
31
|
+
.strict(),
|
|
32
|
+
handler: (options) => this.handler(options),
|
|
33
|
+
});
|
|
38
34
|
const collectionName = await this.getCollectionName();
|
|
39
|
-
const workflow = this.
|
|
35
|
+
const workflow = this.getOrCreateWorkflowForBuilder(collectionName);
|
|
40
36
|
const collection = workflow.engine.createCollection(collectionName);
|
|
41
37
|
const schematicsInCollection = collection.description.schematics;
|
|
42
38
|
// We cannot use `collection.listSchematicNames()` as this doesn't return hidden schematics.
|
|
43
39
|
const schematicNames = new Set(Object.keys(schematicsInCollection).sort());
|
|
40
|
+
const [, schematicNameFromArgs] = this.parseSchematicInfo(
|
|
41
|
+
// positional = [generate, component] or [generate]
|
|
42
|
+
this.context.args.positional[1]);
|
|
44
43
|
if (schematicNameFromArgs && schematicNames.has(schematicNameFromArgs)) {
|
|
45
44
|
// No need to process all schematics since we know which one the user invoked.
|
|
46
45
|
schematicNames.clear();
|
|
@@ -63,11 +62,28 @@ class GenerateCommandModule extends schematics_command_module_1.SchematicsComman
|
|
|
63
62
|
handler: (options) => this.handler({ ...options, schematic: `${collectionName}:${schematicName}` }),
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
|
-
return localYargs;
|
|
65
|
+
return localYargs.demandCommand(1, command_1.demandCommandFailureMessage);
|
|
66
|
+
}
|
|
67
|
+
async run(options) {
|
|
68
|
+
const { dryRun, schematic, defaults, force, interactive, ...schematicOptions } = options;
|
|
69
|
+
const [collectionName = await this.getCollectionName(), schematicName = ''] = this.parseSchematicInfo(schematic);
|
|
70
|
+
return this.runSchematic({
|
|
71
|
+
collectionName,
|
|
72
|
+
schematicName,
|
|
73
|
+
schematicOptions,
|
|
74
|
+
executionOptions: {
|
|
75
|
+
dryRun,
|
|
76
|
+
defaults,
|
|
77
|
+
force,
|
|
78
|
+
interactive,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
67
81
|
}
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
82
|
+
async getCollectionName() {
|
|
83
|
+
const [collectionName = await this.getDefaultSchematicCollection()] = this.parseSchematicInfo(
|
|
84
|
+
// positional = [generate, component] or [generate]
|
|
85
|
+
this.context.args.positional[1]);
|
|
86
|
+
return collectionName;
|
|
71
87
|
}
|
|
72
88
|
/**
|
|
73
89
|
* Generate a command string to be passed to the command builder.
|
|
@@ -8,16 +8,18 @@
|
|
|
8
8
|
import { Argv } from 'yargs';
|
|
9
9
|
import { CommandModuleImplementation, CommandScope, Options, OtherOptions } from '../../command-builder/command-module';
|
|
10
10
|
import { SchematicsCommandArgs, SchematicsCommandModule } from '../../command-builder/schematics-command-module';
|
|
11
|
-
|
|
11
|
+
interface NewCommandArgs extends SchematicsCommandArgs {
|
|
12
12
|
collection?: string;
|
|
13
13
|
}
|
|
14
14
|
export declare class NewCommandModule extends SchematicsCommandModule implements CommandModuleImplementation<NewCommandArgs> {
|
|
15
|
-
|
|
15
|
+
private readonly schematicName;
|
|
16
16
|
static scope: CommandScope;
|
|
17
|
+
protected allowPrivateSchematics: boolean;
|
|
17
18
|
command: string;
|
|
18
19
|
aliases: string;
|
|
19
20
|
describe: string;
|
|
20
21
|
longDescriptionPath?: string | undefined;
|
|
21
22
|
builder(argv: Argv): Promise<Argv<NewCommandArgs>>;
|
|
22
|
-
run(options: Options<NewCommandArgs> & OtherOptions):
|
|
23
|
+
run(options: Options<NewCommandArgs> & OtherOptions): Promise<number | void>;
|
|
23
24
|
}
|
|
25
|
+
export {};
|
package/src/commands/new/cli.js
CHANGED
|
@@ -10,26 +10,56 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.NewCommandModule = void 0;
|
|
11
11
|
const command_module_1 = require("../../command-builder/command-module");
|
|
12
12
|
const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
|
|
13
|
-
const
|
|
13
|
+
const package_manager_1 = require("../../utilities/package-manager");
|
|
14
|
+
const version_1 = require("../../utilities/version");
|
|
14
15
|
class NewCommandModule extends schematics_command_module_1.SchematicsCommandModule {
|
|
15
16
|
constructor() {
|
|
16
17
|
super(...arguments);
|
|
17
18
|
this.schematicName = 'ng-new';
|
|
19
|
+
this.allowPrivateSchematics = true;
|
|
18
20
|
this.command = 'new [name]';
|
|
19
21
|
this.aliases = 'n';
|
|
20
22
|
this.describe = 'Creates a new Angular workspace.';
|
|
21
23
|
}
|
|
22
24
|
async builder(argv) {
|
|
23
|
-
const
|
|
24
|
-
return baseYargs.option('collection', {
|
|
25
|
+
const localYargs = (await super.builder(argv)).option('collection', {
|
|
25
26
|
alias: 'c',
|
|
26
27
|
describe: 'A collection of schematics to use in generating the initial application.',
|
|
27
28
|
type: 'string',
|
|
28
29
|
});
|
|
30
|
+
const { options: { collectionNameFromArgs }, } = this.context.args;
|
|
31
|
+
const collectionName = typeof collectionNameFromArgs === 'string'
|
|
32
|
+
? collectionNameFromArgs
|
|
33
|
+
: await this.getDefaultSchematicCollection();
|
|
34
|
+
const workflow = await this.getOrCreateWorkflowForBuilder(collectionName);
|
|
35
|
+
const collection = workflow.engine.createCollection(collectionName);
|
|
36
|
+
const options = await this.getSchematicOptions(collection, this.schematicName, workflow);
|
|
37
|
+
return this.addSchemaOptionsToCommand(localYargs, options);
|
|
29
38
|
}
|
|
30
|
-
run(options) {
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
async run(options) {
|
|
40
|
+
var _a;
|
|
41
|
+
// Register the version of the CLI in the registry.
|
|
42
|
+
const collectionName = (_a = options.collection) !== null && _a !== void 0 ? _a : (await this.getDefaultSchematicCollection());
|
|
43
|
+
const workflow = await this.getOrCreateWorkflowForExecution(collectionName, options);
|
|
44
|
+
workflow.registry.addSmartDefaultProvider('ng-cli-version', () => version_1.VERSION.full);
|
|
45
|
+
const { dryRun, force, interactive, defaults, collection, ...schematicOptions } = options;
|
|
46
|
+
// Compatibility check for NPM 7
|
|
47
|
+
if (collectionName === '@schematics/angular' &&
|
|
48
|
+
!schematicOptions.skipInstall &&
|
|
49
|
+
(schematicOptions.packageManager === undefined || schematicOptions.packageManager === 'npm')) {
|
|
50
|
+
await (0, package_manager_1.ensureCompatibleNpm)(this.context.root);
|
|
51
|
+
}
|
|
52
|
+
return this.runSchematic({
|
|
53
|
+
collectionName,
|
|
54
|
+
schematicName: this.schematicName,
|
|
55
|
+
schematicOptions,
|
|
56
|
+
executionOptions: {
|
|
57
|
+
dryRun,
|
|
58
|
+
force,
|
|
59
|
+
interactive,
|
|
60
|
+
defaults,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
33
63
|
}
|
|
34
64
|
}
|
|
35
65
|
exports.NewCommandModule = NewCommandModule;
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { Argv } from 'yargs';
|
|
9
|
-
import { CommandModule, CommandScope, Options
|
|
10
|
-
|
|
11
|
-
packages?: string
|
|
9
|
+
import { CommandModule, CommandScope, Options } from '../../command-builder/command-module';
|
|
10
|
+
interface UpdateCommandArgs {
|
|
11
|
+
packages?: string[];
|
|
12
12
|
force: boolean;
|
|
13
13
|
next: boolean;
|
|
14
14
|
'migrate-only'?: boolean;
|
|
@@ -21,9 +21,34 @@ export interface UpdateCommandArgs {
|
|
|
21
21
|
}
|
|
22
22
|
export declare class UpdateCommandModule extends CommandModule<UpdateCommandArgs> {
|
|
23
23
|
static scope: CommandScope;
|
|
24
|
+
protected shouldReportAnalytics: boolean;
|
|
24
25
|
command: string;
|
|
25
26
|
describe: string;
|
|
26
|
-
longDescriptionPath
|
|
27
|
+
longDescriptionPath: string;
|
|
27
28
|
builder(localYargs: Argv): Argv<UpdateCommandArgs>;
|
|
28
|
-
run(options: Options<UpdateCommandArgs>
|
|
29
|
+
run(options: Options<UpdateCommandArgs>): Promise<number | void>;
|
|
30
|
+
private executeSchematic;
|
|
31
|
+
/**
|
|
32
|
+
* @return Whether or not the migration was performed successfully.
|
|
33
|
+
*/
|
|
34
|
+
private executeMigration;
|
|
35
|
+
/**
|
|
36
|
+
* @return Whether or not the migrations were performed successfully.
|
|
37
|
+
*/
|
|
38
|
+
private executeMigrations;
|
|
39
|
+
private executePackageMigrations;
|
|
40
|
+
private migrateOnly;
|
|
41
|
+
private updatePackagesAndMigrate;
|
|
42
|
+
/**
|
|
43
|
+
* @return Whether or not the commit was successful.
|
|
44
|
+
*/
|
|
45
|
+
private commit;
|
|
46
|
+
private checkCleanGit;
|
|
47
|
+
/**
|
|
48
|
+
* Checks if the current installed CLI version is older or newer than a compatible version.
|
|
49
|
+
* @returns the version to install or null when there is no update to install.
|
|
50
|
+
*/
|
|
51
|
+
private checkCLIVersion;
|
|
52
|
+
private getCLIUpdateRunnerVersion;
|
|
29
53
|
}
|
|
54
|
+
export {};
|