@angular/cli 21.1.0-next.1 → 21.1.0-next.2
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/code-examples.db +0 -0
- package/package.json +16 -16
- package/src/commands/add/cli.js +129 -87
- package/src/commands/add/cli.js.map +1 -1
- package/src/commands/mcp/cli.js +4 -1
- package/src/commands/mcp/cli.js.map +1 -1
- package/src/commands/mcp/{dev-server.d.ts → devserver.d.ts} +4 -4
- package/src/commands/mcp/{dev-server.js → devserver.js} +14 -14
- package/src/commands/mcp/devserver.js.map +1 -0
- package/src/commands/mcp/mcp-server.d.ts +30 -0
- package/src/commands/mcp/mcp-server.js +22 -7
- package/src/commands/mcp/mcp-server.js.map +1 -1
- package/src/commands/mcp/tools/best-practices.js.map +1 -1
- package/src/commands/mcp/tools/build.js +2 -2
- package/src/commands/mcp/tools/build.js.map +1 -1
- package/src/commands/mcp/tools/devserver/{start-devserver.d.ts → devserver-start.d.ts} +6 -7
- package/src/commands/mcp/tools/devserver/{start-devserver.js → devserver-start.js} +26 -27
- package/src/commands/mcp/tools/devserver/devserver-start.js.map +1 -0
- package/src/commands/mcp/tools/devserver/{stop-devserver.d.ts → devserver-stop.d.ts} +6 -6
- package/src/commands/mcp/tools/devserver/{stop-devserver.js → devserver-stop.js} +13 -13
- package/src/commands/mcp/tools/devserver/{stop-devserver.js.map → devserver-stop.js.map} +1 -1
- package/src/commands/mcp/tools/devserver/{wait-for-devserver-build.d.ts → devserver-wait-for-build.d.ts} +6 -6
- package/src/commands/mcp/tools/devserver/{wait-for-devserver-build.js → devserver-wait-for-build.js} +16 -16
- package/src/commands/mcp/tools/devserver/{wait-for-devserver-build.js.map → devserver-wait-for-build.js.map} +1 -1
- package/src/commands/mcp/tools/modernize.js +1 -1
- package/src/commands/mcp/tools/modernize.js.map +1 -1
- package/src/commands/mcp/tools/tool-registry.d.ts +2 -2
- package/src/commands/mcp/tools/tool-registry.js.map +1 -1
- package/src/commands/update/cli.d.ts +0 -24
- package/src/commands/update/cli.js +39 -447
- package/src/commands/update/cli.js.map +1 -1
- package/src/commands/update/utilities/cli-version.d.ts +48 -0
- package/src/commands/update/utilities/cli-version.js +196 -0
- package/src/commands/update/utilities/cli-version.js.map +1 -0
- package/src/commands/update/utilities/constants.d.ts +12 -0
- package/src/commands/update/utilities/constants.js +16 -0
- package/src/commands/update/utilities/constants.js.map +1 -0
- package/src/commands/update/utilities/git.d.ts +34 -0
- package/src/commands/update/utilities/git.js +115 -0
- package/src/commands/update/utilities/git.js.map +1 -0
- package/src/commands/update/utilities/migration.d.ts +32 -0
- package/src/commands/update/utilities/migration.js +257 -0
- package/src/commands/update/utilities/migration.js.map +1 -0
- package/src/package-managers/error.d.ts +12 -0
- package/src/package-managers/host.js +7 -3
- package/src/package-managers/host.js.map +1 -1
- package/src/package-managers/package-manager-descriptor.d.ts +28 -4
- package/src/package-managers/package-manager-descriptor.js +24 -4
- package/src/package-managers/package-manager-descriptor.js.map +1 -1
- package/src/package-managers/package-manager.js +61 -7
- package/src/package-managers/package-manager.js.map +1 -1
- package/src/package-managers/parsers.d.ts +69 -4
- package/src/package-managers/parsers.js +231 -32
- package/src/package-managers/parsers.js.map +1 -1
- package/src/utilities/version.js +1 -1
- package/src/commands/mcp/dev-server.js.map +0 -1
- package/src/commands/mcp/tools/devserver/start-devserver.js.map +0 -1
|
@@ -0,0 +1,257 @@
|
|
|
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.dev/license
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.executeSchematic = executeSchematic;
|
|
44
|
+
exports.executeMigration = executeMigration;
|
|
45
|
+
exports.executeMigrations = executeMigrations;
|
|
46
|
+
exports.commitChanges = commitChanges;
|
|
47
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
48
|
+
const semver = __importStar(require("semver"));
|
|
49
|
+
const schematic_workflow_1 = require("../../../command-builder/utilities/schematic-workflow");
|
|
50
|
+
const color_1 = require("../../../utilities/color");
|
|
51
|
+
const error_1 = require("../../../utilities/error");
|
|
52
|
+
const log_file_1 = require("../../../utilities/log-file");
|
|
53
|
+
const prompt_1 = require("../../../utilities/prompt");
|
|
54
|
+
const tty_1 = require("../../../utilities/tty");
|
|
55
|
+
const cli_version_1 = require("./cli-version");
|
|
56
|
+
const git_1 = require("./git");
|
|
57
|
+
async function executeSchematic(workflow, logger, collection, schematic, options = {}) {
|
|
58
|
+
const workflowSubscription = (0, schematic_workflow_1.subscribeToWorkflow)(workflow, logger);
|
|
59
|
+
// TODO: Allow passing a schematic instance directly
|
|
60
|
+
try {
|
|
61
|
+
await workflow
|
|
62
|
+
.execute({
|
|
63
|
+
collection,
|
|
64
|
+
schematic,
|
|
65
|
+
options,
|
|
66
|
+
logger,
|
|
67
|
+
})
|
|
68
|
+
.toPromise();
|
|
69
|
+
return { success: !workflowSubscription.error, files: workflowSubscription.files };
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
if (e instanceof schematics_1.UnsuccessfulWorkflowExecution) {
|
|
73
|
+
logger.error(`${color_1.figures.cross} Migration failed. See above for further details.\n`);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
(0, error_1.assertIsError)(e);
|
|
77
|
+
const logPath = (0, log_file_1.writeErrorToLogFile)(e);
|
|
78
|
+
logger.fatal(`${color_1.figures.cross} Migration failed: ${e.message}\n` +
|
|
79
|
+
` See "${logPath}" for further details.\n`);
|
|
80
|
+
}
|
|
81
|
+
return { success: false, files: workflowSubscription.files };
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
workflowSubscription.unsubscribe();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @return Whether or not the migration was performed successfully.
|
|
89
|
+
*/
|
|
90
|
+
async function executeMigration(workflow, logger, packageName, collectionPath, migrationName, commit = false) {
|
|
91
|
+
const collection = workflow.engine.createCollection(collectionPath);
|
|
92
|
+
const name = collection.listSchematicNames().find((name) => name === migrationName);
|
|
93
|
+
if (!name) {
|
|
94
|
+
logger.error(`Cannot find migration '${migrationName}' in '${packageName}'.`);
|
|
95
|
+
return 1;
|
|
96
|
+
}
|
|
97
|
+
logger.info(color_1.colors.cyan(`** Executing '${migrationName}' of package '${packageName}' **\n`));
|
|
98
|
+
const schematic = workflow.engine.createSchematic(name, collection);
|
|
99
|
+
return executePackageMigrations(workflow, logger, [schematic.description], packageName, commit);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @return Whether or not the migrations were performed successfully.
|
|
103
|
+
*/
|
|
104
|
+
async function executeMigrations(workflow, logger, packageName, collectionPath, from, to, commit = false) {
|
|
105
|
+
const collection = workflow.engine.createCollection(collectionPath);
|
|
106
|
+
const migrationRange = new semver.Range('>' + (semver.prerelease(from) ? from.split('-')[0] + '-0' : from) + ' <=' + to.split('-')[0]);
|
|
107
|
+
const requiredMigrations = [];
|
|
108
|
+
const optionalMigrations = [];
|
|
109
|
+
for (const name of collection.listSchematicNames()) {
|
|
110
|
+
const schematic = workflow.engine.createSchematic(name, collection);
|
|
111
|
+
const description = schematic.description;
|
|
112
|
+
description.version = (0, cli_version_1.coerceVersionNumber)(description.version);
|
|
113
|
+
if (!description.version) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (semver.satisfies(description.version, migrationRange, { includePrerelease: true })) {
|
|
117
|
+
(description.optional ? optionalMigrations : requiredMigrations).push(description);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (requiredMigrations.length === 0 && optionalMigrations.length === 0) {
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
// Required migrations
|
|
124
|
+
if (requiredMigrations.length) {
|
|
125
|
+
logger.info(color_1.colors.cyan(`** Executing migrations of package '${packageName}' **\n`));
|
|
126
|
+
requiredMigrations.sort((a, b) => semver.compare(a.version, b.version) || a.name.localeCompare(b.name));
|
|
127
|
+
const result = await executePackageMigrations(workflow, logger, requiredMigrations, packageName, commit);
|
|
128
|
+
if (result === 1) {
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Optional migrations
|
|
133
|
+
if (optionalMigrations.length) {
|
|
134
|
+
logger.info(color_1.colors.magenta(`** Optional migrations of package '${packageName}' **\n`));
|
|
135
|
+
optionalMigrations.sort((a, b) => semver.compare(a.version, b.version) || a.name.localeCompare(b.name));
|
|
136
|
+
const migrationsToRun = await getOptionalMigrationsToRun(logger, optionalMigrations, packageName);
|
|
137
|
+
if (migrationsToRun?.length) {
|
|
138
|
+
return executePackageMigrations(workflow, logger, migrationsToRun, packageName, commit);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
async function executePackageMigrations(workflow, logger, migrations, packageName, commit = false) {
|
|
144
|
+
for (const migration of migrations) {
|
|
145
|
+
const { title, description } = getMigrationTitleAndDescription(migration);
|
|
146
|
+
logger.info(color_1.colors.cyan(color_1.figures.pointer) + ' ' + color_1.colors.bold(title));
|
|
147
|
+
if (description) {
|
|
148
|
+
logger.info(' ' + description);
|
|
149
|
+
}
|
|
150
|
+
const { success, files } = await executeSchematic(workflow, logger, migration.collection.name, migration.name);
|
|
151
|
+
if (!success) {
|
|
152
|
+
return 1;
|
|
153
|
+
}
|
|
154
|
+
let modifiedFilesText;
|
|
155
|
+
switch (files.size) {
|
|
156
|
+
case 0:
|
|
157
|
+
modifiedFilesText = 'No changes made';
|
|
158
|
+
break;
|
|
159
|
+
case 1:
|
|
160
|
+
modifiedFilesText = '1 file modified';
|
|
161
|
+
break;
|
|
162
|
+
default:
|
|
163
|
+
modifiedFilesText = `${files.size} files modified`;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
logger.info(` Migration completed (${modifiedFilesText}).`);
|
|
167
|
+
// Commit migration
|
|
168
|
+
if (commit) {
|
|
169
|
+
const commitPrefix = `${packageName} migration - ${migration.name}`;
|
|
170
|
+
const commitMessage = migration.description
|
|
171
|
+
? `${commitPrefix}\n\n${migration.description}`
|
|
172
|
+
: commitPrefix;
|
|
173
|
+
const committed = commitChanges(logger, commitMessage);
|
|
174
|
+
if (!committed) {
|
|
175
|
+
// Failed to commit, something went wrong. Abort the update.
|
|
176
|
+
return 1;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
logger.info(''); // Extra trailing newline.
|
|
180
|
+
}
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* @return Whether or not the commit was successful.
|
|
185
|
+
*/
|
|
186
|
+
function commitChanges(logger, message) {
|
|
187
|
+
// Check if a commit is needed.
|
|
188
|
+
let commitNeeded;
|
|
189
|
+
try {
|
|
190
|
+
commitNeeded = (0, git_1.hasChangesToCommit)();
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
logger.error(` Failed to read Git tree:\n${err.stderr}`);
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
if (!commitNeeded) {
|
|
197
|
+
logger.info(' No changes to commit after migration.');
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
// Commit changes and abort on error.
|
|
201
|
+
try {
|
|
202
|
+
(0, git_1.createCommit)(message);
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
logger.error(`Failed to commit update (${message}):\n${err.stderr}`);
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
// Notify user of the commit.
|
|
209
|
+
const hash = (0, git_1.findCurrentGitSha)();
|
|
210
|
+
const shortMessage = message.split('\n')[0];
|
|
211
|
+
if (hash) {
|
|
212
|
+
logger.info(` Committed migration step (${(0, git_1.getShortHash)(hash)}): ${shortMessage}.`);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
// Commit was successful, but reading the hash was not. Something weird happened,
|
|
216
|
+
// but nothing that would stop the update. Just log the weirdness and continue.
|
|
217
|
+
logger.info(` Committed migration step: ${shortMessage}.`);
|
|
218
|
+
logger.warn(' Failed to look up hash of most recent commit, continuing anyways.');
|
|
219
|
+
}
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
async function getOptionalMigrationsToRun(logger, optionalMigrations, packageName) {
|
|
223
|
+
const numberOfMigrations = optionalMigrations.length;
|
|
224
|
+
logger.info(`This package has ${numberOfMigrations} optional migration${numberOfMigrations > 1 ? 's' : ''} that can be executed.`);
|
|
225
|
+
if (!(0, tty_1.isTTY)()) {
|
|
226
|
+
for (const migration of optionalMigrations) {
|
|
227
|
+
const { title } = getMigrationTitleAndDescription(migration);
|
|
228
|
+
logger.info(color_1.colors.cyan(color_1.figures.pointer) + ' ' + color_1.colors.bold(title));
|
|
229
|
+
logger.info(color_1.colors.gray(` ng update ${packageName} --name ${migration.name}`));
|
|
230
|
+
logger.info(''); // Extra trailing newline.
|
|
231
|
+
}
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
logger.info('Optional migrations may be skipped and executed after the update process, if preferred.');
|
|
235
|
+
logger.info(''); // Extra trailing newline.
|
|
236
|
+
const answer = await (0, prompt_1.askChoices)(`Select the migrations that you'd like to run`, optionalMigrations.map((migration) => {
|
|
237
|
+
const { title, documentation } = getMigrationTitleAndDescription(migration);
|
|
238
|
+
return {
|
|
239
|
+
name: `[${color_1.colors.white(migration.name)}] ${title}${documentation ? ` (${documentation})` : ''}`,
|
|
240
|
+
value: migration.name,
|
|
241
|
+
checked: migration.recommended,
|
|
242
|
+
};
|
|
243
|
+
}), null);
|
|
244
|
+
logger.info(''); // Extra trailing newline.
|
|
245
|
+
return optionalMigrations.filter(({ name }) => answer?.includes(name));
|
|
246
|
+
}
|
|
247
|
+
function getMigrationTitleAndDescription(migration) {
|
|
248
|
+
const [title, ...description] = migration.description.split('. ');
|
|
249
|
+
return {
|
|
250
|
+
title: title.endsWith('.') ? title : title + '.',
|
|
251
|
+
description: description.join('.\n '),
|
|
252
|
+
documentation: migration.documentation
|
|
253
|
+
? new URL(migration.documentation, 'https://angular.dev').href
|
|
254
|
+
: undefined,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.js","sourceRoot":"","sources":["migration.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCH,4CAqCC;AAKD,4CA0BC;AAKD,8CA8EC;AAiED,sCAyCC;AAhSD,2DAAiG;AAOjG,+CAAiC;AACjC,8FAA4F;AAC5F,oDAA2D;AAC3D,oDAAyD;AACzD,0DAAkE;AAClE,sDAAuD;AACvD,gDAA+C;AAC/C,+CAAoD;AACpD,+BAA0F;AAgBnF,KAAK,UAAU,gBAAgB,CACpC,QAAsB,EACtB,MAAsB,EACtB,UAAkB,EAClB,SAAiB,EACjB,UAAmC,EAAE;IAErC,MAAM,oBAAoB,GAAG,IAAA,wCAAmB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEnE,oDAAoD;IACpD,IAAI,CAAC;QACH,MAAM,QAAQ;aACX,OAAO,CAAC;YACP,UAAU;YACV,SAAS;YACT,OAAO;YACP,MAAM;SACP,CAAC;aACD,SAAS,EAAE,CAAC;QAEf,OAAO,EAAE,OAAO,EAAE,CAAC,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,CAAC;IACrF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,0CAA6B,EAAE,CAAC;YAC/C,MAAM,CAAC,KAAK,CAAC,GAAG,eAAO,CAAC,KAAK,qDAAqD,CAAC,CAAC;QACtF,CAAC;aAAM,CAAC;YACN,IAAA,qBAAa,EAAC,CAAC,CAAC,CAAC;YACjB,MAAM,OAAO,GAAG,IAAA,8BAAmB,EAAC,CAAC,CAAC,CAAC;YACvC,MAAM,CAAC,KAAK,CACV,GAAG,eAAO,CAAC,KAAK,sBAAsB,CAAC,CAAC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AAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QACnC,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,+BAA+B,CAAC,SAAS,CAAC,CAAC;QAE5E,OAAO;YACL,IAAI,EAAE,IAAI,cAAM,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YAC/F,KAAK,EAAE,SAAS,CAAC,IAAI;YACrB,OAAO,EAAE,SAAS,CAAC,WAAW;SAC/B,CAAC;IACJ,CAAC,CAAC,EACF,IAAI,CACL,CAAC;IAEF,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,0BAA0B;IAE3C,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,+BAA+B,CAAC,SAAwC;IAK/E,MAAM,CAAC,KAAK,EAAE,GAAG,WAAW,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAElE,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG;QAChD,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC;QACtC,aAAa,EAAE,SAAS,CAAC,aAAa;YACpC,CAAC,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC,IAAI;YAC9D,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -29,3 +29,15 @@ export declare class PackageManagerError extends Error {
|
|
|
29
29
|
*/
|
|
30
30
|
constructor(message: string, stdout: string, stderr: string, exitCode: number | null);
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Represents structured information about an error returned by a package manager command.
|
|
34
|
+
* This is a data interface, not an `Error` subclass.
|
|
35
|
+
*/
|
|
36
|
+
export interface ErrorInfo {
|
|
37
|
+
/** A specific error code (e.g. 'E404', 'EACCES'). */
|
|
38
|
+
readonly code: string;
|
|
39
|
+
/** A short, human-readable summary of the error. */
|
|
40
|
+
readonly summary: string;
|
|
41
|
+
/** An optional, detailed description of the error. */
|
|
42
|
+
readonly detail?: string;
|
|
43
|
+
}
|
|
@@ -31,9 +31,10 @@ exports.NodeJS_HOST = {
|
|
|
31
31
|
deleteDirectory: (path) => (0, promises_1.rm)(path, { recursive: true, force: true }),
|
|
32
32
|
runCommand: async (command, args, options = {}) => {
|
|
33
33
|
const signal = options.timeout ? AbortSignal.timeout(options.timeout) : undefined;
|
|
34
|
+
const isWin32 = (0, node_os_1.platform)() === 'win32';
|
|
34
35
|
return new Promise((resolve, reject) => {
|
|
35
|
-
const
|
|
36
|
-
shell:
|
|
36
|
+
const spawnOptions = {
|
|
37
|
+
shell: isWin32,
|
|
37
38
|
stdio: options.stdio ?? 'pipe',
|
|
38
39
|
signal,
|
|
39
40
|
cwd: options.cwd,
|
|
@@ -41,7 +42,10 @@ exports.NodeJS_HOST = {
|
|
|
41
42
|
...process.env,
|
|
42
43
|
...options.env,
|
|
43
44
|
},
|
|
44
|
-
}
|
|
45
|
+
};
|
|
46
|
+
const childProcess = isWin32
|
|
47
|
+
? (0, node_child_process_1.spawn)(`${command} ${args.join(' ')}`, spawnOptions)
|
|
48
|
+
: (0, node_child_process_1.spawn)(command, args, spawnOptions);
|
|
45
49
|
let stdout = '';
|
|
46
50
|
childProcess.stdout?.on('data', (data) => (stdout += data.toString()));
|
|
47
51
|
let stderr = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;;GAK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,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;oBAE/D,OAAO;gBACT,CAAC;gBACD,MAAM,OAAO,GAAG,8BAA8B,GAAG,CAAC,OAAO,EAAE,CAAC;gBAC5D,MAAM,CAAC,IAAI,2BAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
* supported package managers. It is the single source of truth for all
|
|
11
11
|
* package-manager-specific commands, flags, and output parsing.
|
|
12
12
|
*/
|
|
13
|
+
import { ErrorInfo } from './error';
|
|
13
14
|
import { Logger } from './logger';
|
|
14
15
|
import { PackageManifest, PackageMetadata } from './package-metadata';
|
|
15
16
|
import { InstalledPackage } from './package-tree';
|
|
16
|
-
import { parseNpmLikeDependencies, parseNpmLikeManifest, parseNpmLikeMetadata, parseYarnClassicDependencies,
|
|
17
|
+
import { parseNpmLikeDependencies, parseNpmLikeError, parseNpmLikeManifest, parseNpmLikeMetadata, parseYarnClassicDependencies, parseYarnClassicError, parseYarnClassicManifest, parseYarnClassicMetadata, parseYarnModernDependencies } from './parsers';
|
|
17
18
|
/**
|
|
18
19
|
* An interface that describes the commands and properties of a package manager.
|
|
19
20
|
*/
|
|
@@ -49,6 +50,8 @@ export interface PackageManagerDescriptor {
|
|
|
49
50
|
readonly listDependenciesCommand: readonly string[];
|
|
50
51
|
/** The command to fetch the registry manifest of a package. */
|
|
51
52
|
readonly getManifestCommand: readonly string[];
|
|
53
|
+
/** Whether a specific version lookup is needed prior to fetching a registry manifest. */
|
|
54
|
+
readonly requiresManifestVersionLookup?: boolean;
|
|
52
55
|
/** A function that formats the arguments for field-filtered registry views. */
|
|
53
56
|
readonly viewCommandFieldArgFormatter?: (fields: readonly string[]) => string[];
|
|
54
57
|
/** A collection of functions to parse the output of specific commands. */
|
|
@@ -59,10 +62,20 @@ export interface PackageManagerDescriptor {
|
|
|
59
62
|
getRegistryManifest: (stdout: string, logger?: Logger) => PackageManifest | null;
|
|
60
63
|
/** A function to parse the output of `getManifestCommand` for the full package metadata. */
|
|
61
64
|
getRegistryMetadata: (stdout: string, logger?: Logger) => PackageMetadata | null;
|
|
65
|
+
/** A function to parse the output when a command fails. */
|
|
66
|
+
getError?: (output: string, logger?: Logger) => ErrorInfo | null;
|
|
62
67
|
};
|
|
68
|
+
/** A function that checks if a structured error represents a "package not found" error. */
|
|
69
|
+
readonly isNotFound: (error: ErrorInfo) => boolean;
|
|
63
70
|
}
|
|
64
71
|
/** A type that represents the name of a supported package manager. */
|
|
65
72
|
export type PackageManagerName = keyof typeof SUPPORTED_PACKAGE_MANAGERS;
|
|
73
|
+
/**
|
|
74
|
+
* A shared function to check if a structured error represents a "package not found" error.
|
|
75
|
+
* @param error The structured error to check.
|
|
76
|
+
* @returns True if the error code is a known "not found" code, false otherwise.
|
|
77
|
+
*/
|
|
78
|
+
declare function isKnownNotFound(error: ErrorInfo): boolean;
|
|
66
79
|
/**
|
|
67
80
|
* A map of supported package managers to their descriptors.
|
|
68
81
|
* This is the single source of truth for all package-manager-specific
|
|
@@ -97,7 +110,9 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
|
|
|
97
110
|
listDependencies: typeof parseNpmLikeDependencies;
|
|
98
111
|
getRegistryManifest: typeof parseNpmLikeManifest;
|
|
99
112
|
getRegistryMetadata: typeof parseNpmLikeMetadata;
|
|
113
|
+
getError: typeof parseNpmLikeError;
|
|
100
114
|
};
|
|
115
|
+
isNotFound: typeof isKnownNotFound;
|
|
101
116
|
};
|
|
102
117
|
yarn: {
|
|
103
118
|
binary: string;
|
|
@@ -123,7 +138,9 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
|
|
|
123
138
|
listDependencies: typeof parseYarnModernDependencies;
|
|
124
139
|
getRegistryManifest: typeof parseNpmLikeManifest;
|
|
125
140
|
getRegistryMetadata: typeof parseNpmLikeMetadata;
|
|
141
|
+
getError: typeof parseNpmLikeError;
|
|
126
142
|
};
|
|
143
|
+
isNotFound: typeof isKnownNotFound;
|
|
127
144
|
};
|
|
128
145
|
'yarn-classic': {
|
|
129
146
|
binary: string;
|
|
@@ -142,11 +159,14 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
|
|
|
142
159
|
versionCommand: string[];
|
|
143
160
|
listDependenciesCommand: string[];
|
|
144
161
|
getManifestCommand: string[];
|
|
162
|
+
requiresManifestVersionLookup: true;
|
|
145
163
|
outputParsers: {
|
|
146
164
|
listDependencies: typeof parseYarnClassicDependencies;
|
|
147
|
-
getRegistryManifest: typeof
|
|
148
|
-
getRegistryMetadata: typeof
|
|
165
|
+
getRegistryManifest: typeof parseYarnClassicManifest;
|
|
166
|
+
getRegistryMetadata: typeof parseYarnClassicMetadata;
|
|
167
|
+
getError: typeof parseYarnClassicError;
|
|
149
168
|
};
|
|
169
|
+
isNotFound: typeof isKnownNotFound;
|
|
150
170
|
};
|
|
151
171
|
pnpm: {
|
|
152
172
|
binary: string;
|
|
@@ -170,7 +190,9 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
|
|
|
170
190
|
listDependencies: typeof parseNpmLikeDependencies;
|
|
171
191
|
getRegistryManifest: typeof parseNpmLikeManifest;
|
|
172
192
|
getRegistryMetadata: typeof parseNpmLikeMetadata;
|
|
193
|
+
getError: typeof parseNpmLikeError;
|
|
173
194
|
};
|
|
195
|
+
isNotFound: typeof isKnownNotFound;
|
|
174
196
|
};
|
|
175
197
|
bun: {
|
|
176
198
|
binary: string;
|
|
@@ -189,12 +211,13 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
|
|
|
189
211
|
versionCommand: string[];
|
|
190
212
|
listDependenciesCommand: string[];
|
|
191
213
|
getManifestCommand: string[];
|
|
192
|
-
viewCommandFieldArgFormatter: (fields: readonly string[]) => string[];
|
|
193
214
|
outputParsers: {
|
|
194
215
|
listDependencies: typeof parseNpmLikeDependencies;
|
|
195
216
|
getRegistryManifest: typeof parseNpmLikeManifest;
|
|
196
217
|
getRegistryMetadata: typeof parseNpmLikeMetadata;
|
|
218
|
+
getError: typeof parseNpmLikeError;
|
|
197
219
|
};
|
|
220
|
+
isNotFound: typeof isKnownNotFound;
|
|
198
221
|
};
|
|
199
222
|
};
|
|
200
223
|
/**
|
|
@@ -202,3 +225,4 @@ export declare const SUPPORTED_PACKAGE_MANAGERS: {
|
|
|
202
225
|
* This is a best-effort ordering based on estimated Angular community usage and default presence.
|
|
203
226
|
*/
|
|
204
227
|
export declare const PACKAGE_MANAGER_PRECEDENCE: readonly PackageManagerName[];
|
|
228
|
+
export {};
|
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.PACKAGE_MANAGER_PRECEDENCE = exports.SUPPORTED_PACKAGE_MANAGERS = void 0;
|
|
11
11
|
const parsers_1 = require("./parsers");
|
|
12
|
+
/** A set of error codes that are known to indicate a "package not found" error. */
|
|
13
|
+
const NOT_FOUND_ERROR_CODES = new Set(['E404']);
|
|
14
|
+
/**
|
|
15
|
+
* A shared function to check if a structured error represents a "package not found" error.
|
|
16
|
+
* @param error The structured error to check.
|
|
17
|
+
* @returns True if the error code is a known "not found" code, false otherwise.
|
|
18
|
+
*/
|
|
19
|
+
function isKnownNotFound(error) {
|
|
20
|
+
return NOT_FOUND_ERROR_CODES.has(error.code);
|
|
21
|
+
}
|
|
12
22
|
/**
|
|
13
23
|
* A map of supported package managers to their descriptors.
|
|
14
24
|
* This is the single source of truth for all package-manager-specific
|
|
@@ -41,7 +51,9 @@ exports.SUPPORTED_PACKAGE_MANAGERS = {
|
|
|
41
51
|
listDependencies: parsers_1.parseNpmLikeDependencies,
|
|
42
52
|
getRegistryManifest: parsers_1.parseNpmLikeManifest,
|
|
43
53
|
getRegistryMetadata: parsers_1.parseNpmLikeMetadata,
|
|
54
|
+
getError: parsers_1.parseNpmLikeError,
|
|
44
55
|
},
|
|
56
|
+
isNotFound: isKnownNotFound,
|
|
45
57
|
},
|
|
46
58
|
yarn: {
|
|
47
59
|
binary: 'yarn',
|
|
@@ -63,7 +75,9 @@ exports.SUPPORTED_PACKAGE_MANAGERS = {
|
|
|
63
75
|
listDependencies: parsers_1.parseYarnModernDependencies,
|
|
64
76
|
getRegistryManifest: parsers_1.parseNpmLikeManifest,
|
|
65
77
|
getRegistryMetadata: parsers_1.parseNpmLikeMetadata,
|
|
78
|
+
getError: parsers_1.parseNpmLikeError,
|
|
66
79
|
},
|
|
80
|
+
isNotFound: isKnownNotFound,
|
|
67
81
|
},
|
|
68
82
|
'yarn-classic': {
|
|
69
83
|
binary: 'yarn',
|
|
@@ -82,12 +96,15 @@ exports.SUPPORTED_PACKAGE_MANAGERS = {
|
|
|
82
96
|
getRegistryOptions: (registry) => ({ args: ['--registry', registry] }),
|
|
83
97
|
versionCommand: ['--version'],
|
|
84
98
|
listDependenciesCommand: ['list', '--depth=0', '--json'],
|
|
85
|
-
getManifestCommand: ['info', '--json'],
|
|
99
|
+
getManifestCommand: ['info', '--json', '--verbose'],
|
|
100
|
+
requiresManifestVersionLookup: true,
|
|
86
101
|
outputParsers: {
|
|
87
102
|
listDependencies: parsers_1.parseYarnClassicDependencies,
|
|
88
|
-
getRegistryManifest: parsers_1.
|
|
89
|
-
getRegistryMetadata: parsers_1.
|
|
103
|
+
getRegistryManifest: parsers_1.parseYarnClassicManifest,
|
|
104
|
+
getRegistryMetadata: parsers_1.parseYarnClassicMetadata,
|
|
105
|
+
getError: parsers_1.parseYarnClassicError,
|
|
90
106
|
},
|
|
107
|
+
isNotFound: isKnownNotFound,
|
|
91
108
|
},
|
|
92
109
|
pnpm: {
|
|
93
110
|
binary: 'pnpm',
|
|
@@ -109,7 +126,9 @@ exports.SUPPORTED_PACKAGE_MANAGERS = {
|
|
|
109
126
|
listDependencies: parsers_1.parseNpmLikeDependencies,
|
|
110
127
|
getRegistryManifest: parsers_1.parseNpmLikeManifest,
|
|
111
128
|
getRegistryMetadata: parsers_1.parseNpmLikeMetadata,
|
|
129
|
+
getError: parsers_1.parseNpmLikeError,
|
|
112
130
|
},
|
|
131
|
+
isNotFound: isKnownNotFound,
|
|
113
132
|
},
|
|
114
133
|
bun: {
|
|
115
134
|
binary: 'bun',
|
|
@@ -126,12 +145,13 @@ exports.SUPPORTED_PACKAGE_MANAGERS = {
|
|
|
126
145
|
versionCommand: ['--version'],
|
|
127
146
|
listDependenciesCommand: ['pm', 'ls', '--json'],
|
|
128
147
|
getManifestCommand: ['pm', 'view', '--json'],
|
|
129
|
-
viewCommandFieldArgFormatter: (fields) => [...fields],
|
|
130
148
|
outputParsers: {
|
|
131
149
|
listDependencies: parsers_1.parseNpmLikeDependencies,
|
|
132
150
|
getRegistryManifest: parsers_1.parseNpmLikeManifest,
|
|
133
151
|
getRegistryMetadata: parsers_1.parseNpmLikeMetadata,
|
|
152
|
+
getError: parsers_1.parseNpmLikeError,
|
|
134
153
|
},
|
|
154
|
+
isNotFound: isKnownNotFound,
|
|
135
155
|
},
|
|
136
156
|
};
|
|
137
157
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager-descriptor.js","sourceRoot":"","sources":["package-manager-descriptor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;
|
|
1
|
+
{"version":3,"file":"package-manager-descriptor.js","sourceRoot":"","sources":["package-manager-descriptor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAYH,uCAUmB;AA+EnB,mFAAmF;AACnF,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEhD;;;;GAIG;AACH,SAAS,eAAe,CAAC,KAAgB;IACvC,OAAO,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;GAUG;AACU,QAAA,0BAA0B,GAAG;IACxC,GAAG,EAAE;QACH,MAAM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CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC9E,cAAc,EAAE,CAAC,WAAW,CAAC;QAC7B,uBAAuB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC;QAC/C,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC;QAC5C,aAAa,EAAE;YACb,gBAAgB,EAAE,kCAAwB;YAC1C,mBAAmB,EAAE,8BAAoB;YACzC,mBAAmB,EAAE,8BAAoB;YACzC,QAAQ,EAAE,2BAAiB;SAC5B;QACD,UAAU,EAAE,eAAe;KAC5B;CACiD,CAAC;AAErD;;;GAGG;AACU,QAAA,0BAA0B,GAAkC;IACvE,MAAM;IACN,MAAM;IACN,KAAK;IACL,KAAK;CACN,CAAC"}
|
|
@@ -18,6 +18,7 @@ exports.PackageManager = void 0;
|
|
|
18
18
|
*/
|
|
19
19
|
const node_path_1 = require("node:path");
|
|
20
20
|
const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
|
|
21
|
+
const semver_1 = require("semver");
|
|
21
22
|
const error_1 = require("./error");
|
|
22
23
|
/**
|
|
23
24
|
* The fields to request from the registry for package metadata.
|
|
@@ -120,12 +121,13 @@ class PackageManager {
|
|
|
120
121
|
this.options.logger?.info(`[DRY RUN] Would execute in [${executionDirectory}]: ${this.descriptor.binary} ${finalArgs.join(' ')}`);
|
|
121
122
|
return { stdout: '', stderr: '' };
|
|
122
123
|
}
|
|
123
|
-
|
|
124
|
+
const commandResult = await this.host.runCommand(this.descriptor.binary, finalArgs, {
|
|
124
125
|
...runOptions,
|
|
125
126
|
cwd: executionDirectory,
|
|
126
127
|
stdio: 'pipe',
|
|
127
128
|
env: finalEnv,
|
|
128
129
|
});
|
|
130
|
+
return { stdout: commandResult.stdout.trim(), stderr: commandResult.stderr.trim() };
|
|
129
131
|
}
|
|
130
132
|
/**
|
|
131
133
|
* A private, generic method to encapsulate the common logic of running a command,
|
|
@@ -142,19 +144,50 @@ class PackageManager {
|
|
|
142
144
|
}
|
|
143
145
|
let stdout;
|
|
144
146
|
let stderr;
|
|
147
|
+
let exitCode;
|
|
148
|
+
let thrownError;
|
|
145
149
|
try {
|
|
146
150
|
({ stdout, stderr } = await this.#run(args, runOptions));
|
|
151
|
+
exitCode = 0;
|
|
147
152
|
}
|
|
148
153
|
catch (e) {
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
thrownError = e;
|
|
155
|
+
if (e instanceof error_1.PackageManagerError) {
|
|
156
|
+
stdout = e.stdout;
|
|
157
|
+
stderr = e.stderr;
|
|
158
|
+
exitCode = e.exitCode;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
// Re-throw unexpected errors
|
|
162
|
+
throw e;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Yarn classic can exit with code 0 even when an error occurs.
|
|
166
|
+
// To ensure we capture these cases, we will always attempt to parse a
|
|
167
|
+
// structured error from the output, regardless of the exit code.
|
|
168
|
+
const getError = this.descriptor.outputParsers.getError;
|
|
169
|
+
const parsedError = getError?.(stdout, this.options.logger) ?? getError?.(stderr, this.options.logger) ?? null;
|
|
170
|
+
if (parsedError) {
|
|
171
|
+
this.options.logger?.debug(`[${this.descriptor.binary}] Structured error (code: ${parsedError.code}): ${parsedError.summary}`);
|
|
172
|
+
// Special case for 'not found' errors (e.g., E404). Return null for these.
|
|
173
|
+
if (this.descriptor.isNotFound(parsedError)) {
|
|
151
174
|
if (cache && cacheKey) {
|
|
152
175
|
cache.set(cacheKey, null);
|
|
153
176
|
}
|
|
154
177
|
return null;
|
|
155
178
|
}
|
|
156
|
-
|
|
179
|
+
else {
|
|
180
|
+
// For all other structured errors, throw a more informative error.
|
|
181
|
+
throw new error_1.PackageManagerError(parsedError.summary, stdout, stderr, exitCode);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// If an error was originally thrown and we didn't parse a more specific
|
|
185
|
+
// structured error, re-throw the original error now.
|
|
186
|
+
if (thrownError) {
|
|
187
|
+
throw thrownError;
|
|
157
188
|
}
|
|
189
|
+
// If we reach this point, the command succeeded and no structured error was found.
|
|
190
|
+
// We can now safely parse the successful output.
|
|
158
191
|
try {
|
|
159
192
|
const result = parser(stdout, this.options.logger);
|
|
160
193
|
if (cache && cacheKey) {
|
|
@@ -164,7 +197,7 @@ class PackageManager {
|
|
|
164
197
|
}
|
|
165
198
|
catch (e) {
|
|
166
199
|
const message = `Failed to parse package manager output: ${e instanceof Error ? e.message : ''}`;
|
|
167
|
-
throw new error_1.PackageManagerError(message, stdout, stderr,
|
|
200
|
+
throw new error_1.PackageManagerError(message, stdout, stderr, exitCode);
|
|
168
201
|
}
|
|
169
202
|
}
|
|
170
203
|
/**
|
|
@@ -291,12 +324,33 @@ class PackageManager {
|
|
|
291
324
|
switch (type) {
|
|
292
325
|
case 'range':
|
|
293
326
|
case 'version':
|
|
294
|
-
case 'tag':
|
|
327
|
+
case 'tag': {
|
|
295
328
|
if (!name) {
|
|
296
329
|
throw new Error(`Could not parse package name from specifier: ${specifier}`);
|
|
297
330
|
}
|
|
298
331
|
// `fetchSpec` is the version, range, or tag.
|
|
299
|
-
|
|
332
|
+
let versionSpec = fetchSpec ?? 'latest';
|
|
333
|
+
if (this.descriptor.requiresManifestVersionLookup) {
|
|
334
|
+
if (type === 'tag' || !fetchSpec) {
|
|
335
|
+
const metadata = await this.getRegistryMetadata(name, options);
|
|
336
|
+
if (!metadata) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
versionSpec = metadata['dist-tags'][versionSpec];
|
|
340
|
+
}
|
|
341
|
+
else if (type === 'range') {
|
|
342
|
+
const metadata = await this.getRegistryMetadata(name, options);
|
|
343
|
+
if (!metadata) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
versionSpec = (0, semver_1.maxSatisfying)(metadata.versions, fetchSpec) ?? '';
|
|
347
|
+
}
|
|
348
|
+
if (!versionSpec) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return this.getRegistryManifest(name, versionSpec, options);
|
|
353
|
+
}
|
|
300
354
|
case 'directory': {
|
|
301
355
|
if (!fetchSpec) {
|
|
302
356
|
throw new Error(`Could not parse directory path from specifier: ${specifier}`);
|