Skip to content

fix(turbo-ignore): no longer attempt to use catalog protocol #10458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
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
14 changes: 14 additions & 0 deletions packages/turbo-ignore/__fixtures__/turbo_catalog/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "test-app",
"private": true,
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "vercel",
"dependencies": {
"turbo": "catalog:"
}
}
5 changes: 5 additions & 0 deletions packages/turbo-ignore/__fixtures__/turbo_catalog/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tasks": {
"build": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "test-app",
"private": true,
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "vercel",
"dependencies": {
"turbo": "^99"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tasks": {
"build": {}
}
}
16 changes: 16 additions & 0 deletions packages/turbo-ignore/__tests__/getTurboVersion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,20 @@ describe("getWorkspace()", () => {
null
);
});

describe("pnpm catalog", () => {
const fixture = "./__fixtures__/turbo_catalog";

it("warns on catalog usage", () => {
getTurboVersion({}, fixture);
expect(mockConsole.warn).toHaveBeenCalledWith(
"≫ ",
"Cannot infer turbo version due to use of `catalog` protocol. Remove `turbo` from your PNPM catalog to ensure correct turbo version is used"
);
});

it("falls back to inferring major from turbo.json", () => {
expect(getTurboVersion({}, fixture)).toEqual("^2");
});
});
});
11 changes: 8 additions & 3 deletions packages/turbo-ignore/src/getTurboVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "node:fs";
import path from "node:path";
import type { PackageJson } from "@turbo/utils";
import { parse as JSON5Parse } from "json5";
import { error, info } from "./logger";
import { error, info, warn } from "./logger";
import type { TurboIgnoreOptions } from "./types";

export function getTurboVersion(
Expand All @@ -23,8 +23,13 @@ export function getTurboVersion(
const devDependencies = packageJson.devDependencies?.turbo;
turboVersion = dependencies || devDependencies;
if (turboVersion !== undefined) {
info(`Inferred turbo version "${turboVersion}" from "package.json"`);
return turboVersion;
if (!turboVersion.startsWith("catalog:")) {
info(`Inferred turbo version "${turboVersion}" from "package.json"`);
return turboVersion;
}
warn(
"Cannot infer turbo version due to use of `catalog` protocol. Remove `turbo` from your PNPM catalog to ensure correct turbo version is used"
);
}
} catch (e) {
error(
Expand Down
Loading