@angular/cli 14.0.0-next.6 → 14.0.0-next.9
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 +19 -22
- package/src/analytics/analytics-collector.js +2 -0
- package/src/analytics/analytics.d.ts +1 -1
- package/src/analytics/analytics.js +39 -36
- package/src/command-builder/architect-base-command-module.d.ts +8 -1
- package/src/command-builder/architect-base-command-module.js +65 -3
- package/src/command-builder/architect-command-module.d.ts +4 -1
- package/src/command-builder/architect-command-module.js +40 -14
- package/src/command-builder/command-module.d.ts +4 -3
- package/src/command-builder/command-module.js +14 -7
- package/src/command-builder/command-runner.d.ts +1 -2
- package/src/command-builder/command-runner.js +69 -36
- package/src/command-builder/schematics-command-module.d.ts +3 -4
- package/src/command-builder/schematics-command-module.js +88 -48
- package/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
- package/src/command-builder/utilities/normalize-options-middleware.js +59 -0
- package/src/command-builder/utilities/schematic-engine-host.d.ts +2 -2
- package/src/command-builder/utilities/schematic-engine-host.js +30 -17
- 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/analytics/settings/cli.js +2 -2
- 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 +49 -0
- package/src/commands/completion/cli.d.ts +16 -0
- package/src/commands/completion/cli.js +31 -0
- package/src/commands/completion/long-description.md +1 -0
- package/src/commands/config/cli.d.ts +1 -1
- package/src/commands/config/cli.js +15 -15
- package/src/commands/deploy/cli.d.ts +2 -1
- package/src/commands/deploy/cli.js +27 -13
- package/src/commands/doc/cli.d.ts +1 -1
- package/src/commands/e2e/cli.d.ts +3 -2
- package/src/commands/e2e/cli.js +14 -13
- package/src/commands/generate/cli.d.ts +11 -1
- package/src/commands/generate/cli.js +54 -23
- package/src/commands/lint/cli.d.ts +2 -1
- package/src/commands/lint/cli.js +6 -9
- package/src/commands/new/cli.d.ts +2 -0
- package/src/commands/new/cli.js +22 -6
- package/src/commands/run/cli.d.ts +2 -0
- package/src/commands/run/cli.js +24 -0
- package/src/commands/update/cli.d.ts +1 -0
- package/src/commands/update/cli.js +53 -23
- 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 +5 -5
- package/src/utilities/config.js +27 -44
- 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/memoize.d.ts +15 -0
- package/src/utilities/memoize.js +69 -0
- package/src/utilities/package-manager.d.ts +33 -5
- package/src/utilities/package-manager.js +252 -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.d.ts +2 -0
- package/src/utilities/prompt.js +20 -3
- 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,59 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.normalizeOptionsMiddleware = void 0;
|
|
34
|
+
const yargs = __importStar(require("yargs"));
|
|
35
|
+
/**
|
|
36
|
+
* A Yargs middleware that normalizes non Array options when the argument has been provided multiple times.
|
|
37
|
+
*
|
|
38
|
+
* By default, when an option is non array and it is provided multiple times in the command line, yargs
|
|
39
|
+
* will not override it's value but instead it will be changed to an array unless `duplicate-arguments-array` is disabled.
|
|
40
|
+
* But this option also have an effect on real array options which isn't desired.
|
|
41
|
+
*
|
|
42
|
+
* See: https://github.com/yargs/yargs-parser/pull/163#issuecomment-516566614
|
|
43
|
+
*/
|
|
44
|
+
function normalizeOptionsMiddleware(args) {
|
|
45
|
+
// `getOptions` is not included in the types even though it's public API.
|
|
46
|
+
// https://github.com/yargs/yargs/issues/2098
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
const { array } = yargs.getOptions();
|
|
49
|
+
const arrayOptions = new Set(array);
|
|
50
|
+
for (const [key, value] of Object.entries(args)) {
|
|
51
|
+
if (key !== '_' && Array.isArray(value) && !arrayOptions.has(key)) {
|
|
52
|
+
const newValue = value.pop();
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.warn(`Option '${key}' has been specified multiple times. The value '${newValue}' will be used.`);
|
|
55
|
+
args[key] = newValue;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.normalizeOptionsMiddleware = normalizeOptionsMiddleware;
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { RuleFactory } from '@angular-devkit/schematics';
|
|
9
|
-
import { NodeModulesEngineHost } from '@angular-devkit/schematics/tools';
|
|
9
|
+
import { FileSystemCollectionDesc, NodeModulesEngineHost } from '@angular-devkit/schematics/tools';
|
|
10
10
|
export declare class SchematicEngineHost extends NodeModulesEngineHost {
|
|
11
|
-
protected _resolveReferenceString(refString: string, parentPath: string): {
|
|
11
|
+
protected _resolveReferenceString(refString: string, parentPath: string, collectionDescription?: FileSystemCollectionDesc): {
|
|
12
12
|
ref: RuleFactory<{}>;
|
|
13
13
|
path: string;
|
|
14
14
|
} | null;
|
|
@@ -21,21 +21,18 @@ const path_1 = require("path");
|
|
|
21
21
|
const vm_1 = require("vm");
|
|
22
22
|
/**
|
|
23
23
|
* Environment variable to control schematic package redirection
|
|
24
|
-
* Default: Angular schematics only
|
|
25
24
|
*/
|
|
26
25
|
const schematicRedirectVariable = (_a = process.env['NG_SCHEMATIC_REDIRECT']) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
27
|
-
function shouldWrapSchematic(schematicFile) {
|
|
26
|
+
function shouldWrapSchematic(schematicFile, schematicEncapsulation) {
|
|
28
27
|
// Check environment variable if present
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
28
|
+
switch (schematicRedirectVariable) {
|
|
29
|
+
case '0':
|
|
30
|
+
case 'false':
|
|
31
|
+
case 'off':
|
|
32
|
+
case 'none':
|
|
33
|
+
return false;
|
|
34
|
+
case 'all':
|
|
35
|
+
return true;
|
|
39
36
|
}
|
|
40
37
|
const normalizedSchematicFile = schematicFile.replace(/\\/g, '/');
|
|
41
38
|
// Never wrap the internal update schematic when executed directly
|
|
@@ -45,17 +42,21 @@ function shouldWrapSchematic(schematicFile) {
|
|
|
45
42
|
!normalizedSchematicFile.includes('node_modules/@angular/cli/node_modules/')) {
|
|
46
43
|
return false;
|
|
47
44
|
}
|
|
48
|
-
//
|
|
45
|
+
// Check for first-party Angular schematic packages
|
|
49
46
|
// Angular schematics are safe to use in the wrapped VM context
|
|
50
|
-
|
|
47
|
+
if (/\/node_modules\/@(?:angular|schematics|nguniversal)\//.test(normalizedSchematicFile)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
// Otherwise use the value of the schematic collection's encapsulation option (current default of false)
|
|
51
|
+
return schematicEncapsulation;
|
|
51
52
|
}
|
|
52
53
|
class SchematicEngineHost extends tools_1.NodeModulesEngineHost {
|
|
53
|
-
_resolveReferenceString(refString, parentPath) {
|
|
54
|
+
_resolveReferenceString(refString, parentPath, collectionDescription) {
|
|
54
55
|
const [path, name] = refString.split('#', 2);
|
|
55
56
|
// Mimic behavior of ExportStringRef class used in default behavior
|
|
56
57
|
const fullPath = path[0] === '.' ? (0, path_1.resolve)(parentPath !== null && parentPath !== void 0 ? parentPath : process.cwd(), path) : path;
|
|
57
58
|
const schematicFile = require.resolve(fullPath, { paths: [parentPath] });
|
|
58
|
-
if (shouldWrapSchematic(schematicFile)) {
|
|
59
|
+
if (shouldWrapSchematic(schematicFile, !!(collectionDescription === null || collectionDescription === void 0 ? void 0 : collectionDescription.encapsulation))) {
|
|
59
60
|
const schematicPath = (0, path_1.dirname)(schematicFile);
|
|
60
61
|
const moduleCache = new Map();
|
|
61
62
|
const factoryInitializer = wrap(schematicFile, schematicPath, moduleCache, name || 'default');
|
|
@@ -66,7 +67,7 @@ class SchematicEngineHost extends tools_1.NodeModulesEngineHost {
|
|
|
66
67
|
return { ref: factory, path: schematicPath };
|
|
67
68
|
}
|
|
68
69
|
// All other schematics use default behavior
|
|
69
|
-
return super._resolveReferenceString(refString, parentPath);
|
|
70
|
+
return super._resolveReferenceString(refString, parentPath, collectionDescription);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
exports.SchematicEngineHost = SchematicEngineHost;
|
|
@@ -108,6 +109,15 @@ function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
|
|
|
108
109
|
// Provide compatibility modules for older versions of @angular/cdk
|
|
109
110
|
return legacyModules[id];
|
|
110
111
|
}
|
|
112
|
+
else if (id.startsWith('schematics:')) {
|
|
113
|
+
// Schematics built-in modules use the `schematics` scheme (similar to the Node.js `node` scheme)
|
|
114
|
+
const builtinId = id.slice(11);
|
|
115
|
+
const builtinModule = loadBuiltinModule(builtinId);
|
|
116
|
+
if (!builtinModule) {
|
|
117
|
+
throw new Error(`Unknown schematics built-in module '${id}' requested from schematic '${schematicFile}'`);
|
|
118
|
+
}
|
|
119
|
+
return builtinModule;
|
|
120
|
+
}
|
|
111
121
|
else if (id.startsWith('@angular-devkit/') || id.startsWith('@schematics/')) {
|
|
112
122
|
// Files should not redirect `@angular/core` and instead use the direct
|
|
113
123
|
// dependency if available. This allows old major version migrations to continue to function
|
|
@@ -170,3 +180,6 @@ function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
|
|
|
170
180
|
const exportsFactory = script.runInNewContext(context);
|
|
171
181
|
return exportsFactory;
|
|
172
182
|
}
|
|
183
|
+
function loadBuiltinModule(id) {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
package/src/commands/add/cli.js
CHANGED
|
@@ -20,8 +20,6 @@ const workspace_schema_1 = require("../../../lib/config/workspace-schema");
|
|
|
20
20
|
const analytics_1 = require("../../analytics/analytics");
|
|
21
21
|
const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
|
|
22
22
|
const color_1 = require("../../utilities/color");
|
|
23
|
-
const install_package_1 = require("../../utilities/install-package");
|
|
24
|
-
const package_manager_1 = require("../../utilities/package-manager");
|
|
25
23
|
const package_metadata_1 = require("../../utilities/package-metadata");
|
|
26
24
|
const prompt_1 = require("../../utilities/prompt");
|
|
27
25
|
const spinner_1 = require("../../utilities/spinner");
|
|
@@ -84,9 +82,9 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
84
82
|
// eslint-disable-next-line max-lines-per-function
|
|
85
83
|
async run(options) {
|
|
86
84
|
var _a;
|
|
87
|
-
const {
|
|
85
|
+
const { logger, packageManager } = this.context;
|
|
88
86
|
const { verbose, registry, collection, skipConfirmation } = options;
|
|
89
|
-
|
|
87
|
+
packageManager.ensureCompatibility();
|
|
90
88
|
let packageIdentifier;
|
|
91
89
|
try {
|
|
92
90
|
packageIdentifier = (0, npm_package_arg_1.default)(collection);
|
|
@@ -107,8 +105,8 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
107
105
|
}
|
|
108
106
|
const spinner = new spinner_1.Spinner();
|
|
109
107
|
spinner.start('Determining package manager...');
|
|
110
|
-
const usingYarn = packageManager === workspace_schema_1.PackageManager.Yarn;
|
|
111
|
-
spinner.info(`Using package manager: ${color_1.colors.grey(packageManager)}`);
|
|
108
|
+
const usingYarn = packageManager.name === workspace_schema_1.PackageManager.Yarn;
|
|
109
|
+
spinner.info(`Using package manager: ${color_1.colors.grey(packageManager.name)}`);
|
|
112
110
|
if (packageIdentifier.name && packageIdentifier.type === 'tag' && !packageIdentifier.rawSpec) {
|
|
113
111
|
// only package name provided; search for viable version
|
|
114
112
|
// plus special cases for packages that did not have peer deps setup
|
|
@@ -131,7 +129,8 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
131
129
|
packageIdentifier = npm_package_arg_1.default.resolve(latestManifest.name, latestManifest.version);
|
|
132
130
|
}
|
|
133
131
|
// Adjust the version based on name and peer dependencies
|
|
134
|
-
if (latestManifest
|
|
132
|
+
if ((latestManifest === null || latestManifest === void 0 ? void 0 : latestManifest.peerDependencies) &&
|
|
133
|
+
Object.keys(latestManifest.peerDependencies).length === 0) {
|
|
135
134
|
spinner.succeed(`Found compatible package version: ${color_1.colors.grey(packageIdentifier.toString())}.`);
|
|
136
135
|
}
|
|
137
136
|
else if (!latestManifest || (await this.hasMismatchedPeer(latestManifest))) {
|
|
@@ -210,19 +209,19 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
210
209
|
if (savePackage === false) {
|
|
211
210
|
// Temporary packages are located in a different directory
|
|
212
211
|
// Hence we need to resolve them using the temp path
|
|
213
|
-
const {
|
|
212
|
+
const { success, tempNodeModules } = await packageManager.installTemp(packageIdentifier.raw, registry ? [`--registry="${registry}"`] : undefined);
|
|
214
213
|
const resolvedCollectionPath = require.resolve((0, path_1.join)(collectionName, 'package.json'), {
|
|
215
214
|
paths: [tempNodeModules],
|
|
216
215
|
});
|
|
217
|
-
if (
|
|
218
|
-
return
|
|
216
|
+
if (!success) {
|
|
217
|
+
return 1;
|
|
219
218
|
}
|
|
220
219
|
collectionName = (0, path_1.dirname)(resolvedCollectionPath);
|
|
221
220
|
}
|
|
222
221
|
else {
|
|
223
|
-
const
|
|
224
|
-
if (
|
|
225
|
-
return
|
|
222
|
+
const success = await packageManager.install(packageIdentifier.raw, savePackage, registry ? [`--registry="${registry}"`] : undefined);
|
|
223
|
+
if (!success) {
|
|
224
|
+
return 1;
|
|
226
225
|
}
|
|
227
226
|
}
|
|
228
227
|
return this.executeSchematic({ ...options, collection: collectionName });
|
|
@@ -301,6 +300,7 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
301
300
|
}
|
|
302
301
|
}
|
|
303
302
|
async findProjectVersion(name) {
|
|
303
|
+
var _a, _b;
|
|
304
304
|
const { logger, root } = this.context;
|
|
305
305
|
let installedPackage;
|
|
306
306
|
try {
|
|
@@ -322,7 +322,7 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
322
322
|
}
|
|
323
323
|
catch { }
|
|
324
324
|
if (projectManifest) {
|
|
325
|
-
const version = projectManifest.dependencies[name] || projectManifest.devDependencies[name];
|
|
325
|
+
const version = ((_a = projectManifest.dependencies) === null || _a === void 0 ? void 0 : _a[name]) || ((_b = projectManifest.devDependencies) === null || _b === void 0 ? void 0 : _b[name]);
|
|
326
326
|
if (version) {
|
|
327
327
|
return version;
|
|
328
328
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
Adds the npm package for a published library to your workspace, and configures
|
|
2
|
-
the project in the current working directory
|
|
3
|
-
not in a project directory) to use that library, as specified by the library's schematic.
|
|
2
|
+
the project in the current working directory to use that library, as specified by the library's schematic.
|
|
4
3
|
For example, adding `@angular/pwa` configures your project for PWA support:
|
|
5
4
|
|
|
6
5
|
```bash
|
|
7
6
|
ng add @angular/pwa
|
|
8
7
|
```
|
|
9
|
-
|
|
10
|
-
The default project is the value of `defaultProject` in `angular.json`.
|
|
@@ -10,7 +10,7 @@ import { CommandModule, CommandModuleImplementation, Options } from '../../comma
|
|
|
10
10
|
export declare class AnalyticsCommandModule extends CommandModule implements CommandModuleImplementation {
|
|
11
11
|
command: string;
|
|
12
12
|
describe: string;
|
|
13
|
-
longDescriptionPath?: string
|
|
13
|
+
longDescriptionPath?: string;
|
|
14
14
|
builder(localYargs: Argv): Argv;
|
|
15
15
|
run(_options: Options<{}>): void;
|
|
16
16
|
}
|
|
@@ -10,7 +10,7 @@ import { CommandModule, CommandModuleImplementation, Options } from '../../../co
|
|
|
10
10
|
export declare class AnalyticsInfoCommandModule extends CommandModule implements CommandModuleImplementation {
|
|
11
11
|
command: string;
|
|
12
12
|
describe: string;
|
|
13
|
-
longDescriptionPath?: string
|
|
13
|
+
longDescriptionPath?: string;
|
|
14
14
|
builder(localYargs: Argv): Argv;
|
|
15
15
|
run(_options: Options<{}>): Promise<void>;
|
|
16
16
|
}
|
|
@@ -11,7 +11,7 @@ interface AnalyticsCommandArgs {
|
|
|
11
11
|
global: boolean;
|
|
12
12
|
}
|
|
13
13
|
declare abstract class AnalyticsSettingModule extends CommandModule<AnalyticsCommandArgs> implements CommandModuleImplementation<AnalyticsCommandArgs> {
|
|
14
|
-
longDescriptionPath?: string
|
|
14
|
+
longDescriptionPath?: string;
|
|
15
15
|
builder(localYargs: Argv): Argv<AnalyticsCommandArgs>;
|
|
16
16
|
abstract run({ global }: Options<AnalyticsCommandArgs>): Promise<void>;
|
|
17
17
|
}
|
|
@@ -30,7 +30,7 @@ class AnalyticsDisableModule extends AnalyticsSettingModule {
|
|
|
30
30
|
this.describe = 'Disables analytics gathering and reporting for the user.';
|
|
31
31
|
}
|
|
32
32
|
async run({ global }) {
|
|
33
|
-
(0, analytics_1.setAnalyticsConfig)(global, false);
|
|
33
|
+
await (0, analytics_1.setAnalyticsConfig)(global, false);
|
|
34
34
|
process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -43,7 +43,7 @@ class AnalyticsEnableModule extends AnalyticsSettingModule {
|
|
|
43
43
|
this.describe = 'Enables analytics gathering and reporting for the user.';
|
|
44
44
|
}
|
|
45
45
|
async run({ global }) {
|
|
46
|
-
(0, analytics_1.setAnalyticsConfig)(global, true);
|
|
46
|
+
await (0, analytics_1.setAnalyticsConfig)(global, true);
|
|
47
47
|
process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { Argv } from 'yargs';
|
|
9
|
+
import { CommandModule, CommandModuleImplementation, CommandScope } from '../../../command-builder/command-module';
|
|
10
|
+
export declare class CacheCleanModule extends CommandModule implements CommandModuleImplementation {
|
|
11
|
+
command: string;
|
|
12
|
+
describe: string;
|
|
13
|
+
longDescriptionPath: string | undefined;
|
|
14
|
+
static scope: CommandScope.In;
|
|
15
|
+
builder(localYargs: Argv): Argv;
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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.CacheCleanModule = void 0;
|
|
11
|
+
const fs_1 = require("fs");
|
|
12
|
+
const command_module_1 = require("../../../command-builder/command-module");
|
|
13
|
+
const utilities_1 = require("../utilities");
|
|
14
|
+
class CacheCleanModule extends command_module_1.CommandModule {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.command = 'clean';
|
|
18
|
+
this.describe = 'Deletes persistent disk cache from disk.';
|
|
19
|
+
}
|
|
20
|
+
builder(localYargs) {
|
|
21
|
+
return localYargs.strict();
|
|
22
|
+
}
|
|
23
|
+
run() {
|
|
24
|
+
const { path } = (0, utilities_1.getCacheConfig)(this.context.workspace);
|
|
25
|
+
return fs_1.promises.rm(path, {
|
|
26
|
+
force: true,
|
|
27
|
+
recursive: true,
|
|
28
|
+
maxRetries: 3,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.CacheCleanModule = CacheCleanModule;
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { Argv } from 'yargs';
|
|
9
|
+
import { CommandModule, CommandModuleImplementation, CommandScope, Options } from '../../command-builder/command-module';
|
|
10
|
+
export declare class CacheCommandModule extends CommandModule implements CommandModuleImplementation {
|
|
11
|
+
command: string;
|
|
12
|
+
describe: string;
|
|
13
|
+
longDescriptionPath: string;
|
|
14
|
+
static scope: CommandScope.In;
|
|
15
|
+
builder(localYargs: Argv): Argv;
|
|
16
|
+
run(_options: Options<{}>): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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.CacheCommandModule = void 0;
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const command_module_1 = require("../../command-builder/command-module");
|
|
13
|
+
const command_1 = require("../../command-builder/utilities/command");
|
|
14
|
+
const cli_1 = require("./clean/cli");
|
|
15
|
+
const cli_2 = require("./info/cli");
|
|
16
|
+
const cli_3 = require("./settings/cli");
|
|
17
|
+
class CacheCommandModule extends command_module_1.CommandModule {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.command = 'cache';
|
|
21
|
+
this.describe = 'Configure persistent disk cache and retrieve cache statistics.';
|
|
22
|
+
this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
|
|
23
|
+
}
|
|
24
|
+
builder(localYargs) {
|
|
25
|
+
const subcommands = [
|
|
26
|
+
cli_3.CacheEnableModule,
|
|
27
|
+
cli_3.CacheDisableModule,
|
|
28
|
+
cli_1.CacheCleanModule,
|
|
29
|
+
cli_2.CacheInfoCommandModule,
|
|
30
|
+
].sort();
|
|
31
|
+
for (const module of subcommands) {
|
|
32
|
+
localYargs = (0, command_1.addCommandModuleToYargs)(localYargs, module, this.context);
|
|
33
|
+
}
|
|
34
|
+
return localYargs.demandCommand(1, command_1.demandCommandFailureMessage).strict();
|
|
35
|
+
}
|
|
36
|
+
run(_options) { }
|
|
37
|
+
}
|
|
38
|
+
exports.CacheCommandModule = CacheCommandModule;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { Argv } from 'yargs';
|
|
9
|
+
import { CommandModule, CommandModuleImplementation, CommandScope } from '../../../command-builder/command-module';
|
|
10
|
+
export declare class CacheInfoCommandModule extends CommandModule implements CommandModuleImplementation {
|
|
11
|
+
command: string;
|
|
12
|
+
describe: string;
|
|
13
|
+
longDescriptionPath?: string | undefined;
|
|
14
|
+
static scope: CommandScope.In;
|
|
15
|
+
builder(localYargs: Argv): Argv;
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
private getSizeOfDirectory;
|
|
18
|
+
private formatSize;
|
|
19
|
+
private effectiveEnabledStatus;
|
|
20
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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.CacheInfoCommandModule = void 0;
|
|
11
|
+
const core_1 = require("@angular-devkit/core");
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
const command_module_1 = require("../../../command-builder/command-module");
|
|
15
|
+
const environment_options_1 = require("../../../utilities/environment-options");
|
|
16
|
+
const utilities_1 = require("../utilities");
|
|
17
|
+
class CacheInfoCommandModule extends command_module_1.CommandModule {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.command = 'info';
|
|
21
|
+
this.describe = 'Prints persistent disk cache configuration and statistics in the console.';
|
|
22
|
+
}
|
|
23
|
+
builder(localYargs) {
|
|
24
|
+
return localYargs.strict();
|
|
25
|
+
}
|
|
26
|
+
async run() {
|
|
27
|
+
const { path, environment, enabled } = (0, utilities_1.getCacheConfig)(this.context.workspace);
|
|
28
|
+
this.context.logger.info(core_1.tags.stripIndents `
|
|
29
|
+
Enabled: ${enabled ? 'yes' : 'no'}
|
|
30
|
+
Environment: ${environment}
|
|
31
|
+
Path: ${path}
|
|
32
|
+
Size on disk: ${await this.getSizeOfDirectory(path)}
|
|
33
|
+
Effective status on current machine: ${this.effectiveEnabledStatus() ? 'enabled' : 'disabled'}
|
|
34
|
+
`);
|
|
35
|
+
}
|
|
36
|
+
async getSizeOfDirectory(path) {
|
|
37
|
+
const directoriesStack = [path];
|
|
38
|
+
let size = 0;
|
|
39
|
+
while (directoriesStack.length) {
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
41
|
+
const dirPath = directoriesStack.pop();
|
|
42
|
+
let entries = [];
|
|
43
|
+
try {
|
|
44
|
+
entries = await fs_1.promises.readdir(dirPath);
|
|
45
|
+
}
|
|
46
|
+
catch { }
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
const entryPath = (0, path_1.join)(dirPath, entry);
|
|
49
|
+
const stats = await fs_1.promises.stat(entryPath);
|
|
50
|
+
if (stats.isDirectory()) {
|
|
51
|
+
directoriesStack.push(entryPath);
|
|
52
|
+
}
|
|
53
|
+
size += stats.size;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return this.formatSize(size);
|
|
57
|
+
}
|
|
58
|
+
formatSize(size) {
|
|
59
|
+
if (size <= 0) {
|
|
60
|
+
return '0 bytes';
|
|
61
|
+
}
|
|
62
|
+
const abbreviations = ['bytes', 'kB', 'MB', 'GB'];
|
|
63
|
+
const index = Math.floor(Math.log(size) / Math.log(1024));
|
|
64
|
+
const roundedSize = size / Math.pow(1024, index);
|
|
65
|
+
// bytes don't have a fraction
|
|
66
|
+
const fractionDigits = index === 0 ? 0 : 2;
|
|
67
|
+
return `${roundedSize.toFixed(fractionDigits)} ${abbreviations[index]}`;
|
|
68
|
+
}
|
|
69
|
+
effectiveEnabledStatus() {
|
|
70
|
+
const { enabled, environment } = (0, utilities_1.getCacheConfig)(this.context.workspace);
|
|
71
|
+
if (enabled) {
|
|
72
|
+
switch (environment) {
|
|
73
|
+
case 'ci':
|
|
74
|
+
return environment_options_1.isCI;
|
|
75
|
+
case 'local':
|
|
76
|
+
return !environment_options_1.isCI;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return enabled;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.CacheInfoCommandModule = CacheInfoCommandModule;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Angular CLI saves a number of cachable operations on disk by default.
|
|
2
|
+
|
|
3
|
+
When you re-run the same build, the build system restores the state of the previous build and re-uses previously performed operations, which decreases the time taken to build and test your applications and libraries.
|
|
4
|
+
|
|
5
|
+
To amend the default cache settings, add the `cli.cache` object to your [Workspace Configuration](guide/workspace-config).
|
|
6
|
+
The object goes under `cli.cache` at the top level of the file, outside the `projects` sections.
|
|
7
|
+
|
|
8
|
+
```jsonc
|
|
9
|
+
{
|
|
10
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
11
|
+
"version": 1,
|
|
12
|
+
"cli": {
|
|
13
|
+
"cache": {
|
|
14
|
+
// ...
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"projects": {}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For more information, see [cache options](guide/workspace-config#cache-options).
|
|
22
|
+
|
|
23
|
+
### Cache environments
|
|
24
|
+
|
|
25
|
+
By default, disk cache is only enabled for local environments. The value of environment can be one of the following:
|
|
26
|
+
|
|
27
|
+
- `all` - allows disk cache on all machines.
|
|
28
|
+
- `local` - allows disk cache only on development machines.
|
|
29
|
+
- `ci` - allows disk cache only on continuous integration (Ci) systems.
|
|
30
|
+
|
|
31
|
+
To change the environment setting to `all`, run the following command:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
ng config cli.cache.environment all
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
For more information, see `environment` in [cache options](guide/workspace-config#cache-options).
|
|
38
|
+
|
|
39
|
+
<div class="alert is-helpful">
|
|
40
|
+
|
|
41
|
+
The Angular CLI checks for the presence and value of the `CI` environment variable to determine in which environment it is running.
|
|
42
|
+
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
### Cache path
|
|
46
|
+
|
|
47
|
+
By default, `.angular/cache` is used as a base directory to store cache results.
|
|
48
|
+
|
|
49
|
+
To change this path to `.cache/ng`, run the following command:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
ng config cli.cache.path ".cache/ng"
|
|
53
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { Argv } from 'yargs';
|
|
9
|
+
import { CommandModule, CommandModuleImplementation, CommandScope } from '../../../command-builder/command-module';
|
|
10
|
+
export declare class CacheDisableModule extends CommandModule implements CommandModuleImplementation {
|
|
11
|
+
command: string;
|
|
12
|
+
aliases: string;
|
|
13
|
+
describe: string;
|
|
14
|
+
longDescriptionPath: string | undefined;
|
|
15
|
+
static scope: CommandScope.In;
|
|
16
|
+
builder(localYargs: Argv): Argv;
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare class CacheEnableModule extends CommandModule implements CommandModuleImplementation {
|
|
20
|
+
command: string;
|
|
21
|
+
aliases: string;
|
|
22
|
+
describe: string;
|
|
23
|
+
longDescriptionPath: string | undefined;
|
|
24
|
+
static scope: CommandScope.In;
|
|
25
|
+
builder(localYargs: Argv): Argv;
|
|
26
|
+
run(): Promise<void>;
|
|
27
|
+
}
|
|
@@ -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
|
+
return (0, utilities_1.updateCacheConfig)(this.getWorkspaceOrThrow(), '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
|
+
return (0, utilities_1.updateCacheConfig)(this.getWorkspaceOrThrow(), '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>(workspace: AngularWorkspace, key: K, value: Cache[K]): Promise<void>;
|
|
11
|
+
export declare function getCacheConfig(workspace: AngularWorkspace | undefined): Required<Cache>;
|