From 20ae135984dc096592f61d7e9b7a050582710310 Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Thu, 6 Jun 2024 15:04:22 -0700 Subject: [PATCH 1/2] fix(turbo-ignore): infer correct version of turbo for project --- .../invalid_turbo_json/package.json | 11 +++ .../invalid_turbo_json/turbo.json | 3 + .../__fixtures__/no_turbo_deps/package.json | 11 +++ .../__fixtures__/no_turbo_deps/turbo.json | 6 ++ .../no_turbo_deps_v1/package.json | 11 +++ .../__fixtures__/no_turbo_deps_v1/turbo.json | 5 ++ .../__fixtures__/turbo_in_deps/package.json | 14 ++++ .../__fixtures__/turbo_in_deps/turbo.json | 5 ++ .../__tests__/getTurboVersion.test.ts | 69 +++++++++++++++++++ .../turbo-ignore/__tests__/ignore.test.ts | 67 +++++++++++++----- packages/turbo-ignore/package.json | 3 + packages/turbo-ignore/src/cli.ts | 6 ++ packages/turbo-ignore/src/getTurboVersion.ts | 55 +++++++++++++++ packages/turbo-ignore/src/ignore.ts | 8 ++- packages/turbo-ignore/src/types.ts | 2 + pnpm-lock.yaml | 4 ++ 16 files changed, 262 insertions(+), 18 deletions(-) create mode 100644 packages/turbo-ignore/__fixtures__/invalid_turbo_json/package.json create mode 100644 packages/turbo-ignore/__fixtures__/invalid_turbo_json/turbo.json create mode 100644 packages/turbo-ignore/__fixtures__/no_turbo_deps/package.json create mode 100644 packages/turbo-ignore/__fixtures__/no_turbo_deps/turbo.json create mode 100644 packages/turbo-ignore/__fixtures__/no_turbo_deps_v1/package.json create mode 100644 packages/turbo-ignore/__fixtures__/no_turbo_deps_v1/turbo.json create mode 100644 packages/turbo-ignore/__fixtures__/turbo_in_deps/package.json create mode 100644 packages/turbo-ignore/__fixtures__/turbo_in_deps/turbo.json create mode 100644 packages/turbo-ignore/__tests__/getTurboVersion.test.ts create mode 100644 packages/turbo-ignore/src/getTurboVersion.ts diff --git a/packages/turbo-ignore/__fixtures__/invalid_turbo_json/package.json b/packages/turbo-ignore/__fixtures__/invalid_turbo_json/package.json new file mode 100644 index 0000000000000..17d7c56314b6d --- /dev/null +++ b/packages/turbo-ignore/__fixtures__/invalid_turbo_json/package.json @@ -0,0 +1,11 @@ +{ + "name": "test-app", + "private": true, + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "vercel" +} diff --git a/packages/turbo-ignore/__fixtures__/invalid_turbo_json/turbo.json b/packages/turbo-ignore/__fixtures__/invalid_turbo_json/turbo.json new file mode 100644 index 0000000000000..c339cfd8ba66d --- /dev/null +++ b/packages/turbo-ignore/__fixtures__/invalid_turbo_json/turbo.json @@ -0,0 +1,3 @@ +{ + // No pipeline or tasks +} diff --git a/packages/turbo-ignore/__fixtures__/no_turbo_deps/package.json b/packages/turbo-ignore/__fixtures__/no_turbo_deps/package.json new file mode 100644 index 0000000000000..17d7c56314b6d --- /dev/null +++ b/packages/turbo-ignore/__fixtures__/no_turbo_deps/package.json @@ -0,0 +1,11 @@ +{ + "name": "test-app", + "private": true, + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "vercel" +} diff --git a/packages/turbo-ignore/__fixtures__/no_turbo_deps/turbo.json b/packages/turbo-ignore/__fixtures__/no_turbo_deps/turbo.json new file mode 100644 index 0000000000000..4d9a94289d8c9 --- /dev/null +++ b/packages/turbo-ignore/__fixtures__/no_turbo_deps/turbo.json @@ -0,0 +1,6 @@ +{ + // A comment! + "tasks": { + "build": {} + } +} diff --git a/packages/turbo-ignore/__fixtures__/no_turbo_deps_v1/package.json b/packages/turbo-ignore/__fixtures__/no_turbo_deps_v1/package.json new file mode 100644 index 0000000000000..17d7c56314b6d --- /dev/null +++ b/packages/turbo-ignore/__fixtures__/no_turbo_deps_v1/package.json @@ -0,0 +1,11 @@ +{ + "name": "test-app", + "private": true, + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "vercel" +} diff --git a/packages/turbo-ignore/__fixtures__/no_turbo_deps_v1/turbo.json b/packages/turbo-ignore/__fixtures__/no_turbo_deps_v1/turbo.json new file mode 100644 index 0000000000000..f27ee6c9b5ebf --- /dev/null +++ b/packages/turbo-ignore/__fixtures__/no_turbo_deps_v1/turbo.json @@ -0,0 +1,5 @@ +{ + "pipeline": { + "build": {} + } +} diff --git a/packages/turbo-ignore/__fixtures__/turbo_in_deps/package.json b/packages/turbo-ignore/__fixtures__/turbo_in_deps/package.json new file mode 100644 index 0000000000000..5ecef8f856f45 --- /dev/null +++ b/packages/turbo-ignore/__fixtures__/turbo_in_deps/package.json @@ -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" + } +} diff --git a/packages/turbo-ignore/__fixtures__/turbo_in_deps/turbo.json b/packages/turbo-ignore/__fixtures__/turbo_in_deps/turbo.json new file mode 100644 index 0000000000000..355525a7657a7 --- /dev/null +++ b/packages/turbo-ignore/__fixtures__/turbo_in_deps/turbo.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "build": {} + } +} diff --git a/packages/turbo-ignore/__tests__/getTurboVersion.test.ts b/packages/turbo-ignore/__tests__/getTurboVersion.test.ts new file mode 100644 index 0000000000000..5852abd19114e --- /dev/null +++ b/packages/turbo-ignore/__tests__/getTurboVersion.test.ts @@ -0,0 +1,69 @@ +import { spyConsole, validateLogs } from "@turbo/test-utils"; +import { getTurboVersion } from "../src/getTurboVersion"; + +describe("getWorkspace()", () => { + const mockConsole = spyConsole(); + it("getTurboVersion returns turboVersion from arg", () => { + expect( + getTurboVersion( + { + turboVersion: "1.2.3", + }, + "./__fixtures__/app" + ) + ).toEqual("1.2.3"); + validateLogs( + ['Using turbo version "1.2.3" from arguments'], + mockConsole.log, + { prefix: "≫ " } + ); + }); + + it("getTurboVersion returns version from package.json", () => { + expect(getTurboVersion({}, "./__fixtures__/turbo_in_deps")).toEqual("^99"); + expect(mockConsole.log).toHaveBeenCalledWith( + "≫ ", + 'Inferred turbo version "^99" from "package.json"' + ); + }); + + it("getTurboVersion infers ^2 if tasks in turbo.json", () => { + expect(getTurboVersion({}, "./__fixtures__/no_turbo_deps")).toEqual("^2"); + expect(mockConsole.log).toHaveBeenCalledWith( + "≫ ", + 'Inferred turbo version ^2 based on "tasks" in "turbo.json"' + ); + }); + + it("getTurboVersion infers ^1 if pipeline in turbo.json", () => { + expect(getTurboVersion({}, "./__fixtures__/no_turbo_deps_v1")).toEqual( + "^1" + ); + expect(mockConsole.log).toHaveBeenCalledWith( + "≫ ", + 'Inferred turbo version ^1 based on "pipeline" in "turbo.json"' + ); + }); + + it("getTurboVersion return null if no turbo.json", () => { + expect(getTurboVersion({}, "./__fixtures__/app")).toEqual(null); + expect(mockConsole.error).toHaveBeenCalledWith( + "≫ ", + '"__fixtures__/app/turbo.json" could not be read. turbo-ignore turbo version inference failed' + ); + }); + + it("getTurboVersion return null if no package.json", () => { + expect(getTurboVersion({}, "./__fixtures__/no-app")).toEqual(null); + expect(mockConsole.error).toHaveBeenCalledWith( + "≫ ", + '"__fixtures__/no-app/package.json" could not be read. turbo-ignore turbo version inference failed' + ); + }); + + it("getTurboVersion return null if invalid JSON", () => { + expect(getTurboVersion({}, "./__fixtures__/invalid_turbo_json")).toEqual( + null + ); + }); +}); diff --git a/packages/turbo-ignore/__tests__/ignore.test.ts b/packages/turbo-ignore/__tests__/ignore.test.ts index 4137e761e7847..a21268d3ea613 100644 --- a/packages/turbo-ignore/__tests__/ignore.test.ts +++ b/packages/turbo-ignore/__tests__/ignore.test.ts @@ -59,7 +59,7 @@ describe("turboIgnore()", () => { turboIgnore("test-workspace", { telemetry }); expect(mockExec).toHaveBeenCalledWith( - `npx turbo run build --filter="test-workspace...[HEAD^]" --dry=json`, + `npx -y turbo@^2 run build --filter="test-workspace...[HEAD^]" --dry=json`, expect.anything(), expect.anything() ); @@ -92,7 +92,7 @@ describe("turboIgnore()", () => { turboIgnore("test-workspace", {}); expect(mockExec).toHaveBeenCalledWith( - `npx turbo run build --filter="test-workspace...[HEAD^]" --dry=json`, + `npx -y turbo@^2 run build --filter="test-workspace...[HEAD^]" --dry=json`, expect.anything(), expect.anything() ); @@ -137,7 +137,7 @@ describe("turboIgnore()", () => { turboIgnore("test-workspace", { telemetry }); expect(mockExec).toHaveBeenCalledWith( - `npx turbo run build --filter="test-workspace...[too-far-back]" --dry=json`, + `npx -y turbo@^2 run build --filter="test-workspace...[too-far-back]" --dry=json`, expect.anything(), expect.anything() ); @@ -175,7 +175,7 @@ describe("turboIgnore()", () => { turboIgnore("test-workspace", { fallback: "HEAD^" }); expect(mockExec).toHaveBeenCalledWith( - `npx turbo run build --filter="test-workspace...[HEAD^]" --dry=json`, + `npx -y turbo@^2 run build --filter="test-workspace...[HEAD^]" --dry=json`, expect.anything(), expect.anything() ); @@ -250,7 +250,7 @@ describe("turboIgnore()", () => { process.env.VERCEL_GIT_COMMIT_REF = "my-branch"; turboIgnore("test-app", { directory: "__fixtures__/app" }); expect(mockConsole.log).toHaveBeenNthCalledWith( - 4, + 5, "≫ ", 'No previous deployments found for "test-app" on branch "my-branch"' ); @@ -283,9 +283,10 @@ describe("turboIgnore()", () => { [ "Using Turborepo to determine if this project is affected by the commit...\n", 'Inferred "test-app" as workspace from "package.json"', + 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', 'Using "build" as the task as it was unspecified', `Found previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch"`, - 'Analyzing results of `npx turbo run build --filter="test-app...[last-deployed-sha]" --dry=json`', + 'Analyzing results of `npx -y turbo@^2 run build --filter="test-app...[last-deployed-sha]" --dry=json`', "This project and its dependencies are not affected", () => expect.stringContaining("⏭ Ignoring the change"), ], @@ -327,9 +328,10 @@ describe("turboIgnore()", () => { [ "Using Turborepo to determine if this project is affected by the commit...\n", 'Inferred "test-app" as workspace from "package.json"', + 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', 'Using "workspace#build" as the task from the arguments', 'Found previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch"', - 'Analyzing results of `npx turbo run "workspace#build" --filter="test-app...[last-deployed-sha]" --dry=json`', + 'Analyzing results of `npx -y turbo@^2 run "workspace#build" --filter="test-app...[last-deployed-sha]" --dry=json`', 'This commit affects "test-app"', () => expect.stringContaining("✓ Proceeding with deployment"), ], @@ -368,9 +370,10 @@ describe("turboIgnore()", () => { [ "Using Turborepo to determine if this project is affected by the commit...\n", 'Inferred "test-app" as workspace from "package.json"', + 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', 'Using "build" as the task as it was unspecified', 'Found previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch"', - 'Analyzing results of `npx turbo run build --filter="test-app...[last-deployed-sha]" --dry=json`', + 'Analyzing results of `npx -y turbo@^2 run build --filter="test-app...[last-deployed-sha]" --dry=json`', 'This commit affects "test-app" and 1 dependency (ui)', () => expect.stringContaining("✓ Proceeding with deployment"), ], @@ -409,9 +412,10 @@ describe("turboIgnore()", () => { [ "Using Turborepo to determine if this project is affected by the commit...\n", 'Inferred "test-app" as workspace from "package.json"', + 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', 'Using "build" as the task as it was unspecified', 'Found previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch"', - 'Analyzing results of `npx turbo run build --filter="test-app...[last-deployed-sha]" --dry=json`', + 'Analyzing results of `npx -y turbo@^2 run build --filter="test-app...[last-deployed-sha]" --dry=json`', 'This commit affects "test-app" and 2 dependencies (ui, tsconfig)', () => expect.stringContaining("✓ Proceeding with deployment"), ], @@ -459,10 +463,11 @@ describe("turboIgnore()", () => { [ "Using Turborepo to determine if this project is affected by the commit...\n", 'Inferred "test-app" as workspace from "package.json"', + 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', 'Using "workspace#build" as the task from the arguments', 'Previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch" is unreachable.', "Falling back to ref HEAD^2", - 'Analyzing results of `npx turbo run "workspace#build" --filter="test-app...[HEAD^2]" --dry=json`', + 'Analyzing results of `npx -y turbo@^2 run "workspace#build" --filter="test-app...[HEAD^2]" --dry=json`', 'This commit affects "test-app"', () => expect.stringContaining("✓ Proceeding with deployment"), ], @@ -488,13 +493,13 @@ describe("turboIgnore()", () => { turboIgnore(undefined, { directory: "__fixtures__/app" }); expect(mockExec).toHaveBeenCalledWith( - `npx turbo run build --filter="test-app...[HEAD^]" --dry=json`, + `npx -y turbo@^2 run build --filter="test-app...[HEAD^]" --dry=json`, expect.anything(), expect.anything() ); validateLogs( [ - 'Failed to parse JSON output from `npx turbo run build --filter="test-app...[HEAD^]" --dry=json`.', + 'Failed to parse JSON output from `npx -y turbo@^2 run build --filter="test-app...[HEAD^]" --dry=json`.', ], mockConsole.error, { prefix: "≫ " } @@ -521,13 +526,13 @@ describe("turboIgnore()", () => { turboIgnore(undefined, { directory: "__fixtures__/app" }); expect(mockExec).toHaveBeenCalledWith( - `npx turbo run build --filter="test-app...[HEAD^]" --dry=json`, + `npx -y turbo@^2 run build --filter="test-app...[HEAD^]" --dry=json`, expect.anything(), expect.anything() ); validateLogs( [ - 'Failed to parse JSON output from `npx turbo run build --filter="test-app...[HEAD^]" --dry=json`.', + 'Failed to parse JSON output from `npx -y turbo@^2 run build --filter="test-app...[HEAD^]" --dry=json`.', ], mockConsole.error, { prefix: "≫ " } @@ -547,6 +552,7 @@ describe("turboIgnore()", () => { [ "Using Turborepo to determine if this project is affected by the commit...\n", 'Inferred "test-app" as workspace from "package.json"', + 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', 'Using "build" as the task as it was unspecified', "Found commit message: [vercel skip]", () => expect.stringContaining("⏭ Ignoring the change"), @@ -568,6 +574,7 @@ describe("turboIgnore()", () => { [ "Using Turborepo to determine if this project is affected by the commit...\n", 'Inferred "test-app" as workspace from "package.json"', + 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', 'Using "build" as the task as it was unspecified', "Found commit message: [vercel deploy]", () => expect.stringContaining("✓ Proceeding with deployment"), @@ -608,10 +615,11 @@ describe("turboIgnore()", () => { [ "Using Turborepo to determine if this project is affected by the commit...\n", 'Inferred "test-app" as workspace from "package.json"', + 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', 'Using "build" as the task as it was unspecified', "Conflicting commit messages found: [vercel deploy] and [vercel skip]", `Found previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch"`, - 'Analyzing results of `npx turbo run build --filter="test-app...[last-deployed-sha]" --dry=json`', + 'Analyzing results of `npx -y turbo@^2 run build --filter="test-app...[last-deployed-sha]" --dry=json`', "This project and its dependencies are not affected", () => expect.stringContaining("⏭ Ignoring the change"), ], @@ -641,7 +649,7 @@ describe("turboIgnore()", () => { turboIgnore(undefined, { directory: "__fixtures__/app", maxBuffer: 1024 }); expect(mockExec).toHaveBeenCalledWith( - `npx turbo run build --filter="test-app...[HEAD^]" --dry=json`, + `npx -y turbo@^2 run build --filter="test-app...[HEAD^]" --dry=json`, expect.objectContaining({ maxBuffer: 1024 }), expect.anything() ); @@ -670,7 +678,7 @@ describe("turboIgnore()", () => { }); expect(mockExec).toHaveBeenCalledWith( - `npx turbo run build --filter="test-app...[HEAD^]" --dry=json`, + `npx -y turbo@^2 run build --filter="test-app...[HEAD^]" --dry=json`, expect.objectContaining({ maxBuffer: 1024 }), expect.anything() ); @@ -699,4 +707,29 @@ describe("turboIgnore()", () => { expectBuild(mockExit); mockExec.mockRestore(); }); + + it("defaults to latest turbo if no hints for version", () => { + const mockExec = jest + .spyOn(child_process, "exec") + .mockImplementation((command, options, callback) => { + if (callback) { + return callback( + null, + '{"packages": [],"tasks":[]}', + "stderr" + ) as unknown as ChildProcess; + } + return {} as unknown as ChildProcess; + }); + + turboIgnore(undefined, { directory: "__fixtures__/invalid_turbo_json" }); + + expect(mockExec).toHaveBeenCalledWith( + `npx -y turbo run build --filter="test-app...[HEAD^]" --dry=json`, + expect.anything(), + expect.anything() + ); + + mockExec.mockRestore(); + }); }); diff --git a/packages/turbo-ignore/package.json b/packages/turbo-ignore/package.json index e1c455774ab7a..25f631a7e8c58 100644 --- a/packages/turbo-ignore/package.json +++ b/packages/turbo-ignore/package.json @@ -25,6 +25,9 @@ "check-types": "tsc --noEmit", "lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore" }, + "dependencies": { + "json5": "^2.2.3" + }, "devDependencies": { "@turbo/eslint-config": "workspace:*", "@turbo/telemetry": "workspace:*", diff --git a/packages/turbo-ignore/src/cli.ts b/packages/turbo-ignore/src/cli.ts index 748f4ea8d231a..1794a661ddc03 100755 --- a/packages/turbo-ignore/src/cli.ts +++ b/packages/turbo-ignore/src/cli.ts @@ -54,6 +54,12 @@ turboIgnoreCli "The directory to run in (default: cwd)" ) ) + .addOption( + new Option( + "--turbo-version ", + "Explicitly set which version of turbo to invoke" + ) + ) .addOption( new Option( "-b, --max-buffer ", diff --git a/packages/turbo-ignore/src/getTurboVersion.ts b/packages/turbo-ignore/src/getTurboVersion.ts new file mode 100644 index 0000000000000..28f83fedd26d2 --- /dev/null +++ b/packages/turbo-ignore/src/getTurboVersion.ts @@ -0,0 +1,55 @@ +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 type { TurboIgnoreOptions } from "./types"; + +export function getTurboVersion( + args: TurboIgnoreOptions, + root: string +): string | null { + let { turboVersion } = args; + if (turboVersion) { + info(`Using turbo version "${turboVersion}" from arguments`); + return turboVersion; + } + + const packageJsonPath = path.join(root, "package.json"); + try { + const raw = fs.readFileSync(packageJsonPath, "utf8"); + const packageJson = JSON.parse(raw) as PackageJson; + const dependencies = packageJson.dependencies?.turbo; + const devDependencies = packageJson.devDependencies?.turbo; + turboVersion = dependencies || devDependencies; + if (turboVersion !== undefined) { + info(`Inferred turbo version "${turboVersion}" from "package.json"`); + return turboVersion; + } + } catch (e) { + error( + `"${packageJsonPath}" could not be read. turbo-ignore turbo version inference failed` + ); + return null; + } + + const turboJSONPath = path.join(root, "turbo.json"); + try { + const rawTurboJson = fs.readFileSync(turboJSONPath, "utf8"); + const turboJson = JSON5Parse(rawTurboJson); + if ("tasks" in turboJson) { + info(`Inferred turbo version ^2 based on "tasks" in "turbo.json"`); + return "^2"; + } + if ("pipeline" in turboJson) { + info(`Inferred turbo version ^1 based on "pipeline" in "turbo.json"`); + return "^1"; + } + return null; + } catch (e) { + error( + `"${turboJSONPath}" could not be read. turbo-ignore turbo version inference failed` + ); + return null; + } +} diff --git a/packages/turbo-ignore/src/ignore.ts b/packages/turbo-ignore/src/ignore.ts index 3e2655a6b177b..12ba61b2ad549 100644 --- a/packages/turbo-ignore/src/ignore.ts +++ b/packages/turbo-ignore/src/ignore.ts @@ -6,6 +6,7 @@ import type { DryRun } from "@turbo/types"; import { getComparison } from "./getComparison"; import { getTask } from "./getTask"; import { getWorkspace } from "./getWorkspace"; +import { getTurboVersion } from "./getTurboVersion"; import { log, info, warn, error } from "./logger"; import { shouldWarn } from "./errors"; import type { TurboIgnoreArg, TurboIgnoreOptions } from "./types"; @@ -79,6 +80,9 @@ export function turboIgnore( return continueBuild(); } + // Find the version of turbo this project uses + const turboVersion = getTurboVersion(inputs, root); + // Identify which task to execute from the command-line args const task = getTask(inputs); @@ -103,8 +107,10 @@ export function turboIgnore( return continueBuild(); } + // If we can't find a turbo version in package.json, don't specify a version + const turbo = turboVersion ? `turbo@${turboVersion}` : "turbo"; // Build, and execute the command - const command = `npx turbo run ${task} --filter="${workspace}...[${comparison.ref}]" --dry=json`; + const command = `npx -y ${turbo} run ${task} --filter="${workspace}...[${comparison.ref}]" --dry=json`; info(`Analyzing results of \`${command}\``); const execOptions: { cwd: string; maxBuffer?: number } = { diff --git a/packages/turbo-ignore/src/types.ts b/packages/turbo-ignore/src/types.ts index bff6fe46925ba..e6a72a3320ec8 100644 --- a/packages/turbo-ignore/src/types.ts +++ b/packages/turbo-ignore/src/types.ts @@ -24,6 +24,8 @@ export interface TurboIgnoreOptions { task?: string; // A ref/head to compare against if no previously deployed SHA is available fallback?: string; + // An explicit version of turbo to use + turboVersion?: string; // The maxBuffer for the child process in KB maxBuffer?: number; // The telemetry client diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 92b88d150c635..597718ecb2f67 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -620,6 +620,10 @@ importers: version: 5.3.3 packages/turbo-ignore: + dependencies: + json5: + specifier: ^2.2.3 + version: 2.2.3 devDependencies: '@turbo/eslint-config': specifier: workspace:* From 507dc82d95704e898a25c7e51d89642744715966 Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Thu, 6 Jun 2024 15:51:32 -0700 Subject: [PATCH 2/2] chore: fix any type lint --- packages/turbo-ignore/src/getTurboVersion.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/turbo-ignore/src/getTurboVersion.ts b/packages/turbo-ignore/src/getTurboVersion.ts index 28f83fedd26d2..ff416c4d72426 100644 --- a/packages/turbo-ignore/src/getTurboVersion.ts +++ b/packages/turbo-ignore/src/getTurboVersion.ts @@ -36,7 +36,8 @@ export function getTurboVersion( const turboJSONPath = path.join(root, "turbo.json"); try { const rawTurboJson = fs.readFileSync(turboJSONPath, "utf8"); - const turboJson = JSON5Parse(rawTurboJson); + const turboJson: { tasks?: unknown; pipeline?: unknown } = + JSON5Parse(rawTurboJson); if ("tasks" in turboJson) { info(`Inferred turbo version ^2 based on "tasks" in "turbo.json"`); return "^2";