@angular/cli 19.1.7 → 19.1.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/init.js +5 -5
- package/package.json +13 -13
- package/src/analytics/analytics-collector.js +5 -5
- package/src/analytics/analytics.js +2 -2
- package/src/command-builder/command-module.js +3 -3
- package/src/command-builder/schematics-command-module.js +7 -7
- package/src/command-builder/utilities/schematic-engine-host.js +13 -13
- package/src/commands/add/cli.js +24 -16
- package/src/commands/build/cli.js +2 -2
- package/src/commands/cache/clean/cli.js +2 -2
- package/src/commands/cache/cli.js +2 -2
- package/src/commands/cache/info/cli.js +5 -5
- package/src/commands/cache/utilities.js +3 -3
- package/src/commands/completion/cli.js +2 -2
- package/src/commands/config/cli.js +4 -4
- package/src/commands/lint/cli.js +2 -2
- package/src/commands/run/cli.js +2 -2
- package/src/commands/test/cli.js +2 -2
- package/src/commands/update/cli.js +6 -6
- package/src/commands/update/schematic/index.js +6 -3
- package/src/utilities/completion.js +12 -12
- package/src/utilities/config.js +10 -10
- package/src/utilities/error.js +2 -2
- package/src/utilities/find-up.js +3 -3
- package/src/utilities/json-file.js +4 -4
- package/src/utilities/log-file.js +6 -6
- package/src/utilities/package-manager.js +11 -11
- package/src/utilities/package-metadata.js +7 -7
- package/src/utilities/package-tree.js +4 -4
- package/src/utilities/project.js +3 -3
- package/src/utilities/version.js +1 -1
package/lib/init.js
CHANGED
|
@@ -42,9 +42,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
require("symbol-observable");
|
|
44
44
|
// symbol polyfill must go first
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const path = __importStar(require("path"));
|
|
45
|
+
const node_fs_1 = require("node:fs");
|
|
46
|
+
const node_module_1 = require("node:module");
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
48
48
|
const semver_1 = require("semver");
|
|
49
49
|
const color_1 = require("../src/utilities/color");
|
|
50
50
|
const config_1 = require("../src/utilities/config");
|
|
@@ -81,7 +81,7 @@ let forceExit = false;
|
|
|
81
81
|
try {
|
|
82
82
|
// No error implies a projectLocalCli, which will load whatever
|
|
83
83
|
// version of ng-cli you have installed in a local package.json
|
|
84
|
-
const cwdRequire = (0,
|
|
84
|
+
const cwdRequire = (0, node_module_1.createRequire)(process.cwd() + '/');
|
|
85
85
|
const projectLocalCli = cwdRequire.resolve('@angular/cli');
|
|
86
86
|
cli = await Promise.resolve(`${projectLocalCli}`).then(s => __importStar(require(s)));
|
|
87
87
|
const globalVersion = new semver_1.SemVer(version_1.VERSION.full);
|
|
@@ -89,7 +89,7 @@ let forceExit = false;
|
|
|
89
89
|
let localVersion = cli.VERSION?.full;
|
|
90
90
|
if (!localVersion) {
|
|
91
91
|
try {
|
|
92
|
-
const localPackageJson = await
|
|
92
|
+
const localPackageJson = await node_fs_1.promises.readFile(path.join(path.dirname(projectLocalCli), '../../package.json'), 'utf-8');
|
|
93
93
|
localVersion = JSON.parse(localPackageJson).version;
|
|
94
94
|
}
|
|
95
95
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/cli",
|
|
3
|
-
"version": "19.1.
|
|
3
|
+
"version": "19.1.9",
|
|
4
4
|
"description": "CLI tool for Angular",
|
|
5
5
|
"main": "lib/cli/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/angular/angular-cli",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@angular-devkit/architect": "0.1901.
|
|
29
|
-
"@angular-devkit/core": "19.1.
|
|
30
|
-
"@angular-devkit/schematics": "19.1.
|
|
28
|
+
"@angular-devkit/architect": "0.1901.9",
|
|
29
|
+
"@angular-devkit/core": "19.1.9",
|
|
30
|
+
"@angular-devkit/schematics": "19.1.9",
|
|
31
31
|
"@inquirer/prompts": "7.2.1",
|
|
32
32
|
"@listr2/prompt-adapter-inquirer": "2.0.18",
|
|
33
|
-
"@schematics/angular": "19.1.
|
|
33
|
+
"@schematics/angular": "19.1.9",
|
|
34
34
|
"@yarnpkg/lockfile": "1.1.0",
|
|
35
35
|
"ini": "5.0.0",
|
|
36
36
|
"jsonc-parser": "3.3.1",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"ng-update": {
|
|
47
47
|
"migrations": "@schematics/angular/migrations/migration-collection.json",
|
|
48
48
|
"packageGroup": {
|
|
49
|
-
"@angular/cli": "19.1.
|
|
50
|
-
"@angular/build": "19.1.
|
|
51
|
-
"@angular/ssr": "19.1.
|
|
52
|
-
"@angular-devkit/architect": "0.1901.
|
|
53
|
-
"@angular-devkit/build-angular": "19.1.
|
|
54
|
-
"@angular-devkit/build-webpack": "0.1901.
|
|
55
|
-
"@angular-devkit/core": "19.1.
|
|
56
|
-
"@angular-devkit/schematics": "19.1.
|
|
49
|
+
"@angular/cli": "19.1.9",
|
|
50
|
+
"@angular/build": "19.1.9",
|
|
51
|
+
"@angular/ssr": "19.1.9",
|
|
52
|
+
"@angular-devkit/architect": "0.1901.9",
|
|
53
|
+
"@angular-devkit/build-angular": "19.1.9",
|
|
54
|
+
"@angular-devkit/build-webpack": "0.1901.9",
|
|
55
|
+
"@angular-devkit/core": "19.1.9",
|
|
56
|
+
"@angular-devkit/schematics": "19.1.9"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
@@ -41,10 +41,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
41
|
})();
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.AnalyticsCollector = void 0;
|
|
44
|
-
const
|
|
45
|
-
const https = __importStar(require("https"));
|
|
46
|
-
const os = __importStar(require("os"));
|
|
47
|
-
const querystring = __importStar(require("querystring"));
|
|
44
|
+
const node_crypto_1 = require("node:crypto");
|
|
45
|
+
const https = __importStar(require("node:https"));
|
|
46
|
+
const os = __importStar(require("node:os"));
|
|
47
|
+
const querystring = __importStar(require("node:querystring"));
|
|
48
48
|
const semver = __importStar(require("semver"));
|
|
49
49
|
const environment_options_1 = require("../utilities/environment-options");
|
|
50
50
|
const error_1 = require("../utilities/error");
|
|
@@ -67,7 +67,7 @@ class AnalyticsCollector {
|
|
|
67
67
|
? TRACKING_ID_PROD
|
|
68
68
|
: TRACKING_ID_STAGING,
|
|
69
69
|
// Built-in user properties
|
|
70
|
-
[analytics_parameters_1.RequestParameter.SessionId]: (0,
|
|
70
|
+
[analytics_parameters_1.RequestParameter.SessionId]: (0, node_crypto_1.randomUUID)(),
|
|
71
71
|
[analytics_parameters_1.RequestParameter.UserAgentArchitecture]: os.arch(),
|
|
72
72
|
[analytics_parameters_1.RequestParameter.UserAgentPlatform]: os.platform(),
|
|
73
73
|
[analytics_parameters_1.RequestParameter.UserAgentPlatformVersion]: os.release(),
|
|
@@ -14,7 +14,7 @@ exports.promptAnalytics = promptAnalytics;
|
|
|
14
14
|
exports.getAnalyticsUserId = getAnalyticsUserId;
|
|
15
15
|
exports.getAnalyticsInfoString = getAnalyticsInfoString;
|
|
16
16
|
const core_1 = require("@angular-devkit/core");
|
|
17
|
-
const
|
|
17
|
+
const node_crypto_1 = require("node:crypto");
|
|
18
18
|
const color_1 = require("../utilities/color");
|
|
19
19
|
const config_1 = require("../utilities/config");
|
|
20
20
|
const environment_options_1 = require("../utilities/environment-options");
|
|
@@ -55,7 +55,7 @@ async function setAnalyticsConfig(global, value) {
|
|
|
55
55
|
if (!workspace || !core_1.json.isJsonObject(cli)) {
|
|
56
56
|
throw new Error(`Invalid config found at ${workspace.filePath}. CLI should be an object.`);
|
|
57
57
|
}
|
|
58
|
-
cli.analytics = value === true ? (0,
|
|
58
|
+
cli.analytics = value === true ? (0, node_crypto_1.randomUUID)() : value;
|
|
59
59
|
await workspace.save();
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -79,8 +79,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
79
79
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
80
80
|
exports.CommandModuleError = exports.CommandModule = exports.CommandScope = void 0;
|
|
81
81
|
const core_1 = require("@angular-devkit/core");
|
|
82
|
-
const
|
|
83
|
-
const path = __importStar(require("path"));
|
|
82
|
+
const node_fs_1 = require("node:fs");
|
|
83
|
+
const path = __importStar(require("node:path"));
|
|
84
84
|
const yargs_1 = __importDefault(require("yargs"));
|
|
85
85
|
const helpers_1 = require("yargs/helpers");
|
|
86
86
|
const analytics_1 = require("../analytics/analytics");
|
|
@@ -131,7 +131,7 @@ let CommandModule = (() => {
|
|
|
131
131
|
longDescriptionRelativePath: path
|
|
132
132
|
.relative(path.join(__dirname, '../../../../'), this.longDescriptionPath)
|
|
133
133
|
.replace(/\\/g, path.posix.sep),
|
|
134
|
-
longDescription: (0,
|
|
134
|
+
longDescription: (0, node_fs_1.readFileSync)(this.longDescriptionPath, 'utf8').replace(/\r\n/g, '\n'),
|
|
135
135
|
}
|
|
136
136
|
: {}),
|
|
137
137
|
};
|
|
@@ -78,7 +78,7 @@ exports.SchematicsCommandModule = exports.DEFAULT_SCHEMATICS_COLLECTION = void 0
|
|
|
78
78
|
const core_1 = require("@angular-devkit/core");
|
|
79
79
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
80
80
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
81
|
-
const
|
|
81
|
+
const node_path_1 = require("node:path");
|
|
82
82
|
const analytics_1 = require("../analytics/analytics");
|
|
83
83
|
const analytics_parameters_1 = require("../analytics/analytics-parameters");
|
|
84
84
|
const config_1 = require("../utilities/config");
|
|
@@ -176,7 +176,7 @@ let SchematicsCommandModule = (() => {
|
|
|
176
176
|
workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
|
|
177
177
|
workflow.registry.useXDeprecatedProvider((msg) => logger.warn(msg));
|
|
178
178
|
workflow.registry.addSmartDefaultProvider('projectName', () => this.getProjectName());
|
|
179
|
-
const workingDir = (0, core_1.normalize)((0,
|
|
179
|
+
const workingDir = (0, core_1.normalize)((0, node_path_1.relative)(this.context.root, process.cwd()));
|
|
180
180
|
workflow.registry.addSmartDefaultProvider('workingDirectory', () => workingDir === '' ? undefined : workingDir);
|
|
181
181
|
let shouldReportAnalytics = true;
|
|
182
182
|
workflow.engineHost.registerOptionsTransform(async (schematic, options) => {
|
|
@@ -286,17 +286,13 @@ let SchematicsCommandModule = (() => {
|
|
|
286
286
|
return workflow;
|
|
287
287
|
}
|
|
288
288
|
async getSchematicCollections() {
|
|
289
|
-
// Resolve relative collections from the location of `angular.json`
|
|
290
|
-
const resolveRelativeCollection = (collectionName) => collectionName.charAt(0) === '.'
|
|
291
|
-
? (0, path_1.resolve)(this.context.root, collectionName)
|
|
292
|
-
: collectionName;
|
|
293
289
|
const getSchematicCollections = (configSection) => {
|
|
294
290
|
if (!configSection) {
|
|
295
291
|
return undefined;
|
|
296
292
|
}
|
|
297
293
|
const { schematicCollections } = configSection;
|
|
298
294
|
if (Array.isArray(schematicCollections)) {
|
|
299
|
-
return new Set(schematicCollections
|
|
295
|
+
return new Set(schematicCollections);
|
|
300
296
|
}
|
|
301
297
|
return undefined;
|
|
302
298
|
};
|
|
@@ -379,6 +375,10 @@ let SchematicsCommandModule = (() => {
|
|
|
379
375
|
}
|
|
380
376
|
getResolvePaths(collectionName) {
|
|
381
377
|
const { workspace, root } = this.context;
|
|
378
|
+
if (collectionName[0] === '.') {
|
|
379
|
+
// Resolve relative collections from the location of `angular.json`
|
|
380
|
+
return [root];
|
|
381
|
+
}
|
|
382
382
|
return workspace
|
|
383
383
|
? // Workspace
|
|
384
384
|
collectionName === exports.DEFAULT_SCHEMATICS_COLLECTION
|
|
@@ -10,11 +10,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.SchematicEngineHost = void 0;
|
|
11
11
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
12
12
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
13
|
-
const fs_1 = require("fs");
|
|
14
13
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
14
|
+
const node_fs_1 = require("node:fs");
|
|
15
|
+
const node_module_1 = require("node:module");
|
|
16
|
+
const node_path_1 = require("node:path");
|
|
17
|
+
const node_vm_1 = require("node:vm");
|
|
18
18
|
const error_1 = require("../../utilities/error");
|
|
19
19
|
/**
|
|
20
20
|
* Environment variable to control schematic package redirection
|
|
@@ -57,11 +57,11 @@ class SchematicEngineHost extends tools_1.NodeModulesEngineHost {
|
|
|
57
57
|
_resolveReferenceString(refString, parentPath, collectionDescription) {
|
|
58
58
|
const [path, name] = refString.split('#', 2);
|
|
59
59
|
// Mimic behavior of ExportStringRef class used in default behavior
|
|
60
|
-
const fullPath = path[0] === '.' ? (0,
|
|
61
|
-
const referenceRequire = (0,
|
|
60
|
+
const fullPath = path[0] === '.' ? (0, node_path_1.resolve)(parentPath ?? process.cwd(), path) : path;
|
|
61
|
+
const referenceRequire = (0, node_module_1.createRequire)(__filename);
|
|
62
62
|
const schematicFile = referenceRequire.resolve(fullPath, { paths: [parentPath] });
|
|
63
63
|
if (shouldWrapSchematic(schematicFile, !!collectionDescription?.encapsulation)) {
|
|
64
|
-
const schematicPath = (0,
|
|
64
|
+
const schematicPath = (0, node_path_1.dirname)(schematicFile);
|
|
65
65
|
const moduleCache = new Map();
|
|
66
66
|
const factoryInitializer = wrap(schematicFile, schematicPath, moduleCache, name || 'default');
|
|
67
67
|
const factory = factoryInitializer();
|
|
@@ -106,8 +106,8 @@ const legacyModules = {
|
|
|
106
106
|
* @param exportName An optional name of a specific export to return. Otherwise, return all exports.
|
|
107
107
|
*/
|
|
108
108
|
function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
|
|
109
|
-
const hostRequire = (0,
|
|
110
|
-
const schematicRequire = (0,
|
|
109
|
+
const hostRequire = (0, node_module_1.createRequire)(__filename);
|
|
110
|
+
const schematicRequire = (0, node_module_1.createRequire)(schematicFile);
|
|
111
111
|
const customRequire = function (id) {
|
|
112
112
|
if (legacyModules[id]) {
|
|
113
113
|
// Provide compatibility modules for older versions of @angular/cdk
|
|
@@ -154,7 +154,7 @@ function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
|
|
|
154
154
|
if (!/[/\\]node_modules[/\\]@schematics[/\\]angular[/\\]third_party[/\\]/.test(modulePath) &&
|
|
155
155
|
!modulePath.endsWith('.json')) {
|
|
156
156
|
// Wrap module and save in cache
|
|
157
|
-
const wrappedModule = wrap(modulePath, (0,
|
|
157
|
+
const wrappedModule = wrap(modulePath, (0, node_path_1.dirname)(modulePath), moduleCache)();
|
|
158
158
|
moduleCache.set(modulePath, wrappedModule);
|
|
159
159
|
return wrappedModule;
|
|
160
160
|
}
|
|
@@ -163,12 +163,12 @@ function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
|
|
|
163
163
|
return schematicRequire(id);
|
|
164
164
|
};
|
|
165
165
|
// Setup a wrapper function to capture the module's exports
|
|
166
|
-
const schematicCode = (0,
|
|
167
|
-
const script = new
|
|
166
|
+
const schematicCode = (0, node_fs_1.readFileSync)(schematicFile, 'utf8');
|
|
167
|
+
const script = new node_vm_1.Script(node_module_1.Module.wrap(schematicCode), {
|
|
168
168
|
filename: schematicFile,
|
|
169
169
|
lineOffset: 1,
|
|
170
170
|
});
|
|
171
|
-
const schematicModule = new
|
|
171
|
+
const schematicModule = new node_module_1.Module(schematicFile);
|
|
172
172
|
const moduleFactory = script.runInThisContext();
|
|
173
173
|
return () => {
|
|
174
174
|
moduleFactory(schematicModule.exports, customRequire, schematicModule, schematicFile, schematicDirectory);
|
package/src/commands/add/cli.js
CHANGED
|
@@ -45,10 +45,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
47
47
|
const listr2_1 = require("listr2");
|
|
48
|
-
const module_1 = require("module");
|
|
49
48
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
49
|
+
const node_module_1 = require("node:module");
|
|
50
|
+
const node_path_1 = require("node:path");
|
|
50
51
|
const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
|
|
51
|
-
const path_1 = require("path");
|
|
52
52
|
const semver_1 = require("semver");
|
|
53
53
|
const workspace_schema_1 = require("../../../lib/config/workspace-schema");
|
|
54
54
|
const schematics_command_module_1 = require("../../command-builder/schematics-command-module");
|
|
@@ -72,10 +72,10 @@ const packageVersionExclusions = {
|
|
|
72
72
|
class AddCommandModule extends schematics_command_module_1.SchematicsCommandModule {
|
|
73
73
|
command = 'add <collection>';
|
|
74
74
|
describe = 'Adds support for an external library to your project.';
|
|
75
|
-
longDescriptionPath = (0,
|
|
75
|
+
longDescriptionPath = (0, node_path_1.join)(__dirname, 'long-description.md');
|
|
76
76
|
allowPrivateSchematics = true;
|
|
77
77
|
schematicName = 'ng-add';
|
|
78
|
-
rootRequire = (0,
|
|
78
|
+
rootRequire = (0, node_module_1.createRequire)(this.context.root + '/');
|
|
79
79
|
async builder(argv) {
|
|
80
80
|
const localYargs = (await super.builder(argv))
|
|
81
81
|
.positional('collection', {
|
|
@@ -99,7 +99,10 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
99
99
|
// Possibly in the future update the logic to use the following syntax:
|
|
100
100
|
// `ng add @angular/localize -- --package-options`.
|
|
101
101
|
.strict(false);
|
|
102
|
-
const collectionName =
|
|
102
|
+
const collectionName = this.getCollectionName();
|
|
103
|
+
if (!collectionName) {
|
|
104
|
+
return localYargs;
|
|
105
|
+
}
|
|
103
106
|
const workflow = this.getOrCreateWorkflowForBuilder(collectionName);
|
|
104
107
|
try {
|
|
105
108
|
const collection = workflow.engine.createCollection(collectionName);
|
|
@@ -282,13 +285,13 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
282
285
|
// Temporary packages are located in a different directory
|
|
283
286
|
// Hence we need to resolve them using the temp path
|
|
284
287
|
const { success, tempNodeModules } = await packageManager.installTemp(context.packageIdentifier.toString(), registry ? [`--registry="${registry}"`] : undefined);
|
|
285
|
-
const tempRequire = (0,
|
|
288
|
+
const tempRequire = (0, node_module_1.createRequire)(tempNodeModules + '/');
|
|
286
289
|
(0, node_assert_1.default)(context.collectionName, 'Collection name should always be available');
|
|
287
|
-
const resolvedCollectionPath = tempRequire.resolve((0,
|
|
290
|
+
const resolvedCollectionPath = tempRequire.resolve((0, node_path_1.join)(context.collectionName, 'package.json'));
|
|
288
291
|
if (!success) {
|
|
289
292
|
throw new CommandError('Unable to install package');
|
|
290
293
|
}
|
|
291
|
-
context.collectionName = (0,
|
|
294
|
+
context.collectionName = (0, node_path_1.dirname)(resolvedCollectionPath);
|
|
292
295
|
}
|
|
293
296
|
else {
|
|
294
297
|
const success = await packageManager.install(context.packageIdentifier.toString(), context.savePackage, registry ? [`--registry="${registry}"`] : undefined, undefined);
|
|
@@ -336,13 +339,18 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
336
339
|
}
|
|
337
340
|
return false;
|
|
338
341
|
}
|
|
339
|
-
|
|
340
|
-
|
|
342
|
+
getCollectionName() {
|
|
343
|
+
const [, collectionName] = this.context.args.positional;
|
|
344
|
+
if (!collectionName) {
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
341
347
|
// The CLI argument may specify also a version, like `ng add @my/lib@13.0.0`,
|
|
342
|
-
// but here we need only the name of the package, like `@my/lib
|
|
348
|
+
// but here we need only the name of the package, like `@my/lib`.
|
|
343
349
|
try {
|
|
344
|
-
const
|
|
345
|
-
|
|
350
|
+
const packageName = (0, npm_package_arg_1.default)(collectionName).name;
|
|
351
|
+
if (packageName) {
|
|
352
|
+
return packageName;
|
|
353
|
+
}
|
|
346
354
|
}
|
|
347
355
|
catch (e) {
|
|
348
356
|
(0, error_1.assertIsError)(e);
|
|
@@ -352,7 +360,7 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
352
360
|
}
|
|
353
361
|
isPackageInstalled(name) {
|
|
354
362
|
try {
|
|
355
|
-
this.rootRequire.resolve((0,
|
|
363
|
+
this.rootRequire.resolve((0, node_path_1.join)(name, 'package.json'));
|
|
356
364
|
return true;
|
|
357
365
|
}
|
|
358
366
|
catch (e) {
|
|
@@ -392,12 +400,12 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
392
400
|
const { logger, root } = this.context;
|
|
393
401
|
let installedPackage;
|
|
394
402
|
try {
|
|
395
|
-
installedPackage = this.rootRequire.resolve((0,
|
|
403
|
+
installedPackage = this.rootRequire.resolve((0, node_path_1.join)(name, 'package.json'));
|
|
396
404
|
}
|
|
397
405
|
catch { }
|
|
398
406
|
if (installedPackage) {
|
|
399
407
|
try {
|
|
400
|
-
const installed = await (0, package_metadata_1.fetchPackageManifest)((0,
|
|
408
|
+
const installed = await (0, package_metadata_1.fetchPackageManifest)((0, node_path_1.dirname)(installedPackage), logger);
|
|
401
409
|
return installed.version;
|
|
402
410
|
}
|
|
403
411
|
catch { }
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
11
|
const architect_command_module_1 = require("../../command-builder/architect-command-module");
|
|
12
12
|
const command_config_1 = require("../command-config");
|
|
13
13
|
class BuildCommandModule extends architect_command_module_1.ArchitectCommandModule {
|
|
@@ -15,6 +15,6 @@ class BuildCommandModule extends architect_command_module_1.ArchitectCommandModu
|
|
|
15
15
|
command = 'build [project]';
|
|
16
16
|
aliases = command_config_1.RootCommands['build'].aliases;
|
|
17
17
|
describe = 'Compiles an Angular application or library into an output directory named dist/ at the given output path.';
|
|
18
|
-
longDescriptionPath = (0,
|
|
18
|
+
longDescriptionPath = (0, node_path_1.join)(__dirname, 'long-description.md');
|
|
19
19
|
}
|
|
20
20
|
exports.default = BuildCommandModule;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.CacheCleanModule = void 0;
|
|
11
|
-
const
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
12
|
const command_module_1 = require("../../../command-builder/command-module");
|
|
13
13
|
const utilities_1 = require("../utilities");
|
|
14
14
|
class CacheCleanModule extends command_module_1.CommandModule {
|
|
@@ -21,7 +21,7 @@ class CacheCleanModule extends command_module_1.CommandModule {
|
|
|
21
21
|
}
|
|
22
22
|
run() {
|
|
23
23
|
const { path } = (0, utilities_1.getCacheConfig)(this.context.workspace);
|
|
24
|
-
return
|
|
24
|
+
return node_fs_1.promises.rm(path, {
|
|
25
25
|
force: true,
|
|
26
26
|
recursive: true,
|
|
27
27
|
maxRetries: 3,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
11
|
const command_module_1 = require("../../command-builder/command-module");
|
|
12
12
|
const command_1 = require("../../command-builder/utilities/command");
|
|
13
13
|
const cli_1 = require("./clean/cli");
|
|
@@ -16,7 +16,7 @@ const cli_3 = require("./settings/cli");
|
|
|
16
16
|
class CacheCommandModule extends command_module_1.CommandModule {
|
|
17
17
|
command = 'cache';
|
|
18
18
|
describe = 'Configure persistent disk cache and retrieve cache statistics.';
|
|
19
|
-
longDescriptionPath = (0,
|
|
19
|
+
longDescriptionPath = (0, node_path_1.join)(__dirname, 'long-description.md');
|
|
20
20
|
scope = command_module_1.CommandScope.In;
|
|
21
21
|
builder(localYargs) {
|
|
22
22
|
const subcommands = [
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.CacheInfoCommandModule = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const node_fs_1 = require("node:fs");
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
14
|
const command_module_1 = require("../../../command-builder/command-module");
|
|
15
15
|
const environment_options_1 = require("../../../utilities/environment-options");
|
|
16
16
|
const utilities_1 = require("../utilities");
|
|
@@ -40,12 +40,12 @@ class CacheInfoCommandModule extends command_module_1.CommandModule {
|
|
|
40
40
|
const dirPath = directoriesStack.pop();
|
|
41
41
|
let entries = [];
|
|
42
42
|
try {
|
|
43
|
-
entries = await
|
|
43
|
+
entries = await node_fs_1.promises.readdir(dirPath);
|
|
44
44
|
}
|
|
45
45
|
catch { }
|
|
46
46
|
for (const entry of entries) {
|
|
47
|
-
const entryPath = (0,
|
|
48
|
-
const stats = await
|
|
47
|
+
const entryPath = (0, node_path_1.join)(dirPath, entry);
|
|
48
|
+
const stats = await node_fs_1.promises.stat(entryPath);
|
|
49
49
|
if (stats.isDirectory()) {
|
|
50
50
|
directoriesStack.push(entryPath);
|
|
51
51
|
}
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.updateCacheConfig = updateCacheConfig;
|
|
11
11
|
exports.getCacheConfig = getCacheConfig;
|
|
12
12
|
const core_1 = require("@angular-devkit/core");
|
|
13
|
-
const
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
14
|
const workspace_schema_1 = require("../../../lib/config/workspace-schema");
|
|
15
15
|
function updateCacheConfig(workspace, key, value) {
|
|
16
16
|
const cli = (workspace.extensions['cli'] ??= {});
|
|
@@ -23,7 +23,7 @@ function getCacheConfig(workspace) {
|
|
|
23
23
|
throw new Error(`Cannot retrieve cache configuration as workspace is not defined.`);
|
|
24
24
|
}
|
|
25
25
|
const defaultSettings = {
|
|
26
|
-
path: (0,
|
|
26
|
+
path: (0, node_path_1.resolve)(workspace.basePath, '.angular/cache'),
|
|
27
27
|
environment: workspace_schema_1.Environment.Local,
|
|
28
28
|
enabled: true,
|
|
29
29
|
};
|
|
@@ -39,7 +39,7 @@ function getCacheConfig(workspace) {
|
|
|
39
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
40
|
} = cacheSettings;
|
|
41
41
|
return {
|
|
42
|
-
path: (0,
|
|
42
|
+
path: (0, node_path_1.resolve)(workspace.basePath, path),
|
|
43
43
|
environment,
|
|
44
44
|
enabled,
|
|
45
45
|
};
|
|
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
const
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
14
|
const yargs_1 = __importDefault(require("yargs"));
|
|
15
15
|
const command_module_1 = require("../../command-builder/command-module");
|
|
16
16
|
const command_1 = require("../../command-builder/utilities/command");
|
|
@@ -20,7 +20,7 @@ const error_1 = require("../../utilities/error");
|
|
|
20
20
|
class CompletionCommandModule extends command_module_1.CommandModule {
|
|
21
21
|
command = 'completion';
|
|
22
22
|
describe = 'Set up Angular CLI autocompletion for your terminal.';
|
|
23
|
-
longDescriptionPath = (0,
|
|
23
|
+
longDescriptionPath = (0, node_path_1.join)(__dirname, 'long-description.md');
|
|
24
24
|
builder(localYargs) {
|
|
25
25
|
return (0, command_1.addCommandModuleToYargs)(localYargs, CompletionScriptCommandModule, this.context);
|
|
26
26
|
}
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const node_crypto_1 = require("node:crypto");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
12
|
const command_module_1 = require("../../command-builder/command-module");
|
|
13
13
|
const config_1 = require("../../utilities/config");
|
|
14
14
|
const json_file_1 = require("../../utilities/json-file");
|
|
15
15
|
class ConfigCommandModule extends command_module_1.CommandModule {
|
|
16
16
|
command = 'config [json-path] [value]';
|
|
17
17
|
describe = 'Retrieves or sets Angular configuration values in the angular.json file for the workspace.';
|
|
18
|
-
longDescriptionPath = (0,
|
|
18
|
+
longDescriptionPath = (0, node_path_1.join)(__dirname, 'long-description.md');
|
|
19
19
|
builder(localYargs) {
|
|
20
20
|
return localYargs
|
|
21
21
|
.positional('json-path', {
|
|
@@ -75,7 +75,7 @@ class ConfigCommandModule extends command_module_1.CommandModule {
|
|
|
75
75
|
if (!config || !configPath) {
|
|
76
76
|
throw new command_module_1.CommandModuleError('Confguration file cannot be found.');
|
|
77
77
|
}
|
|
78
|
-
const normalizeUUIDValue = (v) => (v === '' ? (0,
|
|
78
|
+
const normalizeUUIDValue = (v) => (v === '' ? (0, node_crypto_1.randomUUID)() : `${v}`);
|
|
79
79
|
const value = options.jsonPath === 'cli.analyticsSharing.uuid'
|
|
80
80
|
? normalizeUUIDValue(options.value)
|
|
81
81
|
: options.value;
|
package/src/commands/lint/cli.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
11
|
const architect_command_module_1 = require("../../command-builder/architect-command-module");
|
|
12
12
|
class LintCommandModule extends architect_command_module_1.ArchitectCommandModule {
|
|
13
13
|
missingTargetChoices = [
|
|
@@ -18,7 +18,7 @@ class LintCommandModule extends architect_command_module_1.ArchitectCommandModul
|
|
|
18
18
|
];
|
|
19
19
|
multiTarget = true;
|
|
20
20
|
command = 'lint [project]';
|
|
21
|
-
longDescriptionPath = (0,
|
|
21
|
+
longDescriptionPath = (0, node_path_1.join)(__dirname, 'long-description.md');
|
|
22
22
|
describe = 'Runs linting tools on Angular application code in a given project folder.';
|
|
23
23
|
}
|
|
24
24
|
exports.default = LintCommandModule;
|
package/src/commands/run/cli.js
CHANGED
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
11
|
const architect_base_command_module_1 = require("../../command-builder/architect-base-command-module");
|
|
12
12
|
const command_module_1 = require("../../command-builder/command-module");
|
|
13
13
|
class RunCommandModule extends architect_base_command_module_1.ArchitectBaseCommandModule {
|
|
14
14
|
scope = command_module_1.CommandScope.In;
|
|
15
15
|
command = 'run <target>';
|
|
16
16
|
describe = 'Runs an Architect target with an optional custom builder configuration defined in your project.';
|
|
17
|
-
longDescriptionPath = (0,
|
|
17
|
+
longDescriptionPath = (0, node_path_1.join)(__dirname, 'long-description.md');
|
|
18
18
|
async builder(argv) {
|
|
19
19
|
const { jsonHelp, getYargsCompletions, help } = this.context.args.options;
|
|
20
20
|
const localYargs = argv
|
package/src/commands/test/cli.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
11
|
const architect_command_module_1 = require("../../command-builder/architect-command-module");
|
|
12
12
|
const command_config_1 = require("../command-config");
|
|
13
13
|
class TestCommandModule extends architect_command_module_1.ArchitectCommandModule {
|
|
@@ -15,6 +15,6 @@ class TestCommandModule extends architect_command_module_1.ArchitectCommandModul
|
|
|
15
15
|
command = 'test [project]';
|
|
16
16
|
aliases = command_config_1.RootCommands['test'].aliases;
|
|
17
17
|
describe = 'Runs unit tests in a project.';
|
|
18
|
-
longDescriptionPath = (0,
|
|
18
|
+
longDescriptionPath = (0, node_path_1.join)(__dirname, 'long-description.md');
|
|
19
19
|
}
|
|
20
20
|
exports.default = TestCommandModule;
|
|
@@ -49,10 +49,10 @@ const listr2_1 = require("listr2");
|
|
|
49
49
|
const node_child_process_1 = require("node:child_process");
|
|
50
50
|
const node_fs_1 = require("node:fs");
|
|
51
51
|
const node_module_1 = require("node:module");
|
|
52
|
+
const path = __importStar(require("node:path"));
|
|
53
|
+
const node_path_1 = require("node:path");
|
|
52
54
|
const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
|
|
53
55
|
const npm_pick_manifest_1 = __importDefault(require("npm-pick-manifest"));
|
|
54
|
-
const path = __importStar(require("path"));
|
|
55
|
-
const path_1 = require("path");
|
|
56
56
|
const semver = __importStar(require("semver"));
|
|
57
57
|
const workspace_schema_1 = require("../../../lib/config/workspace-schema");
|
|
58
58
|
const command_module_1 = require("../../command-builder/command-module");
|
|
@@ -77,7 +77,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
77
77
|
resolvePaths = [__dirname, this.context.root];
|
|
78
78
|
command = 'update [packages..]';
|
|
79
79
|
describe = 'Updates your workspace and its dependencies. See https://update.angular.dev/.';
|
|
80
|
-
longDescriptionPath = (0,
|
|
80
|
+
longDescriptionPath = (0, node_path_1.join)(__dirname, 'long-description.md');
|
|
81
81
|
builder(localYargs) {
|
|
82
82
|
return localYargs
|
|
83
83
|
.positional('packages', {
|
|
@@ -773,8 +773,8 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
773
773
|
// Remove version/tag etc... from package name
|
|
774
774
|
// Ex: @angular/cli@latest -> @angular/cli
|
|
775
775
|
const packageNameNoVersion = packageName.substring(0, packageName.lastIndexOf('@'));
|
|
776
|
-
const pkgLocation = (0,
|
|
777
|
-
const packageJsonPath = (0,
|
|
776
|
+
const pkgLocation = (0, node_path_1.join)(tempNodeModules, packageNameNoVersion);
|
|
777
|
+
const packageJsonPath = (0, node_path_1.join)(pkgLocation, 'package.json');
|
|
778
778
|
// Get a binary location for this package
|
|
779
779
|
let binPath;
|
|
780
780
|
if ((0, node_fs_1.existsSync)(packageJsonPath)) {
|
|
@@ -783,7 +783,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
783
783
|
const { bin = {} } = JSON.parse(content);
|
|
784
784
|
const binKeys = Object.keys(bin);
|
|
785
785
|
if (binKeys.length) {
|
|
786
|
-
binPath = (0,
|
|
786
|
+
binPath = (0, node_path_1.resolve)(pkgLocation, bin[binKeys[0]]);
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
789
|
}
|
|
@@ -370,17 +370,20 @@ function _usageMessage(options, infoMap, logger) {
|
|
|
370
370
|
.filter(({ info, version, target }) => target?.['ng-update'] && semver.compare(info.installed.version, version) < 0)
|
|
371
371
|
.map(({ name, info, version, tag, target }) => {
|
|
372
372
|
// Look for packageGroup.
|
|
373
|
-
const
|
|
373
|
+
const ngUpdate = target['ng-update'];
|
|
374
|
+
const packageGroup = ngUpdate?.['packageGroup'];
|
|
374
375
|
if (packageGroup) {
|
|
375
376
|
const packageGroupNames = Array.isArray(packageGroup)
|
|
376
377
|
? packageGroup
|
|
377
378
|
: Object.keys(packageGroup);
|
|
378
|
-
const packageGroupName =
|
|
379
|
+
const packageGroupName = ngUpdate?.['packageGroupName'] || packageGroupNames.find((n) => infoMap.has(n));
|
|
379
380
|
if (packageGroupName) {
|
|
380
381
|
if (packageGroups.has(name)) {
|
|
381
382
|
return null;
|
|
382
383
|
}
|
|
383
|
-
|
|
384
|
+
for (const groupName of packageGroupNames) {
|
|
385
|
+
packageGroups.set(groupName, packageGroupName);
|
|
386
|
+
}
|
|
384
387
|
packageGroups.set(packageGroupName, packageGroupName);
|
|
385
388
|
name = packageGroupName;
|
|
386
389
|
}
|
|
@@ -44,10 +44,10 @@ exports.considerSettingUpAutocompletion = considerSettingUpAutocompletion;
|
|
|
44
44
|
exports.initializeAutocomplete = initializeAutocomplete;
|
|
45
45
|
exports.hasGlobalCliInstall = hasGlobalCliInstall;
|
|
46
46
|
const core_1 = require("@angular-devkit/core");
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const path = __importStar(require("path"));
|
|
50
|
-
const
|
|
47
|
+
const node_child_process_1 = require("node:child_process");
|
|
48
|
+
const node_fs_1 = require("node:fs");
|
|
49
|
+
const path = __importStar(require("node:path"));
|
|
50
|
+
const node_process_1 = require("node:process");
|
|
51
51
|
const color_1 = require("../utilities/color");
|
|
52
52
|
const config_1 = require("../utilities/config");
|
|
53
53
|
const environment_options_1 = require("../utilities/environment-options");
|
|
@@ -142,12 +142,12 @@ async function shouldPromptForAutocompletionSetup(command, config) {
|
|
|
142
142
|
return false;
|
|
143
143
|
}
|
|
144
144
|
// `$HOME` variable is necessary to find RC files to modify.
|
|
145
|
-
const home =
|
|
145
|
+
const home = node_process_1.env['HOME'];
|
|
146
146
|
if (!home) {
|
|
147
147
|
return false;
|
|
148
148
|
}
|
|
149
149
|
// Get possible RC files for the current shell.
|
|
150
|
-
const shell =
|
|
150
|
+
const shell = node_process_1.env['SHELL'];
|
|
151
151
|
if (!shell) {
|
|
152
152
|
return false;
|
|
153
153
|
}
|
|
@@ -162,7 +162,7 @@ async function shouldPromptForAutocompletionSetup(command, config) {
|
|
|
162
162
|
}
|
|
163
163
|
// Check each RC file if they already use `ng completion script` in any capacity and don't prompt.
|
|
164
164
|
for (const rcFile of rcFiles) {
|
|
165
|
-
const contents = await
|
|
165
|
+
const contents = await node_fs_1.promises.readFile(rcFile, 'utf-8').catch(() => undefined);
|
|
166
166
|
if (contents?.includes('ng completion script')) {
|
|
167
167
|
return false;
|
|
168
168
|
}
|
|
@@ -188,14 +188,14 @@ will modify configuration files in your home directory.)
|
|
|
188
188
|
*/
|
|
189
189
|
async function initializeAutocomplete() {
|
|
190
190
|
// Get the currently active `$SHELL` and `$HOME` environment variables.
|
|
191
|
-
const shell =
|
|
191
|
+
const shell = node_process_1.env['SHELL'];
|
|
192
192
|
if (!shell) {
|
|
193
193
|
throw new Error('`$SHELL` environment variable not set. Angular CLI autocompletion only supports Bash or' +
|
|
194
194
|
" Zsh. If you're on Windows, Cmd and Powershell don't support command autocompletion," +
|
|
195
195
|
' but Git Bash or Windows Subsystem for Linux should work, so please try again in one of' +
|
|
196
196
|
' those environments.');
|
|
197
197
|
}
|
|
198
|
-
const home =
|
|
198
|
+
const home = node_process_1.env['HOME'];
|
|
199
199
|
if (!home) {
|
|
200
200
|
throw new Error('`$HOME` environment variable not set. Setting up autocompletion modifies configuration files' +
|
|
201
201
|
' in the home directory and must be set.');
|
|
@@ -206,11 +206,11 @@ async function initializeAutocomplete() {
|
|
|
206
206
|
throw new Error(`Unknown \`$SHELL\` environment variable value (${shell}). Angular CLI autocompletion only supports Bash or Zsh.`);
|
|
207
207
|
}
|
|
208
208
|
// Get the first file that already exists or fallback to a new file of the first candidate.
|
|
209
|
-
const candidates = await Promise.allSettled(runCommandCandidates.map((rcFile) =>
|
|
209
|
+
const candidates = await Promise.allSettled(runCommandCandidates.map((rcFile) => node_fs_1.promises.access(rcFile).then(() => rcFile)));
|
|
210
210
|
const rcFile = candidates.find((result) => result.status === 'fulfilled')?.value ?? runCommandCandidates[0];
|
|
211
211
|
// Append Angular autocompletion setup to RC file.
|
|
212
212
|
try {
|
|
213
|
-
await
|
|
213
|
+
await node_fs_1.promises.appendFile(rcFile, '\n\n# Load Angular CLI autocompletion.\nsource <(ng completion script)\n');
|
|
214
214
|
}
|
|
215
215
|
catch (err) {
|
|
216
216
|
(0, error_1.assertIsError)(err);
|
|
@@ -240,7 +240,7 @@ function getShellRunCommandCandidates(shell, home) {
|
|
|
240
240
|
function hasGlobalCliInstall() {
|
|
241
241
|
// List all binaries with the `ng` name on the user's `$PATH`.
|
|
242
242
|
return new Promise((resolve) => {
|
|
243
|
-
(0,
|
|
243
|
+
(0, node_child_process_1.execFile)('which', ['-a', 'ng'], (error, stdout) => {
|
|
244
244
|
if (error) {
|
|
245
245
|
// No instances of `ng` on the user's `$PATH`
|
|
246
246
|
// `which` returns exit code 2 if an invalid option is specified and `-a` doesn't appear to be
|
package/src/utilities/config.js
CHANGED
|
@@ -49,9 +49,9 @@ exports.getConfiguredPackageManager = getConfiguredPackageManager;
|
|
|
49
49
|
exports.getSchematicDefaults = getSchematicDefaults;
|
|
50
50
|
exports.isWarningEnabled = isWarningEnabled;
|
|
51
51
|
const core_1 = require("@angular-devkit/core");
|
|
52
|
-
const
|
|
53
|
-
const os = __importStar(require("os"));
|
|
54
|
-
const path = __importStar(require("path"));
|
|
52
|
+
const node_fs_1 = require("node:fs");
|
|
53
|
+
const os = __importStar(require("node:os"));
|
|
54
|
+
const path = __importStar(require("node:path"));
|
|
55
55
|
const find_up_1 = require("./find-up");
|
|
56
56
|
const json_file_1 = require("./json-file");
|
|
57
57
|
function isJsonObject(value) {
|
|
@@ -60,14 +60,14 @@ function isJsonObject(value) {
|
|
|
60
60
|
function createWorkspaceHost() {
|
|
61
61
|
return {
|
|
62
62
|
readFile(path) {
|
|
63
|
-
return
|
|
63
|
+
return node_fs_1.promises.readFile(path, 'utf-8');
|
|
64
64
|
},
|
|
65
65
|
async writeFile(path, data) {
|
|
66
|
-
await
|
|
66
|
+
await node_fs_1.promises.writeFile(path, data);
|
|
67
67
|
},
|
|
68
68
|
async isDirectory(path) {
|
|
69
69
|
try {
|
|
70
|
-
const stats = await
|
|
70
|
+
const stats = await node_fs_1.promises.stat(path);
|
|
71
71
|
return stats.isDirectory();
|
|
72
72
|
}
|
|
73
73
|
catch {
|
|
@@ -76,7 +76,7 @@ function createWorkspaceHost() {
|
|
|
76
76
|
},
|
|
77
77
|
async isFile(path) {
|
|
78
78
|
try {
|
|
79
|
-
const stats = await
|
|
79
|
+
const stats = await node_fs_1.promises.stat(path);
|
|
80
80
|
return stats.isFile();
|
|
81
81
|
}
|
|
82
82
|
catch {
|
|
@@ -119,19 +119,19 @@ function globalFilePath() {
|
|
|
119
119
|
// global file in home directory, with this user will have
|
|
120
120
|
// choice to move change its location to meet XDG convention
|
|
121
121
|
const xdgConfig = xdgConfigHome(home, 'config.json');
|
|
122
|
-
if ((0,
|
|
122
|
+
if ((0, node_fs_1.existsSync)(xdgConfig)) {
|
|
123
123
|
return xdgConfig;
|
|
124
124
|
}
|
|
125
125
|
// NOTE: This check is for the old configuration location, for more
|
|
126
126
|
// information see https://github.com/angular/angular-cli/pull/20556
|
|
127
127
|
const xdgConfigOld = xdgConfigHomeOld(home);
|
|
128
|
-
if ((0,
|
|
128
|
+
if ((0, node_fs_1.existsSync)(xdgConfigOld)) {
|
|
129
129
|
/* eslint-disable no-console */
|
|
130
130
|
console.warn(`Old configuration location detected: ${xdgConfigOld}\n` +
|
|
131
131
|
`Please move the file to the new location ~/.config/angular/config.json`);
|
|
132
132
|
return xdgConfigOld;
|
|
133
133
|
}
|
|
134
|
-
if ((0,
|
|
134
|
+
if ((0, node_fs_1.existsSync)(defaultGlobalFilePath)) {
|
|
135
135
|
return defaultGlobalFilePath;
|
|
136
136
|
}
|
|
137
137
|
return null;
|
package/src/utilities/error.js
CHANGED
|
@@ -11,10 +11,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.assertIsError = assertIsError;
|
|
14
|
-
const
|
|
14
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
15
15
|
function assertIsError(value) {
|
|
16
16
|
const isError = value instanceof Error ||
|
|
17
17
|
// The following is needing to identify errors coming from RxJs.
|
|
18
18
|
(typeof value === 'object' && value && 'name' in value && 'message' in value);
|
|
19
|
-
(0,
|
|
19
|
+
(0, node_assert_1.default)(isError, 'catch clause variable is not an Error instance');
|
|
20
20
|
}
|
package/src/utilities/find-up.js
CHANGED
|
@@ -41,8 +41,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
41
|
})();
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.findUp = findUp;
|
|
44
|
-
const
|
|
45
|
-
const path = __importStar(require("path"));
|
|
44
|
+
const node_fs_1 = require("node:fs");
|
|
45
|
+
const path = __importStar(require("node:path"));
|
|
46
46
|
function findUp(names, from) {
|
|
47
47
|
if (!Array.isArray(names)) {
|
|
48
48
|
names = [names];
|
|
@@ -52,7 +52,7 @@ function findUp(names, from) {
|
|
|
52
52
|
while (currentDir && currentDir !== root) {
|
|
53
53
|
for (const name of names) {
|
|
54
54
|
const p = path.join(currentDir, name);
|
|
55
|
-
if ((0,
|
|
55
|
+
if ((0, node_fs_1.existsSync)(p)) {
|
|
56
56
|
return p;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -10,8 +10,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.JSONFile = void 0;
|
|
11
11
|
exports.readAndParseJson = readAndParseJson;
|
|
12
12
|
exports.parseJson = parseJson;
|
|
13
|
-
const fs_1 = require("fs");
|
|
14
13
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
14
|
+
const node_fs_1 = require("node:fs");
|
|
15
15
|
const eol_1 = require("./eol");
|
|
16
16
|
/** @internal */
|
|
17
17
|
class JSONFile {
|
|
@@ -20,7 +20,7 @@ class JSONFile {
|
|
|
20
20
|
eol;
|
|
21
21
|
constructor(path) {
|
|
22
22
|
this.path = path;
|
|
23
|
-
const buffer = (0,
|
|
23
|
+
const buffer = (0, node_fs_1.readFileSync)(this.path);
|
|
24
24
|
if (buffer) {
|
|
25
25
|
this.content = buffer.toString();
|
|
26
26
|
}
|
|
@@ -82,14 +82,14 @@ class JSONFile {
|
|
|
82
82
|
return true;
|
|
83
83
|
}
|
|
84
84
|
save() {
|
|
85
|
-
(0,
|
|
85
|
+
(0, node_fs_1.writeFileSync)(this.path, this.content);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
exports.JSONFile = JSONFile;
|
|
89
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
90
|
function readAndParseJson(path) {
|
|
91
91
|
const errors = [];
|
|
92
|
-
const content = (0, jsonc_parser_1.parse)((0,
|
|
92
|
+
const content = (0, jsonc_parser_1.parse)((0, node_fs_1.readFileSync)(path, 'utf-8'), errors, { allowTrailingComma: true });
|
|
93
93
|
if (errors.length) {
|
|
94
94
|
formatError(path, errors);
|
|
95
95
|
}
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.writeErrorToLogFile = writeErrorToLogFile;
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
|
+
const node_os_1 = require("node:os");
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
14
|
let logPath;
|
|
15
15
|
/**
|
|
16
16
|
* Writes an Error to a temporary log file.
|
|
@@ -19,9 +19,9 @@ let logPath;
|
|
|
19
19
|
*/
|
|
20
20
|
function writeErrorToLogFile(error) {
|
|
21
21
|
if (!logPath) {
|
|
22
|
-
const tempDirectory = (0,
|
|
23
|
-
logPath = (0,
|
|
22
|
+
const tempDirectory = (0, node_fs_1.mkdtempSync)((0, node_fs_1.realpathSync)((0, node_os_1.tmpdir)()) + '/ng-');
|
|
23
|
+
logPath = (0, node_path_1.normalize)(tempDirectory + '/angular-errors.log');
|
|
24
24
|
}
|
|
25
|
-
(0,
|
|
25
|
+
(0, node_fs_1.appendFileSync)(logPath, '[error] ' + (error.stack || error) + '\n\n');
|
|
26
26
|
return logPath;
|
|
27
27
|
}
|
|
@@ -43,10 +43,10 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
44
|
exports.PackageManagerUtils = void 0;
|
|
45
45
|
const core_1 = require("@angular-devkit/core");
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
46
|
+
const node_child_process_1 = require("node:child_process");
|
|
47
|
+
const node_fs_1 = require("node:fs");
|
|
48
|
+
const node_os_1 = require("node:os");
|
|
49
|
+
const node_path_1 = require("node:path");
|
|
50
50
|
const workspace_schema_1 = require("../../lib/config/workspace-schema");
|
|
51
51
|
const config_1 = require("./config");
|
|
52
52
|
const memoize_1 = require("./memoize");
|
|
@@ -95,11 +95,11 @@ let PackageManagerUtils = (() => {
|
|
|
95
95
|
}
|
|
96
96
|
/** Install a single package temporary. */
|
|
97
97
|
async installTemp(packageName, extraArgs) {
|
|
98
|
-
const tempPath = await
|
|
98
|
+
const tempPath = await node_fs_1.promises.mkdtemp((0, node_path_1.join)((0, node_fs_1.realpathSync)((0, node_os_1.tmpdir)()), 'angular-cli-packages-'));
|
|
99
99
|
// clean up temp directory on process exit
|
|
100
100
|
process.on('exit', () => {
|
|
101
101
|
try {
|
|
102
|
-
(0,
|
|
102
|
+
(0, node_fs_1.rmSync)(tempPath, { recursive: true, maxRetries: 3 });
|
|
103
103
|
}
|
|
104
104
|
catch { }
|
|
105
105
|
});
|
|
@@ -111,7 +111,7 @@ let PackageManagerUtils = (() => {
|
|
|
111
111
|
// npm WARN .ng-temp-packages-84Qi7y No license field.
|
|
112
112
|
// While we can use `npm init -y` we will end up needing to update the 'package.json' anyways
|
|
113
113
|
// because of missing fields.
|
|
114
|
-
await
|
|
114
|
+
await node_fs_1.promises.writeFile((0, node_path_1.join)(tempPath, 'package.json'), JSON.stringify({
|
|
115
115
|
name: 'temp-cli-install',
|
|
116
116
|
description: 'temp-cli-install',
|
|
117
117
|
repository: 'temp-cli-install',
|
|
@@ -119,7 +119,7 @@ let PackageManagerUtils = (() => {
|
|
|
119
119
|
}));
|
|
120
120
|
// setup prefix/global modules path
|
|
121
121
|
const packageManagerArgs = this.getArguments();
|
|
122
|
-
const tempNodeModules = (0,
|
|
122
|
+
const tempNodeModules = (0, node_path_1.join)(tempPath, 'node_modules');
|
|
123
123
|
// Yarn will not append 'node_modules' to the path
|
|
124
124
|
const prefixPath = this.name === workspace_schema_1.PackageManager.Yarn ? tempNodeModules : tempPath;
|
|
125
125
|
const installArgs = [
|
|
@@ -171,7 +171,7 @@ let PackageManagerUtils = (() => {
|
|
|
171
171
|
const { cwd = process.cwd(), silent = false } = options;
|
|
172
172
|
return new Promise((resolve) => {
|
|
173
173
|
const bufferedOutput = [];
|
|
174
|
-
const childProcess = (0,
|
|
174
|
+
const childProcess = (0, node_child_process_1.spawn)(this.name, args, {
|
|
175
175
|
// Always pipe stderr to allow for failures to be reported
|
|
176
176
|
stdio: silent ? ['ignore', 'ignore', 'pipe'] : 'pipe',
|
|
177
177
|
shell: true,
|
|
@@ -191,7 +191,7 @@ let PackageManagerUtils = (() => {
|
|
|
191
191
|
}
|
|
192
192
|
getVersion(name) {
|
|
193
193
|
try {
|
|
194
|
-
return (0,
|
|
194
|
+
return (0, node_child_process_1.execSync)(`${name} --version`, {
|
|
195
195
|
encoding: 'utf8',
|
|
196
196
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
197
197
|
env: {
|
|
@@ -276,7 +276,7 @@ let PackageManagerUtils = (() => {
|
|
|
276
276
|
lockfileName = 'package-lock.json';
|
|
277
277
|
break;
|
|
278
278
|
}
|
|
279
|
-
return (0,
|
|
279
|
+
return (0, node_fs_1.existsSync)((0, node_path_1.join)(this.context.root, lockfileName));
|
|
280
280
|
}
|
|
281
281
|
getConfiguredPackageManager() {
|
|
282
282
|
const getPackageManager = (source) => {
|
|
@@ -44,10 +44,10 @@ exports.fetchPackageMetadata = fetchPackageMetadata;
|
|
|
44
44
|
exports.fetchPackageManifest = fetchPackageManifest;
|
|
45
45
|
exports.getNpmPackageJson = getNpmPackageJson;
|
|
46
46
|
const lockfile = __importStar(require("@yarnpkg/lockfile"));
|
|
47
|
-
const fs_1 = require("fs");
|
|
48
47
|
const ini = __importStar(require("ini"));
|
|
49
|
-
const
|
|
50
|
-
const
|
|
48
|
+
const node_fs_1 = require("node:fs");
|
|
49
|
+
const node_os_1 = require("node:os");
|
|
50
|
+
const path = __importStar(require("node:path"));
|
|
51
51
|
let npmrc;
|
|
52
52
|
const npmPackageJsonCache = new Map();
|
|
53
53
|
function ensureNpmrc(logger, usingYarn, verbose) {
|
|
@@ -80,7 +80,7 @@ function readOptions(logger, yarn = false, showPotentials = false) {
|
|
|
80
80
|
}
|
|
81
81
|
const defaultConfigLocations = [
|
|
82
82
|
(!yarn && process.env.NPM_CONFIG_GLOBALCONFIG) || path.join(globalPrefix, 'etc', baseFilename),
|
|
83
|
-
(!yarn && process.env.NPM_CONFIG_USERCONFIG) || path.join((0,
|
|
83
|
+
(!yarn && process.env.NPM_CONFIG_USERCONFIG) || path.join((0, node_os_1.homedir)(), dotFilename),
|
|
84
84
|
];
|
|
85
85
|
const projectConfigLocations = [path.join(cwd, dotFilename)];
|
|
86
86
|
if (yarn) {
|
|
@@ -94,11 +94,11 @@ function readOptions(logger, yarn = false, showPotentials = false) {
|
|
|
94
94
|
}
|
|
95
95
|
let rcOptions = {};
|
|
96
96
|
for (const location of [...defaultConfigLocations, ...projectConfigLocations]) {
|
|
97
|
-
if ((0,
|
|
97
|
+
if ((0, node_fs_1.existsSync)(location)) {
|
|
98
98
|
if (showPotentials) {
|
|
99
99
|
logger.info(`Trying '${location}'...found.`);
|
|
100
100
|
}
|
|
101
|
-
const data = (0,
|
|
101
|
+
const data = (0, node_fs_1.readFileSync)(location, 'utf8');
|
|
102
102
|
// Normalize RC options that are needed by 'npm-registry-fetch'.
|
|
103
103
|
// See: https://github.com/npm/npm-registry-fetch/blob/ebddbe78a5f67118c1f7af2e02c8a22bcaf9e850/index.js#L99-L126
|
|
104
104
|
const rcConfig = yarn ? lockfile.parse(data) : ini.parse(data);
|
|
@@ -177,7 +177,7 @@ function normalizeOptions(rawOptions, location = process.cwd(), existingNormaliz
|
|
|
177
177
|
if (typeof substitutedValue === 'string') {
|
|
178
178
|
const cafile = path.resolve(path.dirname(location), substitutedValue);
|
|
179
179
|
try {
|
|
180
|
-
options['ca'] = (0,
|
|
180
|
+
options['ca'] = (0, node_fs_1.readFileSync)(cafile, 'utf8').replace(/\r?\n/g, '\n');
|
|
181
181
|
}
|
|
182
182
|
catch { }
|
|
183
183
|
}
|
|
@@ -43,8 +43,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
43
43
|
exports.readPackageJson = readPackageJson;
|
|
44
44
|
exports.findPackageJson = findPackageJson;
|
|
45
45
|
exports.getProjectDependencies = getProjectDependencies;
|
|
46
|
-
const fs = __importStar(require("fs"));
|
|
47
|
-
const
|
|
46
|
+
const fs = __importStar(require("node:fs"));
|
|
47
|
+
const node_path_1 = require("node:path");
|
|
48
48
|
const resolve = __importStar(require("resolve"));
|
|
49
49
|
function getAllDependencies(pkg) {
|
|
50
50
|
return new Set([
|
|
@@ -73,7 +73,7 @@ function findPackageJson(workspaceDir, packageName) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
async function getProjectDependencies(dir) {
|
|
76
|
-
const pkg = await readPackageJson((0,
|
|
76
|
+
const pkg = await readPackageJson((0, node_path_1.join)(dir, 'package.json'));
|
|
77
77
|
if (!pkg) {
|
|
78
78
|
throw new Error('Could not find package.json');
|
|
79
79
|
}
|
|
@@ -86,7 +86,7 @@ async function getProjectDependencies(dir) {
|
|
|
86
86
|
results.set(name, {
|
|
87
87
|
name,
|
|
88
88
|
version,
|
|
89
|
-
path: (0,
|
|
89
|
+
path: (0, node_path_1.dirname)(packageJsonPath),
|
|
90
90
|
package: await readPackageJson(packageJsonPath),
|
|
91
91
|
});
|
|
92
92
|
}
|
package/src/utilities/project.js
CHANGED
|
@@ -42,9 +42,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.findWorkspaceFile = findWorkspaceFile;
|
|
44
44
|
const core_1 = require("@angular-devkit/core");
|
|
45
|
-
const fs = __importStar(require("fs"));
|
|
46
|
-
const os = __importStar(require("os"));
|
|
47
|
-
const path = __importStar(require("path"));
|
|
45
|
+
const fs = __importStar(require("node:fs"));
|
|
46
|
+
const os = __importStar(require("node:os"));
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
48
48
|
const find_up_1 = require("./find-up");
|
|
49
49
|
function findWorkspaceFile(currentDirectory = process.cwd()) {
|
|
50
50
|
const possibleConfigFiles = ['angular.json', '.angular.json'];
|
package/src/utilities/version.js
CHANGED