@angular/cli 11.1.4 → 11.2.0
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/commands/add-impl.js +40 -14
- package/commands/doc-impl.js +2 -2
- package/commands/lint-long.md +1 -1
- package/commands/new-impl.js +0 -2
- package/commands/update-impl.js +2 -18
- package/models/schematic-command.js +9 -10
- package/models/schematic-engine-host.d.ts +15 -0
- package/models/schematic-engine-host.js +155 -0
- package/package.json +15 -14
- package/utilities/install-package.d.ts +2 -2
- package/utilities/install-package.js +2 -2
- package/utilities/package-manager.js +5 -4
- package/utilities/spinner.d.ts +20 -0
- package/utilities/spinner.js +51 -0
package/commands/add-impl.js
CHANGED
|
@@ -19,6 +19,7 @@ const color_1 = require("../utilities/color");
|
|
|
19
19
|
const install_package_1 = require("../utilities/install-package");
|
|
20
20
|
const package_manager_1 = require("../utilities/package-manager");
|
|
21
21
|
const package_metadata_1 = require("../utilities/package-metadata");
|
|
22
|
+
const spinner_1 = require("../utilities/spinner");
|
|
22
23
|
const npa = require('npm-package-arg');
|
|
23
24
|
class AddCommand extends schematic_command_1.SchematicCommand {
|
|
24
25
|
constructor() {
|
|
@@ -71,11 +72,15 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
71
72
|
return this.executeSchematic(packageIdentifier.name, options['--']);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
75
|
+
const spinner = new spinner_1.Spinner();
|
|
76
|
+
spinner.start('Determining package manager...');
|
|
74
77
|
const packageManager = await package_manager_1.getPackageManager(this.context.root);
|
|
75
78
|
const usingYarn = packageManager === schema_1.PackageManager.Yarn;
|
|
79
|
+
spinner.info(`Using package manager: ${color_1.colors.grey(packageManager)}`);
|
|
76
80
|
if (packageIdentifier.type === 'tag' && !packageIdentifier.rawSpec) {
|
|
77
81
|
// only package name provided; search for viable version
|
|
78
82
|
// plus special cases for packages that did not have peer deps setup
|
|
83
|
+
spinner.start('Searching for compatible package version...');
|
|
79
84
|
let packageMetadata;
|
|
80
85
|
try {
|
|
81
86
|
packageMetadata = await package_metadata_1.fetchPackageMetadata(packageIdentifier.name, this.logger, {
|
|
@@ -85,7 +90,7 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
85
90
|
});
|
|
86
91
|
}
|
|
87
92
|
catch (e) {
|
|
88
|
-
|
|
93
|
+
spinner.fail('Unable to load package information from registry: ' + e.message);
|
|
89
94
|
return 1;
|
|
90
95
|
}
|
|
91
96
|
const latestManifest = packageMetadata.tags['latest'];
|
|
@@ -99,6 +104,10 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
99
104
|
packageIdentifier = npa.resolve('@angular/pwa', '0.12');
|
|
100
105
|
}
|
|
101
106
|
}
|
|
107
|
+
else {
|
|
108
|
+
packageIdentifier = npa.resolve(latestManifest.name, latestManifest.version);
|
|
109
|
+
}
|
|
110
|
+
spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier)}.`);
|
|
102
111
|
}
|
|
103
112
|
else if (!latestManifest || (await this.hasMismatchedPeer(latestManifest))) {
|
|
104
113
|
// 'latest' is invalid so search for most recent matching package
|
|
@@ -112,16 +121,22 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
112
121
|
}
|
|
113
122
|
}
|
|
114
123
|
if (!newIdentifier) {
|
|
115
|
-
|
|
124
|
+
spinner.warn("Unable to find compatible package. Using 'latest'.");
|
|
116
125
|
}
|
|
117
126
|
else {
|
|
118
127
|
packageIdentifier = newIdentifier;
|
|
128
|
+
spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier)}.`);
|
|
119
129
|
}
|
|
120
130
|
}
|
|
131
|
+
else {
|
|
132
|
+
packageIdentifier = npa.resolve(latestManifest.name, latestManifest.version);
|
|
133
|
+
spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier)}.`);
|
|
134
|
+
}
|
|
121
135
|
}
|
|
122
136
|
let collectionName = packageIdentifier.name;
|
|
123
137
|
let savePackage;
|
|
124
138
|
try {
|
|
139
|
+
spinner.start('Loading package information from registry...');
|
|
125
140
|
const manifest = await package_metadata_1.fetchPackageManifest(packageIdentifier, this.logger, {
|
|
126
141
|
registry: options.registry,
|
|
127
142
|
verbose: options.verbose,
|
|
@@ -130,24 +145,35 @@ class AddCommand extends schematic_command_1.SchematicCommand {
|
|
|
130
145
|
savePackage = (_a = manifest['ng-add']) === null || _a === void 0 ? void 0 : _a.save;
|
|
131
146
|
collectionName = manifest.name;
|
|
132
147
|
if (await this.hasMismatchedPeer(manifest)) {
|
|
133
|
-
|
|
148
|
+
spinner.warn('Package has unmet peer dependencies. Adding the package may not succeed.');
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
spinner.succeed(`Package information loaded.`);
|
|
134
152
|
}
|
|
135
153
|
}
|
|
136
154
|
catch (e) {
|
|
137
|
-
|
|
155
|
+
spinner.fail(`Unable to fetch package information for '${packageIdentifier}': ${e.message}`);
|
|
138
156
|
return 1;
|
|
139
157
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
158
|
+
try {
|
|
159
|
+
spinner.start('Installing package...');
|
|
160
|
+
if (savePackage === false) {
|
|
161
|
+
// Temporary packages are located in a different directory
|
|
162
|
+
// Hence we need to resolve them using the temp path
|
|
163
|
+
const tempPath = install_package_1.installTempPackage(packageIdentifier.raw, undefined, packageManager, options.registry ? [`--registry="${options.registry}"`] : undefined);
|
|
164
|
+
const resolvedCollectionPath = require.resolve(path_1.join(collectionName, 'package.json'), {
|
|
165
|
+
paths: [tempPath],
|
|
166
|
+
});
|
|
167
|
+
collectionName = path_1.dirname(resolvedCollectionPath);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
install_package_1.installPackage(packageIdentifier.raw, undefined, packageManager, savePackage, options.registry ? [`--registry="${options.registry}"`] : undefined);
|
|
171
|
+
}
|
|
172
|
+
spinner.succeed('Package successfully installed.');
|
|
148
173
|
}
|
|
149
|
-
|
|
150
|
-
|
|
174
|
+
catch (error) {
|
|
175
|
+
spinner.fail(`Package installation failed: ${error.message}`);
|
|
176
|
+
return 1;
|
|
151
177
|
}
|
|
152
178
|
return this.executeSchematic(collectionName, options['--']);
|
|
153
179
|
}
|
package/commands/doc-impl.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.DocCommand = void 0;
|
|
11
|
+
const open = require("open");
|
|
11
12
|
const command_1 = require("../models/command");
|
|
12
|
-
const open = require('open');
|
|
13
13
|
class DocCommand extends command_1.Command {
|
|
14
14
|
async run(options) {
|
|
15
15
|
if (!options.keyword) {
|
|
@@ -36,7 +36,7 @@ class DocCommand extends command_1.Command {
|
|
|
36
36
|
// and use it if we can find it
|
|
37
37
|
try {
|
|
38
38
|
/* tslint:disable-next-line:no-implicit-dependencies */
|
|
39
|
-
const currentNgVersion = require('@angular/core').VERSION.major;
|
|
39
|
+
const currentNgVersion = (await Promise.resolve().then(() => require('@angular/core'))).VERSION.major;
|
|
40
40
|
domain = `v${currentNgVersion}.angular.io`;
|
|
41
41
|
}
|
|
42
42
|
catch (e) { }
|
package/commands/lint-long.md
CHANGED
|
@@ -4,4 +4,4 @@ When a project name is not supplied, it will execute for all projects.
|
|
|
4
4
|
The default linting tool is [TSLint](https://palantir.github.io/tslint/), and the default configuration is specified in the project's `tslint.json` file.
|
|
5
5
|
|
|
6
6
|
**Note**: TSLint has been discontinued and support has been deprecated in the Angular CLI. The options shown below are for the deprecated TSLint builder.
|
|
7
|
-
To opt-in using the community driven ESLint builder, see [angular-eslint](https://github.com/angular-eslint/angular-eslint#migrating-from-codelyzer-and-tslint) README.
|
|
7
|
+
To opt-in using the community driven ESLint builder, see [angular-eslint](https://github.com/angular-eslint/angular-eslint#migrating-an-angular-cli-project-from-codelyzer-and-tslint) README.
|
package/commands/new-impl.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NewCommand = void 0;
|
|
4
4
|
const schematic_command_1 = require("../models/schematic-command");
|
|
5
|
-
const package_manager_1 = require("../utilities/package-manager");
|
|
6
5
|
class NewCommand extends schematic_command_1.SchematicCommand {
|
|
7
6
|
constructor() {
|
|
8
7
|
super(...arguments);
|
|
@@ -14,7 +13,6 @@ class NewCommand extends schematic_command_1.SchematicCommand {
|
|
|
14
13
|
return super.initialize(options);
|
|
15
14
|
}
|
|
16
15
|
async run(options) {
|
|
17
|
-
await package_manager_1.ensureCompatibleNpm(this.context.root);
|
|
18
16
|
// Register the version of the CLI in the registry.
|
|
19
17
|
const packageJson = require('../package.json');
|
|
20
18
|
const version = packageJson.version;
|
package/commands/update-impl.js
CHANGED
|
@@ -16,6 +16,7 @@ const path = require("path");
|
|
|
16
16
|
const semver = require("semver");
|
|
17
17
|
const schema_1 = require("../lib/config/schema");
|
|
18
18
|
const command_1 = require("../models/command");
|
|
19
|
+
const schematic_engine_host_1 = require("../models/schematic-engine-host");
|
|
19
20
|
const color_1 = require("../utilities/color");
|
|
20
21
|
const install_package_1 = require("../utilities/install-package");
|
|
21
22
|
const log_file_1 = require("../utilities/log-file");
|
|
@@ -49,6 +50,7 @@ class UpdateCommand extends command_1.Command {
|
|
|
49
50
|
// Otherwise, use packages from the active workspace (migrations)
|
|
50
51
|
resolvePaths: [__dirname, this.context.root],
|
|
51
52
|
schemaValidation: true,
|
|
53
|
+
engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
async executeSchematic(collection, schematic, options = {}) {
|
|
@@ -189,24 +191,6 @@ class UpdateCommand extends command_1.Command {
|
|
|
189
191
|
async run(options) {
|
|
190
192
|
var _a;
|
|
191
193
|
await package_manager_1.ensureCompatibleNpm(this.context.root);
|
|
192
|
-
// Check if the @angular-devkit/schematics package can be resolved from the workspace root
|
|
193
|
-
// This works around issues with packages containing migrations that cannot directly depend on the package
|
|
194
|
-
// This check can be removed once the schematic runtime handles this situation
|
|
195
|
-
try {
|
|
196
|
-
require.resolve('@angular-devkit/schematics', { paths: [this.context.root] });
|
|
197
|
-
}
|
|
198
|
-
catch (e) {
|
|
199
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
200
|
-
this.logger.fatal('The "@angular-devkit/schematics" package cannot be resolved from the workspace root directory. ' +
|
|
201
|
-
'This may be due to an unsupported node modules structure.\n' +
|
|
202
|
-
'Please remove both the "node_modules" directory and the package lock file; and then reinstall.\n' +
|
|
203
|
-
'If this does not correct the problem, ' +
|
|
204
|
-
'please temporarily install the "@angular-devkit/schematics" package within the workspace. ' +
|
|
205
|
-
'It can be removed once the update is complete.');
|
|
206
|
-
return 1;
|
|
207
|
-
}
|
|
208
|
-
throw e;
|
|
209
|
-
}
|
|
210
194
|
// Check if the current installed CLI version is older than the latest version.
|
|
211
195
|
if (!disableVersionCheck && await this.checkCLILatestVersion(options.verbose, options.next)) {
|
|
212
196
|
this.logger.warn(`The installed local Angular CLI version is older than the latest ${options.next ? 'pre-release' : 'stable'} version.\n` +
|
|
@@ -21,6 +21,7 @@ const tty_1 = require("../utilities/tty");
|
|
|
21
21
|
const analytics_1 = require("./analytics");
|
|
22
22
|
const command_1 = require("./command");
|
|
23
23
|
const parser_1 = require("./parser");
|
|
24
|
+
const schematic_engine_host_1 = require("./schematic-engine-host");
|
|
24
25
|
class UnknownCollectionError extends Error {
|
|
25
26
|
constructor(collectionName) {
|
|
26
27
|
super(`Invalid collection (${collectionName}).`);
|
|
@@ -176,6 +177,7 @@ class SchematicCommand extends command_1.Command {
|
|
|
176
177
|
...current,
|
|
177
178
|
}),
|
|
178
179
|
],
|
|
180
|
+
engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
|
|
179
181
|
});
|
|
180
182
|
const getProjectName = () => {
|
|
181
183
|
if (this.workspace) {
|
|
@@ -264,16 +266,6 @@ class SchematicCommand extends command_1.Command {
|
|
|
264
266
|
};
|
|
265
267
|
});
|
|
266
268
|
break;
|
|
267
|
-
case 'input':
|
|
268
|
-
if (definition.propertyTypes.size === 1 &&
|
|
269
|
-
(definition.propertyTypes.has('number') ||
|
|
270
|
-
definition.propertyTypes.has('integer'))) {
|
|
271
|
-
question.type = 'number';
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
question.type = 'input';
|
|
275
|
-
}
|
|
276
|
-
break;
|
|
277
269
|
default:
|
|
278
270
|
question.type = definition.type;
|
|
279
271
|
break;
|
|
@@ -391,6 +383,13 @@ class SchematicCommand extends command_1.Command {
|
|
|
391
383
|
error = false;
|
|
392
384
|
}
|
|
393
385
|
});
|
|
386
|
+
// Temporary compatibility check for NPM 7
|
|
387
|
+
if (collectionName === '@schematics/angular' && schematicName === 'ng-new') {
|
|
388
|
+
if (!input.skipInstall &&
|
|
389
|
+
(input.packageManager === undefined || input.packageManager === 'npm')) {
|
|
390
|
+
await package_manager_1.ensureCompatibleNpm(this.context.root);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
394
393
|
return new Promise(resolve => {
|
|
395
394
|
workflow
|
|
396
395
|
.execute({
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. 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 { RuleFactory } from '@angular-devkit/schematics';
|
|
9
|
+
import { NodeModulesEngineHost } from '@angular-devkit/schematics/tools';
|
|
10
|
+
export declare class SchematicEngineHost extends NodeModulesEngineHost {
|
|
11
|
+
protected _resolveReferenceString(refString: string, parentPath: string): {
|
|
12
|
+
ref: RuleFactory<{}>;
|
|
13
|
+
path: string;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SchematicEngineHost = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
8
|
+
*
|
|
9
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
10
|
+
* found in the LICENSE file at https://angular.io/license
|
|
11
|
+
*/
|
|
12
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const jsonc_parser_1 = require("jsonc-parser");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const vm_1 = require("vm");
|
|
18
|
+
/**
|
|
19
|
+
* Environment variable to control schematic package redirection
|
|
20
|
+
* Default: Angular schematics only
|
|
21
|
+
*/
|
|
22
|
+
const schematicRedirectVariable = (_a = process.env['NG_SCHEMATIC_REDIRECT']) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
23
|
+
function shouldWrapSchematic(schematicFile) {
|
|
24
|
+
// Check environment variable if present
|
|
25
|
+
if (schematicRedirectVariable !== undefined) {
|
|
26
|
+
switch (schematicRedirectVariable) {
|
|
27
|
+
case '0':
|
|
28
|
+
case 'false':
|
|
29
|
+
case 'off':
|
|
30
|
+
case 'none':
|
|
31
|
+
return false;
|
|
32
|
+
case 'all':
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Never wrap `@schematics/update` when executed directly
|
|
37
|
+
// It communicates with the update command via `global`
|
|
38
|
+
if (/[\/\\]node_modules[\/\\]@schematics[\/\\]update[\/\\]/.test(schematicFile)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
// Default is only first-party Angular schematic packages
|
|
42
|
+
// Angular schematics are safe to use in the wrapped VM context
|
|
43
|
+
return /[\/\\]node_modules[\/\\]@(?:angular|schematics|nguniversal)[\/\\]/.test(schematicFile);
|
|
44
|
+
}
|
|
45
|
+
class SchematicEngineHost extends tools_1.NodeModulesEngineHost {
|
|
46
|
+
_resolveReferenceString(refString, parentPath) {
|
|
47
|
+
const [path, name] = refString.split('#', 2);
|
|
48
|
+
// Mimic behavior of ExportStringRef class used in default behavior
|
|
49
|
+
const fullPath = path[0] === '.' ? path_1.resolve(parentPath !== null && parentPath !== void 0 ? parentPath : process.cwd(), path) : path;
|
|
50
|
+
const schematicFile = require.resolve(fullPath, { paths: [parentPath] });
|
|
51
|
+
if (shouldWrapSchematic(schematicFile)) {
|
|
52
|
+
const schematicPath = path_1.dirname(schematicFile);
|
|
53
|
+
const moduleCache = new Map();
|
|
54
|
+
const factoryInitializer = wrap(schematicFile, schematicPath, moduleCache, name || 'default');
|
|
55
|
+
const factory = factoryInitializer();
|
|
56
|
+
if (!factory || typeof factory !== 'function') {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return { ref: factory, path: schematicPath };
|
|
60
|
+
}
|
|
61
|
+
// All other schematics use default behavior
|
|
62
|
+
return super._resolveReferenceString(refString, parentPath);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.SchematicEngineHost = SchematicEngineHost;
|
|
66
|
+
/**
|
|
67
|
+
* Minimal shim modules for legacy deep imports of `@schematics/angular`
|
|
68
|
+
*/
|
|
69
|
+
const legacyModules = {
|
|
70
|
+
'@schematics/angular/utility/config': {
|
|
71
|
+
getWorkspace(host) {
|
|
72
|
+
const path = '/.angular.json';
|
|
73
|
+
const data = host.read(path);
|
|
74
|
+
if (!data) {
|
|
75
|
+
throw new schematics_1.SchematicsException(`Could not find (${path})`);
|
|
76
|
+
}
|
|
77
|
+
return jsonc_parser_1.parse(data.toString(), [], { allowTrailingComma: true });
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
'@schematics/angular/utility/project': {
|
|
81
|
+
buildDefaultPath(project) {
|
|
82
|
+
const root = project.sourceRoot ? `/${project.sourceRoot}/` : `/${project.root}/src/`;
|
|
83
|
+
return `${root}${project.projectType === 'application' ? 'app' : 'lib'}`;
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Wrap a JavaScript file in a VM context to allow specific Angular dependencies to be redirected.
|
|
89
|
+
* This VM setup is ONLY intended to redirect dependencies.
|
|
90
|
+
*
|
|
91
|
+
* @param schematicFile A JavaScript schematic file path that should be wrapped.
|
|
92
|
+
* @param schematicDirectory A directory that will be used as the location of the JavaScript file.
|
|
93
|
+
* @param moduleCache A map to use for caching repeat module usage and proper `instanceof` support.
|
|
94
|
+
* @param exportName An optional name of a specific export to return. Otherwise, return all exports.
|
|
95
|
+
*/
|
|
96
|
+
function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
|
|
97
|
+
const { createRequire, createRequireFromPath } = require('module');
|
|
98
|
+
// Node.js 10.x does not support `createRequire` so fallback to `createRequireFromPath`
|
|
99
|
+
// `createRequireFromPath` is deprecated in 12+ and can be removed once 10.x support is removed
|
|
100
|
+
const scopedRequire = (createRequire === null || createRequire === void 0 ? void 0 : createRequire(schematicFile)) || createRequireFromPath(schematicFile);
|
|
101
|
+
const customRequire = function (id) {
|
|
102
|
+
if (legacyModules[id]) {
|
|
103
|
+
// Provide compatibility modules for older versions of @angular/cdk
|
|
104
|
+
return legacyModules[id];
|
|
105
|
+
}
|
|
106
|
+
else if (id.startsWith('@angular-devkit/') || id.startsWith('@schematics/')) {
|
|
107
|
+
// Resolve from inside the `@angular/cli` project
|
|
108
|
+
const packagePath = require.resolve(id);
|
|
109
|
+
return require(packagePath);
|
|
110
|
+
}
|
|
111
|
+
else if (id.startsWith('.') || id.startsWith('@angular/cdk')) {
|
|
112
|
+
// Wrap relative files inside the schematic collection
|
|
113
|
+
// Also wrap `@angular/cdk`, it contains helper utilities that import core schematic packages
|
|
114
|
+
// Resolve from the original file
|
|
115
|
+
const modulePath = scopedRequire.resolve(id);
|
|
116
|
+
// Use cached module if available
|
|
117
|
+
const cachedModule = moduleCache.get(modulePath);
|
|
118
|
+
if (cachedModule) {
|
|
119
|
+
return cachedModule;
|
|
120
|
+
}
|
|
121
|
+
// Do not wrap vendored third-party packages or JSON files
|
|
122
|
+
if (!/[\/\\]node_modules[\/\\]@schematics[\/\\]angular[\/\\]third_party[\/\\]/.test(modulePath) &&
|
|
123
|
+
!modulePath.endsWith('.json')) {
|
|
124
|
+
// Wrap module and save in cache
|
|
125
|
+
const wrappedModule = wrap(modulePath, path_1.dirname(modulePath), moduleCache)();
|
|
126
|
+
moduleCache.set(modulePath, wrappedModule);
|
|
127
|
+
return wrappedModule;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// All others are required directly from the original file
|
|
131
|
+
return scopedRequire(id);
|
|
132
|
+
};
|
|
133
|
+
// Setup a wrapper function to capture the module's exports
|
|
134
|
+
const schematicCode = fs_1.readFileSync(schematicFile, 'utf8');
|
|
135
|
+
// `module` is required due to @angular/localize ng-add being in UMD format
|
|
136
|
+
const headerCode = '(function() {\nvar exports = {};\nvar module = { exports };\n';
|
|
137
|
+
const footerCode = exportName ? `\nreturn exports['${exportName}'];});` : '\nreturn exports;});';
|
|
138
|
+
const script = new vm_1.Script(headerCode + schematicCode + footerCode, {
|
|
139
|
+
filename: schematicFile,
|
|
140
|
+
lineOffset: 3,
|
|
141
|
+
});
|
|
142
|
+
const context = {
|
|
143
|
+
__dirname: schematicDirectory,
|
|
144
|
+
__filename: schematicFile,
|
|
145
|
+
Buffer,
|
|
146
|
+
console,
|
|
147
|
+
process,
|
|
148
|
+
get global() {
|
|
149
|
+
return this;
|
|
150
|
+
},
|
|
151
|
+
require: customRequire,
|
|
152
|
+
};
|
|
153
|
+
const exportsFactory = script.runInNewContext(context);
|
|
154
|
+
return exportsFactory;
|
|
155
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/cli",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "CLI tool for Angular",
|
|
5
5
|
"main": "lib/cli/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/angular/angular-cli",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@angular-devkit/architect": "0.
|
|
32
|
-
"@angular-devkit/core": "11.
|
|
33
|
-
"@angular-devkit/schematics": "11.
|
|
34
|
-
"@schematics/angular": "11.
|
|
35
|
-
"@schematics/update": "0.
|
|
31
|
+
"@angular-devkit/architect": "0.1102.0",
|
|
32
|
+
"@angular-devkit/core": "11.2.0",
|
|
33
|
+
"@angular-devkit/schematics": "11.2.0",
|
|
34
|
+
"@schematics/angular": "11.2.0",
|
|
35
|
+
"@schematics/update": "0.1102.0",
|
|
36
36
|
"@yarnpkg/lockfile": "1.1.0",
|
|
37
37
|
"ansi-colors": "4.1.1",
|
|
38
38
|
"debug": "4.3.1",
|
|
@@ -41,8 +41,9 @@
|
|
|
41
41
|
"jsonc-parser": "3.0.0",
|
|
42
42
|
"npm-package-arg": "8.1.0",
|
|
43
43
|
"npm-pick-manifest": "6.1.0",
|
|
44
|
-
"open": "7.
|
|
45
|
-
"
|
|
44
|
+
"open": "7.4.0",
|
|
45
|
+
"ora": "5.3.0",
|
|
46
|
+
"pacote": "11.2.4",
|
|
46
47
|
"resolve": "1.19.0",
|
|
47
48
|
"rimraf": "3.0.2",
|
|
48
49
|
"semver": "7.3.4",
|
|
@@ -53,12 +54,12 @@
|
|
|
53
54
|
"ng-update": {
|
|
54
55
|
"migrations": "@schematics/angular/migrations/migration-collection.json",
|
|
55
56
|
"packageGroup": {
|
|
56
|
-
"@angular/cli": "11.
|
|
57
|
-
"@angular-devkit/architect": "0.
|
|
58
|
-
"@angular-devkit/build-angular": "0.
|
|
59
|
-
"@angular-devkit/build-webpack": "0.
|
|
60
|
-
"@angular-devkit/core": "11.
|
|
61
|
-
"@angular-devkit/schematics": "11.
|
|
57
|
+
"@angular/cli": "11.2.0",
|
|
58
|
+
"@angular-devkit/architect": "0.1102.0",
|
|
59
|
+
"@angular-devkit/build-angular": "0.1102.0",
|
|
60
|
+
"@angular-devkit/build-webpack": "0.1102.0",
|
|
61
|
+
"@angular-devkit/core": "11.2.0",
|
|
62
|
+
"@angular-devkit/schematics": "11.2.0"
|
|
62
63
|
}
|
|
63
64
|
},
|
|
64
65
|
"engines": {
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
import { logging } from '@angular-devkit/core';
|
|
9
9
|
import { PackageManager } from '../lib/config/schema';
|
|
10
10
|
import { NgAddSaveDepedency } from '../utilities/package-metadata';
|
|
11
|
-
export declare function installPackage(packageName: string, logger: logging.Logger, packageManager?: PackageManager, save?: Exclude<NgAddSaveDepedency, false>, extraArgs?: string[], cwd?: string): void;
|
|
12
|
-
export declare function installTempPackage(packageName: string, logger: logging.Logger, packageManager?: PackageManager, extraArgs?: string[]): string;
|
|
11
|
+
export declare function installPackage(packageName: string, logger: logging.Logger | undefined, packageManager?: PackageManager, save?: Exclude<NgAddSaveDepedency, false>, extraArgs?: string[], cwd?: string): void;
|
|
12
|
+
export declare function installTempPackage(packageName: string, logger: logging.Logger | undefined, packageManager?: PackageManager, extraArgs?: string[]): string;
|
|
13
13
|
export declare function runTempPackageBin(packageName: string, logger: logging.Logger, packageManager?: PackageManager, args?: string[]): number;
|
|
@@ -22,7 +22,7 @@ function installPackage(packageName, logger, packageManager = schema_1.PackageMa
|
|
|
22
22
|
packageName,
|
|
23
23
|
packageManagerArgs.silent,
|
|
24
24
|
];
|
|
25
|
-
logger.info(color_1.colors.green(`Installing packages for tooling via ${packageManager}.`));
|
|
25
|
+
logger === null || logger === void 0 ? void 0 : logger.info(color_1.colors.green(`Installing packages for tooling via ${packageManager}.`));
|
|
26
26
|
if (save === 'devDependencies') {
|
|
27
27
|
installArgs.push(packageManagerArgs.saveDev);
|
|
28
28
|
}
|
|
@@ -39,7 +39,7 @@ function installPackage(packageName, logger, packageManager = schema_1.PackageMa
|
|
|
39
39
|
}
|
|
40
40
|
throw new Error(errorMessage + `Package install failed${errorMessage ? ', see above' : ''}.`);
|
|
41
41
|
}
|
|
42
|
-
logger.info(color_1.colors.green(`Installed packages for tooling via ${packageManager}.`));
|
|
42
|
+
logger === null || logger === void 0 ? void 0 : logger.info(color_1.colors.green(`Installed packages for tooling via ${packageManager}.`));
|
|
43
43
|
}
|
|
44
44
|
exports.installPackage = installPackage;
|
|
45
45
|
function installTempPackage(packageName, logger, packageManager = schema_1.PackageManager.Npm, extraArgs) {
|
|
@@ -67,13 +67,14 @@ async function ensureCompatibleNpm(root) {
|
|
|
67
67
|
try {
|
|
68
68
|
const version = child_process_1.execSync('npm --version', { encoding: 'utf8', stdio: 'pipe' }).trim();
|
|
69
69
|
const major = Number((_a = version.match(/^(\d+)\./)) === null || _a === void 0 ? void 0 : _a[1]);
|
|
70
|
-
if (major
|
|
70
|
+
if (major <= 6) {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
// tslint:disable-next-line: no-console
|
|
74
|
-
console.error(`npm version ${version} detected.\n` +
|
|
75
|
-
'
|
|
76
|
-
'
|
|
74
|
+
console.error(`npm version ${version} detected. The Angular CLI temporarily requires npm version 6 while upstream issues are addressed.\n\n` +
|
|
75
|
+
'Please install a compatible version to proceed (`npm install --global npm@6`).\n' +
|
|
76
|
+
'For additional information and alternative workarounds, please see ' +
|
|
77
|
+
'https://github.com/angular/angular-cli/issues/19957#issuecomment-775407654');
|
|
77
78
|
process.exit(3);
|
|
78
79
|
}
|
|
79
80
|
catch (_b) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. 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
|
+
export declare class Spinner {
|
|
9
|
+
private readonly spinner;
|
|
10
|
+
/** When false, only fail messages will be displayed. */
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
constructor(text?: string);
|
|
13
|
+
set text(text: string);
|
|
14
|
+
succeed(text?: string): void;
|
|
15
|
+
info(text?: string): void;
|
|
16
|
+
fail(text?: string): void;
|
|
17
|
+
warn(text?: string): void;
|
|
18
|
+
stop(): void;
|
|
19
|
+
start(text?: string): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google Inc. 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.Spinner = void 0;
|
|
11
|
+
const ora = require("ora");
|
|
12
|
+
const color_1 = require("./color");
|
|
13
|
+
class Spinner {
|
|
14
|
+
constructor(text) {
|
|
15
|
+
/** When false, only fail messages will be displayed. */
|
|
16
|
+
this.enabled = true;
|
|
17
|
+
this.spinner = ora({
|
|
18
|
+
text,
|
|
19
|
+
// The below 2 options are needed because otherwise CTRL+C will be delayed
|
|
20
|
+
// when the underlying process is sync.
|
|
21
|
+
hideCursor: false,
|
|
22
|
+
discardStdin: false,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
set text(text) {
|
|
26
|
+
this.spinner.text = text;
|
|
27
|
+
}
|
|
28
|
+
succeed(text) {
|
|
29
|
+
if (this.enabled) {
|
|
30
|
+
this.spinner.succeed(text);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
info(text) {
|
|
34
|
+
this.spinner.info(text);
|
|
35
|
+
}
|
|
36
|
+
fail(text) {
|
|
37
|
+
this.spinner.fail(text && color_1.colors.redBright(text));
|
|
38
|
+
}
|
|
39
|
+
warn(text) {
|
|
40
|
+
this.spinner.fail(text && color_1.colors.yellowBright(text));
|
|
41
|
+
}
|
|
42
|
+
stop() {
|
|
43
|
+
this.spinner.stop();
|
|
44
|
+
}
|
|
45
|
+
start(text) {
|
|
46
|
+
if (this.enabled) {
|
|
47
|
+
this.spinner.start(text);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.Spinner = Spinner;
|