@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
|
@@ -48,20 +48,11 @@ const command_module_1 = require("../../command-builder/command-module");
|
|
|
48
48
|
const schematic_engine_host_1 = require("../../command-builder/utilities/schematic-engine-host");
|
|
49
49
|
const schematic_workflow_1 = require("../../command-builder/utilities/schematic-workflow");
|
|
50
50
|
const color_1 = require("../../utilities/color");
|
|
51
|
-
const
|
|
51
|
+
const environment_options_1 = require("../../utilities/environment-options");
|
|
52
52
|
const log_file_1 = require("../../utilities/log-file");
|
|
53
|
-
const package_manager_1 = require("../../utilities/package-manager");
|
|
54
53
|
const package_metadata_1 = require("../../utilities/package-metadata");
|
|
55
54
|
const package_tree_1 = require("../../utilities/package-tree");
|
|
56
55
|
const version_1 = require("../../utilities/version");
|
|
57
|
-
/**
|
|
58
|
-
* Disable CLI version mismatch checks and forces usage of the invoked CLI
|
|
59
|
-
* instead of invoking the local installed version.
|
|
60
|
-
*/
|
|
61
|
-
const disableVersionCheckEnv = process.env['NG_DISABLE_VERSION_CHECK'];
|
|
62
|
-
const disableVersionCheck = disableVersionCheckEnv !== undefined &&
|
|
63
|
-
disableVersionCheckEnv !== '0' &&
|
|
64
|
-
disableVersionCheckEnv.toLowerCase() !== 'false';
|
|
65
56
|
const ANGULAR_PACKAGES_REGEXP = /^@(?:angular|nguniversal)\//;
|
|
66
57
|
const UPDATE_SCHEMATIC_COLLECTION = path.join(__dirname, 'schematic/collection.json');
|
|
67
58
|
class UpdateCommandModule extends command_module_1.CommandModule {
|
|
@@ -76,7 +67,8 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
76
67
|
return localYargs
|
|
77
68
|
.positional('packages', {
|
|
78
69
|
description: 'The names of package(s) to update.',
|
|
79
|
-
|
|
70
|
+
type: 'string',
|
|
71
|
+
array: true,
|
|
80
72
|
})
|
|
81
73
|
.option('force', {
|
|
82
74
|
description: 'Ignore peer dependency version mismatches. ' +
|
|
@@ -156,14 +148,14 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
156
148
|
async run(options) {
|
|
157
149
|
var _a, _b;
|
|
158
150
|
const { logger, packageManager } = this.context;
|
|
159
|
-
|
|
151
|
+
packageManager.ensureCompatibility();
|
|
160
152
|
// Check if the current installed CLI version is older than the latest compatible version.
|
|
161
|
-
if (!disableVersionCheck) {
|
|
153
|
+
if (!environment_options_1.disableVersionCheck) {
|
|
162
154
|
const cliVersionToInstall = await this.checkCLIVersion(options.packages, options.verbose, options.next);
|
|
163
155
|
if (cliVersionToInstall) {
|
|
164
156
|
logger.warn('The installed Angular CLI version is outdated.\n' +
|
|
165
157
|
`Installing a temporary Angular CLI versioned ${cliVersionToInstall} to perform the update.`);
|
|
166
|
-
return
|
|
158
|
+
return this.runTempBinary(`@angular/cli@${cliVersionToInstall}`, process.argv.slice(2));
|
|
167
159
|
}
|
|
168
160
|
}
|
|
169
161
|
const packages = [];
|
|
@@ -193,12 +185,12 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
193
185
|
return 1;
|
|
194
186
|
}
|
|
195
187
|
}
|
|
196
|
-
logger.info(`Using package manager:
|
|
188
|
+
logger.info(`Using package manager: ${color_1.colors.grey(packageManager.name)}`);
|
|
197
189
|
logger.info('Collecting installed dependencies...');
|
|
198
190
|
const rootDependencies = await (0, package_tree_1.getProjectDependencies)(this.context.root);
|
|
199
191
|
logger.info(`Found ${rootDependencies.size} dependencies.`);
|
|
200
192
|
const workflow = new tools_1.NodeWorkflow(this.context.root, {
|
|
201
|
-
packageManager:
|
|
193
|
+
packageManager: packageManager.name,
|
|
202
194
|
packageManagerForce: options.force,
|
|
203
195
|
// __dirname -> favor @schematics/update from this package
|
|
204
196
|
// Otherwise, use packages from the active workspace (migrations)
|
|
@@ -212,7 +204,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
212
204
|
force: options.force,
|
|
213
205
|
next: options.next,
|
|
214
206
|
verbose: options.verbose,
|
|
215
|
-
packageManager,
|
|
207
|
+
packageManager: packageManager.name,
|
|
216
208
|
packages: [],
|
|
217
209
|
});
|
|
218
210
|
return success ? 0 : 1;
|
|
@@ -509,7 +501,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
509
501
|
verbose: options.verbose,
|
|
510
502
|
force: options.force,
|
|
511
503
|
next: options.next,
|
|
512
|
-
packageManager: this.context.packageManager,
|
|
504
|
+
packageManager: this.context.packageManager.name,
|
|
513
505
|
packages: packagesToUpdate,
|
|
514
506
|
});
|
|
515
507
|
if (success) {
|
|
@@ -521,9 +513,9 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
521
513
|
});
|
|
522
514
|
}
|
|
523
515
|
catch { }
|
|
524
|
-
const
|
|
525
|
-
if (
|
|
526
|
-
return
|
|
516
|
+
const installationSuccess = await this.context.packageManager.installAll(options.force ? ['--force'] : [], this.context.root);
|
|
517
|
+
if (!installationSuccess) {
|
|
518
|
+
return 1;
|
|
527
519
|
}
|
|
528
520
|
}
|
|
529
521
|
if (success && options.createCommits) {
|
|
@@ -665,9 +657,9 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
665
657
|
* @returns the version to install or null when there is no update to install.
|
|
666
658
|
*/
|
|
667
659
|
async checkCLIVersion(packagesToUpdate, verbose = false, next = false) {
|
|
668
|
-
const { version } = await (0, package_metadata_1.fetchPackageManifest)(`@angular/cli@${this.getCLIUpdateRunnerVersion(
|
|
660
|
+
const { version } = await (0, package_metadata_1.fetchPackageManifest)(`@angular/cli@${this.getCLIUpdateRunnerVersion(packagesToUpdate, next)}`, this.context.logger, {
|
|
669
661
|
verbose,
|
|
670
|
-
usingYarn: this.context.packageManager === workspace_schema_1.PackageManager.Yarn,
|
|
662
|
+
usingYarn: this.context.packageManager.name === workspace_schema_1.PackageManager.Yarn,
|
|
671
663
|
});
|
|
672
664
|
return version_1.VERSION.full === version ? null : version;
|
|
673
665
|
}
|
|
@@ -694,6 +686,44 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
694
686
|
// We end up using Angular ClI v13 to run the migrations if we run the migrations using the CLI installed major version + 1 logic.
|
|
695
687
|
return version_1.VERSION.major;
|
|
696
688
|
}
|
|
689
|
+
async runTempBinary(packageName, args = []) {
|
|
690
|
+
const { success, tempNodeModules } = await this.context.packageManager.installTemp(packageName);
|
|
691
|
+
if (!success) {
|
|
692
|
+
return 1;
|
|
693
|
+
}
|
|
694
|
+
// Remove version/tag etc... from package name
|
|
695
|
+
// Ex: @angular/cli@latest -> @angular/cli
|
|
696
|
+
const packageNameNoVersion = packageName.substring(0, packageName.lastIndexOf('@'));
|
|
697
|
+
const pkgLocation = (0, path_1.join)(tempNodeModules, packageNameNoVersion);
|
|
698
|
+
const packageJsonPath = (0, path_1.join)(pkgLocation, 'package.json');
|
|
699
|
+
// Get a binary location for this package
|
|
700
|
+
let binPath;
|
|
701
|
+
if ((0, fs_1.existsSync)(packageJsonPath)) {
|
|
702
|
+
const content = await fs_1.promises.readFile(packageJsonPath, 'utf-8');
|
|
703
|
+
if (content) {
|
|
704
|
+
const { bin = {} } = JSON.parse(content);
|
|
705
|
+
const binKeys = Object.keys(bin);
|
|
706
|
+
if (binKeys.length) {
|
|
707
|
+
binPath = (0, path_1.resolve)(pkgLocation, bin[binKeys[0]]);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
if (!binPath) {
|
|
712
|
+
throw new Error(`Cannot locate bin for temporary package: ${packageNameNoVersion}.`);
|
|
713
|
+
}
|
|
714
|
+
const { status, error } = (0, child_process_1.spawnSync)(process.execPath, [binPath, ...args], {
|
|
715
|
+
stdio: 'inherit',
|
|
716
|
+
env: {
|
|
717
|
+
...process.env,
|
|
718
|
+
NG_DISABLE_VERSION_CHECK: 'true',
|
|
719
|
+
NG_CLI_ANALYTICS: 'false',
|
|
720
|
+
},
|
|
721
|
+
});
|
|
722
|
+
if (status === null && error) {
|
|
723
|
+
throw error;
|
|
724
|
+
}
|
|
725
|
+
return status !== null && status !== void 0 ? status : 0;
|
|
726
|
+
}
|
|
697
727
|
}
|
|
698
728
|
exports.UpdateCommandModule = UpdateCommandModule;
|
|
699
729
|
UpdateCommandModule.scope = command_module_1.CommandScope.In;
|
|
@@ -286,6 +286,7 @@ function _getUpdateMetadata(packageJson, logger) {
|
|
|
286
286
|
}
|
|
287
287
|
else if (typeof packageGroup == 'object' &&
|
|
288
288
|
packageGroup &&
|
|
289
|
+
!Array.isArray(packageGroup) &&
|
|
289
290
|
Object.values(packageGroup).every((x) => typeof x == 'string')) {
|
|
290
291
|
result.packageGroup = packageGroup;
|
|
291
292
|
}
|
|
@@ -362,23 +363,26 @@ function _usageMessage(options, infoMap, logger) {
|
|
|
362
363
|
})
|
|
363
364
|
.filter(({ info, version, target }) => (target === null || target === void 0 ? void 0 : target['ng-update']) && semver.compare(info.installed.version, version) < 0)
|
|
364
365
|
.map(({ name, info, version, tag, target }) => {
|
|
365
|
-
var _a;
|
|
366
|
+
var _a, _b, _c;
|
|
366
367
|
// Look for packageGroup.
|
|
367
|
-
const packageGroup = target['ng-update']['packageGroup'];
|
|
368
|
+
const packageGroup = (_a = target['ng-update']) === null || _a === void 0 ? void 0 : _a['packageGroup'];
|
|
368
369
|
if (packageGroup) {
|
|
369
|
-
const
|
|
370
|
+
const packageGroupNames = Array.isArray(packageGroup)
|
|
371
|
+
? packageGroup
|
|
372
|
+
: Object.keys(packageGroup);
|
|
373
|
+
const packageGroupName = ((_b = target['ng-update']) === null || _b === void 0 ? void 0 : _b['packageGroupName']) || packageGroupNames[0];
|
|
370
374
|
if (packageGroupName) {
|
|
371
375
|
if (packageGroups.has(name)) {
|
|
372
376
|
return null;
|
|
373
377
|
}
|
|
374
|
-
|
|
378
|
+
packageGroupNames.forEach((x) => packageGroups.set(x, packageGroupName));
|
|
375
379
|
packageGroups.set(packageGroupName, packageGroupName);
|
|
376
380
|
name = packageGroupName;
|
|
377
381
|
}
|
|
378
382
|
}
|
|
379
383
|
let command = `ng update ${name}`;
|
|
380
384
|
if (!tag) {
|
|
381
|
-
command += `@${((
|
|
385
|
+
command += `@${((_c = semver.parse(version)) === null || _c === void 0 ? void 0 : _c.major) || version}`;
|
|
382
386
|
}
|
|
383
387
|
else if (tag == 'next') {
|
|
384
388
|
command += ' --next';
|
|
@@ -508,29 +512,34 @@ function _addPackageGroup(tree, packages, allDependencies, npmPackageJson, logge
|
|
|
508
512
|
if (!ngUpdateMetadata) {
|
|
509
513
|
return;
|
|
510
514
|
}
|
|
511
|
-
|
|
515
|
+
const packageGroup = ngUpdateMetadata['packageGroup'];
|
|
512
516
|
if (!packageGroup) {
|
|
513
517
|
return;
|
|
514
518
|
}
|
|
519
|
+
let packageGroupNormalized = {};
|
|
515
520
|
if (Array.isArray(packageGroup) && !packageGroup.some((x) => typeof x != 'string')) {
|
|
516
|
-
|
|
521
|
+
packageGroupNormalized = packageGroup.reduce((acc, curr) => {
|
|
517
522
|
acc[curr] = maybePackage;
|
|
518
523
|
return acc;
|
|
519
524
|
}, {});
|
|
520
525
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
packageGroup
|
|
524
|
-
Object.values(packageGroup).
|
|
525
|
-
|
|
526
|
+
else if (typeof packageGroup == 'object' &&
|
|
527
|
+
packageGroup &&
|
|
528
|
+
!Array.isArray(packageGroup) &&
|
|
529
|
+
Object.values(packageGroup).every((x) => typeof x == 'string')) {
|
|
530
|
+
packageGroupNormalized = packageGroup;
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
logger.warn(`packageGroup metadata of package ${npmPackageJson.name} is malformed. Ignoring.`);
|
|
526
534
|
return;
|
|
527
535
|
}
|
|
528
|
-
Object.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
.
|
|
532
|
-
|
|
533
|
-
|
|
536
|
+
for (const [name, value] of Object.entries(packageGroupNormalized)) {
|
|
537
|
+
// Don't override names from the command line.
|
|
538
|
+
// Remove packages that aren't installed.
|
|
539
|
+
if (!packages.has(name) && allDependencies.has(name)) {
|
|
540
|
+
packages.set(name, value);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
534
543
|
}
|
|
535
544
|
/**
|
|
536
545
|
* Add peer dependencies of packages on the command line to the list of packages to update.
|
|
@@ -11,7 +11,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.VersionCommandModule = void 0;
|
|
14
|
-
const child_process_1 = require("child_process");
|
|
15
14
|
const module_1 = __importDefault(require("module"));
|
|
16
15
|
const path_1 = require("path");
|
|
17
16
|
const command_module_1 = require("../../command-builder/command-module");
|
|
@@ -43,10 +42,11 @@ class VersionCommandModule extends command_module_1.CommandModule {
|
|
|
43
42
|
return localYargs;
|
|
44
43
|
}
|
|
45
44
|
async run() {
|
|
46
|
-
|
|
45
|
+
var _a;
|
|
46
|
+
const { packageManager, logger, root } = this.context;
|
|
47
47
|
const localRequire = module_1.default.createRequire((0, path_1.resolve)(__filename, '../../../'));
|
|
48
48
|
// Trailing slash is used to allow the path to be treated as a directory
|
|
49
|
-
const workspaceRequire = module_1.default.createRequire(
|
|
49
|
+
const workspaceRequire = module_1.default.createRequire(root + '/');
|
|
50
50
|
const cliPackage = localRequire('./package.json');
|
|
51
51
|
let workspacePackage;
|
|
52
52
|
try {
|
|
@@ -100,7 +100,7 @@ class VersionCommandModule extends command_module_1.CommandModule {
|
|
|
100
100
|
logger.info(`
|
|
101
101
|
Angular CLI: ${ngCliVersion}
|
|
102
102
|
Node: ${process.versions.node}${unsupportedNodeVersion ? ' (Unsupported)' : ''}
|
|
103
|
-
Package Manager: ${
|
|
103
|
+
Package Manager: ${packageManager.name} ${(_a = packageManager.version) !== null && _a !== void 0 ? _a : '<error>'}
|
|
104
104
|
OS: ${process.platform} ${process.arch}
|
|
105
105
|
|
|
106
106
|
Angular: ${angularCoreVersion}
|
|
@@ -157,24 +157,5 @@ class VersionCommandModule extends command_module_1.CommandModule {
|
|
|
157
157
|
}
|
|
158
158
|
return '<error>';
|
|
159
159
|
}
|
|
160
|
-
getPackageManagerVersion() {
|
|
161
|
-
try {
|
|
162
|
-
const manager = this.context.packageManager;
|
|
163
|
-
const version = (0, child_process_1.execSync)(`${manager} --version`, {
|
|
164
|
-
encoding: 'utf8',
|
|
165
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
166
|
-
env: {
|
|
167
|
-
...process.env,
|
|
168
|
-
// NPM updater notifier will prevents the child process from closing until it timeout after 3 minutes.
|
|
169
|
-
NO_UPDATE_NOTIFIER: '1',
|
|
170
|
-
NPM_CONFIG_UPDATE_NOTIFIER: 'false',
|
|
171
|
-
},
|
|
172
|
-
}).trim();
|
|
173
|
-
return `${manager} ${version}`;
|
|
174
|
-
}
|
|
175
|
-
catch {
|
|
176
|
-
return '<error>';
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
160
|
}
|
|
180
161
|
exports.VersionCommandModule = VersionCommandModule;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
|
|
9
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
10
|
+
// Workaround for https://github.com/bazelbuild/rules_nodejs/issues/1033
|
|
11
|
+
// Alternative approach instead of https://github.com/angular/angular/pull/33226
|
|
12
|
+
declare module '@yarnpkg/lockfile' {
|
|
13
|
+
export * from '@types/yarnpkg__lockfile';
|
|
14
|
+
}
|
package/src/typings.d.ts
CHANGED
|
@@ -5,20 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
declare module '@yarnpkg/lockfile' {
|
|
9
|
-
function parse(data: string): Record<string, any>;
|
|
10
|
-
}
|
|
11
|
-
declare module 'ini' {
|
|
12
|
-
function parse(data: string): Record<string, any>;
|
|
13
|
-
}
|
|
14
8
|
declare module 'npm-pick-manifest' {
|
|
15
9
|
function pickManifest(metadata: import('./utilities/package-metadata').PackageMetadata, selector: string): import('./utilities/package-metadata').PackageManifest;
|
|
16
10
|
export = pickManifest;
|
|
17
11
|
}
|
|
18
|
-
declare module 'pacote' {
|
|
19
|
-
function manifest(specifier: string, options: Record<string, unknown>): Promise<{
|
|
20
|
-
name: string;
|
|
21
|
-
version: string;
|
|
22
|
-
}>;
|
|
23
|
-
function packument(specifier: string, options: Record<string, unknown>): Promise<import('./utilities/package-metadata').NpmRepositoryPackageJson>;
|
|
24
|
-
}
|
|
@@ -10,17 +10,18 @@ import { PackageManager } from '../../lib/config/workspace-schema';
|
|
|
10
10
|
import { JSONFile } from './json-file';
|
|
11
11
|
export declare const workspaceSchemaPath: string;
|
|
12
12
|
export declare class AngularWorkspace {
|
|
13
|
-
private workspace;
|
|
13
|
+
private readonly workspace;
|
|
14
14
|
readonly filePath: string;
|
|
15
15
|
readonly basePath: string;
|
|
16
16
|
constructor(workspace: workspaces.WorkspaceDefinition, filePath: string);
|
|
17
17
|
get extensions(): Record<string, json.JsonValue | undefined>;
|
|
18
18
|
get projects(): workspaces.ProjectDefinitionCollection;
|
|
19
|
-
getCli(): Record<string, any
|
|
20
|
-
getProjectCli(projectName: string): Record<string, any
|
|
19
|
+
getCli(): Record<string, any> | undefined;
|
|
20
|
+
getProjectCli(projectName: string): Record<string, any> | undefined;
|
|
21
|
+
save(): Promise<void>;
|
|
21
22
|
static load(workspaceFilePath: string): Promise<AngularWorkspace>;
|
|
22
23
|
}
|
|
23
|
-
export declare function getWorkspace(level?: 'local' | 'global'): Promise<AngularWorkspace |
|
|
24
|
+
export declare function getWorkspace(level?: 'local' | 'global'): Promise<AngularWorkspace | undefined>;
|
|
24
25
|
export declare function createGlobalSettings(): string;
|
|
25
26
|
export declare function getWorkspaceRaw(level?: 'local' | 'global'): [JSONFile | null, string | null];
|
|
26
27
|
export declare function validateWorkspace(data: json.JsonObject): Promise<void>;
|
|
@@ -28,4 +29,3 @@ export declare function getProjectByCwd(workspace: AngularWorkspace): string | n
|
|
|
28
29
|
export declare function getConfiguredPackageManager(): Promise<PackageManager | null>;
|
|
29
30
|
export declare function getSchematicDefaults(collection: string, schematic: string, project?: string | null): Promise<{}>;
|
|
30
31
|
export declare function isWarningEnabled(warning: string): Promise<boolean>;
|
|
31
|
-
export declare function getProjectsByPath(workspace: workspaces.WorkspaceDefinition, cwd: string, root: string): string[];
|
package/src/utilities/config.js
CHANGED
|
@@ -30,7 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.
|
|
33
|
+
exports.isWarningEnabled = exports.getSchematicDefaults = exports.getConfiguredPackageManager = exports.getProjectByCwd = exports.validateWorkspace = exports.getWorkspaceRaw = exports.createGlobalSettings = exports.getWorkspace = exports.AngularWorkspace = exports.workspaceSchemaPath = void 0;
|
|
34
34
|
const core_1 = require("@angular-devkit/core");
|
|
35
35
|
const fs_1 = require("fs");
|
|
36
36
|
const os = __importStar(require("os"));
|
|
@@ -42,15 +42,16 @@ function isJsonObject(value) {
|
|
|
42
42
|
}
|
|
43
43
|
function createWorkspaceHost() {
|
|
44
44
|
return {
|
|
45
|
-
|
|
46
|
-
return
|
|
45
|
+
readFile(path) {
|
|
46
|
+
return fs_1.promises.readFile(path, 'utf-8');
|
|
47
47
|
},
|
|
48
48
|
async writeFile(path, data) {
|
|
49
|
-
|
|
49
|
+
await fs_1.promises.writeFile(path, data);
|
|
50
50
|
},
|
|
51
51
|
async isDirectory(path) {
|
|
52
52
|
try {
|
|
53
|
-
|
|
53
|
+
const stats = await fs_1.promises.stat(path);
|
|
54
|
+
return stats.isDirectory();
|
|
54
55
|
}
|
|
55
56
|
catch {
|
|
56
57
|
return false;
|
|
@@ -58,7 +59,8 @@ function createWorkspaceHost() {
|
|
|
58
59
|
},
|
|
59
60
|
async isFile(path) {
|
|
60
61
|
try {
|
|
61
|
-
|
|
62
|
+
const stats = await fs_1.promises.stat(path);
|
|
63
|
+
return stats.isFile();
|
|
62
64
|
}
|
|
63
65
|
catch {
|
|
64
66
|
return false;
|
|
@@ -132,12 +134,15 @@ class AngularWorkspace {
|
|
|
132
134
|
// Temporary helper functions to support refactoring
|
|
133
135
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
136
|
getCli() {
|
|
135
|
-
return this.workspace.extensions['cli']
|
|
137
|
+
return this.workspace.extensions['cli'];
|
|
136
138
|
}
|
|
137
139
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
140
|
getProjectCli(projectName) {
|
|
139
141
|
const project = this.workspace.projects.get(projectName);
|
|
140
|
-
return
|
|
142
|
+
return project === null || project === void 0 ? void 0 : project.extensions['cli'];
|
|
143
|
+
}
|
|
144
|
+
save() {
|
|
145
|
+
return core_1.workspaces.writeWorkspace(this.workspace, createWorkspaceHost(), this.filePath);
|
|
141
146
|
}
|
|
142
147
|
static async load(workspaceFilePath) {
|
|
143
148
|
const result = await core_1.workspaces.readWorkspace(workspaceFilePath, createWorkspaceHost(), core_1.workspaces.WorkspaceFormat.JSON);
|
|
@@ -147,14 +152,16 @@ class AngularWorkspace {
|
|
|
147
152
|
exports.AngularWorkspace = AngularWorkspace;
|
|
148
153
|
const cachedWorkspaces = new Map();
|
|
149
154
|
async function getWorkspace(level = 'local') {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return cached;
|
|
155
|
+
if (cachedWorkspaces.has(level)) {
|
|
156
|
+
return cachedWorkspaces.get(level);
|
|
153
157
|
}
|
|
154
|
-
|
|
158
|
+
let configPath = level === 'local' ? projectFilePath() : globalFilePath();
|
|
155
159
|
if (!configPath) {
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
if (level === 'local') {
|
|
161
|
+
cachedWorkspaces.set(level, undefined);
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
configPath = createGlobalSettings();
|
|
158
165
|
}
|
|
159
166
|
try {
|
|
160
167
|
const workspace = await AngularWorkspace.load(configPath);
|
|
@@ -237,6 +244,7 @@ function findProjectByPath(workspace, location) {
|
|
|
237
244
|
}
|
|
238
245
|
return projects[0][1];
|
|
239
246
|
}
|
|
247
|
+
let defaultProjectDeprecationWarningShown = false;
|
|
240
248
|
function getProjectByCwd(workspace) {
|
|
241
249
|
if (workspace.projects.size === 1) {
|
|
242
250
|
// If there is only one project, return that one.
|
|
@@ -249,6 +257,11 @@ function getProjectByCwd(workspace) {
|
|
|
249
257
|
const defaultProject = workspace.extensions['defaultProject'];
|
|
250
258
|
if (defaultProject && typeof defaultProject === 'string') {
|
|
251
259
|
// If there is a default project name, return it.
|
|
260
|
+
if (!defaultProjectDeprecationWarningShown) {
|
|
261
|
+
console.warn(`DEPRECATED: The 'defaultProject' workspace option has been deprecated. ` +
|
|
262
|
+
`The project to use will be determined from the current working directory.`);
|
|
263
|
+
defaultProjectDeprecationWarningShown = true;
|
|
264
|
+
}
|
|
252
265
|
return defaultProject;
|
|
253
266
|
}
|
|
254
267
|
return null;
|
|
@@ -341,33 +354,3 @@ async function isWarningEnabled(warning) {
|
|
|
341
354
|
return result !== null && result !== void 0 ? result : true;
|
|
342
355
|
}
|
|
343
356
|
exports.isWarningEnabled = isWarningEnabled;
|
|
344
|
-
function getProjectsByPath(workspace, cwd, root) {
|
|
345
|
-
if (workspace.projects.size === 1) {
|
|
346
|
-
return Array.from(workspace.projects.keys());
|
|
347
|
-
}
|
|
348
|
-
const isInside = (base, potential) => {
|
|
349
|
-
const absoluteBase = path.resolve(root, base);
|
|
350
|
-
const absolutePotential = path.resolve(root, potential);
|
|
351
|
-
const relativePotential = path.relative(absoluteBase, absolutePotential);
|
|
352
|
-
if (!relativePotential.startsWith('..') && !path.isAbsolute(relativePotential)) {
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
355
|
-
return false;
|
|
356
|
-
};
|
|
357
|
-
const projects = Array.from(workspace.projects.entries())
|
|
358
|
-
.map(([name, project]) => [path.resolve(root, project.root), name])
|
|
359
|
-
.filter((tuple) => isInside(tuple[0], cwd))
|
|
360
|
-
// Sort tuples by depth, with the deeper ones first. Since the first member is a path and
|
|
361
|
-
// we filtered all invalid paths, the longest will be the deepest (and in case of equality
|
|
362
|
-
// the sort is stable and the first declared project will win).
|
|
363
|
-
.sort((a, b) => b[0].length - a[0].length);
|
|
364
|
-
if (projects.length === 1) {
|
|
365
|
-
return [projects[0][1]];
|
|
366
|
-
}
|
|
367
|
-
else if (projects.length > 1) {
|
|
368
|
-
const firstPath = projects[0][0];
|
|
369
|
-
return projects.filter((v) => v[0] === firstPath).map((v) => v[1]);
|
|
370
|
-
}
|
|
371
|
-
return [];
|
|
372
|
-
}
|
|
373
|
-
exports.getProjectsByPath = getProjectsByPath;
|
|
@@ -0,0 +1,24 @@
|
|
|
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.ngDebug = exports.disableVersionCheck = exports.isCI = exports.analyticsShareDisabled = exports.analyticsDisabled = void 0;
|
|
11
|
+
function isPresent(variable) {
|
|
12
|
+
return typeof variable === 'string' && variable !== '';
|
|
13
|
+
}
|
|
14
|
+
function isDisabled(variable) {
|
|
15
|
+
return isPresent(variable) && (variable === '0' || variable.toLowerCase() === 'false');
|
|
16
|
+
}
|
|
17
|
+
function isEnabled(variable) {
|
|
18
|
+
return isPresent(variable) && (variable === '1' || variable.toLowerCase() === 'true');
|
|
19
|
+
}
|
|
20
|
+
exports.analyticsDisabled = isDisabled(process.env['NG_CLI_ANALYTICS']);
|
|
21
|
+
exports.analyticsShareDisabled = isDisabled(process.env['NG_CLI_ANALYTICS_SHARE']);
|
|
22
|
+
exports.isCI = isEnabled(process.env['CI']);
|
|
23
|
+
exports.disableVersionCheck = isEnabled(process.env['NG_DISABLE_VERSION_CHECK']);
|
|
24
|
+
exports.ngDebug = isEnabled(process.env['NG_DEBUG']);
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* A decorator that memoizes methods and getters.
|
|
10
|
+
*
|
|
11
|
+
* **Note**: Be cautious where and how to use this decorator as the size of the cache will grow unbounded.
|
|
12
|
+
*
|
|
13
|
+
* @see https://en.wikipedia.org/wiki/Memoization
|
|
14
|
+
*/
|
|
15
|
+
export declare function memoize<T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
|
@@ -0,0 +1,69 @@
|
|
|
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.memoize = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* A decorator that memoizes methods and getters.
|
|
13
|
+
*
|
|
14
|
+
* **Note**: Be cautious where and how to use this decorator as the size of the cache will grow unbounded.
|
|
15
|
+
*
|
|
16
|
+
* @see https://en.wikipedia.org/wiki/Memoization
|
|
17
|
+
*/
|
|
18
|
+
function memoize(target, propertyKey, descriptor) {
|
|
19
|
+
const descriptorPropertyName = descriptor.get ? 'get' : 'value';
|
|
20
|
+
const originalMethod = descriptor[descriptorPropertyName];
|
|
21
|
+
if (typeof originalMethod !== 'function') {
|
|
22
|
+
throw new Error('Memoize decorator can only be used on methods or get accessors.');
|
|
23
|
+
}
|
|
24
|
+
const cache = new Map();
|
|
25
|
+
return {
|
|
26
|
+
...descriptor,
|
|
27
|
+
[descriptorPropertyName]: function (...args) {
|
|
28
|
+
for (const arg of args) {
|
|
29
|
+
if (!isJSONSerializable(arg)) {
|
|
30
|
+
throw new Error(`Argument ${isNonPrimitive(arg) ? arg.toString() : arg} is JSON serializable.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const key = JSON.stringify(args);
|
|
34
|
+
if (cache.has(key)) {
|
|
35
|
+
return cache.get(key);
|
|
36
|
+
}
|
|
37
|
+
const result = originalMethod.apply(this, args);
|
|
38
|
+
cache.set(key, result);
|
|
39
|
+
return result;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.memoize = memoize;
|
|
44
|
+
/** Method to check if value is a non primitive. */
|
|
45
|
+
function isNonPrimitive(value) {
|
|
46
|
+
return ((value !== null && typeof value === 'object') ||
|
|
47
|
+
typeof value === 'function' ||
|
|
48
|
+
typeof value === 'symbol');
|
|
49
|
+
}
|
|
50
|
+
/** Method to check if the values are JSON serializable */
|
|
51
|
+
function isJSONSerializable(value) {
|
|
52
|
+
if (!isNonPrimitive(value)) {
|
|
53
|
+
// Can be seralized since it's a primitive.
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
let nestedValues;
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
// It's an array, check each item.
|
|
59
|
+
nestedValues = value;
|
|
60
|
+
}
|
|
61
|
+
else if (Object.prototype.toString.call(value) === '[object Object]') {
|
|
62
|
+
// It's a plain object, check each value.
|
|
63
|
+
nestedValues = Object.values(value);
|
|
64
|
+
}
|
|
65
|
+
if (!nestedValues || nestedValues.some((v) => !isJSONSerializable(v))) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|