Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove experimentalGlobalPassThroughEnv from schema #7799

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 18 additions & 5 deletions packages/turbo-codemod/src/transforms/stabilize-env-mode.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import path from "node:path";
import { readJsonSync, existsSync } from "fs-extra";
import { type PackageJson, getTurboConfigs } from "@turbo/utils";
import type { Schema as TurboJsonSchema } from "@turbo/types";
import type { RootSchema } from "@turbo/types/src/types/config";
import type {
EnvWildcard,
RootSchema,
WorkspaceSchema,
} from "@turbo/types/src/types/config";
import type { TransformerArgs } from "../types";
import { getTransformerHelpers } from "../utils/getTransformerHelpers";
import type { TransformerResults } from "../runner";
Expand All @@ -13,7 +16,17 @@ const DESCRIPTION =
"Rewrite experimentalPassThroughEnv and experimentalGlobalPassThroughEnv";
const INTRODUCED_IN = "1.10.0";

function migrateRootConfig(config: RootSchema) {
interface LegacyRootSchema extends RootSchema {
experimentalGlobalPassThroughEnv?: null | Array<EnvWildcard>;
}

interface LegacyWorkspaceSchema extends WorkspaceSchema {
experimentalGlobalPassThroughEnv?: null | Array<EnvWildcard>;
}

type LegacySchema = LegacyRootSchema | LegacyWorkspaceSchema;

function migrateRootConfig(config: LegacyRootSchema) {
const oldConfig = config.experimentalGlobalPassThroughEnv;
const newConfig = config.globalPassThroughEnv;
// Set to an empty array is meaningful, so we have undefined as an option here.
Expand Down Expand Up @@ -45,7 +58,7 @@ function migrateRootConfig(config: RootSchema) {
return migrateTaskConfigs(config);
}

function migrateTaskConfigs(config: TurboJsonSchema) {
function migrateTaskConfigs(config: LegacySchema) {
for (const [_, taskDef] of Object.entries(config.pipeline)) {
const oldConfig = taskDef.experimentalPassThroughEnv;
const newConfig = taskDef.passThroughEnv;
Expand Down Expand Up @@ -119,7 +132,7 @@ export function transformer({
});
}

const turboJson = readJsonSync(turboConfigPath) as TurboJsonSchema;
const turboJson = readJsonSync(turboConfigPath) as LegacySchema;
runner.modifyFile({
filePath: turboConfigPath,
after: migrateRootConfig(turboJson),
Expand Down
11 changes: 0 additions & 11 deletions packages/turbo-types/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@ export interface RootSchema extends BaseSchema {
*/
globalEnv?: Array<EnvWildcard>;

/**
* An allowlist of environment variables that should be made to all tasks, but
* should not contribute to the task's cache key, e.g. `AWS_SECRET_KEY`.
*
* Documentation: https://turbo.build/repo/docs/reference/configuration#globalPassThroughEnv
*
* @defaultValue null
* @deprecated use `globalPassThroughEnv` instead
*/
experimentalGlobalPassThroughEnv?: null | Array<string>;

/**
* An allowlist of environment variables that should be made to all tasks, but
* should not contribute to the task's cache key, e.g. `AWS_SECRET_KEY`.
Expand Down