Skip to content

Commit

Permalink
Add codemod.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhammond committed Apr 28, 2023
1 parent 7c2d8c3 commit a3322e6
Show file tree
Hide file tree
Showing 18 changed files with 593 additions and 33 deletions.
51 changes: 51 additions & 0 deletions docs/pages/repo/docs/reference/codemods.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ npx @turbo/codemod <transform> <path>
2. [create-turbo-config](#create-turbo-config)
3. [migrate-env-var-dependencies](#migrate-env-var-dependencies)
4. [set-default-outputs](#set-default-outputs)
5. [stabilize-env-mode](#stabilize-env-mode)

### `add-package-manager`

Expand Down Expand Up @@ -276,3 +277,53 @@ Run the codemod:
```sh
npx @turbo/codemod set-default-outputs
```

### `stabilize-env-mode`

<Callout type="info">
Introduced in v1.10.0
</Callout>

Migrates `turbo.json`'s `experimentalGlobalPassThroughEnv` to `globalPassThroughEnv` and `experimentalPassThroughEnv` to `passThroughEnv`.

For example:

```json
// Before, turbo.json
{
"$schema": "https://turbo.build/schema.json",
"experimentalGlobalPassThroughEnv": ["CC"],
"pipeline": {
"build": {
"experimentalPassThroughEnv": ["GOROOT"],
}
}
}
```

```diff
// After, turbo.json
{
"$schema": "https://turbo.build/schema.json",
"globalPassThroughEnv": ["CC"],
"pipeline": {
"build": {
"passThroughEnv": ["GOROOT"],
}
}
}
```

#### Usage

Go to your project:

```sh
cd path-to-your-turborepo/
```

Run the codemod:

```sh
npx @turbo/codemod stabilize-env-mode
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,5 @@
"dependencies": {},
"devDependencies": {},
"packageManager": "npm@1.2.3",
"turbo": {
"pipeline": {
"build-one": {
"outputs": [
"foo"
]
},
"build-two": {
"outputs": []
},
"build-three": {}
}
}
"turbo": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://turbo.build/schema.json",
"experimentalGlobalPassThroughEnv": [
"EXPERIMENTAL_GLOBAL_PASSTHROUGH"
],
"globalPassThroughEnv": [
"GLOBAL_PASSTHROUGH"
],
"pipeline": {
"build": {
"experimentalPassThroughEnv": ["EXPERIMENTAL_TASK_PASSTHROUGH"],
"passThroughEnv": ["TASK_PASSTHROUGH"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://turbo.build/schema.json",
"experimentalGlobalPassThroughEnv": [
"DUPLICATE_GLOBAL",
"DUPLICATE_GLOBAL",
"EXPERIMENTAL_GLOBAL_PASSTHROUGH"
],
"globalPassThroughEnv": [
"DUPLICATE_GLOBAL",
"DUPLICATE_GLOBAL",
"GLOBAL_PASSTHROUGH"
],
"pipeline": {
"build": {
"experimentalPassThroughEnv": ["DUPLICATE_TASK", "DUPLICATE_TASK", "EXPERIMENTAL_TASK_PASSTHROUGH"],
"passThroughEnv": ["DUPLICATE_TASK", "DUPLICATE_TASK", "TASK_PASSTHROUGH"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://turbo.build/schema.json",
"experimentalGlobalPassThroughEnv": [],
"pipeline": {
"build": {
"experimentalPassThroughEnv": []
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://turbo.build/schema.json",
"globalPassThroughEnv": [
"GLOBAL_PASSTHROUGH"
],
"pipeline": {
"build": {
"passThroughEnv": ["TASK_PASSTHROUGH"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://turbo.build/schema.json",
"experimentalGlobalPassThroughEnv": [
"GLOBAL_PASSTHROUGH"
],
"pipeline": {
"build": {
"experimentalPassThroughEnv": ["TASK_PASSTHROUGH"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "stabilize-env-mode-no-turbo-json",
"version": "1.0.0",
"dependencies": {},
"devDependencies": {},
"packageManager": "npm@1.2.3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "stabilize-env-mode-old-config",
"version": "1.0.0",
"dependencies": {},
"devDependencies": {},
"packageManager": "npm@1.2.3",
"turbo": {
"pipeline": {
"build-one": {
"outputs": [
"foo"
]
},
"build-two": {
"outputs": []
},
"build-three": {}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "stabilize-env-mode-docs"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": ["//"],
"pipeline": {
"build": {
"experimentalPassThroughEnv": ["EXPERIMENTAL_DOCS_TASK_PASSTHROUGH"],
"passThroughEnv": ["DOCS_TASK_PASSTHROUGH"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "stabilize-env-mode-website"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": ["//"],
"pipeline": {
"build": {
"experimentalPassThroughEnv": ["EXPERIMENTAL_WEBSITE_TASK_PASSTHROUGH"],
"passThroughEnv": ["WEBSITE_TASK_PASSTHROUGH"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"private": true,
"workspaces": [
"apps/*"
],
"packageManager": "yarn@1.22.19"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://turbo.build/schema.json",
"experimentalGlobalPassThroughEnv": [
"EXPERIMENTAL_GLOBAL_PASSTHROUGH"
],
"globalPassThroughEnv": [
"GLOBAL_PASSTHROUGH"
],
"pipeline": {
"build": {
"experimentalPassThroughEnv": ["EXPERIMENTAL_TASK_PASSTHROUGH"],
"passThroughEnv": ["TASK_PASSTHROUGH"]
}
}
}

0 comments on commit a3322e6

Please sign in to comment.