@angular/cli 14.0.0-rc.2 → 14.0.1
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.js +35 -9
- package/lib/init.js +14 -0
- package/package.json +11 -11
- package/src/command-builder/architect-base-command-module.js +1 -1
- package/src/command-builder/architect-command-module.js +16 -8
- package/src/command-builder/command-module.d.ts +1 -1
- package/src/command-builder/command-runner.js +15 -0
- package/src/command-builder/schematics-command-module.js +1 -1
- package/src/commands/cache/clean/cli.d.ts +1 -1
- package/src/commands/cache/clean/cli.js +1 -0
- package/src/commands/cache/cli.d.ts +1 -1
- package/src/commands/cache/cli.js +1 -0
- package/src/commands/cache/info/cli.d.ts +1 -1
- package/src/commands/cache/info/cli.js +1 -0
- package/src/commands/cache/settings/cli.d.ts +2 -2
- package/src/commands/cache/settings/cli.js +2 -0
- package/src/commands/completion/long-description.md +2 -5
- package/src/commands/config/cli.js +2 -2
- package/src/commands/deploy/cli.js +0 -4
- package/src/commands/update/cli.js +17 -1
- package/src/utilities/config.d.ts +10 -3
- package/src/utilities/config.js +26 -23
- package/src/utilities/package-manager.d.ts +1 -1
- package/src/utilities/package-manager.js +10 -15
package/lib/cli/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.VERSION = void 0;
|
|
11
|
-
const
|
|
11
|
+
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const util_1 = require("util");
|
|
13
13
|
const command_module_1 = require("../../src/command-builder/command-module");
|
|
14
14
|
const command_runner_1 = require("../../src/command-builder/command-runner");
|
|
@@ -17,22 +17,44 @@ const environment_options_1 = require("../../src/utilities/environment-options")
|
|
|
17
17
|
const log_file_1 = require("../../src/utilities/log-file");
|
|
18
18
|
var version_1 = require("../../src/utilities/version");
|
|
19
19
|
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
|
|
20
|
+
const MIN_NODEJS_VERISON = [14, 15];
|
|
20
21
|
/* eslint-disable no-console */
|
|
21
22
|
async function default_1(options) {
|
|
22
23
|
// This node version check ensures that the requirements of the project instance of the CLI are met
|
|
23
24
|
const [major, minor] = process.versions.node.split('.').map((part) => Number(part));
|
|
24
|
-
if (major <
|
|
25
|
+
if (major < MIN_NODEJS_VERISON[0] ||
|
|
26
|
+
(major === MIN_NODEJS_VERISON[0] && minor < MIN_NODEJS_VERISON[1])) {
|
|
25
27
|
process.stderr.write(`Node.js version ${process.version} detected.\n` +
|
|
26
|
-
|
|
28
|
+
`The Angular CLI requires a minimum of v${MIN_NODEJS_VERISON[0]}.${MIN_NODEJS_VERISON[1]}.\n\n` +
|
|
27
29
|
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n');
|
|
28
30
|
return 3;
|
|
29
31
|
}
|
|
30
|
-
const
|
|
31
|
-
info: (s) =>
|
|
32
|
-
debug: (s) =>
|
|
33
|
-
warn: (s) =>
|
|
34
|
-
error: (s) =>
|
|
35
|
-
fatal: (s) =>
|
|
32
|
+
const colorLevels = {
|
|
33
|
+
info: (s) => s,
|
|
34
|
+
debug: (s) => s,
|
|
35
|
+
warn: (s) => color_1.colors.bold.yellow(s),
|
|
36
|
+
error: (s) => color_1.colors.bold.red(s),
|
|
37
|
+
fatal: (s) => color_1.colors.bold.red(s),
|
|
38
|
+
};
|
|
39
|
+
const logger = new core_1.logging.IndentLogger('cli-main-logger');
|
|
40
|
+
const logInfo = console.log;
|
|
41
|
+
const logError = console.error;
|
|
42
|
+
const loggerFinished = logger.forEach((entry) => {
|
|
43
|
+
if (!environment_options_1.ngDebug && entry.level === 'debug') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const color = color_1.colors.enabled ? colorLevels[entry.level] : color_1.removeColor;
|
|
47
|
+
const message = color(entry.message);
|
|
48
|
+
switch (entry.level) {
|
|
49
|
+
case 'warn':
|
|
50
|
+
case 'fatal':
|
|
51
|
+
case 'error':
|
|
52
|
+
logError(message);
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
logInfo(message);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
36
58
|
});
|
|
37
59
|
// Redirect console to logger
|
|
38
60
|
console.info = console.log = function (...args) {
|
|
@@ -77,5 +99,9 @@ async function default_1(options) {
|
|
|
77
99
|
}
|
|
78
100
|
return 1;
|
|
79
101
|
}
|
|
102
|
+
finally {
|
|
103
|
+
logger.complete();
|
|
104
|
+
await loggerFinished;
|
|
105
|
+
}
|
|
80
106
|
}
|
|
81
107
|
exports.default = default_1;
|
package/lib/init.js
CHANGED
|
@@ -39,6 +39,13 @@ const color_1 = require("../src/utilities/color");
|
|
|
39
39
|
const config_1 = require("../src/utilities/config");
|
|
40
40
|
const environment_options_1 = require("../src/utilities/environment-options");
|
|
41
41
|
const version_1 = require("../src/utilities/version");
|
|
42
|
+
/**
|
|
43
|
+
* Angular CLI versions prior to v14 may not exit correctly if not forcibly exited
|
|
44
|
+
* via `process.exit()`. When bootstrapping, `forceExit` will be set to `true`
|
|
45
|
+
* if the local CLI version is less than v14 to prevent the CLI from hanging on
|
|
46
|
+
* exit in those cases.
|
|
47
|
+
*/
|
|
48
|
+
let forceExit = false;
|
|
42
49
|
(async () => {
|
|
43
50
|
var _a;
|
|
44
51
|
/**
|
|
@@ -74,6 +81,10 @@ const version_1 = require("../src/utilities/version");
|
|
|
74
81
|
console.error('Version mismatch check skipped. Unable to retrieve local version: ' + error);
|
|
75
82
|
}
|
|
76
83
|
}
|
|
84
|
+
// Ensure older versions of the CLI fully exit
|
|
85
|
+
if ((0, semver_1.major)(localVersion) < 14) {
|
|
86
|
+
forceExit = true;
|
|
87
|
+
}
|
|
77
88
|
let isGlobalGreater = false;
|
|
78
89
|
try {
|
|
79
90
|
isGlobalGreater = !!localVersion && globalVersion.compare(localVersion) > 0;
|
|
@@ -120,6 +131,9 @@ const version_1 = require("../src/utilities/version");
|
|
|
120
131
|
});
|
|
121
132
|
})
|
|
122
133
|
.then((exitCode) => {
|
|
134
|
+
if (forceExit) {
|
|
135
|
+
process.exit(exitCode);
|
|
136
|
+
}
|
|
123
137
|
process.exitCode = exitCode;
|
|
124
138
|
})
|
|
125
139
|
.catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/cli",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.1",
|
|
4
4
|
"description": "CLI tool for Angular",
|
|
5
5
|
"main": "lib/cli/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/angular/angular-cli",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@angular-devkit/architect": "0.1400.
|
|
29
|
-
"@angular-devkit/core": "14.0.
|
|
30
|
-
"@angular-devkit/schematics": "14.0.
|
|
31
|
-
"@schematics/angular": "14.0.
|
|
28
|
+
"@angular-devkit/architect": "0.1400.1",
|
|
29
|
+
"@angular-devkit/core": "14.0.1",
|
|
30
|
+
"@angular-devkit/schematics": "14.0.1",
|
|
31
|
+
"@schematics/angular": "14.0.1",
|
|
32
32
|
"@yarnpkg/lockfile": "1.1.0",
|
|
33
33
|
"ansi-colors": "4.1.1",
|
|
34
34
|
"debug": "4.3.4",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"ng-update": {
|
|
50
50
|
"migrations": "@schematics/angular/migrations/migration-collection.json",
|
|
51
51
|
"packageGroup": {
|
|
52
|
-
"@angular/cli": "14.0.
|
|
53
|
-
"@angular-devkit/architect": "0.1400.
|
|
54
|
-
"@angular-devkit/build-angular": "14.0.
|
|
55
|
-
"@angular-devkit/build-webpack": "0.1400.
|
|
56
|
-
"@angular-devkit/core": "14.0.
|
|
57
|
-
"@angular-devkit/schematics": "14.0.
|
|
52
|
+
"@angular/cli": "14.0.1",
|
|
53
|
+
"@angular-devkit/architect": "0.1400.1",
|
|
54
|
+
"@angular-devkit/build-angular": "14.0.1",
|
|
55
|
+
"@angular-devkit/build-webpack": "0.1400.1",
|
|
56
|
+
"@angular-devkit/core": "14.0.1",
|
|
57
|
+
"@angular-devkit/schematics": "14.0.1"
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
@@ -104,7 +104,7 @@ class ArchitectBaseCommandModule extends command_module_1.CommandModule {
|
|
|
104
104
|
(0, fs_1.existsSync)((0, path_1.resolve)(basePath, '.pnp.mjs'))) {
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
this.context.logger.warn(`Node packages may not be installed. Try installing with '${this.context.packageManager} install'.`);
|
|
107
|
+
this.context.logger.warn(`Node packages may not be installed. Try installing with '${this.context.packageManager.name} install'.`);
|
|
108
108
|
}
|
|
109
109
|
getArchitectTarget() {
|
|
110
110
|
return this.commandName;
|
|
@@ -17,6 +17,7 @@ exports.ArchitectCommandModule = void 0;
|
|
|
17
17
|
const config_1 = require("../utilities/config");
|
|
18
18
|
const memoize_1 = require("../utilities/memoize");
|
|
19
19
|
const architect_base_command_module_1 = require("./architect-base-command-module");
|
|
20
|
+
const command_module_1 = require("./command-module");
|
|
20
21
|
class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBaseCommandModule {
|
|
21
22
|
async builder(argv) {
|
|
22
23
|
const project = this.getArchitectProject();
|
|
@@ -73,13 +74,14 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
getArchitectProject() {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
const [, projectName] = this.context.args.positional;
|
|
77
|
+
const { options, positional } = this.context.args;
|
|
78
|
+
const [, projectName] = positional;
|
|
81
79
|
if (projectName) {
|
|
82
|
-
return
|
|
80
|
+
return projectName;
|
|
81
|
+
}
|
|
82
|
+
// Yargs allows positional args to be used as flags.
|
|
83
|
+
if (typeof options['project'] === 'string') {
|
|
84
|
+
return options['project'];
|
|
83
85
|
}
|
|
84
86
|
const target = this.getArchitectTarget();
|
|
85
87
|
const projectFromTarget = this.getProjectNamesByTarget(target);
|
|
@@ -105,8 +107,14 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
105
107
|
return allProjectsForTargetName;
|
|
106
108
|
}
|
|
107
109
|
const maybeProject = (0, config_1.getProjectByCwd)(workspace);
|
|
108
|
-
if (maybeProject
|
|
109
|
-
return [maybeProject];
|
|
110
|
+
if (maybeProject) {
|
|
111
|
+
return allProjectsForTargetName.includes(maybeProject) ? [maybeProject] : undefined;
|
|
112
|
+
}
|
|
113
|
+
const { getYargsCompletions, help } = this.context.args.options;
|
|
114
|
+
if (!getYargsCompletions && !help) {
|
|
115
|
+
// Only issue the below error when not in help / completion mode.
|
|
116
|
+
throw new command_module_1.CommandModuleError('Cannot determine project for command. ' +
|
|
117
|
+
'Pass the project name as a command line argument or change the current working directory to a project directory.');
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
return undefined;
|
|
@@ -25,7 +25,7 @@ export interface CommandContext {
|
|
|
25
25
|
currentDirectory: string;
|
|
26
26
|
root: string;
|
|
27
27
|
workspace?: AngularWorkspace;
|
|
28
|
-
globalConfiguration
|
|
28
|
+
globalConfiguration: AngularWorkspace;
|
|
29
29
|
logger: logging.Logger;
|
|
30
30
|
packageManager: PackageManagerUtils;
|
|
31
31
|
/** Arguments parsed in free-from without parser configuration. */
|
|
@@ -143,6 +143,7 @@ async function runCommand(args, logger) {
|
|
|
143
143
|
'deprecated: %s': color_1.colors.yellow('deprecated:') + ' %s',
|
|
144
144
|
'Did you mean %s?': 'Unknown command. Did you mean %s?',
|
|
145
145
|
})
|
|
146
|
+
.epilogue(color_1.colors.gray(getEpilogue(!!workspace)))
|
|
146
147
|
.demandCommand(1, command_1.demandCommandFailureMessage)
|
|
147
148
|
.recommendCommands()
|
|
148
149
|
.middleware(normalize_options_middleware_1.normalizeOptionsMiddleware)
|
|
@@ -161,3 +162,17 @@ async function runCommand(args, logger) {
|
|
|
161
162
|
return (_b = process.exitCode) !== null && _b !== void 0 ? _b : 0;
|
|
162
163
|
}
|
|
163
164
|
exports.runCommand = runCommand;
|
|
165
|
+
function getEpilogue(isInsideWorkspace) {
|
|
166
|
+
let message;
|
|
167
|
+
if (isInsideWorkspace) {
|
|
168
|
+
message =
|
|
169
|
+
'The above commands are available when running the Angular CLI inside a workspace.' +
|
|
170
|
+
'More commands are available when running outside a workspace.\n';
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
message =
|
|
174
|
+
'The above commands are available when running the Angular CLI outside a workspace.' +
|
|
175
|
+
'More commands are available when running inside a workspace.\n';
|
|
176
|
+
}
|
|
177
|
+
return message + 'For more information, see https://angular.io/cli/.\n';
|
|
178
|
+
}
|
|
@@ -261,7 +261,7 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
const value = (_a = getSchematicCollections(workspace === null || workspace === void 0 ? void 0 : workspace.getCli())) !== null && _a !== void 0 ? _a : getSchematicCollections(globalConfiguration
|
|
264
|
+
const value = (_a = getSchematicCollections(workspace === null || workspace === void 0 ? void 0 : workspace.getCli())) !== null && _a !== void 0 ? _a : getSchematicCollections(globalConfiguration.getCli());
|
|
265
265
|
if (value) {
|
|
266
266
|
return value;
|
|
267
267
|
}
|
|
@@ -11,7 +11,7 @@ export declare class CacheCleanModule extends CommandModule implements CommandMo
|
|
|
11
11
|
command: string;
|
|
12
12
|
describe: string;
|
|
13
13
|
longDescriptionPath: string | undefined;
|
|
14
|
-
static scope: CommandScope
|
|
14
|
+
static scope: CommandScope;
|
|
15
15
|
builder(localYargs: Argv): Argv;
|
|
16
16
|
run(): Promise<void>;
|
|
17
17
|
}
|
|
@@ -11,7 +11,7 @@ export declare class CacheCommandModule extends CommandModule implements Command
|
|
|
11
11
|
command: string;
|
|
12
12
|
describe: string;
|
|
13
13
|
longDescriptionPath: string;
|
|
14
|
-
static scope: CommandScope
|
|
14
|
+
static scope: CommandScope;
|
|
15
15
|
builder(localYargs: Argv): Argv;
|
|
16
16
|
run(_options: Options<{}>): void;
|
|
17
17
|
}
|
|
@@ -11,7 +11,7 @@ export declare class CacheInfoCommandModule extends CommandModule implements Com
|
|
|
11
11
|
command: string;
|
|
12
12
|
describe: string;
|
|
13
13
|
longDescriptionPath?: string | undefined;
|
|
14
|
-
static scope: CommandScope
|
|
14
|
+
static scope: CommandScope;
|
|
15
15
|
builder(localYargs: Argv): Argv;
|
|
16
16
|
run(): Promise<void>;
|
|
17
17
|
private getSizeOfDirectory;
|
|
@@ -12,7 +12,7 @@ export declare class CacheDisableModule extends CommandModule implements Command
|
|
|
12
12
|
aliases: string;
|
|
13
13
|
describe: string;
|
|
14
14
|
longDescriptionPath: string | undefined;
|
|
15
|
-
static scope: CommandScope
|
|
15
|
+
static scope: CommandScope;
|
|
16
16
|
builder(localYargs: Argv): Argv;
|
|
17
17
|
run(): Promise<void>;
|
|
18
18
|
}
|
|
@@ -21,7 +21,7 @@ export declare class CacheEnableModule extends CommandModule implements CommandM
|
|
|
21
21
|
aliases: string;
|
|
22
22
|
describe: string;
|
|
23
23
|
longDescriptionPath: string | undefined;
|
|
24
|
-
static scope: CommandScope
|
|
24
|
+
static scope: CommandScope;
|
|
25
25
|
builder(localYargs: Argv): Argv;
|
|
26
26
|
run(): Promise<void>;
|
|
27
27
|
}
|
|
@@ -25,6 +25,7 @@ class CacheDisableModule extends command_module_1.CommandModule {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.CacheDisableModule = CacheDisableModule;
|
|
28
|
+
CacheDisableModule.scope = command_module_1.CommandScope.In;
|
|
28
29
|
class CacheEnableModule extends command_module_1.CommandModule {
|
|
29
30
|
constructor() {
|
|
30
31
|
super(...arguments);
|
|
@@ -40,3 +41,4 @@ class CacheEnableModule extends command_module_1.CommandModule {
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
exports.CacheEnableModule = CacheEnableModule;
|
|
44
|
+
CacheEnableModule.scope = command_module_1.CommandScope.In;
|
|
@@ -13,11 +13,8 @@ Simply answer "Yes" and the CLI will take care of the rest.
|
|
|
13
13
|
|
|
14
14
|
```
|
|
15
15
|
$ ng serve
|
|
16
|
-
? Would you like to enable autocompletion? This will set up your terminal so pressing TAB while
|
|
17
|
-
|
|
18
|
-
autocompletion will modify configuration files in your home directory.) Yes
|
|
19
|
-
Appended `source <(ng completion script)` to `/home/my-username/.bashrc`. Restart your terminal or
|
|
20
|
-
run:
|
|
16
|
+
? Would you like to enable autocompletion? This will set up your terminal so pressing TAB while typing Angular CLI commands will show possible options and autocomplete arguments. (Enabling autocompletion will modify configuration files in your home directory.) Yes
|
|
17
|
+
Appended `source <(ng completion script)` to `/home/my-username/.bashrc`. Restart your terminal or run:
|
|
21
18
|
|
|
22
19
|
source <(ng completion script)
|
|
23
20
|
|
|
@@ -41,7 +41,7 @@ class ConfigCommandModule extends command_module_1.CommandModule {
|
|
|
41
41
|
}
|
|
42
42
|
async run(options) {
|
|
43
43
|
const level = options.global ? 'global' : 'local';
|
|
44
|
-
const [config] = (0, config_1.getWorkspaceRaw)(level);
|
|
44
|
+
const [config] = await (0, config_1.getWorkspaceRaw)(level);
|
|
45
45
|
if (options.value == undefined) {
|
|
46
46
|
if (!config) {
|
|
47
47
|
this.context.logger.error('No config found.');
|
|
@@ -90,7 +90,7 @@ class ConfigCommandModule extends command_module_1.CommandModule {
|
|
|
90
90
|
!validGlobalCliPaths.has(options.jsonPath)) {
|
|
91
91
|
throw new command_module_1.CommandModuleError('Invalid Path.');
|
|
92
92
|
}
|
|
93
|
-
const [config, configPath] = (0, config_1.getWorkspaceRaw)(options.global ? 'global' : 'local');
|
|
93
|
+
const [config, configPath] = await (0, config_1.getWorkspaceRaw)(options.global ? 'global' : 'local');
|
|
94
94
|
const { logger } = this.context;
|
|
95
95
|
if (!config || !configPath) {
|
|
96
96
|
throw new command_module_1.CommandModuleError('Confguration file cannot be found.');
|
|
@@ -19,10 +19,6 @@ class DeployCommandModule extends architect_command_module_1.ArchitectCommandMod
|
|
|
19
19
|
name: 'Amazon S3',
|
|
20
20
|
value: '@jefiozie/ngx-aws-deploy',
|
|
21
21
|
},
|
|
22
|
-
{
|
|
23
|
-
name: 'Azure',
|
|
24
|
-
value: '@azure/ng-deploy',
|
|
25
|
-
},
|
|
26
22
|
{
|
|
27
23
|
name: 'Firebase',
|
|
28
24
|
value: '@angular/fire',
|
|
@@ -510,7 +510,23 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
510
510
|
});
|
|
511
511
|
}
|
|
512
512
|
catch { }
|
|
513
|
-
|
|
513
|
+
let forceInstall = false;
|
|
514
|
+
// npm 7+ can fail due to it incorrectly resolving peer dependencies that have valid SemVer
|
|
515
|
+
// ranges during an update. Update will set correct versions of dependencies within the
|
|
516
|
+
// package.json file. The force option is set to workaround these errors.
|
|
517
|
+
// Example error:
|
|
518
|
+
// npm ERR! Conflicting peer dependency: @angular/compiler-cli@14.0.0-rc.0
|
|
519
|
+
// npm ERR! node_modules/@angular/compiler-cli
|
|
520
|
+
// npm ERR! peer @angular/compiler-cli@"^14.0.0 || ^14.0.0-rc" from @angular-devkit/build-angular@14.0.0-rc.0
|
|
521
|
+
// npm ERR! node_modules/@angular-devkit/build-angular
|
|
522
|
+
// npm ERR! dev @angular-devkit/build-angular@"~14.0.0-rc.0" from the root project
|
|
523
|
+
if (this.context.packageManager.name === workspace_schema_1.PackageManager.Npm &&
|
|
524
|
+
this.context.packageManager.version &&
|
|
525
|
+
semver.gte(this.context.packageManager.version, '7.0.0', { includePrerelease: true })) {
|
|
526
|
+
logVerbose('NPM 7+ detected -- enabling force option for package installation');
|
|
527
|
+
forceInstall = true;
|
|
528
|
+
}
|
|
529
|
+
const installationSuccess = await this.context.packageManager.installAll(forceInstall ? ['--force'] : [], this.context.root);
|
|
514
530
|
if (!installationSuccess) {
|
|
515
531
|
return 1;
|
|
516
532
|
}
|
|
@@ -21,9 +21,16 @@ export declare class AngularWorkspace {
|
|
|
21
21
|
save(): Promise<void>;
|
|
22
22
|
static load(workspaceFilePath: string): Promise<AngularWorkspace>;
|
|
23
23
|
}
|
|
24
|
-
export declare function getWorkspace(level
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
24
|
+
export declare function getWorkspace(level: 'global'): Promise<AngularWorkspace>;
|
|
25
|
+
export declare function getWorkspace(level: 'local'): Promise<AngularWorkspace | undefined>;
|
|
26
|
+
export declare function getWorkspace(level: 'local' | 'global'): Promise<AngularWorkspace | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* This method will load the workspace configuration in raw JSON format.
|
|
29
|
+
* When `level` is `global` and file doesn't exists, it will be created.
|
|
30
|
+
*
|
|
31
|
+
* NB: This method is intended to be used only for `ng config`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getWorkspaceRaw(level?: 'local' | 'global'): Promise<[JSONFile | null, string | null]>;
|
|
27
34
|
export declare function validateWorkspace(data: json.JsonObject): Promise<void>;
|
|
28
35
|
export declare function getProjectByCwd(workspace: AngularWorkspace): string | null;
|
|
29
36
|
export declare function getConfiguredPackageManager(): Promise<PackageManager | null>;
|
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.isWarningEnabled = exports.getSchematicDefaults = exports.getConfiguredPackageManager = exports.getProjectByCwd = exports.validateWorkspace = exports.getWorkspaceRaw = exports.
|
|
33
|
+
exports.isWarningEnabled = exports.getSchematicDefaults = exports.getConfiguredPackageManager = exports.getProjectByCwd = exports.validateWorkspace = exports.getWorkspaceRaw = 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"));
|
|
@@ -71,6 +71,7 @@ function createWorkspaceHost() {
|
|
|
71
71
|
exports.workspaceSchemaPath = path.join(__dirname, '../../lib/config/schema.json');
|
|
72
72
|
const configNames = ['angular.json', '.angular.json'];
|
|
73
73
|
const globalFileName = '.angular-config.json';
|
|
74
|
+
const defaultGlobalFilePath = path.join(os.homedir(), globalFileName);
|
|
74
75
|
function xdgConfigHome(home, configFile) {
|
|
75
76
|
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
76
77
|
const xdgConfigHome = process.env['XDG_CONFIG_HOME'] || path.join(home, '.config');
|
|
@@ -113,9 +114,8 @@ function globalFilePath() {
|
|
|
113
114
|
`Please move the file to the new location ~/.config/angular/config.json`);
|
|
114
115
|
return xdgConfigOld;
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return p;
|
|
117
|
+
if ((0, fs_1.existsSync)(defaultGlobalFilePath)) {
|
|
118
|
+
return defaultGlobalFilePath;
|
|
119
119
|
}
|
|
120
120
|
return null;
|
|
121
121
|
}
|
|
@@ -142,7 +142,7 @@ class AngularWorkspace {
|
|
|
142
142
|
return project === null || project === void 0 ? void 0 : project.extensions['cli'];
|
|
143
143
|
}
|
|
144
144
|
save() {
|
|
145
|
-
return core_1.workspaces.writeWorkspace(this.workspace, createWorkspaceHost(), this.filePath);
|
|
145
|
+
return core_1.workspaces.writeWorkspace(this.workspace, createWorkspaceHost(), this.filePath, core_1.workspaces.WorkspaceFormat.JSON);
|
|
146
146
|
}
|
|
147
147
|
static async load(workspaceFilePath) {
|
|
148
148
|
const result = await core_1.workspaces.readWorkspace(workspaceFilePath, createWorkspaceHost(), core_1.workspaces.WorkspaceFormat.JSON);
|
|
@@ -151,17 +151,21 @@ class AngularWorkspace {
|
|
|
151
151
|
}
|
|
152
152
|
exports.AngularWorkspace = AngularWorkspace;
|
|
153
153
|
const cachedWorkspaces = new Map();
|
|
154
|
-
async function getWorkspace(level
|
|
154
|
+
async function getWorkspace(level) {
|
|
155
155
|
if (cachedWorkspaces.has(level)) {
|
|
156
156
|
return cachedWorkspaces.get(level);
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
const configPath = level === 'local' ? projectFilePath() : globalFilePath();
|
|
159
159
|
if (!configPath) {
|
|
160
|
-
if (level === '
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
if (level === 'global') {
|
|
161
|
+
// Unlike a local config, a global config is not mandatory.
|
|
162
|
+
// So we create an empty one in memory and keep it as such until it has been modified and saved.
|
|
163
|
+
const globalWorkspace = new AngularWorkspace({ extensions: {}, projects: new core_1.workspaces.ProjectDefinitionCollection() }, defaultGlobalFilePath);
|
|
164
|
+
cachedWorkspaces.set(level, globalWorkspace);
|
|
165
|
+
return globalWorkspace;
|
|
163
166
|
}
|
|
164
|
-
|
|
167
|
+
cachedWorkspaces.set(level, undefined);
|
|
168
|
+
return undefined;
|
|
165
169
|
}
|
|
166
170
|
try {
|
|
167
171
|
const workspace = await AngularWorkspace.load(configPath);
|
|
@@ -174,21 +178,20 @@ async function getWorkspace(level = 'local') {
|
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
exports.getWorkspace = getWorkspace;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return globalPath;
|
|
185
|
-
}
|
|
186
|
-
exports.createGlobalSettings = createGlobalSettings;
|
|
187
|
-
function getWorkspaceRaw(level = 'local') {
|
|
181
|
+
/**
|
|
182
|
+
* This method will load the workspace configuration in raw JSON format.
|
|
183
|
+
* When `level` is `global` and file doesn't exists, it will be created.
|
|
184
|
+
*
|
|
185
|
+
* NB: This method is intended to be used only for `ng config`.
|
|
186
|
+
*/
|
|
187
|
+
async function getWorkspaceRaw(level = 'local') {
|
|
188
188
|
let configPath = level === 'local' ? projectFilePath() : globalFilePath();
|
|
189
189
|
if (!configPath) {
|
|
190
190
|
if (level === 'global') {
|
|
191
|
-
configPath =
|
|
191
|
+
configPath = defaultGlobalFilePath;
|
|
192
|
+
// Config doesn't exist, force create it.
|
|
193
|
+
const globalWorkspace = await getWorkspace('global');
|
|
194
|
+
await globalWorkspace.save();
|
|
192
195
|
}
|
|
193
196
|
else {
|
|
194
197
|
return [null, null];
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { PackageManager } from '../../lib/config/workspace-schema';
|
|
9
9
|
import { AngularWorkspace } from './config';
|
|
10
10
|
export interface PackageManagerUtilsContext {
|
|
11
|
-
globalConfiguration
|
|
11
|
+
globalConfiguration: AngularWorkspace;
|
|
12
12
|
workspace?: AngularWorkspace;
|
|
13
13
|
root: string;
|
|
14
14
|
}
|
|
@@ -61,24 +61,20 @@ class PackageManagerUtils {
|
|
|
61
61
|
/** Install a single package. */
|
|
62
62
|
async install(packageName, save = true, extraArgs = [], cwd) {
|
|
63
63
|
const packageManagerArgs = this.getArguments();
|
|
64
|
-
const installArgs = [
|
|
65
|
-
packageManagerArgs.install,
|
|
66
|
-
packageName,
|
|
67
|
-
packageManagerArgs.silent,
|
|
68
|
-
];
|
|
64
|
+
const installArgs = [packageManagerArgs.install, packageName];
|
|
69
65
|
if (save === 'devDependencies') {
|
|
70
66
|
installArgs.push(packageManagerArgs.saveDev);
|
|
71
67
|
}
|
|
72
|
-
return this.run([...installArgs, ...extraArgs], cwd);
|
|
68
|
+
return this.run([...installArgs, ...extraArgs], { cwd, silent: true });
|
|
73
69
|
}
|
|
74
70
|
/** Install all packages. */
|
|
75
71
|
async installAll(extraArgs = [], cwd) {
|
|
76
72
|
const packageManagerArgs = this.getArguments();
|
|
77
|
-
const installArgs = [
|
|
73
|
+
const installArgs = [];
|
|
78
74
|
if (packageManagerArgs.installAll) {
|
|
79
75
|
installArgs.push(packageManagerArgs.installAll);
|
|
80
76
|
}
|
|
81
|
-
return this.run([...installArgs, ...extraArgs], cwd);
|
|
77
|
+
return this.run([...installArgs, ...extraArgs], { cwd, silent: true });
|
|
82
78
|
}
|
|
83
79
|
/** Install a single package temporary. */
|
|
84
80
|
async installTemp(packageName, extraArgs) {
|
|
@@ -86,7 +82,7 @@ class PackageManagerUtils {
|
|
|
86
82
|
// clean up temp directory on process exit
|
|
87
83
|
process.on('exit', () => {
|
|
88
84
|
try {
|
|
89
|
-
(0, fs_1.
|
|
85
|
+
(0, fs_1.rmSync)(tempPath, { recursive: true, maxRetries: 3 });
|
|
90
86
|
}
|
|
91
87
|
catch { }
|
|
92
88
|
});
|
|
@@ -123,7 +119,6 @@ class PackageManagerUtils {
|
|
|
123
119
|
switch (this.name) {
|
|
124
120
|
case workspace_schema_1.PackageManager.Yarn:
|
|
125
121
|
return {
|
|
126
|
-
silent: '--silent',
|
|
127
122
|
saveDev: '--dev',
|
|
128
123
|
install: 'add',
|
|
129
124
|
prefix: '--modules-folder',
|
|
@@ -131,7 +126,6 @@ class PackageManagerUtils {
|
|
|
131
126
|
};
|
|
132
127
|
case workspace_schema_1.PackageManager.Pnpm:
|
|
133
128
|
return {
|
|
134
|
-
silent: '--silent',
|
|
135
129
|
saveDev: '--save-dev',
|
|
136
130
|
install: 'add',
|
|
137
131
|
installAll: 'install',
|
|
@@ -140,7 +134,6 @@ class PackageManagerUtils {
|
|
|
140
134
|
};
|
|
141
135
|
default:
|
|
142
136
|
return {
|
|
143
|
-
silent: '--quiet',
|
|
144
137
|
saveDev: '--save-dev',
|
|
145
138
|
install: 'install',
|
|
146
139
|
installAll: 'install',
|
|
@@ -149,14 +142,16 @@ class PackageManagerUtils {
|
|
|
149
142
|
};
|
|
150
143
|
}
|
|
151
144
|
}
|
|
152
|
-
async run(args,
|
|
145
|
+
async run(args, options = {}) {
|
|
146
|
+
const { cwd = process.cwd(), silent = false } = options;
|
|
153
147
|
const spinner = new spinner_1.Spinner();
|
|
154
148
|
spinner.start('Installing packages...');
|
|
155
149
|
return new Promise((resolve) => {
|
|
156
150
|
var _a, _b;
|
|
157
151
|
const bufferedOutput = [];
|
|
158
152
|
const childProcess = (0, child_process_1.spawn)(this.name, args, {
|
|
159
|
-
|
|
153
|
+
// Always pipe stderr to allow for failures to be reported
|
|
154
|
+
stdio: silent ? ['ignore', 'ignore', 'pipe'] : 'pipe',
|
|
160
155
|
shell: true,
|
|
161
156
|
cwd,
|
|
162
157
|
}).on('close', (code) => {
|
|
@@ -273,7 +268,7 @@ class PackageManagerUtils {
|
|
|
273
268
|
result !== null && result !== void 0 ? result : (result = getPackageManager(localWorkspace.extensions['cli']));
|
|
274
269
|
}
|
|
275
270
|
if (!result) {
|
|
276
|
-
result = getPackageManager(globalWorkspace
|
|
271
|
+
result = getPackageManager(globalWorkspace.extensions['cli']);
|
|
277
272
|
}
|
|
278
273
|
return result;
|
|
279
274
|
}
|