@angular/cli 18.1.0-next.2 → 18.1.0-rc.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/lib/cli/index.js +5 -4
- package/package.json +18 -18
- package/src/command-builder/architect-base-command-module.js +1 -1
- package/src/command-builder/architect-command-module.js +158 -124
- package/src/command-builder/command-module.js +225 -196
- package/src/command-builder/schematics-command-module.js +308 -284
- package/src/commands/add/cli.js +193 -123
- package/src/commands/new/cli.js +1 -1
- package/src/commands/update/cli.js +62 -31
- package/src/utilities/color.d.ts +2 -3
- package/src/utilities/color.js +15 -51
- package/src/utilities/memoize.d.ts +1 -1
- package/src/utilities/memoize.js +14 -19
- package/src/utilities/package-manager.js +265 -245
- package/src/utilities/tty.d.ts +1 -1
- package/src/utilities/tty.js +2 -2
- package/src/utilities/version.js +1 -1
- package/src/utilities/spinner.d.ts +0 -20
- package/src/utilities/spinner.js +0 -55
|
@@ -6,14 +6,39 @@
|
|
|
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.dev/license
|
|
8
8
|
*/
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
10
|
+
var useValue = arguments.length > 2;
|
|
11
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
12
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
13
|
+
}
|
|
14
|
+
return useValue ? value : void 0;
|
|
14
15
|
};
|
|
15
|
-
var
|
|
16
|
-
if (
|
|
16
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
17
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
18
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
19
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
20
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
21
|
+
var _, done = false;
|
|
22
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
23
|
+
var context = {};
|
|
24
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
25
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
26
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
27
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
28
|
+
if (kind === "accessor") {
|
|
29
|
+
if (result === void 0) continue;
|
|
30
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
31
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
32
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
33
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
34
|
+
}
|
|
35
|
+
else if (_ = accept(result)) {
|
|
36
|
+
if (kind === "field") initializers.unshift(_);
|
|
37
|
+
else descriptor[key] = _;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
41
|
+
done = true;
|
|
17
42
|
};
|
|
18
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
44
|
exports.PackageManagerUtils = void 0;
|
|
@@ -25,263 +50,258 @@ const path_1 = require("path");
|
|
|
25
50
|
const workspace_schema_1 = require("../../lib/config/workspace-schema");
|
|
26
51
|
const config_1 = require("./config");
|
|
27
52
|
const memoize_1 = require("./memoize");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return this.getVersion(this.name);
|
|
41
|
-
}
|
|
42
|
-
/** Install a single package. */
|
|
43
|
-
async install(packageName, save = true, extraArgs = [], cwd) {
|
|
44
|
-
const packageManagerArgs = this.getArguments();
|
|
45
|
-
const installArgs = [packageManagerArgs.install, packageName];
|
|
46
|
-
if (save === 'devDependencies') {
|
|
47
|
-
installArgs.push(packageManagerArgs.saveDev);
|
|
53
|
+
let PackageManagerUtils = (() => {
|
|
54
|
+
let _instanceExtraInitializers = [];
|
|
55
|
+
let _getVersion_decorators;
|
|
56
|
+
let _getName_decorators;
|
|
57
|
+
return class PackageManagerUtils {
|
|
58
|
+
static {
|
|
59
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
60
|
+
_getVersion_decorators = [memoize_1.memoize];
|
|
61
|
+
_getName_decorators = [memoize_1.memoize];
|
|
62
|
+
__esDecorate(this, null, _getVersion_decorators, { kind: "method", name: "getVersion", static: false, private: false, access: { has: obj => "getVersion" in obj, get: obj => obj.getVersion }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
63
|
+
__esDecorate(this, null, _getName_decorators, { kind: "method", name: "getName", static: false, private: false, access: { has: obj => "getName" in obj, get: obj => obj.getName }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
64
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
48
65
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
async installAll(extraArgs = [], cwd) {
|
|
53
|
-
const packageManagerArgs = this.getArguments();
|
|
54
|
-
const installArgs = [];
|
|
55
|
-
if (packageManagerArgs.installAll) {
|
|
56
|
-
installArgs.push(packageManagerArgs.installAll);
|
|
66
|
+
context = __runInitializers(this, _instanceExtraInitializers);
|
|
67
|
+
constructor(context) {
|
|
68
|
+
this.context = context;
|
|
57
69
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
/** Get the package manager name. */
|
|
71
|
+
get name() {
|
|
72
|
+
return this.getName();
|
|
73
|
+
}
|
|
74
|
+
/** Get the package manager version. */
|
|
75
|
+
get version() {
|
|
76
|
+
return this.getVersion(this.name);
|
|
77
|
+
}
|
|
78
|
+
/** Install a single package. */
|
|
79
|
+
async install(packageName, save = true, extraArgs = [], cwd) {
|
|
80
|
+
const packageManagerArgs = this.getArguments();
|
|
81
|
+
const installArgs = [packageManagerArgs.install, packageName];
|
|
82
|
+
if (save === 'devDependencies') {
|
|
83
|
+
installArgs.push(packageManagerArgs.saveDev);
|
|
67
84
|
}
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
// NPM will warn when a `package.json` is not found in the install directory
|
|
71
|
-
// Example:
|
|
72
|
-
// npm WARN enoent ENOENT: no such file or directory, open '/tmp/.ng-temp-packages-84Qi7y/package.json'
|
|
73
|
-
// npm WARN .ng-temp-packages-84Qi7y No description
|
|
74
|
-
// npm WARN .ng-temp-packages-84Qi7y No repository field.
|
|
75
|
-
// npm WARN .ng-temp-packages-84Qi7y No license field.
|
|
76
|
-
// While we can use `npm init -y` we will end up needing to update the 'package.json' anyways
|
|
77
|
-
// because of missing fields.
|
|
78
|
-
await fs_1.promises.writeFile((0, path_1.join)(tempPath, 'package.json'), JSON.stringify({
|
|
79
|
-
name: 'temp-cli-install',
|
|
80
|
-
description: 'temp-cli-install',
|
|
81
|
-
repository: 'temp-cli-install',
|
|
82
|
-
license: 'MIT',
|
|
83
|
-
}));
|
|
84
|
-
// setup prefix/global modules path
|
|
85
|
-
const packageManagerArgs = this.getArguments();
|
|
86
|
-
const tempNodeModules = (0, path_1.join)(tempPath, 'node_modules');
|
|
87
|
-
// Yarn will not append 'node_modules' to the path
|
|
88
|
-
const prefixPath = this.name === workspace_schema_1.PackageManager.Yarn ? tempNodeModules : tempPath;
|
|
89
|
-
const installArgs = [
|
|
90
|
-
...(extraArgs ?? []),
|
|
91
|
-
`${packageManagerArgs.prefix}="${prefixPath}"`,
|
|
92
|
-
packageManagerArgs.noLockfile,
|
|
93
|
-
];
|
|
94
|
-
return {
|
|
95
|
-
success: await this.install(packageName, true, installArgs, tempPath),
|
|
96
|
-
tempNodeModules,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
getArguments() {
|
|
100
|
-
switch (this.name) {
|
|
101
|
-
case workspace_schema_1.PackageManager.Yarn:
|
|
102
|
-
return {
|
|
103
|
-
saveDev: '--dev',
|
|
104
|
-
install: 'add',
|
|
105
|
-
prefix: '--modules-folder',
|
|
106
|
-
noLockfile: '--no-lockfile',
|
|
107
|
-
};
|
|
108
|
-
case workspace_schema_1.PackageManager.Pnpm:
|
|
109
|
-
return {
|
|
110
|
-
saveDev: '--save-dev',
|
|
111
|
-
install: 'add',
|
|
112
|
-
installAll: 'install',
|
|
113
|
-
prefix: '--prefix',
|
|
114
|
-
noLockfile: '--no-lockfile',
|
|
115
|
-
};
|
|
116
|
-
case workspace_schema_1.PackageManager.Bun:
|
|
117
|
-
return {
|
|
118
|
-
saveDev: '--development',
|
|
119
|
-
install: 'add',
|
|
120
|
-
installAll: 'install',
|
|
121
|
-
prefix: '--cwd',
|
|
122
|
-
noLockfile: '',
|
|
123
|
-
};
|
|
124
|
-
default:
|
|
125
|
-
return {
|
|
126
|
-
saveDev: '--save-dev',
|
|
127
|
-
install: 'install',
|
|
128
|
-
installAll: 'install',
|
|
129
|
-
prefix: '--prefix',
|
|
130
|
-
noLockfile: '--no-package-lock',
|
|
131
|
-
};
|
|
85
|
+
return this.run([...installArgs, ...extraArgs], { cwd, silent: true });
|
|
132
86
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
spinner.stop();
|
|
152
|
-
bufferedOutput.forEach(({ stream, data }) => stream.write(data));
|
|
153
|
-
spinner.fail('Packages installation failed, see above.');
|
|
154
|
-
resolve(false);
|
|
87
|
+
/** Install all packages. */
|
|
88
|
+
async installAll(extraArgs = [], cwd) {
|
|
89
|
+
const packageManagerArgs = this.getArguments();
|
|
90
|
+
const installArgs = [];
|
|
91
|
+
if (packageManagerArgs.installAll) {
|
|
92
|
+
installArgs.push(packageManagerArgs.installAll);
|
|
93
|
+
}
|
|
94
|
+
return this.run([...installArgs, ...extraArgs], { cwd, silent: true });
|
|
95
|
+
}
|
|
96
|
+
/** Install a single package temporary. */
|
|
97
|
+
async installTemp(packageName, extraArgs) {
|
|
98
|
+
const tempPath = await fs_1.promises.mkdtemp((0, path_1.join)((0, fs_1.realpathSync)((0, os_1.tmpdir)()), 'angular-cli-packages-'));
|
|
99
|
+
// clean up temp directory on process exit
|
|
100
|
+
process.on('exit', () => {
|
|
101
|
+
try {
|
|
102
|
+
(0, fs_1.rmSync)(tempPath, { recursive: true, maxRetries: 3 });
|
|
155
103
|
}
|
|
104
|
+
catch { }
|
|
156
105
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
106
|
+
// NPM will warn when a `package.json` is not found in the install directory
|
|
107
|
+
// Example:
|
|
108
|
+
// npm WARN enoent ENOENT: no such file or directory, open '/tmp/.ng-temp-packages-84Qi7y/package.json'
|
|
109
|
+
// npm WARN .ng-temp-packages-84Qi7y No description
|
|
110
|
+
// npm WARN .ng-temp-packages-84Qi7y No repository field.
|
|
111
|
+
// npm WARN .ng-temp-packages-84Qi7y No license field.
|
|
112
|
+
// While we can use `npm init -y` we will end up needing to update the 'package.json' anyways
|
|
113
|
+
// because of missing fields.
|
|
114
|
+
await fs_1.promises.writeFile((0, path_1.join)(tempPath, 'package.json'), JSON.stringify({
|
|
115
|
+
name: 'temp-cli-install',
|
|
116
|
+
description: 'temp-cli-install',
|
|
117
|
+
repository: 'temp-cli-install',
|
|
118
|
+
license: 'MIT',
|
|
119
|
+
}));
|
|
120
|
+
// setup prefix/global modules path
|
|
121
|
+
const packageManagerArgs = this.getArguments();
|
|
122
|
+
const tempNodeModules = (0, path_1.join)(tempPath, 'node_modules');
|
|
123
|
+
// Yarn will not append 'node_modules' to the path
|
|
124
|
+
const prefixPath = this.name === workspace_schema_1.PackageManager.Yarn ? tempNodeModules : tempPath;
|
|
125
|
+
const installArgs = [
|
|
126
|
+
...(extraArgs ?? []),
|
|
127
|
+
`${packageManagerArgs.prefix}="${prefixPath}"`,
|
|
128
|
+
packageManagerArgs.noLockfile,
|
|
129
|
+
];
|
|
130
|
+
return {
|
|
131
|
+
success: await this.install(packageName, true, installArgs, tempPath),
|
|
132
|
+
tempNodeModules,
|
|
133
|
+
};
|
|
173
134
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
135
|
+
getArguments() {
|
|
136
|
+
switch (this.name) {
|
|
137
|
+
case workspace_schema_1.PackageManager.Yarn:
|
|
138
|
+
return {
|
|
139
|
+
saveDev: '--dev',
|
|
140
|
+
install: 'add',
|
|
141
|
+
prefix: '--modules-folder',
|
|
142
|
+
noLockfile: '--no-lockfile',
|
|
143
|
+
};
|
|
144
|
+
case workspace_schema_1.PackageManager.Pnpm:
|
|
145
|
+
return {
|
|
146
|
+
saveDev: '--save-dev',
|
|
147
|
+
install: 'add',
|
|
148
|
+
installAll: 'install',
|
|
149
|
+
prefix: '--prefix',
|
|
150
|
+
noLockfile: '--no-lockfile',
|
|
151
|
+
};
|
|
152
|
+
case workspace_schema_1.PackageManager.Bun:
|
|
153
|
+
return {
|
|
154
|
+
saveDev: '--development',
|
|
155
|
+
install: 'add',
|
|
156
|
+
installAll: 'install',
|
|
157
|
+
prefix: '--cwd',
|
|
158
|
+
noLockfile: '',
|
|
159
|
+
};
|
|
160
|
+
default:
|
|
161
|
+
return {
|
|
162
|
+
saveDev: '--save-dev',
|
|
163
|
+
install: 'install',
|
|
164
|
+
installAll: 'install',
|
|
165
|
+
prefix: '--prefix',
|
|
166
|
+
noLockfile: '--no-package-lock',
|
|
167
|
+
};
|
|
195
168
|
}
|
|
196
169
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
170
|
+
async run(args, options = {}) {
|
|
171
|
+
const { cwd = process.cwd(), silent = false } = options;
|
|
172
|
+
return new Promise((resolve) => {
|
|
173
|
+
const bufferedOutput = [];
|
|
174
|
+
const childProcess = (0, child_process_1.spawn)(this.name, args, {
|
|
175
|
+
// Always pipe stderr to allow for failures to be reported
|
|
176
|
+
stdio: silent ? ['ignore', 'ignore', 'pipe'] : 'pipe',
|
|
177
|
+
shell: true,
|
|
178
|
+
cwd,
|
|
179
|
+
}).on('close', (code) => {
|
|
180
|
+
if (code === 0) {
|
|
181
|
+
resolve(true);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
bufferedOutput.forEach(({ stream, data }) => stream.write(data));
|
|
185
|
+
resolve(false);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
childProcess.stdout?.on('data', (data) => bufferedOutput.push({ stream: process.stdout, data: data }));
|
|
189
|
+
childProcess.stderr?.on('data', (data) => bufferedOutput.push({ stream: process.stderr, data: data }));
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
getVersion(name) {
|
|
193
|
+
try {
|
|
194
|
+
return (0, child_process_1.execSync)(`${name} --version`, {
|
|
195
|
+
encoding: 'utf8',
|
|
196
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
197
|
+
env: {
|
|
198
|
+
...process.env,
|
|
199
|
+
// NPM updater notifier will prevents the child process from closing until it timeout after 3 minutes.
|
|
200
|
+
NO_UPDATE_NOTIFIER: '1',
|
|
201
|
+
NPM_CONFIG_UPDATE_NOTIFIER: 'false',
|
|
202
|
+
},
|
|
203
|
+
}).trim();
|
|
206
204
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return workspace_schema_1.PackageManager.Bun;
|
|
205
|
+
catch {
|
|
206
|
+
return undefined;
|
|
210
207
|
}
|
|
211
208
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const hasBun = !!this.getVersion(workspace_schema_1.PackageManager.Bun);
|
|
217
|
-
if (hasYarn && !hasPnpm && !hasBun) {
|
|
218
|
-
return workspace_schema_1.PackageManager.Yarn;
|
|
209
|
+
getName() {
|
|
210
|
+
const packageManager = this.getConfiguredPackageManager();
|
|
211
|
+
if (packageManager) {
|
|
212
|
+
return packageManager;
|
|
219
213
|
}
|
|
220
|
-
|
|
221
|
-
|
|
214
|
+
const hasNpmLock = this.hasLockfile(workspace_schema_1.PackageManager.Npm);
|
|
215
|
+
const hasYarnLock = this.hasLockfile(workspace_schema_1.PackageManager.Yarn);
|
|
216
|
+
const hasPnpmLock = this.hasLockfile(workspace_schema_1.PackageManager.Pnpm);
|
|
217
|
+
const hasBunLock = this.hasLockfile(workspace_schema_1.PackageManager.Bun);
|
|
218
|
+
// PERF NOTE: `this.getVersion` spawns the package a the child_process which can take around ~300ms at times.
|
|
219
|
+
// Therefore, we should only call this method when needed. IE: don't call `this.getVersion(PackageManager.Pnpm)` unless truly needed.
|
|
220
|
+
// The result of this method is not stored in a variable because it's memoized.
|
|
221
|
+
if (hasNpmLock) {
|
|
222
|
+
// Has NPM lock file.
|
|
223
|
+
if (!hasYarnLock && !hasPnpmLock && !hasBunLock && this.getVersion(workspace_schema_1.PackageManager.Npm)) {
|
|
224
|
+
// Only NPM lock file and NPM binary is available.
|
|
225
|
+
return workspace_schema_1.PackageManager.Npm;
|
|
226
|
+
}
|
|
222
227
|
}
|
|
223
|
-
else
|
|
224
|
-
|
|
228
|
+
else {
|
|
229
|
+
// No NPM lock file.
|
|
230
|
+
if (hasYarnLock && this.getVersion(workspace_schema_1.PackageManager.Yarn)) {
|
|
231
|
+
// Yarn lock file and Yarn binary is available.
|
|
232
|
+
return workspace_schema_1.PackageManager.Yarn;
|
|
233
|
+
}
|
|
234
|
+
else if (hasPnpmLock && this.getVersion(workspace_schema_1.PackageManager.Pnpm)) {
|
|
235
|
+
// PNPM lock file and PNPM binary is available.
|
|
236
|
+
return workspace_schema_1.PackageManager.Pnpm;
|
|
237
|
+
}
|
|
238
|
+
else if (hasBunLock && this.getVersion(workspace_schema_1.PackageManager.Bun)) {
|
|
239
|
+
// Bun lock file and Bun binary is available.
|
|
240
|
+
return workspace_schema_1.PackageManager.Bun;
|
|
241
|
+
}
|
|
225
242
|
}
|
|
243
|
+
if (!this.getVersion(workspace_schema_1.PackageManager.Npm)) {
|
|
244
|
+
// Doesn't have NPM installed.
|
|
245
|
+
const hasYarn = !!this.getVersion(workspace_schema_1.PackageManager.Yarn);
|
|
246
|
+
const hasPnpm = !!this.getVersion(workspace_schema_1.PackageManager.Pnpm);
|
|
247
|
+
const hasBun = !!this.getVersion(workspace_schema_1.PackageManager.Bun);
|
|
248
|
+
if (hasYarn && !hasPnpm && !hasBun) {
|
|
249
|
+
return workspace_schema_1.PackageManager.Yarn;
|
|
250
|
+
}
|
|
251
|
+
else if (hasPnpm && !hasYarn && !hasBun) {
|
|
252
|
+
return workspace_schema_1.PackageManager.Pnpm;
|
|
253
|
+
}
|
|
254
|
+
else if (hasBun && !hasYarn && !hasPnpm) {
|
|
255
|
+
return workspace_schema_1.PackageManager.Bun;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// TODO: This should eventually inform the user of ambiguous package manager usage.
|
|
259
|
+
// Potentially with a prompt to choose and optionally set as the default.
|
|
260
|
+
return workspace_schema_1.PackageManager.Npm;
|
|
226
261
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
lockfileName = 'package-lock.json';
|
|
246
|
-
break;
|
|
262
|
+
hasLockfile(packageManager) {
|
|
263
|
+
let lockfileName;
|
|
264
|
+
switch (packageManager) {
|
|
265
|
+
case workspace_schema_1.PackageManager.Yarn:
|
|
266
|
+
lockfileName = 'yarn.lock';
|
|
267
|
+
break;
|
|
268
|
+
case workspace_schema_1.PackageManager.Pnpm:
|
|
269
|
+
lockfileName = 'pnpm-lock.yaml';
|
|
270
|
+
break;
|
|
271
|
+
case workspace_schema_1.PackageManager.Bun:
|
|
272
|
+
lockfileName = 'bun.lockb';
|
|
273
|
+
break;
|
|
274
|
+
case workspace_schema_1.PackageManager.Npm:
|
|
275
|
+
default:
|
|
276
|
+
lockfileName = 'package-lock.json';
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
return (0, fs_1.existsSync)((0, path_1.join)(this.context.root, lockfileName));
|
|
247
280
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
281
|
+
getConfiguredPackageManager() {
|
|
282
|
+
const getPackageManager = (source) => {
|
|
283
|
+
if (source && (0, core_1.isJsonObject)(source)) {
|
|
284
|
+
const value = source['packageManager'];
|
|
285
|
+
if (typeof value === 'string') {
|
|
286
|
+
return value;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return undefined;
|
|
290
|
+
};
|
|
291
|
+
let result;
|
|
292
|
+
const { workspace: localWorkspace, globalConfiguration: globalWorkspace } = this.context;
|
|
293
|
+
if (localWorkspace) {
|
|
294
|
+
const project = (0, config_1.getProjectByCwd)(localWorkspace);
|
|
295
|
+
if (project) {
|
|
296
|
+
result = getPackageManager(localWorkspace.projects.get(project)?.extensions['cli']);
|
|
256
297
|
}
|
|
298
|
+
result ??= getPackageManager(localWorkspace.extensions['cli']);
|
|
257
299
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
let result;
|
|
261
|
-
const { workspace: localWorkspace, globalConfiguration: globalWorkspace } = this.context;
|
|
262
|
-
if (localWorkspace) {
|
|
263
|
-
const project = (0, config_1.getProjectByCwd)(localWorkspace);
|
|
264
|
-
if (project) {
|
|
265
|
-
result = getPackageManager(localWorkspace.projects.get(project)?.extensions['cli']);
|
|
300
|
+
if (!result) {
|
|
301
|
+
result = getPackageManager(globalWorkspace.extensions['cli']);
|
|
266
302
|
}
|
|
267
|
-
result
|
|
303
|
+
return result;
|
|
268
304
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
return result;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
305
|
+
};
|
|
306
|
+
})();
|
|
275
307
|
exports.PackageManagerUtils = PackageManagerUtils;
|
|
276
|
-
__decorate([
|
|
277
|
-
memoize_1.memoize,
|
|
278
|
-
__metadata("design:type", Function),
|
|
279
|
-
__metadata("design:paramtypes", [String]),
|
|
280
|
-
__metadata("design:returntype", Object)
|
|
281
|
-
], PackageManagerUtils.prototype, "getVersion", null);
|
|
282
|
-
__decorate([
|
|
283
|
-
memoize_1.memoize,
|
|
284
|
-
__metadata("design:type", Function),
|
|
285
|
-
__metadata("design:paramtypes", []),
|
|
286
|
-
__metadata("design:returntype", String)
|
|
287
|
-
], PackageManagerUtils.prototype, "getName", null);
|
package/src/utilities/tty.d.ts
CHANGED
package/src/utilities/tty.js
CHANGED
|
@@ -12,11 +12,11 @@ function _isTruthy(value) {
|
|
|
12
12
|
// Returns true if value is a string that is anything but 0 or false.
|
|
13
13
|
return value !== undefined && value !== '0' && value.toUpperCase() !== 'FALSE';
|
|
14
14
|
}
|
|
15
|
-
function isTTY() {
|
|
15
|
+
function isTTY(stream = process.stdout) {
|
|
16
16
|
// If we force TTY, we always return true.
|
|
17
17
|
const force = process.env['NG_FORCE_TTY'];
|
|
18
18
|
if (force !== undefined) {
|
|
19
19
|
return _isTruthy(force);
|
|
20
20
|
}
|
|
21
|
-
return !!
|
|
21
|
+
return !!stream.isTTY && !_isTruthy(process.env['CI']);
|
|
22
22
|
}
|
package/src/utilities/version.js
CHANGED
|
@@ -25,5 +25,5 @@ class Version {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
// TODO(bazel): Convert this to use build-time version stamping after flipping the build script to use bazel
|
|
28
|
-
// export const VERSION = new Version('18.1.0-
|
|
28
|
+
// export const VERSION = new Version('18.1.0-rc.0');
|
|
29
29
|
exports.VERSION = new Version(JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../package.json'), 'utf-8')).version);
|
|
@@ -1,20 +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.dev/license
|
|
7
|
-
*/
|
|
8
|
-
export declare class Spinner {
|
|
9
|
-
private readonly spinner;
|
|
10
|
-
/** When false, only fail messages will be displayed. */
|
|
11
|
-
enabled: boolean;
|
|
12
|
-
constructor(text?: string);
|
|
13
|
-
set text(text: string);
|
|
14
|
-
succeed(text?: string): void;
|
|
15
|
-
info(text?: string): void;
|
|
16
|
-
fail(text?: string): void;
|
|
17
|
-
warn(text?: string): void;
|
|
18
|
-
stop(): void;
|
|
19
|
-
start(text?: string): void;
|
|
20
|
-
}
|