@angular/cli 14.0.0-next.6 → 14.0.0-next.7
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 +15 -18
- package/src/analytics/analytics-collector.js +2 -0
- package/src/analytics/analytics.js +17 -16
- package/src/command-builder/architect-command-module.js +3 -3
- package/src/command-builder/command-module.d.ts +3 -2
- package/src/command-builder/command-runner.d.ts +1 -2
- package/src/command-builder/command-runner.js +50 -33
- package/src/command-builder/schematics-command-module.d.ts +4 -2
- package/src/command-builder/schematics-command-module.js +81 -41
- 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/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 +50 -0
- package/src/commands/config/cli.d.ts +1 -1
- package/src/commands/config/cli.js +2 -2
- package/src/commands/doc/cli.d.ts +1 -1
- package/src/commands/e2e/cli.d.ts +1 -1
- package/src/commands/e2e/cli.js +3 -3
- package/src/commands/generate/cli.d.ts +11 -1
- package/src/commands/generate/cli.js +54 -23
- package/src/commands/new/cli.d.ts +2 -0
- package/src/commands/new/cli.js +15 -4
- package/src/commands/update/cli.d.ts +1 -0
- package/src/commands/update/cli.js +50 -21
- 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 +1 -2
- package/src/utilities/config.js +18 -41
- 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/package-manager.d.ts +33 -5
- package/src/utilities/package-manager.js +241 -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.js +2 -2
- 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
|
@@ -6,24 +6,15 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { logging } from '@angular-devkit/core';
|
|
9
|
-
import {
|
|
10
|
-
export interface
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
description: string;
|
|
14
|
-
'dist-tags': {
|
|
15
|
-
[name: string]: string;
|
|
16
|
-
};
|
|
17
|
-
versions: {
|
|
18
|
-
[version: string]: JsonSchemaForNpmPackageJsonFiles;
|
|
19
|
-
};
|
|
20
|
-
time: {
|
|
21
|
-
modified: string;
|
|
22
|
-
created: string;
|
|
23
|
-
[version: string]: string;
|
|
24
|
-
};
|
|
9
|
+
import type { Manifest, Packument } from 'pacote';
|
|
10
|
+
export interface PackageMetadata extends Packument, NgPackageManifestProperties {
|
|
11
|
+
tags: Record<string, PackageManifest>;
|
|
12
|
+
versions: Record<string, PackageManifest>;
|
|
25
13
|
}
|
|
26
|
-
export
|
|
14
|
+
export interface NpmRepositoryPackageJson extends PackageMetadata {
|
|
15
|
+
requestedName?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare type NgAddSaveDependency = 'dependencies' | 'devDependencies' | boolean;
|
|
27
18
|
export interface PackageIdentifier {
|
|
28
19
|
type: 'git' | 'tag' | 'version' | 'range' | 'file' | 'directory' | 'remote';
|
|
29
20
|
name: string;
|
|
@@ -33,31 +24,18 @@ export interface PackageIdentifier {
|
|
|
33
24
|
fetchSpec: string;
|
|
34
25
|
rawSpec: string;
|
|
35
26
|
}
|
|
36
|
-
export interface
|
|
37
|
-
name: string;
|
|
38
|
-
version: string;
|
|
39
|
-
license?: string;
|
|
40
|
-
private?: boolean;
|
|
41
|
-
deprecated?: boolean;
|
|
42
|
-
dependencies: Record<string, string>;
|
|
43
|
-
devDependencies: Record<string, string>;
|
|
44
|
-
peerDependencies: Record<string, string>;
|
|
45
|
-
optionalDependencies: Record<string, string>;
|
|
27
|
+
export interface NgPackageManifestProperties {
|
|
46
28
|
'ng-add'?: {
|
|
47
|
-
save?:
|
|
29
|
+
save?: NgAddSaveDependency;
|
|
48
30
|
};
|
|
49
31
|
'ng-update'?: {
|
|
50
|
-
migrations
|
|
51
|
-
packageGroup
|
|
32
|
+
migrations?: string;
|
|
33
|
+
packageGroup?: string[] | Record<string, string>;
|
|
34
|
+
packageGroupName?: string;
|
|
35
|
+
requirements?: string[] | Record<string, string>;
|
|
52
36
|
};
|
|
53
37
|
}
|
|
54
|
-
export interface
|
|
55
|
-
name: string;
|
|
56
|
-
tags: {
|
|
57
|
-
[tag: string]: PackageManifest | undefined;
|
|
58
|
-
};
|
|
59
|
-
versions: Record<string, PackageManifest>;
|
|
60
|
-
'dist-tags'?: unknown;
|
|
38
|
+
export interface PackageManifest extends Manifest, NgPackageManifestProperties {
|
|
61
39
|
}
|
|
62
40
|
export declare function fetchPackageMetadata(name: string, logger: logging.LoggerApi, options?: {
|
|
63
41
|
registry?: string;
|
|
@@ -35,10 +35,9 @@ const lockfile = __importStar(require("@yarnpkg/lockfile"));
|
|
|
35
35
|
const fs_1 = require("fs");
|
|
36
36
|
const ini = __importStar(require("ini"));
|
|
37
37
|
const os_1 = require("os");
|
|
38
|
-
const pacote = __importStar(require("pacote"));
|
|
39
38
|
const path = __importStar(require("path"));
|
|
40
|
-
const npmPackageJsonCache = new Map();
|
|
41
39
|
let npmrc;
|
|
40
|
+
const npmPackageJsonCache = new Map();
|
|
42
41
|
function ensureNpmrc(logger, usingYarn, verbose) {
|
|
43
42
|
if (!npmrc) {
|
|
44
43
|
try {
|
|
@@ -170,16 +169,6 @@ function normalizeOptions(rawOptions, location = process.cwd(), existingNormaliz
|
|
|
170
169
|
}
|
|
171
170
|
return options;
|
|
172
171
|
}
|
|
173
|
-
function normalizeManifest(rawManifest) {
|
|
174
|
-
// TODO: Fully normalize and sanitize
|
|
175
|
-
return {
|
|
176
|
-
dependencies: {},
|
|
177
|
-
devDependencies: {},
|
|
178
|
-
peerDependencies: {},
|
|
179
|
-
optionalDependencies: {},
|
|
180
|
-
...rawManifest,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
172
|
async function fetchPackageMetadata(name, logger, options) {
|
|
184
173
|
const { usingYarn, verbose, registry } = {
|
|
185
174
|
registry: undefined,
|
|
@@ -188,25 +177,18 @@ async function fetchPackageMetadata(name, logger, options) {
|
|
|
188
177
|
...options,
|
|
189
178
|
};
|
|
190
179
|
ensureNpmrc(logger, usingYarn, verbose);
|
|
191
|
-
const
|
|
180
|
+
const { packument } = await Promise.resolve().then(() => __importStar(require('pacote')));
|
|
181
|
+
const response = await packument(name, {
|
|
192
182
|
fullMetadata: true,
|
|
193
183
|
...npmrc,
|
|
194
184
|
...(registry ? { registry } : {}),
|
|
195
185
|
});
|
|
196
186
|
// Normalize the response
|
|
197
187
|
const metadata = {
|
|
198
|
-
|
|
188
|
+
...response,
|
|
199
189
|
tags: {},
|
|
200
|
-
versions: {},
|
|
201
190
|
};
|
|
202
|
-
if (response.versions) {
|
|
203
|
-
for (const [version, manifest] of Object.entries(response.versions)) {
|
|
204
|
-
metadata.versions[version] = normalizeManifest(manifest);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
191
|
if (response['dist-tags']) {
|
|
208
|
-
// Store this for use with other npm utility packages
|
|
209
|
-
metadata['dist-tags'] = response['dist-tags'];
|
|
210
192
|
for (const [tag, version] of Object.entries(response['dist-tags'])) {
|
|
211
193
|
const manifest = metadata.versions[version];
|
|
212
194
|
if (manifest) {
|
|
@@ -223,22 +205,24 @@ exports.fetchPackageMetadata = fetchPackageMetadata;
|
|
|
223
205
|
async function fetchPackageManifest(name, logger, options = {}) {
|
|
224
206
|
const { usingYarn = false, verbose = false, registry } = options;
|
|
225
207
|
ensureNpmrc(logger, usingYarn, verbose);
|
|
226
|
-
const
|
|
208
|
+
const { manifest } = await Promise.resolve().then(() => __importStar(require('pacote')));
|
|
209
|
+
const response = await manifest(name, {
|
|
227
210
|
fullMetadata: true,
|
|
228
211
|
...npmrc,
|
|
229
212
|
...(registry ? { registry } : {}),
|
|
230
213
|
});
|
|
231
|
-
return
|
|
214
|
+
return response;
|
|
232
215
|
}
|
|
233
216
|
exports.fetchPackageManifest = fetchPackageManifest;
|
|
234
|
-
function getNpmPackageJson(packageName, logger, options = {}) {
|
|
217
|
+
async function getNpmPackageJson(packageName, logger, options = {}) {
|
|
235
218
|
const cachedResponse = npmPackageJsonCache.get(packageName);
|
|
236
219
|
if (cachedResponse) {
|
|
237
220
|
return cachedResponse;
|
|
238
221
|
}
|
|
239
222
|
const { usingYarn = false, verbose = false, registry } = options;
|
|
240
223
|
ensureNpmrc(logger, usingYarn, verbose);
|
|
241
|
-
const
|
|
224
|
+
const { packument } = await Promise.resolve().then(() => __importStar(require('pacote')));
|
|
225
|
+
const resultPromise = packument(packageName, {
|
|
242
226
|
fullMetadata: true,
|
|
243
227
|
...npmrc,
|
|
244
228
|
...(registry ? { registry } : {}),
|
|
@@ -5,7 +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
|
-
import {
|
|
8
|
+
import { NgAddSaveDependency } from './package-metadata';
|
|
9
9
|
interface PackageJson {
|
|
10
10
|
name: string;
|
|
11
11
|
version: string;
|
|
@@ -17,7 +17,7 @@ interface PackageJson {
|
|
|
17
17
|
migrations?: string;
|
|
18
18
|
};
|
|
19
19
|
'ng-add'?: {
|
|
20
|
-
save?:
|
|
20
|
+
save?: NgAddSaveDependency;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
export interface PackageTreeNode {
|
package/src/utilities/prompt.js
CHANGED
|
@@ -31,7 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.askConfirmation = void 0;
|
|
34
|
-
const inquirer = __importStar(require("inquirer"));
|
|
35
34
|
const tty_1 = require("./tty");
|
|
36
35
|
async function askConfirmation(message, defaultResponse, noTTYResponse) {
|
|
37
36
|
if (!(0, tty_1.isTTY)()) {
|
|
@@ -44,7 +43,8 @@ async function askConfirmation(message, defaultResponse, noTTYResponse) {
|
|
|
44
43
|
message,
|
|
45
44
|
default: defaultResponse,
|
|
46
45
|
};
|
|
47
|
-
const
|
|
46
|
+
const { prompt } = await Promise.resolve().then(() => __importStar(require('inquirer')));
|
|
47
|
+
const answers = await prompt([question]);
|
|
48
48
|
return answers['confirmation'];
|
|
49
49
|
}
|
|
50
50
|
exports.askConfirmation = askConfirmation;
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
'use strict';
|
|
10
|
-
// This file is ES5 because it needs to be executed as is.
|
|
11
|
-
|
|
12
|
-
if ('NG_CLI_ANALYTICS' in process.env) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
var analytics = require('../../src/analytics/analytics');
|
|
18
|
-
|
|
19
|
-
analytics
|
|
20
|
-
.getAnalytics('global')
|
|
21
|
-
.then((hasGlobalConfig) => {
|
|
22
|
-
if (!hasGlobalConfig) {
|
|
23
|
-
return analytics.promptAnalytics(true /** global */);
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
.catch(() => {});
|
|
27
|
-
} catch (_) {}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
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
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
// These should not fail but if they do they should not block installation of the package
|
|
13
|
-
try {
|
|
14
|
-
// eslint-disable-next-line import/no-unassigned-import
|
|
15
|
-
require('./analytics-prompt');
|
|
16
|
-
} catch (_) {}
|
|
@@ -1,20 +0,0 @@
|
|
|
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.analyticsShareDisabled = exports.analyticsDisabled = void 0;
|
|
11
|
-
function isDisabled(variable) {
|
|
12
|
-
return variable === '0' || variable.toLowerCase() === 'false';
|
|
13
|
-
}
|
|
14
|
-
function isPresent(variable) {
|
|
15
|
-
return typeof variable === 'string' && variable !== '';
|
|
16
|
-
}
|
|
17
|
-
const analyticsVariable = process.env['NG_CLI_ANALYTICS'];
|
|
18
|
-
exports.analyticsDisabled = isPresent(analyticsVariable) && isDisabled(analyticsVariable);
|
|
19
|
-
const analyticsShareVariable = process.env['NG_CLI_ANALYTICS_SHARE'];
|
|
20
|
-
exports.analyticsShareDisabled = isPresent(analyticsShareVariable) && isDisabled(analyticsShareVariable);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { PackageManager } from '../../lib/config/workspace-schema';
|
|
9
|
-
import { NgAddSaveDepedency } from './package-metadata';
|
|
10
|
-
export declare function installAllPackages(packageManager?: PackageManager, extraArgs?: string[], cwd?: string): Promise<1 | 0>;
|
|
11
|
-
export declare function installPackage(packageName: string, packageManager?: PackageManager, save?: Exclude<NgAddSaveDepedency, false>, extraArgs?: string[], cwd?: string): Promise<1 | 0>;
|
|
12
|
-
export declare function installTempPackage(packageName: string, packageManager?: PackageManager, extraArgs?: string[]): Promise<{
|
|
13
|
-
status: 1 | 0;
|
|
14
|
-
tempNodeModules: string;
|
|
15
|
-
}>;
|
|
16
|
-
export declare function runTempPackageBin(packageName: string, packageManager?: PackageManager, args?: string[]): Promise<number>;
|
|
@@ -1,193 +0,0 @@
|
|
|
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.runTempPackageBin = exports.installTempPackage = exports.installPackage = exports.installAllPackages = void 0;
|
|
11
|
-
const child_process_1 = require("child_process");
|
|
12
|
-
const fs_1 = require("fs");
|
|
13
|
-
const os_1 = require("os");
|
|
14
|
-
const path_1 = require("path");
|
|
15
|
-
const workspace_schema_1 = require("../../lib/config/workspace-schema");
|
|
16
|
-
const spinner_1 = require("./spinner");
|
|
17
|
-
async function installAllPackages(packageManager = workspace_schema_1.PackageManager.Npm, extraArgs = [], cwd = process.cwd()) {
|
|
18
|
-
const packageManagerArgs = getPackageManagerArguments(packageManager);
|
|
19
|
-
const installArgs = [];
|
|
20
|
-
if (packageManagerArgs.installAll) {
|
|
21
|
-
installArgs.push(packageManagerArgs.installAll);
|
|
22
|
-
}
|
|
23
|
-
installArgs.push(packageManagerArgs.silent);
|
|
24
|
-
const spinner = new spinner_1.Spinner();
|
|
25
|
-
spinner.start('Installing packages...');
|
|
26
|
-
const bufferedOutput = [];
|
|
27
|
-
return new Promise((resolve, reject) => {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
const childProcess = (0, child_process_1.spawn)(packageManager, [...installArgs, ...extraArgs], {
|
|
30
|
-
stdio: 'pipe',
|
|
31
|
-
shell: true,
|
|
32
|
-
cwd,
|
|
33
|
-
}).on('close', (code) => {
|
|
34
|
-
if (code === 0) {
|
|
35
|
-
spinner.succeed('Packages successfully installed.');
|
|
36
|
-
resolve(0);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
spinner.stop();
|
|
40
|
-
bufferedOutput.forEach(({ stream, data }) => stream.write(data));
|
|
41
|
-
spinner.fail('Package install failed, see above.');
|
|
42
|
-
reject(1);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
(_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => bufferedOutput.push({ stream: process.stdout, data: data }));
|
|
46
|
-
(_b = childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => bufferedOutput.push({ stream: process.stderr, data: data }));
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
exports.installAllPackages = installAllPackages;
|
|
50
|
-
async function installPackage(packageName, packageManager = workspace_schema_1.PackageManager.Npm, save = true, extraArgs = [], cwd = process.cwd()) {
|
|
51
|
-
const packageManagerArgs = getPackageManagerArguments(packageManager);
|
|
52
|
-
const installArgs = [
|
|
53
|
-
packageManagerArgs.install,
|
|
54
|
-
packageName,
|
|
55
|
-
packageManagerArgs.silent,
|
|
56
|
-
];
|
|
57
|
-
const spinner = new spinner_1.Spinner();
|
|
58
|
-
spinner.start('Installing package...');
|
|
59
|
-
if (save === 'devDependencies') {
|
|
60
|
-
installArgs.push(packageManagerArgs.saveDev);
|
|
61
|
-
}
|
|
62
|
-
const bufferedOutput = [];
|
|
63
|
-
return new Promise((resolve, reject) => {
|
|
64
|
-
var _a, _b;
|
|
65
|
-
const childProcess = (0, child_process_1.spawn)(packageManager, [...installArgs, ...extraArgs], {
|
|
66
|
-
stdio: 'pipe',
|
|
67
|
-
shell: true,
|
|
68
|
-
cwd,
|
|
69
|
-
}).on('close', (code) => {
|
|
70
|
-
if (code === 0) {
|
|
71
|
-
spinner.succeed('Package successfully installed.');
|
|
72
|
-
resolve(0);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
spinner.stop();
|
|
76
|
-
bufferedOutput.forEach(({ stream, data }) => stream.write(data));
|
|
77
|
-
spinner.fail('Package install failed, see above.');
|
|
78
|
-
reject(1);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
(_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => bufferedOutput.push({ stream: process.stdout, data: data }));
|
|
82
|
-
(_b = childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => bufferedOutput.push({ stream: process.stderr, data: data }));
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
exports.installPackage = installPackage;
|
|
86
|
-
async function installTempPackage(packageName, packageManager = workspace_schema_1.PackageManager.Npm, extraArgs) {
|
|
87
|
-
const tempPath = (0, fs_1.mkdtempSync)((0, path_1.join)((0, fs_1.realpathSync)((0, os_1.tmpdir)()), 'angular-cli-packages-'));
|
|
88
|
-
// clean up temp directory on process exit
|
|
89
|
-
process.on('exit', () => {
|
|
90
|
-
try {
|
|
91
|
-
(0, fs_1.rmdirSync)(tempPath, { recursive: true, maxRetries: 3 });
|
|
92
|
-
}
|
|
93
|
-
catch { }
|
|
94
|
-
});
|
|
95
|
-
// NPM will warn when a `package.json` is not found in the install directory
|
|
96
|
-
// Example:
|
|
97
|
-
// npm WARN enoent ENOENT: no such file or directory, open '/tmp/.ng-temp-packages-84Qi7y/package.json'
|
|
98
|
-
// npm WARN .ng-temp-packages-84Qi7y No description
|
|
99
|
-
// npm WARN .ng-temp-packages-84Qi7y No repository field.
|
|
100
|
-
// npm WARN .ng-temp-packages-84Qi7y No license field.
|
|
101
|
-
// While we can use `npm init -y` we will end up needing to update the 'package.json' anyways
|
|
102
|
-
// because of missing fields.
|
|
103
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(tempPath, 'package.json'), JSON.stringify({
|
|
104
|
-
name: 'temp-cli-install',
|
|
105
|
-
description: 'temp-cli-install',
|
|
106
|
-
repository: 'temp-cli-install',
|
|
107
|
-
license: 'MIT',
|
|
108
|
-
}));
|
|
109
|
-
// setup prefix/global modules path
|
|
110
|
-
const packageManagerArgs = getPackageManagerArguments(packageManager);
|
|
111
|
-
const tempNodeModules = (0, path_1.join)(tempPath, 'node_modules');
|
|
112
|
-
// Yarn will not append 'node_modules' to the path
|
|
113
|
-
const prefixPath = packageManager === workspace_schema_1.PackageManager.Yarn ? tempNodeModules : tempPath;
|
|
114
|
-
const installArgs = [
|
|
115
|
-
...(extraArgs || []),
|
|
116
|
-
`${packageManagerArgs.prefix}="${prefixPath}"`,
|
|
117
|
-
packageManagerArgs.noLockfile,
|
|
118
|
-
];
|
|
119
|
-
return {
|
|
120
|
-
status: await installPackage(packageName, packageManager, true, installArgs, tempPath),
|
|
121
|
-
tempNodeModules,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
exports.installTempPackage = installTempPackage;
|
|
125
|
-
async function runTempPackageBin(packageName, packageManager = workspace_schema_1.PackageManager.Npm, args = []) {
|
|
126
|
-
const { status: code, tempNodeModules } = await installTempPackage(packageName, packageManager);
|
|
127
|
-
if (code !== 0) {
|
|
128
|
-
return code;
|
|
129
|
-
}
|
|
130
|
-
// Remove version/tag etc... from package name
|
|
131
|
-
// Ex: @angular/cli@latest -> @angular/cli
|
|
132
|
-
const packageNameNoVersion = packageName.substring(0, packageName.lastIndexOf('@'));
|
|
133
|
-
const pkgLocation = (0, path_1.join)(tempNodeModules, packageNameNoVersion);
|
|
134
|
-
const packageJsonPath = (0, path_1.join)(pkgLocation, 'package.json');
|
|
135
|
-
// Get a binary location for this package
|
|
136
|
-
let binPath;
|
|
137
|
-
if ((0, fs_1.existsSync)(packageJsonPath)) {
|
|
138
|
-
const content = (0, fs_1.readFileSync)(packageJsonPath, 'utf-8');
|
|
139
|
-
if (content) {
|
|
140
|
-
const { bin = {} } = JSON.parse(content);
|
|
141
|
-
const binKeys = Object.keys(bin);
|
|
142
|
-
if (binKeys.length) {
|
|
143
|
-
binPath = (0, path_1.resolve)(pkgLocation, bin[binKeys[0]]);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (!binPath) {
|
|
148
|
-
throw new Error(`Cannot locate bin for temporary package: ${packageNameNoVersion}.`);
|
|
149
|
-
}
|
|
150
|
-
const { status, error } = (0, child_process_1.spawnSync)(process.execPath, [binPath, ...args], {
|
|
151
|
-
stdio: 'inherit',
|
|
152
|
-
env: {
|
|
153
|
-
...process.env,
|
|
154
|
-
NG_DISABLE_VERSION_CHECK: 'true',
|
|
155
|
-
NG_CLI_ANALYTICS: 'false',
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
if (status === null && error) {
|
|
159
|
-
throw error;
|
|
160
|
-
}
|
|
161
|
-
return status || 0;
|
|
162
|
-
}
|
|
163
|
-
exports.runTempPackageBin = runTempPackageBin;
|
|
164
|
-
function getPackageManagerArguments(packageManager) {
|
|
165
|
-
switch (packageManager) {
|
|
166
|
-
case workspace_schema_1.PackageManager.Yarn:
|
|
167
|
-
return {
|
|
168
|
-
silent: '--silent',
|
|
169
|
-
saveDev: '--dev',
|
|
170
|
-
install: 'add',
|
|
171
|
-
prefix: '--modules-folder',
|
|
172
|
-
noLockfile: '--no-lockfile',
|
|
173
|
-
};
|
|
174
|
-
case workspace_schema_1.PackageManager.Pnpm:
|
|
175
|
-
return {
|
|
176
|
-
silent: '--silent',
|
|
177
|
-
saveDev: '--save-dev',
|
|
178
|
-
install: 'add',
|
|
179
|
-
installAll: 'install',
|
|
180
|
-
prefix: '--prefix',
|
|
181
|
-
noLockfile: '--no-lockfile',
|
|
182
|
-
};
|
|
183
|
-
default:
|
|
184
|
-
return {
|
|
185
|
-
silent: '--quiet',
|
|
186
|
-
saveDev: '--save-dev',
|
|
187
|
-
install: 'install',
|
|
188
|
-
installAll: 'install',
|
|
189
|
-
prefix: '--prefix',
|
|
190
|
-
noLockfile: '--no-package-lock',
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
}
|