@angular/cli 14.0.0-next.6 → 14.0.0-next.7
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/lib/cli/index.d.ts +0 -1
- package/lib/cli/index.js +3 -30
- package/lib/config/schema.json +22 -3
- package/lib/config/workspace-schema.d.ts +5 -0
- package/lib/init.js +2 -5
- package/package.json +15 -18
- package/src/analytics/analytics-collector.js +2 -0
- package/src/analytics/analytics.js +17 -16
- package/src/command-builder/architect-command-module.js +3 -3
- package/src/command-builder/command-module.d.ts +3 -2
- package/src/command-builder/command-runner.d.ts +1 -2
- package/src/command-builder/command-runner.js +50 -33
- package/src/command-builder/schematics-command-module.d.ts +4 -2
- package/src/command-builder/schematics-command-module.js +81 -41
- package/src/commands/add/cli.js +14 -14
- package/src/commands/add/long-description.md +1 -4
- package/src/commands/analytics/cli.d.ts +1 -1
- package/src/commands/analytics/info/cli.d.ts +1 -1
- package/src/commands/analytics/settings/cli.d.ts +1 -1
- package/src/commands/cache/clean/cli.d.ts +17 -0
- package/src/commands/cache/clean/cli.js +32 -0
- package/src/commands/cache/cli.d.ts +17 -0
- package/src/commands/cache/cli.js +38 -0
- package/src/commands/cache/info/cli.d.ts +20 -0
- package/src/commands/cache/info/cli.js +82 -0
- package/src/commands/cache/long-description.md +53 -0
- package/src/commands/cache/settings/cli.d.ts +27 -0
- package/src/commands/cache/settings/cli.js +42 -0
- package/src/commands/cache/utilities.d.ts +11 -0
- package/src/commands/cache/utilities.js +50 -0
- package/src/commands/config/cli.d.ts +1 -1
- package/src/commands/config/cli.js +2 -2
- package/src/commands/doc/cli.d.ts +1 -1
- package/src/commands/e2e/cli.d.ts +1 -1
- package/src/commands/e2e/cli.js +3 -3
- package/src/commands/generate/cli.d.ts +11 -1
- package/src/commands/generate/cli.js +54 -23
- package/src/commands/new/cli.d.ts +2 -0
- package/src/commands/new/cli.js +15 -4
- package/src/commands/update/cli.d.ts +1 -0
- package/src/commands/update/cli.js +50 -21
- package/src/commands/update/schematic/index.js +27 -18
- package/src/commands/version/cli.d.ts +0 -1
- package/src/commands/version/cli.js +4 -23
- package/src/typings-bazel.d.ts +14 -0
- package/src/typings.d.ts +0 -13
- package/src/utilities/config.d.ts +1 -2
- package/src/utilities/config.js +18 -41
- package/src/{analytics/analytics-environment-options.d.ts → utilities/environment-options.d.ts} +3 -0
- package/src/utilities/environment-options.js +24 -0
- package/src/utilities/package-manager.d.ts +33 -5
- package/src/utilities/package-manager.js +241 -71
- package/src/utilities/package-metadata.d.ts +15 -37
- package/src/utilities/package-metadata.js +10 -26
- package/src/utilities/package-tree.d.ts +2 -2
- package/src/utilities/prompt.js +2 -2
- package/bin/postinstall/analytics-prompt.js +0 -27
- package/bin/postinstall/script.js +0 -16
- package/src/analytics/analytics-environment-options.js +0 -20
- package/src/utilities/install-package.d.ts +0 -16
- package/src/utilities/install-package.js +0 -193
- package/src/utilities/package-json.d.ts +0 -249
- package/src/utilities/package-json.js +0 -9
|
@@ -0,0 +1,42 @@
|
|
|
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.CacheEnableModule = exports.CacheDisableModule = void 0;
|
|
11
|
+
const command_module_1 = require("../../../command-builder/command-module");
|
|
12
|
+
const utilities_1 = require("../utilities");
|
|
13
|
+
class CacheDisableModule extends command_module_1.CommandModule {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.command = 'disable';
|
|
17
|
+
this.aliases = 'off';
|
|
18
|
+
this.describe = 'Disables persistent disk cache for all projects in the workspace.';
|
|
19
|
+
}
|
|
20
|
+
builder(localYargs) {
|
|
21
|
+
return localYargs;
|
|
22
|
+
}
|
|
23
|
+
run() {
|
|
24
|
+
(0, utilities_1.updateCacheConfig)('enabled', false);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.CacheDisableModule = CacheDisableModule;
|
|
28
|
+
class CacheEnableModule extends command_module_1.CommandModule {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.command = 'enable';
|
|
32
|
+
this.aliases = 'on';
|
|
33
|
+
this.describe = 'Enables disk cache for all projects in the workspace.';
|
|
34
|
+
}
|
|
35
|
+
builder(localYargs) {
|
|
36
|
+
return localYargs;
|
|
37
|
+
}
|
|
38
|
+
run() {
|
|
39
|
+
(0, utilities_1.updateCacheConfig)('enabled', true);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.CacheEnableModule = CacheEnableModule;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Cache } from '../../../lib/config/workspace-schema';
|
|
9
|
+
import { AngularWorkspace } from '../../utilities/config';
|
|
10
|
+
export declare function updateCacheConfig<K extends keyof Cache>(key: K, value: Cache[K]): void;
|
|
11
|
+
export declare function getCacheConfig(workspace: AngularWorkspace | undefined): Required<Cache>;
|
|
@@ -0,0 +1,50 @@
|
|
|
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.getCacheConfig = exports.updateCacheConfig = void 0;
|
|
11
|
+
const core_1 = require("@angular-devkit/core");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const workspace_schema_1 = require("../../../lib/config/workspace-schema");
|
|
14
|
+
const config_1 = require("../../utilities/config");
|
|
15
|
+
function updateCacheConfig(key, value) {
|
|
16
|
+
const [localWorkspace] = (0, config_1.getWorkspaceRaw)('local');
|
|
17
|
+
if (!localWorkspace) {
|
|
18
|
+
throw new Error('Cannot find workspace configuration file.');
|
|
19
|
+
}
|
|
20
|
+
localWorkspace.modify(['cli', 'cache', key], value);
|
|
21
|
+
localWorkspace.save();
|
|
22
|
+
}
|
|
23
|
+
exports.updateCacheConfig = updateCacheConfig;
|
|
24
|
+
function getCacheConfig(workspace) {
|
|
25
|
+
if (!workspace) {
|
|
26
|
+
throw new Error(`Cannot retrieve cache configuration as workspace is not defined.`);
|
|
27
|
+
}
|
|
28
|
+
const defaultSettings = {
|
|
29
|
+
path: (0, path_1.resolve)(workspace.basePath, '.angular/cache'),
|
|
30
|
+
environment: workspace_schema_1.Environment.Local,
|
|
31
|
+
enabled: true,
|
|
32
|
+
};
|
|
33
|
+
const cliSetting = workspace.extensions['cli'];
|
|
34
|
+
if (!cliSetting || !(0, core_1.isJsonObject)(cliSetting)) {
|
|
35
|
+
return defaultSettings;
|
|
36
|
+
}
|
|
37
|
+
const cacheSettings = cliSetting['cache'];
|
|
38
|
+
if (!(0, core_1.isJsonObject)(cacheSettings)) {
|
|
39
|
+
return defaultSettings;
|
|
40
|
+
}
|
|
41
|
+
const { path = defaultSettings.path, environment = defaultSettings.environment, enabled = defaultSettings.enabled,
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
} = cacheSettings;
|
|
44
|
+
return {
|
|
45
|
+
path: (0, path_1.resolve)(workspace.basePath, path),
|
|
46
|
+
environment,
|
|
47
|
+
enabled,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
exports.getCacheConfig = getCacheConfig;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { Argv } from 'yargs';
|
|
9
9
|
import { CommandModule, CommandModuleImplementation, Options } from '../../command-builder/command-module';
|
|
10
10
|
interface ConfigCommandArgs {
|
|
11
|
-
'json-path'
|
|
11
|
+
'json-path'?: string;
|
|
12
12
|
value?: string;
|
|
13
13
|
global?: boolean;
|
|
14
14
|
}
|
|
@@ -16,7 +16,7 @@ const json_file_1 = require("../../utilities/json-file");
|
|
|
16
16
|
class ConfigCommandModule extends command_module_1.CommandModule {
|
|
17
17
|
constructor() {
|
|
18
18
|
super(...arguments);
|
|
19
|
-
this.command = 'config
|
|
19
|
+
this.command = 'config [json-path] [value]';
|
|
20
20
|
this.describe = 'Retrieves or sets Angular configuration values in the angular.json file for the workspace.';
|
|
21
21
|
this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
|
|
22
22
|
}
|
|
@@ -26,7 +26,6 @@ class ConfigCommandModule extends command_module_1.CommandModule {
|
|
|
26
26
|
description: `The configuration key to set or query, in JSON path format. ` +
|
|
27
27
|
`For example: "a[3].foo.bar[2]". If no new value is provided, returns the current value of this key.`,
|
|
28
28
|
type: 'string',
|
|
29
|
-
demandOption: true,
|
|
30
29
|
})
|
|
31
30
|
.positional('value', {
|
|
32
31
|
description: 'If provided, a new value for the given configuration key.',
|
|
@@ -79,6 +78,7 @@ class ConfigCommandModule extends command_module_1.CommandModule {
|
|
|
79
78
|
const validCliPaths = new Map([
|
|
80
79
|
['cli.warnings.versionMismatch', undefined],
|
|
81
80
|
['cli.defaultCollection', undefined],
|
|
81
|
+
['cli.schematicCollections', undefined],
|
|
82
82
|
['cli.packageManager', undefined],
|
|
83
83
|
['cli.analytics', undefined],
|
|
84
84
|
['cli.analyticsSharing.tracking', undefined],
|
|
@@ -16,7 +16,7 @@ export declare class DocCommandModule extends CommandModule<DocCommandArgs> impl
|
|
|
16
16
|
command: string;
|
|
17
17
|
aliases: string[];
|
|
18
18
|
describe: string;
|
|
19
|
-
longDescriptionPath?: string
|
|
19
|
+
longDescriptionPath?: string;
|
|
20
20
|
builder(localYargs: Argv): Argv<DocCommandArgs>;
|
|
21
21
|
run(options: Options<DocCommandArgs>): Promise<number | void>;
|
|
22
22
|
}
|
package/src/commands/e2e/cli.js
CHANGED
|
@@ -16,14 +16,14 @@ class E2eCommandModule extends architect_command_module_1.ArchitectCommandModule
|
|
|
16
16
|
this.multiTarget = true;
|
|
17
17
|
this.missingErrorTarget = core_1.tags.stripIndents `
|
|
18
18
|
Cannot find "e2e" target for the specified project.
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
You should add a package that implements end-to-end testing capabilities.
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
For example:
|
|
23
23
|
Cypress: ng add @cypress/schematic
|
|
24
24
|
Nightwatch: ng add @nightwatch/schematics
|
|
25
25
|
WebdriverIO: ng add @wdio/schematics
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
More options will be added to the list as they become available.
|
|
28
28
|
`;
|
|
29
29
|
this.command = 'e2e [project]';
|
|
@@ -18,12 +18,22 @@ export declare class GenerateCommandModule extends SchematicsCommandModule imple
|
|
|
18
18
|
longDescriptionPath?: string | undefined;
|
|
19
19
|
builder(argv: Argv): Promise<Argv<GenerateCommandArgs>>;
|
|
20
20
|
run(options: Options<GenerateCommandArgs> & OtherOptions): Promise<number | void>;
|
|
21
|
-
private
|
|
21
|
+
private getCollectionNames;
|
|
22
22
|
/**
|
|
23
23
|
* Generate a command string to be passed to the command builder.
|
|
24
24
|
*
|
|
25
25
|
* @example `component [name]` or `@schematics/angular:component [name]`.
|
|
26
26
|
*/
|
|
27
27
|
private generateCommandString;
|
|
28
|
+
/**
|
|
29
|
+
* Get schematics that can to be registered as subcommands.
|
|
30
|
+
*/
|
|
31
|
+
private getSchematics;
|
|
32
|
+
/**
|
|
33
|
+
* Get schematics that should to be registered as subcommands.
|
|
34
|
+
*
|
|
35
|
+
* @returns a sorted list of schematic that needs to be registered as subcommands.
|
|
36
|
+
*/
|
|
37
|
+
private getSchematicsToRegister;
|
|
28
38
|
}
|
|
29
39
|
export {};
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.GenerateCommandModule = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
|
+
const command_module_1 = require("../../command-builder/command-module");
|
|
12
13
|
const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
|
|
13
14
|
const command_1 = require("../../command-builder/utilities/command");
|
|
14
15
|
class GenerateCommandModule extends schematics_command_module_1.SchematicsCommandModule {
|
|
@@ -31,26 +32,14 @@ class GenerateCommandModule extends schematics_command_module_1.SchematicsComman
|
|
|
31
32
|
.strict(),
|
|
32
33
|
handler: (options) => this.handler(options),
|
|
33
34
|
});
|
|
34
|
-
const collectionName
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// We cannot use `collection.listSchematicNames()` as this doesn't return hidden schematics.
|
|
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]);
|
|
43
|
-
if (schematicNameFromArgs && schematicNames.has(schematicNameFromArgs)) {
|
|
44
|
-
// No need to process all schematics since we know which one the user invoked.
|
|
45
|
-
schematicNames.clear();
|
|
46
|
-
schematicNames.add(schematicNameFromArgs);
|
|
47
|
-
}
|
|
48
|
-
for (const schematicName of schematicNames) {
|
|
49
|
-
const { description: { schemaJson, aliases: schematicAliases, hidden: schematicHidden }, } = collection.createSchematic(schematicName, true);
|
|
35
|
+
for (const [schematicName, collectionName] of await this.getSchematicsToRegister()) {
|
|
36
|
+
const workflow = this.getOrCreateWorkflowForBuilder(collectionName);
|
|
37
|
+
const collection = workflow.engine.createCollection(collectionName);
|
|
38
|
+
const { description: { schemaJson, aliases: schematicAliases, hidden: schematicHidden, description: schematicDescription, }, } = collection.createSchematic(schematicName, true);
|
|
50
39
|
if (!schemaJson) {
|
|
51
40
|
continue;
|
|
52
41
|
}
|
|
53
|
-
const {
|
|
42
|
+
const { 'x-deprecated': xDeprecated, description = schematicDescription, aliases = schematicAliases, hidden = schematicHidden, } = schemaJson;
|
|
54
43
|
const options = await this.getSchematicOptions(collection, schematicName, workflow);
|
|
55
44
|
localYargs = localYargs.command({
|
|
56
45
|
command: await this.generateCommandString(collectionName, schematicName, options),
|
|
@@ -66,7 +55,10 @@ class GenerateCommandModule extends schematics_command_module_1.SchematicsComman
|
|
|
66
55
|
}
|
|
67
56
|
async run(options) {
|
|
68
57
|
const { dryRun, schematic, defaults, force, interactive, ...schematicOptions } = options;
|
|
69
|
-
const [collectionName
|
|
58
|
+
const [collectionName, schematicName] = this.parseSchematicInfo(schematic);
|
|
59
|
+
if (!collectionName || !schematicName) {
|
|
60
|
+
throw new command_module_1.CommandModuleError('A collection and schematic is required during execution.');
|
|
61
|
+
}
|
|
70
62
|
return this.runSchematic({
|
|
71
63
|
collectionName,
|
|
72
64
|
schematicName,
|
|
@@ -79,11 +71,11 @@ class GenerateCommandModule extends schematics_command_module_1.SchematicsComman
|
|
|
79
71
|
},
|
|
80
72
|
});
|
|
81
73
|
}
|
|
82
|
-
async
|
|
83
|
-
const [collectionName
|
|
74
|
+
async getCollectionNames() {
|
|
75
|
+
const [collectionName] = this.parseSchematicInfo(
|
|
84
76
|
// positional = [generate, component] or [generate]
|
|
85
77
|
this.context.args.positional[1]);
|
|
86
|
-
return collectionName;
|
|
78
|
+
return collectionName ? [collectionName] : [...(await this.getSchematicCollections())];
|
|
87
79
|
}
|
|
88
80
|
/**
|
|
89
81
|
* Generate a command string to be passed to the command builder.
|
|
@@ -95,10 +87,13 @@ class GenerateCommandModule extends schematics_command_module_1.SchematicsComman
|
|
|
95
87
|
// positional = [generate, component] or [generate]
|
|
96
88
|
this.context.args.positional[1]);
|
|
97
89
|
const dasherizedSchematicName = core_1.strings.dasherize(schematicName);
|
|
98
|
-
|
|
90
|
+
const schematicCollectionsFromConfig = await this.getSchematicCollections();
|
|
91
|
+
const collectionNames = await this.getCollectionNames();
|
|
92
|
+
// Only add the collection name as part of the command when it's not a known
|
|
93
|
+
// schematics collection or when it has been provided via the CLI.
|
|
99
94
|
// Ex:`ng generate @schematics/angular:component`
|
|
100
95
|
const commandName = !!collectionNameFromArgs ||
|
|
101
|
-
|
|
96
|
+
!collectionNames.some((c) => schematicCollectionsFromConfig.has(c))
|
|
102
97
|
? collectionName + ':' + dasherizedSchematicName
|
|
103
98
|
: dasherizedSchematicName;
|
|
104
99
|
const positionalArgs = options
|
|
@@ -110,5 +105,41 @@ class GenerateCommandModule extends schematics_command_module_1.SchematicsComman
|
|
|
110
105
|
.join(' ');
|
|
111
106
|
return `${commandName}${positionalArgs ? ' ' + positionalArgs : ''}`;
|
|
112
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Get schematics that can to be registered as subcommands.
|
|
110
|
+
*/
|
|
111
|
+
async *getSchematics() {
|
|
112
|
+
const seenNames = new Set();
|
|
113
|
+
for (const collectionName of await this.getCollectionNames()) {
|
|
114
|
+
const workflow = this.getOrCreateWorkflowForBuilder(collectionName);
|
|
115
|
+
const collection = workflow.engine.createCollection(collectionName);
|
|
116
|
+
for (const schematicName of collection.listSchematicNames(true /** includeHidden */)) {
|
|
117
|
+
// If a schematic with this same name is already registered skip.
|
|
118
|
+
if (!seenNames.has(schematicName)) {
|
|
119
|
+
seenNames.add(schematicName);
|
|
120
|
+
yield { schematicName, collectionName };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get schematics that should to be registered as subcommands.
|
|
127
|
+
*
|
|
128
|
+
* @returns a sorted list of schematic that needs to be registered as subcommands.
|
|
129
|
+
*/
|
|
130
|
+
async getSchematicsToRegister() {
|
|
131
|
+
const schematicsToRegister = [];
|
|
132
|
+
const [, schematicNameFromArgs] = this.parseSchematicInfo(
|
|
133
|
+
// positional = [generate, component] or [generate]
|
|
134
|
+
this.context.args.positional[1]);
|
|
135
|
+
for await (const { schematicName, collectionName } of this.getSchematics()) {
|
|
136
|
+
if (schematicName === schematicNameFromArgs) {
|
|
137
|
+
return [[schematicName, collectionName]];
|
|
138
|
+
}
|
|
139
|
+
schematicsToRegister.push([schematicName, collectionName]);
|
|
140
|
+
}
|
|
141
|
+
// Didn't find the schematic or no schematic name was provided Ex: `ng generate --help`.
|
|
142
|
+
return schematicsToRegister.sort(([nameA], [nameB]) => nameA.localeCompare(nameB, undefined, { sensitivity: 'accent' }));
|
|
143
|
+
}
|
|
113
144
|
}
|
|
114
145
|
exports.GenerateCommandModule = GenerateCommandModule;
|
|
@@ -21,5 +21,7 @@ export declare class NewCommandModule extends SchematicsCommandModule implements
|
|
|
21
21
|
longDescriptionPath?: string | undefined;
|
|
22
22
|
builder(argv: Argv): Promise<Argv<NewCommandArgs>>;
|
|
23
23
|
run(options: Options<NewCommandArgs> & OtherOptions): Promise<number | void>;
|
|
24
|
+
/** Find a collection from config that has an `ng-new` schematic. */
|
|
25
|
+
private getCollectionFromConfig;
|
|
24
26
|
}
|
|
25
27
|
export {};
|
package/src/commands/new/cli.js
CHANGED
|
@@ -10,7 +10,6 @@ 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 package_manager_1 = require("../../utilities/package-manager");
|
|
14
13
|
const version_1 = require("../../utilities/version");
|
|
15
14
|
class NewCommandModule extends schematics_command_module_1.SchematicsCommandModule {
|
|
16
15
|
constructor() {
|
|
@@ -30,7 +29,7 @@ class NewCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
30
29
|
const { options: { collectionNameFromArgs }, } = this.context.args;
|
|
31
30
|
const collectionName = typeof collectionNameFromArgs === 'string'
|
|
32
31
|
? collectionNameFromArgs
|
|
33
|
-
: await this.
|
|
32
|
+
: await this.getCollectionFromConfig();
|
|
34
33
|
const workflow = await this.getOrCreateWorkflowForBuilder(collectionName);
|
|
35
34
|
const collection = workflow.engine.createCollection(collectionName);
|
|
36
35
|
const options = await this.getSchematicOptions(collection, this.schematicName, workflow);
|
|
@@ -39,7 +38,7 @@ class NewCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
39
38
|
async run(options) {
|
|
40
39
|
var _a;
|
|
41
40
|
// Register the version of the CLI in the registry.
|
|
42
|
-
const collectionName = (_a = options.collection) !== null && _a !== void 0 ? _a : (await this.
|
|
41
|
+
const collectionName = (_a = options.collection) !== null && _a !== void 0 ? _a : (await this.getCollectionFromConfig());
|
|
43
42
|
const workflow = await this.getOrCreateWorkflowForExecution(collectionName, options);
|
|
44
43
|
workflow.registry.addSmartDefaultProvider('ng-cli-version', () => version_1.VERSION.full);
|
|
45
44
|
const { dryRun, force, interactive, defaults, collection, ...schematicOptions } = options;
|
|
@@ -47,7 +46,7 @@ class NewCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
47
46
|
if (collectionName === '@schematics/angular' &&
|
|
48
47
|
!schematicOptions.skipInstall &&
|
|
49
48
|
(schematicOptions.packageManager === undefined || schematicOptions.packageManager === 'npm')) {
|
|
50
|
-
|
|
49
|
+
this.context.packageManager.ensureCompatibility();
|
|
51
50
|
}
|
|
52
51
|
return this.runSchematic({
|
|
53
52
|
collectionName,
|
|
@@ -61,6 +60,18 @@ class NewCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
61
60
|
},
|
|
62
61
|
});
|
|
63
62
|
}
|
|
63
|
+
/** Find a collection from config that has an `ng-new` schematic. */
|
|
64
|
+
async getCollectionFromConfig() {
|
|
65
|
+
for (const collectionName of await this.getSchematicCollections()) {
|
|
66
|
+
const workflow = this.getOrCreateWorkflowForBuilder(collectionName);
|
|
67
|
+
const collection = workflow.engine.createCollection(collectionName);
|
|
68
|
+
const schematicsInCollection = collection.description.schematics;
|
|
69
|
+
if (Object.keys(schematicsInCollection).includes(this.schematicName)) {
|
|
70
|
+
return collectionName;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return schematics_command_module_1.DEFAULT_SCHEMATICS_COLLECTION;
|
|
74
|
+
}
|
|
64
75
|
}
|
|
65
76
|
exports.NewCommandModule = NewCommandModule;
|
|
66
77
|
NewCommandModule.scope = command_module_1.CommandScope.Out;
|
|
@@ -48,20 +48,11 @@ const command_module_1 = require("../../command-builder/command-module");
|
|
|
48
48
|
const schematic_engine_host_1 = require("../../command-builder/utilities/schematic-engine-host");
|
|
49
49
|
const schematic_workflow_1 = require("../../command-builder/utilities/schematic-workflow");
|
|
50
50
|
const color_1 = require("../../utilities/color");
|
|
51
|
-
const
|
|
51
|
+
const environment_options_1 = require("../../utilities/environment-options");
|
|
52
52
|
const log_file_1 = require("../../utilities/log-file");
|
|
53
|
-
const package_manager_1 = require("../../utilities/package-manager");
|
|
54
53
|
const package_metadata_1 = require("../../utilities/package-metadata");
|
|
55
54
|
const package_tree_1 = require("../../utilities/package-tree");
|
|
56
55
|
const version_1 = require("../../utilities/version");
|
|
57
|
-
/**
|
|
58
|
-
* Disable CLI version mismatch checks and forces usage of the invoked CLI
|
|
59
|
-
* instead of invoking the local installed version.
|
|
60
|
-
*/
|
|
61
|
-
const disableVersionCheckEnv = process.env['NG_DISABLE_VERSION_CHECK'];
|
|
62
|
-
const disableVersionCheck = disableVersionCheckEnv !== undefined &&
|
|
63
|
-
disableVersionCheckEnv !== '0' &&
|
|
64
|
-
disableVersionCheckEnv.toLowerCase() !== 'false';
|
|
65
56
|
const ANGULAR_PACKAGES_REGEXP = /^@(?:angular|nguniversal)\//;
|
|
66
57
|
const UPDATE_SCHEMATIC_COLLECTION = path.join(__dirname, 'schematic/collection.json');
|
|
67
58
|
class UpdateCommandModule extends command_module_1.CommandModule {
|
|
@@ -156,14 +147,14 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
156
147
|
async run(options) {
|
|
157
148
|
var _a, _b;
|
|
158
149
|
const { logger, packageManager } = this.context;
|
|
159
|
-
|
|
150
|
+
packageManager.ensureCompatibility();
|
|
160
151
|
// Check if the current installed CLI version is older than the latest compatible version.
|
|
161
|
-
if (!disableVersionCheck) {
|
|
152
|
+
if (!environment_options_1.disableVersionCheck) {
|
|
162
153
|
const cliVersionToInstall = await this.checkCLIVersion(options.packages, options.verbose, options.next);
|
|
163
154
|
if (cliVersionToInstall) {
|
|
164
155
|
logger.warn('The installed Angular CLI version is outdated.\n' +
|
|
165
156
|
`Installing a temporary Angular CLI versioned ${cliVersionToInstall} to perform the update.`);
|
|
166
|
-
return
|
|
157
|
+
return this.runTempBinary(`@angular/cli@${cliVersionToInstall}`, process.argv.slice(2));
|
|
167
158
|
}
|
|
168
159
|
}
|
|
169
160
|
const packages = [];
|
|
@@ -193,12 +184,12 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
193
184
|
return 1;
|
|
194
185
|
}
|
|
195
186
|
}
|
|
196
|
-
logger.info(`Using package manager:
|
|
187
|
+
logger.info(`Using package manager: ${color_1.colors.grey(packageManager.name)}`);
|
|
197
188
|
logger.info('Collecting installed dependencies...');
|
|
198
189
|
const rootDependencies = await (0, package_tree_1.getProjectDependencies)(this.context.root);
|
|
199
190
|
logger.info(`Found ${rootDependencies.size} dependencies.`);
|
|
200
191
|
const workflow = new tools_1.NodeWorkflow(this.context.root, {
|
|
201
|
-
packageManager:
|
|
192
|
+
packageManager: packageManager.name,
|
|
202
193
|
packageManagerForce: options.force,
|
|
203
194
|
// __dirname -> favor @schematics/update from this package
|
|
204
195
|
// Otherwise, use packages from the active workspace (migrations)
|
|
@@ -212,7 +203,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
212
203
|
force: options.force,
|
|
213
204
|
next: options.next,
|
|
214
205
|
verbose: options.verbose,
|
|
215
|
-
packageManager,
|
|
206
|
+
packageManager: packageManager.name,
|
|
216
207
|
packages: [],
|
|
217
208
|
});
|
|
218
209
|
return success ? 0 : 1;
|
|
@@ -509,7 +500,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
509
500
|
verbose: options.verbose,
|
|
510
501
|
force: options.force,
|
|
511
502
|
next: options.next,
|
|
512
|
-
packageManager: this.context.packageManager,
|
|
503
|
+
packageManager: this.context.packageManager.name,
|
|
513
504
|
packages: packagesToUpdate,
|
|
514
505
|
});
|
|
515
506
|
if (success) {
|
|
@@ -521,9 +512,9 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
521
512
|
});
|
|
522
513
|
}
|
|
523
514
|
catch { }
|
|
524
|
-
const
|
|
525
|
-
if (
|
|
526
|
-
return
|
|
515
|
+
const installationSuccess = await this.context.packageManager.installAll(options.force ? ['--force'] : [], this.context.root);
|
|
516
|
+
if (!installationSuccess) {
|
|
517
|
+
return 1;
|
|
527
518
|
}
|
|
528
519
|
}
|
|
529
520
|
if (success && options.createCommits) {
|
|
@@ -667,7 +658,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
667
658
|
async checkCLIVersion(packagesToUpdate, verbose = false, next = false) {
|
|
668
659
|
const { version } = await (0, package_metadata_1.fetchPackageManifest)(`@angular/cli@${this.getCLIUpdateRunnerVersion(typeof packagesToUpdate === 'string' ? [packagesToUpdate] : packagesToUpdate, next)}`, this.context.logger, {
|
|
669
660
|
verbose,
|
|
670
|
-
usingYarn: this.context.packageManager === workspace_schema_1.PackageManager.Yarn,
|
|
661
|
+
usingYarn: this.context.packageManager.name === workspace_schema_1.PackageManager.Yarn,
|
|
671
662
|
});
|
|
672
663
|
return version_1.VERSION.full === version ? null : version;
|
|
673
664
|
}
|
|
@@ -694,6 +685,44 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
694
685
|
// We end up using Angular ClI v13 to run the migrations if we run the migrations using the CLI installed major version + 1 logic.
|
|
695
686
|
return version_1.VERSION.major;
|
|
696
687
|
}
|
|
688
|
+
async runTempBinary(packageName, args = []) {
|
|
689
|
+
const { success, tempNodeModules } = await this.context.packageManager.installTemp(packageName);
|
|
690
|
+
if (!success) {
|
|
691
|
+
return 1;
|
|
692
|
+
}
|
|
693
|
+
// Remove version/tag etc... from package name
|
|
694
|
+
// Ex: @angular/cli@latest -> @angular/cli
|
|
695
|
+
const packageNameNoVersion = packageName.substring(0, packageName.lastIndexOf('@'));
|
|
696
|
+
const pkgLocation = (0, path_1.join)(tempNodeModules, packageNameNoVersion);
|
|
697
|
+
const packageJsonPath = (0, path_1.join)(pkgLocation, 'package.json');
|
|
698
|
+
// Get a binary location for this package
|
|
699
|
+
let binPath;
|
|
700
|
+
if ((0, fs_1.existsSync)(packageJsonPath)) {
|
|
701
|
+
const content = await fs_1.promises.readFile(packageJsonPath, 'utf-8');
|
|
702
|
+
if (content) {
|
|
703
|
+
const { bin = {} } = JSON.parse(content);
|
|
704
|
+
const binKeys = Object.keys(bin);
|
|
705
|
+
if (binKeys.length) {
|
|
706
|
+
binPath = (0, path_1.resolve)(pkgLocation, bin[binKeys[0]]);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
if (!binPath) {
|
|
711
|
+
throw new Error(`Cannot locate bin for temporary package: ${packageNameNoVersion}.`);
|
|
712
|
+
}
|
|
713
|
+
const { status, error } = (0, child_process_1.spawnSync)(process.execPath, [binPath, ...args], {
|
|
714
|
+
stdio: 'inherit',
|
|
715
|
+
env: {
|
|
716
|
+
...process.env,
|
|
717
|
+
NG_DISABLE_VERSION_CHECK: 'true',
|
|
718
|
+
NG_CLI_ANALYTICS: 'false',
|
|
719
|
+
},
|
|
720
|
+
});
|
|
721
|
+
if (status === null && error) {
|
|
722
|
+
throw error;
|
|
723
|
+
}
|
|
724
|
+
return status !== null && status !== void 0 ? status : 0;
|
|
725
|
+
}
|
|
697
726
|
}
|
|
698
727
|
exports.UpdateCommandModule = UpdateCommandModule;
|
|
699
728
|
UpdateCommandModule.scope = command_module_1.CommandScope.In;
|
|
@@ -286,6 +286,7 @@ function _getUpdateMetadata(packageJson, logger) {
|
|
|
286
286
|
}
|
|
287
287
|
else if (typeof packageGroup == 'object' &&
|
|
288
288
|
packageGroup &&
|
|
289
|
+
!Array.isArray(packageGroup) &&
|
|
289
290
|
Object.values(packageGroup).every((x) => typeof x == 'string')) {
|
|
290
291
|
result.packageGroup = packageGroup;
|
|
291
292
|
}
|
|
@@ -362,23 +363,26 @@ function _usageMessage(options, infoMap, logger) {
|
|
|
362
363
|
})
|
|
363
364
|
.filter(({ info, version, target }) => (target === null || target === void 0 ? void 0 : target['ng-update']) && semver.compare(info.installed.version, version) < 0)
|
|
364
365
|
.map(({ name, info, version, tag, target }) => {
|
|
365
|
-
var _a;
|
|
366
|
+
var _a, _b, _c;
|
|
366
367
|
// Look for packageGroup.
|
|
367
|
-
const packageGroup = target['ng-update']['packageGroup'];
|
|
368
|
+
const packageGroup = (_a = target['ng-update']) === null || _a === void 0 ? void 0 : _a['packageGroup'];
|
|
368
369
|
if (packageGroup) {
|
|
369
|
-
const
|
|
370
|
+
const packageGroupNames = Array.isArray(packageGroup)
|
|
371
|
+
? packageGroup
|
|
372
|
+
: Object.keys(packageGroup);
|
|
373
|
+
const packageGroupName = ((_b = target['ng-update']) === null || _b === void 0 ? void 0 : _b['packageGroupName']) || packageGroupNames[0];
|
|
370
374
|
if (packageGroupName) {
|
|
371
375
|
if (packageGroups.has(name)) {
|
|
372
376
|
return null;
|
|
373
377
|
}
|
|
374
|
-
|
|
378
|
+
packageGroupNames.forEach((x) => packageGroups.set(x, packageGroupName));
|
|
375
379
|
packageGroups.set(packageGroupName, packageGroupName);
|
|
376
380
|
name = packageGroupName;
|
|
377
381
|
}
|
|
378
382
|
}
|
|
379
383
|
let command = `ng update ${name}`;
|
|
380
384
|
if (!tag) {
|
|
381
|
-
command += `@${((
|
|
385
|
+
command += `@${((_c = semver.parse(version)) === null || _c === void 0 ? void 0 : _c.major) || version}`;
|
|
382
386
|
}
|
|
383
387
|
else if (tag == 'next') {
|
|
384
388
|
command += ' --next';
|
|
@@ -508,29 +512,34 @@ function _addPackageGroup(tree, packages, allDependencies, npmPackageJson, logge
|
|
|
508
512
|
if (!ngUpdateMetadata) {
|
|
509
513
|
return;
|
|
510
514
|
}
|
|
511
|
-
|
|
515
|
+
const packageGroup = ngUpdateMetadata['packageGroup'];
|
|
512
516
|
if (!packageGroup) {
|
|
513
517
|
return;
|
|
514
518
|
}
|
|
519
|
+
let packageGroupNormalized = {};
|
|
515
520
|
if (Array.isArray(packageGroup) && !packageGroup.some((x) => typeof x != 'string')) {
|
|
516
|
-
|
|
521
|
+
packageGroupNormalized = packageGroup.reduce((acc, curr) => {
|
|
517
522
|
acc[curr] = maybePackage;
|
|
518
523
|
return acc;
|
|
519
524
|
}, {});
|
|
520
525
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
packageGroup
|
|
524
|
-
Object.values(packageGroup).
|
|
525
|
-
|
|
526
|
+
else if (typeof packageGroup == 'object' &&
|
|
527
|
+
packageGroup &&
|
|
528
|
+
!Array.isArray(packageGroup) &&
|
|
529
|
+
Object.values(packageGroup).every((x) => typeof x == 'string')) {
|
|
530
|
+
packageGroupNormalized = packageGroup;
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
logger.warn(`packageGroup metadata of package ${npmPackageJson.name} is malformed. Ignoring.`);
|
|
526
534
|
return;
|
|
527
535
|
}
|
|
528
|
-
Object.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
.
|
|
532
|
-
|
|
533
|
-
|
|
536
|
+
for (const [name, value] of Object.entries(packageGroupNormalized)) {
|
|
537
|
+
// Don't override names from the command line.
|
|
538
|
+
// Remove packages that aren't installed.
|
|
539
|
+
if (!packages.has(name) && allDependencies.has(name)) {
|
|
540
|
+
packages.set(name, value);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
534
543
|
}
|
|
535
544
|
/**
|
|
536
545
|
* Add peer dependencies of packages on the command line to the list of packages to update.
|