@angular/cli 12.0.0-rc.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -30
- package/bin/ng +3 -3
- package/bin/postinstall/analytics-prompt.js +1 -1
- package/commands/add-impl.d.ts +7 -0
- package/commands/add-impl.js +18 -20
- package/commands/add.json +1 -2
- package/commands/add.md +1 -0
- package/commands/analytics-impl.d.ts +8 -1
- package/commands/analytics-impl.js +7 -7
- package/commands/analytics-long.md +8 -7
- package/commands/analytics.json +3 -15
- package/commands/build-impl.d.ts +1 -1
- package/commands/build-impl.js +3 -3
- package/commands/build.json +1 -1
- package/commands/config-impl.d.ts +2 -2
- package/commands/config-impl.js +16 -11
- package/commands/config-long.md +1 -1
- package/commands/config.json +1 -2
- package/commands/definitions.json +3 -5
- package/commands/deploy-impl.d.ts +1 -1
- package/commands/deploy-impl.js +3 -3
- package/commands/deploy-long.md +1 -1
- package/commands/deploy.json +1 -3
- package/commands/doc-impl.d.ts +1 -1
- package/commands/doc-impl.js +2 -2
- package/commands/doc.json +3 -4
- package/commands/e2e-impl.d.ts +1 -1
- package/commands/e2e-impl.js +1 -1
- package/commands/e2e-long.md +1 -1
- package/commands/e2e.json +1 -1
- package/commands/easter-egg-impl.d.ts +1 -1
- package/commands/easter-egg-impl.js +3 -3
- package/commands/easter-egg.json +1 -3
- package/commands/extract-i18n-impl.d.ts +1 -1
- package/commands/extract-i18n-impl.js +5 -4
- package/commands/generate-impl.d.ts +1 -1
- package/commands/generate-impl.js +9 -2
- package/commands/generate.json +2 -3
- package/commands/help-impl.d.ts +1 -1
- package/commands/help-impl.js +3 -3
- package/commands/help-long.md +5 -5
- package/commands/help.json +1 -3
- package/commands/lint-impl.d.ts +1 -1
- package/commands/lint-impl.js +3 -3
- package/commands/lint-long.md +1 -1
- package/commands/lint.json +1 -3
- package/commands/new-impl.d.ts +1 -1
- package/commands/new-impl.js +8 -1
- package/commands/new.json +3 -3
- package/commands/new.md +5 -5
- package/commands/run-impl.d.ts +1 -1
- package/commands/run-impl.js +1 -1
- package/commands/run-long.md +1 -1
- package/commands/run.json +2 -3
- package/commands/serve-impl.d.ts +2 -2
- package/commands/serve-impl.js +4 -4
- package/commands/serve.json +1 -1
- package/commands/test-impl.d.ts +1 -1
- package/commands/test-impl.js +1 -1
- package/commands/test-long.md +1 -1
- package/commands/test.json +1 -1
- package/commands/update-impl.d.ts +9 -2
- package/commands/update-impl.js +29 -23
- package/commands/update.d.ts +2 -1
- package/commands/update.json +1 -1
- package/commands/version-impl.d.ts +8 -0
- package/commands/version-impl.js +19 -6
- package/commands/version.json +2 -4
- package/lib/cli/index.d.ts +7 -0
- package/lib/cli/index.js +14 -16
- package/lib/config/schema.json +20 -12
- package/lib/config/workspace-schema.d.ts +4 -0
- package/lib/init.d.ts +1 -1
- package/lib/init.js +11 -10
- package/models/analytics-collector.d.ts +1 -2
- package/models/analytics-collector.js +7 -8
- package/models/analytics.d.ts +7 -0
- package/models/analytics.js +6 -8
- package/models/architect-command.d.ts +2 -2
- package/models/architect-command.js +10 -11
- package/models/command-runner.d.ts +1 -1
- package/models/command-runner.js +8 -7
- package/models/command.d.ts +3 -4
- package/models/command.js +17 -21
- package/models/error.d.ts +1 -1
- package/models/error.js +1 -1
- package/models/interface.d.ts +2 -2
- package/models/interface.js +7 -0
- package/models/parser.d.ts +1 -2
- package/models/parser.js +12 -15
- package/models/schematic-command.d.ts +1 -1
- package/models/schematic-command.js +48 -49
- package/models/schematic-engine-host.d.ts +1 -1
- package/models/schematic-engine-host.js +4 -4
- package/models/version.d.ts +1 -1
- package/models/version.js +1 -1
- package/package.json +14 -14
- package/src/commands/update/schematic/index.d.ts +7 -0
- package/src/commands/update/schematic/index.js +59 -56
- package/src/commands/update/schematic/npm-package-json.d.ts +1 -1
- package/src/commands/update/schematic/npm-package-json.js +7 -0
- package/src/commands/update/schematic/npm.d.ts +1 -1
- package/src/commands/update/schematic/npm.js +9 -4
- package/src/commands/update/schematic/package-json.d.ts +1 -1
- package/src/commands/update/schematic/package-json.js +1 -7
- package/src/commands/update/schematic/schema.json +2 -8
- package/utilities/color.d.ts +1 -1
- package/utilities/color.js +3 -3
- package/utilities/config.d.ts +1 -1
- package/utilities/config.js +24 -7
- package/utilities/find-up.d.ts +1 -1
- package/utilities/find-up.js +1 -1
- package/utilities/install-package.d.ts +7 -5
- package/utilities/install-package.js +37 -23
- package/utilities/json-file.d.ts +1 -1
- package/utilities/json-file.js +4 -4
- package/utilities/json-schema.d.ts +1 -1
- package/utilities/json-schema.js +30 -27
- package/utilities/log-file.d.ts +1 -1
- package/utilities/log-file.js +1 -1
- package/utilities/package-manager.d.ts +7 -0
- package/utilities/package-manager.js +5 -5
- package/utilities/package-metadata.d.ts +1 -1
- package/utilities/package-metadata.js +8 -1
- package/utilities/package-tree.d.ts +1 -1
- package/utilities/package-tree.js +1 -1
- package/utilities/project.d.ts +7 -0
- package/utilities/project.js +3 -3
- package/utilities/prompt.d.ts +7 -0
- package/utilities/prompt.js +3 -3
- package/utilities/spinner.d.ts +1 -1
- package/utilities/spinner.js +1 -1
- package/utilities/tty.d.ts +1 -1
- package/utilities/tty.js +1 -1
|
@@ -1,2 +1,9 @@
|
|
|
1
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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,11 +1,18 @@
|
|
|
1
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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.getNpmPackageJson = void 0;
|
|
4
11
|
const fs_1 = require("fs");
|
|
5
12
|
const os_1 = require("os");
|
|
6
13
|
const path = require("path");
|
|
7
|
-
const ini = require('ini');
|
|
8
14
|
const lockfile = require('@yarnpkg/lockfile');
|
|
15
|
+
const ini = require('ini');
|
|
9
16
|
const pacote = require('pacote');
|
|
10
17
|
const npmPackageJsonCache = new Map();
|
|
11
18
|
let npmrc;
|
|
@@ -27,9 +34,7 @@ function readOptions(logger, yarn = false, showPotentials = false) {
|
|
|
27
34
|
path.join(globalPrefix, 'etc', baseFilename),
|
|
28
35
|
path.join(os_1.homedir(), dotFilename),
|
|
29
36
|
];
|
|
30
|
-
const projectConfigLocations = [
|
|
31
|
-
path.join(cwd, dotFilename),
|
|
32
|
-
];
|
|
37
|
+
const projectConfigLocations = [path.join(cwd, dotFilename)];
|
|
33
38
|
const root = path.parse(cwd).root;
|
|
34
39
|
for (let curDir = path.dirname(cwd); curDir && curDir !== root; curDir = path.dirname(curDir)) {
|
|
35
40
|
projectConfigLocations.unshift(path.join(curDir, dotFilename));
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
5
|
*
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
-
/**
|
|
10
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
11
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
12
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
13
|
-
*/
|
|
14
|
-
// tslint:disable
|
|
15
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -57,14 +57,8 @@
|
|
|
57
57
|
"description": "The preferred package manager configuration files to use for registry settings.",
|
|
58
58
|
"type": "string",
|
|
59
59
|
"default": "npm",
|
|
60
|
-
"enum": [
|
|
61
|
-
"npm",
|
|
62
|
-
"yarn",
|
|
63
|
-
"cnpm",
|
|
64
|
-
"pnpm"
|
|
65
|
-
]
|
|
60
|
+
"enum": ["npm", "yarn", "cnpm", "pnpm"]
|
|
66
61
|
}
|
|
67
62
|
},
|
|
68
|
-
"required": [
|
|
69
|
-
]
|
|
63
|
+
"required": []
|
|
70
64
|
}
|
package/utilities/color.d.ts
CHANGED
package/utilities/color.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.colors = exports.removeColor = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.colors = exports.removeColor = void 0;
|
|
11
11
|
const ansiColors = require("ansi-colors");
|
|
12
12
|
const tty_1 = require("tty");
|
|
13
13
|
const supportsColor = process.stdout instanceof tty_1.WriteStream && process.stdout.getColorDepth() > 1;
|
package/utilities/config.d.ts
CHANGED
package/utilities/config.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isWarningEnabled = exports.getSchematicDefaults = exports.migrateLegacyGlobalConfig = exports.getConfiguredPackageManager = exports.getProjectByCwd = exports.validateWorkspace = exports.getWorkspaceRaw = exports.createGlobalSettings = exports.getWorkspace = exports.AngularWorkspace = exports.workspaceSchemaPath = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.isWarningEnabled = exports.getSchematicDefaults = exports.migrateLegacyGlobalConfig = exports.getConfiguredPackageManager = exports.getProjectByCwd = exports.validateWorkspace = exports.getWorkspaceRaw = exports.createGlobalSettings = exports.getWorkspace = exports.AngularWorkspace = exports.workspaceSchemaPath = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const fs_1 = require("fs");
|
|
13
13
|
const os = require("os");
|
|
@@ -51,8 +51,16 @@ const configNames = ['angular.json', '.angular.json'];
|
|
|
51
51
|
const globalFileName = '.angular-config.json';
|
|
52
52
|
function xdgConfigHome(home, configFile) {
|
|
53
53
|
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
54
|
+
const xdgConfigHome = process.env['XDG_CONFIG_HOME'] || path.join(home, '.config');
|
|
55
|
+
const xdgAngularHome = path.join(xdgConfigHome, 'angular');
|
|
56
|
+
return configFile ? path.join(xdgAngularHome, configFile) : xdgAngularHome;
|
|
57
|
+
}
|
|
58
|
+
function xdgConfigHomeOld(home) {
|
|
59
|
+
// Check the configuration files in the old location that should be:
|
|
60
|
+
// - $XDG_CONFIG_HOME/.angular-config.json (if XDG_CONFIG_HOME is set)
|
|
61
|
+
// - $HOME/.config/angular/.angular-config.json (otherwise)
|
|
54
62
|
const p = process.env['XDG_CONFIG_HOME'] || path.join(home, '.config', 'angular');
|
|
55
|
-
return
|
|
63
|
+
return path.join(p, '.angular-config.json');
|
|
56
64
|
}
|
|
57
65
|
function projectFilePath(projectPath) {
|
|
58
66
|
// Find the configuration, either where specified, in the Angular CLI project
|
|
@@ -70,10 +78,19 @@ function globalFilePath() {
|
|
|
70
78
|
// note that createGlobalSettings() will continue creating
|
|
71
79
|
// global file in home directory, with this user will have
|
|
72
80
|
// choice to move change its location to meet XDG convention
|
|
73
|
-
const xdgConfig = xdgConfigHome(home,
|
|
81
|
+
const xdgConfig = xdgConfigHome(home, 'config.json');
|
|
74
82
|
if (fs_1.existsSync(xdgConfig)) {
|
|
75
83
|
return xdgConfig;
|
|
76
84
|
}
|
|
85
|
+
// NOTE: This check is for the old configuration location, for more
|
|
86
|
+
// information see https://github.com/angular/angular-cli/pull/20556
|
|
87
|
+
const xdgConfigOld = xdgConfigHomeOld(home);
|
|
88
|
+
if (fs_1.existsSync(xdgConfigOld)) {
|
|
89
|
+
/* eslint-disable no-console */
|
|
90
|
+
console.warn(`Old configuration location detected: ${xdgConfigOld}\n` +
|
|
91
|
+
`Please move the file to the new location ~/.config/angular/config.json`);
|
|
92
|
+
return xdgConfigOld;
|
|
93
|
+
}
|
|
77
94
|
const p = path.join(home, globalFileName);
|
|
78
95
|
if (fs_1.existsSync(p)) {
|
|
79
96
|
return p;
|
|
@@ -93,11 +110,11 @@ class AngularWorkspace {
|
|
|
93
110
|
return this.workspace.projects;
|
|
94
111
|
}
|
|
95
112
|
// Temporary helper functions to support refactoring
|
|
96
|
-
//
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
114
|
getCli() {
|
|
98
115
|
return this.workspace.extensions['cli'] || {};
|
|
99
116
|
}
|
|
100
|
-
//
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
101
118
|
getProjectCli(projectName) {
|
|
102
119
|
const project = this.workspace.projects.get(projectName);
|
|
103
120
|
return (project === null || project === void 0 ? void 0 : project.extensions['cli']) || {};
|
package/utilities/find-up.d.ts
CHANGED
package/utilities/find-up.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
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
|
-
import { logging } from '@angular-devkit/core';
|
|
9
8
|
import { PackageManager } from '../lib/config/workspace-schema';
|
|
10
9
|
import { NgAddSaveDepedency } from '../utilities/package-metadata';
|
|
11
|
-
export declare function installPackage(packageName: string,
|
|
12
|
-
export declare function installTempPackage(packageName: string,
|
|
13
|
-
|
|
10
|
+
export declare function installPackage(packageName: string, packageManager?: PackageManager, save?: Exclude<NgAddSaveDepedency, false>, extraArgs?: string[], cwd?: string): Promise<1 | 0>;
|
|
11
|
+
export declare function installTempPackage(packageName: string, packageManager?: PackageManager, extraArgs?: string[]): Promise<{
|
|
12
|
+
status: 1 | 0;
|
|
13
|
+
tempPath: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function runTempPackageBin(packageName: string, packageManager?: PackageManager, args?: string[]): Promise<number>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
5
|
*
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
@@ -14,35 +14,44 @@ const os_1 = require("os");
|
|
|
14
14
|
const path_1 = require("path");
|
|
15
15
|
const rimraf = require("rimraf");
|
|
16
16
|
const workspace_schema_1 = require("../lib/config/workspace-schema");
|
|
17
|
-
const
|
|
18
|
-
function installPackage(packageName,
|
|
17
|
+
const spinner_1 = require("./spinner");
|
|
18
|
+
async function installPackage(packageName, packageManager = workspace_schema_1.PackageManager.Npm, save = true, extraArgs = [], cwd = process.cwd()) {
|
|
19
19
|
const packageManagerArgs = getPackageManagerArguments(packageManager);
|
|
20
20
|
const installArgs = [
|
|
21
21
|
packageManagerArgs.install,
|
|
22
22
|
packageName,
|
|
23
23
|
packageManagerArgs.silent,
|
|
24
24
|
];
|
|
25
|
-
|
|
25
|
+
const spinner = new spinner_1.Spinner();
|
|
26
|
+
spinner.start('Installing package...');
|
|
26
27
|
if (save === 'devDependencies') {
|
|
27
28
|
installArgs.push(packageManagerArgs.saveDev);
|
|
28
29
|
}
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const bufferedOutput = [];
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const childProcess = child_process_1.spawn(packageManager, [...installArgs, ...extraArgs], {
|
|
34
|
+
stdio: 'pipe',
|
|
35
|
+
shell: true,
|
|
36
|
+
cwd,
|
|
37
|
+
}).on('close', (code) => {
|
|
38
|
+
if (code === 0) {
|
|
39
|
+
spinner.succeed('Package successfully installed.');
|
|
40
|
+
resolve(0);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
spinner.stop();
|
|
44
|
+
bufferedOutput.forEach(({ stream, data }) => stream.write(data));
|
|
45
|
+
spinner.fail('Package install failed, see above.');
|
|
46
|
+
reject(1);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
(_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => bufferedOutput.push({ stream: process.stdout, data: data }));
|
|
50
|
+
(_b = childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => bufferedOutput.push({ stream: process.stderr, data: data }));
|
|
34
51
|
});
|
|
35
|
-
if (status !== 0) {
|
|
36
|
-
let errorMessage = ((error && error.message) || stderr || stdout || '').trim();
|
|
37
|
-
if (errorMessage) {
|
|
38
|
-
errorMessage += '\n';
|
|
39
|
-
}
|
|
40
|
-
throw new Error(errorMessage + `Package install failed${errorMessage ? ', see above' : ''}.`);
|
|
41
|
-
}
|
|
42
|
-
logger === null || logger === void 0 ? void 0 : logger.info(color_1.colors.green(`Installed packages for tooling via ${packageManager}.`));
|
|
43
52
|
}
|
|
44
53
|
exports.installPackage = installPackage;
|
|
45
|
-
function installTempPackage(packageName,
|
|
54
|
+
async function installTempPackage(packageName, packageManager = workspace_schema_1.PackageManager.Npm, extraArgs) {
|
|
46
55
|
const tempPath = fs_1.mkdtempSync(path_1.join(fs_1.realpathSync(os_1.tmpdir()), 'angular-cli-packages-'));
|
|
47
56
|
// clean up temp directory on process exit
|
|
48
57
|
process.on('exit', () => {
|
|
@@ -75,16 +84,21 @@ function installTempPackage(packageName, logger, packageManager = workspace_sche
|
|
|
75
84
|
`${packageManagerArgs.prefix}="${prefixPath}"`,
|
|
76
85
|
packageManagerArgs.noLockfile,
|
|
77
86
|
];
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
return {
|
|
88
|
+
status: await installPackage(packageName, packageManager, true, installArgs, tempPath),
|
|
89
|
+
tempPath,
|
|
90
|
+
};
|
|
80
91
|
}
|
|
81
92
|
exports.installTempPackage = installTempPackage;
|
|
82
|
-
function runTempPackageBin(packageName,
|
|
83
|
-
const
|
|
93
|
+
async function runTempPackageBin(packageName, packageManager = workspace_schema_1.PackageManager.Npm, args = []) {
|
|
94
|
+
const { status: code, tempPath } = await installTempPackage(packageName, packageManager);
|
|
95
|
+
if (code !== 0) {
|
|
96
|
+
return code;
|
|
97
|
+
}
|
|
84
98
|
// Remove version/tag etc... from package name
|
|
85
99
|
// Ex: @angular/cli@latest -> @angular/cli
|
|
86
100
|
const packageNameNoVersion = packageName.substring(0, packageName.lastIndexOf('@'));
|
|
87
|
-
const pkgLocation = path_1.join(
|
|
101
|
+
const pkgLocation = path_1.join(tempPath, packageNameNoVersion);
|
|
88
102
|
const packageJsonPath = path_1.join(pkgLocation, 'package.json');
|
|
89
103
|
// Get a binary location for this package
|
|
90
104
|
let binPath;
|
package/utilities/json-file.d.ts
CHANGED
package/utilities/json-file.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
5
|
*
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
@@ -52,7 +52,7 @@ class JSONFile {
|
|
|
52
52
|
let getInsertionIndex;
|
|
53
53
|
if (insertInOrder === undefined) {
|
|
54
54
|
const property = jsonPath.slice(-1)[0];
|
|
55
|
-
getInsertionIndex = properties => [...properties, property].sort().findIndex(p => p === property);
|
|
55
|
+
getInsertionIndex = (properties) => [...properties, property].sort().findIndex((p) => p === property);
|
|
56
56
|
}
|
|
57
57
|
else if (insertInOrder !== false) {
|
|
58
58
|
getInsertionIndex = insertInOrder;
|
|
@@ -76,7 +76,7 @@ class JSONFile {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
exports.JSONFile = JSONFile;
|
|
79
|
-
//
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
80
|
function readAndParseJson(path) {
|
|
81
81
|
const errors = [];
|
|
82
82
|
const content = jsonc_parser_1.parse(fs_1.readFileSync(path, 'utf-8'), errors, { allowTrailingComma: true });
|
|
@@ -90,7 +90,7 @@ function formatError(path, errors) {
|
|
|
90
90
|
const { error, offset } = errors[0];
|
|
91
91
|
throw new Error(`Failed to parse "${path}" as JSON AST Object. ${jsonc_parser_1.printParseErrorCode(error)} at location: ${offset}.`);
|
|
92
92
|
}
|
|
93
|
-
//
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
94
|
function parseJson(content) {
|
|
95
95
|
return jsonc_parser_1.parse(content, undefined, { allowTrailingComma: true });
|
|
96
96
|
}
|
package/utilities/json-schema.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseJsonSchemaToOptions = exports.parseJsonSchemaToCommandDescription = exports.parseJsonSchemaToSubCommandDescription = exports.CommandJsonPathException = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.parseJsonSchemaToOptions = exports.parseJsonSchemaToCommandDescription = exports.parseJsonSchemaToSubCommandDescription = exports.CommandJsonPathException = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
13
13
|
const fs_1 = require("fs");
|
|
@@ -34,14 +34,14 @@ async function parseJsonSchemaToSubCommandDescription(name, jsonPath, registry,
|
|
|
34
34
|
const options = await parseJsonSchemaToOptions(registry, schema);
|
|
35
35
|
const aliases = [];
|
|
36
36
|
if (core_1.json.isJsonArray(schema.$aliases)) {
|
|
37
|
-
schema.$aliases.forEach(value => {
|
|
37
|
+
schema.$aliases.forEach((value) => {
|
|
38
38
|
if (typeof value == 'string') {
|
|
39
39
|
aliases.push(value);
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
if (core_1.json.isJsonArray(schema.aliases)) {
|
|
44
|
-
schema.aliases.forEach(value => {
|
|
44
|
+
schema.aliases.forEach((value) => {
|
|
45
45
|
if (typeof value == 'string') {
|
|
46
46
|
aliases.push(value);
|
|
47
47
|
}
|
|
@@ -131,7 +131,8 @@ async function parseJsonSchemaToOptions(registry, schema) {
|
|
|
131
131
|
throw new Error('Cannot find type of schema.');
|
|
132
132
|
}
|
|
133
133
|
// We only support number, string or boolean (or array of those), so remove everything else.
|
|
134
|
-
const types = [...typeSet]
|
|
134
|
+
const types = [...typeSet]
|
|
135
|
+
.filter((x) => {
|
|
135
136
|
switch (x) {
|
|
136
137
|
case 'boolean':
|
|
137
138
|
case 'number':
|
|
@@ -139,22 +140,23 @@ async function parseJsonSchemaToOptions(registry, schema) {
|
|
|
139
140
|
return true;
|
|
140
141
|
case 'array':
|
|
141
142
|
// Only include arrays if they're boolean, string or number.
|
|
142
|
-
if (core_1.json.isJsonObject(current.items)
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
if (core_1.json.isJsonObject(current.items) &&
|
|
144
|
+
typeof current.items.type == 'string' &&
|
|
145
|
+
['boolean', 'number', 'string'].includes(current.items.type)) {
|
|
145
146
|
return true;
|
|
146
147
|
}
|
|
147
148
|
return false;
|
|
148
149
|
default:
|
|
149
150
|
return false;
|
|
150
151
|
}
|
|
151
|
-
})
|
|
152
|
+
})
|
|
153
|
+
.map((x) => _getEnumFromValue(x, interface_1.OptionType, interface_1.OptionType.String));
|
|
152
154
|
if (types.length == 0) {
|
|
153
155
|
// This means it's not usable on the command line. e.g. an Object.
|
|
154
156
|
return;
|
|
155
157
|
}
|
|
156
158
|
// Only keep enum values we support (booleans, numbers and strings).
|
|
157
|
-
const enumValues = (core_1.json.isJsonArray(current.enum) && current.enum || []).filter(x => {
|
|
159
|
+
const enumValues = ((core_1.json.isJsonArray(current.enum) && current.enum) || []).filter((x) => {
|
|
158
160
|
switch (typeof x) {
|
|
159
161
|
case 'boolean':
|
|
160
162
|
case 'number':
|
|
@@ -186,14 +188,16 @@ async function parseJsonSchemaToOptions(registry, schema) {
|
|
|
186
188
|
}
|
|
187
189
|
const type = types[0];
|
|
188
190
|
const $default = current.$default;
|
|
189
|
-
const $defaultIndex =
|
|
190
|
-
|
|
191
|
-
const positional = typeof $defaultIndex == 'number'
|
|
192
|
-
? $defaultIndex : undefined;
|
|
191
|
+
const $defaultIndex = core_1.json.isJsonObject($default) && $default['$source'] == 'argv' ? $default['index'] : undefined;
|
|
192
|
+
const positional = typeof $defaultIndex == 'number' ? $defaultIndex : undefined;
|
|
193
193
|
const required = core_1.json.isJsonArray(current.required)
|
|
194
|
-
? current.required.indexOf(name) != -1
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
? current.required.indexOf(name) != -1
|
|
195
|
+
: false;
|
|
196
|
+
const aliases = core_1.json.isJsonArray(current.aliases)
|
|
197
|
+
? [...current.aliases].map((x) => '' + x)
|
|
198
|
+
: current.alias
|
|
199
|
+
? ['' + current.alias]
|
|
200
|
+
: [];
|
|
197
201
|
const format = typeof current.format == 'string' ? current.format : undefined;
|
|
198
202
|
const visible = current.visible === undefined || current.visible === true;
|
|
199
203
|
const hidden = !!current.hidden || !visible;
|
|
@@ -201,21 +205,20 @@ async function parseJsonSchemaToOptions(registry, schema) {
|
|
|
201
205
|
const userAnalytics = typeof xUserAnalytics == 'number' ? xUserAnalytics : undefined;
|
|
202
206
|
// Deprecated is set only if it's true or a string.
|
|
203
207
|
const xDeprecated = current['x-deprecated'];
|
|
204
|
-
const deprecated =
|
|
205
|
-
? xDeprecated : undefined;
|
|
208
|
+
const deprecated = xDeprecated === true || typeof xDeprecated === 'string' ? xDeprecated : undefined;
|
|
206
209
|
const option = {
|
|
207
210
|
name,
|
|
208
211
|
description: '' + (current.description === undefined ? '' : current.description),
|
|
209
|
-
...types.length == 1 ? { type } : { type, types },
|
|
210
|
-
...defaultValue !== undefined ? { default: defaultValue } : {},
|
|
211
|
-
...enumValues && enumValues.length > 0 ? { enum: enumValues } : {},
|
|
212
|
+
...(types.length == 1 ? { type } : { type, types }),
|
|
213
|
+
...(defaultValue !== undefined ? { default: defaultValue } : {}),
|
|
214
|
+
...(enumValues && enumValues.length > 0 ? { enum: enumValues } : {}),
|
|
212
215
|
required,
|
|
213
216
|
aliases,
|
|
214
|
-
...format !== undefined ? { format } : {},
|
|
217
|
+
...(format !== undefined ? { format } : {}),
|
|
215
218
|
hidden,
|
|
216
|
-
...userAnalytics ? { userAnalytics } : {},
|
|
217
|
-
...deprecated !== undefined ? { deprecated } : {},
|
|
218
|
-
...positional !== undefined ? { positional } : {},
|
|
219
|
+
...(userAnalytics ? { userAnalytics } : {}),
|
|
220
|
+
...(deprecated !== undefined ? { deprecated } : {}),
|
|
221
|
+
...(positional !== undefined ? { positional } : {}),
|
|
219
222
|
};
|
|
220
223
|
options.push(option);
|
|
221
224
|
}
|
package/utilities/log-file.d.ts
CHANGED
package/utilities/log-file.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
8
|
import { PackageManager } from '../lib/config/workspace-schema';
|
|
2
9
|
export declare function supportsYarn(): boolean;
|
|
3
10
|
export declare function supportsNpm(): boolean;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureCompatibleNpm = exports.getPackageManager = exports.supportsNpm = exports.supportsYarn = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ensureCompatibleNpm = exports.getPackageManager = exports.supportsNpm = exports.supportsYarn = void 0;
|
|
11
11
|
const child_process_1 = require("child_process");
|
|
12
12
|
const fs_1 = require("fs");
|
|
13
13
|
const path_1 = require("path");
|
|
@@ -32,7 +32,7 @@ function supportsNpm() {
|
|
|
32
32
|
}
|
|
33
33
|
exports.supportsNpm = supportsNpm;
|
|
34
34
|
async function getPackageManager(root) {
|
|
35
|
-
let packageManager = await config_1.getConfiguredPackageManager();
|
|
35
|
+
let packageManager = (await config_1.getConfiguredPackageManager());
|
|
36
36
|
if (packageManager) {
|
|
37
37
|
return packageManager;
|
|
38
38
|
}
|
|
@@ -71,7 +71,7 @@ async function ensureCompatibleNpm(root) {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
if (semver_1.satisfies(version, '>=7 <7.5.6')) {
|
|
74
|
-
//
|
|
74
|
+
// eslint-disable-next-line no-console
|
|
75
75
|
console.warn(`npm version ${version} detected.` +
|
|
76
76
|
' When using npm 7 with the Angular CLI, npm version 7.5.6 or higher is recommended.');
|
|
77
77
|
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.fetchPackageManifest = exports.fetchPackageMetadata = void 0;
|
|
4
11
|
const fs_1 = require("fs");
|
|
5
12
|
const os_1 = require("os");
|
|
6
13
|
const path = require("path");
|
|
7
|
-
const ini = require('ini');
|
|
8
14
|
const lockfile = require('@yarnpkg/lockfile');
|
|
15
|
+
const ini = require('ini');
|
|
9
16
|
const pacote = require('pacote');
|
|
10
17
|
let npmrc;
|
|
11
18
|
function ensureNpmrc(logger, usingYarn, verbose) {
|
package/utilities/project.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
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
|
+
*/
|
|
1
8
|
export declare function findWorkspaceFile(currentDirectory?: string): string | null;
|