Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/base/src/tool-versions-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export const ToolVersion = z.object({
version: z.string().min(1),
prerelease: z.literal(true).exactOptional(),
lts: z.literal(true).exactOptional(),
/** the registry deprecates the version, only for npm tools */
/**
* the registry deprecates the version: npm deprecated it, all its PyPI files
* are yanked, or the gem is gone from rubygems
*/
deprecated: z.literal(true).exactOptional(),
/** when the version was released, in UTC */
releaseTimestamp: z.iso.datetime().exactOptional(),
Expand Down
3 changes: 2 additions & 1 deletion packages/base/src/tool-versions-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export interface ToolVersion {
prerelease?: true;
lts?: true;
/**
* The registry deprecates the version, only for npm tools.
* The registry deprecates the version: npm deprecated it, all its PyPI files
* are yanked, or the gem is gone from rubygems.
*/
deprecated?: true;
/**
Expand Down
7 changes: 7 additions & 0 deletions src/cli/command/install-npm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ describe('cli/command/install-npm', () => {

vi.stubEnv('DEL_CLI_VERSION', '5.0.0');
expect(await cli.run(['del-cli'])).toBe(0);
// install-npm never reads the tool-versions data
expect(mocks.resolveVersion).toHaveBeenLastCalledWith(
'del-cli',
'5.0.0',
'npm',
false,
);
expect(mocks.installTool).toHaveBeenCalledTimes(2);
expect(mocks.installTool).toHaveBeenCalledWith(
'del-cli',
Expand Down
7 changes: 7 additions & 0 deletions src/cli/command/install-tool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ describe('cli/command/install-tool', () => {
);
vi.stubEnv('NODE_VERSION', '16.13.0');
expect(await cli.run(['node'])).toBe(0);
// install-tool may read the tool-versions data
expect(mocks.resolveVersion).toHaveBeenLastCalledWith(
'node',
'16.13.0',
undefined,
true,
);
expect(mocks.installTool).toHaveBeenCalledTimes(1);
expect(mocks.installTool).toHaveBeenCalledWith(
'node',
Expand Down
10 changes: 9 additions & 1 deletion src/cli/command/install-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ export class InstallToolCommand extends Command {
logger.debug(
`Try resolving version for ${this.name}@${version ?? 'latest'} ...`,
);
version = await resolveVersion(this.name, version, type);
// only `install-tool` reads the tool-versions data, `install-gem`,
// `install-npm` and `install-pip` set `this.type` and always ask their
// registry
version = await resolveVersion(
this.name,
version,
type,
this.type === undefined,
);

if (!isNonEmptyStringAndNotWhitespace(version)) {
error = true;
Expand Down
Loading