aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2023-11-03 21:25:40 +0800
committer简律纯 <i@jyunko.cn>2023-11-03 21:25:40 +0800
commit9029588590bea8b10451575c5142dcde77ecd1b5 (patch)
tree04cf8aee56c23fd225ff19d340f7cee621d874ef
parent94071d7ce16c56641d67d488e2bac6be84ffe731 (diff)
downloadHydroRoll-9029588590bea8b10451575c5142dcde77ecd1b5.tar.gz
HydroRoll-9029588590bea8b10451575c5142dcde77ecd1b5.zip
chore: delete useless files
-rw-r--r--packages/create-turbo/.gitignore1
-rw-r--r--packages/create-turbo/LICENSE373
-rw-r--r--packages/create-turbo/README.md13
-rw-r--r--packages/create-turbo/__tests__/examples.test.ts134
-rw-r--r--packages/create-turbo/__tests__/git.test.ts239
-rw-r--r--packages/create-turbo/__tests__/index.test.ts90
-rw-r--r--packages/create-turbo/__tests__/isFolderEmpty.test.ts41
-rw-r--r--packages/create-turbo/__tests__/isWritable.test.ts35
-rw-r--r--packages/create-turbo/__tests__/test-utils.ts34
-rw-r--r--packages/create-turbo/jest.config.js11
-rw-r--r--packages/create-turbo/package.json65
-rw-r--r--packages/create-turbo/src/cli.ts65
-rw-r--r--packages/create-turbo/src/commands/create/createProject.ts192
-rw-r--r--packages/create-turbo/src/commands/create/index.ts243
-rw-r--r--packages/create-turbo/src/commands/create/prompts.ts124
-rw-r--r--packages/create-turbo/src/commands/create/types.ts8
-rw-r--r--packages/create-turbo/src/commands/index.ts1
-rw-r--r--packages/create-turbo/src/logger.ts32
-rw-r--r--packages/create-turbo/src/transforms/errors.ts17
-rw-r--r--packages/create-turbo/src/transforms/git-ignore.ts30
-rw-r--r--packages/create-turbo/src/transforms/index.ts13
-rw-r--r--packages/create-turbo/src/transforms/official-starter.ts73
-rw-r--r--packages/create-turbo/src/transforms/package-manager.ts26
-rw-r--r--packages/create-turbo/src/transforms/types.ts30
-rw-r--r--packages/create-turbo/src/utils/examples.ts139
-rw-r--r--packages/create-turbo/src/utils/git.ts90
-rw-r--r--packages/create-turbo/src/utils/isDefaultExample.ts5
-rw-r--r--packages/create-turbo/src/utils/isFolderEmpty.ts37
-rw-r--r--packages/create-turbo/src/utils/isOnline.ts40
-rw-r--r--packages/create-turbo/src/utils/isWriteable.ts10
-rw-r--r--packages/create-turbo/src/utils/notifyUpdate.ts22
-rw-r--r--packages/create-turbo/tsconfig.json7
-rw-r--r--packages/create-turbo/tsup.config.ts9
-rw-r--r--packages/create-turbo/turbo.json12
-rw-r--r--packages/eslint-config-turbo/LICENSE373
-rw-r--r--packages/eslint-config-turbo/README.md27
-rw-r--r--packages/eslint-config-turbo/index.js3
-rw-r--r--packages/eslint-config-turbo/package.json32
-rw-r--r--packages/eslint-plugin-turbo/LICENSE373
-rw-r--r--packages/eslint-plugin-turbo/README.md53
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/configs/single/turbo.json25
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/index.js6
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/package.json4
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/turbo.json9
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/index.js6
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/package.json4
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/turbo.json9
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/package.json14
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/index.js6
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/package.json4
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/turbo.json9
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace-configs/turbo.json9
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace/.eslintrc.js4
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace/child/child.js2
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace/package-lock.json58
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace/package.json5
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace/peer.js1
-rw-r--r--packages/eslint-plugin-turbo/__fixtures__/workspace/turbo.json34
-rw-r--r--packages/eslint-plugin-turbo/__tests__/cwd.test.ts88
-rw-r--r--packages/eslint-plugin-turbo/__tests__/lib/no-undeclared-env-vars.test.ts433
-rw-r--r--packages/eslint-plugin-turbo/docs/rules/no-undeclared-env-vars.md74
-rw-r--r--packages/eslint-plugin-turbo/jest.config.js12
-rw-r--r--packages/eslint-plugin-turbo/lib/configs/recommended.ts26
-rw-r--r--packages/eslint-plugin-turbo/lib/constants.ts5
-rw-r--r--packages/eslint-plugin-turbo/lib/index.ts17
-rw-r--r--packages/eslint-plugin-turbo/lib/rules/no-undeclared-env-vars.ts187
-rw-r--r--packages/eslint-plugin-turbo/lib/utils/getEnvVarDependencies.ts75
-rw-r--r--packages/eslint-plugin-turbo/package.json51
-rw-r--r--packages/eslint-plugin-turbo/tsconfig.json6
-rw-r--r--packages/eslint-plugin-turbo/tsup.config.ts8
-rw-r--r--packages/eslint-plugin-turbo/turbo.json9
-rw-r--r--packages/node-module-trace/package.json10
-rw-r--r--packages/tsconfig/README.md3
-rw-r--r--packages/tsconfig/base.json20
-rw-r--r--packages/tsconfig/library.json12
-rw-r--r--packages/tsconfig/package.json5
-rw-r--r--packages/turbo-codemod/LICENSE373
-rw-r--r--packages/turbo-codemod/README.md55
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/has-package-manager/package.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/no-package-manager/package.json6
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/wrong-package-manager/package.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/both-configs/package.json28
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/both-configs/turbo.json18
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-package-json-config/package.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-package-json-file/a-random-file.txt1
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-turbo-json-config/package.json24
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/turbo-json-config/package.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/turbo-json-config/turbo.json18
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-deps/package.json4
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-package/README.md1
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-turbo/package.json6
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/normal-workspaces-dev-install/package.json12
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/normal-workspaces/package.json12
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces-dev-install/package.json8
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces-dev-install/pnpm-workspace.yaml3
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces/package.json8
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces/pnpm-workspace.yaml3
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/single-package-dev-install/package.json8
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/single-package/package.json8
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/env-dependencies/turbo.json21
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/migrated-env-dependencies/turbo.json25
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/no-turbo-json/package.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/old-config/package.json20
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/old-config/turbo.json12
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/index.js6
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/package.json4
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/turbo.json9
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/index.js6
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/package.json4
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/turbo.json12
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/package.json14
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/index.js6
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/package.json4
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/turbo.json9
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/turbo.json21
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate/no-repo/README.md1
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/migrate/old-turbo/package.json26
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/invalid-outputs/package.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/invalid-outputs/turbo.json36
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-outputs/package.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-outputs/turbo.json14
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-pipeline/package.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-pipeline/turbo.json5
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-turbo-json/package.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-config/package.json20
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-config/turbo.json12
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-outputs/package.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-outputs/turbo.json12
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/index.js6
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/package.json4
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/turbo.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/index.js6
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/package.json4
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/turbo.json10
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/package.json14
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/index.js6
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/package.json4
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/turbo.json7
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/turbo.json12
-rw-r--r--packages/turbo-codemod/__tests__/__fixtures__/transform/basic/package.json8
-rw-r--r--packages/turbo-codemod/__tests__/add-package-manager.test.ts504
-rw-r--r--packages/turbo-codemod/__tests__/create-turbo-config.test.ts416
-rw-r--r--packages/turbo-codemod/__tests__/get-turbo-upgrade-command.test.ts576
-rw-r--r--packages/turbo-codemod/__tests__/migrate-env-var-dependencies.test.ts758
-rw-r--r--packages/turbo-codemod/__tests__/migrate.test.ts761
-rw-r--r--packages/turbo-codemod/__tests__/set-default-outputs.test.ts391
-rw-r--r--packages/turbo-codemod/__tests__/transform.test.ts172
-rw-r--r--packages/turbo-codemod/index.d.ts1
-rw-r--r--packages/turbo-codemod/jest.config.js18
-rw-r--r--packages/turbo-codemod/package.json67
-rw-r--r--packages/turbo-codemod/plopfile.js46
-rw-r--r--packages/turbo-codemod/src/cli.ts73
-rw-r--r--packages/turbo-codemod/src/commands/index.ts11
-rw-r--r--packages/turbo-codemod/src/commands/migrate/index.ts215
-rw-r--r--packages/turbo-codemod/src/commands/migrate/steps/getCurrentVersion.ts45
-rw-r--r--packages/turbo-codemod/src/commands/migrate/steps/getLatestVersion.ts31
-rw-r--r--packages/turbo-codemod/src/commands/migrate/steps/getTransformsForMigration.ts25
-rw-r--r--packages/turbo-codemod/src/commands/migrate/steps/getTurboUpgradeCommand.ts182
-rw-r--r--packages/turbo-codemod/src/commands/migrate/types.ts9
-rw-r--r--packages/turbo-codemod/src/commands/migrate/utils.ts16
-rw-r--r--packages/turbo-codemod/src/commands/transform/index.ts101
-rw-r--r--packages/turbo-codemod/src/commands/transform/types.ts7
-rw-r--r--packages/turbo-codemod/src/runner/FileTransform.ts94
-rw-r--r--packages/turbo-codemod/src/runner/Runner.ts132
-rw-r--r--packages/turbo-codemod/src/runner/index.ts3
-rw-r--r--packages/turbo-codemod/src/runner/types.ts40
-rw-r--r--packages/turbo-codemod/src/transforms/README.md36
-rw-r--r--packages/turbo-codemod/src/transforms/add-package-manager.ts75
-rw-r--r--packages/turbo-codemod/src/transforms/create-turbo-config.ts70
-rw-r--r--packages/turbo-codemod/src/transforms/migrate-env-var-dependencies.ts181
-rw-r--r--packages/turbo-codemod/src/transforms/set-default-outputs.ts97
-rw-r--r--packages/turbo-codemod/src/types.ts24
-rw-r--r--packages/turbo-codemod/src/utils/checkGitStatus.ts40
-rw-r--r--packages/turbo-codemod/src/utils/directoryInfo.ts10
-rw-r--r--packages/turbo-codemod/src/utils/getPackageManager.ts42
-rw-r--r--packages/turbo-codemod/src/utils/getPackageManagerVersion.ts16
-rw-r--r--packages/turbo-codemod/src/utils/getTransformerHelpers.ts23
-rw-r--r--packages/turbo-codemod/src/utils/loadTransformers.ts27
-rw-r--r--packages/turbo-codemod/src/utils/logger.ts47
-rw-r--r--packages/turbo-codemod/src/utils/looksLikeRepo.ts12
-rw-r--r--packages/turbo-codemod/src/utils/notifyUpdate.ts35
-rw-r--r--packages/turbo-codemod/templates/transformer.hbs45
-rw-r--r--packages/turbo-codemod/templates/transformer.test.hbs25
-rw-r--r--packages/turbo-codemod/tsconfig.json6
-rw-r--r--packages/turbo-codemod/tsup.config.ts9
-rw-r--r--packages/turbo-ignore/README.md99
-rw-r--r--packages/turbo-ignore/__fixtures__/app/package.json11
-rw-r--r--packages/turbo-ignore/__fixtures__/invalid-app/package.json10
-rw-r--r--packages/turbo-ignore/__fixtures__/no-app/index.js0
-rw-r--r--packages/turbo-ignore/__tests__/args.test.ts109
-rw-r--r--packages/turbo-ignore/__tests__/checkCommit.test.ts229
-rw-r--r--packages/turbo-ignore/__tests__/errors.test.ts46
-rw-r--r--packages/turbo-ignore/__tests__/getComparison.test.ts61
-rw-r--r--packages/turbo-ignore/__tests__/getTask.test.ts27
-rw-r--r--packages/turbo-ignore/__tests__/getWorkspace.test.ts62
-rw-r--r--packages/turbo-ignore/__tests__/ignore.test.ts578
-rw-r--r--packages/turbo-ignore/jest.config.js18
-rw-r--r--packages/turbo-ignore/package.json40
-rw-r--r--packages/turbo-ignore/src/args.ts89
-rw-r--r--packages/turbo-ignore/src/checkCommit.ts104
-rw-r--r--packages/turbo-ignore/src/errors.ts43
-rw-r--r--packages/turbo-ignore/src/getComparison.ts39
-rw-r--r--packages/turbo-ignore/src/getTask.ts13
-rw-r--r--packages/turbo-ignore/src/getWorkspace.ts37
-rw-r--r--packages/turbo-ignore/src/ignore.ts125
-rw-r--r--packages/turbo-ignore/src/index.ts6
-rw-r--r--packages/turbo-ignore/src/logger.ts16
-rw-r--r--packages/turbo-ignore/src/types.ts23
-rw-r--r--packages/turbo-ignore/tsconfig.json6
-rw-r--r--packages/turbo-ignore/tsup.config.ts9
-rw-r--r--packages/turbo-test-utils/README.md3
-rw-r--r--packages/turbo-test-utils/package.json40
-rw-r--r--packages/turbo-test-utils/src/index.ts9
-rw-r--r--packages/turbo-test-utils/src/mockEnv.ts12
-rw-r--r--packages/turbo-test-utils/src/spyConsole.ts25
-rw-r--r--packages/turbo-test-utils/src/spyExit.ts21
-rw-r--r--packages/turbo-test-utils/src/useFixtures.ts89
-rw-r--r--packages/turbo-test-utils/src/validateLogs.ts27
-rw-r--r--packages/turbo-test-utils/tsconfig.json6
-rw-r--r--packages/turbo-tracing-next-plugin/README.md39
-rw-r--r--packages/turbo-tracing-next-plugin/package.json25
-rw-r--r--packages/turbo-tracing-next-plugin/src/index.ts27
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/.env.local.example1
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/.gitignore34
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/README.md5
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/components/Form.js202
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/css/form.css39
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/css/style.css184
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/lib/dbConnect.js40
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/models/Pet.js59
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/next.config.js12
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/package.json20
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/[id]/edit.js33
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/[id]/index.js75
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/_app.js36
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/api/pets/[id].js56
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/api/pets/index.js32
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/index.js65
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/new.js19
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/public/favicon.icobin15086 -> 0 bytes
-rw-r--r--packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/public/zeit.svg10
-rw-r--r--packages/turbo-tracing-next-plugin/tsconfig.json14
-rw-r--r--packages/turbo-types/package.json19
-rw-r--r--packages/turbo-types/src/index.ts1
-rw-r--r--packages/turbo-types/src/scripts/codegen.js22
-rw-r--r--packages/turbo-types/src/types/config.ts231
-rw-r--r--packages/turbo-types/tsconfig.json6
-rw-r--r--packages/turbo-types/turbo.json8
-rw-r--r--packages/turbo-utils/LICENSE373
-rw-r--r--packages/turbo-utils/README.md3
-rw-r--r--packages/turbo-utils/__fixtures__/common/single-package/child/child.js2
-rw-r--r--packages/turbo-utils/__fixtures__/common/single-package/package.json3
-rw-r--r--packages/turbo-utils/__fixtures__/common/single-package/turbo.json34
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/apps/docs/index.js6
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/apps/docs/package.json4
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/index.js6
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/package.json4
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/turbo.json9
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/package.json14
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/index.js6
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/package.json4
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/turbo.json9
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/index.js6
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/package.json4
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/turbo.json9
-rw-r--r--packages/turbo-utils/__fixtures__/common/workspace-configs/turbo.json9
-rw-r--r--packages/turbo-utils/__tests__/getTurboConfigs.test.ts112
-rw-r--r--packages/turbo-utils/__tests__/getTurboRoot.test.ts33
-rw-r--r--packages/turbo-utils/jest.config.js7
-rw-r--r--packages/turbo-utils/package.json45
-rw-r--r--packages/turbo-utils/src/getTurboConfigs.ts106
-rw-r--r--packages/turbo-utils/src/getTurboRoot.ts49
-rw-r--r--packages/turbo-utils/src/index.ts8
-rw-r--r--packages/turbo-utils/src/managers.ts53
-rw-r--r--packages/turbo-utils/src/searchUp.ts44
-rw-r--r--packages/turbo-utils/tsconfig.json6
-rw-r--r--packages/turbo-utils/tsup.config.ts12
-rw-r--r--packages/turbo-workspaces/LICENSE373
-rw-r--r--packages/turbo-workspaces/README.md49
-rw-r--r--packages/turbo-workspaces/__fixtures__/invalid/index.js1
-rw-r--r--packages/turbo-workspaces/__fixtures__/npm/monorepo/apps/docs/package.json11
-rw-r--r--packages/turbo-workspaces/__fixtures__/npm/monorepo/apps/web/package.json11
-rw-r--r--packages/turbo-workspaces/__fixtures__/npm/monorepo/package-lock.json385
-rw-r--r--packages/turbo-workspaces/__fixtures__/npm/monorepo/package.json14
-rw-r--r--packages/turbo-workspaces/__fixtures__/npm/monorepo/packages/tsconfig/package.json5
-rw-r--r--packages/turbo-workspaces/__fixtures__/npm/monorepo/packages/ui/package.json7
-rw-r--r--packages/turbo-workspaces/__fixtures__/npm/non-monorepo/package-lock.json12
-rw-r--r--packages/turbo-workspaces/__fixtures__/npm/non-monorepo/package.json6
-rw-r--r--packages/turbo-workspaces/__fixtures__/pnpm/monorepo/apps/docs/package.json11
-rw-r--r--packages/turbo-workspaces/__fixtures__/pnpm/monorepo/apps/web/package.json11
-rw-r--r--packages/turbo-workspaces/__fixtures__/pnpm/monorepo/package.json10
-rw-r--r--packages/turbo-workspaces/__fixtures__/pnpm/monorepo/packages/tsconfig/package.json5
-rw-r--r--packages/turbo-workspaces/__fixtures__/pnpm/monorepo/packages/ui/package.json7
-rw-r--r--packages/turbo-workspaces/__fixtures__/pnpm/monorepo/pnpm-lock.yaml33
-rw-r--r--packages/turbo-workspaces/__fixtures__/pnpm/monorepo/pnpm-workspace.yaml3
-rw-r--r--packages/turbo-workspaces/__fixtures__/pnpm/non-monorepo/package.json8
-rw-r--r--packages/turbo-workspaces/__fixtures__/pnpm/non-monorepo/pnpm-lock.yaml33
-rw-r--r--packages/turbo-workspaces/__fixtures__/yarn/monorepo/apps/docs/package.json11
-rw-r--r--packages/turbo-workspaces/__fixtures__/yarn/monorepo/apps/web/package.json11
-rw-r--r--packages/turbo-workspaces/__fixtures__/yarn/monorepo/package.json14
-rw-r--r--packages/turbo-workspaces/__fixtures__/yarn/monorepo/packages/tsconfig/package.json5
-rw-r--r--packages/turbo-workspaces/__fixtures__/yarn/monorepo/packages/ui/package.json7
-rw-r--r--packages/turbo-workspaces/__fixtures__/yarn/monorepo/yarn.lock4
-rw-r--r--packages/turbo-workspaces/__fixtures__/yarn/non-monorepo/package.json8
-rw-r--r--packages/turbo-workspaces/__fixtures__/yarn/non-monorepo/yarn.lock4
-rw-r--r--packages/turbo-workspaces/__tests__/index.test.ts85
-rw-r--r--packages/turbo-workspaces/__tests__/managers.test.ts285
-rw-r--r--packages/turbo-workspaces/__tests__/test-utils.ts153
-rw-r--r--packages/turbo-workspaces/jest.config.js19
-rw-r--r--packages/turbo-workspaces/package.json66
-rw-r--r--packages/turbo-workspaces/src/cli.ts53
-rw-r--r--packages/turbo-workspaces/src/commands/convert/index.ts109
-rw-r--r--packages/turbo-workspaces/src/commands/convert/types.ts6
-rw-r--r--packages/turbo-workspaces/src/commands/index.ts8
-rw-r--r--packages/turbo-workspaces/src/commands/summary/index.ts98
-rw-r--r--packages/turbo-workspaces/src/commands/summary/types.ts1
-rw-r--r--packages/turbo-workspaces/src/convert.ts61
-rw-r--r--packages/turbo-workspaces/src/errors.ts31
-rw-r--r--packages/turbo-workspaces/src/getWorkspaceDetails.ts35
-rw-r--r--packages/turbo-workspaces/src/index.ts58
-rw-r--r--packages/turbo-workspaces/src/install.ts125
-rw-r--r--packages/turbo-workspaces/src/logger.ts109
-rw-r--r--packages/turbo-workspaces/src/managers/index.ts11
-rw-r--r--packages/turbo-workspaces/src/managers/npm.ts223
-rw-r--r--packages/turbo-workspaces/src/managers/pnpm.ts238
-rw-r--r--packages/turbo-workspaces/src/managers/yarn.ts222
-rw-r--r--packages/turbo-workspaces/src/types.ts127
-rw-r--r--packages/turbo-workspaces/src/updateDependencies.ts135
-rw-r--r--packages/turbo-workspaces/src/utils.ts197
-rw-r--r--packages/turbo-workspaces/tsconfig.json6
-rw-r--r--packages/turbo-workspaces/tsup.config.ts10
-rw-r--r--packages/turbo-workspaces/turbo.json9
-rw-r--r--packages/turbo/.dev-mode3
-rw-r--r--packages/turbo/README.md54
-rw-r--r--packages/turbo/bin/turbo14
-rw-r--r--packages/turbo/bump-version.js21
-rw-r--r--packages/turbo/install.js331
-rw-r--r--packages/turbo/node-platform.js257
-rw-r--r--packages/turbo/package.json29
-rw-r--r--packages/webpack-nmt/package.json26
-rw-r--r--packages/webpack-nmt/src/index.ts173
-rw-r--r--packages/webpack-nmt/tsconfig.json9
342 files changed, 0 insertions, 19721 deletions
diff --git a/packages/create-turbo/.gitignore b/packages/create-turbo/.gitignore
deleted file mode 100644
index 47f732d..0000000
--- a/packages/create-turbo/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-!templates/*/.npmrc
diff --git a/packages/create-turbo/LICENSE b/packages/create-turbo/LICENSE
deleted file mode 100644
index fa0086a..0000000
--- a/packages/create-turbo/LICENSE
+++ /dev/null
@@ -1,373 +0,0 @@
-Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
- means each individual or legal entity that creates, contributes to
- the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
- means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
- means Source Code Form to which the initial Contributor has attached
- the notice in Exhibit A, the Executable Form of such Source Code
- Form, and Modifications of such Source Code Form, in each case
- including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- (a) that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-
- (b) that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-1.6. "Executable Form"
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
- means a work that combines Covered Software with other material, in
- a separate file or files, that is not Covered Software.
-
-1.8. "License"
- means this document.
-
-1.9. "Licensable"
- means having the right to grant, to the maximum extent possible,
- whether at the time of the initial grant or subsequently, any and
- all of the rights conveyed by this License.
-
-1.10. "Modifications"
- means any of the following:
-
- (a) any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-
- (b) any new file in Source Code Form that contains any Covered
- Software.
-
-1.11. "Patent Claims" of a Contributor
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-1.12. "Secondary License"
- means either the GNU General Public License, Version 2.0, the GNU
- Lesser General Public License, Version 2.1, the GNU Affero General
- Public License, Version 3.0, or any later versions of those
- licenses.
-
-1.13. "Source Code Form"
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that
- controls, is controlled by, or is under common control with You. For
- purposes of this definition, "control" means (a) the power, direct
- or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or (b) ownership of more than
- fifty percent (50%) of the outstanding shares or beneficial
- ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
- or
-
-(b) for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
- Form, as described in Section 3.1, and You must inform recipients of
- the Executable Form how they can obtain a copy of such Source Code
- Form by reasonable means in a timely manner, at a charge no more
- than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-* *
-* 6. Disclaimer of Warranty *
-* ------------------------- *
-* *
-* Covered Software is provided under this License on an "as is" *
-* basis, without warranty of any kind, either expressed, implied, or *
-* statutory, including, without limitation, warranties that the *
-* Covered Software is free of defects, merchantable, fit for a *
-* particular purpose or non-infringing. The entire risk as to the *
-* quality and performance of the Covered Software is with You. *
-* Should any Covered Software prove defective in any respect, You *
-* (not any Contributor) assume the cost of any necessary servicing, *
-* repair, or correction. This disclaimer of warranty constitutes an *
-* essential part of this License. No use of any Covered Software is *
-* authorized under this License except under this disclaimer. *
-* *
-************************************************************************
-
-************************************************************************
-* *
-* 7. Limitation of Liability *
-* -------------------------- *
-* *
-* Under no circumstances and under no legal theory, whether tort *
-* (including negligence), contract, or otherwise, shall any *
-* Contributor, or anyone who distributes Covered Software as *
-* permitted above, be liable to You for any direct, indirect, *
-* special, incidental, or consequential damages of any character *
-* including, without limitation, damages for lost profits, loss of *
-* goodwill, work stoppage, computer failure or malfunction, or any *
-* and all other commercial damages or losses, even if such party *
-* shall have been informed of the possibility of such damages. This *
-* limitation of liability shall not apply to liability for death or *
-* personal injury resulting from such party's negligence to the *
-* extent applicable law prohibits such limitation. Some *
-* jurisdictions do not allow the exclusion or limitation of *
-* incidental or consequential damages, so this exclusion and *
-* limitation may not apply to You. *
-* *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0. \ No newline at end of file
diff --git a/packages/create-turbo/README.md b/packages/create-turbo/README.md
deleted file mode 100644
index 485485f..0000000
--- a/packages/create-turbo/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Welcome to Turborepo
-
-[Turborepo](https://turbo.build/repo) is a high-performance monorepo build-system for modern JavaScript and TypeScript codebases.
-
-To get started, open a new shell and run:
-
-```sh
-npx create-turbo@latest
-```
-
-Then follow the prompts you see in your terminal.
-
-For more information about Turborepo, [visit turbo.build/repo](https://turbo.build/repo) and follow us on Twitter ([@turborepo](https://twitter.com/turborepo))!
diff --git a/packages/create-turbo/__tests__/examples.test.ts b/packages/create-turbo/__tests__/examples.test.ts
deleted file mode 100644
index 20d4464..0000000
--- a/packages/create-turbo/__tests__/examples.test.ts
+++ /dev/null
@@ -1,134 +0,0 @@
-import got from "got";
-import * as Got from "got";
-import { isUrlOk, getRepoInfo, hasRepo } from "../src/utils/examples";
-
-jest.mock("got", () => ({
- __esModule: true,
- ...jest.requireActual("got"),
-}));
-
-describe("examples", () => {
- describe("isUrlOk", () => {
- it("returns true if url returns 200", async () => {
- const mockGot = jest
- .spyOn(got, "head")
- .mockReturnValue({ statusCode: 200 } as any);
-
- const url = "https://github.com/vercel/turbo/";
- const result = await isUrlOk(url);
- expect(result).toBe(true);
-
- expect(mockGot).toHaveBeenCalledWith(url);
- mockGot.mockRestore();
- });
-
- it("returns false if url returns status != 200", async () => {
- const mockGot = jest
- .spyOn(got, "head")
- .mockReturnValue({ statusCode: 401 } as any);
-
- const url = "https://not-github.com/vercel/turbo/";
- const result = await isUrlOk(url);
- expect(result).toBe(false);
-
- expect(mockGot).toHaveBeenCalledWith(url);
- mockGot.mockRestore();
- });
- });
-
- describe("getRepoInfo", () => {
- test.each([
- {
- repoUrl: "https://github.com/vercel/turbo/",
- examplePath: undefined,
- defaultBranch: "main",
- expectBranchLookup: true,
- expected: {
- username: "vercel",
- name: "turbo",
- branch: "main",
- filePath: "",
- },
- },
- {
- repoUrl:
- "https://github.com/vercel/turbo/tree/canary/examples/kitchen-sink",
- examplePath: undefined,
- defaultBranch: "canary",
- expectBranchLookup: false,
- expected: {
- username: "vercel",
- name: "turbo",
- branch: "canary",
- filePath: "examples/kitchen-sink",
- },
- },
- {
- repoUrl: "https://github.com/vercel/turbo/tree/tek/test-branch/",
- examplePath: "examples/basic",
- defaultBranch: "canary",
- expectBranchLookup: false,
- expected: {
- username: "vercel",
- name: "turbo",
- branch: "tek/test-branch",
- filePath: "examples/basic",
- },
- },
- ])(
- "retrieves repo info for $repoUrl and $examplePath",
- async ({
- repoUrl,
- examplePath,
- defaultBranch,
- expectBranchLookup,
- expected,
- }) => {
- const mockGot = jest.spyOn(Got, "default").mockReturnValue({
- body: JSON.stringify({ default_branch: defaultBranch }),
- } as any);
-
- const url = new URL(repoUrl);
- const result = await getRepoInfo(url, examplePath);
- expect(result).toMatchObject(expected);
-
- if (result && expectBranchLookup) {
- expect(mockGot).toHaveBeenCalledWith(
- `https://api.github.com/repos/${result.username}/${result.name}`
- );
- }
-
- mockGot.mockRestore();
- }
- );
- });
-
- describe("hasRepo", () => {
- test.each([
- {
- repoInfo: {
- username: "vercel",
- name: "turbo",
- branch: "main",
- filePath: "",
- },
- expected: true,
- expectedUrl:
- "https://api.github.com/repos/vercel/turbo/contents/package.json?ref=main",
- },
- ])(
- "checks repo at $expectedUrl",
- async ({ expected, repoInfo, expectedUrl }) => {
- const mockGot = jest
- .spyOn(got, "head")
- .mockReturnValue({ statusCode: 200 } as any);
-
- const result = await hasRepo(repoInfo);
- expect(result).toBe(expected);
-
- expect(mockGot).toHaveBeenCalledWith(expectedUrl);
- mockGot.mockRestore();
- }
- );
- });
-});
diff --git a/packages/create-turbo/__tests__/git.test.ts b/packages/create-turbo/__tests__/git.test.ts
deleted file mode 100644
index 27ac118..0000000
--- a/packages/create-turbo/__tests__/git.test.ts
+++ /dev/null
@@ -1,239 +0,0 @@
-import path from "path";
-import {
- DEFAULT_IGNORE,
- GIT_REPO_COMMAND,
- HG_REPO_COMMAND,
- isInGitRepository,
- isInMercurialRepository,
- tryGitInit,
-} from "../src/utils/git";
-import childProcess from "child_process";
-import { setupTestFixtures } from "@turbo/test-utils";
-
-describe("git", () => {
- // just to make sure this doesn't get lost
- it("default .gitignore includes .turbo", async () => {
- expect(DEFAULT_IGNORE).toContain(".turbo");
- });
-
- describe("isInGitRepository", () => {
- it("returns true when in a repo", async () => {
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockReturnValue("true");
-
- const result = isInGitRepository();
- expect(result).toBe(true);
-
- expect(mockExecSync).toHaveBeenCalledWith(GIT_REPO_COMMAND, {
- stdio: "ignore",
- });
- mockExecSync.mockRestore();
- });
-
- it("returns false when not in a repo", async () => {
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockImplementation(() => {
- throw new Error(
- "fatal: not a git repository (or any of the parent directories): .git"
- );
- });
-
- const result = isInGitRepository();
- expect(result).toBe(false);
-
- expect(mockExecSync).toHaveBeenCalledWith(GIT_REPO_COMMAND, {
- stdio: "ignore",
- });
- mockExecSync.mockRestore();
- });
-
- it("returns false on error", async () => {
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockImplementation(() => {
- throw new Error("unknown error");
- });
-
- const result = isInGitRepository();
- expect(result).toBe(false);
-
- expect(mockExecSync).toHaveBeenCalledWith(GIT_REPO_COMMAND, {
- stdio: "ignore",
- });
- mockExecSync.mockRestore();
- });
- });
-
- describe("isInMercurialRepository", () => {
- it("returns true when in a repo", async () => {
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockReturnValue("true");
-
- const result = isInMercurialRepository();
- expect(result).toBe(true);
-
- expect(mockExecSync).toHaveBeenCalledWith(HG_REPO_COMMAND, {
- stdio: "ignore",
- });
- mockExecSync.mockRestore();
- });
-
- it("returns false when not in a repo", async () => {
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockImplementation(() => {
- throw new Error("abort: no repository found (.hg not found)");
- });
-
- const result = isInMercurialRepository();
- expect(result).toBe(false);
-
- expect(mockExecSync).toHaveBeenCalledWith(HG_REPO_COMMAND, {
- stdio: "ignore",
- });
- mockExecSync.mockRestore();
- });
-
- it("returns false on error", async () => {
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockImplementation(() => {
- throw new Error("unknown error");
- });
-
- const result = isInMercurialRepository();
- expect(result).toBe(false);
-
- expect(mockExecSync).toHaveBeenCalledWith(HG_REPO_COMMAND, {
- stdio: "ignore",
- });
- mockExecSync.mockRestore();
- });
- });
-
- describe("tryGitInit", () => {
- const { useFixture } = setupTestFixtures({
- directory: path.join(__dirname, "../"),
- });
-
- it("inits a repo succesfully", async () => {
- const { root } = useFixture({ fixture: `git` });
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockReturnValueOnce("git version 2.38.1")
- .mockImplementationOnce(() => {
- throw new Error(
- "fatal: not a git repository (or any of the parent directories): .git"
- );
- })
- .mockImplementationOnce(() => {
- throw new Error("abort: no repository found (.hg not found)");
- })
- .mockReturnValue("success");
-
- const result = tryGitInit(root, "test commit");
- expect(result).toBe(true);
-
- const calls = [
- "git --version",
- "git init",
- "git checkout -b main",
- "git add -A",
- 'git commit -m "test commit"',
- ];
- expect(mockExecSync).toHaveBeenCalledTimes(calls.length + 2);
- calls.forEach((call) => {
- expect(mockExecSync).toHaveBeenCalledWith(call, {
- stdio: "ignore",
- });
- });
- mockExecSync.mockRestore();
- });
-
- it("skips init if already in a repo", async () => {
- const { root } = useFixture({ fixture: `git` });
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockReturnValueOnce("git version 2.38.1")
- .mockReturnValueOnce("true")
- .mockReturnValue("success");
-
- const result = tryGitInit(root, "test commit");
- expect(result).toBe(false);
-
- const calls = ["git --version"];
-
- // 1 call for git --version, 1 call for isInGitRepository
- expect(mockExecSync).toHaveBeenCalledTimes(calls.length + 1);
- calls.forEach((call) => {
- expect(mockExecSync).toHaveBeenCalledWith(call, {
- stdio: "ignore",
- });
- });
- mockExecSync.mockRestore();
- });
-
- it("returns false on unexpected error", async () => {
- const { root } = useFixture({ fixture: `git` });
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockImplementationOnce(() => {
- throw new Error("fatal: unknown command git");
- });
-
- const result = tryGitInit(root, "test commit");
- expect(result).toBe(false);
-
- const calls = ["git --version"];
-
- expect(mockExecSync).toHaveBeenCalledTimes(calls.length);
- calls.forEach((call) => {
- expect(mockExecSync).toHaveBeenCalledWith(call, {
- stdio: "ignore",
- });
- });
- mockExecSync.mockRestore();
- });
-
- it("cleans up from partial init on failure", async () => {
- const { root } = useFixture({ fixture: `git` });
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockReturnValueOnce("git version 2.38.1")
- .mockImplementationOnce(() => {
- throw new Error(
- "fatal: not a git repository (or any of the parent directories): .git"
- );
- })
- .mockImplementationOnce(() => {
- throw new Error("abort: no repository found (.hg not found)");
- })
- .mockReturnValueOnce("success")
- .mockReturnValueOnce("success")
- .mockImplementationOnce(() => {
- throw new Error("fatal: could not add files");
- });
-
- const result = tryGitInit(root, "test commit");
- expect(result).toBe(false);
-
- const calls = [
- "git --version",
- "git init",
- "git checkout -b main",
- "git add -A",
- ];
-
- expect(mockExecSync).toHaveBeenCalledTimes(calls.length + 2);
- calls.forEach((call) => {
- expect(mockExecSync).toHaveBeenCalledWith(call, {
- stdio: "ignore",
- });
- });
- mockExecSync.mockRestore();
- });
- });
-});
diff --git a/packages/create-turbo/__tests__/index.test.ts b/packages/create-turbo/__tests__/index.test.ts
deleted file mode 100644
index 641b193..0000000
--- a/packages/create-turbo/__tests__/index.test.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-import path from "path";
-import chalk from "chalk";
-import childProcess from "child_process";
-import { setupTestFixtures, spyConsole } from "@turbo/test-utils";
-import { create } from "../src/commands/create";
-import type { CreateCommandArgument } from "../src/commands/create/types";
-import { turboGradient } from "../src/logger";
-import type { PackageManager } from "@turbo/workspaces";
-
-// imports for mocks
-import * as createProject from "../src/commands/create/createProject";
-import * as turboWorkspaces from "@turbo/workspaces";
-import { getWorkspaceDetailsMockReturnValue } from "./test-utils";
-
-jest.mock("@turbo/workspaces", () => ({
- __esModule: true,
- ...jest.requireActual("@turbo/workspaces"),
-}));
-
-describe("create-turbo", () => {
- const { useFixture } = setupTestFixtures({
- directory: path.join(__dirname, "../"),
- });
-
- const mockConsole = spyConsole();
-
- test.each<{ packageManager: PackageManager }>([
- { packageManager: "yarn" },
- { packageManager: "npm" },
- { packageManager: "pnpm" },
- ])(
- "outputs expected console messages when using $packageManager",
- async ({ packageManager }) => {
- const { root } = useFixture({ fixture: `create-turbo` });
-
- const availableScripts = ["build", "test", "dev"];
-
- const mockCreateProject = jest
- .spyOn(createProject, "createProject")
- .mockResolvedValue({
- cdPath: "",
- hasPackageJson: true,
- availableScripts,
- });
-
- const mockGetWorkspaceDetails = jest
- .spyOn(turboWorkspaces, "getWorkspaceDetails")
- .mockResolvedValue(
- getWorkspaceDetailsMockReturnValue({
- root,
- packageManager,
- })
- );
-
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockImplementation(() => {
- return "success";
- });
-
- await create(
- root as CreateCommandArgument,
- packageManager as CreateCommandArgument,
- {
- skipInstall: true,
- example: "default",
- }
- );
-
- const expected = `${chalk.bold(
- turboGradient(">>> Success!")
- )} Created a new Turborepo at "${path.relative(process.cwd(), root)}".`;
-
- expect(mockConsole.log).toHaveBeenCalledWith(expected);
- expect(mockConsole.log).toHaveBeenCalledWith(
- "Inside that directory, you can run several commands:"
- );
-
- availableScripts.forEach((script) => {
- expect(mockConsole.log).toHaveBeenCalledWith(
- chalk.cyan(` ${packageManager} run ${script}`)
- );
- });
-
- mockCreateProject.mockRestore();
- mockGetWorkspaceDetails.mockRestore();
- mockExecSync.mockRestore();
- }
- );
-});
diff --git a/packages/create-turbo/__tests__/isFolderEmpty.test.ts b/packages/create-turbo/__tests__/isFolderEmpty.test.ts
deleted file mode 100644
index 66b2310..0000000
--- a/packages/create-turbo/__tests__/isFolderEmpty.test.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import fs from "fs-extra";
-import path from "path";
-import { isFolderEmpty } from "../src/utils/isFolderEmpty";
-import { setupTestFixtures } from "@turbo/test-utils";
-
-describe("isFolderEmpty", () => {
- const { useFixture } = setupTestFixtures({
- directory: path.join(__dirname, "../"),
- });
-
- it("correctly identifies an empty directory", async () => {
- const { root } = useFixture({ fixture: `is-folder-empty` });
- const result = isFolderEmpty(root);
- expect(result.isEmpty).toEqual(true);
- expect(result.conflicts).toEqual([]);
- });
-
- it("correctly identifies a directory with non-conflicting files", async () => {
- const { root } = useFixture({ fixture: `is-folder-empty` });
- fs.writeFileSync(path.join(root, "LICENSE"), "MIT");
- const result = isFolderEmpty(root);
- expect(result.isEmpty).toEqual(true);
- expect(result.conflicts).toEqual([]);
- });
-
- it("correctly identifies a directory non-conflicting files (intelliJ)", async () => {
- const { root } = useFixture({ fixture: `is-folder-empty` });
- fs.writeFileSync(path.join(root, "intellij-idea-config.iml"), "{}");
- const result = isFolderEmpty(root);
- expect(result.isEmpty).toEqual(true);
- expect(result.conflicts).toEqual([]);
- });
-
- it("correctly identifies a directory conflicting files", async () => {
- const { root } = useFixture({ fixture: `is-folder-empty` });
- fs.writeFileSync(path.join(root, "README.md"), "my cool project");
- const result = isFolderEmpty(root);
- expect(result.isEmpty).toEqual(false);
- expect(result.conflicts).toEqual(["README.md"]);
- });
-});
diff --git a/packages/create-turbo/__tests__/isWritable.test.ts b/packages/create-turbo/__tests__/isWritable.test.ts
deleted file mode 100644
index b06670b..0000000
--- a/packages/create-turbo/__tests__/isWritable.test.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import path from "path";
-import { isWriteable } from "../src/utils/isWriteable";
-import { setupTestFixtures } from "@turbo/test-utils";
-import fs from "fs-extra";
-
-describe("isWriteable", () => {
- const { useFixture } = setupTestFixtures({
- directory: path.join(__dirname, "../"),
- });
-
- it("correctly identifies a writeable directory", async () => {
- const { root } = useFixture({ fixture: `is-writeable` });
- const result = await isWriteable(root);
- expect(result).toEqual(true);
- });
-
- it("correctly identifies a non-writeable directory", async () => {
- const { root } = useFixture({ fixture: `is-writeable` });
- const result = await isWriteable(path.join(root, "does-not-exist"));
- expect(result).toEqual(false);
- });
-
- it("returns false on unexpected failure", async () => {
- const { root } = useFixture({ fixture: `is-writeable` });
- const mockFsAccess = jest
- .spyOn(fs, "access")
- .mockRejectedValue(new Error("unknown error"));
-
- const result = await isWriteable(root);
- expect(result).toEqual(false);
- expect(mockFsAccess).toHaveBeenCalledWith(root, fs.constants.W_OK);
-
- mockFsAccess.mockRestore();
- });
-});
diff --git a/packages/create-turbo/__tests__/test-utils.ts b/packages/create-turbo/__tests__/test-utils.ts
deleted file mode 100644
index fa6c204..0000000
--- a/packages/create-turbo/__tests__/test-utils.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import path from "path";
-import { PackageManager } from "@turbo/workspaces";
-
-export function getWorkspaceDetailsMockReturnValue({
- root,
- packageManager = "npm",
-}: {
- root: string;
- packageManager: PackageManager;
-}) {
- return {
- name: "mock-project",
- packageManager,
- paths: {
- root,
- packageJson: path.join(root, "package.json"),
- lockfile: path.join(root, "yarn.lock"),
- nodeModules: path.join(root, "node_modules"),
- },
- workspaceData: {
- globs: ["packages/*"],
- workspaces: [
- {
- name: "packages/mock-package",
- paths: {
- root: path.join(root, "packages/mock-package"),
- packageJson: path.join(root, "packages/mock-package/package.json"),
- nodeModules: path.join(root, "packages/mock-package/node_modules"),
- },
- },
- ],
- },
- };
-}
diff --git a/packages/create-turbo/jest.config.js b/packages/create-turbo/jest.config.js
deleted file mode 100644
index b738f4b..0000000
--- a/packages/create-turbo/jest.config.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
- preset: "ts-jest/presets/js-with-ts",
- testEnvironment: "node",
- testPathIgnorePatterns: ["/__fixtures__/", "/__tests__/test-utils.ts"],
- coveragePathIgnorePatterns: ["/__fixtures__/", "/__tests__/test-utils.ts"],
- transformIgnorePatterns: ["/node_modules/(?!(ansi-regex)/)"],
- modulePathIgnorePatterns: ["<rootDir>/node_modules", "<rootDir>/dist"],
- collectCoverage: true,
- verbose: true,
-};
diff --git a/packages/create-turbo/package.json b/packages/create-turbo/package.json
deleted file mode 100644
index 9f723ba..0000000
--- a/packages/create-turbo/package.json
+++ /dev/null
@@ -1,65 +0,0 @@
-{
- "name": "create-turbo",
- "version": "1.9.4-canary.2",
- "description": "Create a new Turborepo",
- "homepage": "https://turbo.build/repo",
- "license": "MPL-2.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/turbo",
- "directory": "packages/create-turbo"
- },
- "bugs": {
- "url": "https://github.com/vercel/turbo/issues"
- },
- "bin": {
- "create-turbo": "dist/cli.js"
- },
- "scripts": {
- "build": "tsup",
- "test": "jest",
- "lint": "eslint src/**/*.ts",
- "check-types": "tsc --noEmit"
- },
- "dependencies": {
- "async-retry": "^1.3.3",
- "chalk": "2.4.2",
- "commander": "^10.0.0",
- "cross-spawn": "^7.0.3",
- "execa": "5.1.1",
- "fs-extra": "^10.1.0",
- "got": "^11.8.5",
- "gradient-string": "^2.0.0",
- "inquirer": "^8.0.0",
- "ora": "4.1.1",
- "rimraf": "^3.0.2",
- "semver": "^7.3.8",
- "tar": "6.1.13",
- "update-check": "^1.5.4"
- },
- "devDependencies": {
- "@turbo/workspaces": "workspace:*",
- "@types/async-retry": "^1.4.5",
- "@types/cross-spawn": "^6.0.2",
- "@types/fs-extra": "^9.0.13",
- "@types/gradient-string": "^1.1.2",
- "@types/inquirer": "^7.3.1",
- "@types/jest": "^27.4.0",
- "@types/node": "^16.11.12",
- "@types/rimraf": "^3.0.2",
- "@types/semver": "^7.3.9",
- "@types/tar": "^6.1.4",
- "eslint": "^7.23.0",
- "jest": "^27.4.3",
- "strip-ansi": "^6.0.1",
- "ts-jest": "^27.1.1",
- "@turbo/tsconfig": "workspace:*",
- "tsup": "^5.10.3",
- "@turbo/utils": "workspace:*",
- "@turbo/test-utils": "workspace:*",
- "typescript": "^4.5.5"
- },
- "files": [
- "dist"
- ]
-}
diff --git a/packages/create-turbo/src/cli.ts b/packages/create-turbo/src/cli.ts
deleted file mode 100644
index 1290a13..0000000
--- a/packages/create-turbo/src/cli.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env node
-
-import chalk from "chalk";
-import { Command } from "commander";
-import notifyUpdate from "./utils/notifyUpdate";
-import { turboGradient, error } from "./logger";
-
-import { create } from "./commands";
-import cliPkg from "../package.json";
-
-const createTurboCli = new Command();
-
-// create
-createTurboCli
- .name(chalk.bold(turboGradient("create-turbo")))
- .description("Create a new Turborepo")
- .usage(`${chalk.bold("<project-directory> <package-manager>")} [options]`)
- .argument("[project-directory]")
- .argument("[package-manager]")
- .option(
- "--skip-install",
- "Do not run a package manager install after creating the project",
- false
- )
- .option(
- "--skip-transforms",
- "Do not run any code transformation after creating the project",
- false
- )
- .option(
- "-e, --example [name]|[github-url]",
- `
- An example to bootstrap the app with. You can use an example name
- from the official Turborepo repo or a GitHub URL. The URL can use
- any branch and/or subdirectory
-`
- )
- .option(
- "-p, --example-path <path-to-example>",
- `
- In a rare case, your GitHub URL might contain a branch name with
- a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar).
- In this case, you must specify the path to the example separately:
- --example-path foo/bar
-`
- )
- .version(cliPkg.version, "-v, --version", "output the current version")
- .helpOption()
- .action(create);
-
-createTurboCli
- .parseAsync()
- .then(notifyUpdate)
- .catch(async (reason) => {
- console.log();
- if (reason.command) {
- error(`${chalk.bold(reason.command)} has failed.`);
- } else {
- error("Unexpected error. Please report it as a bug:");
- console.log(reason);
- }
- console.log();
- await notifyUpdate();
- process.exit(1);
- });
diff --git a/packages/create-turbo/src/commands/create/createProject.ts b/packages/create-turbo/src/commands/create/createProject.ts
deleted file mode 100644
index 0c1d2ac..0000000
--- a/packages/create-turbo/src/commands/create/createProject.ts
+++ /dev/null
@@ -1,192 +0,0 @@
-import retry from "async-retry";
-import chalk from "chalk";
-import fs from "fs-extra";
-import path from "path";
-
-import {
- downloadAndExtractExample,
- downloadAndExtractRepo,
- getRepoInfo,
- existsInRepo,
- hasRepo,
- RepoInfo,
-} from "../../utils/examples";
-import { isFolderEmpty } from "../../utils/isFolderEmpty";
-import { isWriteable } from "../../utils/isWriteable";
-import { turboLoader, error } from "../../logger";
-import { isDefaultExample } from "../../utils/isDefaultExample";
-
-export class DownloadError extends Error {}
-
-export async function createProject({
- appPath,
- example,
- examplePath,
-}: {
- appPath: string;
- example: string;
- examplePath?: string;
-}): Promise<{
- cdPath: string;
- hasPackageJson: boolean;
- availableScripts: Array<string>;
- repoInfo?: RepoInfo;
-}> {
- let repoInfo: RepoInfo | undefined;
- let repoUrl: URL | undefined;
- const defaultExample = isDefaultExample(example);
-
- try {
- repoUrl = new URL(example);
- } catch (err: any) {
- if (err.code !== "ERR_INVALID_URL") {
- error(err);
- process.exit(1);
- }
- }
-
- if (repoUrl) {
- if (repoUrl.origin !== "https://github.com") {
- error(
- `Invalid URL: ${chalk.red(
- `"${example}"`
- )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`
- );
- process.exit(1);
- }
-
- repoInfo = await getRepoInfo(repoUrl, examplePath);
-
- if (!repoInfo) {
- error(
- `Unable to fetch repository information from: ${chalk.red(
- `"${example}"`
- )}. Please fix the URL and try again.`
- );
- process.exit(1);
- }
-
- const found = await hasRepo(repoInfo);
-
- if (!found) {
- error(
- `Could not locate the repository for ${chalk.red(
- `"${example}"`
- )}. Please check that the repository exists and try again.`
- );
- process.exit(1);
- }
- } else {
- const found = await existsInRepo(example);
-
- if (!found) {
- error(
- `Could not locate an example named ${chalk.red(
- `"${example}"`
- )}. It could be due to the following:\n`,
- `1. Your spelling of example ${chalk.red(
- `"${example}"`
- )} might be incorrect.\n`,
- `2. You might not be connected to the internet or you are behind a proxy.`
- );
- process.exit(1);
- }
- }
-
- const root = path.resolve(appPath);
-
- if (!(await isWriteable(path.dirname(root)))) {
- error(
- "The application path is not writable, please check folder permissions and try again."
- );
- error("It is likely you do not have write permissions for this folder.");
- process.exit(1);
- }
-
- const appName = path.basename(root);
- try {
- await fs.mkdir(root, { recursive: true });
- } catch (err) {
- error("Unable to create project directory");
- console.error(err);
- process.exit(1);
- }
- const { isEmpty, conflicts } = isFolderEmpty(root);
- if (!isEmpty) {
- error(
- `${chalk.dim(root)} has ${conflicts.length} conflicting ${
- conflicts.length === 1 ? "file" : "files"
- } - please try a different location`
- );
- process.exit(1);
- }
-
- const originalDirectory = process.cwd();
- process.chdir(root);
-
- /**
- * clone the example repository
- */
- const loader = turboLoader("Downloading files...");
- try {
- if (repoInfo) {
- console.log(
- `\nDownloading files from repo ${chalk.cyan(
- example
- )}. This might take a moment.`
- );
- console.log();
- loader.start();
- await retry(() => downloadAndExtractRepo(root, repoInfo as RepoInfo), {
- retries: 3,
- });
- } else {
- console.log(
- `\nDownloading files${
- !defaultExample ? ` for example ${chalk.cyan(example)}` : ""
- }. This might take a moment.`
- );
- console.log();
- loader.start();
- await retry(() => downloadAndExtractExample(root, example), {
- retries: 3,
- });
- }
- } catch (reason) {
- function isErrorLike(err: unknown): err is { message: string } {
- return (
- typeof err === "object" &&
- err !== null &&
- typeof (err as { message?: unknown }).message === "string"
- );
- }
- throw new DownloadError(isErrorLike(reason) ? reason.message : reason + "");
- } finally {
- loader.stop();
- }
-
- const rootPackageJsonPath = path.join(root, "package.json");
- const hasPackageJson = fs.existsSync(rootPackageJsonPath);
- const availableScripts = [];
-
- if (hasPackageJson) {
- let packageJsonContent;
- try {
- packageJsonContent = fs.readJsonSync(rootPackageJsonPath);
- } catch {
- // ignore
- }
-
- if (packageJsonContent) {
- // read the scripts from the package.json
- availableScripts.push(...Object.keys(packageJsonContent.scripts || {}));
- }
- }
-
- let cdPath: string = appPath;
- if (path.join(originalDirectory, appName) === appPath) {
- cdPath = appName;
- }
-
- return { cdPath, hasPackageJson, availableScripts, repoInfo };
-}
diff --git a/packages/create-turbo/src/commands/create/index.ts b/packages/create-turbo/src/commands/create/index.ts
deleted file mode 100644
index 419328b..0000000
--- a/packages/create-turbo/src/commands/create/index.ts
+++ /dev/null
@@ -1,243 +0,0 @@
-import path from "path";
-import chalk from "chalk";
-import type { Project } from "@turbo/workspaces";
-import {
- getWorkspaceDetails,
- install,
- getPackageManagerMeta,
- ConvertError,
-} from "@turbo/workspaces";
-import { getAvailablePackageManagers } from "@turbo/utils";
-import type { CreateCommandArgument, CreateCommandOptions } from "./types";
-import * as prompts from "./prompts";
-import { createProject } from "./createProject";
-import { tryGitCommit, tryGitInit } from "../../utils/git";
-import { isOnline } from "../../utils/isOnline";
-import { transforms } from "../../transforms";
-import { turboGradient, turboLoader, info, error, warn } from "../../logger";
-import { TransformError } from "../../transforms/errors";
-
-function handleErrors(err: unknown) {
- // handle errors from ../../transforms
- if (err instanceof TransformError) {
- error(chalk.bold(err.transform), chalk.red(err.message));
- if (err.fatal) {
- process.exit(1);
- }
- // handle errors from @turbo/workspaces
- } else if (err instanceof ConvertError && err.type !== "unknown") {
- error(chalk.red(err.message));
- process.exit(1);
- // handle unknown errors (no special handling, just re-throw to catch at root)
- } else {
- throw err;
- }
-}
-
-const SCRIPTS_TO_DISPLAY: Record<string, string> = {
- build: "Build",
- dev: "Develop",
- test: "Test",
- lint: "Lint",
-};
-
-export async function create(
- directory: CreateCommandArgument,
- packageManager: CreateCommandArgument,
- opts: CreateCommandOptions
-) {
- const { skipInstall, skipTransforms } = opts;
- console.log(chalk.bold(turboGradient(`\n>>> TURBOREPO\n`)));
- info(`Welcome to Turborepo! Let's get you set up with a new codebase.`);
- console.log();
-
- const [online, availablePackageManagers] = await Promise.all([
- isOnline(),
- getAvailablePackageManagers(),
- ]);
-
- if (!online) {
- error(
- "You appear to be offline. Please check your network connection and try again."
- );
- process.exit(1);
- }
- const { root, projectName } = await prompts.directory({ directory });
- const relativeProjectDir = path.relative(process.cwd(), root);
- const projectDirIsCurrentDir = relativeProjectDir === "";
-
- // selected package manager can be undefined if the user chooses to skip transforms
- const selectedPackageManagerDetails = await prompts.packageManager({
- packageManager,
- skipTransforms,
- });
-
- if (packageManager && opts.skipTransforms) {
- warn(
- "--skip-transforms conflicts with <package-manager>. The package manager argument will be ignored."
- );
- }
-
- const { example, examplePath } = opts;
- const exampleName = example && example !== "default" ? example : "basic";
- const { hasPackageJson, availableScripts, repoInfo } = await createProject({
- appPath: root,
- example: exampleName,
- examplePath,
- });
-
- // create a new git repo after creating the project
- tryGitInit(root, `feat(create-turbo): create ${exampleName}`);
-
- // read the project after creating it to get details about workspaces, package manager, etc.
- let project: Project = {} as Project;
- try {
- project = await getWorkspaceDetails({ root });
- } catch (err) {
- handleErrors(err);
- }
-
- // run any required transforms
- if (!skipTransforms) {
- for (const transform of transforms) {
- try {
- const transformResult = await transform({
- example: {
- repo: repoInfo,
- name: exampleName,
- },
- project,
- prompts: {
- projectName,
- root,
- packageManager: selectedPackageManagerDetails,
- },
- opts,
- });
- if (transformResult.result === "success") {
- tryGitCommit(
- `feat(create-turbo): apply ${transformResult.name} transform`
- );
- }
- } catch (err) {
- handleErrors(err);
- }
- }
- }
-
- // if the user opted out of transforms, the package manager will be the same as the source example
- const projectPackageManager =
- skipTransforms || !selectedPackageManagerDetails
- ? {
- name: project.packageManager,
- version: availablePackageManagers[project.packageManager].version,
- }
- : selectedPackageManagerDetails;
-
- info("Created a new Turborepo with the following:");
- console.log();
- if (project.workspaceData.workspaces.length > 0) {
- const workspacesForDisplay = project.workspaceData.workspaces
- .map((w) => ({
- group: path.relative(root, w.paths.root).split(path.sep)?.[0] || "",
- title: path.relative(root, w.paths.root),
- description: w.description,
- }))
- .sort((a, b) => a.title.localeCompare(b.title));
-
- let lastGroup: string | undefined;
- workspacesForDisplay.forEach(({ group, title, description }, idx) => {
- if (idx === 0 || group !== lastGroup) {
- console.log(chalk.cyan(group));
- }
- console.log(
- ` - ${chalk.bold(title)}${description ? `: ${description}` : ""}`
- );
- lastGroup = group;
- });
- } else {
- console.log(chalk.cyan("apps"));
- console.log(` - ${chalk.bold(projectName)}`);
- }
-
- // run install
- console.log();
- if (hasPackageJson && !skipInstall) {
- // in the case when the user opted out of transforms, but not install, we need to make sure the package manager is available
- // before we attempt an install
- if (
- opts.skipTransforms &&
- !availablePackageManagers[project.packageManager].available
- ) {
- warn(
- `Unable to install dependencies - "${exampleName}" uses "${project.packageManager}" which could not be found.`
- );
- warn(
- `Try running without "--skip-transforms" to convert "${exampleName}" to a package manager that is available on your system.`
- );
- console.log();
- } else if (projectPackageManager) {
- console.log("Installing packages. This might take a couple of minutes.");
- console.log();
-
- const loader = turboLoader("Installing dependencies...").start();
- await install({
- project,
- to: projectPackageManager,
- options: {
- interactive: false,
- },
- });
-
- tryGitCommit("feat(create-turbo): install dependencies");
- loader.stop();
- }
- }
-
- if (projectDirIsCurrentDir) {
- console.log(
- `${chalk.bold(
- turboGradient(">>> Success!")
- )} Your new Turborepo is ready.`
- );
- } else {
- console.log(
- `${chalk.bold(
- turboGradient(">>> Success!")
- )} Created a new Turborepo at "${relativeProjectDir}".`
- );
- }
-
- // get the package manager details so we display the right commands to the user in log messages
- const packageManagerMeta = getPackageManagerMeta(projectPackageManager);
- if (packageManagerMeta && hasPackageJson) {
- console.log(
- `Inside ${
- projectDirIsCurrentDir ? "this" : "that"
- } directory, you can run several commands:`
- );
- console.log();
- availableScripts
- .filter((script) => SCRIPTS_TO_DISPLAY[script])
- .forEach((script) => {
- console.log(
- chalk.cyan(` ${packageManagerMeta.command} run ${script}`)
- );
- console.log(` ${SCRIPTS_TO_DISPLAY[script]} all apps and packages`);
- console.log();
- });
- console.log(`Turborepo will cache locally by default. For an additional`);
- console.log(`speed boost, enable Remote Caching with Vercel by`);
- console.log(`entering the following command:`);
- console.log();
- console.log(chalk.cyan(` ${packageManagerMeta.executable} turbo login`));
- console.log();
- console.log(`We suggest that you begin by typing:`);
- console.log();
- if (!projectDirIsCurrentDir) {
- console.log(` ${chalk.cyan("cd")} ${relativeProjectDir}`);
- }
- console.log(chalk.cyan(` ${packageManagerMeta.executable} turbo login`));
- console.log();
- }
-}
diff --git a/packages/create-turbo/src/commands/create/prompts.ts b/packages/create-turbo/src/commands/create/prompts.ts
deleted file mode 100644
index a5ed7bf..0000000
--- a/packages/create-turbo/src/commands/create/prompts.ts
+++ /dev/null
@@ -1,124 +0,0 @@
-import path from "path";
-import fs from "fs-extra";
-import chalk from "chalk";
-import type { PackageManager } from "@turbo/workspaces";
-import type { CreateCommandArgument } from "./types";
-import { getAvailablePackageManagers } from "@turbo/utils";
-import { isFolderEmpty } from "../../utils/isFolderEmpty";
-import inquirer from "inquirer";
-
-function validateDirectory(directory: string): {
- valid: boolean;
- root: string;
- projectName: string;
- error?: string;
-} {
- const root = path.resolve(directory);
- const projectName = path.basename(root);
- const exists = fs.existsSync(root);
-
- const stat = fs.lstatSync(root, { throwIfNoEntry: false });
- if (stat && !stat.isDirectory()) {
- return {
- valid: false,
- root,
- projectName,
- error: `${chalk.dim(
- projectName
- )} is not a directory - please try a different location`,
- };
- }
-
- if (exists) {
- const { isEmpty, conflicts } = isFolderEmpty(root);
- if (!isEmpty) {
- return {
- valid: false,
- root,
- projectName,
- error: `${chalk.dim(projectName)} has ${conflicts.length} conflicting ${
- conflicts.length === 1 ? "file" : "files"
- } - please try a different location`,
- };
- }
- }
-
- return { valid: true, root, projectName };
-}
-
-export async function directory({
- directory,
-}: {
- directory: CreateCommandArgument;
-}) {
- const projectDirectoryAnswer = await inquirer.prompt<{
- projectDirectory: string;
- }>({
- type: "input",
- name: "projectDirectory",
- message: "Where would you like to create your turborepo?",
- when: !directory,
- default: "./my-turborepo",
- validate: (directory: string) => {
- const { valid, error } = validateDirectory(directory);
- if (!valid && error) {
- return error;
- }
- return true;
- },
- filter: (directory: string) => directory.trim(),
- });
-
- const { projectDirectory: selectedProjectDirectory = directory as string } =
- projectDirectoryAnswer;
-
- return validateDirectory(selectedProjectDirectory);
-}
-
-export async function packageManager({
- packageManager,
- skipTransforms,
-}: {
- packageManager: CreateCommandArgument;
- skipTransforms?: boolean;
-}) {
- // if skip transforms is passed, we don't need to ask about the package manager (because that requires a transform)
- if (skipTransforms) {
- return undefined;
- }
-
- const availablePackageManagers = await getAvailablePackageManagers();
- const packageManagerAnswer = await inquirer.prompt<{
- packageManagerInput?: PackageManager;
- }>({
- name: "packageManagerInput",
- type: "list",
- message: "Which package manager do you want to use?",
- when:
- // prompt for package manager if it wasn't provided as an argument, or if it was
- // provided, but isn't available (always allow npm)
- !packageManager ||
- (packageManager as PackageManager) !== "npm" ||
- !Object.keys(availablePackageManagers).includes(packageManager),
- choices: ["npm", "pnpm", "yarn"].map((p) => ({
- name: p,
- value: p,
- disabled:
- // npm should always be available
- p === "npm" ||
- availablePackageManagers?.[p as PackageManager]?.available
- ? false
- : `not installed`,
- })),
- });
-
- const {
- packageManagerInput:
- selectedPackageManager = packageManager as PackageManager,
- } = packageManagerAnswer;
-
- return {
- name: selectedPackageManager,
- version: availablePackageManagers[selectedPackageManager].version,
- };
-}
diff --git a/packages/create-turbo/src/commands/create/types.ts b/packages/create-turbo/src/commands/create/types.ts
deleted file mode 100644
index 094c8d2..0000000
--- a/packages/create-turbo/src/commands/create/types.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export type CreateCommandArgument = "string" | undefined;
-
-export interface CreateCommandOptions {
- skipInstall?: boolean;
- skipTransforms?: boolean;
- example?: string;
- examplePath?: string;
-}
diff --git a/packages/create-turbo/src/commands/index.ts b/packages/create-turbo/src/commands/index.ts
deleted file mode 100644
index 7c5f96b..0000000
--- a/packages/create-turbo/src/commands/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { create } from "./create";
diff --git a/packages/create-turbo/src/logger.ts b/packages/create-turbo/src/logger.ts
deleted file mode 100644
index ee6d584..0000000
--- a/packages/create-turbo/src/logger.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import chalk from "chalk";
-import ora from "ora";
-import gradient from "gradient-string";
-
-const BLUE = "#0099F7";
-const RED = "#F11712";
-const YELLOW = "#FFFF00";
-
-export const turboGradient = gradient(BLUE, RED);
-export const turboBlue = chalk.hex(BLUE);
-export const turboRed = chalk.hex(RED);
-export const yellow = chalk.hex(YELLOW);
-
-export const turboLoader = (text: string) =>
- ora({
- text,
- spinner: {
- frames: [" ", turboBlue("> "), turboBlue(">> "), turboBlue(">>>")],
- },
- });
-
-export const info = (...args: any[]) => {
- console.log(turboBlue.bold(">>>"), ...args);
-};
-
-export const error = (...args: any[]) => {
- console.error(turboRed.bold(">>>"), ...args);
-};
-
-export const warn = (...args: any[]) => {
- console.error(yellow.bold(">>>"), ...args);
-};
diff --git a/packages/create-turbo/src/transforms/errors.ts b/packages/create-turbo/src/transforms/errors.ts
deleted file mode 100644
index a5b8a7a..0000000
--- a/packages/create-turbo/src/transforms/errors.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-export type TransformErrorOptions = {
- transform?: string;
- fatal?: boolean;
-};
-
-export class TransformError extends Error {
- public transform: string;
- public fatal: boolean;
-
- constructor(message: string, opts?: TransformErrorOptions) {
- super(message);
- this.name = "TransformError";
- this.transform = opts?.transform ?? "unknown";
- this.fatal = opts?.fatal ?? true;
- Error.captureStackTrace(this, TransformError);
- }
-}
diff --git a/packages/create-turbo/src/transforms/git-ignore.ts b/packages/create-turbo/src/transforms/git-ignore.ts
deleted file mode 100644
index bb61ca7..0000000
--- a/packages/create-turbo/src/transforms/git-ignore.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import path from "path";
-import fs from "fs-extra";
-import { DEFAULT_IGNORE } from "../utils/git";
-import { TransformInput, TransformResult } from "./types";
-import { TransformError } from "./errors";
-
-const meta = {
- name: "git-ignore",
-};
-
-export async function transform(args: TransformInput): TransformResult {
- const { prompts } = args;
- const ignorePath = path.join(prompts.root, ".gitignore");
- try {
- if (!fs.existsSync(ignorePath)) {
- fs.writeFileSync(ignorePath, DEFAULT_IGNORE);
- } else {
- return { result: "not-applicable", ...meta };
- }
- } catch (err) {
- // existsSync cannot throw, so we don't need to narrow here and can
- // assume this came from writeFileSync
- throw new TransformError("Unable to write .gitignore", {
- transform: meta.name,
- fatal: false,
- });
- }
-
- return { result: "success", ...meta };
-}
diff --git a/packages/create-turbo/src/transforms/index.ts b/packages/create-turbo/src/transforms/index.ts
deleted file mode 100644
index 1918ecc..0000000
--- a/packages/create-turbo/src/transforms/index.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { transform as packageManagerTransform } from "./package-manager";
-import { transform as officialStarter } from "./official-starter";
-import { transform as gitIgnoreTransform } from "./git-ignore";
-import type { TransformInput, TransformResult } from "./types";
-
-/**
- * In the future, we may want to support sourcing additional transforms from the templates themselves.
- */
-export const transforms: Array<(args: TransformInput) => TransformResult> = [
- officialStarter,
- gitIgnoreTransform,
- packageManagerTransform,
-];
diff --git a/packages/create-turbo/src/transforms/official-starter.ts b/packages/create-turbo/src/transforms/official-starter.ts
deleted file mode 100644
index 1d71909..0000000
--- a/packages/create-turbo/src/transforms/official-starter.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import path from "path";
-import fs from "fs-extra";
-import semverPrerelease from "semver/functions/prerelease";
-import cliPkgJson from "../../package.json";
-import { isDefaultExample } from "../utils/isDefaultExample";
-import { TransformInput, TransformResult } from "./types";
-import { TransformError } from "./errors";
-
-const meta = {
- name: "official-starter",
-};
-
-// applied to "official starter" examples (those hosted within vercel/turbo/examples)
-export async function transform(args: TransformInput): TransformResult {
- const { prompts, example } = args;
-
- const defaultExample = isDefaultExample(example.name);
- const isOfficialStarter =
- !example.repo ||
- (example.repo?.username === "vercel" && example.repo?.name === "turbo");
-
- if (!isOfficialStarter) {
- return { result: "not-applicable", ...meta };
- }
-
- // paths
- const rootPackageJsonPath = path.join(prompts.root, "package.json");
- const rootMetaJsonPath = path.join(prompts.root, "meta.json");
- const hasPackageJson = fs.existsSync(rootPackageJsonPath);
-
- // 1. remove meta file (used for generating the examples page on turbo.build)
- try {
- fs.rmSync(rootMetaJsonPath, { force: true });
- } catch (_err) {}
-
- if (hasPackageJson) {
- let packageJsonContent;
- try {
- packageJsonContent = fs.readJsonSync(rootPackageJsonPath);
- } catch {
- throw new TransformError("Unable to read package.json", {
- transform: meta.name,
- fatal: false,
- });
- }
-
- // if using the basic example, set the name to the project name (legacy behavior)
- if (packageJsonContent) {
- if (defaultExample) {
- packageJsonContent.name = prompts.projectName;
- }
-
- // if we're using a pre-release version of create-turbo, install turbo canary instead of latest
- const shouldUsePreRelease = semverPrerelease(cliPkgJson.version) !== null;
- if (shouldUsePreRelease && packageJsonContent?.devDependencies?.turbo) {
- packageJsonContent.devDependencies.turbo = "canary";
- }
-
- try {
- fs.writeJsonSync(rootPackageJsonPath, packageJsonContent, {
- spaces: 2,
- });
- } catch (err) {
- throw new TransformError("Unable to write package.json", {
- transform: meta.name,
- fatal: false,
- });
- }
- }
- }
-
- return { result: "success", ...meta };
-}
diff --git a/packages/create-turbo/src/transforms/package-manager.ts b/packages/create-turbo/src/transforms/package-manager.ts
deleted file mode 100644
index 9c0af24..0000000
--- a/packages/create-turbo/src/transforms/package-manager.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { convert } from "@turbo/workspaces";
-import { TransformInput, TransformResult } from "./types";
-
-const meta = {
- name: "package-manager",
-};
-
-export async function transform(args: TransformInput): TransformResult {
- const { project, prompts } = args;
- const { root, packageManager } = prompts;
-
- if (packageManager && project.packageManager !== packageManager.name) {
- await convert({
- root,
- to: packageManager.name,
- options: {
- // skip install after conversion- we will do it later
- skipInstall: true,
- },
- });
- } else {
- return { result: "not-applicable", ...meta };
- }
-
- return { result: "success", ...meta };
-}
diff --git a/packages/create-turbo/src/transforms/types.ts b/packages/create-turbo/src/transforms/types.ts
deleted file mode 100644
index 6a8e141..0000000
--- a/packages/create-turbo/src/transforms/types.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { CreateCommandOptions } from "../commands/create/types";
-import { RepoInfo } from "../utils/examples";
-import type { Project, PackageManager } from "@turbo/workspaces";
-
-export interface TransformInput {
- example: {
- repo: RepoInfo | undefined;
- name: string;
- };
- project: Project;
- prompts: {
- projectName: string;
- root: string;
- packageManager:
- | {
- name: PackageManager;
- version: string | undefined;
- }
- | undefined;
- };
- opts: CreateCommandOptions;
-}
-
-export interface TransformResponse {
- // errors should be thrown as instances of TransformError
- result: "not-applicable" | "success";
- name: string;
-}
-
-export type TransformResult = Promise<TransformResponse>;
diff --git a/packages/create-turbo/src/utils/examples.ts b/packages/create-turbo/src/utils/examples.ts
deleted file mode 100644
index b7c4812..0000000
--- a/packages/create-turbo/src/utils/examples.ts
+++ /dev/null
@@ -1,139 +0,0 @@
-import got from "got";
-import tar from "tar";
-import { Stream } from "stream";
-import { promisify } from "util";
-import { join } from "path";
-import { tmpdir } from "os";
-import { createWriteStream, promises as fs } from "fs";
-
-const pipeline = promisify(Stream.pipeline);
-
-export type RepoInfo = {
- username: string;
- name: string;
- branch: string;
- filePath: string;
-};
-
-export async function isUrlOk(url: string): Promise<boolean> {
- try {
- const res = await got.head(url);
- return res.statusCode === 200;
- } catch (err) {
- return false;
- }
-}
-
-export async function getRepoInfo(
- url: URL,
- examplePath?: string
-): Promise<RepoInfo | undefined> {
- const [, username, name, tree, sourceBranch, ...file] =
- url.pathname.split("/");
- const filePath = examplePath
- ? examplePath.replace(/^\//, "")
- : file.join("/");
-
- if (
- // Support repos whose entire purpose is to be a Turborepo example, e.g.
- // https://github.com/:username/:my-cool-turborepo-example-repo-name.
- tree === undefined ||
- // Support GitHub URL that ends with a trailing slash, e.g.
- // https://github.com/:username/:my-cool-turborepo-example-repo-name/
- // In this case "t" will be an empty string while the turbo part "_branch" will be undefined
- (tree === "" && sourceBranch === undefined)
- ) {
- try {
- const infoResponse = await got(
- `https://api.github.com/repos/${username}/${name}`
- );
- const info = JSON.parse(infoResponse.body);
- return { username, name, branch: info["default_branch"], filePath };
- } catch (err) {
- return;
- }
- }
-
- // If examplePath is available, the branch name takes the entire path
- const branch = examplePath
- ? `${sourceBranch}/${file.join("/")}`.replace(
- new RegExp(`/${filePath}|/$`),
- ""
- )
- : sourceBranch;
-
- if (username && name && branch && tree === "tree") {
- return { username, name, branch, filePath };
- }
-}
-
-export function hasRepo({
- username,
- name,
- branch,
- filePath,
-}: RepoInfo): Promise<boolean> {
- const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;
- const packagePath = `${filePath ? `/${filePath}` : ""}/package.json`;
-
- return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);
-}
-
-export function existsInRepo(nameOrUrl: string): Promise<boolean> {
- try {
- const url = new URL(nameOrUrl);
- return isUrlOk(url.href);
- } catch {
- return isUrlOk(
- `https://api.github.com/repos/vercel/turbo/contents/examples/${encodeURIComponent(
- nameOrUrl
- )}`
- );
- }
-}
-
-async function downloadTar(url: string, name: string) {
- const tempFile = join(tmpdir(), `${name}.temp-${Date.now()}`);
- await pipeline(got.stream(url), createWriteStream(tempFile));
- return tempFile;
-}
-
-export async function downloadAndExtractRepo(
- root: string,
- { username, name, branch, filePath }: RepoInfo
-) {
- const tempFile = await downloadTar(
- `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`,
- `turbo-ct-example`
- );
-
- await tar.x({
- file: tempFile,
- cwd: root,
- strip: filePath ? filePath.split("/").length + 1 : 1,
- filter: (p: string) =>
- p.startsWith(
- `${name}-${branch.replace(/\//g, "-")}${
- filePath ? `/${filePath}/` : "/"
- }`
- ),
- });
-
- await fs.unlink(tempFile);
-}
-
-export async function downloadAndExtractExample(root: string, name: string) {
- const tempFile = await downloadTar(
- `https://codeload.github.com/vercel/turbo/tar.gz/main`,
- `turbo-ct-example`
- );
-
- await tar.x({
- file: tempFile,
- cwd: root,
- strip: 2 + name.split("/").length,
- filter: (p: string) => p.includes(`turbo-main/examples/${name}/`),
- });
-
- await fs.unlink(tempFile);
-}
diff --git a/packages/create-turbo/src/utils/git.ts b/packages/create-turbo/src/utils/git.ts
deleted file mode 100644
index 593e7ea..0000000
--- a/packages/create-turbo/src/utils/git.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-import fs from "fs-extra";
-import { execSync } from "child_process";
-import path from "path";
-import rimraf from "rimraf";
-
-export const DEFAULT_IGNORE = `
-# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
-
-# dependencies
-node_modules
-.pnp
-.pnp.js
-
-# testing
-coverage
-
-# misc
-.DS_Store
-*.pem
-
-# debug
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-
-# turbo
-.turbo
-
-# vercel
-.vercel
-`;
-
-export const GIT_REPO_COMMAND = "git rev-parse --is-inside-work-tree";
-export const HG_REPO_COMMAND = "hg --cwd . root";
-
-export function isInGitRepository(): boolean {
- try {
- execSync(GIT_REPO_COMMAND, { stdio: "ignore" });
- return true;
- } catch (_) {}
- return false;
-}
-
-export function isInMercurialRepository(): boolean {
- try {
- execSync(HG_REPO_COMMAND, { stdio: "ignore" });
- return true;
- } catch (_) {}
- return false;
-}
-
-export function tryGitInit(root: string, message: string): boolean {
- let didInit = false;
- try {
- execSync("git --version", { stdio: "ignore" });
- if (isInGitRepository() || isInMercurialRepository()) {
- return false;
- }
-
- execSync("git init", { stdio: "ignore" });
- didInit = true;
-
- execSync("git checkout -b main", { stdio: "ignore" });
-
- execSync("git add -A", { stdio: "ignore" });
- execSync(`git commit -m "${message}"`, {
- stdio: "ignore",
- });
- return true;
- } catch (err) {
- if (didInit) {
- try {
- rimraf.sync(path.join(root, ".git"));
- } catch (_) {}
- }
- return false;
- }
-}
-
-export function tryGitCommit(message: string): boolean {
- try {
- execSync("git add -A", { stdio: "ignore" });
- execSync(`git commit -m "${message}"`, {
- stdio: "ignore",
- });
- return true;
- } catch (err) {
- return false;
- }
-}
diff --git a/packages/create-turbo/src/utils/isDefaultExample.ts b/packages/create-turbo/src/utils/isDefaultExample.ts
deleted file mode 100644
index 9fb2ef2..0000000
--- a/packages/create-turbo/src/utils/isDefaultExample.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export const DEFAULT_EXAMPLES = new Set(["basic", "default"]);
-
-export function isDefaultExample(example: string): boolean {
- return DEFAULT_EXAMPLES.has(example);
-}
diff --git a/packages/create-turbo/src/utils/isFolderEmpty.ts b/packages/create-turbo/src/utils/isFolderEmpty.ts
deleted file mode 100644
index 4de2d58..0000000
--- a/packages/create-turbo/src/utils/isFolderEmpty.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import fs from "fs-extra";
-
-const VALID_FILES = [
- ".DS_Store",
- ".git",
- ".gitattributes",
- ".gitignore",
- ".gitlab-ci.yml",
- ".hg",
- ".hgcheck",
- ".hgignore",
- ".idea",
- ".npmignore",
- ".travis.yml",
- "LICENSE",
- "Thumbs.db",
- "docs",
- "mkdocs.yml",
- "npm-debug.log",
- "yarn-debug.log",
- "yarn-error.log",
- "yarnrc.yml",
- ".yarn",
-];
-
-export function isFolderEmpty(root: string): {
- isEmpty: boolean;
- conflicts: Array<string>;
-} {
- const conflicts = fs
- .readdirSync(root)
- .filter((file) => !VALID_FILES.includes(file))
- // Support IntelliJ IDEA-based editors
- .filter((file) => !/\.iml$/.test(file));
-
- return { isEmpty: conflicts.length === 0, conflicts };
-}
diff --git a/packages/create-turbo/src/utils/isOnline.ts b/packages/create-turbo/src/utils/isOnline.ts
deleted file mode 100644
index f02b2e6..0000000
--- a/packages/create-turbo/src/utils/isOnline.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { execSync } from "child_process";
-import dns from "dns";
-import url from "url";
-
-function getProxy(): string | undefined {
- if (process.env.https_proxy) {
- return process.env.https_proxy;
- }
-
- try {
- const httpsProxy = execSync("npm config get https-proxy").toString().trim();
- return httpsProxy !== "null" ? httpsProxy : undefined;
- } catch (e) {
- return;
- }
-}
-
-export function isOnline(): Promise<boolean> {
- return new Promise((resolve) => {
- dns.lookup("registry.yarnpkg.com", (registryErr) => {
- if (!registryErr) {
- return resolve(true);
- }
-
- const proxy = getProxy();
- if (!proxy) {
- return resolve(false);
- }
-
- const { hostname } = url.parse(proxy);
- if (!hostname) {
- return resolve(false);
- }
-
- dns.lookup(hostname, (proxyErr) => {
- resolve(proxyErr == null);
- });
- });
- });
-}
diff --git a/packages/create-turbo/src/utils/isWriteable.ts b/packages/create-turbo/src/utils/isWriteable.ts
deleted file mode 100644
index 132c42a..0000000
--- a/packages/create-turbo/src/utils/isWriteable.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import fs from "fs-extra";
-
-export async function isWriteable(directory: string): Promise<boolean> {
- try {
- await fs.access(directory, (fs.constants || fs).W_OK);
- return true;
- } catch (err) {
- return false;
- }
-}
diff --git a/packages/create-turbo/src/utils/notifyUpdate.ts b/packages/create-turbo/src/utils/notifyUpdate.ts
deleted file mode 100644
index e1dadc0..0000000
--- a/packages/create-turbo/src/utils/notifyUpdate.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import chalk from "chalk";
-import checkForUpdate from "update-check";
-
-import cliPkgJson from "../../package.json";
-
-const update = checkForUpdate(cliPkgJson).catch(() => null);
-
-export default async function notifyUpdate(): Promise<void> {
- try {
- const res = await update;
- if (res?.latest) {
- console.log();
- console.log(
- chalk.yellow.bold("A new version of `create-turbo` is available!")
- );
- console.log();
- }
- process.exit();
- } catch (_e: any) {
- // ignore error
- }
-}
diff --git a/packages/create-turbo/tsconfig.json b/packages/create-turbo/tsconfig.json
deleted file mode 100644
index abcb2c6..0000000
--- a/packages/create-turbo/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "@turbo/tsconfig/library.json",
- "exclude": ["templates"],
- "compilerOptions": {
- "rootDir": "."
- }
-}
diff --git a/packages/create-turbo/tsup.config.ts b/packages/create-turbo/tsup.config.ts
deleted file mode 100644
index 18b0666..0000000
--- a/packages/create-turbo/tsup.config.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { defineConfig, Options } from "tsup";
-
-export default defineConfig((options: Options) => ({
- entry: ["src/cli.ts"],
- format: ["cjs"],
- clean: true,
- minify: true,
- ...options,
-}));
diff --git a/packages/create-turbo/turbo.json b/packages/create-turbo/turbo.json
deleted file mode 100644
index 6466b2d..0000000
--- a/packages/create-turbo/turbo.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "$schema": "../../docs/public/schema.json",
- "extends": ["//"],
- "pipeline": {
- "test": {
- "dependsOn": ["build"]
- },
- "build": {
- "dependsOn": ["^build"]
- }
- }
-}
diff --git a/packages/eslint-config-turbo/LICENSE b/packages/eslint-config-turbo/LICENSE
deleted file mode 100644
index fa0086a..0000000
--- a/packages/eslint-config-turbo/LICENSE
+++ /dev/null
@@ -1,373 +0,0 @@
-Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
- means each individual or legal entity that creates, contributes to
- the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
- means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
- means Source Code Form to which the initial Contributor has attached
- the notice in Exhibit A, the Executable Form of such Source Code
- Form, and Modifications of such Source Code Form, in each case
- including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- (a) that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-
- (b) that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-1.6. "Executable Form"
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
- means a work that combines Covered Software with other material, in
- a separate file or files, that is not Covered Software.
-
-1.8. "License"
- means this document.
-
-1.9. "Licensable"
- means having the right to grant, to the maximum extent possible,
- whether at the time of the initial grant or subsequently, any and
- all of the rights conveyed by this License.
-
-1.10. "Modifications"
- means any of the following:
-
- (a) any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-
- (b) any new file in Source Code Form that contains any Covered
- Software.
-
-1.11. "Patent Claims" of a Contributor
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-1.12. "Secondary License"
- means either the GNU General Public License, Version 2.0, the GNU
- Lesser General Public License, Version 2.1, the GNU Affero General
- Public License, Version 3.0, or any later versions of those
- licenses.
-
-1.13. "Source Code Form"
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that
- controls, is controlled by, or is under common control with You. For
- purposes of this definition, "control" means (a) the power, direct
- or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or (b) ownership of more than
- fifty percent (50%) of the outstanding shares or beneficial
- ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
- or
-
-(b) for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
- Form, as described in Section 3.1, and You must inform recipients of
- the Executable Form how they can obtain a copy of such Source Code
- Form by reasonable means in a timely manner, at a charge no more
- than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-* *
-* 6. Disclaimer of Warranty *
-* ------------------------- *
-* *
-* Covered Software is provided under this License on an "as is" *
-* basis, without warranty of any kind, either expressed, implied, or *
-* statutory, including, without limitation, warranties that the *
-* Covered Software is free of defects, merchantable, fit for a *
-* particular purpose or non-infringing. The entire risk as to the *
-* quality and performance of the Covered Software is with You. *
-* Should any Covered Software prove defective in any respect, You *
-* (not any Contributor) assume the cost of any necessary servicing, *
-* repair, or correction. This disclaimer of warranty constitutes an *
-* essential part of this License. No use of any Covered Software is *
-* authorized under this License except under this disclaimer. *
-* *
-************************************************************************
-
-************************************************************************
-* *
-* 7. Limitation of Liability *
-* -------------------------- *
-* *
-* Under no circumstances and under no legal theory, whether tort *
-* (including negligence), contract, or otherwise, shall any *
-* Contributor, or anyone who distributes Covered Software as *
-* permitted above, be liable to You for any direct, indirect, *
-* special, incidental, or consequential damages of any character *
-* including, without limitation, damages for lost profits, loss of *
-* goodwill, work stoppage, computer failure or malfunction, or any *
-* and all other commercial damages or losses, even if such party *
-* shall have been informed of the possibility of such damages. This *
-* limitation of liability shall not apply to liability for death or *
-* personal injury resulting from such party's negligence to the *
-* extent applicable law prohibits such limitation. Some *
-* jurisdictions do not allow the exclusion or limitation of *
-* incidental or consequential damages, so this exclusion and *
-* limitation may not apply to You. *
-* *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0. \ No newline at end of file
diff --git a/packages/eslint-config-turbo/README.md b/packages/eslint-config-turbo/README.md
deleted file mode 100644
index 834b887..0000000
--- a/packages/eslint-config-turbo/README.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# `eslint-config-turbo`
-
-Ease configuration for Turborepo
-
-## Installation
-
-1. You'll first need to install [ESLint](https://eslint.org/):
-
-```sh
-npm install eslint --save-dev
-```
-
-2. Next, install `eslint-config-turbo`:
-
-```sh
-npm install eslint-config-turbo --save-dev
-```
-
-## Usage
-
-Add `turbo` to the extends section of your eslint configuration file. You can omit the `eslint-config-` prefix:
-
-```json
-{
- "extends": ["turbo"]
-}
-```
diff --git a/packages/eslint-config-turbo/index.js b/packages/eslint-config-turbo/index.js
deleted file mode 100644
index 5d932b3..0000000
--- a/packages/eslint-config-turbo/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = {
- extends: ["plugin:turbo/recommended"],
-};
diff --git a/packages/eslint-config-turbo/package.json b/packages/eslint-config-turbo/package.json
deleted file mode 100644
index 88717ca..0000000
--- a/packages/eslint-config-turbo/package.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "name": "eslint-config-turbo",
- "version": "1.9.4-canary.2",
- "description": "ESLint config for Turborepo",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/turbo",
- "directory": "packages/eslint-config-turbo"
- },
- "bugs": {
- "url": "https://github.com/vercel/turbo/issues"
- },
- "keywords": [
- "turbo",
- "eslint",
- "turborepo",
- "eslintconfig",
- "eslint-config"
- ],
- "main": "index.js",
- "author": "Vercel",
- "dependencies": {
- "eslint-plugin-turbo": "workspace:*"
- },
- "peerDependencies": {
- "eslint": ">6.6.0"
- },
- "license": "MPL-2.0",
- "devDependencies": {
- "@types/eslint": "^8.4.5"
- }
-}
diff --git a/packages/eslint-plugin-turbo/LICENSE b/packages/eslint-plugin-turbo/LICENSE
deleted file mode 100644
index fa0086a..0000000
--- a/packages/eslint-plugin-turbo/LICENSE
+++ /dev/null
@@ -1,373 +0,0 @@
-Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
- means each individual or legal entity that creates, contributes to
- the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
- means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
- means Source Code Form to which the initial Contributor has attached
- the notice in Exhibit A, the Executable Form of such Source Code
- Form, and Modifications of such Source Code Form, in each case
- including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- (a) that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-
- (b) that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-1.6. "Executable Form"
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
- means a work that combines Covered Software with other material, in
- a separate file or files, that is not Covered Software.
-
-1.8. "License"
- means this document.
-
-1.9. "Licensable"
- means having the right to grant, to the maximum extent possible,
- whether at the time of the initial grant or subsequently, any and
- all of the rights conveyed by this License.
-
-1.10. "Modifications"
- means any of the following:
-
- (a) any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-
- (b) any new file in Source Code Form that contains any Covered
- Software.
-
-1.11. "Patent Claims" of a Contributor
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-1.12. "Secondary License"
- means either the GNU General Public License, Version 2.0, the GNU
- Lesser General Public License, Version 2.1, the GNU Affero General
- Public License, Version 3.0, or any later versions of those
- licenses.
-
-1.13. "Source Code Form"
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that
- controls, is controlled by, or is under common control with You. For
- purposes of this definition, "control" means (a) the power, direct
- or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or (b) ownership of more than
- fifty percent (50%) of the outstanding shares or beneficial
- ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
- or
-
-(b) for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
- Form, as described in Section 3.1, and You must inform recipients of
- the Executable Form how they can obtain a copy of such Source Code
- Form by reasonable means in a timely manner, at a charge no more
- than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-* *
-* 6. Disclaimer of Warranty *
-* ------------------------- *
-* *
-* Covered Software is provided under this License on an "as is" *
-* basis, without warranty of any kind, either expressed, implied, or *
-* statutory, including, without limitation, warranties that the *
-* Covered Software is free of defects, merchantable, fit for a *
-* particular purpose or non-infringing. The entire risk as to the *
-* quality and performance of the Covered Software is with You. *
-* Should any Covered Software prove defective in any respect, You *
-* (not any Contributor) assume the cost of any necessary servicing, *
-* repair, or correction. This disclaimer of warranty constitutes an *
-* essential part of this License. No use of any Covered Software is *
-* authorized under this License except under this disclaimer. *
-* *
-************************************************************************
-
-************************************************************************
-* *
-* 7. Limitation of Liability *
-* -------------------------- *
-* *
-* Under no circumstances and under no legal theory, whether tort *
-* (including negligence), contract, or otherwise, shall any *
-* Contributor, or anyone who distributes Covered Software as *
-* permitted above, be liable to You for any direct, indirect, *
-* special, incidental, or consequential damages of any character *
-* including, without limitation, damages for lost profits, loss of *
-* goodwill, work stoppage, computer failure or malfunction, or any *
-* and all other commercial damages or losses, even if such party *
-* shall have been informed of the possibility of such damages. This *
-* limitation of liability shall not apply to liability for death or *
-* personal injury resulting from such party's negligence to the *
-* extent applicable law prohibits such limitation. Some *
-* jurisdictions do not allow the exclusion or limitation of *
-* incidental or consequential damages, so this exclusion and *
-* limitation may not apply to You. *
-* *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0. \ No newline at end of file
diff --git a/packages/eslint-plugin-turbo/README.md b/packages/eslint-plugin-turbo/README.md
deleted file mode 100644
index 83627a1..0000000
--- a/packages/eslint-plugin-turbo/README.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# `eslint-plugin-turbo`
-
-Ease configuration for Turborepo
-
-## Installation
-
-1. You'll first need to install [ESLint](https://eslint.org/):
-
-```sh
-npm install eslint --save-dev
-```
-
-2. Next, install `eslint-plugin-turbo`:
-
-```sh
-npm install eslint-plugin-turbo --save-dev
-```
-
-## Usage
-
-Add `turbo` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
-
-```json
-{
- "plugins": ["turbo"]
-}
-```
-
-Then configure the rules you want to use under the rules section.
-
-```json
-{
- "rules": {
- "turbo/no-undeclared-env-vars": "error"
- }
-}
-```
-
-### Example
-
-```json
-{
- "plugins": ["turbo"],
- "rules": {
- "turbo/no-undeclared-env-vars": [
- "error",
- {
- "allowList": ["^ENV_[A-Z]+$"]
- }
- ]
- }
-}
-```
diff --git a/packages/eslint-plugin-turbo/__fixtures__/configs/single/turbo.json b/packages/eslint-plugin-turbo/__fixtures__/configs/single/turbo.json
deleted file mode 100644
index 22b79b5..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/configs/single/turbo.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- // new style, global env dependency
- "globalEnv": ["NEW_STYLE_GLOBAL_ENV_KEY", "$NEW_STYLE_GLOBAL_ENV_KEY"],
- // old style, global env dependency (deprecated)
- "globalDependencies": ["$GLOBAL_ENV_KEY"],
- "pipeline": {
- "test": {
- "outputs": ["coverage/**"],
- "dependsOn": ["^build"]
- },
- "lint": {
- "outputs": []
- },
- "dev": {
- "cache": false
- },
- "build": {
- "outputs": ["dist/**", ".next/**", "!.next/.cache/**"],
- // task level env var deps
- "env": ["NEW_STYLE_ENV_KEY"],
- // old task level env var deps (deprecated)
- "dependsOn": ["^build", "$TASK_ENV_KEY", "$ANOTHER_ENV_KEY"]
- }
- }
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/index.js b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/index.js
deleted file mode 100644
index 4de53f5..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function docs() {
- if (process.env.ENV_1 === undefined) {
- return "does not exist";
- }
- return "exists";
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/package.json b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/package.json
deleted file mode 100644
index 82f9a44..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "docs",
- "version": "1.0.0"
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/turbo.json b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/turbo.json
deleted file mode 100644
index a3713ef..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/docs/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {
- "env": ["ENV_3"]
- }
- }
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/index.js b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/index.js
deleted file mode 100644
index bfd3ab8..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function web() {
- if (!process.env.ENV_2) {
- return "bar";
- }
- return "foo";
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/package.json b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/package.json
deleted file mode 100644
index d8a83ed..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "web",
- "version": "1.0.0"
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/turbo.json b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/turbo.json
deleted file mode 100644
index 0d1b80f..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/apps/web/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {
- "env": ["ENV_2"]
- }
- }
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/package.json b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/package.json
deleted file mode 100644
index c6616a6..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "private": true,
- "workspaces": [
- "apps/*",
- "packages/*"
- ],
- "scripts": {
- "build": "turbo run build"
- },
- "devDependencies": {
- "turbo": "latest"
- },
- "packageManager": "yarn@1.22.19"
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/index.js b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/index.js
deleted file mode 100644
index dee5e80..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function foo() {
- if (!process.env.IS_SERVER) {
- return "bar";
- }
- return "foo";
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/package.json b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/package.json
deleted file mode 100644
index 7cb7cf1..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "ui",
- "version": "1.0.0"
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/turbo.json b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/turbo.json
deleted file mode 100644
index 8bff09e..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/packages/ui/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {
- "env": ["IS_SERVER"]
- }
- }
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/turbo.json b/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/turbo.json
deleted file mode 100644
index cb4fb20..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace-configs/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "globalEnv": ["CI"],
- "pipeline": {
- "build": {
- "env": ["ENV_1"]
- }
- }
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace/.eslintrc.js b/packages/eslint-plugin-turbo/__fixtures__/workspace/.eslintrc.js
deleted file mode 100644
index 8dc66dc..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace/.eslintrc.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = {
- root: true,
- extends: ["plugin:turbo/recommended"],
-};
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace/child/child.js b/packages/eslint-plugin-turbo/__fixtures__/workspace/child/child.js
deleted file mode 100644
index 9e799a2..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace/child/child.js
+++ /dev/null
@@ -1,2 +0,0 @@
-process.env.NONEXISTENT;
-process.env.CI;
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace/package-lock.json b/packages/eslint-plugin-turbo/__fixtures__/workspace/package-lock.json
deleted file mode 100644
index 301f072..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace/package-lock.json
+++ /dev/null
@@ -1,58 +0,0 @@
-{
- "name": "workspace",
- "lockfileVersion": 2,
- "requires": true,
- "packages": {
- "": {
- "dependencies": {
- "eslint-plugin-turbo": "../../"
- }
- },
- "../..": {
- "version": "1.9.0",
- "license": "MPL-2.0",
- "devDependencies": {
- "@turbo/test-utils": "workspace:*",
- "@turbo/tsconfig": "workspace:*",
- "@turbo/types": "workspace:*",
- "@turbo/utils": "workspace:*",
- "@types/eslint": "^8.4.5",
- "@types/estree": "^1.0.0",
- "@types/jest": "^27.4.0",
- "@types/node": "^16.11.12",
- "jest": "^27.4.3",
- "json5": "^2.2.1",
- "ts-jest": "^27.1.1",
- "tsup": "^6.2.0",
- "typescript": "^4.7.4"
- },
- "peerDependencies": {
- "eslint": ">6.6.0"
- }
- },
- "node_modules/eslint-plugin-turbo": {
- "resolved": "../..",
- "link": true
- }
- },
- "dependencies": {
- "eslint-plugin-turbo": {
- "version": "file:../..",
- "requires": {
- "@turbo/test-utils": "workspace:*",
- "@turbo/tsconfig": "workspace:*",
- "@turbo/types": "workspace:*",
- "@turbo/utils": "workspace:*",
- "@types/eslint": "^8.4.5",
- "@types/estree": "^1.0.0",
- "@types/jest": "^27.4.0",
- "@types/node": "^16.11.12",
- "jest": "^27.4.3",
- "json5": "^2.2.1",
- "ts-jest": "^27.1.1",
- "tsup": "^6.2.0",
- "typescript": "^4.7.4"
- }
- }
- }
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace/package.json b/packages/eslint-plugin-turbo/__fixtures__/workspace/package.json
deleted file mode 100644
index a1b2929..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "dependencies": {
- "eslint-plugin-turbo": "../../"
- }
-}
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace/peer.js b/packages/eslint-plugin-turbo/__fixtures__/workspace/peer.js
deleted file mode 100644
index 16c8bb0..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace/peer.js
+++ /dev/null
@@ -1 +0,0 @@
-process.env.CI;
diff --git a/packages/eslint-plugin-turbo/__fixtures__/workspace/turbo.json b/packages/eslint-plugin-turbo/__fixtures__/workspace/turbo.json
deleted file mode 100644
index 8079eb2..0000000
--- a/packages/eslint-plugin-turbo/__fixtures__/workspace/turbo.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "globalEnv": ["UNORDERED", "CI"],
- "pipeline": {
- "build": {
- // A workspace's `build` task depends on that workspace's
- // topological dependencies' and devDependencies'
- // `build` tasks being completed first. The `^` symbol
- // indicates an upstream dependency.
- "dependsOn": ["^build"]
- },
- "test": {
- // A workspace's `test` task depends on that workspace's
- // own `build` task being completed first.
- "dependsOn": ["build"],
- "outputs": [],
- // A workspace's `test` task should only be rerun when
- // either a `.tsx` or `.ts` file has changed.
- "inputs": ["src/**/*.tsx", "src/**/*.ts", "test/**/*.ts", "test/**/*.tsx"]
- },
- "lint": {
- // A workspace's `lint` task has no dependencies and
- // can be run whenever.
- "outputs": []
- },
- "deploy": {
- // A workspace's `deploy` task depends on the `build`,
- // `test`, and `lint` tasks of the same workspace
- // being completed.
- "dependsOn": ["build", "test", "lint"],
- "outputs": []
- }
- }
-}
diff --git a/packages/eslint-plugin-turbo/__tests__/cwd.test.ts b/packages/eslint-plugin-turbo/__tests__/cwd.test.ts
deleted file mode 100644
index 15a2695..0000000
--- a/packages/eslint-plugin-turbo/__tests__/cwd.test.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import path from "path";
-import JSON5 from "json5";
-import { execSync } from "child_process";
-import { Schema } from "@turbo/types";
-import { setupTestFixtures } from "@turbo/test-utils";
-
-describe("eslint settings check", () => {
- const { useFixture } = setupTestFixtures({
- directory: path.join(__dirname, "../"),
- });
-
- it("does the right thing for peers", () => {
- const { root: cwd } = useFixture({ fixture: "workspace" });
- execSync(`npm install`, { cwd });
-
- const configString = execSync(`eslint --print-config peer.js`, {
- cwd,
- encoding: "utf8",
- });
- const configJson = JSON5.parse(configString);
-
- expect(configJson.settings).toEqual({
- turbo: { envVars: ["CI", "UNORDERED"] },
- });
- });
-
- it("does the right thing for child dirs", () => {
- const { root } = useFixture({ fixture: "workspace" });
- execSync(`npm install`, { cwd: root });
-
- const cwd = path.join(root, "child");
- const configString = execSync(`eslint --print-config child.js`, {
- cwd,
- encoding: "utf8",
- });
- const configJson = JSON5.parse(configString);
-
- expect(configJson.settings).toEqual({
- turbo: { envVars: ["CI", "UNORDERED"] },
- });
- });
-});
-
-describe("eslint cache is busted", () => {
- const { useFixture } = setupTestFixtures({
- directory: path.join(__dirname, "../"),
- });
-
- it("catches a lint error after changing config", () => {
- expect.assertions(2);
-
- // ensure that we populate the cache with a failure.
- const { root, readJson, write } = useFixture({ fixture: "workspace" });
- execSync(`npm install`, { cwd: root });
-
- const cwd = path.join(root, "child");
- try {
- execSync(`eslint --format=json child.js`, { cwd, encoding: "utf8" });
- } catch (error: any) {
- const outputJson = JSON5.parse(error.stdout);
- expect(outputJson).toMatchObject([
- {
- messages: [
- {
- message:
- "NONEXISTENT is not listed as a dependency in turbo.json",
- },
- ],
- },
- ]);
- }
-
- // change the configuration
- const turboJson = readJson<Schema>("turbo.json");
- if (turboJson && "globalEnv" in turboJson) {
- turboJson.globalEnv = ["CI", "NONEXISTENT"];
- write("turbo.json", JSON5.stringify(turboJson, null, 2));
- }
-
- // test that we invalidated the eslint cache
- const output = execSync(`eslint --format=json child.js`, {
- cwd,
- encoding: "utf8",
- });
- const outputJson = JSON5.parse(output);
- expect(outputJson).toMatchObject([{ errorCount: 0 }]);
- });
-});
diff --git a/packages/eslint-plugin-turbo/__tests__/lib/no-undeclared-env-vars.test.ts b/packages/eslint-plugin-turbo/__tests__/lib/no-undeclared-env-vars.test.ts
deleted file mode 100644
index 5c753dd..0000000
--- a/packages/eslint-plugin-turbo/__tests__/lib/no-undeclared-env-vars.test.ts
+++ /dev/null
@@ -1,433 +0,0 @@
-import { RULES } from "../../lib/constants";
-import rule from "../../lib/rules/no-undeclared-env-vars";
-import { RuleTester } from "eslint";
-import path from "path";
-
-const ruleTester = new RuleTester({
- parserOptions: { ecmaVersion: 2020 },
-});
-
-ruleTester.run(RULES.noUndeclaredEnvVars, rule, {
- valid: [
- {
- code: `
- const { ENV_2 } = process.env;
- `,
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/workspace-configs") },
- ],
- filename: path.join(
- __dirname,
- "../../__fixtures__/workspace-configs/apps/web/index.js"
- ),
- },
- {
- code: `
- const { ENV_1 } = process.env;
- `,
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/workspace-configs") },
- ],
- filename: path.join(
- __dirname,
- "../../__fixtures__/workspace-configs/apps/web/index.js"
- ),
- },
- {
- code: `
- const { ENV_1 } = process.env;
- `,
- options: [{ cwd: "/some/random/path" }],
- },
- {
- code: `
- const { CI } = process.env;
- `,
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/workspace-configs") },
- ],
- filename: path.join(
- __dirname,
- "../../__fixtures__/workspace-configs/apps/web/index.js"
- ),
- },
- {
- code: `
- const { TASK_ENV_KEY, ANOTHER_ENV_KEY } = process.env;
- `,
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- {
- code: `
- const { NEW_STYLE_ENV_KEY, TASK_ENV_KEY } = process.env;
- `,
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- {
- code: `
- const { NEW_STYLE_GLOBAL_ENV_KEY, TASK_ENV_KEY } = process.env;
- `,
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- {
- code: `
- const val = process.env["NEW_STYLE_GLOBAL_ENV_KEY"];
- `,
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- {
- code: `
- const { TASK_ENV_KEY, ANOTHER_ENV_KEY } = process.env;
- `,
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- {
- code: `
- const x = process.env.GLOBAL_ENV_KEY;
- const { TASK_ENV_KEY, GLOBAL_ENV_KEY: renamedX } = process.env;
- `,
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- {
- code: "var x = process.env.GLOBAL_ENV_KEY;",
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- {
- code: "let x = process.env.TASK_ENV_KEY;",
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- {
- code: "const x = process.env.ANOTHER_KEY_VALUE;",
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- allowList: ["^ANOTHER_KEY_[A-Z]+$"],
- },
- ],
- },
- {
- code: `
- var x = process.env.ENV_VAR_ONE;
- var y = process.env.ENV_VAR_TWO;
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- allowList: ["^ENV_VAR_[A-Z]+$"],
- },
- ],
- },
- {
- code: `
- var x = process.env.ENV_VAR_ONE;
- var y = process.env.ENV_VAR_TWO;
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- allowList: ["^ENV_VAR_O[A-Z]+$", "ENV_VAR_TWO"],
- },
- ],
- },
- {
- code: `
- var globalOrTask = process.env.TASK_ENV_KEY || process.env.GLOBAL_ENV_KEY;
- var oneOrTwo = process.env.ENV_VAR_ONE || process.env.ENV_VAR_TWO;
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- allowList: ["^ENV_VAR_[A-Z]+$"],
- },
- ],
- },
- {
- code: `
- () => { return process.env.GLOBAL_ENV_KEY }
- () => { return process.env.TASK_ENV_KEY }
- () => { return process.env.ENV_VAR_ALLOWED }
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- allowList: ["^ENV_VAR_[A-Z]+$"],
- },
- ],
- },
- {
- code: `
- var foo = process?.env.GLOBAL_ENV_KEY
- var foo = process?.env.TASK_ENV_KEY
- var foo = process?.env.ENV_VAR_ALLOWED
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- allowList: ["^ENV_VAR_[A-Z]+$"],
- },
- ],
- },
- {
- code: `
- function test(arg1 = process.env.GLOBAL_ENV_KEY) {};
- function test(arg1 = process.env.TASK_ENV_KEY) {};
- function test(arg1 = process.env.ENV_VAR_ALLOWED) {};
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- allowList: ["^ENV_VAR_[A-Z]+$"],
- },
- ],
- },
- {
- code: `
- (arg1 = process.env.GLOBAL_ENV_KEY) => {}
- (arg1 = process.env.TASK_ENV_KEY) => {}
- (arg1 = process.env.ENV_VAR_ALLOWED) => {}
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- allowList: ["^ENV_VAR_[A-Z]+$"],
- },
- ],
- },
- {
- code: "const getEnv = (key) => process.env[key];",
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- {
- code: "function getEnv(key) { return process.env[key]; }",
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- {
- code: "for (let x of ['ONE', 'TWO', 'THREE']) { console.log(process.env[x]); }",
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- },
- ],
-
- invalid: [
- {
- code: `
- const { ENV_2 } = process.env;
- `,
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/workspace-configs") },
- ],
- filename: path.join(
- __dirname,
- "../../__fixtures__/workspace-configs/apps/docs/index.js"
- ),
- errors: [
- {
- message:
- "ENV_2 is not listed as a dependency in the root turbo.json or workspace (apps/docs) turbo.json",
- },
- ],
- },
- {
- code: "let { X } = process.env;",
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- errors: [{ message: "X is not listed as a dependency in turbo.json" }],
- },
- {
- code: "const { X, Y, Z } = process.env;",
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- errors: [
- { message: "X is not listed as a dependency in turbo.json" },
- { message: "Y is not listed as a dependency in turbo.json" },
- { message: "Z is not listed as a dependency in turbo.json" },
- ],
- },
- {
- code: "const { X, Y: NewName, Z } = process.env;",
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- errors: [
- { message: "X is not listed as a dependency in turbo.json" },
- { message: "Y is not listed as a dependency in turbo.json" },
- { message: "Z is not listed as a dependency in turbo.json" },
- ],
- },
- {
- code: "var x = process.env.NOT_THERE;",
- options: [
- { cwd: path.join(__dirname, "../../__fixtures__/configs/single") },
- ],
- errors: [
- {
- message: "NOT_THERE is not listed as a dependency in turbo.json",
- },
- ],
- },
- {
- code: "var x = process.env.KEY;",
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- allowList: ["^ANOTHER_KEY_[A-Z]+$"],
- },
- ],
- errors: [{ message: "KEY is not listed as a dependency in turbo.json" }],
- },
- {
- code: `
- var globalOrTask = process.env.TASK_ENV_KEY_NEW || process.env.GLOBAL_ENV_KEY_NEW;
- var oneOrTwo = process.env.ENV_VAR_ONE || process.env.ENV_VAR_TWO;
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- },
- ],
- errors: [
- {
- message:
- "TASK_ENV_KEY_NEW is not listed as a dependency in turbo.json",
- },
- {
- message:
- "GLOBAL_ENV_KEY_NEW is not listed as a dependency in turbo.json",
- },
- {
- message: "ENV_VAR_ONE is not listed as a dependency in turbo.json",
- },
- {
- message: "ENV_VAR_TWO is not listed as a dependency in turbo.json",
- },
- ],
- },
- {
- code: `
- () => { return process.env.GLOBAL_ENV_KEY_NEW }
- () => { return process.env.TASK_ENV_KEY_NEW }
- () => { return process.env.ENV_VAR_NOT_ALLOWED }
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- },
- ],
- errors: [
- {
- message:
- "GLOBAL_ENV_KEY_NEW is not listed as a dependency in turbo.json",
- },
- {
- message:
- "TASK_ENV_KEY_NEW is not listed as a dependency in turbo.json",
- },
- {
- message:
- "ENV_VAR_NOT_ALLOWED is not listed as a dependency in turbo.json",
- },
- ],
- },
- {
- code: `
- var foo = process?.env.GLOBAL_ENV_KEY_NEW
- var foo = process?.env.TASK_ENV_KEY_NEW
- var foo = process?.env.ENV_VAR_NOT_ALLOWED
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- },
- ],
- errors: [
- {
- message:
- "GLOBAL_ENV_KEY_NEW is not listed as a dependency in turbo.json",
- },
- {
- message:
- "TASK_ENV_KEY_NEW is not listed as a dependency in turbo.json",
- },
- {
- message:
- "ENV_VAR_NOT_ALLOWED is not listed as a dependency in turbo.json",
- },
- ],
- },
- {
- code: `
- function test(arg1 = process.env.GLOBAL_ENV_KEY_NEW) {};
- function test(arg1 = process.env.TASK_ENV_KEY_NEW) {};
- function test(arg1 = process.env.ENV_VAR_NOT_ALLOWED) {};
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- },
- ],
- errors: [
- {
- message:
- "GLOBAL_ENV_KEY_NEW is not listed as a dependency in turbo.json",
- },
- {
- message:
- "TASK_ENV_KEY_NEW is not listed as a dependency in turbo.json",
- },
- {
- message:
- "ENV_VAR_NOT_ALLOWED is not listed as a dependency in turbo.json",
- },
- ],
- },
- {
- code: `
- (arg1 = process.env.GLOBAL_ENV_KEY_NEW) => {}
- (arg1 = process.env.TASK_ENV_KEY_NEW) => {}
- (arg1 = process.env.ENV_VAR_NOT_ALLOWED) => {}
- `,
- options: [
- {
- cwd: path.join(__dirname, "../../__fixtures__/configs/single"),
- },
- ],
- errors: [
- {
- message:
- "GLOBAL_ENV_KEY_NEW is not listed as a dependency in turbo.json",
- },
- {
- message:
- "TASK_ENV_KEY_NEW is not listed as a dependency in turbo.json",
- },
- {
- message:
- "ENV_VAR_NOT_ALLOWED is not listed as a dependency in turbo.json",
- },
- ],
- },
- ],
-});
diff --git a/packages/eslint-plugin-turbo/docs/rules/no-undeclared-env-vars.md b/packages/eslint-plugin-turbo/docs/rules/no-undeclared-env-vars.md
deleted file mode 100644
index 049d7af..0000000
--- a/packages/eslint-plugin-turbo/docs/rules/no-undeclared-env-vars.md
+++ /dev/null
@@ -1,74 +0,0 @@
-# Ensure all environment variables are correctly included in cache keys (`no-undeclared-env-vars`)
-
-Ensures that all detectable usage of environment variables are correctly included in cache keys. This ensures build outputs remain correctly cacheable across environments.
-
-## Rule Details
-
-This rule aims to prevent users from forgetting to include an environment variable in their `turbo.json` configuration.
-
-The following examples assume the following code:
-
-```js
-const client = MyAPI({ token: process.env.MY_API_TOKEN });
-```
-
-Examples of **incorrect** code for this rule:
-
-```json
-{
- "pipeline": {
- "build": {
- "dependsOn": ["^build"],
- "outputs": ["dist/**", ".next/**", "!.next/cache/**"]
- },
- "lint": {},
- "dev": {
- "cache": false
- }
- }
-}
-```
-
-Examples of **correct** code for this rule:
-
-```json
-{
- "globalEnv": ["MY_API_TOKEN"],
- "pipeline": {
- "build": {
- "dependsOn": ["^build"],
- "outputs": ["dist/**", ".next/**", "!.next/cache/**"]
- },
- "lint": {},
- "dev": {
- "cache": false
- }
- }
-}
-```
-
-```json
-{
- "pipeline": {
- "build": {
- "dependsOn": ["^build"],
- "env": ["MY_API_TOKEN"],
- "outputs": ["dist/**", ".next/**", "!.next/cache/**"]
- },
- "lint": {},
- "dev": {
- "cache": false
- }
- }
-}
-```
-
-## Options
-
-| Option | Required | Default | Details | Example |
-| ----------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
-| `allowList` | No | [] | An array of strings (or regular expressions) to exclude. NOTE: an env variable should only be excluded if it has no effect on build outputs | `["MY_API_TOKEN", "^MY_ENV_PREFIX_[A-Z]+$"]` |
-
-## Further Reading
-
-- [Altering Caching Based on Environment Variables](https://turbo.build/repo/docs/core-concepts/caching#altering-caching-based-on-environment-variables)
diff --git a/packages/eslint-plugin-turbo/jest.config.js b/packages/eslint-plugin-turbo/jest.config.js
deleted file mode 100644
index 102773e..0000000
--- a/packages/eslint-plugin-turbo/jest.config.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
- roots: ["<rootDir>"],
- transform: {
- "^.+\\.tsx?$": "ts-jest",
- },
- testPathIgnorePatterns: ["/__fixtures__/"],
- coveragePathIgnorePatterns: ["/__fixtures__/"],
- moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
- modulePathIgnorePatterns: ["<rootDir>/node_modules", "<rootDir>/dist"],
- preset: "ts-jest",
-};
diff --git a/packages/eslint-plugin-turbo/lib/configs/recommended.ts b/packages/eslint-plugin-turbo/lib/configs/recommended.ts
deleted file mode 100644
index e247503..0000000
--- a/packages/eslint-plugin-turbo/lib/configs/recommended.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { RULES } from "../constants";
-import getEnvVarDependencies from "../utils/getEnvVarDependencies";
-
-// Add the environment variables into the ESLint incremental cache key.
-const envVars = getEnvVarDependencies({
- cwd: process.cwd(),
-});
-const settings = {
- turbo: {
- envVars: envVars
- ? Object.values(envVars)
- .flatMap((s) => Array.from(s))
- .sort()
- : [],
- },
-};
-
-const config = {
- settings,
- plugins: ["turbo"],
- rules: {
- [`turbo/${RULES.noUndeclaredEnvVars}`]: "error",
- },
-};
-
-export default config;
diff --git a/packages/eslint-plugin-turbo/lib/constants.ts b/packages/eslint-plugin-turbo/lib/constants.ts
deleted file mode 100644
index 5af2e6f..0000000
--- a/packages/eslint-plugin-turbo/lib/constants.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-const RULES = {
- noUndeclaredEnvVars: `no-undeclared-env-vars`,
-};
-
-export { RULES };
diff --git a/packages/eslint-plugin-turbo/lib/index.ts b/packages/eslint-plugin-turbo/lib/index.ts
deleted file mode 100644
index e7f113c..0000000
--- a/packages/eslint-plugin-turbo/lib/index.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { RULES } from "./constants";
-
-// rules
-import noUndeclaredEnvVars from "./rules/no-undeclared-env-vars";
-
-// configs
-import recommended from "./configs/recommended";
-
-const rules = {
- [RULES.noUndeclaredEnvVars]: noUndeclaredEnvVars,
-};
-
-const configs = {
- recommended,
-};
-
-export { rules, configs };
diff --git a/packages/eslint-plugin-turbo/lib/rules/no-undeclared-env-vars.ts b/packages/eslint-plugin-turbo/lib/rules/no-undeclared-env-vars.ts
deleted file mode 100644
index 372d21a..0000000
--- a/packages/eslint-plugin-turbo/lib/rules/no-undeclared-env-vars.ts
+++ /dev/null
@@ -1,187 +0,0 @@
-import type { Rule } from "eslint";
-import path from "path";
-import { Node, MemberExpression } from "estree";
-import { RULES } from "../constants";
-import getEnvVarDependencies from "../utils/getEnvVarDependencies";
-
-const meta: Rule.RuleMetaData = {
- type: "problem",
- docs: {
- description:
- "Do not allow the use of `process.env` without including the env key in any turbo.json",
- category: "Configuration Issues",
- recommended: true,
- url: `https://github.com/vercel/turbo/tree/main/packages/eslint-plugin-turbo/docs/rules/${RULES.noUndeclaredEnvVars}.md`,
- },
- schema: [
- {
- type: "object",
- default: {},
- additionalProperties: false,
- properties: {
- // override cwd, primarily exposed for easier testing
- cwd: {
- require: false,
- type: "string",
- },
- allowList: {
- default: [],
- type: "array",
- items: {
- type: "string",
- },
- },
- },
- },
- ],
-};
-
-/**
- * Normalize the value of the cwd
- * Extracted from eslint
- * SPDX-License-Identifier: MIT
- */
-function normalizeCwd(
- cwd: string | undefined,
- options: Array<any>
-): string | undefined {
- if (options?.[0]?.cwd) {
- return options[0].cwd;
- }
-
- if (cwd) {
- return cwd;
- }
- if (typeof process === "object") {
- return process.cwd();
- }
-
- return undefined;
-}
-
-function create(context: Rule.RuleContext): Rule.RuleListener {
- const { options, getPhysicalFilename } = context;
- const allowList: Array<string> = options?.[0]?.allowList || [];
- const regexAllowList: Array<RegExp> = [];
- allowList.forEach((allowed) => {
- try {
- regexAllowList.push(new RegExp(allowed));
- } catch (err) {
- // log the error, but just move on without this allowList entry
- console.error(`Unable to convert "${allowed}" to regex`);
- }
- });
-
- const cwd = normalizeCwd(
- context.getCwd ? context.getCwd() : undefined,
- options
- );
- const filePath = getPhysicalFilename();
- const allTurboVars = getEnvVarDependencies({
- cwd,
- });
-
- // if allTurboVars is null, something went wrong reading from the turbo config
- // (this is different from finding a config with no env vars present, which would
- // return an empty set) - so there is no point continuing if we have nothing to check against
- if (!allTurboVars) {
- // return of {} bails early from a rule check
- return {};
- }
-
- const globalTurboVars = allTurboVars["//"];
- const hasWorkspaceConfigs = Object.keys(allTurboVars).length > 1;
-
- // find any workspace configs that match the current file path
- // find workspace config (if any) that match the current file path
- const workspaceKey = Object.keys(allTurboVars).find(
- (workspacePath) => filePath !== "//" && filePath.startsWith(workspacePath)
- );
-
- let workspaceTurboVars: Set<string> | null = null;
- if (workspaceKey) {
- workspaceTurboVars = allTurboVars[workspaceKey];
- }
-
- const checkKey = (node: Node, envKey?: string) => {
- if (
- envKey &&
- !globalTurboVars.has(envKey) &&
- !regexAllowList.some((regex) => regex.test(envKey))
- ) {
- // if we have a workspace config, check that too
- if (workspaceTurboVars && workspaceTurboVars.has(envKey)) {
- return {};
- } else {
- let message = `{{ envKey }} is not listed as a dependency in ${
- hasWorkspaceConfigs ? "root turbo.json" : "turbo.json"
- }`;
- if (workspaceKey && workspaceTurboVars) {
- if (cwd) {
- // if we have a cwd, we can provide a relative path to the workspace config
- message = `{{ envKey }} is not listed as a dependency in the root turbo.json or workspace (${path.relative(
- cwd,
- workspaceKey
- )}) turbo.json`;
- } else {
- message = `{{ envKey }} is not listed as a dependency in the root turbo.json or workspace turbo.json`;
- }
- }
-
- context.report({
- node,
- message,
- data: { envKey },
- });
- }
- }
- };
-
- const isComputed = (
- node: MemberExpression & Rule.NodeParentExtension
- ): boolean => {
- if ("computed" in node.parent) {
- return node.parent.computed;
- }
-
- return false;
- };
-
- return {
- MemberExpression(node) {
- // we only care about complete process env declarations and non-computed keys
- if (
- "name" in node.object &&
- "name" in node.property &&
- !isComputed(node)
- ) {
- const objectName = node.object.name;
- const propertyName = node.property.name;
-
- // we're doing something with process.env
- if (objectName === "process" && propertyName === "env") {
- // destructuring from process.env
- if ("id" in node.parent && node.parent.id?.type === "ObjectPattern") {
- const values = node.parent.id.properties.values();
- Array.from(values).forEach((item) => {
- if ("key" in item && "name" in item.key) {
- checkKey(node.parent, item.key.name);
- }
- });
- }
-
- // accessing key on process.env
- else if (
- "property" in node.parent &&
- "name" in node.parent.property
- ) {
- checkKey(node.parent, node.parent.property?.name);
- }
- }
- }
- },
- };
-}
-
-const rule = { create, meta };
-export default rule;
diff --git a/packages/eslint-plugin-turbo/lib/utils/getEnvVarDependencies.ts b/packages/eslint-plugin-turbo/lib/utils/getEnvVarDependencies.ts
deleted file mode 100644
index a57e5eb..0000000
--- a/packages/eslint-plugin-turbo/lib/utils/getEnvVarDependencies.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import { getTurboConfigs } from "@turbo/utils";
-
-function findDependsOnEnvVars({
- dependencies,
-}: {
- dependencies?: Array<string>;
-}) {
- if (dependencies) {
- return (
- dependencies
- // filter for dep env vars
- .filter((dep) => dep.startsWith("$"))
- // remove leading $
- .map((envVar) => envVar.slice(1, envVar.length))
- );
- }
-
- return [];
-}
-
-function getEnvVarDependencies({
- cwd,
-}: {
- cwd: string | undefined;
-}): Record<string, Set<string>> | null {
- const turboConfigs = getTurboConfigs(cwd);
-
- if (!turboConfigs.length) {
- return null;
- }
-
- const envVars: Record<string, Set<string>> = {
- "//": new Set(),
- };
-
- turboConfigs.forEach((turboConfig) => {
- const { config, workspacePath, isRootConfig } = turboConfig;
-
- const key = isRootConfig ? "//" : workspacePath;
- if (!envVars[key]) {
- envVars[key] = new Set();
- }
-
- // handle globals
- if (!("extends" in config)) {
- const { globalDependencies = [], globalEnv = [] } = config;
-
- const keys = [
- ...findDependsOnEnvVars({
- dependencies: globalDependencies,
- }),
- ...globalEnv,
- ];
- keys.forEach((k) => envVars[key].add(k));
- }
-
- // handle pipelines
- const { pipeline = {} } = config;
- Object.values(pipeline).forEach(({ env, dependsOn }) => {
- if (dependsOn) {
- findDependsOnEnvVars({ dependencies: dependsOn }).forEach((k) =>
- envVars[key].add(k)
- );
- }
-
- if (env) {
- env.forEach((k) => envVars[key].add(k));
- }
- });
- });
-
- return envVars;
-}
-
-export default getEnvVarDependencies;
diff --git a/packages/eslint-plugin-turbo/package.json b/packages/eslint-plugin-turbo/package.json
deleted file mode 100644
index d19eef2..0000000
--- a/packages/eslint-plugin-turbo/package.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "name": "eslint-plugin-turbo",
- "version": "1.9.4-canary.2",
- "description": "ESLint plugin for Turborepo",
- "keywords": [
- "turbo",
- "eslint",
- "turborepo",
- "eslintplugin",
- "eslint-plugin"
- ],
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/turbo",
- "directory": "packages/eslint-plugin-turbo"
- },
- "bugs": {
- "url": "https://github.com/vercel/turbo/issues"
- },
- "author": "Vercel",
- "main": "./dist/index.js",
- "files": [
- "dist/**"
- ],
- "scripts": {
- "release": "pnpm build && pnpm publish",
- "test": "jest",
- "build": "tsup",
- "check-types": "tsc --noEmit",
- "lint": "eslint lib/**/*.ts"
- },
- "devDependencies": {
- "@types/eslint": "^8.4.5",
- "@types/estree": "^1.0.0",
- "@types/jest": "^27.4.0",
- "@types/node": "^16.11.12",
- "jest": "^27.4.3",
- "json5": "^2.2.1",
- "ts-jest": "^27.1.1",
- "@turbo/tsconfig": "workspace:*",
- "tsup": "^6.2.0",
- "@turbo/test-utils": "workspace:*",
- "@turbo/types": "workspace:*",
- "@turbo/utils": "workspace:*",
- "typescript": "^4.7.4"
- },
- "peerDependencies": {
- "eslint": ">6.6.0"
- },
- "license": "MPL-2.0"
-}
diff --git a/packages/eslint-plugin-turbo/tsconfig.json b/packages/eslint-plugin-turbo/tsconfig.json
deleted file mode 100644
index 0620a3c..0000000
--- a/packages/eslint-plugin-turbo/tsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "extends": "@turbo/tsconfig/library.json",
- "compilerOptions": {
- "rootDir": "."
- }
-}
diff --git a/packages/eslint-plugin-turbo/tsup.config.ts b/packages/eslint-plugin-turbo/tsup.config.ts
deleted file mode 100644
index bbda8cb..0000000
--- a/packages/eslint-plugin-turbo/tsup.config.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { defineConfig, Options } from "tsup";
-
-export default defineConfig((options: Options) => ({
- entry: ["lib/index.ts"],
- clean: true,
- minify: true,
- ...options,
-}));
diff --git a/packages/eslint-plugin-turbo/turbo.json b/packages/eslint-plugin-turbo/turbo.json
deleted file mode 100644
index f86a4db..0000000
--- a/packages/eslint-plugin-turbo/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "../../docs/public/schema.json",
- "extends": ["//"],
- "pipeline": {
- "test": {
- "dependsOn": ["build"]
- }
- }
-}
diff --git a/packages/node-module-trace/package.json b/packages/node-module-trace/package.json
deleted file mode 100644
index 0494edc..0000000
--- a/packages/node-module-trace/package.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "name": "@vercel/experimental-nft",
- "version": "0.0.5-alpha.0",
- "description": "Node.js module trace",
- "license": "MPL-2.0",
- "alias": "node-file-trace",
- "publishConfig": {
- "access": "public"
- }
-}
diff --git a/packages/tsconfig/README.md b/packages/tsconfig/README.md
deleted file mode 100644
index c78d9de..0000000
--- a/packages/tsconfig/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# `tsconfig`
-
-Collection of internal tsconfigs shared between [turborepo/packages/](https://github.com/vercel/turbo/tree/main/packages)
diff --git a/packages/tsconfig/base.json b/packages/tsconfig/base.json
deleted file mode 100644
index aab01c7..0000000
--- a/packages/tsconfig/base.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "$schema": "https://json.schemastore.org/tsconfig",
- "display": "Default",
- "compilerOptions": {
- "composite": false,
- "declaration": true,
- "declarationMap": true,
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
- "inlineSources": false,
- "isolatedModules": true,
- "moduleResolution": "node",
- "noUnusedLocals": false,
- "noUnusedParameters": false,
- "preserveWatchOutput": true,
- "skipLibCheck": true,
- "strict": true
- },
- "exclude": ["node_modules", "dist"]
-}
diff --git a/packages/tsconfig/library.json b/packages/tsconfig/library.json
deleted file mode 100644
index 66db367..0000000
--- a/packages/tsconfig/library.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "extends": "./base.json",
- "display": "TS Library",
- "compilerOptions": {
- "lib": ["ES2019"],
- "target": "ES2019",
- "skipLibCheck": true,
- "resolveJsonModule": true,
- "outDir": "dist",
- "allowJs": false
- }
-}
diff --git a/packages/tsconfig/package.json b/packages/tsconfig/package.json
deleted file mode 100644
index 913e344..0000000
--- a/packages/tsconfig/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "@turbo/tsconfig",
- "version": "0.0.0",
- "private": true
-}
diff --git a/packages/turbo-codemod/LICENSE b/packages/turbo-codemod/LICENSE
deleted file mode 100644
index fa0086a..0000000
--- a/packages/turbo-codemod/LICENSE
+++ /dev/null
@@ -1,373 +0,0 @@
-Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
- means each individual or legal entity that creates, contributes to
- the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
- means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
- means Source Code Form to which the initial Contributor has attached
- the notice in Exhibit A, the Executable Form of such Source Code
- Form, and Modifications of such Source Code Form, in each case
- including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- (a) that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-
- (b) that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-1.6. "Executable Form"
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
- means a work that combines Covered Software with other material, in
- a separate file or files, that is not Covered Software.
-
-1.8. "License"
- means this document.
-
-1.9. "Licensable"
- means having the right to grant, to the maximum extent possible,
- whether at the time of the initial grant or subsequently, any and
- all of the rights conveyed by this License.
-
-1.10. "Modifications"
- means any of the following:
-
- (a) any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-
- (b) any new file in Source Code Form that contains any Covered
- Software.
-
-1.11. "Patent Claims" of a Contributor
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-1.12. "Secondary License"
- means either the GNU General Public License, Version 2.0, the GNU
- Lesser General Public License, Version 2.1, the GNU Affero General
- Public License, Version 3.0, or any later versions of those
- licenses.
-
-1.13. "Source Code Form"
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that
- controls, is controlled by, or is under common control with You. For
- purposes of this definition, "control" means (a) the power, direct
- or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or (b) ownership of more than
- fifty percent (50%) of the outstanding shares or beneficial
- ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
- or
-
-(b) for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
- Form, as described in Section 3.1, and You must inform recipients of
- the Executable Form how they can obtain a copy of such Source Code
- Form by reasonable means in a timely manner, at a charge no more
- than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-* *
-* 6. Disclaimer of Warranty *
-* ------------------------- *
-* *
-* Covered Software is provided under this License on an "as is" *
-* basis, without warranty of any kind, either expressed, implied, or *
-* statutory, including, without limitation, warranties that the *
-* Covered Software is free of defects, merchantable, fit for a *
-* particular purpose or non-infringing. The entire risk as to the *
-* quality and performance of the Covered Software is with You. *
-* Should any Covered Software prove defective in any respect, You *
-* (not any Contributor) assume the cost of any necessary servicing, *
-* repair, or correction. This disclaimer of warranty constitutes an *
-* essential part of this License. No use of any Covered Software is *
-* authorized under this License except under this disclaimer. *
-* *
-************************************************************************
-
-************************************************************************
-* *
-* 7. Limitation of Liability *
-* -------------------------- *
-* *
-* Under no circumstances and under no legal theory, whether tort *
-* (including negligence), contract, or otherwise, shall any *
-* Contributor, or anyone who distributes Covered Software as *
-* permitted above, be liable to You for any direct, indirect, *
-* special, incidental, or consequential damages of any character *
-* including, without limitation, damages for lost profits, loss of *
-* goodwill, work stoppage, computer failure or malfunction, or any *
-* and all other commercial damages or losses, even if such party *
-* shall have been informed of the possibility of such damages. This *
-* limitation of liability shall not apply to liability for death or *
-* personal injury resulting from such party's negligence to the *
-* extent applicable law prohibits such limitation. Some *
-* jurisdictions do not allow the exclusion or limitation of *
-* incidental or consequential damages, so this exclusion and *
-* limitation may not apply to You. *
-* *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0. \ No newline at end of file
diff --git a/packages/turbo-codemod/README.md b/packages/turbo-codemod/README.md
deleted file mode 100644
index 5545561..0000000
--- a/packages/turbo-codemod/README.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# Turborepo Codemods
-
-Turborepo provides Codemod transformations to help upgrade your Turborepo codebase.
-
-Codemods are transformations that run on your codebase programmatically. This allows for a large amount of changes to be applied without having to manually go through every file.
-
-## Commands
-
-### `migrate`
-
-Updates your Turborepo codebase to the specified version of Turborepo (defaults to the latest), running any required codemods, and installing the new version of Turborepo.
-
-```
-Usage: @turbo/codemod migrate|update [options] [path]
-
-Migrate a project to the latest version of Turborepo
-
-Arguments:
- path Directory where the transforms should be applied
-
-Options:
- --from <version> Specify the version to migrate from (default: current version)
- --to <version> Specify the version to migrate to (default: latest)
- --install Install new version of turbo after migration (default: true)
- --force Bypass Git safety checks and forcibly run codemods (default: false)
- --dry Dry run (no changes are made to files) (default: false)
- --print Print transformed files to your terminal (default: false)
- -h, --help display help for command
-```
-
-### `transform` (default)
-
-Runs a single codemod on your codebase. This is the default command, and can be omitted.
-
-```
-Usage: @turbo/codemod transform [options] [transform] [path]
- @turbo/codemod [options] [transform] [path]
-
-Apply a single code transformation to a project
-
-Arguments:
- transform The transformer to run
- path Directory where the transforms should be applied
-
-Options:
- --force Bypass Git safety checks and forcibly run codemods (default: false)
- --list List all available transforms (default: false)
- --dry Dry run (no changes are made to files) (default: false)
- --print Print transformed files to your terminal (default: false)
- -h, --help display help for command
-```
-
-## Developing
-
-To add a new transformer, run `pnpm add-transformer`, or [view the complete guide](./src/transforms/README.md).
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/has-package-manager/package.json b/packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/has-package-manager/package.json
deleted file mode 100644
index d6edac5..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/has-package-manager/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "has-package-manager",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/no-package-manager/package.json b/packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/no-package-manager/package.json
deleted file mode 100644
index 2e28fe4..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/no-package-manager/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "name": "no-package-manager",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {}
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/wrong-package-manager/package.json b/packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/wrong-package-manager/package.json
deleted file mode 100644
index f58aca2..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/add-package-manager/wrong-package-manager/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "has-package-manager",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "turbo@1.7.0"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/both-configs/package.json b/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/both-configs/package.json
deleted file mode 100644
index c4606fa..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/both-configs/package.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "name": "both-configs",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3",
- "turbo": {
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "package-only": {
- "cache": false,
- "persistent": true
- },
- "build": {
- "outputs": [
- ".next/**",
- "!.next/cache/**"
- ]
- },
- "lint": {
- "outputs": []
- },
- "dev": {
- "cache": false
- }
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/both-configs/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/both-configs/turbo.json
deleted file mode 100644
index e6eb652..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/both-configs/turbo.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "turbo-only": {
- "cache": false,
- "persistent": true
- },
- "build": {
- "outputs": [".next/**", "!.next/cache/**"]
- },
- "lint": {
- "outputs": []
- },
- "dev": {
- "cache": false
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-package-json-config/package.json b/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-package-json-config/package.json
deleted file mode 100644
index b965b7d..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-package-json-config/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "no-turbo-json-config",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-package-json-file/a-random-file.txt b/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-package-json-file/a-random-file.txt
deleted file mode 100644
index 7488fec..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-package-json-file/a-random-file.txt
+++ /dev/null
@@ -1 +0,0 @@
-Nothing exists here
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-turbo-json-config/package.json b/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-turbo-json-config/package.json
deleted file mode 100644
index 7754c7d..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/no-turbo-json-config/package.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "name": "no-turbo-json-config",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3",
- "turbo": {
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "build": {
- "outputs": [
- ".next/**",
- "!.next/cache/**"
- ]
- },
- "lint": {
- "outputs": []
- },
- "dev": {
- "cache": false
- }
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/turbo-json-config/package.json b/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/turbo-json-config/package.json
deleted file mode 100644
index a48d0ec..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/turbo-json-config/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "both-configs",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/turbo-json-config/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/turbo-json-config/turbo.json
deleted file mode 100644
index e6eb652..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/create-turbo-config/turbo-json-config/turbo.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "turbo-only": {
- "cache": false,
- "persistent": true
- },
- "build": {
- "outputs": [".next/**", "!.next/cache/**"]
- },
- "lint": {
- "outputs": []
- },
- "dev": {
- "cache": false
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-deps/package.json b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-deps/package.json
deleted file mode 100644
index b632eef..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-deps/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "no-turbo",
- "version": "0.0.0"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-package/README.md b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-package/README.md
deleted file mode 100644
index 64355e7..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-package/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Nothing here
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-turbo/package.json b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-turbo/package.json
deleted file mode 100644
index 524df50..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/no-turbo/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "name": "no-turbo",
- "version": "0.0.0",
- "dependencies": {},
- "devDependencies": {}
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/normal-workspaces-dev-install/package.json b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/normal-workspaces-dev-install/package.json
deleted file mode 100644
index f5b2368..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/normal-workspaces-dev-install/package.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "name": "normal-workspaces",
- "version": "0.0.0",
- "workspaces": [
- "apps/*",
- "packages/*"
- ],
- "dependencies": {},
- "devDependencies": {
- "turbo": "1.0.0"
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/normal-workspaces/package.json b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/normal-workspaces/package.json
deleted file mode 100644
index 6344a38..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/normal-workspaces/package.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "name": "normal-workspaces",
- "version": "0.0.0",
- "workspaces": [
- "apps/*",
- "packages/*"
- ],
- "dependencies": {
- "turbo": "1.0.0"
- },
- "devDependencies": {}
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces-dev-install/package.json b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces-dev-install/package.json
deleted file mode 100644
index 5c12f28..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces-dev-install/package.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "pnpm-workspaces",
- "version": "0.0.0",
- "dependencies": {},
- "devDependencies": {
- "turbo": "1.0.0"
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces-dev-install/pnpm-workspace.yaml b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces-dev-install/pnpm-workspace.yaml
deleted file mode 100644
index 3ff5faa..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces-dev-install/pnpm-workspace.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-packages:
- - "apps/*"
- - "packages/*"
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces/package.json b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces/package.json
deleted file mode 100644
index fedeb8d..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces/package.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "pnpm-workspaces",
- "version": "0.0.0",
- "dependencies": {
- "turbo": "1.0.0"
- },
- "devDependencies": {}
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces/pnpm-workspace.yaml b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces/pnpm-workspace.yaml
deleted file mode 100644
index 3ff5faa..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/pnpm-workspaces/pnpm-workspace.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-packages:
- - "apps/*"
- - "packages/*"
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/single-package-dev-install/package.json b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/single-package-dev-install/package.json
deleted file mode 100644
index 38bd995..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/single-package-dev-install/package.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "single-package-dev-install",
- "version": "0.0.0",
- "dependencies": {},
- "devDependencies": {
- "turbo": "1.0.0"
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/single-package/package.json b/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/single-package/package.json
deleted file mode 100644
index 0fd3453..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/get-turbo-upgrade-command/single-package/package.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "single-package",
- "version": "0.0.0",
- "dependencies": {
- "turbo": "1.0.0"
- },
- "devDependencies": {}
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/env-dependencies/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/env-dependencies/turbo.json
deleted file mode 100644
index bb3e248..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/env-dependencies/turbo.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "globalDependencies": ["$NEXT_PUBLIC_API_KEY", "$STRIPE_API_KEY", ".env"],
- "pipeline": {
- "build": {
- "outputs": [".next/**", "!.next/cache/**"],
- "dependsOn": ["^build", "$PROD_API_KEY"]
- },
- "lint": {
- "outputs": [],
- "dependsOn": ["$IS_CI"]
- },
- "test": {
- "outputs": [],
- "dependsOn": ["$IS_CI", "test"]
- },
- "dev": {
- "cache": false
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/migrated-env-dependencies/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/migrated-env-dependencies/turbo.json
deleted file mode 100644
index 9217af6..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/migrated-env-dependencies/turbo.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "globalDependencies": [],
- "globalEnv": ["NEXT_PUBLIC_API_KEY", "STRIPE_API_KEY"],
- "pipeline": {
- "build": {
- "dependsOn": ["^build"],
- "env": ["PROD_API_KEY"],
- "outputs": [".next/**", "!.next/cache/**"]
- },
- "dev": {
- "cache": false
- },
- "lint": {
- "dependsOn": [],
- "env": ["IS_CI"],
- "outputs": []
- },
- "test": {
- "dependsOn": ["test"],
- "env": ["IS_CI"],
- "outputs": []
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/no-turbo-json/package.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/no-turbo-json/package.json
deleted file mode 100644
index 83443be..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/no-turbo-json/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "no-turbo-json",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/old-config/package.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/old-config/package.json
deleted file mode 100644
index 6774d3c..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/old-config/package.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "migrate-env-var-dependencies-old-config",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3",
- "turbo": {
- "pipeline": {
- "build-one": {
- "outputs": [
- "foo"
- ]
- },
- "build-two": {
- "outputs": []
- },
- "build-three": {}
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/old-config/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/old-config/turbo.json
deleted file mode 100644
index b0f6150..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/old-config/turbo.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "build-one": {
- "outputs": ["foo"]
- },
- "build-two": {
- "outputs": []
- },
- "build-three": {}
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/index.js b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/index.js
deleted file mode 100644
index 4de53f5..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function docs() {
- if (process.env.ENV_1 === undefined) {
- return "does not exist";
- }
- return "exists";
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/package.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/package.json
deleted file mode 100644
index 82f9a44..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "docs",
- "version": "1.0.0"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/turbo.json
deleted file mode 100644
index a3713ef..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/docs/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {
- "env": ["ENV_3"]
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/index.js b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/index.js
deleted file mode 100644
index bfd3ab8..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function web() {
- if (!process.env.ENV_2) {
- return "bar";
- }
- return "foo";
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/package.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/package.json
deleted file mode 100644
index d8a83ed..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "web",
- "version": "1.0.0"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/turbo.json
deleted file mode 100644
index dd69c31..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/apps/web/turbo.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {
- // old
- "dependsOn": ["build", "$ENV_2"],
- // new
- "env": ["ENV_1"]
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/package.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/package.json
deleted file mode 100644
index c6616a6..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "private": true,
- "workspaces": [
- "apps/*",
- "packages/*"
- ],
- "scripts": {
- "build": "turbo run build"
- },
- "devDependencies": {
- "turbo": "latest"
- },
- "packageManager": "yarn@1.22.19"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/index.js b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/index.js
deleted file mode 100644
index dee5e80..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function foo() {
- if (!process.env.IS_SERVER) {
- return "bar";
- }
- return "foo";
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/package.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/package.json
deleted file mode 100644
index 7cb7cf1..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "ui",
- "version": "1.0.0"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/turbo.json
deleted file mode 100644
index 6ce7b30..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/packages/ui/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {
- "dependsOn": ["$IS_SERVER"]
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/turbo.json
deleted file mode 100644
index 718e461..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate-env-var-dependencies/workspace-configs/turbo.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "globalDependencies": ["$NEXT_PUBLIC_API_KEY", "$STRIPE_API_KEY", ".env"],
- "pipeline": {
- "build": {
- "outputs": [".next/**", "!.next/cache/**"],
- "dependsOn": ["^build", "$PROD_API_KEY"]
- },
- "lint": {
- "outputs": [],
- "dependsOn": ["$IS_TEST"]
- },
- "test": {
- "outputs": [],
- "dependsOn": ["$IS_CI", "test"]
- },
- "dev": {
- "cache": false
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate/no-repo/README.md b/packages/turbo-codemod/__tests__/__fixtures__/migrate/no-repo/README.md
deleted file mode 100644
index 64355e7..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate/no-repo/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Nothing here
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/migrate/old-turbo/package.json b/packages/turbo-codemod/__tests__/__fixtures__/migrate/old-turbo/package.json
deleted file mode 100644
index 62959b8..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/migrate/old-turbo/package.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "name": "no-turbo-json",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {
- "turbo": "1.0.0"
- },
- "turbo": {
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "build": {
- "outputs": [
- ".next/**",
- "!.next/cache/**"
- ]
- },
- "lint": {
- "outputs": []
- },
- "test": {},
- "dev": {
- "cache": false
- }
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/invalid-outputs/package.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/invalid-outputs/package.json
deleted file mode 100644
index 6b50aac..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/invalid-outputs/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "invalid-outputs",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/invalid-outputs/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/invalid-outputs/turbo.json
deleted file mode 100644
index 33c2b93..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/invalid-outputs/turbo.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "build-one": {
- "outputs": ["foo"]
- },
- "build-two": {
- "outputs": []
- },
- "build-three": {},
- "garbage-in-numeric-0": {
- "outputs": 0
- },
- "garbage-in-numeric": {
- "outputs": 42
- },
- "garbage-in-string": {
- "outputs": "string"
- },
- "garbage-in-empty-string": {
- "outputs": ""
- },
- "garbage-in-null": {
- "outputs": null
- },
- "garbage-in-false": {
- "outputs": false
- },
- "garbage-in-true": {
- "outputs": true
- },
- "garbage-in-object": {
- "outputs": {}
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-outputs/package.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-outputs/package.json
deleted file mode 100644
index 4e17dc1..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-outputs/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "no-outputs",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-outputs/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-outputs/turbo.json
deleted file mode 100644
index f5d57fc..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-outputs/turbo.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "build-one": {
- "dependsOn": ["build-two"]
- },
- "build-two": {
- "cache": false
- },
- "build-three": {
- "persistent": true
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-pipeline/package.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-pipeline/package.json
deleted file mode 100644
index 6e20fc8..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-pipeline/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "no-pipeline",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-pipeline/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-pipeline/turbo.json
deleted file mode 100644
index 0e2d6fd..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-pipeline/turbo.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "globalDependencies": ["$NEXT_PUBLIC_API_KEY", "$STRIPE_API_KEY", ".env"],
- "pipeline": {}
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-turbo-json/package.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-turbo-json/package.json
deleted file mode 100644
index cd98334..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/no-turbo-json/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "set-default-outputs-no-turbo-json",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-config/package.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-config/package.json
deleted file mode 100644
index 4c816c2..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-config/package.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "set-default-outputs-old-config",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3",
- "turbo": {
- "pipeline": {
- "build-one": {
- "outputs": [
- "foo"
- ]
- },
- "build-two": {
- "outputs": []
- },
- "build-three": {}
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-config/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-config/turbo.json
deleted file mode 100644
index b0f6150..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-config/turbo.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "build-one": {
- "outputs": ["foo"]
- },
- "build-two": {
- "outputs": []
- },
- "build-three": {}
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-outputs/package.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-outputs/package.json
deleted file mode 100644
index e4220ba..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-outputs/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "old-outputs",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "npm@1.2.3"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-outputs/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-outputs/turbo.json
deleted file mode 100644
index b0f6150..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/old-outputs/turbo.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "build-one": {
- "outputs": ["foo"]
- },
- "build-two": {
- "outputs": []
- },
- "build-three": {}
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/index.js b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/index.js
deleted file mode 100644
index 4de53f5..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function docs() {
- if (process.env.ENV_1 === undefined) {
- return "does not exist";
- }
- return "exists";
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/package.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/package.json
deleted file mode 100644
index 82f9a44..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "docs",
- "version": "1.0.0"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/turbo.json
deleted file mode 100644
index e60cdb7..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/docs/turbo.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {}
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/index.js b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/index.js
deleted file mode 100644
index bfd3ab8..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function web() {
- if (!process.env.ENV_2) {
- return "bar";
- }
- return "foo";
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/package.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/package.json
deleted file mode 100644
index d8a83ed..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "web",
- "version": "1.0.0"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/turbo.json
deleted file mode 100644
index b239cbf..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/apps/web/turbo.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {
- // old
- "outputs": []
- }
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/package.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/package.json
deleted file mode 100644
index c6616a6..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "private": true,
- "workspaces": [
- "apps/*",
- "packages/*"
- ],
- "scripts": {
- "build": "turbo run build"
- },
- "devDependencies": {
- "turbo": "latest"
- },
- "packageManager": "yarn@1.22.19"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/index.js b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/index.js
deleted file mode 100644
index dee5e80..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function foo() {
- if (!process.env.IS_SERVER) {
- return "bar";
- }
- return "foo";
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/package.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/package.json
deleted file mode 100644
index 7cb7cf1..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "ui",
- "version": "1.0.0"
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/turbo.json
deleted file mode 100644
index fe51119..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/packages/ui/turbo.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build-three": {}
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/turbo.json b/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/turbo.json
deleted file mode 100644
index b0f6150..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/set-default-outputs/workspace-configs/turbo.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "pipeline": {
- "build-one": {
- "outputs": ["foo"]
- },
- "build-two": {
- "outputs": []
- },
- "build-three": {}
- }
-}
diff --git a/packages/turbo-codemod/__tests__/__fixtures__/transform/basic/package.json b/packages/turbo-codemod/__tests__/__fixtures__/transform/basic/package.json
deleted file mode 100644
index 651edb6..0000000
--- a/packages/turbo-codemod/__tests__/__fixtures__/transform/basic/package.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "transform-basic",
- "version": "1.0.0",
- "dependencies": {},
- "devDependencies": {
- "turbo": "1.0.0"
- }
-}
diff --git a/packages/turbo-codemod/__tests__/add-package-manager.test.ts b/packages/turbo-codemod/__tests__/add-package-manager.test.ts
deleted file mode 100644
index 5bde7e0..0000000
--- a/packages/turbo-codemod/__tests__/add-package-manager.test.ts
+++ /dev/null
@@ -1,504 +0,0 @@
-import { transformer } from "../src/transforms/add-package-manager";
-import { setupTestFixtures } from "@turbo/test-utils";
-import fs from "fs-extra";
-import * as getPackageManager from "../src/utils/getPackageManager";
-import * as getPackageManagerVersion from "../src/utils/getPackageManagerVersion";
-
-describe("add-package-manager", () => {
- const { useFixture } = setupTestFixtures({
- directory: __dirname,
- test: "add-package-manager",
- });
- test("no package manager - basic", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-package-manager" });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // mock out workspace and version detection so we're not dependent on our actual repo
- const mockGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
-
- const mockGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager);
-
- // package manager should not exist
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(mockGetPackageManager).toHaveBeenCalledWith({ directory: root });
- expect(mockGetPackageManagerVersion).toHaveBeenCalledWith(
- packageManager,
- root
- );
-
- // package manager should now exist
- expect(JSON.parse(read("package.json") || "{}").packageManager).toBe(
- `${packageManager}@${packageManagerVersion}`
- );
- // result should be correct
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 0,
- },
- }
- `);
-
- mockGetPackageManagerVersion.mockRestore();
- mockGetPackageManager.mockRestore();
- });
-
- test("no package manager - repeat run", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-package-manager" });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // mock out workspace and version detection so we're not dependent on our actual repo
- const mockGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
-
- const mockGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager);
-
- // package manager should not exist
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(mockGetPackageManager).toHaveBeenCalledWith({ directory: root });
- expect(mockGetPackageManagerVersion).toHaveBeenCalled();
- expect(mockGetPackageManagerVersion).toHaveBeenCalledWith(
- packageManager,
- root
- );
-
- // package manager should now exist
- expect(JSON.parse(read("package.json") || "{}").packageManager).toBe(
- `${packageManager}@${packageManagerVersion}`
- );
- // result should be correct
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 0,
- },
- }
- `);
-
- // run the transformer again to ensure nothing changes on a second run
- const repeatResult = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
- expect(repeatResult.fatalError).toBeUndefined();
- expect(repeatResult.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- }
- `);
-
- mockGetPackageManagerVersion.mockRestore();
- mockGetPackageManager.mockRestore();
- });
-
- test("no package manager - dry", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-package-manager" });
-
- const packageManager = "npm";
- const packageManagerVersion = "1.2.3";
-
- // mock out workspace and version detection so we're not dependent on our actual repo
- const mockGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager);
-
- // package manager should not exist
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: true, print: false },
- });
-
- expect(mockGetPackageManager).toHaveBeenCalledWith({ directory: root });
- expect(mockGetPackageManagerVersion).toHaveBeenCalledWith(
- packageManager,
- root
- );
-
- // package manager should not exist
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
- // result should be correct
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "skipped",
- "additions": 1,
- "deletions": 0,
- },
- }
- `);
-
- mockGetPackageManagerVersion.mockRestore();
- });
-
- test("no package manager - print", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-package-manager" });
-
- const packageManager = "yarn";
- const packageManagerVersion = "1.2.3";
-
- // mock out workspace and version detection so we're not dependent on our actual repo
- const mockGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
-
- const mockGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager);
-
- // package manager should not exist
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: true },
- });
-
- expect(mockGetPackageManager).toHaveBeenCalledWith({ directory: root });
- expect(mockGetPackageManagerVersion).toHaveBeenCalledWith(
- packageManager,
- root
- );
- // package manager should now exist
- expect(JSON.parse(read("package.json") || "{}").packageManager).toBe(
- `${packageManager}@${packageManagerVersion}`
- );
- // result should be correct
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 0,
- },
- }
- `);
-
- mockGetPackageManagerVersion.mockRestore();
- });
-
- test("no package manager - dry & print", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-package-manager" });
-
- const packageManager = "npm";
- const packageManagerVersion = "1.2.3";
-
- // mock out workspace and version detection so we're not dependent on our actual repo
- const mockGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
-
- const mockGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager);
-
- // package manager should not exist
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: true, print: true },
- });
-
- expect(mockGetPackageManager).toHaveBeenCalledWith({ directory: root });
- expect(mockGetPackageManagerVersion).toHaveBeenCalledWith(
- packageManager,
- root
- );
-
- // package manager should not exist
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
- // result should be correct
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "skipped",
- "additions": 1,
- "deletions": 0,
- },
- }
- `);
-
- mockGetPackageManagerVersion.mockRestore();
- mockGetPackageManager.mockRestore();
- });
-
- test("package manager already exists", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "has-package-manager" });
- const packageManager = "npm";
- const packageManagerVersion = "1.2.3";
-
- // mock out workspace and version detection so we're not dependent on our actual repo
- const mockGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
-
- const mockGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager);
-
- // package manager should exist
- expect(JSON.parse(read("package.json") || "{}").packageManager).toBe(
- `${packageManager}@${packageManagerVersion}`
- );
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(mockGetPackageManager).toHaveBeenCalledWith({ directory: root });
- expect(mockGetPackageManagerVersion).toHaveBeenCalledWith(
- packageManager,
- root
- );
-
- // package manager should still exist
- expect(JSON.parse(read("package.json") || "{}").packageManager).toBe(
- `${packageManager}@${packageManagerVersion}`
- );
- // result should be correct
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- }
- `);
-
- mockGetPackageManagerVersion.mockRestore();
- mockGetPackageManager.mockRestore();
- });
-
- test("package manager exists but is wrong", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "wrong-package-manager" });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // mock out workspace and version detection so we're not dependent on our actual repo
- const mockGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
-
- const mockGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager);
-
- // package manager should exist
- expect(JSON.parse(read("package.json") || "{}").packageManager).toBe(
- "turbo@1.7.0"
- );
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(mockGetPackageManager).toHaveBeenCalledWith({ directory: root });
- expect(mockGetPackageManagerVersion).toHaveBeenCalledWith(
- packageManager,
- root
- );
-
- // package manager should still exist
- expect(JSON.parse(read("package.json") || "{}").packageManager).toBe(
- `${packageManager}@${packageManagerVersion}`
- );
- // result should be correct
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 1,
- },
- }
- `);
-
- mockGetPackageManagerVersion.mockRestore();
- mockGetPackageManager.mockRestore();
- });
-
- test("errors when unable to determine workspace manager", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-package-manager" });
-
- const mockGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(undefined);
-
- // package manager should not exist
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(mockGetPackageManager).toHaveBeenCalledTimes(1);
- expect(mockGetPackageManager).toHaveBeenCalledWith({ directory: root });
-
- // result should be correct
- // result should be correct
- expect(result.fatalError?.message).toMatch(
- /Unable to determine package manager for .*?/
- );
-
- mockGetPackageManager.mockRestore();
- });
-
- test("errors when unable to determine package manager", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-package-manager" });
-
- const mockGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockImplementation(() => {
- throw new Error("package manager not supported");
- });
-
- // package manager should not exist
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(mockGetPackageManagerVersion).toHaveBeenCalledTimes(1);
-
- // result should be correct
- expect(result.fatalError?.message).toMatch(
- /Unable to determine package manager version for .*?/
- );
-
- mockGetPackageManagerVersion.mockRestore();
- });
-
- test("errors when unable to write json", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-package-manager" });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // mock out workspace and version detection so we're not dependent on our actual repo
- const mockGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
-
- const mockGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager);
-
- const mockWriteJsonSync = jest
- .spyOn(fs, "writeJsonSync")
- .mockImplementation(() => {
- throw new Error("could not write file");
- });
-
- // package manager should not exist
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(mockGetPackageManager).toHaveBeenCalledWith({ directory: root });
- expect(mockGetPackageManagerVersion).toHaveBeenCalledWith(
- packageManager,
- root
- );
-
- // package manager should still not exist (we couldn't write it)
- expect(
- JSON.parse(read("package.json") || "{}").packageManager
- ).toBeUndefined();
-
- // result should be correct
- expect(result.fatalError?.message).toMatch(
- "Encountered an error while transforming files"
- );
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "error",
- "additions": 1,
- "deletions": 0,
- "error": [Error: could not write file],
- },
- }
- `);
-
- mockWriteJsonSync.mockRestore();
- mockGetPackageManagerVersion.mockRestore();
- mockGetPackageManager.mockRestore();
- });
-});
diff --git a/packages/turbo-codemod/__tests__/create-turbo-config.test.ts b/packages/turbo-codemod/__tests__/create-turbo-config.test.ts
deleted file mode 100644
index 8938c78..0000000
--- a/packages/turbo-codemod/__tests__/create-turbo-config.test.ts
+++ /dev/null
@@ -1,416 +0,0 @@
-import { transformer } from "../src/transforms/create-turbo-config";
-import { setupTestFixtures } from "@turbo/test-utils";
-import fs from "fs-extra";
-
-describe("create-turbo-config", () => {
- const { useFixture } = setupTestFixtures({
- directory: __dirname,
- test: "create-turbo-config",
- });
-
- test("package.json config exists but no turbo.json config - basic", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-turbo-json-config" });
-
- // turbo.json should not exist
- expect(read("turbo.json")).toBeUndefined();
-
- // get config from package.json for comparison later
- const turboConfig = JSON.parse(read("package.json") || "{}").turbo;
- expect(turboConfig).toBeDefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- // turbo.json should now exist (and match the package.json config)
- expect(JSON.parse(read("turbo.json") || "{}")).toEqual(turboConfig);
-
- // result should be correct
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "modified",
- "additions": 0,
- "deletions": 1,
- },
- "turbo.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 0,
- },
- }
- `);
- });
-
- test("package.json config exists but no turbo.json config - repeat run", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-turbo-json-config" });
-
- // turbo.json should not exist
- expect(read("turbo.json")).toBeUndefined();
-
- // get config from package.json for comparison later
- const turboConfig = JSON.parse(read("package.json") || "{}").turbo;
- expect(turboConfig).toBeDefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- // turbo.json should now exist (and match the package.json config)
- expect(JSON.parse(read("turbo.json") || "{}")).toEqual(turboConfig);
-
- // result should be correct
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "modified",
- "additions": 0,
- "deletions": 1,
- },
- "turbo.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 0,
- },
- }
- `);
-
- // run the transformer
- const repeatResult = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
- // result should be correct
- expect(repeatResult.fatalError).toBeUndefined();
- expect(repeatResult.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- "turbo.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- }
- `);
- });
-
- test("package.json config exists but no turbo.json config - dry", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-turbo-json-config" });
-
- // turbo.json should not exist
- expect(read("turbo.json")).toBeUndefined();
-
- // get config from package.json for comparison later
- const turboConfig = JSON.parse(read("package.json") || "{}").turbo;
- expect(turboConfig).toBeDefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: true, print: false },
- });
-
- // turbo.json still not exist (dry run)
- expect(read("turbo.json")).toBeUndefined();
-
- // result should be correct
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "skipped",
- "additions": 0,
- "deletions": 1,
- },
- "turbo.json": Object {
- "action": "skipped",
- "additions": 1,
- "deletions": 0,
- },
- }
- `);
- });
-
- test("package.json config exists but no turbo.json config - print", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-turbo-json-config" });
-
- // turbo.json should not exist
- expect(read("turbo.json")).toBeUndefined();
-
- // get config from package.json for comparison later
- const turboConfig = JSON.parse(read("package.json") || "{}").turbo;
- expect(turboConfig).toBeDefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: true },
- });
-
- // turbo.json should now exist (and match the package.json config)
- expect(JSON.parse(read("turbo.json") || "{}")).toEqual(turboConfig);
-
- // result should be correct
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "modified",
- "additions": 0,
- "deletions": 1,
- },
- "turbo.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 0,
- },
- }
- `);
- });
-
- test("package.json config exists but no turbo.json config - dry & print", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-turbo-json-config" });
-
- // turbo.json should not exist
- expect(read("turbo.json")).toBeUndefined();
-
- // get config from package.json for comparison later
- const turboConfig = JSON.parse(read("package.json") || "{}").turbo;
- expect(turboConfig).toBeDefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: true, print: true },
- });
-
- // turbo.json still not exist (dry run)
- expect(read("turbo.json")).toBeUndefined();
-
- // result should be correct
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "skipped",
- "additions": 0,
- "deletions": 1,
- },
- "turbo.json": Object {
- "action": "skipped",
- "additions": 1,
- "deletions": 0,
- },
- }
- `);
- });
-
- test("no package.json config or turbo.json file exists", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-package-json-config" });
-
- // turbo.json should not exist
- expect(read("turbo.json")).toBeUndefined();
-
- // get config from package.json for comparison later
- const packageJsonConfig = JSON.parse(read("package.json") || "{}");
- const turboConfig = packageJsonConfig.turbo;
- expect(turboConfig).toBeUndefined();
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- // turbo.json should still not exist
- expect(read("turbo.json")).toBeUndefined();
-
- // make sure we didn't change the package.json
- expect(JSON.parse(read("package.json") || "{}")).toEqual(packageJsonConfig);
-
- // result should be correct
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- "turbo.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- }
- `);
- });
-
- test("no package.json file exists", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-package-json-file" });
-
- // turbo.json should not exist
- expect(read("turbo.json")).toBeUndefined();
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- // turbo.json should still not exist
- expect(read("turbo.json")).toBeUndefined();
-
- // result should be correct
- expect(result.fatalError?.message).toMatch(
- /No package\.json found at .*?\. Is the path correct\?/
- );
- });
-
- test("turbo.json file exists and no package.json config exists", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "turbo-json-config" });
-
- // turbo.json should exist
- expect(read("turbo.json")).toBeDefined();
-
- // no config should exist in package.json
- const packageJsonConfig = JSON.parse(read("package.json") || "{}");
- const turboConfig = packageJsonConfig.turbo;
- expect(turboConfig).toBeUndefined();
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- // turbo.json should still exist
- expect(read("turbo.json")).toBeDefined();
-
- // make sure we didn't change the package.json
- expect(JSON.parse(read("package.json") || "{}")).toEqual(packageJsonConfig);
-
- // result should be correct
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- "turbo.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- }
- `);
- });
-
- test("turbo.json file exists and package.json config exists", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "both-configs" });
-
- // turbo.json should exist
- const turboJsonConfig = JSON.parse(read("turbo.json") || "{}");
- expect(turboJsonConfig.pipeline).toBeDefined();
-
- // no config should exist in package.json
- const packageJsonConfig = JSON.parse(read("package.json") || "{}");
- const turboConfig = JSON.parse(read("package.json") || "{}").turbo;
- expect(turboConfig).toBeDefined();
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- // make sure we didn't change the package.json
- expect(JSON.parse(read("package.json") || "{}")).toEqual(packageJsonConfig);
-
- // make sure we didn't change the turbo.json
- expect(JSON.parse(read("turbo.json") || "{}")).toEqual(turboJsonConfig);
-
- // result should be correct
- expect(result.fatalError?.message).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- "turbo.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- }
- `);
- });
-
- test("errors when unable to write json", () => {
- // load the fixture for the test
- const { root, read } = useFixture({ fixture: "no-turbo-json-config" });
-
- // turbo.json should not exist
- expect(read("turbo.json")).toBeUndefined();
-
- // get config from package.json for comparison later
- const turboConfig = JSON.parse(read("package.json") || "{}").turbo;
- expect(turboConfig).toBeDefined();
-
- const mockWriteJsonSync = jest
- .spyOn(fs, "writeJsonSync")
- .mockImplementation(() => {
- throw new Error("could not write file");
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- // turbo.json should still not exist (error writing)
- expect(read("turbo.json")).toBeUndefined();
-
- // result should be correct
- expect(result.fatalError).toBeDefined();
- expect(result.fatalError?.message).toMatch(
- "Encountered an error while transforming files"
- );
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "package.json": Object {
- "action": "error",
- "additions": 0,
- "deletions": 1,
- "error": [Error: could not write file],
- },
- "turbo.json": Object {
- "action": "error",
- "additions": 1,
- "deletions": 0,
- "error": [Error: could not write file],
- },
- }
- `);
-
- mockWriteJsonSync.mockRestore();
- });
-});
diff --git a/packages/turbo-codemod/__tests__/get-turbo-upgrade-command.test.ts b/packages/turbo-codemod/__tests__/get-turbo-upgrade-command.test.ts
deleted file mode 100644
index 1015589..0000000
--- a/packages/turbo-codemod/__tests__/get-turbo-upgrade-command.test.ts
+++ /dev/null
@@ -1,576 +0,0 @@
-import { setupTestFixtures } from "@turbo/test-utils";
-import getTurboUpgradeCommand from "../src/commands/migrate/steps/getTurboUpgradeCommand";
-import * as utils from "../src/commands/migrate/utils";
-import * as getPackageManager from "../src/utils/getPackageManager";
-import * as getPackageManagerVersion from "../src/utils/getPackageManagerVersion";
-
-const LOCAL_INSTALL_COMMANDS = [
- // npm - workspaces
- [
- "latest",
- "npm",
- "7.0.0",
- "normal-workspaces-dev-install",
- "npm install turbo@latest --save-dev",
- ],
- [
- "1.6.3",
- "npm",
- "7.0.0",
- "normal-workspaces-dev-install",
- "npm install turbo@1.6.3 --save-dev",
- ],
- [
- "canary",
- "npm",
- "7.0.0",
- "normal-workspaces-dev-install",
- "npm install turbo@canary --save-dev",
- ],
- ["latest", "npm", "7.0.0", "normal-workspaces", "npm install turbo@latest"],
- // npm - single package
- [
- "latest",
- "npm",
- "7.0.0",
- "single-package-dev-install",
- "npm install turbo@latest --save-dev",
- ],
- ["latest", "npm", "7.0.0", "single-package", "npm install turbo@latest"],
- // pnpm - workspaces
- [
- "latest",
- "pnpm",
- "7.0.0",
- "pnpm-workspaces-dev-install",
- "pnpm install turbo@latest --save-dev -w",
- ],
- [
- "1.6.3",
- "pnpm",
- "7.0.0",
- "pnpm-workspaces-dev-install",
- "pnpm install turbo@1.6.3 --save-dev -w",
- ],
- [
- "canary",
- "pnpm",
- "7.0.0",
- "pnpm-workspaces-dev-install",
- "pnpm install turbo@canary --save-dev -w",
- ],
- [
- "latest",
- "pnpm",
- "7.0.0",
- "pnpm-workspaces",
- "pnpm install turbo@latest -w",
- ],
- // pnpm - single package
- [
- "latest",
- "pnpm",
- "7.0.0",
- "single-package-dev-install",
- "pnpm install turbo@latest --save-dev",
- ],
- ["latest", "pnpm", "7.0.0", "single-package", "pnpm install turbo@latest"],
- // yarn 1.x - workspaces
- [
- "latest",
- "yarn",
- "1.22.19",
- "normal-workspaces-dev-install",
- "yarn add turbo@latest --dev -W",
- ],
- [
- "latest",
- "yarn",
- "1.22.19",
- "normal-workspaces",
- "yarn add turbo@latest -W",
- ],
- [
- "1.6.3",
- "yarn",
- "1.22.19",
- "normal-workspaces-dev-install",
- "yarn add turbo@1.6.3 --dev -W",
- ],
- [
- "canary",
- "yarn",
- "1.22.19",
- "normal-workspaces-dev-install",
- "yarn add turbo@canary --dev -W",
- ],
- // yarn 1.x - single package
- [
- "latest",
- "yarn",
- "1.22.19",
- "single-package-dev-install",
- "yarn add turbo@latest --dev",
- ],
- ["latest", "yarn", "1.22.19", "single-package", "yarn add turbo@latest"],
- // yarn 2.x - workspaces
- [
- "latest",
- "yarn",
- "2.3.4",
- "normal-workspaces-dev-install",
- "yarn add turbo@latest --dev",
- ],
- ["latest", "yarn", "2.3.4", "normal-workspaces", "yarn add turbo@latest"],
- [
- "1.6.3",
- "yarn",
- "2.3.4",
- "normal-workspaces-dev-install",
- "yarn add turbo@1.6.3 --dev",
- ],
- [
- "canary",
- "yarn",
- "2.3.4",
- "normal-workspaces-dev-install",
- "yarn add turbo@canary --dev",
- ],
- // yarn 2.x - single package
- [
- "latest",
- "yarn",
- "2.3.4",
- "single-package-dev-install",
- "yarn add turbo@latest --dev",
- ],
- ["latest", "yarn", "2.3.4", "single-package", "yarn add turbo@latest"],
- // yarn 3.x - workspaces
- [
- "latest",
- "yarn",
- "3.3.4",
- "normal-workspaces-dev-install",
- "yarn add turbo@latest --dev",
- ],
- ["latest", "yarn", "3.3.4", "normal-workspaces", "yarn add turbo@latest"],
- [
- "1.6.3",
- "yarn",
- "3.3.4",
- "normal-workspaces-dev-install",
- "yarn add turbo@1.6.3 --dev",
- ],
- [
- "canary",
- "yarn",
- "3.3.4",
- "normal-workspaces-dev-install",
- "yarn add turbo@canary --dev",
- ],
- // yarn 3.x - single package
- [
- "latest",
- "yarn",
- "3.3.4",
- "single-package-dev-install",
- "yarn add turbo@latest --dev",
- ],
- ["latest", "yarn", "3.3.4", "single-package", "yarn add turbo@latest"],
-];
-
-const GLOBAL_INSTALL_COMMANDS = [
- // npm
- [
- "latest",
- "npm",
- "7.0.0",
- "normal-workspaces-dev-install",
- "npm install turbo@latest --global",
- ],
- [
- "1.6.3",
- "npm",
- "7.0.0",
- "normal-workspaces-dev-install",
- "npm install turbo@1.6.3 --global",
- ],
- [
- "latest",
- "npm",
- "7.0.0",
- "normal-workspaces",
- "npm install turbo@latest --global",
- ],
- [
- "latest",
- "npm",
- "7.0.0",
- "single-package",
- "npm install turbo@latest --global",
- ],
- [
- "latest",
- "npm",
- "7.0.0",
- "single-package-dev-install",
- "npm install turbo@latest --global",
- ],
- // pnpm
- [
- "latest",
- "pnpm",
- "7.0.0",
- "pnpm-workspaces-dev-install",
- "pnpm install turbo@latest --global",
- ],
- [
- "1.6.3",
- "pnpm",
- "7.0.0",
- "pnpm-workspaces-dev-install",
- "pnpm install turbo@1.6.3 --global",
- ],
- [
- "latest",
- "pnpm",
- "7.0.0",
- "pnpm-workspaces",
- "pnpm install turbo@latest --global",
- ],
- [
- "latest",
- "pnpm",
- "7.0.0",
- "single-package",
- "pnpm install turbo@latest --global",
- ],
- [
- "latest",
- "pnpm",
- "7.0.0",
- "single-package-dev-install",
- "pnpm install turbo@latest --global",
- ],
- // yarn 1.x
- [
- "latest",
- "yarn",
- "1.22.19",
- "normal-workspaces-dev-install",
- "yarn global add turbo@latest",
- ],
- [
- "latest",
- "yarn",
- "1.22.19",
- "normal-workspaces",
- "yarn global add turbo@latest",
- ],
- [
- "1.6.3",
- "yarn",
- "1.22.19",
- "normal-workspaces-dev-install",
- "yarn global add turbo@1.6.3",
- ],
- [
- "latest",
- "yarn",
- "1.22.19",
- "single-package",
- "yarn global add turbo@latest",
- ],
- [
- "latest",
- "yarn",
- "1.22.19",
- "single-package-dev-install",
- "yarn global add turbo@latest",
- ],
- // yarn 2.x
- [
- "latest",
- "yarn",
- "2.3.4",
- "normal-workspaces-dev-install",
- "yarn global add turbo@latest",
- ],
- [
- "latest",
- "yarn",
- "2.3.4",
- "normal-workspaces",
- "yarn global add turbo@latest",
- ],
- [
- "1.6.3",
- "yarn",
- "2.3.4",
- "normal-workspaces-dev-install",
- "yarn global add turbo@1.6.3",
- ],
- ["latest", "yarn", "2.3.4", "single-package", "yarn global add turbo@latest"],
- [
- "latest",
- "yarn",
- "2.3.4",
- "single-package-dev-install",
- "yarn global add turbo@latest",
- ],
- // yarn 3.x
- [
- "latest",
- "yarn",
- "3.3.3",
- "normal-workspaces-dev-install",
- "yarn global add turbo@latest",
- ],
- [
- "latest",
- "yarn",
- "3.3.3",
- "normal-workspaces",
- "yarn global add turbo@latest",
- ],
- [
- "1.6.3",
- "yarn",
- "3.3.3",
- "normal-workspaces-dev-install",
- "yarn global add turbo@1.6.3",
- ],
- ["latest", "yarn", "3.3.4", "single-package", "yarn global add turbo@latest"],
- [
- "latest",
- "yarn",
- "3.3.4",
- "single-package-dev-install",
- "yarn global add turbo@latest",
- ],
-];
-
-describe("get-turbo-upgrade-command", () => {
- const { useFixture } = setupTestFixtures({
- directory: __dirname,
- test: "get-turbo-upgrade-command",
- });
-
- test.each(LOCAL_INSTALL_COMMANDS)(
- "returns correct upgrade command for local install of turbo@%s using %s@%s (fixture: %s)",
- (
- turboVersion,
- packageManager,
- packageManagerVersion,
- fixture,
- expectedUpgradeCommand
- ) => {
- const { root } = useFixture({
- fixture,
- });
-
- const mockedExec = jest
- .spyOn(utils, "exec")
- .mockImplementation((command: string) => {
- // fail the check for the turbo, and package manager bins to force local
- if (command.includes("bin")) {
- return undefined;
- }
- });
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockedGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager as getPackageManager.PackageManager);
-
- // get the command
- const upgradeCommand = getTurboUpgradeCommand({
- directory: root,
- to: turboVersion === "latest" ? undefined : turboVersion,
- });
-
- expect(upgradeCommand).toEqual(expectedUpgradeCommand);
-
- mockedExec.mockRestore();
- mockedGetPackageManager.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- }
- );
-
- test.each(GLOBAL_INSTALL_COMMANDS)(
- "returns correct upgrade command for global install of turbo@%s using %s@%s (fixture: %s)",
- (
- turboVersion,
- packageManager,
- packageManagerVersion,
- fixture,
- expectedUpgradeCommand
- ) => {
- const { root } = useFixture({
- fixture,
- });
-
- const mockedExec = jest
- .spyOn(utils, "exec")
- .mockImplementation((command: string) => {
- if (command === "turbo bin") {
- return `/global/${packageManager}/bin/turbo`;
- }
- if (command.includes(packageManager)) {
- return `/global/${packageManager}/bin`;
- }
- });
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockedGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager as getPackageManager.PackageManager);
-
- // get the command
- const upgradeCommand = getTurboUpgradeCommand({
- directory: root,
- to: turboVersion === "latest" ? undefined : turboVersion,
- });
-
- expect(upgradeCommand).toEqual(expectedUpgradeCommand);
-
- mockedExec.mockRestore();
- mockedGetPackageManager.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- }
- );
-
- test("fails gracefully if no package.json exists", () => {
- const { root } = useFixture({
- fixture: "no-package",
- });
-
- const mockedExec = jest
- .spyOn(utils, "exec")
- .mockImplementation((command: string) => {
- // fail the check for the turbo, and package manager bins to force local
- if (command.includes("bin")) {
- return undefined;
- }
- });
-
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue("8.0.0");
- const mockedGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue("pnpm" as getPackageManager.PackageManager);
-
- // get the command
- const upgradeCommand = getTurboUpgradeCommand({
- directory: root,
- });
-
- expect(upgradeCommand).toEqual(undefined);
-
- mockedExec.mockRestore();
- mockedGetPackageManager.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- });
-
- test("fails gracefully if turbo cannot be found in package.json", () => {
- const { root } = useFixture({
- fixture: "no-turbo",
- });
-
- const mockedExec = jest
- .spyOn(utils, "exec")
- .mockImplementation((command: string) => {
- // fail the check for the turbo, and package manager bins to force local
- if (command.includes("bin")) {
- return undefined;
- }
- });
-
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue("8.0.0");
- const mockedGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue("pnpm" as getPackageManager.PackageManager);
-
- // get the command
- const upgradeCommand = getTurboUpgradeCommand({
- directory: root,
- });
-
- expect(upgradeCommand).toEqual(undefined);
-
- mockedExec.mockRestore();
- mockedGetPackageManager.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- });
-
- test("fails gracefully if package.json has no deps or devDeps", () => {
- const { root } = useFixture({
- fixture: "no-deps",
- });
-
- const mockedExec = jest
- .spyOn(utils, "exec")
- .mockImplementation((command: string) => {
- // fail the check for the turbo, and package manager bins to force local
- if (command.includes("bin")) {
- return undefined;
- }
- });
-
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue("8.0.0");
- const mockedGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue("pnpm" as getPackageManager.PackageManager);
-
- // get the command
- const upgradeCommand = getTurboUpgradeCommand({
- directory: root,
- });
-
- expect(upgradeCommand).toEqual(undefined);
-
- mockedExec.mockRestore();
- mockedGetPackageManager.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- });
-
- test("fails gracefully if can't find packageManager", () => {
- const { root } = useFixture({
- fixture: "no-deps",
- });
-
- const mockedExec = jest
- .spyOn(utils, "exec")
- .mockImplementation((command: string) => {
- // fail the check for the turbo, and package manager bins to force local
- if (command.includes("bin")) {
- return undefined;
- }
- });
-
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue("8.0.0");
- const mockedGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue("pnpm" as getPackageManager.PackageManager);
-
- // get the command
- const upgradeCommand = getTurboUpgradeCommand({
- directory: root,
- });
-
- expect(upgradeCommand).toEqual(undefined);
-
- mockedExec.mockRestore();
- mockedGetPackageManager.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- });
-});
diff --git a/packages/turbo-codemod/__tests__/migrate-env-var-dependencies.test.ts b/packages/turbo-codemod/__tests__/migrate-env-var-dependencies.test.ts
deleted file mode 100644
index fbc5d8d..0000000
--- a/packages/turbo-codemod/__tests__/migrate-env-var-dependencies.test.ts
+++ /dev/null
@@ -1,758 +0,0 @@
-import merge from "deepmerge";
-import {
- hasLegacyEnvVarDependencies,
- migratePipeline,
- migrateConfig,
- transformer,
-} from "../src/transforms/migrate-env-var-dependencies";
-import { setupTestFixtures } from "@turbo/test-utils";
-import type { Schema } from "@turbo/types";
-
-const getTestTurboConfig = (override: Schema = { pipeline: {} }): Schema => {
- const config = {
- $schema: "./docs/public/schema.json",
- globalDependencies: ["$GLOBAL_ENV_KEY"],
- pipeline: {
- test: {
- outputs: ["coverage/**/*"],
- dependsOn: ["^build"],
- },
- lint: {
- outputs: [],
- },
- dev: {
- cache: false,
- },
- build: {
- outputs: ["dist/**/*", ".next/**/*", "!.next/cache/**"],
- dependsOn: ["^build", "$TASK_ENV_KEY", "$ANOTHER_ENV_KEY"],
- },
- },
- };
-
- return merge(config, override, {
- arrayMerge: (_, sourceArray) => sourceArray,
- });
-};
-
-describe("migrate-env-var-dependencies", () => {
- describe("hasLegacyEnvVarDependencies - utility", () => {
- it("finds env keys in legacy turbo.json - has keys", async () => {
- const config = getTestTurboConfig();
- const { hasKeys, envVars } = hasLegacyEnvVarDependencies(config);
- expect(hasKeys).toEqual(true);
- expect(envVars).toMatchInlineSnapshot(`
- Array [
- "$GLOBAL_ENV_KEY",
- "$TASK_ENV_KEY",
- "$ANOTHER_ENV_KEY",
- ]
- `);
- });
-
- it("finds env keys in legacy turbo.json - multiple pipeline keys", async () => {
- const config = getTestTurboConfig({
- pipeline: { test: { dependsOn: ["$MY_ENV"] } },
- });
- const { hasKeys, envVars } = hasLegacyEnvVarDependencies(config);
- expect(hasKeys).toEqual(true);
- expect(envVars).toMatchInlineSnapshot(`
- Array [
- "$GLOBAL_ENV_KEY",
- "$MY_ENV",
- "$TASK_ENV_KEY",
- "$ANOTHER_ENV_KEY",
- ]
- `);
- });
-
- it("finds env keys in legacy turbo.json - no keys", async () => {
- // override to exclude keys
- const config = getTestTurboConfig({
- globalDependencies: [],
- pipeline: { build: { dependsOn: [] } },
- });
- const { hasKeys, envVars } = hasLegacyEnvVarDependencies(config);
- expect(hasKeys).toEqual(false);
- expect(envVars).toMatchInlineSnapshot(`Array []`);
- });
-
- it("finds env keys in turbo.json - no global", async () => {
- const { hasKeys, envVars } = hasLegacyEnvVarDependencies({
- pipeline: { build: { dependsOn: ["$cool"] } },
- });
- expect(hasKeys).toEqual(true);
- expect(envVars).toMatchInlineSnapshot(`
- Array [
- "$cool",
- ]
- `);
- });
- });
-
- describe("migratePipeline - utility", () => {
- it("migrates pipeline with env var dependencies", async () => {
- const config = getTestTurboConfig();
- const { build } = config.pipeline;
- const pipeline = migratePipeline(build);
- expect(pipeline).toHaveProperty("env");
- expect(pipeline?.env).toMatchInlineSnapshot(`
- Array [
- "TASK_ENV_KEY",
- "ANOTHER_ENV_KEY",
- ]
- `);
- expect(pipeline?.dependsOn).toMatchInlineSnapshot(`
- Array [
- "^build",
- ]
- `);
- });
-
- it("migrates pipeline with no env var dependencies", async () => {
- const config = getTestTurboConfig();
- const { test } = config.pipeline;
- const pipeline = migratePipeline(test);
- expect(pipeline.env).toBeUndefined();
- expect(pipeline?.dependsOn).toMatchInlineSnapshot(`
- Array [
- "^build",
- ]
- `);
- });
-
- it("migrates pipeline with existing env key", async () => {
- const config = getTestTurboConfig({
- pipeline: { test: { env: ["$MY_ENV"], dependsOn: ["^build"] } },
- });
- const { test } = config.pipeline;
- const pipeline = migratePipeline(test);
- expect(pipeline).toHaveProperty("env");
- expect(pipeline?.env).toMatchInlineSnapshot(`
- Array [
- "$MY_ENV",
- ]
- `);
- expect(pipeline?.dependsOn).toMatchInlineSnapshot(`
- Array [
- "^build",
- ]
- `);
- });
-
- it("migrates pipeline with incomplete env key", async () => {
- const config = getTestTurboConfig({
- pipeline: {
- test: { env: ["$MY_ENV"], dependsOn: ["^build", "$SUPER_COOL"] },
- },
- });
- const { test } = config.pipeline;
- const pipeline = migratePipeline(test);
- expect(pipeline).toHaveProperty("env");
- expect(pipeline?.env).toMatchInlineSnapshot(`
- Array [
- "$MY_ENV",
- "SUPER_COOL",
- ]
- `);
- expect(pipeline?.dependsOn).toMatchInlineSnapshot(`
- Array [
- "^build",
- ]
- `);
- });
-
- it("migrates pipeline with duplicate env keys", async () => {
- const config = getTestTurboConfig({
- pipeline: {
- test: { env: ["$MY_ENV"], dependsOn: ["^build", "$MY_ENV"] },
- },
- });
- const { test } = config.pipeline;
- const pipeline = migratePipeline(test);
- expect(pipeline).toHaveProperty("env");
- expect(pipeline?.env).toMatchInlineSnapshot(`
- Array [
- "$MY_ENV",
- "MY_ENV",
- ]
- `);
- expect(pipeline?.dependsOn).toMatchInlineSnapshot(`
- Array [
- "^build",
- ]
- `);
- });
- });
-
- describe("migrateConfig - utility", () => {
- it("migrates config with env var dependencies", async () => {
- const config = getTestTurboConfig();
- const pipeline = migrateConfig(config);
- expect(pipeline).toMatchInlineSnapshot(`
- Object {
- "$schema": "./docs/public/schema.json",
- "globalEnv": Array [
- "GLOBAL_ENV_KEY",
- ],
- "pipeline": Object {
- "build": Object {
- "dependsOn": Array [
- "^build",
- ],
- "env": Array [
- "TASK_ENV_KEY",
- "ANOTHER_ENV_KEY",
- ],
- "outputs": Array [
- "dist/**/*",
- ".next/**/*",
- "!.next/cache/**",
- ],
- },
- "dev": Object {
- "cache": false,
- },
- "lint": Object {
- "outputs": Array [],
- },
- "test": Object {
- "dependsOn": Array [
- "^build",
- ],
- "outputs": Array [
- "coverage/**/*",
- ],
- },
- },
- }
- `);
- });
-
- it("migrates config with no env var dependencies", async () => {
- const config = getTestTurboConfig({
- globalDependencies: [],
- pipeline: {
- build: { dependsOn: ["^build"] },
- },
- });
- const pipeline = migrateConfig(config);
- expect(pipeline).toMatchInlineSnapshot(`
- Object {
- "$schema": "./docs/public/schema.json",
- "pipeline": Object {
- "build": Object {
- "dependsOn": Array [
- "^build",
- ],
- "outputs": Array [
- "dist/**/*",
- ".next/**/*",
- "!.next/cache/**",
- ],
- },
- "dev": Object {
- "cache": false,
- },
- "lint": Object {
- "outputs": Array [],
- },
- "test": Object {
- "dependsOn": Array [
- "^build",
- ],
- "outputs": Array [
- "coverage/**/*",
- ],
- },
- },
- }
- `);
- });
-
- it("migrates config with inconsistent config", async () => {
- const config = getTestTurboConfig({
- pipeline: {
- test: { env: ["$MY_ENV"], dependsOn: ["^build", "$SUPER_COOL"] },
- },
- });
- const pipeline = migrateConfig(config);
- expect(pipeline).toMatchInlineSnapshot(`
- Object {
- "$schema": "./docs/public/schema.json",
- "globalEnv": Array [
- "GLOBAL_ENV_KEY",
- ],
- "pipeline": Object {
- "build": Object {
- "dependsOn": Array [
- "^build",
- ],
- "env": Array [
- "TASK_ENV_KEY",
- "ANOTHER_ENV_KEY",
- ],
- "outputs": Array [
- "dist/**/*",
- ".next/**/*",
- "!.next/cache/**",
- ],
- },
- "dev": Object {
- "cache": false,
- },
- "lint": Object {
- "outputs": Array [],
- },
- "test": Object {
- "dependsOn": Array [
- "^build",
- ],
- "env": Array [
- "$MY_ENV",
- "SUPER_COOL",
- ],
- "outputs": Array [
- "coverage/**/*",
- ],
- },
- },
- }
- `);
- });
-
- it("migrates config with duplicate env keys", async () => {
- const config = getTestTurboConfig({
- pipeline: {
- test: { env: ["$MY_ENV"], dependsOn: ["^build", "$MY_ENV"] },
- },
- });
- const pipeline = migrateConfig(config);
- expect(pipeline).toMatchInlineSnapshot(`
- Object {
- "$schema": "./docs/public/schema.json",
- "globalEnv": Array [
- "GLOBAL_ENV_KEY",
- ],
- "pipeline": Object {
- "build": Object {
- "dependsOn": Array [
- "^build",
- ],
- "env": Array [
- "TASK_ENV_KEY",
- "ANOTHER_ENV_KEY",
- ],
- "outputs": Array [
- "dist/**/*",
- ".next/**/*",
- "!.next/cache/**",
- ],
- },
- "dev": Object {
- "cache": false,
- },
- "lint": Object {
- "outputs": Array [],
- },
- "test": Object {
- "dependsOn": Array [
- "^build",
- ],
- "env": Array [
- "$MY_ENV",
- "MY_ENV",
- ],
- "outputs": Array [
- "coverage/**/*",
- ],
- },
- },
- }
- `);
- });
- });
-
- describe("transform", () => {
- const { useFixture } = setupTestFixtures({
- directory: __dirname,
- test: "migrate-env-var-dependencies",
- });
-
- it("migrates turbo.json env var dependencies - basic", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "env-dependencies",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(JSON.parse(read("turbo.json") || "{}")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- globalDependencies: [".env"],
- globalEnv: ["NEXT_PUBLIC_API_KEY", "STRIPE_API_KEY"],
- pipeline: {
- build: {
- dependsOn: ["^build"],
- env: ["PROD_API_KEY"],
- outputs: [".next/**", "!.next/cache/**"],
- },
- dev: {
- cache: false,
- },
- lint: {
- dependsOn: [],
- env: ["IS_CI"],
- outputs: [],
- },
- test: {
- dependsOn: ["test"],
- env: ["IS_CI"],
- outputs: [],
- },
- },
- });
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "modified",
- "additions": 4,
- "deletions": 4,
- },
- }
- `);
- });
-
- it("migrates turbo.json env var dependencies - workspace configs", async () => {
- // load the fixture for the test
- const { root, readJson } = useFixture({
- fixture: "workspace-configs",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(readJson("turbo.json") || "{}").toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- globalDependencies: [".env"],
- globalEnv: ["NEXT_PUBLIC_API_KEY", "STRIPE_API_KEY"],
- pipeline: {
- build: {
- dependsOn: ["^build"],
- env: ["PROD_API_KEY"],
- outputs: [".next/**", "!.next/cache/**"],
- },
- dev: {
- cache: false,
- },
- lint: {
- dependsOn: [],
- env: ["IS_TEST"],
- outputs: [],
- },
- test: {
- dependsOn: ["test"],
- env: ["IS_CI"],
- outputs: [],
- },
- },
- });
-
- expect(readJson("apps/web/turbo.json") || "{}").toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- extends: ["//"],
- pipeline: {
- build: {
- // old
- dependsOn: ["build"],
- // new
- env: ["ENV_1", "ENV_2"],
- },
- },
- });
-
- expect(readJson("packages/ui/turbo.json") || "{}").toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- extends: ["//"],
- pipeline: {
- build: {
- dependsOn: [],
- env: ["IS_SERVER"],
- },
- },
- });
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "apps/web/turbo.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 0,
- },
- "packages/ui/turbo.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 1,
- },
- "turbo.json": Object {
- "action": "modified",
- "additions": 4,
- "deletions": 4,
- },
- }
- `);
- });
-
- it("migrates turbo.json env var dependencies - repeat run", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "env-dependencies",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(JSON.parse(read("turbo.json") || "{}")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- globalDependencies: [".env"],
- globalEnv: ["NEXT_PUBLIC_API_KEY", "STRIPE_API_KEY"],
- pipeline: {
- build: {
- dependsOn: ["^build"],
- env: ["PROD_API_KEY"],
- outputs: [".next/**", "!.next/cache/**"],
- },
- dev: {
- cache: false,
- },
- lint: {
- dependsOn: [],
- env: ["IS_CI"],
- outputs: [],
- },
- test: {
- dependsOn: ["test"],
- env: ["IS_CI"],
- outputs: [],
- },
- },
- });
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "modified",
- "additions": 4,
- "deletions": 4,
- },
- }
- `);
-
- // run the transformer
- const repeatResult = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(repeatResult.fatalError).toBeUndefined();
- expect(repeatResult.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- }
- `);
- });
-
- it("migrates turbo.json env var dependencies - dry", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "env-dependencies",
- });
-
- const turboJson = JSON.parse(read("turbo.json") || "{}");
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: true, print: false },
- });
-
- // make sure it didn't change
- expect(JSON.parse(read("turbo.json") || "{}")).toEqual(turboJson);
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "skipped",
- "additions": 4,
- "deletions": 4,
- },
- }
- `);
- });
-
- it("migrates turbo.json env var dependencies - print", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "env-dependencies",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: true },
- });
-
- expect(JSON.parse(read("turbo.json") || "{}")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- globalEnv: ["NEXT_PUBLIC_API_KEY", "STRIPE_API_KEY"],
- globalDependencies: [".env"],
- pipeline: {
- build: {
- dependsOn: ["^build"],
- env: ["PROD_API_KEY"],
- outputs: [".next/**", "!.next/cache/**"],
- },
- dev: {
- cache: false,
- },
- lint: {
- dependsOn: [],
- env: ["IS_CI"],
- outputs: [],
- },
- test: {
- dependsOn: ["test"],
- env: ["IS_CI"],
- outputs: [],
- },
- },
- });
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "modified",
- "additions": 4,
- "deletions": 4,
- },
- }
- `);
- });
-
- it("migrates turbo.json env var dependencies - dry & print", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "env-dependencies",
- });
-
- const turboJson = JSON.parse(read("turbo.json") || "{}");
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: true, print: true },
- });
-
- // make sure it didn't change
- expect(JSON.parse(read("turbo.json") || "{}")).toEqual(turboJson);
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "skipped",
- "additions": 4,
- "deletions": 4,
- },
- }
- `);
- });
-
- it("does not change turbo.json if already migrated", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "migrated-env-dependencies",
- });
-
- const turboJson = JSON.parse(read("turbo.json") || "{}");
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(JSON.parse(read("turbo.json") || "{}")).toEqual(turboJson);
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- }
- `);
- });
-
- it("errors if no turbo.json can be found", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "no-turbo-json",
- });
-
- expect(read("turbo.json")).toBeUndefined();
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(read("turbo.json")).toBeUndefined();
- expect(result.fatalError).toBeDefined();
- expect(result.fatalError?.message).toMatch(
- /No turbo\.json found at .*?\. Is the path correct\?/
- );
- });
-
- it("errors if package.json config exists and has not been migrated", async () => {
- // load the fixture for the test
- const { root } = useFixture({
- fixture: "old-config",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(result.fatalError).toBeDefined();
- expect(result.fatalError?.message).toMatch(
- 'turbo" key detected in package.json. Run `npx @turbo/codemod transform create-turbo-config` first'
- );
- });
- });
-});
diff --git a/packages/turbo-codemod/__tests__/migrate.test.ts b/packages/turbo-codemod/__tests__/migrate.test.ts
deleted file mode 100644
index 652ea41..0000000
--- a/packages/turbo-codemod/__tests__/migrate.test.ts
+++ /dev/null
@@ -1,761 +0,0 @@
-import { MigrateCommandArgument } from "../src/commands";
-import migrate from "../src/commands/migrate";
-import { setupTestFixtures, spyExit } from "@turbo/test-utils";
-import childProcess from "child_process";
-import * as checkGitStatus from "../src/utils/checkGitStatus";
-import * as getCurrentVersion from "../src/commands/migrate/steps/getCurrentVersion";
-import * as getLatestVersion from "../src/commands/migrate/steps/getLatestVersion";
-import * as getTurboUpgradeCommand from "../src/commands/migrate/steps/getTurboUpgradeCommand";
-import * as workspaceImplementation from "../src/utils/getPackageManager";
-import * as getPackageManagerVersion from "../src/utils/getPackageManagerVersion";
-
-describe("migrate", () => {
- const mockExit = spyExit();
- const { useFixture } = setupTestFixtures({
- directory: __dirname,
- test: "migrate",
- });
-
- it("migrates from 1.0.0 to 1.7.0", async () => {
- const { root, readJson } = useFixture({
- fixture: "old-turbo",
- });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue("1.0.0");
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockResolvedValue("1.7.0");
- const mockedGetTurboUpgradeCommand = jest
- .spyOn(getTurboUpgradeCommand, "default")
- .mockReturnValue("pnpm install -g turbo@latest");
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockedGetWorkspaceImplementation = jest
- .spyOn(workspaceImplementation, "default")
- .mockReturnValue(packageManager);
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: false,
- });
-
- expect(readJson("package.json")).toStrictEqual({
- dependencies: {},
- devDependencies: {
- turbo: "1.0.0",
- },
- name: "no-turbo-json",
- packageManager: "pnpm@1.2.3",
- version: "1.0.0",
- });
- expect(readJson("turbo.json")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- pipeline: {
- build: {
- outputs: [".next/**", "!.next/cache/**"],
- },
- dev: {
- cache: false,
- },
- lint: {},
- test: {
- outputs: ["dist/**", "build/**"],
- },
- },
- });
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
- expect(mockedGetTurboUpgradeCommand).toHaveBeenCalled();
- expect(mockedGetPackageManagerVersion).toHaveBeenCalled();
- expect(mockedGetWorkspaceImplementation).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- mockedGetLatestVersion.mockRestore();
- mockedGetTurboUpgradeCommand.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- mockedGetWorkspaceImplementation.mockRestore();
- });
-
- it("migrates from 1.0.0 to 1.2.0 (dry run)", async () => {
- const { root, readJson } = useFixture({
- fixture: "old-turbo",
- });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue("1.0.0");
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockResolvedValue("1.2.0");
- const mockedGetTurboUpgradeCommand = jest
- .spyOn(getTurboUpgradeCommand, "default")
- .mockReturnValue("pnpm install -g turbo@latest");
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockedGetWorkspaceImplementation = jest
- .spyOn(workspaceImplementation, "default")
- .mockReturnValue(packageManager);
-
- const packageJson = readJson("package.json");
- const turboJson = readJson("turbo.json");
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: true,
- print: false,
- install: true,
- });
-
- // make sure nothing changed
- expect(readJson("package.json")).toStrictEqual(packageJson);
- expect(readJson("turbo.json")).toStrictEqual(turboJson);
-
- // verify mocks were called
- expect(mockedCheckGitStatus).not.toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
- expect(mockedGetTurboUpgradeCommand).toHaveBeenCalled();
- expect(mockedGetPackageManagerVersion).toHaveBeenCalled();
- expect(mockedGetWorkspaceImplementation).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- mockedGetLatestVersion.mockRestore();
- mockedGetTurboUpgradeCommand.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- mockedGetWorkspaceImplementation.mockRestore();
- });
-
- it("next version can be passed as an option", async () => {
- const { root, readJson } = useFixture({
- fixture: "old-turbo",
- });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue("1.0.0");
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockResolvedValue("1.7.0");
- const mockedGetTurboUpgradeCommand = jest
- .spyOn(getTurboUpgradeCommand, "default")
- .mockReturnValue("pnpm install -g turbo@latest");
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockedGetWorkspaceImplementation = jest
- .spyOn(workspaceImplementation, "default")
- .mockReturnValue(packageManager);
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: false,
- to: "1.7.0",
- });
-
- expect(readJson("package.json")).toStrictEqual({
- dependencies: {},
- devDependencies: {
- turbo: "1.0.0",
- },
- name: "no-turbo-json",
- packageManager: "pnpm@1.2.3",
- version: "1.0.0",
- });
- expect(readJson("turbo.json")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- pipeline: {
- build: {
- outputs: [".next/**", "!.next/cache/**"],
- },
- dev: {
- cache: false,
- },
- test: {
- outputs: ["dist/**", "build/**"],
- },
- lint: {},
- },
- });
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
- expect(mockedGetTurboUpgradeCommand).toHaveBeenCalled();
- expect(mockedGetPackageManagerVersion).toHaveBeenCalled();
- expect(mockedGetWorkspaceImplementation).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- mockedGetLatestVersion.mockRestore();
- mockedGetTurboUpgradeCommand.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- mockedGetWorkspaceImplementation.mockRestore();
- });
-
- it("current version can be passed as an option", async () => {
- const { root, readJson } = useFixture({
- fixture: "old-turbo",
- });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockResolvedValue("1.7.0");
- const mockedGetTurboUpgradeCommand = jest
- .spyOn(getTurboUpgradeCommand, "default")
- .mockReturnValue("pnpm install -g turbo@latest");
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
-
- const mockedGetWorkspaceImplementation = jest
- .spyOn(workspaceImplementation, "default")
- .mockReturnValue(packageManager);
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: false,
- from: "1.0.0",
- });
-
- expect(readJson("package.json")).toStrictEqual({
- dependencies: {},
- devDependencies: {
- turbo: "1.0.0",
- },
- name: "no-turbo-json",
- packageManager: "pnpm@1.2.3",
- version: "1.0.0",
- });
- expect(readJson("turbo.json")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- pipeline: {
- build: {
- outputs: [".next/**", "!.next/cache/**"],
- },
- dev: {
- cache: false,
- },
- lint: {},
- test: {
- outputs: ["dist/**", "build/**"],
- },
- },
- });
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
- expect(mockedGetTurboUpgradeCommand).toHaveBeenCalled();
- expect(mockedGetPackageManagerVersion).toHaveBeenCalled();
- expect(mockedGetWorkspaceImplementation).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetLatestVersion.mockRestore();
- mockedGetTurboUpgradeCommand.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- mockedGetWorkspaceImplementation.mockRestore();
- });
-
- it("exits if the current version is the same as the new version", async () => {
- const { root } = useFixture({
- fixture: "old-turbo",
- });
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue("1.7.0");
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockResolvedValue("1.7.0");
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: false,
- });
-
- expect(mockExit.exit).toHaveBeenCalledWith(0);
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- mockedGetLatestVersion.mockRestore();
- });
-
- it("continues when migration doesn't require codemods", async () => {
- const { root } = useFixture({
- fixture: "old-turbo",
- });
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue("1.3.0");
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockResolvedValue("1.3.1");
- const mockedGetTurboUpgradeCommand = jest
- .spyOn(getTurboUpgradeCommand, "default")
- .mockReturnValue("npm install turbo@1.3.1");
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockReturnValue("installed");
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: true,
- });
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
- expect(mockedGetTurboUpgradeCommand).toHaveBeenCalled();
- expect(mockExecSync).toHaveBeenCalledWith("npm install turbo@1.3.1", {
- cwd: root,
- });
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- mockedGetLatestVersion.mockRestore();
- mockedGetTurboUpgradeCommand.mockRestore();
- mockExecSync.mockRestore();
- });
-
- it("installs the correct turbo version", async () => {
- const { root, readJson } = useFixture({
- fixture: "old-turbo",
- });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue("1.0.0");
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockResolvedValue("1.7.0");
- const mockedGetTurboUpgradeCommand = jest
- .spyOn(getTurboUpgradeCommand, "default")
- .mockReturnValue("pnpm install -g turbo@1.7.0");
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockedGetWorkspaceImplementation = jest
- .spyOn(workspaceImplementation, "default")
- .mockReturnValue(packageManager);
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockReturnValue("installed");
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: true,
- });
-
- expect(readJson("package.json")).toStrictEqual({
- dependencies: {},
- devDependencies: {
- turbo: "1.0.0",
- },
- name: "no-turbo-json",
- packageManager: "pnpm@1.2.3",
- version: "1.0.0",
- });
- expect(readJson("turbo.json")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- pipeline: {
- build: {
- outputs: [".next/**", "!.next/cache/**"],
- },
- dev: {
- cache: false,
- },
- lint: {},
- test: {
- outputs: ["dist/**", "build/**"],
- },
- },
- });
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
- expect(mockedGetTurboUpgradeCommand).toHaveBeenCalled();
- expect(mockedGetPackageManagerVersion).toHaveBeenCalled();
- expect(mockedGetWorkspaceImplementation).toHaveBeenCalled();
- expect(mockExecSync).toHaveBeenCalled();
- expect(mockExecSync).toHaveBeenCalledWith("pnpm install -g turbo@1.7.0", {
- cwd: root,
- });
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- mockedGetLatestVersion.mockRestore();
- mockedGetTurboUpgradeCommand.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- mockedGetWorkspaceImplementation.mockRestore();
- mockExecSync.mockRestore();
- });
-
- it("fails gracefully when the correct upgrade command cannot be found", async () => {
- const { root, readJson } = useFixture({
- fixture: "old-turbo",
- });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue("1.0.0");
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockResolvedValue("1.7.0");
- const mockedGetTurboUpgradeCommand = jest
- .spyOn(getTurboUpgradeCommand, "default")
- .mockReturnValue(undefined);
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockedGetWorkspaceImplementation = jest
- .spyOn(workspaceImplementation, "default")
- .mockReturnValue(packageManager);
- const mockExecSync = jest
- .spyOn(childProcess, "execSync")
- .mockReturnValue("installed");
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: true,
- });
-
- expect(readJson("package.json")).toStrictEqual({
- dependencies: {},
- devDependencies: {
- turbo: "1.0.0",
- },
- name: "no-turbo-json",
- packageManager: "pnpm@1.2.3",
- version: "1.0.0",
- });
- expect(readJson("turbo.json")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- pipeline: {
- build: {
- outputs: [".next/**", "!.next/cache/**"],
- },
- dev: {
- cache: false,
- },
- lint: {},
- test: {
- outputs: ["dist/**", "build/**"],
- },
- },
- });
-
- expect(mockExit.exit).toHaveBeenCalledWith(1);
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
- expect(mockedGetTurboUpgradeCommand).toHaveBeenCalled();
- expect(mockedGetPackageManagerVersion).toHaveBeenCalled();
- expect(mockedGetWorkspaceImplementation).toHaveBeenCalled();
- expect(mockExecSync).not.toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- mockedGetLatestVersion.mockRestore();
- mockedGetTurboUpgradeCommand.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- mockedGetWorkspaceImplementation.mockRestore();
- mockExecSync.mockRestore();
- });
-
- it("exits if current version is not passed and cannot be inferred", async () => {
- const { root } = useFixture({
- fixture: "old-turbo",
- });
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue(undefined);
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: false,
- });
-
- expect(mockExit.exit).toHaveBeenCalledWith(1);
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- });
-
- it("exits if latest version is not passed and cannot be inferred", async () => {
- const { root } = useFixture({
- fixture: "old-turbo",
- });
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue("1.5.0");
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockResolvedValue(undefined);
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: false,
- });
-
- expect(mockExit.exit).toHaveBeenCalledWith(1);
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- mockedGetLatestVersion.mockRestore();
- });
-
- it("exits if latest version throws", async () => {
- const { root } = useFixture({
- fixture: "old-turbo",
- });
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue("1.5.0");
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockRejectedValue(new Error("failed to fetch version"));
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: false,
- });
-
- expect(mockExit.exit).toHaveBeenCalledWith(1);
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- mockedGetLatestVersion.mockRestore();
- });
-
- it("exits if any transforms encounter an error", async () => {
- const { root } = useFixture({
- fixture: "old-turbo",
- });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetCurrentVersion = jest
- .spyOn(getCurrentVersion, "default")
- .mockReturnValue("1.0.0");
- const mockedGetLatestVersion = jest
- .spyOn(getLatestVersion, "default")
- .mockResolvedValue("1.7.0");
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockedGetWorkspaceImplementation = jest
- .spyOn(workspaceImplementation, "default")
- .mockReturnValue(packageManager);
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: true,
- print: false,
- install: true,
- });
-
- expect(mockExit.exit).toHaveBeenCalledWith(1);
-
- // verify mocks were called
- expect(mockedCheckGitStatus).not.toHaveBeenCalled();
- expect(mockedGetCurrentVersion).toHaveBeenCalled();
- expect(mockedGetLatestVersion).toHaveBeenCalled();
- expect(mockedGetPackageManagerVersion).toHaveBeenCalled();
- expect(mockedGetWorkspaceImplementation).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetCurrentVersion.mockRestore();
- mockedGetLatestVersion.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- mockedGetWorkspaceImplementation.mockRestore();
- });
-
- it("exits if invalid directory is passed", async () => {
- const { root } = useFixture({
- fixture: "old-turbo",
- });
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
-
- await migrate("~/path/that/does/not/exist" as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: false,
- });
-
- expect(mockExit.exit).toHaveBeenCalledWith(1);
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- });
-
- it("exits if directory with no repo is passed", async () => {
- const { root } = useFixture({
- fixture: "no-repo",
- });
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
-
- await migrate(root as MigrateCommandArgument, {
- force: false,
- dry: false,
- print: false,
- install: false,
- });
-
- expect(mockExit.exit).toHaveBeenCalledWith(1);
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- });
-});
diff --git a/packages/turbo-codemod/__tests__/set-default-outputs.test.ts b/packages/turbo-codemod/__tests__/set-default-outputs.test.ts
deleted file mode 100644
index 4a71fa7..0000000
--- a/packages/turbo-codemod/__tests__/set-default-outputs.test.ts
+++ /dev/null
@@ -1,391 +0,0 @@
-import { transformer } from "../src/transforms/set-default-outputs";
-import { setupTestFixtures } from "@turbo/test-utils";
-
-describe("set-default-outputs", () => {
- const { useFixture } = setupTestFixtures({
- directory: __dirname,
- test: "set-default-outputs",
- });
- it("migrates turbo.json outputs - basic", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "old-outputs",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(JSON.parse(read("turbo.json") || "{}")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- pipeline: {
- "build-one": {
- outputs: ["foo"],
- },
- "build-two": {},
- "build-three": {
- outputs: ["dist/**", "build/**"],
- },
- },
- });
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "modified",
- "additions": 2,
- "deletions": 1,
- },
- }
- `);
- });
-
- it("migrates turbo.json outputs - workspace configs", async () => {
- // load the fixture for the test
- const { root, readJson } = useFixture({
- fixture: "workspace-configs",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(readJson("turbo.json") || "{}").toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- pipeline: {
- "build-one": {
- outputs: ["foo"],
- },
- "build-two": {},
- "build-three": {
- outputs: ["dist/**", "build/**"],
- },
- },
- });
-
- expect(readJson("apps/docs/turbo.json") || "{}").toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- extends: ["//"],
- pipeline: {
- build: {
- outputs: ["dist/**", "build/**"],
- },
- },
- });
-
- expect(readJson("apps/web/turbo.json") || "{}").toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- extends: ["//"],
- pipeline: {
- build: {},
- },
- });
-
- expect(readJson("packages/ui/turbo.json") || "{}").toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- extends: ["//"],
- pipeline: {
- "build-three": {
- outputs: ["dist/**", "build/**"],
- },
- },
- });
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "apps/docs/turbo.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 1,
- },
- "apps/web/turbo.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 0,
- },
- "packages/ui/turbo.json": Object {
- "action": "modified",
- "additions": 1,
- "deletions": 1,
- },
- "turbo.json": Object {
- "action": "modified",
- "additions": 2,
- "deletions": 1,
- },
- }
- `);
- });
-
- it("migrates turbo.json outputs - dry", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "old-outputs",
- });
-
- const turboJson = JSON.parse(read("turbo.json") || "{}");
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: true, print: false },
- });
-
- // make sure it didn't change
- expect(JSON.parse(read("turbo.json") || "{}")).toEqual(turboJson);
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "skipped",
- "additions": 2,
- "deletions": 1,
- },
- }
- `);
- });
-
- it("migrates turbo.json outputs - print", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "old-outputs",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: true },
- });
-
- expect(JSON.parse(read("turbo.json") || "{}")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- pipeline: {
- "build-one": {
- outputs: ["foo"],
- },
- "build-two": {},
- "build-three": {
- outputs: ["dist/**", "build/**"],
- },
- },
- });
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "modified",
- "additions": 2,
- "deletions": 1,
- },
- }
- `);
- });
-
- it("migrates turbo.json outputs - dry & print", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "old-outputs",
- });
-
- const turboJson = JSON.parse(read("turbo.json") || "{}");
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: true, print: false },
- });
-
- // make sure it didn't change
- expect(JSON.parse(read("turbo.json") || "{}")).toEqual(turboJson);
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "skipped",
- "additions": 2,
- "deletions": 1,
- },
- }
- `);
- });
-
- it("migrates turbo.json outputs - invalid", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "invalid-outputs",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(JSON.parse(read("turbo.json") || "{}")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- pipeline: {
- "build-one": {
- outputs: ["foo"],
- },
- "build-two": {},
- "build-three": {
- outputs: ["dist/**", "build/**"],
- },
- "garbage-in-numeric-0": {
- outputs: ["dist/**", "build/**"],
- },
- "garbage-in-numeric": {
- outputs: 42,
- },
- "garbage-in-string": {
- outputs: "string",
- },
- "garbage-in-empty-string": {
- outputs: ["dist/**", "build/**"],
- },
- "garbage-in-null": {
- outputs: ["dist/**", "build/**"],
- },
- "garbage-in-false": {
- outputs: ["dist/**", "build/**"],
- },
- "garbage-in-true": {
- outputs: true,
- },
- "garbage-in-object": {
- outputs: {},
- },
- },
- });
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "modified",
- "additions": 6,
- "deletions": 5,
- },
- }
- `);
- });
-
- it("migrates turbo.json outputs - config with no pipeline", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "no-pipeline",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(JSON.parse(read("turbo.json") || "{}")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- globalDependencies: ["$NEXT_PUBLIC_API_KEY", "$STRIPE_API_KEY", ".env"],
- pipeline: {},
- });
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "unchanged",
- "additions": 0,
- "deletions": 0,
- },
- }
- `);
- });
-
- it("migrates turbo.json outputs - config with no outputs", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "no-outputs",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(JSON.parse(read("turbo.json") || "{}")).toStrictEqual({
- $schema: "https://turbo.build/schema.json",
- pipeline: {
- "build-one": {
- dependsOn: ["build-two"],
- outputs: ["dist/**", "build/**"],
- },
- "build-two": {
- cache: false,
- },
- "build-three": {
- persistent: true,
- outputs: ["dist/**", "build/**"],
- },
- },
- });
-
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot(`
- Object {
- "turbo.json": Object {
- "action": "modified",
- "additions": 2,
- "deletions": 0,
- },
- }
- `);
- });
-
- it("errors if no turbo.json can be found", async () => {
- // load the fixture for the test
- const { root, read } = useFixture({
- fixture: "no-turbo-json",
- });
-
- expect(read("turbo.json")).toBeUndefined();
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(read("turbo.json")).toBeUndefined();
- expect(result.fatalError).toBeDefined();
- expect(result.fatalError?.message).toMatch(
- /No turbo\.json found at .*?\. Is the path correct\?/
- );
- });
-
- it("errors if package.json config exists and has not been migrated", async () => {
- // load the fixture for the test
- const { root } = useFixture({
- fixture: "old-config",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- expect(result.fatalError).toBeDefined();
- expect(result.fatalError?.message).toMatch(
- 'turbo" key detected in package.json. Run `npx @turbo/codemod transform create-turbo-config` first'
- );
- });
-});
diff --git a/packages/turbo-codemod/__tests__/transform.test.ts b/packages/turbo-codemod/__tests__/transform.test.ts
deleted file mode 100644
index abd015d..0000000
--- a/packages/turbo-codemod/__tests__/transform.test.ts
+++ /dev/null
@@ -1,172 +0,0 @@
-import transform from "../src/commands/transform";
-import { MigrateCommandArgument } from "../src/commands";
-import { setupTestFixtures, spyExit } from "@turbo/test-utils";
-import * as checkGitStatus from "../src/utils/checkGitStatus";
-import * as getPackageManager from "../src/utils/getPackageManager";
-import * as getPackageManagerVersion from "../src/utils/getPackageManagerVersion";
-
-describe("transform", () => {
- const mockExit = spyExit();
- const { useFixture } = setupTestFixtures({
- directory: __dirname,
- test: "transform",
- });
-
- it("runs the selected transform", async () => {
- const { root, readJson } = useFixture({
- fixture: "basic",
- });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockedGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager);
-
- await transform(
- "add-package-manager" as MigrateCommandArgument,
- root as MigrateCommandArgument,
- {
- list: false,
- force: false,
- dry: false,
- print: false,
- }
- );
-
- expect(readJson("package.json")).toStrictEqual({
- dependencies: {},
- devDependencies: {
- turbo: "1.0.0",
- },
- name: "transform-basic",
- packageManager: "pnpm@1.2.3",
- version: "1.0.0",
- });
-
- // verify mocks were called
- expect(mockedCheckGitStatus).toHaveBeenCalled();
- expect(mockedGetPackageManagerVersion).toHaveBeenCalled();
- expect(mockedGetPackageManager).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- mockedGetPackageManager.mockRestore();
- });
-
- it("runs the selected transform - dry & print", async () => {
- const { root, readJson } = useFixture({
- fixture: "basic",
- });
-
- const packageManager = "pnpm";
- const packageManagerVersion = "1.2.3";
-
- // setup mocks
- const mockedCheckGitStatus = jest
- .spyOn(checkGitStatus, "default")
- .mockReturnValue(undefined);
- const mockedGetPackageManagerVersion = jest
- .spyOn(getPackageManagerVersion, "default")
- .mockReturnValue(packageManagerVersion);
- const mockedGetPackageManager = jest
- .spyOn(getPackageManager, "default")
- .mockReturnValue(packageManager);
-
- await transform(
- "add-package-manager" as MigrateCommandArgument,
- root as MigrateCommandArgument,
- {
- list: false,
- force: false,
- dry: true,
- print: true,
- }
- );
-
- expect(readJson("package.json")).toStrictEqual({
- dependencies: {},
- devDependencies: {
- turbo: "1.0.0",
- },
- name: "transform-basic",
- version: "1.0.0",
- });
-
- // verify mocks were called
- expect(mockedCheckGitStatus).not.toHaveBeenCalled();
- expect(mockedGetPackageManagerVersion).toHaveBeenCalled();
- expect(mockedGetPackageManager).toHaveBeenCalled();
-
- // restore mocks
- mockedCheckGitStatus.mockRestore();
- mockedGetPackageManagerVersion.mockRestore();
- mockedGetPackageManager.mockRestore();
- });
-
- it("lists transforms", async () => {
- const { root } = useFixture({
- fixture: "basic",
- });
-
- await transform(
- "add-package-manager" as MigrateCommandArgument,
- root as MigrateCommandArgument,
- {
- list: true,
- force: false,
- dry: false,
- print: false,
- }
- );
-
- expect(mockExit.exit).toHaveBeenCalledWith(0);
- });
-
- it("exits on invalid transform", async () => {
- const { root } = useFixture({
- fixture: "basic",
- });
-
- await transform(
- "not-a-real-option" as MigrateCommandArgument,
- root as MigrateCommandArgument,
- {
- list: false,
- force: false,
- dry: false,
- print: false,
- }
- );
-
- expect(mockExit.exit).toHaveBeenCalledWith(1);
- });
-
- it("exits on invalid directory", async () => {
- const { root } = useFixture({
- fixture: "basic",
- });
-
- await transform(
- "add-package-manager" as MigrateCommandArgument,
- "~/path/that/does/not/exist" as MigrateCommandArgument,
- {
- list: false,
- force: false,
- dry: false,
- print: false,
- }
- );
-
- expect(mockExit.exit).toHaveBeenCalledWith(1);
- });
-});
diff --git a/packages/turbo-codemod/index.d.ts b/packages/turbo-codemod/index.d.ts
deleted file mode 100644
index c3a4874..0000000
--- a/packages/turbo-codemod/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module "is-git-clean";
diff --git a/packages/turbo-codemod/jest.config.js b/packages/turbo-codemod/jest.config.js
deleted file mode 100644
index 2c7542a..0000000
--- a/packages/turbo-codemod/jest.config.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
- preset: "ts-jest/presets/js-with-ts",
- testEnvironment: "node",
- transformIgnorePatterns: ["/node_modules/(?!(ansi-regex)/)"],
- modulePathIgnorePatterns: ["<rootDir>/node_modules", "<rootDir>/dist"],
- testPathIgnorePatterns: ["/__fixtures__/"],
- coveragePathIgnorePatterns: ["/__fixtures__/"],
- collectCoverage: true,
- coverageThreshold: {
- global: {
- branches: 80,
- functions: 89,
- lines: 89,
- statements: 89,
- },
- },
-};
diff --git a/packages/turbo-codemod/package.json b/packages/turbo-codemod/package.json
deleted file mode 100644
index d16bb05..0000000
--- a/packages/turbo-codemod/package.json
+++ /dev/null
@@ -1,67 +0,0 @@
-{
- "name": "@turbo/codemod",
- "version": "1.9.4-canary.2",
- "description": "Provides Codemod transformations to help upgrade your Turborepo codebase when a feature is deprecated.",
- "homepage": "https://turbo.build/repo",
- "license": "MPL-2.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/turbo",
- "directory": "packages/turbo-codemod"
- },
- "bugs": {
- "url": "https://github.com/vercel/turbo/issues"
- },
- "bin": "dist/cli.js",
- "scripts": {
- "build": "tsup",
- "test": "jest",
- "lint": "eslint src/**/*.ts",
- "check-types": "tsc --noEmit",
- "add-transformer": "plop"
- },
- "dependencies": {
- "axios": "0.27.2",
- "chalk": "2.4.2",
- "commander": "^9.5.0",
- "diff": "^5.1.0",
- "find-up": "4.1.0",
- "fs-extra": "^10.0.0",
- "gradient-string": "^2.0.0",
- "inquirer": "^8.2.4",
- "inquirer-file-tree-selection-prompt": "^1.0.19",
- "is-git-clean": "^1.1.0",
- "ora": "4.1.1",
- "semver": "^7.3.7",
- "update-check": "^1.5.4"
- },
- "devDependencies": {
- "@types/chalk-animation": "^1.6.0",
- "@types/diff": "^5.0.2",
- "@types/fs-extra": "^9.0.13",
- "@types/gradient-string": "^1.1.2",
- "@types/inquirer": "^8.2.0",
- "@types/jest": "^27.4.0",
- "@types/node": "^16.11.12",
- "@types/semver": "^7.3.9",
- "@types/uuid": "^9.0.0",
- "deepmerge": "^4.2.2",
- "eslint": "^7.23.0",
- "jest": "^27.4.3",
- "plop": "^3.1.1",
- "semver": "^7.3.5",
- "ts-jest": "^27.1.1",
- "@turbo/tsconfig": "workspace:*",
- "tsup": "^5.10.3",
- "@turbo/test-utils": "workspace:*",
- "@turbo/types": "workspace:*",
- "@turbo/utils": "workspace:*",
- "typescript": "^4.5.5"
- },
- "files": [
- "dist"
- ],
- "publishConfig": {
- "access": "public"
- }
-}
diff --git a/packages/turbo-codemod/plopfile.js b/packages/turbo-codemod/plopfile.js
deleted file mode 100644
index 9cc2dd7..0000000
--- a/packages/turbo-codemod/plopfile.js
+++ /dev/null
@@ -1,46 +0,0 @@
-const fs = require("fs-extra");
-
-module.exports = function plopConfig(plop) {
- // controller generator
- plop.setGenerator("controller", {
- description: "Add a new transformer",
- prompts: [
- {
- type: "input",
- name: "name",
- message: 'key for the transform (example: "create-turbo-config")',
- },
- {
- type: "input",
- name: "description",
- message:
- 'description for the transform (example: "Create the `turbo.json` file from an existing "turbo" key in `package.json`")',
- },
- {
- type: "input",
- name: "introducedIn",
- message:
- 'the semantic version of turbo where this change was introduced (example: "1.1.0")',
- },
- ],
- actions: [
- {
- type: "add",
- path: "src/transforms/{{name}}.ts",
- templateFile: "templates/transformer.hbs",
- },
- {
- type: "add",
- path: "__tests__/{{name}}.test.ts",
- templateFile: "templates/transformer.test.hbs",
- },
- function createFixturesDirectory(answers) {
- process.chdir(plop.getPlopfilePath());
- const directory = `__tests__/__fixtures__/${answers.name}`;
- fs.mkdirSync(`__tests__/__fixtures__/${answers.name}`);
-
- return `created empty ${directory} directory for fixtures`;
- },
- ],
- });
-};
diff --git a/packages/turbo-codemod/src/cli.ts b/packages/turbo-codemod/src/cli.ts
deleted file mode 100644
index 451816f..0000000
--- a/packages/turbo-codemod/src/cli.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env node
-
-import chalk from "chalk";
-import { Command } from "commander";
-
-import { transform, migrate } from "./commands";
-import notifyUpdate from "./utils/notifyUpdate";
-import cliPkg from "../package.json";
-
-const codemodCli = new Command();
-
-codemodCli
- .name("@turbo/codemod")
- .description(
- "Codemod transformations to help upgrade your Turborepo codebase when a feature is deprecated."
- )
- .version(cliPkg.version, "-v, --version", "output the current version");
-
-// migrate
-codemodCli
- .command("migrate")
- .aliases(["update", "upgrade"])
- .description("Migrate a project to the latest version of Turborepo")
- .argument("[path]", "Directory where the transforms should be applied")
- .option(
- "--from <version>",
- "Specify the version to migrate from (default: current version)"
- )
- .option(
- "--to <version>",
- "Specify the version to migrate to (default: latest)"
- )
- .option("--install", "Install new version of turbo after migration", true)
- .option(
- "--force",
- "Bypass Git safety checks and forcibly run codemods",
- false
- )
- .option("--dry", "Dry run (no changes are made to files)", false)
- .option("--print", "Print transformed files to your terminal", false)
- .action(migrate);
-
-// transform
-codemodCli
- .command("transform", { isDefault: true })
- .description("Apply a single code transformation to a project")
- .argument("[transform]", "The transformer to run")
- .argument("[path]", "Directory where the transforms should be applied")
- .option(
- "--force",
- "Bypass Git safety checks and forcibly run codemods",
- false
- )
- .option("--list", "List all available transforms", false)
- .option("--dry", "Dry run (no changes are made to files)", false)
- .option("--print", "Print transformed files to your terminal", false)
- .action(transform);
-
-codemodCli
- .parseAsync()
- .then(notifyUpdate)
- .catch(async (reason) => {
- console.log();
- if (reason.command) {
- console.log(` ${chalk.cyan(reason.command)} has failed.`);
- } else {
- console.log(chalk.red("Unexpected error. Please report it as a bug:"));
- console.log(reason);
- }
- console.log();
- await notifyUpdate();
- process.exit(1);
- });
diff --git a/packages/turbo-codemod/src/commands/index.ts b/packages/turbo-codemod/src/commands/index.ts
deleted file mode 100644
index a7aeee6..0000000
--- a/packages/turbo-codemod/src/commands/index.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export { default as migrate } from "./migrate";
-export { default as transform } from "./transform";
-
-export type {
- TransformCommandArgument,
- TransformCommandOptions,
-} from "./transform/types";
-export type {
- MigrateCommandArgument,
- MigrateCommandOptions,
-} from "./migrate/types";
diff --git a/packages/turbo-codemod/src/commands/migrate/index.ts b/packages/turbo-codemod/src/commands/migrate/index.ts
deleted file mode 100644
index c4c6d02..0000000
--- a/packages/turbo-codemod/src/commands/migrate/index.ts
+++ /dev/null
@@ -1,215 +0,0 @@
-import chalk from "chalk";
-import os from "os";
-import inquirer from "inquirer";
-import { execSync } from "child_process";
-
-import getCurrentVersion from "./steps/getCurrentVersion";
-import getLatestVersion from "./steps/getLatestVersion";
-import getCodemodsForMigration from "./steps/getTransformsForMigration";
-import checkGitStatus from "../../utils/checkGitStatus";
-import directoryInfo from "../../utils/directoryInfo";
-import getTurboUpgradeCommand from "./steps/getTurboUpgradeCommand";
-import Runner from "../../runner/Runner";
-import type { MigrateCommandArgument, MigrateCommandOptions } from "./types";
-import looksLikeRepo from "../../utils/looksLikeRepo";
-
-function endMigration({
- message,
- success,
-}: {
- message?: string;
- success: boolean;
-}) {
- if (success) {
- console.log(chalk.bold(chalk.green("Migration completed")));
- if (message) {
- console.log(message);
- }
- return process.exit(0);
- }
-
- console.log(chalk.bold(chalk.red("Migration failed")));
- if (message) {
- console.log(message);
- }
- return process.exit(1);
-}
-
-/**
-Migration is done in 4 steps:
- -- gather information
- 1. find the version (x) of turbo to migrate from (if not specified)
- 2. find the version (y) of turbo to migrate to (if not specified)
- 3. determine which codemods need to be run to move from version x to version y
- -- action
- 4. execute the codemods (serially, and in order)
- 5. update the turbo version (optionally)
-**/
-export default async function migrate(
- directory: MigrateCommandArgument,
- options: MigrateCommandOptions
-) {
- // check git status
- if (!options.dry) {
- checkGitStatus({ directory, force: options.force });
- }
-
- const answers = await inquirer.prompt<{
- directoryInput?: string;
- }>([
- {
- type: "input",
- name: "directoryInput",
- message: "Where is the root of the repo to migrate?",
- when: !directory,
- default: ".",
- validate: (directory: string) => {
- const { exists, absolute } = directoryInfo({ directory });
- if (exists) {
- return true;
- } else {
- return `Directory ${chalk.dim(`(${absolute})`)} does not exist`;
- }
- },
- filter: (directory: string) => directory.trim(),
- },
- ]);
-
- const { directoryInput: selectedDirectory = directory as string } = answers;
- const { exists, absolute: root } = directoryInfo({
- directory: selectedDirectory,
- });
- if (!exists) {
- return endMigration({
- success: false,
- message: `Directory ${chalk.dim(`(${root})`)} does not exist`,
- });
- }
-
- if (!looksLikeRepo({ directory: root })) {
- return endMigration({
- success: false,
- message: `Directory (${chalk.dim(
- root
- )}) does not appear to be a repository`,
- });
- }
-
- // step 1
- const fromVersion = getCurrentVersion(selectedDirectory, options);
- if (!fromVersion) {
- return endMigration({
- success: false,
- message: `Unable to infer the version of turbo being used by ${directory}`,
- });
- }
-
- // step 2
- let toVersion = options.to;
- try {
- toVersion = await getLatestVersion(options);
- } catch (err) {
- let message = "UNKNOWN_ERROR";
- if (err instanceof Error) {
- message = err.message;
- }
- return endMigration({
- success: false,
- message,
- });
- }
-
- if (!toVersion) {
- return endMigration({
- success: false,
- message: `Unable to fetch the latest version of turbo`,
- });
- }
-
- if (fromVersion === toVersion) {
- return endMigration({
- success: true,
- message: `Nothing to do, current version (${chalk.bold(
- fromVersion
- )}) is the same as the requested version (${chalk.bold(toVersion)})`,
- });
- }
-
- // step 3
- const codemods = getCodemodsForMigration({ fromVersion, toVersion });
- if (codemods.length === 0) {
- console.log(
- `No codemods required to migrate from ${fromVersion} to ${toVersion}`,
- os.EOL
- );
- }
-
- // step 4
- console.log(
- `Upgrading turbo from ${chalk.bold(fromVersion)} to ${chalk.bold(
- toVersion
- )} (${
- codemods.length === 0
- ? "no codemods required"
- : `${codemods.length} required codemod${
- codemods.length === 1 ? "" : "s"
- }`
- })`,
- os.EOL
- );
- const results = codemods.map((codemod, idx) => {
- console.log(
- `(${idx + 1}/${codemods.length}) ${chalk.bold(
- `Running ${codemod.value}`
- )}`
- );
-
- const result = codemod.transformer({ root: selectedDirectory, options });
- Runner.logResults(result);
- return result;
- });
-
- const hasTransformError = results.some(
- (result) =>
- result.fatalError ||
- Object.keys(result.changes).some((key) => result.changes[key].error)
- );
-
- if (hasTransformError) {
- return endMigration({
- success: false,
- message: `Could not complete migration due to codemod errors. Please fix the errors and try again.`,
- });
- }
-
- // step 5
- const upgradeCommand = getTurboUpgradeCommand({
- directory: selectedDirectory,
- to: options.to,
- });
-
- if (!upgradeCommand) {
- return endMigration({
- success: false,
- message: "Unable to determine upgrade command",
- });
- }
-
- if (options.install) {
- if (options.dry) {
- console.log(
- `Upgrading turbo with ${chalk.bold(upgradeCommand)} ${chalk.dim(
- "(dry run)"
- )}`,
- os.EOL
- );
- } else {
- console.log(`Upgrading turbo with ${chalk.bold(upgradeCommand)}`, os.EOL);
- execSync(upgradeCommand, { cwd: selectedDirectory });
- }
- } else {
- console.log(`Upgrade turbo with ${chalk.bold(upgradeCommand)}`, os.EOL);
- }
-
- endMigration({ success: true });
-}
diff --git a/packages/turbo-codemod/src/commands/migrate/steps/getCurrentVersion.ts b/packages/turbo-codemod/src/commands/migrate/steps/getCurrentVersion.ts
deleted file mode 100644
index 3644f8b..0000000
--- a/packages/turbo-codemod/src/commands/migrate/steps/getCurrentVersion.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import path from "path";
-import { existsSync } from "fs-extra";
-
-import getPackageManager from "../../../utils/getPackageManager";
-import { exec } from "../utils";
-import type { MigrateCommandOptions } from "../types";
-
-function getCurrentVersion(
- directory: string,
- opts: MigrateCommandOptions
-): string | undefined {
- const { from } = opts;
- if (from) {
- return from;
- }
-
- // try global first
- const turboVersionFromGlobal = exec(`turbo --version`, { cwd: directory });
-
- if (turboVersionFromGlobal) {
- return turboVersionFromGlobal;
- }
-
- // try to use the package manager to find the version
- const packageManager = getPackageManager({ directory });
- if (packageManager) {
- if (packageManager === "yarn") {
- return exec(`yarn turbo --version`, { cwd: directory });
- }
- if (packageManager === "pnpm") {
- return exec(`pnpm turbo --version`, { cwd: directory });
- } else {
- // this doesn't work for npm, so manually build the binary path
- const turboBin = path.join(directory, "node_modules", ".bin", "turbo");
- if (existsSync(turboBin)) {
- return exec(`${turboBin} --version`, { cwd: directory });
- }
- }
- }
-
- // unable to determine local version,
- return undefined;
-}
-
-export default getCurrentVersion;
diff --git a/packages/turbo-codemod/src/commands/migrate/steps/getLatestVersion.ts b/packages/turbo-codemod/src/commands/migrate/steps/getLatestVersion.ts
deleted file mode 100644
index a6ab7e6..0000000
--- a/packages/turbo-codemod/src/commands/migrate/steps/getLatestVersion.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import axios from "axios";
-
-import type { MigrateCommandOptions } from "../types";
-
-const REGISTRY = "https://registry.npmjs.org";
-
-async function getPackageDetails({ packageName }: { packageName: string }) {
- try {
- const result = await axios.get(`${REGISTRY}/${packageName}`);
- return result.data;
- } catch (err) {
- throw new Error(`Unable to fetch the latest version of ${packageName}`);
- }
-}
-
-export default async function getLatestVersion({
- to,
-}: MigrateCommandOptions): Promise<string | undefined> {
- const packageDetails = await getPackageDetails({ packageName: "turbo" });
- const { "dist-tags": tags, versions } = packageDetails;
-
- if (to) {
- if (tags[to] || versions[to]) {
- return to;
- } else {
- throw new Error(`turbo@${to} does not exist`);
- }
- }
-
- return tags.latest as string;
-}
diff --git a/packages/turbo-codemod/src/commands/migrate/steps/getTransformsForMigration.ts b/packages/turbo-codemod/src/commands/migrate/steps/getTransformsForMigration.ts
deleted file mode 100644
index 2224c06..0000000
--- a/packages/turbo-codemod/src/commands/migrate/steps/getTransformsForMigration.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { gt, lte } from "semver";
-
-import loadTransformers from "../../../utils/loadTransformers";
-import type { Transformer } from "../../../types";
-
-/**
- Returns all transformers introduced after fromVersion, but before or equal to toVersion
-**/
-function getTransformsForMigration({
- fromVersion,
- toVersion,
-}: {
- fromVersion: string;
- toVersion: string;
-}): Array<Transformer> {
- const transforms = loadTransformers();
- return transforms.filter((transformer) => {
- return (
- gt(transformer.introducedIn, fromVersion) &&
- lte(transformer.introducedIn, toVersion)
- );
- });
-}
-
-export default getTransformsForMigration;
diff --git a/packages/turbo-codemod/src/commands/migrate/steps/getTurboUpgradeCommand.ts b/packages/turbo-codemod/src/commands/migrate/steps/getTurboUpgradeCommand.ts
deleted file mode 100644
index 8fd5972..0000000
--- a/packages/turbo-codemod/src/commands/migrate/steps/getTurboUpgradeCommand.ts
+++ /dev/null
@@ -1,182 +0,0 @@
-import os from "os";
-import path from "path";
-import fs from "fs-extra";
-import { gte } from "semver";
-
-import { exec } from "../utils";
-import getPackageManager, {
- PackageManager,
-} from "../../../utils/getPackageManager";
-import getPackageManagerVersion from "../../../utils/getPackageManagerVersion";
-
-type InstallType = "dependencies" | "devDependencies";
-
-function getGlobalBinaryPaths(): Record<PackageManager, string | undefined> {
- return {
- // we run these from a tmpdir to avoid corepack interference
- yarn: exec(`yarn global bin`, { cwd: os.tmpdir() }),
- npm: exec(`npm bin --global`, { cwd: os.tmpdir() }),
- pnpm: exec(`pnpm bin --global`, { cwd: os.tmpdir() }),
- };
-}
-
-function getGlobalUpgradeCommand(
- packageManager: PackageManager,
- to: string = "latest"
-) {
- switch (packageManager) {
- case "yarn":
- return `yarn global add turbo@${to}`;
- case "npm":
- return `npm install turbo@${to} --global`;
- case "pnpm":
- return `pnpm install turbo@${to} --global`;
- }
-}
-
-function getLocalUpgradeCommand({
- packageManager,
- packageManagerVersion,
- installType,
- isUsingWorkspaces,
- to = "latest",
-}: {
- packageManager: PackageManager;
- packageManagerVersion: string;
- installType: InstallType;
- isUsingWorkspaces?: boolean;
- to?: string;
-}) {
- const renderCommand = (
- command: Array<string | boolean | undefined>
- ): string => command.filter(Boolean).join(" ");
- switch (packageManager) {
- // yarn command differs depending on the version
- case "yarn":
- // yarn 2.x and 3.x (berry)
- if (gte(packageManagerVersion, "2.0.0")) {
- return renderCommand([
- "yarn",
- "add",
- `turbo@${to}`,
- installType === "devDependencies" && "--dev",
- ]);
- // yarn 1.x
- } else {
- return renderCommand([
- "yarn",
- "add",
- `turbo@${to}`,
- installType === "devDependencies" && "--dev",
- isUsingWorkspaces && "-W",
- ]);
- }
- case "npm":
- return renderCommand([
- "npm",
- "install",
- `turbo@${to}`,
- installType === "devDependencies" && "--save-dev",
- ]);
- case "pnpm":
- return renderCommand([
- "pnpm",
- "install",
- `turbo@${to}`,
- installType === "devDependencies" && "--save-dev",
- isUsingWorkspaces && "-w",
- ]);
- }
-}
-
-function getInstallType({ directory }: { directory: string }): {
- installType?: InstallType;
- isUsingWorkspaces?: boolean;
-} {
- // read package.json to make sure we have a reference to turbo
- const packageJsonPath = path.join(directory, "package.json");
- const pnpmWorkspaceConfig = path.join(directory, "pnpm-workspace.yaml");
- const isPnpmWorkspaces = fs.existsSync(pnpmWorkspaceConfig);
-
- if (!fs.existsSync(packageJsonPath)) {
- console.error(`Unable to find package.json at ${packageJsonPath}`);
- return { installType: undefined, isUsingWorkspaces: undefined };
- }
-
- const packageJson = fs.readJsonSync(packageJsonPath);
- const isDevDependency =
- packageJson.devDependencies && "turbo" in packageJson.devDependencies;
- const isDependency =
- packageJson.dependencies && "turbo" in packageJson.dependencies;
- let isUsingWorkspaces = "workspaces" in packageJson || isPnpmWorkspaces;
-
- if (isDependency || isDevDependency) {
- return {
- installType: isDependency ? "dependencies" : "devDependencies",
- isUsingWorkspaces,
- };
- }
-
- return {
- installType: undefined,
- isUsingWorkspaces,
- };
-}
-
-/**
- Finding the correct command to upgrade depends on two things:
- 1. The package manager
- 2. The install method (local or global)
-
- We try global first to let turbo handle the inference, then we try local.
-**/
-export default function getTurboUpgradeCommand({
- directory,
- to,
-}: {
- directory: string;
- to?: string;
-}) {
- const turboBinaryPathFromGlobal = exec(`turbo bin`, {
- cwd: directory,
- stdio: "pipe",
- });
- const packageManagerGlobalBinaryPaths = getGlobalBinaryPaths();
-
- const globalPackageManager = Object.keys(
- packageManagerGlobalBinaryPaths
- ).find((packageManager) => {
- const packageManagerBinPath =
- packageManagerGlobalBinaryPaths[packageManager as PackageManager];
- if (packageManagerBinPath && turboBinaryPathFromGlobal) {
- return turboBinaryPathFromGlobal.includes(packageManagerBinPath);
- }
-
- return false;
- }) as PackageManager;
-
- if (turboBinaryPathFromGlobal && globalPackageManager) {
- // figure which package manager we need to upgrade
- return getGlobalUpgradeCommand(globalPackageManager, to);
- } else {
- const packageManager = getPackageManager({ directory });
- // we didn't find a global install, so we'll try to find a local one
- const { installType, isUsingWorkspaces } = getInstallType({ directory });
- if (packageManager && installType) {
- const packageManagerVersion = getPackageManagerVersion(
- packageManager,
- directory
- );
-
- return getLocalUpgradeCommand({
- packageManager,
- packageManagerVersion,
- installType,
- isUsingWorkspaces,
- to,
- });
- }
- }
-
- return undefined;
-}
diff --git a/packages/turbo-codemod/src/commands/migrate/types.ts b/packages/turbo-codemod/src/commands/migrate/types.ts
deleted file mode 100644
index ae90965..0000000
--- a/packages/turbo-codemod/src/commands/migrate/types.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { TransformerOptions } from "../../types";
-
-export type MigrateCommandArgument = "string" | undefined;
-
-export interface MigrateCommandOptions extends TransformerOptions {
- from?: string;
- to?: string;
- install: boolean;
-}
diff --git a/packages/turbo-codemod/src/commands/migrate/utils.ts b/packages/turbo-codemod/src/commands/migrate/utils.ts
deleted file mode 100644
index 512d78b..0000000
--- a/packages/turbo-codemod/src/commands/migrate/utils.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { execSync, ExecSyncOptions } from "child_process";
-
-function exec(
- command: string,
- opts: ExecSyncOptions,
- fallback?: string
-): string | undefined {
- try {
- const rawResult = execSync(command, opts);
- return rawResult.toString("utf8").trim();
- } catch (err) {
- return fallback || undefined;
- }
-}
-
-export { exec };
diff --git a/packages/turbo-codemod/src/commands/transform/index.ts b/packages/turbo-codemod/src/commands/transform/index.ts
deleted file mode 100644
index e3b86aa..0000000
--- a/packages/turbo-codemod/src/commands/transform/index.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-import chalk from "chalk";
-import inquirer from "inquirer";
-
-import loadTransformers from "../../utils/loadTransformers";
-import checkGitStatus from "../../utils/checkGitStatus";
-import directoryInfo from "../../utils/directoryInfo";
-import type {
- TransformCommandOptions,
- TransformCommandArgument,
-} from "./types";
-import { Runner } from "../../runner";
-
-export default async function transform(
- transform: TransformCommandArgument,
- directory: TransformCommandArgument,
- options: TransformCommandOptions
-) {
- const transforms = loadTransformers();
- if (options.list) {
- console.log(
- transforms
- .map((transform) => `- ${chalk.cyan(transform.value)}`)
- .join("\n")
- );
- return process.exit(0);
- }
-
- // check git status
- if (!options.dry) {
- checkGitStatus({ directory, force: options.force });
- }
-
- const answers = await inquirer.prompt<{
- directoryInput?: string;
- transformerInput?: string;
- }>([
- {
- type: "input",
- name: "directoryInput",
- message: "Where is the root of the repo where the transform should run?",
- when: !directory,
- default: ".",
- validate: (directory: string) => {
- const { exists, absolute } = directoryInfo({ directory });
- if (exists) {
- return true;
- } else {
- return `Directory ${chalk.dim(`(${absolute})`)} does not exist`;
- }
- },
- filter: (directory: string) => directory.trim(),
- },
- {
- type: "list",
- name: "transformerInput",
- message: "Which transform would you like to apply?",
- when: !transform,
- pageSize: transforms.length,
- choices: transforms,
- },
- ]);
-
- const {
- directoryInput: selectedDirectory = directory as string,
- transformerInput: selectedTransformer = transform as string,
- } = answers;
- const { exists, absolute: root } = directoryInfo({
- directory: selectedDirectory,
- });
- if (!exists) {
- console.error(`Directory ${chalk.dim(`(${root})`)} does not exist`);
- return process.exit(1);
- }
-
- const transformKeys = transforms.map((transform) => transform.value);
- const transformData = transforms.find(
- (transform) => transform.value === selectedTransformer
- );
-
- // validate transforms
- if (!transformData) {
- console.error(
- `Invalid transform choice ${chalk.dim(`(${transform})`)}, pick one of:`
- );
- console.error(transformKeys.map((key) => `- ${key}`).join("\n"));
- return process.exit(1);
- }
-
- // run the transform
- const result = transformData.transformer({
- root,
- options,
- });
-
- if (result.fatalError) {
- // Runner already logs this, so we can just exit
- return process.exit(1);
- }
-
- Runner.logResults(result);
-}
diff --git a/packages/turbo-codemod/src/commands/transform/types.ts b/packages/turbo-codemod/src/commands/transform/types.ts
deleted file mode 100644
index 9ac2db0..0000000
--- a/packages/turbo-codemod/src/commands/transform/types.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { TransformerOptions } from "../../types";
-
-export type TransformCommandArgument = "string" | undefined;
-
-export interface TransformCommandOptions extends TransformerOptions {
- list: boolean;
-}
diff --git a/packages/turbo-codemod/src/runner/FileTransform.ts b/packages/turbo-codemod/src/runner/FileTransform.ts
deleted file mode 100644
index 3b23f73..0000000
--- a/packages/turbo-codemod/src/runner/FileTransform.ts
+++ /dev/null
@@ -1,94 +0,0 @@
-import chalk from "chalk";
-import { diffLines, Change, diffJson } from "diff";
-import fs from "fs-extra";
-import os from "os";
-import path from "path";
-
-import type { FileTransformArgs, LogFileArgs } from "./types";
-
-export default class FileTransform {
- filePath: string;
- rootPath: string;
- before: string | object;
- after?: string | object;
- error?: Error;
- changes: Array<Change> = [];
-
- constructor(args: FileTransformArgs) {
- this.filePath = args.filePath;
- this.rootPath = args.rootPath;
- this.after = args.after;
- this.error = args.error;
-
- // load original file for comparison
- if (args.before === undefined) {
- try {
- if (path.extname(args.filePath) === ".json") {
- this.before = fs.readJsonSync(args.filePath);
- } else {
- this.before = fs.readFileSync(args.filePath);
- }
- } catch (err) {
- this.before = "";
- }
- } else if (args.before === null) {
- this.before = "";
- } else {
- this.before = args.before;
- }
-
- // determine diff
- if (args.after) {
- if (typeof this.before === "object" || typeof args.after === "object") {
- this.changes = diffJson(this.before, args.after);
- } else {
- this.changes = diffLines(this.before, args.after);
- }
- } else {
- this.changes = [];
- }
- }
-
- fileName(): string {
- return path.relative(this.rootPath, this.filePath);
- }
-
- write(): void {
- if (this.after) {
- if (typeof this.after === "object") {
- fs.writeJsonSync(this.filePath, this.after, { spaces: 2 });
- } else {
- fs.writeFileSync(this.filePath, this.after);
- }
- }
- }
-
- additions(): number {
- return this.changes.filter((c) => c.added).length;
- }
-
- deletions(): number {
- return this.changes.filter((c) => c.removed).length;
- }
-
- hasChanges(): boolean {
- return this.additions() > 0 || this.deletions() > 0;
- }
-
- log(args: LogFileArgs): void {
- if (args.diff) {
- this.changes.forEach((part) => {
- if (part.added) {
- process.stdout.write(chalk.green(part.value));
- } else if (part.removed) {
- process.stdout.write(chalk.red(part.value));
- } else {
- process.stdout.write(chalk.dim(part.value));
- }
- });
- console.log(os.EOL);
- } else {
- console.log(this.after);
- }
- }
-}
diff --git a/packages/turbo-codemod/src/runner/Runner.ts b/packages/turbo-codemod/src/runner/Runner.ts
deleted file mode 100644
index 8f8803d..0000000
--- a/packages/turbo-codemod/src/runner/Runner.ts
+++ /dev/null
@@ -1,132 +0,0 @@
-import chalk from "chalk";
-
-import FileTransform from "./FileTransform";
-import Logger from "../utils/logger";
-import type { UtilityArgs } from "../types";
-import type {
- FileResult,
- ModifyFileArgs,
- AbortTransformArgs,
- TransformerResults,
-} from "./types";
-
-class Runner {
- transform: string;
- rootPath: string;
- dry: boolean;
- print: boolean;
- modifications: Record<string, FileTransform> = {};
- logger: Logger;
-
- constructor(options: UtilityArgs) {
- this.transform = options.transformer;
- this.rootPath = options.rootPath;
- this.dry = options.dry;
- this.print = options.print;
- this.logger = new Logger(options);
- }
-
- abortTransform(args: AbortTransformArgs): TransformerResults {
- this.logger.error(args.reason);
- return {
- fatalError: new Error(args.reason),
- changes: args.changes || {},
- };
- }
-
- // add a file to be transformed
- modifyFile(args: ModifyFileArgs): void {
- this.modifications[args.filePath] = new FileTransform({
- rootPath: this.rootPath,
- ...args,
- });
- }
-
- // execute all transforms and track results for reporting
- finish(): TransformerResults {
- const results: TransformerResults = { changes: {} };
- // perform all actions and track results
- Object.keys(this.modifications).forEach((filePath) => {
- const mod = this.modifications[filePath];
- const result: FileResult = {
- action: "unchanged",
- additions: mod.additions(),
- deletions: mod.deletions(),
- };
-
- if (mod.hasChanges()) {
- if (this.dry) {
- result.action = "skipped";
- this.logger.skipped(chalk.dim(mod.fileName()));
- } else {
- try {
- mod.write();
- result.action = "modified";
- this.logger.modified(chalk.bold(mod.fileName()));
- } catch (err) {
- let message = "Unknown error";
- if (err instanceof Error) {
- message = err.message;
- }
- result.error = new Error(message);
- result.action = "error";
- this.logger.error(mod.fileName(), message);
- }
- }
-
- if (this.print) {
- mod.log({ diff: true });
- }
- } else {
- this.logger.unchanged(chalk.dim(mod.fileName()));
- }
-
- results.changes[mod.fileName()] = result;
- });
-
- const encounteredError = Object.keys(results.changes).some((fileName) => {
- return results.changes[fileName].action === "error";
- });
-
- if (encounteredError) {
- return this.abortTransform({
- reason: "Encountered an error while transforming files",
- changes: results.changes,
- });
- }
-
- return results;
- }
-
- static logResults(results: TransformerResults): void {
- const changedFiles = Object.keys(results.changes);
- console.log();
- if (changedFiles.length > 0) {
- console.log(chalk.bold(`Results:`));
- const table: Record<
- string,
- {
- action: FileResult["action"];
- additions: FileResult["additions"];
- deletions: FileResult["deletions"];
- error?: string;
- }
- > = {};
-
- changedFiles.forEach((fileName) => {
- const fileChanges = results.changes[fileName];
- table[fileName] = {
- action: fileChanges.action,
- additions: fileChanges.additions,
- deletions: fileChanges.deletions,
- error: fileChanges.error?.message || "None",
- };
- });
-
- console.table(table);
- console.log();
- }
- }
-}
-
-export default Runner;
diff --git a/packages/turbo-codemod/src/runner/index.ts b/packages/turbo-codemod/src/runner/index.ts
deleted file mode 100644
index 2aa323d..0000000
--- a/packages/turbo-codemod/src/runner/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export { default as Runner } from "./Runner";
-
-export type { TransformerResults, FileDiffer, FileWriter } from "./types";
diff --git a/packages/turbo-codemod/src/runner/types.ts b/packages/turbo-codemod/src/runner/types.ts
deleted file mode 100644
index e7c37d4..0000000
--- a/packages/turbo-codemod/src/runner/types.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Change } from "diff";
-
-export interface FileResult {
- action: "skipped" | "modified" | "unchanged" | "error";
- error?: Error;
- additions: number;
- deletions: number;
-}
-
-export interface FileTransformArgs extends ModifyFileArgs {
- rootPath: string;
-}
-
-export interface ModifyFileArgs {
- filePath: string;
- before?: string | object;
- after?: string | object;
- error?: Error;
-}
-
-export interface AbortTransformArgs {
- reason: string;
- changes?: Record<string, FileResult>;
-}
-
-export interface LogFileArgs {
- diff?: boolean;
-}
-
-export type FileWriter = (filePath: string, contents: string | object) => void;
-
-export type FileDiffer = (
- before: string | object,
- after: string | object
-) => Array<Change>;
-
-export interface TransformerResults {
- fatalError?: Error;
- changes: Record<string, FileResult>;
-}
diff --git a/packages/turbo-codemod/src/transforms/README.md b/packages/turbo-codemod/src/transforms/README.md
deleted file mode 100644
index 8e4430f..0000000
--- a/packages/turbo-codemod/src/transforms/README.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# `@turbo/codemod` Transformers
-
-## Adding new transformers
-
-Add new transformers using the [plopjs](https://github.com/plopjs/plop) template by running:
-
-```bash
-pnpm add-transformer
-```
-
-New Transformers will be automatically surfaced to the `transform` CLI command and used by the `migrate` CLI command when appropriate.
-
-## How it works
-
-Transformers are loaded automatically from the `src/transforms/` directory via the [`loadTransforms`](../utils/loadTransformers.ts) function.
-
-All new transformers must contain a default export that matches the [`Transformer`](../types.ts) type:
-
-```ts
-export type Transformer = {
- name: string;
- value: string;
- introducedIn: string;
- transformer: (args: TransformerArgs) => TransformerResults;
-};
-```
-
-## Writing a Transform
-
-Transforms are ran using the [TransformRunner](../runner/Runner.ts). This class is designed to make writing transforms as simple as possible by abstracting away all of the boilerplate that determines what should be logged, saved, or output as a result.
-
-To use the TransformRunner:
-
-1. Transform each file in memory (do not write it back to disk `TransformRunner` takes care of this depending on the options passed in by the user), and pass to `TransformRunner.modifyFile` method.
-2. If the transform encounters an unrecoverable error, pass it to the `TransformRunner.abortTransform` method.
-3. When all files have been modified and passed to `TransformRunner.modifyFile`, call `TransformRunner.finish` method to write the files to disk (when not running in `dry` mode) and log the results.
diff --git a/packages/turbo-codemod/src/transforms/add-package-manager.ts b/packages/turbo-codemod/src/transforms/add-package-manager.ts
deleted file mode 100644
index bd6581f..0000000
--- a/packages/turbo-codemod/src/transforms/add-package-manager.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import path from "path";
-import fs from "fs-extra";
-
-import getPackageManager from "../utils/getPackageManager";
-import getPackageManagerVersion from "../utils/getPackageManagerVersion";
-import getTransformerHelpers from "../utils/getTransformerHelpers";
-import { TransformerResults } from "../runner";
-import type { TransformerArgs } from "../types";
-
-// transformer details
-const TRANSFORMER = "add-package-manager";
-const DESCRIPTION = "Set the `packageManager` key in root `package.json` file";
-const INTRODUCED_IN = "1.1.0";
-
-export function transformer({
- root,
- options,
-}: TransformerArgs): TransformerResults {
- const { log, runner } = getTransformerHelpers({
- transformer: TRANSFORMER,
- rootPath: root,
- options,
- });
-
- log.info(`Set "packageManager" key in root "package.json" file...`);
- const packageManager = getPackageManager({ directory: root });
- if (!packageManager) {
- return runner.abortTransform({
- reason: `Unable to determine package manager for ${root}`,
- });
- }
-
- // handle workspaces...
- let version = null;
- try {
- version = getPackageManagerVersion(packageManager, root);
- } catch (err) {
- return runner.abortTransform({
- reason: `Unable to determine package manager version for ${root}`,
- });
- }
- const pkgManagerString = `${packageManager}@${version}`;
- const rootPackageJsonPath = path.join(root, "package.json");
- const rootPackageJson = fs.readJsonSync(rootPackageJsonPath);
- const allWorkspaces = [
- {
- name: "package.json",
- path: root,
- packageJson: {
- ...rootPackageJson,
- packageJsonPath: rootPackageJsonPath,
- },
- },
- ];
-
- for (const workspace of allWorkspaces) {
- const { packageJsonPath, ...pkgJson } = workspace.packageJson;
- const newJson = { ...pkgJson, packageManager: pkgManagerString };
- runner.modifyFile({
- filePath: packageJsonPath,
- after: newJson,
- });
- }
-
- return runner.finish();
-}
-
-const transformerMeta = {
- name: `${TRANSFORMER}: ${DESCRIPTION}`,
- value: TRANSFORMER,
- introducedIn: INTRODUCED_IN,
- transformer,
-};
-
-export default transformerMeta;
diff --git a/packages/turbo-codemod/src/transforms/create-turbo-config.ts b/packages/turbo-codemod/src/transforms/create-turbo-config.ts
deleted file mode 100644
index 0e8549a..0000000
--- a/packages/turbo-codemod/src/transforms/create-turbo-config.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import fs from "fs-extra";
-import path from "path";
-
-import { TransformerResults } from "../runner";
-import getTransformerHelpers from "../utils/getTransformerHelpers";
-import type { TransformerArgs } from "../types";
-
-// transformer details
-const TRANSFORMER = "create-turbo-config";
-const DESCRIPTION =
- 'Create the `turbo.json` file from an existing "turbo" key in `package.json`';
-const INTRODUCED_IN = "1.1.0";
-
-export function transformer({
- root,
- options,
-}: TransformerArgs): TransformerResults {
- const { log, runner } = getTransformerHelpers({
- transformer: TRANSFORMER,
- rootPath: root,
- options,
- });
-
- log.info(`Migrating "package.json" "turbo" key to "turbo.json" file...`);
- const turboConfigPath = path.join(root, "turbo.json");
- const rootPackageJsonPath = path.join(root, "package.json");
- if (!fs.existsSync(rootPackageJsonPath)) {
- return runner.abortTransform({
- reason: `No package.json found at ${root}. Is the path correct?`,
- });
- }
-
- // read files
- const rootPackageJson = fs.readJsonSync(rootPackageJsonPath);
- let rootTurboJson = null;
- try {
- rootTurboJson = fs.readJSONSync(turboConfigPath);
- } catch (err) {
- rootTurboJson = null;
- }
-
- // modify files
- let transformedPackageJson = rootPackageJson;
- let transformedTurboConfig = rootTurboJson;
- if (!rootTurboJson && rootPackageJson["turbo"]) {
- const { turbo: turboConfig, ...remainingPkgJson } = rootPackageJson;
- transformedTurboConfig = turboConfig;
- transformedPackageJson = remainingPkgJson;
- }
-
- runner.modifyFile({
- filePath: turboConfigPath,
- after: transformedTurboConfig,
- });
- runner.modifyFile({
- filePath: rootPackageJsonPath,
- after: transformedPackageJson,
- });
-
- return runner.finish();
-}
-
-const transformerMeta = {
- name: `${TRANSFORMER}: ${DESCRIPTION}`,
- value: TRANSFORMER,
- introducedIn: INTRODUCED_IN,
- transformer,
-};
-
-export default transformerMeta;
diff --git a/packages/turbo-codemod/src/transforms/migrate-env-var-dependencies.ts b/packages/turbo-codemod/src/transforms/migrate-env-var-dependencies.ts
deleted file mode 100644
index ef3a34c..0000000
--- a/packages/turbo-codemod/src/transforms/migrate-env-var-dependencies.ts
+++ /dev/null
@@ -1,181 +0,0 @@
-import fs from "fs-extra";
-import path from "path";
-import { getTurboConfigs } from "@turbo/utils";
-import type { Schema, Pipeline } from "@turbo/types";
-
-import getTransformerHelpers from "../utils/getTransformerHelpers";
-import { TransformerResults } from "../runner";
-import type { TransformerArgs } from "../types";
-
-// transformer details
-const TRANSFORMER = "migrate-env-var-dependencies";
-const DESCRIPTION =
- 'Migrate environment variable dependencies from "dependsOn" to "env" in `turbo.json`';
-const INTRODUCED_IN = "1.5.0";
-
-export function hasLegacyEnvVarDependencies(config: Schema) {
- const dependsOn = [
- "extends" in config ? [] : config.globalDependencies,
- Object.values(config.pipeline).flatMap(
- (pipeline) => pipeline.dependsOn ?? []
- ),
- ].flat();
- const envVars = dependsOn.filter((dep) => dep?.startsWith("$"));
- return { hasKeys: !!envVars.length, envVars };
-}
-
-export function migrateDependencies({
- env,
- deps,
-}: {
- env?: string[];
- deps?: string[];
-}) {
- const envDeps: Set<string> = new Set(env);
- const otherDeps: string[] = [];
- deps?.forEach((dep) => {
- if (dep.startsWith("$")) {
- envDeps.add(dep.slice(1));
- } else {
- otherDeps.push(dep);
- }
- });
- if (envDeps.size) {
- return {
- deps: otherDeps,
- env: Array.from(envDeps),
- };
- } else {
- return { env, deps };
- }
-}
-
-export function migratePipeline(pipeline: Pipeline) {
- const { deps: dependsOn, env } = migrateDependencies({
- env: pipeline.env,
- deps: pipeline.dependsOn,
- });
- const migratedPipeline = { ...pipeline };
- if (dependsOn) {
- migratedPipeline.dependsOn = dependsOn;
- } else {
- delete migratedPipeline.dependsOn;
- }
- if (env && env.length) {
- migratedPipeline.env = env;
- } else {
- delete migratedPipeline.env;
- }
-
- return migratedPipeline;
-}
-
-export function migrateGlobal(config: Schema) {
- if ("extends" in config) {
- return config;
- }
-
- const { deps: globalDependencies, env } = migrateDependencies({
- env: config.globalEnv,
- deps: config.globalDependencies,
- });
- const migratedConfig = { ...config };
- if (globalDependencies && globalDependencies.length) {
- migratedConfig.globalDependencies = globalDependencies;
- } else {
- delete migratedConfig.globalDependencies;
- }
- if (env && env.length) {
- migratedConfig.globalEnv = env;
- } else {
- delete migratedConfig.globalEnv;
- }
- return migratedConfig;
-}
-
-export function migrateConfig(config: Schema) {
- let migratedConfig = migrateGlobal(config);
- Object.keys(config.pipeline).forEach((pipelineKey) => {
- config.pipeline;
- if (migratedConfig.pipeline && config.pipeline[pipelineKey]) {
- const pipeline = migratedConfig.pipeline[pipelineKey];
- migratedConfig.pipeline[pipelineKey] = {
- ...pipeline,
- ...migratePipeline(pipeline),
- };
- }
- });
- return migratedConfig;
-}
-
-export function transformer({
- root,
- options,
-}: TransformerArgs): TransformerResults {
- const { log, runner } = getTransformerHelpers({
- transformer: TRANSFORMER,
- rootPath: root,
- options,
- });
-
- log.info(
- `Migrating environment variable dependencies from "globalDependencies" and "dependsOn" to "env" in "turbo.json"...`
- );
-
- // validate we don't have a package.json config
- const packageJsonPath = path.join(root, "package.json");
- let packageJSON = {};
- try {
- packageJSON = fs.readJSONSync(packageJsonPath);
- } catch (e) {
- // readJSONSync probably failed because the file doesn't exist
- }
-
- if ("turbo" in packageJSON) {
- return runner.abortTransform({
- reason:
- '"turbo" key detected in package.json. Run `npx @turbo/codemod transform create-turbo-config` first',
- });
- }
-
- // validate we have a root config
- const turboConfigPath = path.join(root, "turbo.json");
- if (!fs.existsSync(turboConfigPath)) {
- return runner.abortTransform({
- reason: `No turbo.json found at ${root}. Is the path correct?`,
- });
- }
-
- let turboJson: Schema = fs.readJsonSync(turboConfigPath);
- if (hasLegacyEnvVarDependencies(turboJson).hasKeys) {
- turboJson = migrateConfig(turboJson);
- }
-
- runner.modifyFile({
- filePath: turboConfigPath,
- after: turboJson,
- });
-
- // find and migrate any workspace configs
- const workspaceConfigs = getTurboConfigs(root);
- workspaceConfigs.forEach((workspaceConfig) => {
- const { config, turboConfigPath } = workspaceConfig;
- if (hasLegacyEnvVarDependencies(config).hasKeys) {
- runner.modifyFile({
- filePath: turboConfigPath,
- after: migrateConfig(config),
- });
- }
- });
-
- return runner.finish();
-}
-
-const transformerMeta = {
- name: `${TRANSFORMER}: ${DESCRIPTION}`,
- value: TRANSFORMER,
- introducedIn: INTRODUCED_IN,
- transformer,
-};
-
-export default transformerMeta;
diff --git a/packages/turbo-codemod/src/transforms/set-default-outputs.ts b/packages/turbo-codemod/src/transforms/set-default-outputs.ts
deleted file mode 100644
index 44f7fd1..0000000
--- a/packages/turbo-codemod/src/transforms/set-default-outputs.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import path from "path";
-import fs from "fs-extra";
-import { getTurboConfigs } from "@turbo/utils";
-import type { Schema as TurboJsonSchema } from "@turbo/types";
-
-import type { TransformerArgs } from "../types";
-import getTransformerHelpers from "../utils/getTransformerHelpers";
-import { TransformerResults } from "../runner";
-
-const DEFAULT_OUTPUTS = ["dist/**", "build/**"];
-
-// transformer details
-const TRANSFORMER = "set-default-outputs";
-const DESCRIPTION =
- 'Add the "outputs" key with defaults where it is missing in `turbo.json`';
-const INTRODUCED_IN = "1.7.0";
-
-function migrateConfig(config: TurboJsonSchema) {
- for (const [_, taskDef] of Object.entries(config.pipeline)) {
- if (taskDef.cache !== false) {
- if (!taskDef.outputs) {
- taskDef.outputs = DEFAULT_OUTPUTS;
- } else if (
- Array.isArray(taskDef.outputs) &&
- taskDef.outputs.length === 0
- ) {
- delete taskDef.outputs;
- }
- }
- }
-
- return config;
-}
-
-export function transformer({
- root,
- options,
-}: TransformerArgs): TransformerResults {
- const { log, runner } = getTransformerHelpers({
- transformer: TRANSFORMER,
- rootPath: root,
- options,
- });
-
- // If `turbo` key is detected in package.json, require user to run the other codemod first.
- const packageJsonPath = path.join(root, "package.json");
- // package.json should always exist, but if it doesn't, it would be a silly place to blow up this codemod
- let packageJSON = {};
-
- try {
- packageJSON = fs.readJSONSync(packageJsonPath);
- } catch (e) {
- // readJSONSync probably failed because the file doesn't exist
- }
-
- if ("turbo" in packageJSON) {
- return runner.abortTransform({
- reason:
- '"turbo" key detected in package.json. Run `npx @turbo/codemod transform create-turbo-config` first',
- });
- }
-
- log.info(`Adding default \`outputs\` key into tasks if it doesn't exist`);
- const turboConfigPath = path.join(root, "turbo.json");
- if (!fs.existsSync(turboConfigPath)) {
- return runner.abortTransform({
- reason: `No turbo.json found at ${root}. Is the path correct?`,
- });
- }
-
- const turboJson: TurboJsonSchema = fs.readJsonSync(turboConfigPath);
- runner.modifyFile({
- filePath: turboConfigPath,
- after: migrateConfig(turboJson),
- });
-
- // find and migrate any workspace configs
- const workspaceConfigs = getTurboConfigs(root);
- workspaceConfigs.forEach((workspaceConfig) => {
- const { config, turboConfigPath } = workspaceConfig;
- runner.modifyFile({
- filePath: turboConfigPath,
- after: migrateConfig(config),
- });
- });
-
- return runner.finish();
-}
-
-const transformerMeta = {
- name: `${TRANSFORMER}: ${DESCRIPTION}`,
- value: TRANSFORMER,
- introducedIn: INTRODUCED_IN,
- transformer,
-};
-
-export default transformerMeta;
diff --git a/packages/turbo-codemod/src/types.ts b/packages/turbo-codemod/src/types.ts
deleted file mode 100644
index d5c13c3..0000000
--- a/packages/turbo-codemod/src/types.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { TransformerResults } from "./runner";
-
-export type Transformer = {
- name: string;
- value: string;
- introducedIn: string;
- transformer: (args: TransformerArgs) => TransformerResults;
-};
-
-export type TransformerOptions = {
- force: boolean;
- dry: boolean;
- print: boolean;
-};
-
-export type TransformerArgs = {
- root: string;
- options: TransformerOptions;
-};
-
-export interface UtilityArgs extends TransformerOptions {
- transformer: string;
- rootPath: string;
-}
diff --git a/packages/turbo-codemod/src/utils/checkGitStatus.ts b/packages/turbo-codemod/src/utils/checkGitStatus.ts
deleted file mode 100644
index 68d39ae..0000000
--- a/packages/turbo-codemod/src/utils/checkGitStatus.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import chalk from "chalk";
-import isGitClean from "is-git-clean";
-
-export default function checkGitStatus({
- directory,
- force,
-}: {
- directory?: string;
- force: boolean;
-}) {
- let clean = false;
- let errorMessage = "Unable to determine if git directory is clean";
- try {
- clean = isGitClean.sync(directory || process.cwd());
- errorMessage = "Git directory is not clean";
- } catch (err: any) {
- if (err && err.stderr && err.stderr.indexOf("not a git repository") >= 0) {
- clean = true;
- }
- }
-
- if (!clean) {
- if (force) {
- console.log(
- `${chalk.yellow("WARNING")}: ${errorMessage}. Forcibly continuing...`
- );
- } else {
- console.log("Thank you for using @turbo/codemod!");
- console.log(
- chalk.yellow(
- "\nBut before we continue, please stash or commit your git changes."
- )
- );
- console.log(
- "\nYou may use the --force flag to override this safety check."
- );
- process.exit(1);
- }
- }
-}
diff --git a/packages/turbo-codemod/src/utils/directoryInfo.ts b/packages/turbo-codemod/src/utils/directoryInfo.ts
deleted file mode 100644
index 7cb3594..0000000
--- a/packages/turbo-codemod/src/utils/directoryInfo.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import path from "path";
-import fs from "fs";
-
-export default function directoryInfo({ directory }: { directory: string }) {
- const dir = path.isAbsolute(directory)
- ? directory
- : path.join(process.cwd(), directory);
-
- return { exists: fs.existsSync(dir), absolute: dir };
-}
diff --git a/packages/turbo-codemod/src/utils/getPackageManager.ts b/packages/turbo-codemod/src/utils/getPackageManager.ts
deleted file mode 100644
index 1df0acc..0000000
--- a/packages/turbo-codemod/src/utils/getPackageManager.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import findUp from "find-up";
-import path from "path";
-
-export type PackageManager = "yarn" | "pnpm" | "npm";
-
-const cache: { [cwd: string]: PackageManager } = {};
-
-export default function getPackageManager({
- directory,
-}: { directory?: string } = {}): PackageManager | undefined {
- const cwd = directory || process.cwd();
- if (cache[cwd]) {
- return cache[cwd];
- }
-
- const lockFile = findUp.sync(
- ["yarn.lock", "pnpm-lock.yaml", "package-lock.json"],
- {
- cwd,
- }
- );
-
- if (!lockFile) {
- return;
- }
-
- switch (path.basename(lockFile)) {
- case "yarn.lock":
- cache[cwd] = "yarn";
- break;
-
- case "pnpm-lock.yaml":
- cache[cwd] = "pnpm";
- break;
-
- case "package-lock.json":
- cache[cwd] = "npm";
- break;
- }
-
- return cache[cwd];
-}
diff --git a/packages/turbo-codemod/src/utils/getPackageManagerVersion.ts b/packages/turbo-codemod/src/utils/getPackageManagerVersion.ts
deleted file mode 100644
index 54a572a..0000000
--- a/packages/turbo-codemod/src/utils/getPackageManagerVersion.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { execSync } from "child_process";
-import type { PackageManager } from "./getPackageManager";
-
-export default function getPackageManagerVersion(
- packageManager: PackageManager,
- root: string
-): string {
- switch (packageManager) {
- case "yarn":
- return execSync("yarn --version", { cwd: root }).toString().trim();
- case "pnpm":
- return execSync("pnpm --version", { cwd: root }).toString().trim();
- case "npm":
- return execSync("npm --version", { cwd: root }).toString().trim();
- }
-}
diff --git a/packages/turbo-codemod/src/utils/getTransformerHelpers.ts b/packages/turbo-codemod/src/utils/getTransformerHelpers.ts
deleted file mode 100644
index e37da6e..0000000
--- a/packages/turbo-codemod/src/utils/getTransformerHelpers.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { TransformerOptions } from "../types";
-import { Runner } from "../runner";
-import Logger from "./logger";
-
-export default function getTransformerHelpers({
- transformer,
- rootPath,
- options,
-}: {
- transformer: string;
- rootPath: string;
- options: TransformerOptions;
-}) {
- const utilArgs = {
- transformer,
- rootPath,
- ...options,
- };
- const log = new Logger(utilArgs);
- const runner = new Runner(utilArgs);
-
- return { log, runner };
-}
diff --git a/packages/turbo-codemod/src/utils/loadTransformers.ts b/packages/turbo-codemod/src/utils/loadTransformers.ts
deleted file mode 100644
index 9ba5ca1..0000000
--- a/packages/turbo-codemod/src/utils/loadTransformers.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import path from "path";
-import fs from "fs-extra";
-import type { Transformer } from "../types";
-
-// transforms/ is a sibling when built in in dist/
-export const transformerDirectory =
- process.env.NODE_ENV === "test"
- ? path.join(__dirname, "../transforms")
- : path.join(__dirname, "./transforms");
-
-export default function loadTransformers(): Array<Transformer> {
- const transformerFiles = fs.readdirSync(transformerDirectory);
- return transformerFiles
- .map((transformerFilename) => {
- const transformerPath = path.join(
- transformerDirectory,
- transformerFilename
- );
- try {
- return require(transformerPath).default;
- } catch (e) {
- // we ignore this error because it's likely that the file is not a transformer (README, etc)
- return undefined;
- }
- })
- .filter(Boolean);
-}
diff --git a/packages/turbo-codemod/src/utils/logger.ts b/packages/turbo-codemod/src/utils/logger.ts
deleted file mode 100644
index 123a836..0000000
--- a/packages/turbo-codemod/src/utils/logger.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import chalk from "chalk";
-import { UtilityArgs } from "../types";
-
-export default class Logger {
- transform: string;
- dry: boolean;
-
- constructor(args: UtilityArgs) {
- this.transform = args.transformer;
- this.dry = args.dry;
- }
- modified(...args: any[]) {
- console.log(
- chalk.green(` MODIFIED `),
- ...args,
- this.dry ? chalk.dim(`(dry run)`) : ""
- );
- }
- unchanged(...args: any[]) {
- console.log(
- chalk.gray(` UNCHANGED `),
- ...args,
- this.dry ? chalk.dim(`(dry run)`) : ""
- );
- }
- skipped(...args: any[]) {
- console.log(
- chalk.yellow(` SKIPPED `),
- ...args,
- this.dry ? chalk.dim(`(dry run)`) : ""
- );
- }
- error(...args: any[]) {
- console.log(
- chalk.red(` ERROR `),
- ...args,
- this.dry ? chalk.dim(`(dry run)`) : ""
- );
- }
- info(...args: any[]) {
- console.log(
- chalk.bold(` INFO `),
- ...args,
- this.dry ? chalk.dim(`(dry run)`) : ""
- );
- }
-}
diff --git a/packages/turbo-codemod/src/utils/looksLikeRepo.ts b/packages/turbo-codemod/src/utils/looksLikeRepo.ts
deleted file mode 100644
index 77f0e5c..0000000
--- a/packages/turbo-codemod/src/utils/looksLikeRepo.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import path from "path";
-import { existsSync } from "fs-extra";
-
-const HINTS = ["package.json", "turbo.json", ".git"];
-
-export default function looksLikeRepo({
- directory,
-}: {
- directory: string;
-}): boolean {
- return HINTS.some((hint) => existsSync(path.join(directory, hint)));
-}
diff --git a/packages/turbo-codemod/src/utils/notifyUpdate.ts b/packages/turbo-codemod/src/utils/notifyUpdate.ts
deleted file mode 100644
index 634ffd8..0000000
--- a/packages/turbo-codemod/src/utils/notifyUpdate.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import chalk from "chalk";
-import checkForUpdate from "update-check";
-
-import cliPkgJson from "../../package.json";
-import getWorkspaceImplementation from "./getPackageManager";
-
-const update = checkForUpdate(cliPkgJson).catch(() => null);
-
-export default async function notifyUpdate(): Promise<void> {
- try {
- const res = await update;
- if (res?.latest) {
- const ws = getWorkspaceImplementation();
-
- console.log();
- console.log(
- chalk.yellow.bold("A new version of `@turbo/codemod` is available!")
- );
- console.log(
- "You can update by running: " +
- chalk.cyan(
- ws === "yarn"
- ? "yarn global add @turbo/codemod"
- : ws === "pnpm"
- ? "pnpm i -g @turbo/codemod"
- : "npm i -g @turbo/codemod"
- )
- );
- console.log();
- }
- process.exit();
- } catch (_e: any) {
- // ignore error
- }
-}
diff --git a/packages/turbo-codemod/templates/transformer.hbs b/packages/turbo-codemod/templates/transformer.hbs
deleted file mode 100644
index 593490a..0000000
--- a/packages/turbo-codemod/templates/transformer.hbs
+++ /dev/null
@@ -1,45 +0,0 @@
-import { TransformerArgs } from "../types";
-import { TransformerResults } from "../runner";
-import getTransformerHelpers from "../utils/getTransformerHelpers";
-
-// transformer details
-const TRANSFORMER = "{{ name }}";
-const DESCRIPTION = "{{ description }}";
-const INTRODUCED_IN = "{{ introducedIn }}";
-
-export function transformer({
- root,
- options,
-}: TransformerArgs): TransformerResults {
- const { log, runner } = getTransformerHelpers({
- transformer: TRANSFORMER,
- rootPath: root,
- options,
- });
-
- log.info("Short description about {{ name }}")
-
- /*
- Make changes to required files, and track each modified file with:
-
- runner.modifyFile({
- filePath: packageJsonPath, // absolute path to file
- after: transformedFile, // file after modifications have been made
- });
-
- This automatically handles all cases of print / dry etc.
- */
-
- return runner.finish();
-}
-
-const transformerMeta = {
- name: `${TRANSFORMER}: ${DESCRIPTION}`,
- value: TRANSFORMER,
- introducedIn: INTRODUCED_IN,
- transformer,
-};
-
-export default transformerMeta;
-
-
diff --git a/packages/turbo-codemod/templates/transformer.test.hbs b/packages/turbo-codemod/templates/transformer.test.hbs
deleted file mode 100644
index c63a9df..0000000
--- a/packages/turbo-codemod/templates/transformer.test.hbs
+++ /dev/null
@@ -1,25 +0,0 @@
-import { transformer } from "../src/transforms/{{ name }}";
-import { setupTestFixtures } from "./test-utils";
-
-describe("{{ name }}", () => {
-
- const { useFixture } = setupTestFixtures({ test: "{{ name }}" });
-
- test("basic", () => {
- // load the fixture for the test
- const { root, read, readJson } = useFixture({
- fixture: "specific-fixture",
- });
-
- // run the transformer
- const result = transformer({
- root,
- options: { force: false, dry: false, print: false },
- });
-
- // result should be correct
- expect(result.fatalError).toBeUndefined();
- expect(result.changes).toMatchInlineSnapshot();
- });
-});
-
diff --git a/packages/turbo-codemod/tsconfig.json b/packages/turbo-codemod/tsconfig.json
deleted file mode 100644
index 0620a3c..0000000
--- a/packages/turbo-codemod/tsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "extends": "@turbo/tsconfig/library.json",
- "compilerOptions": {
- "rootDir": "."
- }
-}
diff --git a/packages/turbo-codemod/tsup.config.ts b/packages/turbo-codemod/tsup.config.ts
deleted file mode 100644
index 8e92107..0000000
--- a/packages/turbo-codemod/tsup.config.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { defineConfig, Options } from "tsup";
-
-export default defineConfig((options: Options) => ({
- entry: ["src/cli.ts", "src/transforms/*.ts"],
- format: ["cjs"],
- clean: true,
- minify: true,
- ...options,
-}));
diff --git a/packages/turbo-ignore/README.md b/packages/turbo-ignore/README.md
deleted file mode 100644
index 866c0e7..0000000
--- a/packages/turbo-ignore/README.md
+++ /dev/null
@@ -1,99 +0,0 @@
-# `turbo-ignore`
-
-To get started, use the following command as your [Ignored Build Step](https://vercel.com/docs/concepts/projects/overview#ignored-build-step):
-
-```sh
-$ npx turbo-ignore
-```
-
-This uses `turbo` to automatically determine if the current app has new changes that need to be deployed.
-
-## Usage
-
-Use `npx turbo-ignore --help` to see list of options:
-
-```sh
-turbo-ignore
-
-Automatically ignore builds that have no changes
-
-Usage:
- $ npx turbo-ignore [<workspace>] [flags...]
-
-If <workspace> is not provided, it will be inferred from the "name"
-field of the "package.json" located at the current working directory.
-
-Flags:
- --fallback=<ref> On Vercel, if no previously deployed SHA is available to compare against,
- fallback to comparing against the provided ref [default: None]
- --help, -h Show this help message
- --version, -v Show the version of this script
-
----
-
-turbo-ignore will also check for special commit messages to indicate if a build should be skipped or not.
-
-Skip turbo-ignore check and automatically ignore:
- - [skip ci]
- - [ci skip]
- - [no ci]
- - [skip vercel]
- - [vercel skip]
- - [vercel skip <workspace>]
-
-Skip turbo-ignore check and automatically deploy:
- - [vercel deploy]
- - [vercel build]
- - [vercel deploy <workspace>]
- - [vercel build <workspace>]
-```
-
-### Examples
-
-```sh
-npx turbo-ignore
-```
-
-> Only build if there are changes to the workspace in the current working directory, or any of it's dependencies. On Vercel, compare against the last successful deployment for the current branch. When not on Vercel, compare against the parent commit (`HEAD^`).
-
----
-
-```sh
-npx turbo-ignore docs
-```
-
-> Only build if there are changes to the `docs` workspace, or any of its dependencies. On Vercel, compare against the last successful deployment for the current branch. When not on Vercel compare against the parent commit (`HEAD^`).
-
----
-
-```sh
-npx turbo-ignore --fallback=HEAD~10
-```
-
-> Only build if there are changes to the workspace in the current working directory, or any of it's dependencies. On Vercel, compare against the last successful deployment for the current branch. If this does not exist (first deploy of the branch), compare against the previous 10 commits. When not on Vercel, always compare against the parent commit (`HEAD^`).
-
----
-
-```sh
-npx turbo-ignore --fallback=HEAD^
-```
-
-> Only build if there are changes to the workspace in the current working directory, or any of it's dependencies. On Vercel, compare against the last successful deployment for the current branch. If this does not exist (first deploy of the branch), compare against the parent commit (`HEAD^`). When not on Vercel, always compare against the parent commit (`HEAD^`).
-
-## How it Works
-
-`turbo-ignore` determines if a build should continue by analyzing the package dependency graph of the given workspace.
-
-The _given workspace_ is determined by reading the "name" field in the "package.json" file located at the current working directory, or by passing in a workspace name as the first argument to `turbo-ignore`.
-
-Next, it uses `turbo run build --dry` to determine if the given workspace, _or any dependencies of the workspace_, have changed since the previous commit.
-
-**NOTE:** `turbo` determines dependencies from reading the dependency graph of the given workspace. This means a workspace **must** be listed as a `dependency` (or `devDependency`) in the given workspaces `package.json` for `turbo` to recognize it.
-
-When deploying on [Vercel](https://vercel.com), `turbo-ignore` can make a more accurate decision by comparing between the current commit, and the last successfully deployed commit for the current branch.
-
-**NOTE:** By default on Vercel, `turbo-ignore` will always deploy the first commit of a new branch. This behavior can be changed by providing the `ref` to compare against to the `--fallback` flag. See the [Examples](#Examples) section for more details.
-
----
-
-For more information about Turborepo, visit [turbo.build](https://turbo.build) and follow us on Twitter ([@turborepo](https://twitter.com/turborepo))!
diff --git a/packages/turbo-ignore/__fixtures__/app/package.json b/packages/turbo-ignore/__fixtures__/app/package.json
deleted file mode 100644
index 17d7c56..0000000
--- a/packages/turbo-ignore/__fixtures__/app/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "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-app/package.json b/packages/turbo-ignore/__fixtures__/invalid-app/package.json
deleted file mode 100644
index ee2f59b..0000000
--- a/packages/turbo-ignore/__fixtures__/invalid-app/package.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "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-app/index.js b/packages/turbo-ignore/__fixtures__/no-app/index.js
deleted file mode 100644
index e69de29..0000000
--- a/packages/turbo-ignore/__fixtures__/no-app/index.js
+++ /dev/null
diff --git a/packages/turbo-ignore/__tests__/args.test.ts b/packages/turbo-ignore/__tests__/args.test.ts
deleted file mode 100644
index f546247..0000000
--- a/packages/turbo-ignore/__tests__/args.test.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import parseArgs, { help } from "../src/args";
-import pkg from "../package.json";
-import { spyConsole, spyExit } from "@turbo/test-utils";
-
-describe("parseArgs()", () => {
- const mockConsole = spyConsole();
- const mockExit = spyExit();
-
- it("does not throw with no args", async () => {
- const result = parseArgs({ argv: [] });
- expect(result.workspace).toBe(undefined);
- expect(result.fallback).toBe(undefined);
- expect(result.task).toBe(undefined);
- });
-
- it("outputs help text (--help)", async () => {
- parseArgs({ argv: ["--help"] });
- expect(mockExit.exit).toHaveBeenCalledWith(0);
- expect(mockConsole.log).toHaveBeenCalledWith(help);
- });
-
- it("outputs help text (-h)", async () => {
- parseArgs({ argv: ["-h"] });
- expect(mockExit.exit).toHaveBeenCalledWith(0);
- expect(mockConsole.log).toHaveBeenCalledWith(help);
- });
-
- it("outputs version text (--version)", async () => {
- parseArgs({ argv: ["--version"] });
- expect(mockExit.exit).toHaveBeenCalledWith(0);
- expect(mockConsole.log).toHaveBeenCalledWith(pkg.version);
- });
-
- it("outputs version text (-v)", async () => {
- parseArgs({ argv: ["-v"] });
- expect(mockExit.exit).toHaveBeenCalledWith(0);
- expect(mockConsole.log).toHaveBeenCalledWith(pkg.version);
- });
-
- it("correctly finds workspace", async () => {
- const result = parseArgs({ argv: ["this-workspace"] });
- expect(result.workspace).toBe("this-workspace");
- expect(result.fallback).toBe(undefined);
- expect(result.task).toBe(undefined);
- expect(mockExit.exit).toHaveBeenCalledTimes(0);
- });
-
- it("correctly finds fallback", async () => {
- const result = parseArgs({ argv: ["--fallback=HEAD^"] });
- expect(result.workspace).toBe(undefined);
- expect(result.fallback).toBe("HEAD^");
- expect(result.task).toBe(undefined);
- expect(mockExit.exit).toHaveBeenCalledTimes(0);
- });
-
- it("correctly finds task", async () => {
- const result = parseArgs({ argv: ["--task=some-workspace#build"] });
- expect(result.workspace).toBe(undefined);
- expect(result.fallback).toBe(undefined);
- expect(result.task).toBe("some-workspace#build");
- expect(mockExit.exit).toHaveBeenCalledTimes(0);
- });
-
- it("uses default fallback if incorrectly specified", async () => {
- const result = parseArgs({ argv: ["--fallback"] });
- expect(result.workspace).toBe(undefined);
- expect(result.fallback).toBe(undefined);
- expect(result.task).toBe(undefined);
- expect(mockExit.exit).toHaveBeenCalledTimes(0);
- });
-
- it("uses default fallback if empty string", async () => {
- const result = parseArgs({ argv: ["--fallback="] });
- expect(result.workspace).toBe(undefined);
- expect(result.fallback).toBe(undefined);
- expect(result.task).toBe(undefined);
- expect(mockExit.exit).toHaveBeenCalledTimes(0);
- });
-
- it("uses default task if incorrectly specified", async () => {
- const result = parseArgs({ argv: ["--task"] });
- expect(result.workspace).toBe(undefined);
- expect(result.fallback).toBe(undefined);
- expect(result.task).toBe(undefined);
- expect(mockExit.exit).toHaveBeenCalledTimes(0);
- });
-
- it("uses default task if empty string", async () => {
- const result = parseArgs({ argv: ["--task="] });
- expect(result.workspace).toBe(undefined);
- expect(result.fallback).toBe(undefined);
- expect(result.task).toBe(undefined);
- expect(mockExit.exit).toHaveBeenCalledTimes(0);
- });
-
- it("correctly finds fallback and workspace", async () => {
- const result = parseArgs({
- argv: [
- "this-workspace",
- "--fallback=HEAD~10",
- "--task=some-workspace#build",
- ],
- });
- expect(result.workspace).toBe("this-workspace");
- expect(result.fallback).toBe("HEAD~10");
- expect(result.task).toBe("some-workspace#build");
- expect(mockExit.exit).toHaveBeenCalledTimes(0);
- });
-});
diff --git a/packages/turbo-ignore/__tests__/checkCommit.test.ts b/packages/turbo-ignore/__tests__/checkCommit.test.ts
deleted file mode 100644
index e7e4a5f..0000000
--- a/packages/turbo-ignore/__tests__/checkCommit.test.ts
+++ /dev/null
@@ -1,229 +0,0 @@
-import child_process from "child_process";
-import { checkCommit } from "../src/checkCommit";
-import { mockEnv } from "@turbo/test-utils";
-
-describe("checkCommit()", () => {
- describe("on Vercel", () => {
- mockEnv();
-
- describe("for all workspaces", () => {
- it("results in continue when no special commit messages are found", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE = "fixing a test";
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "continue",
- scope: "global",
- reason: "No deploy or skip string found in commit message.",
- });
- });
-
- it("results in conflict when deploy and skip commit messages are found", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE =
- "deploying [vercel deploy] and skipping [vercel skip]";
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "conflict",
- scope: "global",
- reason:
- "Conflicting commit messages found: [vercel deploy] and [vercel skip]",
- });
- });
-
- it("results in deploy when deploy commit message is found", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE = "deploying [vercel deploy]";
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "deploy",
- scope: "global",
- reason: "Found commit message: [vercel deploy]",
- });
- });
-
- it("results in skip when skip commit message is found", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE = "skip deployment [vercel skip]";
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "skip",
- scope: "global",
- reason: "Found commit message: [vercel skip]",
- });
- });
- });
-
- describe("for specific workspaces", () => {
- it("results in continue when no special commit messages are found", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE =
- "fixing a test in test-workspace";
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "continue",
- scope: "global",
- reason: "No deploy or skip string found in commit message.",
- });
- });
-
- it("results in conflict when deploy and skip commit messages are found", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE =
- "deploying [vercel deploy test-workspace] and skipping [vercel skip test-workspace]";
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "conflict",
- scope: "workspace",
- reason:
- "Conflicting commit messages found: [vercel deploy test-workspace] and [vercel skip test-workspace]",
- });
- });
-
- it("results in deploy when deploy commit message is found", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE =
- "deploying [vercel deploy test-workspace]";
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "deploy",
- scope: "workspace",
- reason: "Found commit message: [vercel deploy test-workspace]",
- });
- });
-
- it("results in skip when skip commit message is found", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE =
- "skip deployment [vercel skip test-workspace]";
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "skip",
- scope: "workspace",
- reason: "Found commit message: [vercel skip test-workspace]",
- });
- });
- });
- });
- describe("Not on Vercel", () => {
- describe("for all workspaces", () => {
- it("results in continue when no special commit messages are found", async () => {
- const commitBody = "fixing a test";
- const mockExecSync = jest
- .spyOn(child_process, "execSync")
- .mockImplementation((_) => commitBody);
-
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "continue",
- scope: "global",
- reason: "No deploy or skip string found in commit message.",
- });
- expect(mockExecSync).toHaveBeenCalledWith("git show -s --format=%B");
- mockExecSync.mockRestore();
- });
-
- it("results in conflict when deploy and skip commit messages are found", async () => {
- const commitBody =
- "deploying [vercel deploy] and skipping [vercel skip]";
- const mockExecSync = jest
- .spyOn(child_process, "execSync")
- .mockImplementation((_) => commitBody);
-
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "conflict",
- scope: "global",
- reason:
- "Conflicting commit messages found: [vercel deploy] and [vercel skip]",
- });
- expect(mockExecSync).toHaveBeenCalledWith("git show -s --format=%B");
- mockExecSync.mockRestore();
- });
-
- it("results in deploy when deploy commit message is found", async () => {
- const commitBody = "deploying [vercel deploy]";
- const mockExecSync = jest
- .spyOn(child_process, "execSync")
- .mockImplementation((_) => commitBody);
-
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "deploy",
- scope: "global",
- reason: "Found commit message: [vercel deploy]",
- });
- expect(mockExecSync).toHaveBeenCalledWith("git show -s --format=%B");
- mockExecSync.mockRestore();
- });
-
- it("results in skip when skip commit message is found", async () => {
- const commitBody = "skip deployment [vercel skip]";
- const mockExecSync = jest
- .spyOn(child_process, "execSync")
- .mockImplementation((_) => commitBody);
-
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "skip",
- scope: "global",
- reason: "Found commit message: [vercel skip]",
- });
- expect(mockExecSync).toHaveBeenCalledWith("git show -s --format=%B");
- mockExecSync.mockRestore();
- });
- });
-
- describe("for specific workspaces", () => {
- it("results in continue when no special commit messages are found", async () => {
- const commitBody = "fixing a test in test-workspace";
- const mockExecSync = jest
- .spyOn(child_process, "execSync")
- .mockImplementation((_) => commitBody);
-
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "continue",
- scope: "global",
- reason: "No deploy or skip string found in commit message.",
- });
- expect(mockExecSync).toHaveBeenCalledWith("git show -s --format=%B");
- mockExecSync.mockRestore();
- });
-
- it("results in conflict when deploy and skip commit messages are found", async () => {
- const commitBody =
- "deploying [vercel deploy test-workspace] and skipping [vercel skip test-workspace]";
- const mockExecSync = jest
- .spyOn(child_process, "execSync")
- .mockImplementation((_) => commitBody);
-
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "conflict",
- scope: "workspace",
- reason:
- "Conflicting commit messages found: [vercel deploy test-workspace] and [vercel skip test-workspace]",
- });
- expect(mockExecSync).toHaveBeenCalledWith("git show -s --format=%B");
- mockExecSync.mockRestore();
- });
-
- it("results in deploy when deploy commit message is found", async () => {
- const commitBody = "deploying [vercel deploy test-workspace]";
- const mockExecSync = jest
- .spyOn(child_process, "execSync")
- .mockImplementation((_) => commitBody);
-
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "deploy",
- scope: "workspace",
- reason: "Found commit message: [vercel deploy test-workspace]",
- });
- expect(mockExecSync).toHaveBeenCalledWith("git show -s --format=%B");
- mockExecSync.mockRestore();
- });
-
- it("results in skip when skip commit message is found", async () => {
- const commitBody = "skip deployment [vercel skip test-workspace]";
- const mockExecSync = jest
- .spyOn(child_process, "execSync")
- .mockImplementation((_) => commitBody);
-
- expect(checkCommit({ workspace: "test-workspace" })).toEqual({
- result: "skip",
- scope: "workspace",
- reason: "Found commit message: [vercel skip test-workspace]",
- });
- expect(mockExecSync).toHaveBeenCalledWith("git show -s --format=%B");
- mockExecSync.mockRestore();
- });
- });
- });
-});
diff --git a/packages/turbo-ignore/__tests__/errors.test.ts b/packages/turbo-ignore/__tests__/errors.test.ts
deleted file mode 100644
index 18f26bd..0000000
--- a/packages/turbo-ignore/__tests__/errors.test.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { shouldWarn, NON_FATAL_ERRORS } from "../src/errors";
-
-describe("shouldWarn()", () => {
- it("it detects errors when packageManager is missing", async () => {
- const result = shouldWarn({
- err: `run failed: We did not detect an in-use package manager for your project. Please set the "packageManager" property in your root package.json (https://nodejs.org/api/packages.html#packagemanager) or run \`npx @turbo/codemod add-package-manager\` in the root of your monorepo.`,
- });
- expect(result.code).toBe("NO_PACKAGE_MANAGER");
- expect(result.level).toBe("warn");
- expect(result.message).toBe(NON_FATAL_ERRORS.NO_PACKAGE_MANAGER.message);
- });
-
- it("it detects errors when yarn lockfile is missing", async () => {
- const result = shouldWarn({
- err: `* reading yarn.lock: open /test/../yarn.lock: no such file or directory`,
- });
- expect(result.code).toBe("MISSING_LOCKFILE");
- expect(result.level).toBe("warn");
- expect(result.message).toBe(NON_FATAL_ERRORS.MISSING_LOCKFILE.message);
- });
-
- it("it detects errors when pnpm lockfile is missing", async () => {
- const result = shouldWarn({
- err: `* reading pnpm-lock.yaml: open /test/../pnpm-lock.yaml: no such file or directory`,
- });
- expect(result.code).toBe("MISSING_LOCKFILE");
- expect(result.level).toBe("warn");
- expect(result.message).toBe(NON_FATAL_ERRORS.MISSING_LOCKFILE.message);
- });
-
- it("it detects errors when npm lockfile is missing", async () => {
- const result = shouldWarn({
- err: `* reading package-lock.json: open /test/../package-lock.json: no such file or directory`,
- });
- expect(result.code).toBe("MISSING_LOCKFILE");
- expect(result.level).toBe("warn");
- expect(result.message).toBe(NON_FATAL_ERRORS.MISSING_LOCKFILE.message);
- });
-
- it("it returns unknown errors", async () => {
- const result = shouldWarn({ err: `something bad happened` });
- expect(result.code).toBe("UNKNOWN_ERROR");
- expect(result.level).toBe("error");
- expect(result.message).toBe(`something bad happened`);
- });
-});
diff --git a/packages/turbo-ignore/__tests__/getComparison.test.ts b/packages/turbo-ignore/__tests__/getComparison.test.ts
deleted file mode 100644
index b5c74c7..0000000
--- a/packages/turbo-ignore/__tests__/getComparison.test.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import { getComparison } from "../src/getComparison";
-import { spyConsole, mockEnv } from "@turbo/test-utils";
-
-describe("getComparison()", () => {
- mockEnv();
- const mockConsole = spyConsole();
- it("uses headRelative comparison when not running Vercel CI", async () => {
- expect(getComparison({ workspace: "test-workspace" }))
- .toMatchInlineSnapshot(`
- Object {
- "ref": "HEAD^",
- "type": "headRelative",
- }
- `);
- });
-
- it("returns null when running in Vercel CI with no VERCEL_GIT_PREVIOUS_SHA", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_REF = "my-branch";
- expect(getComparison({ workspace: "test-workspace" })).toBeNull();
- expect(mockConsole.log).toHaveBeenCalledWith(
- "≫ ",
- 'No previous deployments found for "test-workspace" on branch "my-branch".'
- );
- });
-
- it("uses custom fallback when running in Vercel CI with no VERCEL_GIT_PREVIOUS_SHA", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_REF = "my-branch";
- expect(getComparison({ workspace: "test-workspace", fallback: "HEAD^2" }))
- .toMatchInlineSnapshot(`
- Object {
- "ref": "HEAD^2",
- "type": "customFallback",
- }
- `);
- expect(mockConsole.log).toHaveBeenNthCalledWith(
- 1,
- "≫ ",
- 'No previous deployments found for "test-workspace" on branch "my-branch".'
- );
- expect(mockConsole.log).toHaveBeenNthCalledWith(
- 2,
- "≫ ",
- "Falling back to ref HEAD^2"
- );
- });
-
- it("uses previousDeploy when running in Vercel CI with VERCEL_GIT_PREVIOUS_SHA", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_PREVIOUS_SHA = "mygitsha";
- process.env.VERCEL_GIT_COMMIT_REF = "my-branch";
- expect(getComparison({ workspace: "test-workspace" }))
- .toMatchInlineSnapshot(`
- Object {
- "ref": "mygitsha",
- "type": "previousDeploy",
- }
- `);
- });
-});
diff --git a/packages/turbo-ignore/__tests__/getTask.test.ts b/packages/turbo-ignore/__tests__/getTask.test.ts
deleted file mode 100644
index a184893..0000000
--- a/packages/turbo-ignore/__tests__/getTask.test.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { getTask } from "../src/getTask";
-import { spyConsole, validateLogs } from "@turbo/test-utils";
-
-describe("getWorkspace()", () => {
- const mockConsole = spyConsole();
- it("getTask defaults to build", async () => {
- expect(getTask({})).toEqual("build");
- validateLogs(
- ['Using "build" as the task as it was unspecified'],
- mockConsole.log,
- { prefix: "≫ " }
- );
- });
-
- it("getTask returns a quoted task if user-supplied", async () => {
- expect(
- getTask({
- task: "workspace#task",
- })
- ).toEqual(`"workspace#task"`);
- validateLogs(
- ['Using "workspace#task" as the task from the arguments'],
- mockConsole.log,
- { prefix: "≫ " }
- );
- });
-});
diff --git a/packages/turbo-ignore/__tests__/getWorkspace.test.ts b/packages/turbo-ignore/__tests__/getWorkspace.test.ts
deleted file mode 100644
index 6d97fe2..0000000
--- a/packages/turbo-ignore/__tests__/getWorkspace.test.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { getWorkspace } from "../src/getWorkspace";
-import { spyConsole, validateLogs } from "@turbo/test-utils";
-
-describe("getWorkspace()", () => {
- const mockConsole = spyConsole();
- it("getWorkspace returns workspace from arg", async () => {
- expect(
- getWorkspace({
- workspace: "test-workspace",
- })
- ).toEqual("test-workspace");
- validateLogs(
- ['Using "test-workspace" as workspace from arguments'],
- mockConsole.log,
- { prefix: "≫ " }
- );
- });
-
- it("getWorkspace returns workspace from package.json", async () => {
- expect(
- getWorkspace({
- directory: "./__fixtures__/app",
- })
- ).toEqual("test-app");
- expect(mockConsole.log).toHaveBeenCalledWith(
- "≫ ",
- 'Inferred "test-app" as workspace from "package.json"'
- );
- });
-
- it("getWorkspace used current directory if not specified", async () => {
- expect(getWorkspace({})).toEqual("turbo-ignore");
- expect(mockConsole.log).toHaveBeenCalledWith(
- "≫ ",
- 'Inferred "turbo-ignore" as workspace from "package.json"'
- );
- });
-
- it("getWorkspace returns null when no arg is provided and package.json is missing name field", async () => {
- expect(
- getWorkspace({
- directory: "./__fixtures__/invalid-app",
- })
- ).toEqual(null);
- expect(mockConsole.error).toHaveBeenCalledWith(
- "≫ ",
- '"__fixtures__/invalid-app/package.json" is missing the "name" field (required).'
- );
- });
-
- it("getWorkspace returns null when no arg is provided and package.json can be found", async () => {
- expect(
- getWorkspace({
- directory: "./__fixtures__/no-app",
- })
- ).toEqual(null);
- expect(mockConsole.error).toHaveBeenCalledWith(
- "≫ ",
- '"__fixtures__/no-app/package.json" could not be found. turbo-ignore inferencing failed'
- );
- });
-});
diff --git a/packages/turbo-ignore/__tests__/ignore.test.ts b/packages/turbo-ignore/__tests__/ignore.test.ts
deleted file mode 100644
index 37908c5..0000000
--- a/packages/turbo-ignore/__tests__/ignore.test.ts
+++ /dev/null
@@ -1,578 +0,0 @@
-import child_process, { ChildProcess, ExecException } from "child_process";
-import turboIgnore from "../src/ignore";
-import {
- spyConsole,
- spyExit,
- SpyExit,
- mockEnv,
- validateLogs,
-} from "@turbo/test-utils";
-
-function expectBuild(mockExit: SpyExit) {
- expect(mockExit.exit).toHaveBeenCalledWith(1);
-}
-
-function expectIgnore(mockExit: SpyExit) {
- expect(mockExit.exit).toHaveBeenCalledWith(0);
-}
-
-describe("turboIgnore()", () => {
- mockEnv();
- const mockExit = spyExit();
- const mockConsole = spyConsole();
-
- it("throws error and allows build when exec fails", async () => {
- const mockExec = jest
- .spyOn(child_process, "exec")
- .mockImplementation((command, options, callback) => {
- if (callback) {
- return callback(
- "error" as unknown as ExecException,
- "stdout",
- "stderr"
- ) as unknown as ChildProcess;
- }
- return {} as unknown as ChildProcess;
- });
-
- turboIgnore({
- args: { workspace: "test-workspace" },
- });
-
- expect(mockExec).toHaveBeenCalledWith(
- "npx turbo run build --filter=test-workspace...[HEAD^] --dry=json",
- expect.anything(),
- expect.anything()
- );
-
- validateLogs(["UNKNOWN_ERROR: error"], mockConsole.error, {
- prefix: "≫ ",
- });
-
- expectBuild(mockExit);
- mockExec.mockRestore();
- });
-
- it("throws pretty error and allows build when exec fails", async () => {
- const mockExec = jest
- .spyOn(child_process, "exec")
- .mockImplementation((command, options, callback) => {
- if (callback) {
- return callback(
- {
- message:
- "run failed: We did not detect an in-use package manager for your project",
- } as unknown as ExecException,
- "stdout",
- "stderr"
- ) as unknown as ChildProcess;
- }
- return {} as unknown as ChildProcess;
- });
-
- turboIgnore({
- args: { workspace: "test-workspace" },
- });
-
- expect(mockExec).toHaveBeenCalledWith(
- "npx turbo run build --filter=test-workspace...[HEAD^] --dry=json",
- expect.anything(),
- expect.anything()
- );
-
- validateLogs(
- [
- `turbo-ignore could not complete - no package manager detected, please commit a lockfile, or set "packageManager" in your root "package.json"`,
- ],
- mockConsole.warn,
- { prefix: "≫ " }
- );
-
- expectBuild(mockExit);
- mockExec.mockRestore();
- });
-
- it("throws pretty error and allows build when can't find previous sha", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_PREVIOUS_SHA = "too-far-back";
- process.env.VERCEL_GIT_COMMIT_REF = "my-branch";
- const mockExec = jest
- .spyOn(child_process, "exec")
- .mockImplementation((command, options, callback) => {
- if (callback) {
- return callback(
- {
- message:
- " ERROR run failed: failed to resolve packages to run: commit too-far-back does not exist",
- } as unknown as ExecException,
- "stdout",
- "stderr"
- ) as unknown as ChildProcess;
- }
- return {} as unknown as ChildProcess;
- });
-
- turboIgnore({
- args: { workspace: "test-workspace" },
- });
-
- expect(mockExec).toHaveBeenCalledWith(
- "npx turbo run build --filter=test-workspace...[too-far-back] --dry=json",
- expect.anything(),
- expect.anything()
- );
-
- validateLogs(
- [
- `turbo-ignore could not complete - commit does not exist or is unreachable`,
- ],
- mockConsole.warn,
- { prefix: "≫ " }
- );
-
- expectBuild(mockExit);
- mockExec.mockRestore();
- });
-
- it("throws pretty error and allows build when fallback fails", async () => {
- const mockExec = jest
- .spyOn(child_process, "exec")
- .mockImplementation((command, options, callback) => {
- if (callback) {
- return callback(
- {
- message:
- "ERROR run failed: failed to resolve packages to run: commit HEAD^ does not exist",
- } as unknown as ExecException,
- "stdout",
- "stderr"
- ) as unknown as ChildProcess;
- }
- return {} as unknown as ChildProcess;
- });
-
- turboIgnore({
- args: { workspace: "test-workspace", fallback: "HEAD^" },
- });
-
- expect(mockExec).toHaveBeenCalledWith(
- "npx turbo run build --filter=test-workspace...[HEAD^] --dry=json",
- expect.anything(),
- expect.anything()
- );
-
- validateLogs(
- [
- `turbo-ignore could not complete - parent commit does not exist or is unreachable`,
- ],
- mockConsole.warn,
- { prefix: "≫ " }
- );
-
- expectBuild(mockExit);
- mockExec.mockRestore();
- });
-
- it("skips checks and allows build when no workspace can be found", async () => {
- turboIgnore({
- args: {
- directory: "__fixtures__/no-app",
- },
- });
- validateLogs(
- [
- () => [
- "≫ ",
- expect.stringContaining(
- " could not be found. turbo-ignore inferencing failed"
- ),
- ],
- ],
- mockConsole.error,
- { prefix: "≫ " }
- );
- expectBuild(mockExit);
- });
-
- it("skips checks and allows build when a workspace with no name is found", async () => {
- turboIgnore({
- args: {
- directory: "__fixtures__/invalid-app",
- },
- });
- validateLogs(
- [
- () => [
- "≫ ",
- expect.stringContaining(' is missing the "name" field (required).'),
- ],
- ],
- mockConsole.error,
- { prefix: "≫ " }
- );
- expectBuild(mockExit);
- });
-
- it("skips checks and allows build when no monorepo root can be found", async () => {
- turboIgnore({
- args: { directory: "/" },
- });
- expectBuild(mockExit);
- expect(mockConsole.error).toHaveBeenLastCalledWith(
- "≫ ",
- "Monorepo root not found. turbo-ignore inferencing failed"
- );
- });
-
- it("skips checks and allows build when TURBO_FORCE is set", async () => {
- process.env.TURBO_FORCE = "true";
- turboIgnore({
- args: { workspace: "test-workspace" },
- });
- expect(mockConsole.log).toHaveBeenNthCalledWith(
- 2,
- "≫ ",
- "`TURBO_FORCE` detected"
- );
- expectBuild(mockExit);
- });
-
- it("allows build when no comparison is returned", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_PREVIOUS_SHA = "";
- process.env.VERCEL_GIT_COMMIT_REF = "my-branch";
- turboIgnore({
- args: {
- workspace: "test-app",
- directory: "__fixtures__/app",
- },
- });
- expect(mockConsole.log).toHaveBeenNthCalledWith(
- 4,
- "≫ ",
- 'No previous deployments found for "test-app" on branch "my-branch".'
- );
- expectBuild(mockExit);
- });
-
- it("skips build for `previousDeploy` comparison with no changes", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_PREVIOUS_SHA = "last-deployed-sha";
- process.env.VERCEL_GIT_COMMIT_REF = "my-branch";
- 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({
- args: {
- directory: "__fixtures__/app",
- },
- });
- validateLogs(
- [
- "Using Turborepo to determine if this project is affected by the commit...\n",
- 'Inferred "test-app" as workspace from "package.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`",
- "This project and its dependencies are not affected",
- () => expect.stringContaining("⏭ Ignoring the change"),
- ],
- mockConsole.log,
- { prefix: "≫ " }
- );
-
- expectIgnore(mockExit);
- mockExec.mockRestore();
- });
-
- it("allows build for `previousDeploy` comparison with changes", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_PREVIOUS_SHA = "last-deployed-sha";
- process.env.VERCEL_GIT_COMMIT_REF = "my-branch";
- const mockExec = jest
- .spyOn(child_process, "exec")
- .mockImplementation((command, options, callback) => {
- if (callback) {
- return callback(
- null,
- '{"packages":["test-app"],"tasks":[]}',
- "stderr"
- ) as unknown as ChildProcess;
- }
- return {} as unknown as ChildProcess;
- });
- turboIgnore({
- args: {
- task: "workspace#build",
- directory: "__fixtures__/app",
- },
- });
- validateLogs(
- [
- "Using Turborepo to determine if this project is affected by the commit...\n",
- 'Inferred "test-app" as workspace from "package.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`',
- 'This commit affects "test-app"',
- () => expect.stringContaining("✓ Proceeding with deployment"),
- ],
- mockConsole.log,
- { prefix: "≫ " }
- );
-
- expectBuild(mockExit);
- mockExec.mockRestore();
- });
-
- it("allows build for `previousDeploy` comparison with single dependency change", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_PREVIOUS_SHA = "last-deployed-sha";
- process.env.VERCEL_GIT_COMMIT_REF = "my-branch";
- const mockExec = jest
- .spyOn(child_process, "exec")
- .mockImplementation((command, options, callback) => {
- if (callback) {
- return callback(
- null,
- '{"packages":["test-app", "ui"],"tasks":[]}',
- "stderr"
- ) as unknown as ChildProcess;
- }
- return {} as unknown as ChildProcess;
- });
- turboIgnore({
- args: {
- directory: "__fixtures__/app",
- },
- });
- validateLogs(
- [
- "Using Turborepo to determine if this project is affected by the commit...\n",
- 'Inferred "test-app" as workspace from "package.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`",
- 'This commit affects "test-app" and 1 dependency (ui)',
- () => expect.stringContaining("✓ Proceeding with deployment"),
- ],
- mockConsole.log,
- { prefix: "≫ " }
- );
-
- expectBuild(mockExit);
- mockExec.mockRestore();
- });
-
- it("allows build for `previousDeploy` comparison with multiple dependency changes", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_PREVIOUS_SHA = "last-deployed-sha";
- process.env.VERCEL_GIT_COMMIT_REF = "my-branch";
- const mockExec = jest
- .spyOn(child_process, "exec")
- .mockImplementation((command, options, callback) => {
- if (callback) {
- return callback(
- null,
- '{"packages":["test-app", "ui", "tsconfig"],"tasks":[]}',
- "stderr"
- ) as unknown as ChildProcess;
- }
- return {} as unknown as ChildProcess;
- });
- turboIgnore({
- args: {
- directory: "__fixtures__/app",
- },
- });
- validateLogs(
- [
- "Using Turborepo to determine if this project is affected by the commit...\n",
- 'Inferred "test-app" as workspace from "package.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`",
- 'This commit affects "test-app" and 2 dependencies (ui, tsconfig)',
- () => expect.stringContaining("✓ Proceeding with deployment"),
- ],
- mockConsole.log,
- { prefix: "≫ " }
- );
-
- expectBuild(mockExit);
- mockExec.mockRestore();
- });
-
- it("throws error and allows build when json cannot be parsed", async () => {
- const mockExec = jest
- .spyOn(child_process, "exec")
- .mockImplementation((command, options, callback) => {
- if (callback) {
- return callback(null, "stdout", "stderr") as unknown as ChildProcess;
- }
- return {} as unknown as ChildProcess;
- });
-
- turboIgnore({
- args: {
- directory: "__fixtures__/app",
- },
- });
-
- expect(mockExec).toHaveBeenCalledWith(
- "npx turbo 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`.",
- ],
- mockConsole.error,
- { prefix: "≫ " }
- );
-
- expectBuild(mockExit);
- mockExec.mockRestore();
- });
-
- it("throws error and allows build when stdout is null", async () => {
- const mockExec = jest
- .spyOn(child_process, "exec")
- .mockImplementation((command, options, callback) => {
- if (callback) {
- return callback(
- null,
- null as unknown as string,
- "stderr"
- ) as unknown as ChildProcess;
- }
- return {} as unknown as ChildProcess;
- });
-
- turboIgnore({
- args: {
- directory: "__fixtures__/app",
- },
- });
-
- expect(mockExec).toHaveBeenCalledWith(
- "npx turbo 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`.",
- ],
- mockConsole.error,
- { prefix: "≫ " }
- );
-
- expectBuild(mockExit);
- mockExec.mockRestore();
- });
-
- it("skips when commit message contains a skip string", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE = "[vercel skip]";
-
- turboIgnore({
- args: {
- directory: "__fixtures__/app",
- },
- });
-
- validateLogs(
- [
- "Using Turborepo to determine if this project is affected by the commit...\n",
- 'Inferred "test-app" as workspace from "package.json"',
- 'Using "build" as the task as it was unspecified',
- "Found commit message: [vercel skip]",
- () => expect.stringContaining("⏭ Ignoring the change"),
- ],
- mockConsole.log,
- { prefix: "≫ " }
- );
-
- expectIgnore(mockExit);
- });
-
- it("deploys when commit message contains a deploy string", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE = "[vercel deploy]";
-
- turboIgnore({
- args: {
- directory: "__fixtures__/app",
- },
- });
-
- validateLogs(
- [
- "Using Turborepo to determine if this project is affected by the commit...\n",
- 'Inferred "test-app" as workspace from "package.json"',
- 'Using "build" as the task as it was unspecified',
- "Found commit message: [vercel deploy]",
- () => expect.stringContaining("✓ Proceeding with deployment"),
- ],
- mockConsole.log,
- { prefix: "≫ " }
- );
-
- expectBuild(mockExit);
- });
-
- it("runs full turbo-ignore check when commit message contains a conflicting string", async () => {
- process.env.VERCEL = "1";
- process.env.VERCEL_GIT_COMMIT_MESSAGE = "[vercel deploy] [vercel skip]";
- process.env.VERCEL_GIT_PREVIOUS_SHA = "last-deployed-sha";
- process.env.VERCEL_GIT_COMMIT_REF = "my-branch";
-
- 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({
- args: {
- directory: "__fixtures__/app",
- },
- });
-
- validateLogs(
- [
- "Using Turborepo to determine if this project is affected by the commit...\n",
- 'Inferred "test-app" as workspace from "package.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`",
- "This project and its dependencies are not affected",
- () => expect.stringContaining("⏭ Ignoring the change"),
- ],
- mockConsole.log,
- { prefix: "≫ " }
- );
-
- expectIgnore(mockExit);
- mockExec.mockRestore();
- });
-});
diff --git a/packages/turbo-ignore/jest.config.js b/packages/turbo-ignore/jest.config.js
deleted file mode 100644
index 52ddbbc..0000000
--- a/packages/turbo-ignore/jest.config.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
- preset: "ts-jest/presets/js-with-ts",
- testEnvironment: "node",
- testPathIgnorePatterns: ["/__fixtures__/"],
- coveragePathIgnorePatterns: ["/__fixtures__/"],
- collectCoverage: true,
- coverageThreshold: {
- global: {
- branches: 100,
- functions: 100,
- lines: 100,
- statements: 100,
- },
- },
- modulePathIgnorePatterns: ["<rootDir>/node_modules", "<rootDir>/dist"],
- transformIgnorePatterns: ["/node_modules/(?!(ansi-regex)/)"],
-};
diff --git a/packages/turbo-ignore/package.json b/packages/turbo-ignore/package.json
deleted file mode 100644
index 0fae072..0000000
--- a/packages/turbo-ignore/package.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "name": "turbo-ignore",
- "version": "1.9.4-canary.2",
- "description": "",
- "homepage": "https://turbo.build/repo",
- "keywords": [],
- "author": "Jared Palmer",
- "license": "MPL-2.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/turbo",
- "directory": "packages/turbo-ignore"
- },
- "bugs": {
- "url": "https://github.com/vercel/turbo/issues"
- },
- "files": [
- "dist"
- ],
- "main": "dist/index.js",
- "bin": "dist/index.js",
- "scripts": {
- "build": "tsup",
- "test": "jest",
- "lint": "eslint src/**/*.ts",
- "check-types": "tsc --noEmit"
- },
- "devDependencies": {
- "@types/jest": "^27.4.0",
- "@types/node": "^16.11.12",
- "eslint": "^8.20.0",
- "jest": "^27.4.3",
- "ts-jest": "^27.1.1",
- "@turbo/tsconfig": "workspace:*",
- "tsup": "^5.12.1",
- "@turbo/test-utils": "workspace:^0.0.0",
- "@turbo/utils": "workspace:*",
- "typescript": "^4.7.4"
- }
-}
diff --git a/packages/turbo-ignore/src/args.ts b/packages/turbo-ignore/src/args.ts
deleted file mode 100644
index 8d6015c..0000000
--- a/packages/turbo-ignore/src/args.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-import pkg from "../package.json";
-import { TurboIgnoreArgs } from "./types";
-import {
- skipAllCommits,
- forceAllCommits,
- skipWorkspaceCommits,
- forceWorkspaceCommits,
-} from "./checkCommit";
-
-export const help = `
-turbo-ignore
-
-Automatically ignore builds that have no changes
-
-Usage:
- $ npx turbo-ignore [<workspace>] [flags...]
-
-If <workspace> is not provided, it will be inferred from the "name"
-field of the "package.json" located at the current working directory.
-
-Flags:
- --fallback=<ref> On Vercel, if no previously deployed SHA is available to compare against,
- fallback to comparing against the provided ref
- --help, -h Show this help message
- --version, -v Show the version of this script
-
----
-
-turbo-ignore will also check for special commit messages to indicate if a build should be skipped or not.
-
-Skip turbo-ignore check and automatically ignore:
-${[...skipAllCommits, ...skipWorkspaceCommits({ workspace: "<workspace>" })]
- .map((msg) => ` - ${msg}`)
- .join("\n")}
-
-Skip turbo-ignore check and automatically deploy:
-${[...forceAllCommits, ...forceWorkspaceCommits({ workspace: "<workspace>" })]
- .map((msg) => ` - ${msg}`)
- .join("\n")}
-`;
-
-// simple args parser because we don't want to pull in a dependency
-// and we don't need many features
-export default function parseArgs({
- argv,
-}: {
- argv: Array<string>;
-}): TurboIgnoreArgs {
- const args: TurboIgnoreArgs = { directory: process.cwd() };
-
- // find all flags
- const flags = new Set(
- argv
- .filter((args) => args.startsWith("-"))
- .map((flag) => flag.replace(/-/g, ""))
- );
-
- // handle help flag and exit
- if (flags.has("help") || flags.has("h")) {
- console.log(help);
- process.exit(0);
- }
- // handle version flag and exit
- if (flags.has("version") || flags.has("v")) {
- console.log(pkg.version);
- process.exit(0);
- }
-
- // set workspace (if provided)
- if (argv.length && !argv[0].startsWith("-")) {
- args.workspace = argv[0];
- }
-
- // set task (if provided)
- const taskArgSentinel = "--task=";
- const taskArg = argv.find((arg) => arg.startsWith(taskArgSentinel));
- if (taskArg && taskArg.length > taskArgSentinel.length) {
- args.task = taskArg.split("=")[1];
- }
-
- // set fallback (if provided)
- const fallbackSentinel = "--fallback=";
- const fallbackArg = argv.find((arg) => arg.startsWith(fallbackSentinel));
- if (fallbackArg && fallbackArg.length > fallbackSentinel.length) {
- args.fallback = fallbackArg.split("=")[1];
- }
-
- return args;
-}
diff --git a/packages/turbo-ignore/src/checkCommit.ts b/packages/turbo-ignore/src/checkCommit.ts
deleted file mode 100644
index af6108e..0000000
--- a/packages/turbo-ignore/src/checkCommit.ts
+++ /dev/null
@@ -1,104 +0,0 @@
-import { execSync } from "child_process";
-
-export const skipAllCommits = [
- `[skip ci]`,
- `[ci skip]`,
- `[no ci]`,
- `[skip vercel]`,
- `[vercel skip]`,
-];
-
-export const forceAllCommits = [`[vercel deploy]`, `[vercel build]`];
-
-export function skipWorkspaceCommits({ workspace }: { workspace: string }) {
- return [`[vercel skip ${workspace}]`];
-}
-
-export function forceWorkspaceCommits({ workspace }: { workspace: string }) {
- return [`[vercel deploy ${workspace}]`, `[vercel build ${workspace}]`];
-}
-
-export function getCommitDetails() {
- // if we're on Vercel, use the provided commit message
- if (process.env.VERCEL === "1") {
- if (process.env.VERCEL_GIT_COMMIT_MESSAGE) {
- return process.env.VERCEL_GIT_COMMIT_MESSAGE;
- }
- }
- return execSync("git show -s --format=%B").toString();
-}
-
-export function checkCommit({ workspace }: { workspace: string }): {
- result: "skip" | "deploy" | "continue" | "conflict";
- scope: "global" | "workspace";
- reason: string;
-} {
- const commitMessage = getCommitDetails();
- const findInCommit = (commit: string) => commitMessage.includes(commit);
-
- // check workspace specific messages first
- const forceWorkspaceDeploy = forceWorkspaceCommits({ workspace }).find(
- findInCommit
- );
- const forceWorkspaceSkip = skipWorkspaceCommits({ workspace }).find(
- findInCommit
- );
-
- if (forceWorkspaceDeploy && forceWorkspaceSkip) {
- return {
- result: "conflict",
- scope: "workspace",
- reason: `Conflicting commit messages found: ${forceWorkspaceDeploy} and ${forceWorkspaceSkip}`,
- };
- }
-
- if (forceWorkspaceDeploy) {
- return {
- result: "deploy",
- scope: "workspace",
- reason: `Found commit message: ${forceWorkspaceDeploy}`,
- };
- }
-
- if (forceWorkspaceSkip) {
- return {
- result: "skip",
- scope: "workspace",
- reason: `Found commit message: ${forceWorkspaceSkip}`,
- };
- }
-
- // check global messages last
- const forceDeploy = forceAllCommits.find(findInCommit);
- const forceSkip = skipAllCommits.find(findInCommit);
-
- if (forceDeploy && forceSkip) {
- return {
- result: "conflict",
- scope: "global",
- reason: `Conflicting commit messages found: ${forceDeploy} and ${forceSkip}`,
- };
- }
-
- if (forceDeploy) {
- return {
- result: "deploy",
- scope: "global",
- reason: `Found commit message: ${forceDeploy}`,
- };
- }
-
- if (forceSkip) {
- return {
- result: "skip",
- scope: "global",
- reason: `Found commit message: ${forceSkip}`,
- };
- }
-
- return {
- result: "continue",
- scope: "global",
- reason: `No deploy or skip string found in commit message.`,
- };
-}
diff --git a/packages/turbo-ignore/src/errors.ts b/packages/turbo-ignore/src/errors.ts
deleted file mode 100644
index f600dfb..0000000
--- a/packages/turbo-ignore/src/errors.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { NonFatalErrorKey, NonFatalErrors } from "./types";
-
-export const NON_FATAL_ERRORS: NonFatalErrors = {
- MISSING_LOCKFILE: {
- regex:
- /reading (yarn.lock|package-lock.json|pnpm-lock.yaml):.*?no such file or directory/,
- message: `turbo-ignore could not complete - no lockfile found, please commit one to your repository`,
- },
- NO_PACKAGE_MANAGER: {
- regex:
- /run failed: We did not detect an in-use package manager for your project/,
- message: `turbo-ignore could not complete - no package manager detected, please commit a lockfile, or set "packageManager" in your root "package.json"`,
- },
- UNREACHABLE_PARENT: {
- regex: /failed to resolve packages to run: commit HEAD\^ does not exist/,
- message: `turbo-ignore could not complete - parent commit does not exist or is unreachable`,
- },
- UNREACHABLE_COMMIT: {
- regex: /commit \S+ does not exist/,
- message: `turbo-ignore could not complete - commit does not exist or is unreachable`,
- },
-};
-
-export function shouldWarn({ err }: { err: string }): {
- level: "warn" | "error";
- message: string;
- code: NonFatalErrorKey | "UNKNOWN_ERROR";
-} {
- const knownError = Object.keys(NON_FATAL_ERRORS).find((key) => {
- const { regex } = NON_FATAL_ERRORS[key as NonFatalErrorKey];
- return regex.test(err);
- });
-
- if (knownError) {
- return {
- level: "warn",
- message: NON_FATAL_ERRORS[knownError as NonFatalErrorKey].message,
- code: knownError as NonFatalErrorKey,
- };
- }
-
- return { level: "error", message: err, code: "UNKNOWN_ERROR" };
-}
diff --git a/packages/turbo-ignore/src/getComparison.ts b/packages/turbo-ignore/src/getComparison.ts
deleted file mode 100644
index a2ad61a..0000000
--- a/packages/turbo-ignore/src/getComparison.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { info } from "./logger";
-import { TurboIgnoreArgs } from "./types";
-
-export interface GetComparisonArgs extends TurboIgnoreArgs {
- // the workspace to check for changes
- workspace: string;
- // A ref/head to compare against if no previously deployed SHA is available
- fallback?: string;
-}
-
-export function getComparison(args: GetComparisonArgs): {
- ref: string;
- type: "previousDeploy" | "headRelative" | "customFallback";
-} | null {
- const { fallback, workspace } = args;
- if (process.env.VERCEL === "1") {
- if (process.env.VERCEL_GIT_PREVIOUS_SHA) {
- // use the commit SHA of the last successful deployment for this project / branch
- info(
- `Found previous deployment ("${process.env.VERCEL_GIT_PREVIOUS_SHA}") for "${workspace}" on branch "${process.env.VERCEL_GIT_COMMIT_REF}"`
- );
- return {
- ref: process.env.VERCEL_GIT_PREVIOUS_SHA,
- type: "previousDeploy",
- };
- } else {
- info(
- `No previous deployments found for "${workspace}" on branch "${process.env.VERCEL_GIT_COMMIT_REF}".`
- );
- if (fallback) {
- info(`Falling back to ref ${fallback}`);
- return { ref: fallback, type: "customFallback" };
- }
-
- return null;
- }
- }
- return { ref: "HEAD^", type: "headRelative" };
-}
diff --git a/packages/turbo-ignore/src/getTask.ts b/packages/turbo-ignore/src/getTask.ts
deleted file mode 100644
index 9e95e35..0000000
--- a/packages/turbo-ignore/src/getTask.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { info } from "./logger";
-import { TurboIgnoreArgs } from "./types";
-
-export function getTask(args: TurboIgnoreArgs): string | null {
- if (args.task) {
- info(`Using "${args.task}" as the task from the arguments`);
- return `"${args.task}"`;
- }
-
- info('Using "build" as the task as it was unspecified');
-
- return "build";
-}
diff --git a/packages/turbo-ignore/src/getWorkspace.ts b/packages/turbo-ignore/src/getWorkspace.ts
deleted file mode 100644
index e0b3167..0000000
--- a/packages/turbo-ignore/src/getWorkspace.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import fs from "fs";
-import path from "path";
-import { error, info } from "./logger";
-import { TurboIgnoreArgs } from "./types";
-
-export function getWorkspace(args: TurboIgnoreArgs): string | null {
- const { directory = process.cwd(), workspace } = args;
-
- // if the workspace is provided via args, use that
- if (workspace) {
- info(`Using "${workspace}" as workspace from arguments`);
- return workspace;
- }
-
- // otherwise, try and infer it from a package.json in the current directory
- const packageJsonPath = path.join(directory, "package.json");
- try {
- const raw = fs.readFileSync(packageJsonPath, "utf8");
- const packageJsonContent: Record<string, string> & { name: string } =
- JSON.parse(raw);
-
- if (!packageJsonContent.name) {
- error(`"${packageJsonPath}" is missing the "name" field (required).`);
- return null;
- }
-
- info(
- `Inferred "${packageJsonContent.name}" as workspace from "package.json"`
- );
- return packageJsonContent.name;
- } catch (e) {
- error(
- `"${packageJsonPath}" could not be found. turbo-ignore inferencing failed`
- );
- return null;
- }
-}
diff --git a/packages/turbo-ignore/src/ignore.ts b/packages/turbo-ignore/src/ignore.ts
deleted file mode 100644
index a6f8f2e..0000000
--- a/packages/turbo-ignore/src/ignore.ts
+++ /dev/null
@@ -1,125 +0,0 @@
-import { exec } from "child_process";
-import path from "path";
-import { getTurboRoot } from "@turbo/utils";
-import { getComparison } from "./getComparison";
-import { getTask } from "./getTask";
-import { getWorkspace } from "./getWorkspace";
-import { info, warn, error } from "./logger";
-import { shouldWarn } from "./errors";
-import { TurboIgnoreArgs } from "./types";
-import { checkCommit } from "./checkCommit";
-
-function ignoreBuild() {
- console.log("⏭ Ignoring the change");
- return process.exit(0);
-}
-
-function continueBuild() {
- console.log("✓ Proceeding with deployment");
- return process.exit(1);
-}
-
-export default function turboIgnore({ args }: { args: TurboIgnoreArgs }) {
- info(
- `Using Turborepo to determine if this project is affected by the commit...\n`
- );
-
- // set default directory
- args.directory = args.directory
- ? path.resolve(args.directory)
- : process.cwd();
-
- // check for TURBO_FORCE and bail early if it's set
- if (process.env.TURBO_FORCE === "true") {
- info("`TURBO_FORCE` detected");
- return continueBuild();
- }
-
- // find the monorepo root
- const root = getTurboRoot(args.directory);
- if (!root) {
- error("Monorepo root not found. turbo-ignore inferencing failed");
- return continueBuild();
- }
-
- // Find the workspace from the command-line args, or the package.json at the current directory
- const workspace = getWorkspace(args);
- if (!workspace) {
- return continueBuild();
- }
-
- // Identify which task to execute from the command-line args
- let task = getTask(args);
-
- // check the commit message
- const parsedCommit = checkCommit({ workspace });
- if (parsedCommit.result === "skip") {
- info(parsedCommit.reason);
- return ignoreBuild();
- }
- if (parsedCommit.result === "deploy") {
- info(parsedCommit.reason);
- return continueBuild();
- }
- if (parsedCommit.result === "conflict") {
- info(parsedCommit.reason);
- }
-
- // Get the start of the comparison (previous deployment when available, or previous commit by default)
- const comparison = getComparison({ workspace, fallback: args.fallback });
- if (!comparison) {
- // This is either the first deploy of the project, or the first deploy for the branch, either way - build it.
- return continueBuild();
- }
-
- // Build, and execute the command
- const command = `npx turbo run ${task} --filter=${workspace}...[${comparison.ref}] --dry=json`;
- info(`Analyzing results of \`${command}\``);
- exec(
- command,
- {
- cwd: root,
- },
- (err, stdout) => {
- if (err) {
- const { level, code, message } = shouldWarn({ err: err.message });
- if (level === "warn") {
- warn(message);
- } else {
- error(`${code}: ${err}`);
- }
- return continueBuild();
- }
-
- try {
- const parsed = JSON.parse(stdout);
- if (parsed == null) {
- error(`Failed to parse JSON output from \`${command}\`.`);
- return continueBuild();
- }
- const { packages } = parsed;
- if (packages && packages.length > 0) {
- if (packages.length === 1) {
- info(`This commit affects "${workspace}"`);
- } else {
- // subtract 1 because the first package is the workspace itself
- info(
- `This commit affects "${workspace}" and ${packages.length - 1} ${
- packages.length - 1 === 1 ? "dependency" : "dependencies"
- } (${packages.slice(1).join(", ")})`
- );
- }
-
- return continueBuild();
- } else {
- info(`This project and its dependencies are not affected`);
- return ignoreBuild();
- }
- } catch (e) {
- error(`Failed to parse JSON output from \`${command}\`.`);
- error(e);
- return continueBuild();
- }
- }
- );
-}
diff --git a/packages/turbo-ignore/src/index.ts b/packages/turbo-ignore/src/index.ts
deleted file mode 100644
index 0c34d3a..0000000
--- a/packages/turbo-ignore/src/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env node
-
-import turboIgnore from "./ignore";
-import parseArgs from "./args";
-
-turboIgnore({ args: parseArgs({ argv: process.argv.slice(2) }) });
diff --git a/packages/turbo-ignore/src/logger.ts b/packages/turbo-ignore/src/logger.ts
deleted file mode 100644
index a7903ac..0000000
--- a/packages/turbo-ignore/src/logger.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-// ≫
-const TURBO_IGNORE_PREFIX = "\u226B ";
-
-function info(...args: any[]) {
- console.log(TURBO_IGNORE_PREFIX, ...args);
-}
-
-function error(...args: any[]) {
- console.error(TURBO_IGNORE_PREFIX, ...args);
-}
-
-function warn(...args: any[]) {
- console.warn(TURBO_IGNORE_PREFIX, ...args);
-}
-
-export { info, warn, error };
diff --git a/packages/turbo-ignore/src/types.ts b/packages/turbo-ignore/src/types.ts
deleted file mode 100644
index 07fac3f..0000000
--- a/packages/turbo-ignore/src/types.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-export type NonFatalErrorKey =
- | "MISSING_LOCKFILE"
- | "NO_PACKAGE_MANAGER"
- | "UNREACHABLE_PARENT"
- | "UNREACHABLE_COMMIT";
-
-export interface NonFatalError {
- regex: RegExp;
- message: string;
-}
-
-export type NonFatalErrors = Record<NonFatalErrorKey, NonFatalError>;
-
-export interface TurboIgnoreArgs {
- // the working directory to use when looking for a workspace
- directory?: string;
- // the workspace to check for changes
- workspace?: string;
- // the task to run, if not build
- task?: string;
- // A ref/head to compare against if no previously deployed SHA is available
- fallback?: string;
-}
diff --git a/packages/turbo-ignore/tsconfig.json b/packages/turbo-ignore/tsconfig.json
deleted file mode 100644
index 0620a3c..0000000
--- a/packages/turbo-ignore/tsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "extends": "@turbo/tsconfig/library.json",
- "compilerOptions": {
- "rootDir": "."
- }
-}
diff --git a/packages/turbo-ignore/tsup.config.ts b/packages/turbo-ignore/tsup.config.ts
deleted file mode 100644
index 4d9d9bf..0000000
--- a/packages/turbo-ignore/tsup.config.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { defineConfig, Options } from "tsup";
-
-export default defineConfig((options: Options) => ({
- entry: ["src/index.ts"],
- format: ["cjs"],
- minify: true,
- clean: true,
- ...options,
-}));
diff --git a/packages/turbo-test-utils/README.md b/packages/turbo-test-utils/README.md
deleted file mode 100644
index 60b6382..0000000
--- a/packages/turbo-test-utils/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# `@turbo/test-utils`
-
-Internal package of generic testing utilities shared between [turborepo/packages/](https://github.com/vercel/turbo/tree/main/packages)
diff --git a/packages/turbo-test-utils/package.json b/packages/turbo-test-utils/package.json
deleted file mode 100644
index ff3f7f9..0000000
--- a/packages/turbo-test-utils/package.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "name": "@turbo/test-utils",
- "version": "0.0.0",
- "private": true,
- "description": "",
- "homepage": "https://turbo.build/repo",
- "keywords": [],
- "author": "Vercel",
- "main": "src/index.ts",
- "license": "MPL-2.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/turbo",
- "directory": "packages/turbo-test-utils"
- },
- "bugs": {
- "url": "https://github.com/vercel/turbo/issues"
- },
- "scripts": {
- "lint": "eslint src/**/*.ts",
- "check-types": "tsc --noEmit"
- },
- "devDependencies": {
- "@types/fs-extra": "^9.0.13",
- "@types/jest": "^27.4.0",
- "@types/js-yaml": "^4.0.5",
- "@types/node": "^16.11.12",
- "@types/uuid": "^9.0.0",
- "jest": "^27.4.3",
- "ts-jest": "^27.1.1",
- "@turbo/tsconfig": "workspace:*",
- "typescript": "^4.7.4"
- },
- "dependencies": {
- "fs-extra": "^11.1.0",
- "js-yaml": "^4.1.0",
- "json5": "^2.2.3",
- "uuid": "^9.0.0"
- }
-}
diff --git a/packages/turbo-test-utils/src/index.ts b/packages/turbo-test-utils/src/index.ts
deleted file mode 100644
index 07d0496..0000000
--- a/packages/turbo-test-utils/src/index.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export { default as setupTestFixtures } from "./useFixtures";
-export { default as validateLogs } from "./validateLogs";
-export { default as mockEnv } from "./mockEnv";
-
-export { default as spyExit } from "./spyExit";
-export type { SpyExit } from "./spyExit";
-
-export { default as spyConsole } from "./spyConsole";
-export type { SpyConsole } from "./spyConsole";
diff --git a/packages/turbo-test-utils/src/mockEnv.ts b/packages/turbo-test-utils/src/mockEnv.ts
deleted file mode 100644
index 31909b0..0000000
--- a/packages/turbo-test-utils/src/mockEnv.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export default function mockEnv() {
- const OLD_ENV = process.env;
-
- beforeEach(() => {
- jest.resetModules();
- process.env = { ...OLD_ENV };
- });
-
- afterAll(() => {
- process.env = OLD_ENV;
- });
-}
diff --git a/packages/turbo-test-utils/src/spyConsole.ts b/packages/turbo-test-utils/src/spyConsole.ts
deleted file mode 100644
index 61722a5..0000000
--- a/packages/turbo-test-utils/src/spyConsole.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-export type SpyConsole = { log?: any; error?: any; warn?: any };
-
-export default function spyConsole() {
- let spy: SpyConsole = {};
-
- beforeEach(() => {
- spy.log = jest.spyOn(console, "log").mockImplementation(() => {});
- spy.error = jest.spyOn(console, "error").mockImplementation(() => {});
- spy.warn = jest.spyOn(console, "warn").mockImplementation(() => {});
- });
-
- afterEach(() => {
- spy.log.mockClear();
- spy.error.mockClear();
- spy.warn.mockClear();
- });
-
- afterAll(() => {
- spy.log.mockRestore();
- spy.error.mockRestore();
- spy.warn.mockRestore();
- });
-
- return spy;
-}
diff --git a/packages/turbo-test-utils/src/spyExit.ts b/packages/turbo-test-utils/src/spyExit.ts
deleted file mode 100644
index 1df9844..0000000
--- a/packages/turbo-test-utils/src/spyExit.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-export type SpyExit = { exit?: any };
-
-export default function spyExit() {
- let spy: SpyExit = {};
-
- beforeEach(() => {
- spy.exit = jest
- .spyOn(process, "exit")
- .mockImplementation(() => undefined as never);
- });
-
- afterEach(() => {
- spy.exit.mockClear();
- });
-
- afterAll(() => {
- spy.exit.mockRestore();
- });
-
- return spy;
-}
diff --git a/packages/turbo-test-utils/src/useFixtures.ts b/packages/turbo-test-utils/src/useFixtures.ts
deleted file mode 100644
index 2c47f5a..0000000
--- a/packages/turbo-test-utils/src/useFixtures.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-import { v4 as uuidv4 } from "uuid";
-import path from "path";
-import fs from "fs-extra";
-import yaml from "js-yaml";
-import JSON5 from "json5";
-
-export default function setupTestFixtures({
- directory,
- test = "",
-}: {
- directory: string;
- test?: string;
-}) {
- const fixtures: Array<string> = [];
- const parentDirectory = path.join(directory, test ? test : "test-runs");
-
- afterEach(() => {
- fixtures.forEach((fixture) => {
- fs.rmSync(fixture, { recursive: true, force: true });
- });
- });
-
- afterAll(() => {
- fs.rmSync(parentDirectory, { recursive: true, force: true });
- });
-
- const useFixture = ({ fixture }: { fixture: string }) => {
- const directoryName = uuidv4();
- const testDirectory = path.join(parentDirectory, directoryName);
- if (!fs.existsSync(testDirectory)) {
- fs.mkdirSync(testDirectory, { recursive: true });
- }
- // keep track of it
- fixtures.push(testDirectory);
-
- // copy fixture to test directory
- const fixturePath = path.join(directory, "__fixtures__", test, fixture);
- fs.copySync(fixturePath, testDirectory, {
- recursive: true,
- });
-
- const getFilePath = (filename: string) => {
- return path.isAbsolute(filename)
- ? filename
- : path.join(testDirectory, filename);
- };
-
- const readGenerator = (method: (filePath: string) => unknown) => {
- return <T>(filename: string) => {
- try {
- return method(getFilePath(filename)) as T;
- } catch (e) {
- return undefined;
- }
- };
- };
-
- const write = (
- filename: string,
- content: string | NodeJS.ArrayBufferView
- ) => {
- fs.writeFileSync(getFilePath(filename), content);
- };
-
- const exists = (filename: string): boolean => {
- return fs.existsSync(getFilePath(filename));
- };
-
- const read = readGenerator((filePath) => fs.readFileSync(filePath, "utf8"));
- const readJson = readGenerator((filePath) =>
- JSON5.parse(fs.readFileSync(filePath, "utf8"))
- );
- const readYaml = readGenerator((filePath) =>
- yaml.load(fs.readFileSync(filePath, "utf8"))
- );
-
- return {
- root: testDirectory,
- read,
- readJson,
- readYaml,
- write,
- exists,
- directoryName,
- };
- };
-
- return { useFixture };
-}
diff --git a/packages/turbo-test-utils/src/validateLogs.ts b/packages/turbo-test-utils/src/validateLogs.ts
deleted file mode 100644
index b8e59ac..0000000
--- a/packages/turbo-test-utils/src/validateLogs.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { SpyConsole } from "./spyConsole";
-
-export default function validateLogs(
- logs: Array<string | (() => boolean | Array<any>)>,
- mockConsole: SpyConsole["log"] | SpyConsole["error"],
- options: { prefix?: string } = {}
-) {
- logs.forEach((log, idx) => {
- if (typeof log === "function") {
- const expected = log();
- expect(mockConsole).toHaveBeenNthCalledWith(
- idx + 1,
- ...(Array.isArray(expected) ? expected : [expected])
- );
- } else {
- if (options.prefix) {
- expect(mockConsole).toHaveBeenNthCalledWith(
- idx + 1,
- options.prefix,
- log
- );
- } else {
- expect(mockConsole).toHaveBeenNthCalledWith(idx + 1, log);
- }
- }
- });
-}
diff --git a/packages/turbo-test-utils/tsconfig.json b/packages/turbo-test-utils/tsconfig.json
deleted file mode 100644
index 0620a3c..0000000
--- a/packages/turbo-test-utils/tsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "extends": "@turbo/tsconfig/library.json",
- "compilerOptions": {
- "rootDir": "."
- }
-}
diff --git a/packages/turbo-tracing-next-plugin/README.md b/packages/turbo-tracing-next-plugin/README.md
deleted file mode 100644
index dbd2609..0000000
--- a/packages/turbo-tracing-next-plugin/README.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# `@vercel/experimental-nft-next-plugin`
-
-## Installation
-
-- yarn add -D `@vercel/experimental-nft-next-plugin`
-- npm install -D `@vercel/experimental-nft-next-plugin`
-- pnpm install -D `@vercel/experimental-nft-next-plugin`
-
-## Usage
-
-```js
-// next.config.js
-
-const { createNodeFileTrace } = require("@vercel/experimental-nft-next-plugin");
-
-const withNodeFileTrace = createNodeFileTrace({
- // experimental nft options
- log: {
- all: true,
- },
-});
-
-module.exports = withNodeFileTrace({
- // next config
-});
-```
-
-### experimental nft options
-
-> **Note**
->
-> The default options should work fine.
-
-- `cwd?: string`, default is `process.cwd()`, you can override it to specify another directory to run experimental nft.
-- `contextDirectory?: string`, relative to cwd, default is `.`. It must be the directory where the `node_modules` directory is located. If you are in the monorepo, you should set it to the root directory of the monorepo. For yarn2+/npm workspaces, the default value will respect the `PROJECT_CWD` and `npm_config_local_prefix` environment variables injected by yarn/npm client. If the default value doesn't work, you can override it to specify the root directory of the monorepo.
-- `path?: string`, additional path which will be appended into the `PATH` environment variable.
-- `log?.all?: boolean`, default is `false`, whether to show all logs.
-- `log?.level?: string`, default is `error`, the log level.
-- `log?.detail?: boolean`, default is `false`, whether to expand the log details.
diff --git a/packages/turbo-tracing-next-plugin/package.json b/packages/turbo-tracing-next-plugin/package.json
deleted file mode 100644
index e2f0662..0000000
--- a/packages/turbo-tracing-next-plugin/package.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "name": "@vercel/experimental-nft-next-plugin",
- "version": "0.0.3-alpha.2",
- "license": "MPL-2.0",
- "main": "dist/index.js",
- "types": "dist/index.d.ts",
- "files": [
- "dist/**/*"
- ],
- "publishConfig": {
- "access": "public"
- },
- "dependencies": {
- "@vercel/webpack-nft": "workspace:*"
- },
- "peerDependencies": {
- "next": ">= 12"
- },
- "devDependencies": {
- "next": "^13.0.6"
- },
- "scripts": {
- "lint": "eslint src/**/*.ts"
- }
-}
diff --git a/packages/turbo-tracing-next-plugin/src/index.ts b/packages/turbo-tracing-next-plugin/src/index.ts
deleted file mode 100644
index 0b75113..0000000
--- a/packages/turbo-tracing-next-plugin/src/index.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import {
- NodeModuleTracePlugin,
- NodeModuleTracePluginOptions,
-} from "@vercel/webpack-nft";
-import type { NextConfig } from "next";
-
-export function createNodeFileTrace(options?: NodeModuleTracePluginOptions) {
- return function withNodeFileTrace(config: NextConfig = {}) {
- const createWebpackConfig = config.webpack;
- config.outputFileTracing = false;
- config.webpack = (webpackConfig, context) => {
- const config =
- createWebpackConfig?.(webpackConfig, context) ?? webpackConfig;
- if (context.isServer && !context.dev) {
- const plugin = new NodeModuleTracePlugin(options);
- if (config.plugins) {
- config.plugins.push(plugin);
- } else {
- config.plugins = [plugin];
- }
- }
-
- return config;
- };
- return config;
- };
-}
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/.env.local.example b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/.env.local.example
deleted file mode 100644
index 9dead41..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/.env.local.example
+++ /dev/null
@@ -1 +0,0 @@
-MONGODB_URI= \ No newline at end of file
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/.gitignore b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/.gitignore
deleted file mode 100644
index 1437c53..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/.gitignore
+++ /dev/null
@@ -1,34 +0,0 @@
-# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
-
-# dependencies
-/node_modules
-/.pnp
-.pnp.js
-
-# testing
-/coverage
-
-# next.js
-/.next/
-/out/
-
-# production
-/build
-
-# misc
-.DS_Store
-*.pem
-
-# debug
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-
-# local env files
-.env.local
-.env.development.local
-.env.test.local
-.env.production.local
-
-# vercel
-.vercel
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/README.md b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/README.md
deleted file mode 100644
index 1f7110e..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# MongoDB and Mongoose with Next.js
-
-Copied from https://github.com/vercel/next.js/tree/canary/examples/with-mongodb.
-
-Run `pnpm run --filter @vercel/turbo-tracing-test-app build` to build this application.
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/components/Form.js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/components/Form.js
deleted file mode 100644
index b184d9c..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/components/Form.js
+++ /dev/null
@@ -1,202 +0,0 @@
-import { useState } from "react";
-import { useRouter } from "next/router";
-import { mutate } from "swr";
-
-const Form = ({ formId, petForm, forNewPet = true }) => {
- const router = useRouter();
- const contentType = "application/json";
- const [errors, setErrors] = useState({});
- const [message, setMessage] = useState("");
-
- const [form, setForm] = useState({
- name: petForm.name,
- owner_name: petForm.owner_name,
- species: petForm.species,
- age: petForm.age,
- poddy_trained: petForm.poddy_trained,
- diet: petForm.diet,
- image_url: petForm.image_url,
- likes: petForm.likes,
- dislikes: petForm.dislikes,
- });
-
- /* The PUT method edits an existing entry in the mongodb database. */
- const putData = async (form) => {
- const { id } = router.query;
-
- try {
- const res = await fetch(`/api/pets/${id}`, {
- method: "PUT",
- headers: {
- Accept: contentType,
- "Content-Type": contentType,
- },
- body: JSON.stringify(form),
- });
-
- // Throw error with status code in case Fetch API req failed
- if (!res.ok) {
- throw new Error(res.status);
- }
-
- const { data } = await res.json();
-
- mutate(`/api/pets/${id}`, data, false); // Update the local data without a revalidation
- router.push("/");
- } catch (error) {
- setMessage("Failed to update pet");
- }
- };
-
- /* The POST method adds a new entry in the mongodb database. */
- const postData = async (form) => {
- try {
- const res = await fetch("/api/pets", {
- method: "POST",
- headers: {
- Accept: contentType,
- "Content-Type": contentType,
- },
- body: JSON.stringify(form),
- });
-
- // Throw error with status code in case Fetch API req failed
- if (!res.ok) {
- throw new Error(res.status);
- }
-
- router.push("/");
- } catch (error) {
- setMessage("Failed to add pet");
- }
- };
-
- const handleChange = (e) => {
- const target = e.target;
- const value =
- target.name === "poddy_trained" ? target.checked : target.value;
- const name = target.name;
-
- setForm({
- ...form,
- [name]: value,
- });
- };
-
- const handleSubmit = (e) => {
- e.preventDefault();
- const errs = formValidate();
- if (Object.keys(errs).length === 0) {
- forNewPet ? postData(form) : putData(form);
- } else {
- setErrors({ errs });
- }
- };
-
- /* Makes sure pet info is filled for pet name, owner name, species, and image url*/
- const formValidate = () => {
- let err = {};
- if (!form.name) err.name = "Name is required";
- if (!form.owner_name) err.owner_name = "Owner is required";
- if (!form.species) err.species = "Species is required";
- if (!form.image_url) err.image_url = "Image URL is required";
- return err;
- };
-
- return (
- <>
- <form id={formId} onSubmit={handleSubmit}>
- <label htmlFor="name">Name</label>
- <input
- type="text"
- maxLength="20"
- name="name"
- value={form.name}
- onChange={handleChange}
- required
- />
-
- <label htmlFor="owner_name">Owner</label>
- <input
- type="text"
- maxLength="20"
- name="owner_name"
- value={form.owner_name}
- onChange={handleChange}
- required
- />
-
- <label htmlFor="species">Species</label>
- <input
- type="text"
- maxLength="30"
- name="species"
- value={form.species}
- onChange={handleChange}
- required
- />
-
- <label htmlFor="age">Age</label>
- <input
- type="number"
- name="age"
- value={form.age}
- onChange={handleChange}
- />
-
- <label htmlFor="poddy_trained">Potty Trained</label>
- <input
- type="checkbox"
- name="poddy_trained"
- checked={form.poddy_trained}
- onChange={handleChange}
- />
-
- <label htmlFor="diet">Diet</label>
- <textarea
- name="diet"
- maxLength="60"
- value={form.diet}
- onChange={handleChange}
- />
-
- <label htmlFor="image_url">Image URL</label>
- <input
- type="url"
- name="image_url"
- value={form.image_url}
- onChange={handleChange}
- required
- />
-
- <label htmlFor="likes">Likes</label>
- <textarea
- name="likes"
- maxLength="60"
- value={form.likes}
- onChange={handleChange}
- />
-
- <label htmlFor="dislikes">Dislikes</label>
- <textarea
- name="dislikes"
- maxLength="60"
- value={form.dislikes}
- onChange={handleChange}
- />
-
- <button type="submit" className="btn">
- Submit
- </button>
- </form>
- <p>{message}</p>
- <div>
- {Object.keys(errors).map((err, index) => (
- <li key={index}>{err}</li>
- ))}
- </div>
- </>
- );
-};
-
-export default Form;
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/css/form.css b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/css/form.css
deleted file mode 100644
index 4681e68..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/css/form.css
+++ /dev/null
@@ -1,39 +0,0 @@
-form {
- width: 90%;
- margin: auto;
- max-width: 550px;
-}
-input,
-form button,
-label {
- display: block;
-}
-form button,
-input,
-textarea {
- outline: none;
-}
-input,
-textarea {
- border: 1px solid rgb(199, 199, 199);
- border-radius: 10px;
- padding: 10px;
- font-size: 90%;
- width: 100%;
- height: 30px;
- color: rgb(53, 53, 53);
-}
-textarea {
- height: 50px;
-}
-label {
- margin-top: 10px;
-}
-form button {
- --accent: rgb(0, 162, 255);
- margin-top: 20px;
-}
-
-.form-container {
- width: 90%;
-}
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/css/style.css b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/css/style.css
deleted file mode 100644
index cb90218..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/css/style.css
+++ /dev/null
@@ -1,184 +0,0 @@
-@import url("https://fonts.googleapis.com/css?family=Open+Sans&display=swap");
-
-* {
- font-family: "Open Sans", sans-serif;
- box-sizing: border-box;
-}
-
-/* Nav Area */
-.top-bar {
- width: 100%;
- margin-top: 0;
- position: relative;
- height: 80px;
- text-align: right;
-}
-#title {
- position: absolute;
- left: 20px;
- top: 0;
- display: inline-block;
- height: 100%;
-}
-.nav {
- height: 100%;
- display: inline-block;
-}
-.nav a {
- margin: 0 20px;
- font-size: 120%;
- height: 100%;
- display: inline-flex;
- justify-content: center;
- align-items: center;
-}
-
-.grid {
- display: flex;
- flex-wrap: wrap;
- justify-content: center;
-}
-
-/* Styles for Cards */
-.card {
- display: inline-block;
- width: 300px;
- height: 400px;
- overflow: hidden;
- border: 1.25px solid rgb(233, 233, 233);
- border-radius: 16px;
- margin: 10px;
- transition: 0.5s all;
- --shadow: transparent;
- box-shadow: 0 0 10px 5px var(--shadow);
- position: relative;
- font-size: 100%;
-}
-
-.card:hover {
- --shadow: rgba(53, 53, 53, 0.103);
- /* transform: rotateY(180deg) translate(20px, 20px);
- background: pink; */
-}
-
-.card:hover .main-content {
- pointer-events: initial;
- opacity: 1;
-}
-
-.card * {
- margin: 0;
-}
-
-.card img {
- width: 100%;
- height: 100%;
- object-fit: cover;
-}
-
-.main-content {
- padding: 25px;
- position: absolute;
- top: 0;
- left: 0;
- background-color: rgba(255, 255, 255, 0.9);
- width: 100%;
- height: 100%;
- opacity: 0;
- pointer-events: none;
- transition: 0.5s all;
-}
-
-.owner {
- color: grey;
- font-size: 110%;
-}
-
-.pet-name {
- font-weight: bold;
- font-size: 130%;
-}
-
-h5.pet-name {
- color: white;
- position: absolute;
- left: 0;
- bottom: 0;
- padding: 10px;
- text-shadow: 0px 0px 4px black;
-}
-
-.info ul {
- padding: 10px;
- padding-top: 0px;
- border-radius: 7px;
-}
-
-li {
- list-style-type: none;
- margin: 0;
-}
-
-.info {
- color: rgb(83, 83, 83);
- position: relative;
- overflow: hidden;
-}
-
-.info.likes {
- margin-top: 25px;
-}
-
-.label {
- font-weight: bold;
-}
-
-.btn-container {
- text-align: right;
- padding: 10px;
- position: absolute;
- bottom: 10px;
- right: 10px;
-}
-
-.btn {
- --accent: grey;
- cursor: pointer;
- background: transparent;
- border: 1.5px solid var(--accent);
- color: var(--accent);
- border-radius: 10px;
- padding: 10px 15px;
- font-size: 90%;
- letter-spacing: 1px;
- transition: 0.5s all;
- outline: none;
-}
-
-.btn:hover {
- background: var(--accent);
- color: white;
-}
-
-.edit.btn {
- --accent: green;
-}
-
-.delete.btn {
- --accent: red;
- margin-left: 10px;
-}
-
-.view.btn {
- --accent: blue;
- margin-left: 10px;
-}
-
-/* Delete Pet */
-.pet-container {
- width: 100%;
-}
-
-.confirmation-box.show {
- display: block;
-}
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/lib/dbConnect.js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/lib/dbConnect.js
deleted file mode 100644
index 6b723b4..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/lib/dbConnect.js
+++ /dev/null
@@ -1,40 +0,0 @@
-import mongoose from "mongoose";
-
-const MONGODB_URI = process.env.MONGODB_URI;
-
-if (!MONGODB_URI) {
- throw new Error(
- "Please define the MONGODB_URI environment variable inside .env.local"
- );
-}
-
-/**
- * Global is used here to maintain a cached connection across hot reloads
- * in development. This prevents connections growing exponentially
- * during API Route usage.
- */
-let cached = global.mongoose;
-
-if (!cached) {
- cached = global.mongoose = { conn: null, promise: null };
-}
-
-async function dbConnect() {
- if (cached.conn) {
- return cached.conn;
- }
-
- if (!cached.promise) {
- const opts = {
- bufferCommands: false,
- };
-
- cached.promise = mongoose.connect(MONGODB_URI, opts).then((mongoose) => {
- return mongoose;
- });
- }
- cached.conn = await cached.promise;
- return cached.conn;
-}
-
-export default dbConnect;
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/models/Pet.js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/models/Pet.js
deleted file mode 100644
index ccde695..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/models/Pet.js
+++ /dev/null
@@ -1,59 +0,0 @@
-import mongoose from "mongoose";
-
-/* PetSchema will correspond to a collection in your MongoDB database. */
-const PetSchema = new mongoose.Schema({
- name: {
- /* The name of this pet */
-
- type: String,
- required: [true, "Please provide a name for this pet."],
- maxlength: [60, "Name cannot be more than 60 characters"],
- },
- owner_name: {
- /* The owner of this pet */
-
- type: String,
- required: [true, "Please provide the pet owner's name"],
- maxlength: [60, "Owner's Name cannot be more than 60 characters"],
- },
- species: {
- /* The species of your pet */
-
- type: String,
- required: [true, "Please specify the species of your pet."],
- maxlength: [40, "Species specified cannot be more than 40 characters"],
- },
- age: {
- /* Pet's age, if applicable */
-
- type: Number,
- },
- poddy_trained: {
- /* Boolean poddy_trained value, if applicable */
-
- type: Boolean,
- },
- diet: {
- /* List of dietary needs, if applicable */
-
- type: Array,
- },
- image_url: {
- /* Url to pet image */
-
- required: [true, "Please provide an image url for this pet."],
- type: String,
- },
- likes: {
- /* List of things your pet likes to do */
-
- type: Array,
- },
- dislikes: {
- /* List of things your pet does not like to do */
-
- type: Array,
- },
-});
-
-export default mongoose.models.Pet || mongoose.model("Pet", PetSchema);
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/next.config.js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/next.config.js
deleted file mode 100644
index 3e1a8fb..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/next.config.js
+++ /dev/null
@@ -1,12 +0,0 @@
-const { join } = require("path");
-
-const { createNodeFileTrace } = require("../..");
-
-module.exports = createNodeFileTrace({
- path: join(__dirname, "..", "..", "..", "..", "target", "debug"),
-})({
- reactStrictMode: true,
- eslint: {
- ignoreDuringBuilds: true,
- },
-});
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/package.json b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/package.json
deleted file mode 100644
index 9d877cb..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/package.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "@vercel/turbo-tracing-test-app",
- "private": true,
- "scripts": {
- "dev": "next dev",
- "build": "cross-env MONGODB_URI=localhost:27017 next build",
- "start": "next start"
- },
- "dependencies": {
- "mongoose": "^6.11.3",
- "next": "latest",
- "react": "^18.2.0",
- "react-dom": "^18.2.0",
- "swr": "^1.3.0"
- },
- "devDependencies": {
- "@vercel/experimental-nft-next-plugin": "workspace:*",
- "cross-env": "^7.0.3"
- }
-}
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/[id]/edit.js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/[id]/edit.js
deleted file mode 100644
index 85a1cf9..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/[id]/edit.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import { useRouter } from "next/router";
-import useSWR from "swr";
-import Form from "../../components/Form";
-
-const fetcher = (url) =>
- fetch(url)
- .then((res) => res.json())
- .then((json) => json.data);
-
-const EditPet = () => {
- const router = useRouter();
- const { id } = router.query;
- const { data: pet, error } = useSWR(id ? `/api/pets/${id}` : null, fetcher);
-
- if (error) return <p>Failed to load</p>;
- if (!pet) return <p>Loading...</p>;
-
- const petForm = {
- name: pet.name,
- owner_name: pet.owner_name,
- species: pet.species,
- age: pet.age,
- poddy_trained: pet.poddy_trained,
- diet: pet.diet,
- image_url: pet.image_url,
- likes: pet.likes,
- dislikes: pet.dislikes,
- };
-
- return <Form formId="edit-pet-form" petForm={petForm} forNewPet={false} />;
-};
-
-export default EditPet;
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/[id]/index.js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/[id]/index.js
deleted file mode 100644
index 13b3a2b..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/[id]/index.js
+++ /dev/null
@@ -1,75 +0,0 @@
-import { useState } from "react";
-import { useRouter } from "next/router";
-import Link from "next/link";
-import dbConnect from "../../lib/dbConnect";
-import Pet from "../../models/Pet";
-
-/* Allows you to view pet card info and delete pet card*/
-const PetPage = ({ pet }) => {
- const router = useRouter();
- const [message, setMessage] = useState("");
- const handleDelete = async () => {
- const petID = router.query.id;
-
- try {
- await fetch(`/api/pets/${petID}`, {
- method: "Delete",
- });
- router.push("/");
- } catch (error) {
- setMessage("Failed to delete the pet.");
- }
- };
-
- return (
- <div key={pet._id}>
- <div className="card">
- <img src={pet.image_url} />
- <h5 className="pet-name">{pet.name}</h5>
- <div className="main-content">
- <p className="pet-name">{pet.name}</p>
- <p className="owner">Owner: {pet.owner_name}</p>
-
- {/* Extra Pet Info: Likes and Dislikes */}
- <div className="likes info">
- <p className="label">Likes</p>
- <ul>
- {pet.likes.map((data, index) => (
- <li key={index}>{data} </li>
- ))}
- </ul>
- </div>
- <div className="dislikes info">
- <p className="label">Dislikes</p>
- <ul>
- {pet.dislikes.map((data, index) => (
- <li key={index}>{data} </li>
- ))}
- </ul>
- </div>
-
- <div className="btn-container">
- <Link href="/[id]/edit" as={`/${pet._id}/edit`}>
- <button className="btn edit">Edit</button>
- </Link>
- <button className="btn delete" onClick={handleDelete}>
- Delete
- </button>
- </div>
- </div>
- </div>
- {message && <p>{message}</p>}
- </div>
- );
-};
-
-export async function getServerSideProps({ params }) {
- await dbConnect();
-
- const pet = await Pet.findById(params.id).lean();
- pet._id = pet._id.toString();
-
- return { props: { pet } };
-}
-
-export default PetPage;
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/_app.js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/_app.js
deleted file mode 100644
index 034d020..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/_app.js
+++ /dev/null
@@ -1,36 +0,0 @@
-import "../css/style.css";
-import "../css/form.css";
-import Head from "next/head";
-import Link from "next/link";
-
-function MyApp({ Component, pageProps }) {
- return (
- <>
- <Head>
- <title>Pet Care App</title>
- </Head>
-
- <div className="top-bar">
- <div className="nav">
- <Link href="/">
- <a>Home</a>
- </Link>
- <Link href="/new">
- <a>Add Pet</a>
- </Link>
- </div>
-
- <img
- id="title"
- src="https://upload.wikimedia.org/wikipedia/commons/1/1f/Pet_logo_with_flowers.png"
- alt="pet care logo"
- ></img>
- </div>
- <div className="grid wrapper">
- <Component {...pageProps} />
- </div>
- </>
- );
-}
-
-export default MyApp;
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/api/pets/[id].js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/api/pets/[id].js
deleted file mode 100644
index 1f180dd..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/api/pets/[id].js
+++ /dev/null
@@ -1,56 +0,0 @@
-import dbConnect from "../../../lib/dbConnect";
-import Pet from "../../../models/Pet";
-
-export default async function handler(req, res) {
- const {
- query: { id },
- method,
- } = req;
-
- await dbConnect();
-
- switch (method) {
- case "GET" /* Get a model by its ID */:
- try {
- const pet = await Pet.findById(id);
- if (!pet) {
- return res.status(400).json({ success: false });
- }
- res.status(200).json({ success: true, data: pet });
- } catch (error) {
- res.status(400).json({ success: false });
- }
- break;
-
- case "PUT" /* Edit a model by its ID */:
- try {
- const pet = await Pet.findByIdAndUpdate(id, req.body, {
- new: true,
- runValidators: true,
- });
- if (!pet) {
- return res.status(400).json({ success: false });
- }
- res.status(200).json({ success: true, data: pet });
- } catch (error) {
- res.status(400).json({ success: false });
- }
- break;
-
- case "DELETE" /* Delete a model by its ID */:
- try {
- const deletedPet = await Pet.deleteOne({ _id: id });
- if (!deletedPet) {
- return res.status(400).json({ success: false });
- }
- res.status(200).json({ success: true, data: {} });
- } catch (error) {
- res.status(400).json({ success: false });
- }
- break;
-
- default:
- res.status(400).json({ success: false });
- break;
- }
-}
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/api/pets/index.js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/api/pets/index.js
deleted file mode 100644
index 20b7cf0..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/api/pets/index.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import dbConnect from "../../../lib/dbConnect";
-import Pet from "../../../models/Pet";
-
-export default async function handler(req, res) {
- const { method } = req;
-
- await dbConnect();
-
- switch (method) {
- case "GET":
- try {
- const pets = await Pet.find({}); /* find all the data in our database */
- res.status(200).json({ success: true, data: pets });
- } catch (error) {
- res.status(400).json({ success: false });
- }
- break;
- case "POST":
- try {
- const pet = await Pet.create(
- req.body
- ); /* create a new model in the database */
- res.status(201).json({ success: true, data: pet });
- } catch (error) {
- res.status(400).json({ success: false });
- }
- break;
- default:
- res.status(400).json({ success: false });
- break;
- }
-}
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/index.js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/index.js
deleted file mode 100644
index 0f8d748..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/index.js
+++ /dev/null
@@ -1,65 +0,0 @@
-import Link from "next/link";
-import dbConnect from "../lib/dbConnect";
-import Pet from "../models/Pet";
-
-const Index = ({ pets }) => (
- <>
- {/* Create a card for each pet */}
- {pets.map((pet) => (
- <div key={pet._id}>
- <div className="card">
- <img src={pet.image_url} />
- <h5 className="pet-name">{pet.name}</h5>
- <div className="main-content">
- <p className="pet-name">{pet.name}</p>
- <p className="owner">Owner: {pet.owner_name}</p>
-
- {/* Extra Pet Info: Likes and Dislikes */}
- <div className="likes info">
- <p className="label">Likes</p>
- <ul>
- {pet.likes.map((data, index) => (
- <li key={index}>{data} </li>
- ))}
- </ul>
- </div>
- <div className="dislikes info">
- <p className="label">Dislikes</p>
- <ul>
- {pet.dislikes.map((data, index) => (
- <li key={index}>{data} </li>
- ))}
- </ul>
- </div>
-
- <div className="btn-container">
- <Link href="/[id]/edit" as={`/${pet._id}/edit`}>
- <button className="btn edit">Edit</button>
- </Link>
- <Link href="/[id]" as={`/${pet._id}`}>
- <button className="btn view">View</button>
- </Link>
- </div>
- </div>
- </div>
- </div>
- ))}
- </>
-);
-
-/* Retrieves pet(s) data from mongodb database */
-export async function getServerSideProps() {
- await dbConnect();
-
- /* find all the data in our database */
- const result = await Pet.find({});
- const pets = result.map((doc) => {
- const pet = doc.toObject();
- pet._id = pet._id.toString();
- return pet;
- });
-
- return { props: { pets: pets } };
-}
-
-export default Index;
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/new.js b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/new.js
deleted file mode 100644
index 6d8cc30..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/pages/new.js
+++ /dev/null
@@ -1,19 +0,0 @@
-import Form from "../components/Form";
-
-const NewPet = () => {
- const petForm = {
- name: "",
- owner_name: "",
- species: "",
- age: 0,
- poddy_trained: false,
- diet: [],
- image_url: "",
- likes: [],
- dislikes: [],
- };
-
- return <Form formId="add-pet-form" petForm={petForm} />;
-};
-
-export default NewPet;
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/public/favicon.ico b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/public/favicon.ico
deleted file mode 100644
index 4965832..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/public/favicon.ico
+++ /dev/null
Binary files differ
diff --git a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/public/zeit.svg b/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/public/zeit.svg
deleted file mode 100644
index dd3916c..0000000
--- a/packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose/public/zeit.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-<svg width="82" height="16" fill="none" xmlns="http://www.w3.org/2000/svg">
- <path fill="url(#prefix__paint0_linear)" d="M9.018 0l9.019 16H0L9.018 0z"/>
- <path fill="#333" fill-rule="evenodd" d="M51.634 12.028h-6.492V2.052h6.492v1.256H46.61v3.007h4.37V7.57h-4.37v3.202h5.024v1.255zm-14.063 0h-7.235v-1.096l5.342-7.624h-5.253V2.052h7.058v1.097l-5.342 7.623h5.43v1.256zm21.88 0h6.333v-1.256h-2.423V3.308h2.423V2.052h-6.332v1.256h2.441v7.465h-2.441v1.255zm18.22 0h-1.468v-8.72h-3.36V2.052h8.225v1.256H77.67v8.72z" clip-rule="evenodd"/>
- <defs>
- <linearGradient id="prefix__paint0_linear" x1="28.022" x2="16.189" y1="22.991" y2="8.569" gradientUnits="userSpaceOnUse">
- <stop stop-color="#fff"/>
- <stop offset="1"/>
- </linearGradient>
- </defs>
-</svg>
diff --git a/packages/turbo-tracing-next-plugin/tsconfig.json b/packages/turbo-tracing-next-plugin/tsconfig.json
deleted file mode 100644
index 18316ac..0000000
--- a/packages/turbo-tracing-next-plugin/tsconfig.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "compilerOptions": {
- "composite": true,
- "outDir": "./dist",
- "rootDir": "./src"
- },
- "include": ["src"],
- "references": [
- {
- "path": "../webpack-nmt"
- }
- ]
-}
diff --git a/packages/turbo-types/package.json b/packages/turbo-types/package.json
deleted file mode 100644
index 326cdbe..0000000
--- a/packages/turbo-types/package.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "@turbo/types",
- "main": "src/index.ts",
- "types": "src/index.ts",
- "version": "0.0.0",
- "bin": {
- "turbo-types-generate": "./src/scripts/codegen.js"
- },
- "private": true,
- "dependencies": {
- "ts-json-schema-generator": "1.1.2"
- },
- "scripts": {
- "lint": "eslint src/**/*.ts"
- },
- "devDependencies": {
- "@turbo/tsconfig": "workspace:^0.0.0"
- }
-}
diff --git a/packages/turbo-types/src/index.ts b/packages/turbo-types/src/index.ts
deleted file mode 100644
index 1ade029..0000000
--- a/packages/turbo-types/src/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export type { Schema, Pipeline, RemoteCache } from "./types/config";
diff --git a/packages/turbo-types/src/scripts/codegen.js b/packages/turbo-types/src/scripts/codegen.js
deleted file mode 100644
index cbf0528..0000000
--- a/packages/turbo-types/src/scripts/codegen.js
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env node
-
-const tsj = require("ts-json-schema-generator");
-const fs = require("fs");
-const path = require("path");
-
-/** @type {import('ts-json-schema-generator/dist/src/Config').Config} */
-const config = {
- path: path.join(__dirname, "../index.ts"),
- tsconfig: path.join(__dirname, "../../tsconfig.json"),
- type: "Schema",
- minify: true,
-};
-
-const outputPath = process.argv[2];
-if (!outputPath) {
- throw new Error("Missing output path");
-}
-const schema = tsj.createGenerator(config).createSchema(config.type);
-fs.writeFile(outputPath, JSON.stringify(schema), (err) => {
- if (err) throw err;
-});
diff --git a/packages/turbo-types/src/types/config.ts b/packages/turbo-types/src/types/config.ts
deleted file mode 100644
index 1a3b3cc..0000000
--- a/packages/turbo-types/src/types/config.ts
+++ /dev/null
@@ -1,231 +0,0 @@
-/* This file generates the `schema.json` file. */
-export type Schema = RootSchema | WorkspaceSchema;
-
-export interface BaseSchema {
- /** @default https://turbo.build/schema.json */
- $schema?: string;
- /**
- * An object representing the task dependency graph of your project. turbo interprets
- * these conventions to schedule, execute, and cache the outputs of tasks in
- * your project.
- *
- * Documentation: https://turbo.build/repo/docs/reference/configuration#pipeline
- *
- * @default {}
- */
- pipeline: {
- /**
- * The name of a task that can be executed by turbo. If turbo finds a workspace
- * package with a package.json scripts object with a matching key, it will apply the
- * pipeline task configuration to that npm script during execution.
- */
- [script: string]: Pipeline;
- };
-}
-
-export interface WorkspaceSchema extends BaseSchema {
- /**
- * This key is only available in Workspace Configs
- * and cannot be used in your root turbo.json.
- *
- * Tells turbo to extend your root `turbo.json`
- * and overrides with the keys provided
- * in your Workspace Configs.
- *
- * Currently, only the "//" value is allowed.
- *
- * @default ["//"]
- */
- extends: string[];
-}
-
-export interface RootSchema extends BaseSchema {
- /**
- * A list of globs to include in the set of implicit global hash dependencies.
- *
- * The contents of these files will be included in the global hashing
- * algorithm and affect the hashes of all tasks.
- *
- * This is useful for busting the cache based on:
- *
- * - .env files (not in Git)
- *
- * - any root level file that impacts package tasks
- * that are not represented in the traditional dependency graph
- * (e.g. a root tsconfig.json, jest.config.js, .eslintrc, etc.)
- *
- * Documentation: https://turbo.build/repo/docs/reference/configuration#globaldependencies
- *
- * @default []
- */
- globalDependencies?: string[];
-
- /**
- * A list of environment variables for implicit global hash dependencies.
- *
- * The variables included in this list will affect all task hashes.
- *
- * Documentation: https://turbo.build/repo/docs/reference/configuration#globalenv
- *
- * @default []
- */
- globalEnv?: 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`.
- *
- * Only applies in `--env=strict` mode.
- *
- * Documentation: https://turbo.build/repo/docs/refernce/configuration#experimentalGlobalPassThroughEnv
- *
- * @default []
- */
- experimentalGlobalPassThroughEnv?: string[];
-
- /**
- * Configuration options that control how turbo interfaces with the remote cache.
- *
- * Documentation: https://turbo.build/repo/docs/core-concepts/remote-caching
- *
- * @default {}
- */
- remoteCache?: RemoteCache;
-}
-
-export interface Pipeline {
- /**
- * The list of tasks that this task depends on.
- *
- * Prefixing an item in dependsOn with a ^ prefix tells turbo that this task depends
- * on the package's topological dependencies completing the task first.
- * (e.g. "A package's build tasks should only run once all of its workspace dependencies
- * have completed their own build commands.")
- *
- * Items in dependsOn without a ^ prefix express the relationships between tasks within the
- * same package (e.g. "A package's test and lint commands depend on its own build being
- * completed first.")
- *
- * Documentation: https://turbo.build/repo/docs/reference/configuration#dependson
- *
- * @default []
- */
- dependsOn?: string[];
-
- /**
- * A list of environment variables that this task depends on.
- *
- * Note: If you are migrating from a turbo version 1.5 or below,
- * you may be used to prefixing your variables with a $.
- * You no longer need to use the $ prefix.
- * (e.g. $GITHUB_TOKEN -> GITHUB_TOKEN)
- *
- * Documentation: https://turbo.build/repo/docs/reference/configuration#env
- *
- * @default []
- */
- env?: string[];
-
- /**
- * An allowlist of environment variables that should be made available in this
- * task's environment, but should not contribute to the task's cache key,
- * e.g. `AWS_SECRET_KEY`.
- *
- * Only applies in `--env=strict` mode.
- *
- * Documentation: https://turbo.build/repo/docs/refernce/configuration#experimentalPassThroughEnv
- *
- * @default []
- */
- experimentalPassThroughEnv?: string[];
-
- /**
- * The set of glob patterns indicating a task's cacheable filesystem outputs.
- *
- * Turborepo captures task logs for all tasks. This enables us to cache tasks whose runs
- * produce no artifacts other than logs (such as linters). Logs are always treated as a
- * cacheable artifact and never need to be specified.
- *
- * Documentation: https://turbo.build/repo/docs/reference/configuration#outputs
- *
- * @default []
- */
- outputs?: string[];
-
- /**
- * Whether or not to cache the outputs of the task.
- *
- * Setting cache to false is useful for long-running "watch" or development mode tasks.
- *
- * Documentation: https://turbo.build/repo/docs/reference/configuration#cache
- *
- * @default true
- */
- cache?: boolean;
-
- /**
- * The set of glob patterns to consider as inputs to this task.
- *
- * Changes to files covered by these globs will cause a cache miss and
- * the task will be rerun.
- *
- * If a file has been changed that is **not** included in the set of globs,
- * it will not cause a cache miss.
- *
- * If omitted or empty, all files in the package are considered as inputs.
- *
- * Documentation: https://turbo.build/repo/docs/reference/configuration#inputs
- *
- * @default []
- */
- inputs?: string[];
-
- /**
- * Output mode for the task.
- *
- * "full": Displays all output
- *
- * "hash-only": Show only the hashes of the tasks
- *
- * "new-only": Only show output from cache misses
- *
- * "errors-only": Only show output from task failures
- *
- * "none": Hides all task output
- *
- * Documentation: https://turbo.build/repo/docs/reference/command-line-reference#--output-logs
- *
- * @default full
- */
- outputMode?: OutputMode;
-
- /**
- * Indicates whether the task exits or not. Setting `persistent` to `true` tells
- * turbo that this is a long-running task and will ensure that other tasks
- * cannot depend on it.
- *
- * Documentation: https://turbo.build/repo/docs/reference/configuration#persistent
- *
- * @default false
- */
- persistent?: boolean;
-}
-
-export interface RemoteCache {
- /**
- * Indicates if signature verification is enabled for requests to the remote cache. When
- * `true`, Turborepo will sign every uploaded artifact using the value of the environment
- * variable `TURBO_REMOTE_CACHE_SIGNATURE_KEY`. Turborepo will reject any downloaded artifacts
- * that have an invalid signature or are missing a signature.
- *
- * @default false
- */
- signature?: boolean;
-}
-
-export type OutputMode =
- | "full"
- | "hash-only"
- | "new-only"
- | "errors-only"
- | "none";
diff --git a/packages/turbo-types/tsconfig.json b/packages/turbo-types/tsconfig.json
deleted file mode 100644
index 0620a3c..0000000
--- a/packages/turbo-types/tsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "extends": "@turbo/tsconfig/library.json",
- "compilerOptions": {
- "rootDir": "."
- }
-}
diff --git a/packages/turbo-types/turbo.json b/packages/turbo-types/turbo.json
deleted file mode 100644
index 3a4da0f..0000000
--- a/packages/turbo-types/turbo.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "extends": ["//"],
- "pipeline": {
- // This task exists so the docs workspace
- // can watch this workspace for file changes.
- "topo": {}
- }
-}
diff --git a/packages/turbo-utils/LICENSE b/packages/turbo-utils/LICENSE
deleted file mode 100644
index fa0086a..0000000
--- a/packages/turbo-utils/LICENSE
+++ /dev/null
@@ -1,373 +0,0 @@
-Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
- means each individual or legal entity that creates, contributes to
- the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
- means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
- means Source Code Form to which the initial Contributor has attached
- the notice in Exhibit A, the Executable Form of such Source Code
- Form, and Modifications of such Source Code Form, in each case
- including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- (a) that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-
- (b) that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-1.6. "Executable Form"
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
- means a work that combines Covered Software with other material, in
- a separate file or files, that is not Covered Software.
-
-1.8. "License"
- means this document.
-
-1.9. "Licensable"
- means having the right to grant, to the maximum extent possible,
- whether at the time of the initial grant or subsequently, any and
- all of the rights conveyed by this License.
-
-1.10. "Modifications"
- means any of the following:
-
- (a) any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-
- (b) any new file in Source Code Form that contains any Covered
- Software.
-
-1.11. "Patent Claims" of a Contributor
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-1.12. "Secondary License"
- means either the GNU General Public License, Version 2.0, the GNU
- Lesser General Public License, Version 2.1, the GNU Affero General
- Public License, Version 3.0, or any later versions of those
- licenses.
-
-1.13. "Source Code Form"
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that
- controls, is controlled by, or is under common control with You. For
- purposes of this definition, "control" means (a) the power, direct
- or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or (b) ownership of more than
- fifty percent (50%) of the outstanding shares or beneficial
- ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
- or
-
-(b) for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
- Form, as described in Section 3.1, and You must inform recipients of
- the Executable Form how they can obtain a copy of such Source Code
- Form by reasonable means in a timely manner, at a charge no more
- than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-* *
-* 6. Disclaimer of Warranty *
-* ------------------------- *
-* *
-* Covered Software is provided under this License on an "as is" *
-* basis, without warranty of any kind, either expressed, implied, or *
-* statutory, including, without limitation, warranties that the *
-* Covered Software is free of defects, merchantable, fit for a *
-* particular purpose or non-infringing. The entire risk as to the *
-* quality and performance of the Covered Software is with You. *
-* Should any Covered Software prove defective in any respect, You *
-* (not any Contributor) assume the cost of any necessary servicing, *
-* repair, or correction. This disclaimer of warranty constitutes an *
-* essential part of this License. No use of any Covered Software is *
-* authorized under this License except under this disclaimer. *
-* *
-************************************************************************
-
-************************************************************************
-* *
-* 7. Limitation of Liability *
-* -------------------------- *
-* *
-* Under no circumstances and under no legal theory, whether tort *
-* (including negligence), contract, or otherwise, shall any *
-* Contributor, or anyone who distributes Covered Software as *
-* permitted above, be liable to You for any direct, indirect, *
-* special, incidental, or consequential damages of any character *
-* including, without limitation, damages for lost profits, loss of *
-* goodwill, work stoppage, computer failure or malfunction, or any *
-* and all other commercial damages or losses, even if such party *
-* shall have been informed of the possibility of such damages. This *
-* limitation of liability shall not apply to liability for death or *
-* personal injury resulting from such party's negligence to the *
-* extent applicable law prohibits such limitation. Some *
-* jurisdictions do not allow the exclusion or limitation of *
-* incidental or consequential damages, so this exclusion and *
-* limitation may not apply to You. *
-* *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0. \ No newline at end of file
diff --git a/packages/turbo-utils/README.md b/packages/turbo-utils/README.md
deleted file mode 100644
index 7eb2bad..0000000
--- a/packages/turbo-utils/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# `@turbo/utils`
-
-Internal package of generic utilities shared between [turborepo/packages/](https://github.com/vercel/turbo/tree/main/packages)
diff --git a/packages/turbo-utils/__fixtures__/common/single-package/child/child.js b/packages/turbo-utils/__fixtures__/common/single-package/child/child.js
deleted file mode 100644
index 9e799a2..0000000
--- a/packages/turbo-utils/__fixtures__/common/single-package/child/child.js
+++ /dev/null
@@ -1,2 +0,0 @@
-process.env.NONEXISTENT;
-process.env.CI;
diff --git a/packages/turbo-utils/__fixtures__/common/single-package/package.json b/packages/turbo-utils/__fixtures__/common/single-package/package.json
deleted file mode 100644
index b2a0927..0000000
--- a/packages/turbo-utils/__fixtures__/common/single-package/package.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "name": "single-package"
-}
diff --git a/packages/turbo-utils/__fixtures__/common/single-package/turbo.json b/packages/turbo-utils/__fixtures__/common/single-package/turbo.json
deleted file mode 100644
index 8079eb2..0000000
--- a/packages/turbo-utils/__fixtures__/common/single-package/turbo.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "globalEnv": ["UNORDERED", "CI"],
- "pipeline": {
- "build": {
- // A workspace's `build` task depends on that workspace's
- // topological dependencies' and devDependencies'
- // `build` tasks being completed first. The `^` symbol
- // indicates an upstream dependency.
- "dependsOn": ["^build"]
- },
- "test": {
- // A workspace's `test` task depends on that workspace's
- // own `build` task being completed first.
- "dependsOn": ["build"],
- "outputs": [],
- // A workspace's `test` task should only be rerun when
- // either a `.tsx` or `.ts` file has changed.
- "inputs": ["src/**/*.tsx", "src/**/*.ts", "test/**/*.ts", "test/**/*.tsx"]
- },
- "lint": {
- // A workspace's `lint` task has no dependencies and
- // can be run whenever.
- "outputs": []
- },
- "deploy": {
- // A workspace's `deploy` task depends on the `build`,
- // `test`, and `lint` tasks of the same workspace
- // being completed.
- "dependsOn": ["build", "test", "lint"],
- "outputs": []
- }
- }
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/docs/index.js b/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/docs/index.js
deleted file mode 100644
index 5030114..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/docs/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function docs() {
- if (!process.env.ENV_1) {
- return "bar";
- }
- return "foo";
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/docs/package.json b/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/docs/package.json
deleted file mode 100644
index 82f9a44..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/docs/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "docs",
- "version": "1.0.0"
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/index.js b/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/index.js
deleted file mode 100644
index bfd3ab8..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function web() {
- if (!process.env.ENV_2) {
- return "bar";
- }
- return "foo";
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/package.json b/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/package.json
deleted file mode 100644
index d8a83ed..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "web",
- "version": "1.0.0"
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/turbo.json b/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/turbo.json
deleted file mode 100644
index 0d1b80f..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/apps/web/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {
- "env": ["ENV_2"]
- }
- }
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/package.json b/packages/turbo-utils/__fixtures__/common/workspace-configs/package.json
deleted file mode 100644
index c6616a6..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "private": true,
- "workspaces": [
- "apps/*",
- "packages/*"
- ],
- "scripts": {
- "build": "turbo run build"
- },
- "devDependencies": {
- "turbo": "latest"
- },
- "packageManager": "yarn@1.22.19"
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/index.js b/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/index.js
deleted file mode 100644
index dee5e80..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function foo() {
- if (!process.env.IS_SERVER) {
- return "bar";
- }
- return "foo";
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/package.json b/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/package.json
deleted file mode 100644
index 7cb7cf1..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "ui",
- "version": "1.0.0"
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/turbo.json b/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/turbo.json
deleted file mode 100644
index 8bff09e..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/ui/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {
- "env": ["IS_SERVER"]
- }
- }
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/index.js b/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/index.js
deleted file mode 100644
index dee5e80..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export default function foo() {
- if (!process.env.IS_SERVER) {
- return "bar";
- }
- return "foo";
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/package.json b/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/package.json
deleted file mode 100644
index 39308ba..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "utils",
- "version": "1.0.0"
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/turbo.json b/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/turbo.json
deleted file mode 100644
index fcb2aa7..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/packages/utils/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- // invalid config - missing extends
- "pipeline": {
- "build": {
- "env": ["IS_SERVER"]
- }
- }
-}
diff --git a/packages/turbo-utils/__fixtures__/common/workspace-configs/turbo.json b/packages/turbo-utils/__fixtures__/common/workspace-configs/turbo.json
deleted file mode 100644
index cb4fb20..0000000
--- a/packages/turbo-utils/__fixtures__/common/workspace-configs/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://turbo.build/schema.json",
- "globalEnv": ["CI"],
- "pipeline": {
- "build": {
- "env": ["ENV_1"]
- }
- }
-}
diff --git a/packages/turbo-utils/__tests__/getTurboConfigs.test.ts b/packages/turbo-utils/__tests__/getTurboConfigs.test.ts
deleted file mode 100644
index e61e630..0000000
--- a/packages/turbo-utils/__tests__/getTurboConfigs.test.ts
+++ /dev/null
@@ -1,112 +0,0 @@
-import path from "path";
-import getTurboConfigs from "../src/getTurboConfigs";
-import { setupTestFixtures } from "@turbo/test-utils";
-
-describe("getTurboConfigs", () => {
- const { useFixture } = setupTestFixtures({
- directory: path.join(__dirname, "../"),
- test: "common",
- });
-
- it("single-package", async () => {
- const { root } = useFixture({ fixture: `single-package` });
- const configs = getTurboConfigs(root);
- expect(configs).toHaveLength(1);
- expect(configs[0].isRootConfig).toBe(true);
- expect(configs[0].config).toMatchInlineSnapshot(`
- Object {
- "$schema": "https://turbo.build/schema.json",
- "globalEnv": Array [
- "UNORDERED",
- "CI",
- ],
- "pipeline": Object {
- "build": Object {
- "dependsOn": Array [
- "^build",
- ],
- },
- "deploy": Object {
- "dependsOn": Array [
- "build",
- "test",
- "lint",
- ],
- "outputs": Array [],
- },
- "lint": Object {
- "outputs": Array [],
- },
- "test": Object {
- "dependsOn": Array [
- "build",
- ],
- "inputs": Array [
- "src/**/*.tsx",
- "src/**/*.ts",
- "test/**/*.ts",
- "test/**/*.tsx",
- ],
- "outputs": Array [],
- },
- },
- }
- `);
- });
-
- it("workspace-configs", async () => {
- const { root } = useFixture({ fixture: `workspace-configs` });
- const configs = getTurboConfigs(root);
-
- expect(configs).toHaveLength(3);
- expect(configs[0].isRootConfig).toBe(true);
- expect(configs[0].config).toMatchInlineSnapshot(`
- Object {
- "$schema": "https://turbo.build/schema.json",
- "globalEnv": Array [
- "CI",
- ],
- "pipeline": Object {
- "build": Object {
- "env": Array [
- "ENV_1",
- ],
- },
- },
- }
- `);
- expect(configs[1].isRootConfig).toBe(false);
- expect(configs[1].config).toMatchInlineSnapshot(`
- Object {
- "$schema": "https://turbo.build/schema.json",
- "extends": Array [
- "//",
- ],
- "pipeline": Object {
- "build": Object {
- "env": Array [
- "ENV_2",
- ],
- },
- },
- }
- `);
-
- expect(configs[2].isRootConfig).toBe(false);
- expect(configs[2].config).toMatchInlineSnapshot(`
- Object {
- "$schema": "https://turbo.build/schema.json",
- "extends": Array [
- "//",
- ],
- "pipeline": Object {
- "build": Object {
- "env": Array [
- "IS_SERVER",
- ],
- },
- },
- }
- `);
- });
-});
diff --git a/packages/turbo-utils/__tests__/getTurboRoot.test.ts b/packages/turbo-utils/__tests__/getTurboRoot.test.ts
deleted file mode 100644
index acfb0ce..0000000
--- a/packages/turbo-utils/__tests__/getTurboRoot.test.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import path from "path";
-import getTurboRoot from "../src/getTurboRoot";
-import { setupTestFixtures } from "@turbo/test-utils";
-
-describe("getTurboConfigs", () => {
- const { useFixture } = setupTestFixtures({
- directory: path.join(__dirname, "../"),
- test: "common",
- });
-
- test.each([[""], ["child"]])(
- "finds the root in a non-monorepo (%s)",
- (repoPath) => {
- const { root } = useFixture({ fixture: `single-package` });
- const turboRoot = getTurboRoot(path.join(root, repoPath));
- expect(turboRoot).toEqual(root);
- }
- );
-
- test.each([
- [""],
- ["apps"],
- ["apps/docs"],
- ["apps/web"],
- ["packages"],
- ["packages/ui"],
- ["not-a-real/path"],
- ])("finds the root in a monorepo with workspace configs (%s)", (repoPath) => {
- const { root } = useFixture({ fixture: `workspace-configs` });
- const turboRoot = getTurboRoot(path.join(root, repoPath));
- expect(turboRoot).toEqual(root);
- });
-});
diff --git a/packages/turbo-utils/jest.config.js b/packages/turbo-utils/jest.config.js
deleted file mode 100644
index bbe7825..0000000
--- a/packages/turbo-utils/jest.config.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
- preset: "ts-jest/presets/js-with-ts",
- testEnvironment: "node",
- modulePathIgnorePatterns: ["<rootDir>/node_modules", "<rootDir>/dist"],
- transformIgnorePatterns: ["/node_modules/(?!(ansi-regex)/)"],
-};
diff --git a/packages/turbo-utils/package.json b/packages/turbo-utils/package.json
deleted file mode 100644
index fdaf5f2..0000000
--- a/packages/turbo-utils/package.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "name": "@turbo/utils",
- "version": "0.0.0",
- "private": true,
- "description": "",
- "homepage": "https://turbo.build/repo",
- "keywords": [],
- "author": "Vercel",
- "license": "MPL-2.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/turbo",
- "directory": "packages/turbo-utils"
- },
- "bugs": {
- "url": "https://github.com/vercel/turbo/issues"
- },
- "module": "dist/index.mjs",
- "main": "dist/index.js",
- "types": "dist/index.d.ts",
- "scripts": {
- "build": "tsup",
- "test": "jest",
- "lint": "eslint src/**/*.ts",
- "check-types": "tsc --noEmit"
- },
- "devDependencies": {
- "@manypkg/find-root": "^1.1.0",
- "@types/jest": "^27.4.0",
- "@types/js-yaml": "^4.0.5",
- "@types/node": "^16.11.12",
- "eslint": "^8.23.0",
- "execa": "5.1.1",
- "fast-glob": "^3.2.12",
- "jest": "^27.4.3",
- "js-yaml": "^4.1.0",
- "json5": "^2.2.3",
- "ts-jest": "^27.1.1",
- "@turbo/tsconfig": "workspace:*",
- "tsup": "^5.12.1",
- "@turbo/test-utils": "workspace:*",
- "@turbo/types": "workspace:*",
- "typescript": "^4.7.4"
- }
-}
diff --git a/packages/turbo-utils/src/getTurboConfigs.ts b/packages/turbo-utils/src/getTurboConfigs.ts
deleted file mode 100644
index df15a56..0000000
--- a/packages/turbo-utils/src/getTurboConfigs.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-import fs from "fs";
-import path from "path";
-import getTurboRoot from "./getTurboRoot";
-import yaml from "js-yaml";
-import { sync } from "fast-glob";
-import { Schema } from "@turbo/types";
-import JSON5 from "json5";
-
-const ROOT_GLOB = "turbo.json";
-
-export type TurboConfigs = Array<{
- config: Schema;
- turboConfigPath: string;
- workspacePath: string;
- isRootConfig: boolean;
-}>;
-
-interface Options {
- cache?: boolean;
-}
-
-const configsCache: Record<string, TurboConfigs> = {};
-
-// A quick and dirty workspace parser
-// TODO: after @turbo/workspace-convert is merged, we can leverage those utils here
-function getWorkspaceGlobs(root: string): Array<string> {
- try {
- if (fs.existsSync(path.join(root, "pnpm-workspace.yaml"))) {
- const workspaceConfig = yaml.load(
- fs.readFileSync(path.join(root, "pnpm-workspace.yaml"), "utf8")
- ) as Record<"packages", Array<string>>;
-
- return workspaceConfig?.packages || [];
- } else {
- const packageJson = JSON.parse(
- fs.readFileSync(path.join(root, "package.json"), "utf8")
- );
- return packageJson?.workspaces || [];
- }
- } catch (e) {
- return [];
- }
-}
-
-function getTurboConfigs(cwd?: string, opts?: Options): TurboConfigs {
- const turboRoot = getTurboRoot(cwd, opts);
- const configs: TurboConfigs = [];
-
- const cacheEnabled = opts?.cache ?? true;
- if (cacheEnabled && cwd && configsCache[cwd]) {
- return configsCache[cwd];
- }
-
- // parse workspaces
- if (turboRoot) {
- const workspaceGlobs = getWorkspaceGlobs(turboRoot);
- const workspaceConfigGlobs = workspaceGlobs.map(
- (glob) => `${glob}/turbo.json`
- );
-
- const configPaths = sync([ROOT_GLOB, ...workspaceConfigGlobs], {
- cwd: turboRoot,
- onlyFiles: true,
- followSymbolicLinks: false,
- // avoid throwing when encountering permission errors or unreadable paths
- suppressErrors: true,
- }).map((configPath) => path.join(turboRoot, configPath));
-
- configPaths.forEach((configPath) => {
- try {
- const raw = fs.readFileSync(configPath, "utf8");
- const turboJsonContent: Schema = JSON5.parse(raw);
- // basic config validation
- let isRootConfig = path.dirname(configPath) === turboRoot;
- if (isRootConfig) {
- // invalid - root config with extends
- if ("extends" in turboJsonContent) {
- return;
- }
- } else {
- // invalid - workspace config with no extends
- if (!("extends" in turboJsonContent)) {
- return;
- }
- }
- configs.push({
- config: turboJsonContent,
- turboConfigPath: configPath,
- workspacePath: path.dirname(configPath),
- isRootConfig,
- });
- } catch (e) {
- // if we can't read or parse the config, just ignore it with a warning
- console.warn(e);
- }
- });
- }
-
- if (cacheEnabled && cwd) {
- configsCache[cwd] = configs;
- }
-
- return configs;
-}
-
-export default getTurboConfigs;
diff --git a/packages/turbo-utils/src/getTurboRoot.ts b/packages/turbo-utils/src/getTurboRoot.ts
deleted file mode 100644
index 64a37be..0000000
--- a/packages/turbo-utils/src/getTurboRoot.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import { findRootSync } from "@manypkg/find-root";
-import searchUp from "./searchUp";
-import JSON5 from "json5";
-
-interface Options {
- cache?: boolean;
-}
-
-function contentCheck(content: string): boolean {
- const result = JSON5.parse(content);
- return !result.extends;
-}
-
-const configCache: Record<string, string> = {};
-
-function getTurboRoot(cwd?: string, opts?: Options): string | null {
- const cacheEnabled = opts?.cache ?? true;
- const currentDir = cwd || process.cwd();
-
- if (cacheEnabled && configCache[currentDir]) {
- return configCache[currentDir];
- }
-
- // Turborepo root can be determined by a turbo.json without an extends key
- let root = searchUp({
- target: "turbo.json",
- cwd: currentDir,
- contentCheck,
- });
-
- if (!root) {
- try {
- root = findRootSync(currentDir);
- if (!root) {
- return null;
- }
- } catch (err) {
- return null;
- }
- }
-
- if (cacheEnabled) {
- configCache[currentDir] = root;
- }
-
- return root;
-}
-
-export default getTurboRoot;
diff --git a/packages/turbo-utils/src/index.ts b/packages/turbo-utils/src/index.ts
deleted file mode 100644
index 2d86559..0000000
--- a/packages/turbo-utils/src/index.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-// utils
-export { default as getTurboRoot } from "./getTurboRoot";
-export { default as getTurboConfigs } from "./getTurboConfigs";
-export { default as searchUp } from "./searchUp";
-export { getAvailablePackageManagers } from "./managers";
-
-// types
-export type { PackageManagerAvailable } from "./managers";
diff --git a/packages/turbo-utils/src/managers.ts b/packages/turbo-utils/src/managers.ts
deleted file mode 100644
index ab9c53d..0000000
--- a/packages/turbo-utils/src/managers.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import execa from "execa";
-import os from "os";
-
-export type PackageManager = "npm" | "yarn" | "pnpm";
-export type PackageManagerAvailable = { available: boolean; version?: string };
-
-async function getVersion(
- packageManager: string
-): Promise<PackageManagerAvailable> {
- // run the check from tmpdir to avoid corepack conflicting -
- // this is no longer needed as of https://github.com/nodejs/corepack/pull/167
- // but we'll keep the behavior for those on older versions)
- const execOptions = {
- cwd: os.tmpdir(),
- env: { COREPACK_ENABLE_STRICT: "0" },
- };
-
- let available = false;
- try {
- const userAgent = process.env.npm_config_user_agent;
- if (userAgent && userAgent.startsWith(packageManager)) {
- available = true;
- }
-
- const result = await execa(packageManager, ["--version"], execOptions);
- return {
- available: true,
- version: result.stdout.trim(),
- };
- } catch (e) {
- return {
- available,
- };
- }
-}
-
-async function getAvailablePackageManagers(): Promise<
- Record<PackageManager, PackageManagerAvailable>
-> {
- const [yarn, npm, pnpm] = await Promise.all([
- getVersion("yarnpkg"),
- getVersion("npm"),
- getVersion("pnpm"),
- ]);
-
- return {
- yarn,
- pnpm,
- npm,
- };
-}
-
-export { getAvailablePackageManagers };
diff --git a/packages/turbo-utils/src/searchUp.ts b/packages/turbo-utils/src/searchUp.ts
deleted file mode 100644
index 57f92e4..0000000
--- a/packages/turbo-utils/src/searchUp.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import fs from "fs";
-import path from "path";
-
-function searchUp({
- target,
- cwd,
- contentCheck,
-}: {
- target: string;
- cwd: string;
- contentCheck?: (content: string) => boolean;
-}): string | null {
- const root = path.parse(cwd).root;
-
- let found = false;
- while (!found && cwd !== root) {
- if (contentCheck) {
- try {
- const content = fs.readFileSync(path.join(cwd, target)).toString();
- if (contentCheck(content)) {
- found = true;
- break;
- }
- } catch {
- // keep looking
- }
- } else {
- if (fs.existsSync(path.join(cwd, target))) {
- found = true;
- break;
- }
- }
-
- cwd = path.dirname(cwd);
- }
-
- if (found) {
- return cwd;
- }
-
- return null;
-}
-
-export default searchUp;
diff --git a/packages/turbo-utils/tsconfig.json b/packages/turbo-utils/tsconfig.json
deleted file mode 100644
index 0620a3c..0000000
--- a/packages/turbo-utils/tsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "extends": "@turbo/tsconfig/library.json",
- "compilerOptions": {
- "rootDir": "."
- }
-}
diff --git a/packages/turbo-utils/tsup.config.ts b/packages/turbo-utils/tsup.config.ts
deleted file mode 100644
index 716b7a5..0000000
--- a/packages/turbo-utils/tsup.config.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { defineConfig, Options } from "tsup";
-
-export default defineConfig((options: Options) => ({
- entry: ["src/**/*.ts"],
- treeshake: true,
- splitting: true,
- format: ["esm", "cjs"],
- dts: true,
- minify: true,
- clean: true,
- ...options,
-}));
diff --git a/packages/turbo-workspaces/LICENSE b/packages/turbo-workspaces/LICENSE
deleted file mode 100644
index fa0086a..0000000
--- a/packages/turbo-workspaces/LICENSE
+++ /dev/null
@@ -1,373 +0,0 @@
-Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
- means each individual or legal entity that creates, contributes to
- the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
- means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
- means Source Code Form to which the initial Contributor has attached
- the notice in Exhibit A, the Executable Form of such Source Code
- Form, and Modifications of such Source Code Form, in each case
- including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- (a) that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-
- (b) that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-1.6. "Executable Form"
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
- means a work that combines Covered Software with other material, in
- a separate file or files, that is not Covered Software.
-
-1.8. "License"
- means this document.
-
-1.9. "Licensable"
- means having the right to grant, to the maximum extent possible,
- whether at the time of the initial grant or subsequently, any and
- all of the rights conveyed by this License.
-
-1.10. "Modifications"
- means any of the following:
-
- (a) any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-
- (b) any new file in Source Code Form that contains any Covered
- Software.
-
-1.11. "Patent Claims" of a Contributor
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-1.12. "Secondary License"
- means either the GNU General Public License, Version 2.0, the GNU
- Lesser General Public License, Version 2.1, the GNU Affero General
- Public License, Version 3.0, or any later versions of those
- licenses.
-
-1.13. "Source Code Form"
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that
- controls, is controlled by, or is under common control with You. For
- purposes of this definition, "control" means (a) the power, direct
- or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or (b) ownership of more than
- fifty percent (50%) of the outstanding shares or beneficial
- ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
- or
-
-(b) for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
- Form, as described in Section 3.1, and You must inform recipients of
- the Executable Form how they can obtain a copy of such Source Code
- Form by reasonable means in a timely manner, at a charge no more
- than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-* *
-* 6. Disclaimer of Warranty *
-* ------------------------- *
-* *
-* Covered Software is provided under this License on an "as is" *
-* basis, without warranty of any kind, either expressed, implied, or *
-* statutory, including, without limitation, warranties that the *
-* Covered Software is free of defects, merchantable, fit for a *
-* particular purpose or non-infringing. The entire risk as to the *
-* quality and performance of the Covered Software is with You. *
-* Should any Covered Software prove defective in any respect, You *
-* (not any Contributor) assume the cost of any necessary servicing, *
-* repair, or correction. This disclaimer of warranty constitutes an *
-* essential part of this License. No use of any Covered Software is *
-* authorized under this License except under this disclaimer. *
-* *
-************************************************************************
-
-************************************************************************
-* *
-* 7. Limitation of Liability *
-* -------------------------- *
-* *
-* Under no circumstances and under no legal theory, whether tort *
-* (including negligence), contract, or otherwise, shall any *
-* Contributor, or anyone who distributes Covered Software as *
-* permitted above, be liable to You for any direct, indirect, *
-* special, incidental, or consequential damages of any character *
-* including, without limitation, damages for lost profits, loss of *
-* goodwill, work stoppage, computer failure or malfunction, or any *
-* and all other commercial damages or losses, even if such party *
-* shall have been informed of the possibility of such damages. This *
-* limitation of liability shall not apply to liability for death or *
-* personal injury resulting from such party's negligence to the *
-* extent applicable law prohibits such limitation. Some *
-* jurisdictions do not allow the exclusion or limitation of *
-* incidental or consequential damages, so this exclusion and *
-* limitation may not apply to You. *
-* *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0. \ No newline at end of file
diff --git a/packages/turbo-workspaces/README.md b/packages/turbo-workspaces/README.md
deleted file mode 100644
index 60d8024..0000000
--- a/packages/turbo-workspaces/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# `@turbo/workspaces`
-
-Easily convert your repo between package managers. Supports both non-monorepos and monorepos (using package manager workspaces).
-
-## CLI
-
-```sh
-Usage: @turbo/workspaces [options] [command]
-
-Tools for working with package manager workspaces
-
-Options:
- -v, --version output the current version
- -h, --help display help for command
-
-Commands:
- convert [options] [path] [package-manager] Convert project between workspace managers
- summary [path] Display a summary of the specified project
- help [command] display help for command
-```
-
-## Node API
-
-Methods are also available via the Node API:
-
-```js
-import { convert, getWorkspaceDetails } from "@turbo/workspaces";
-
-// detect the package manager
-const project = getWorkspaceDetails({
- root: process.cwd(),
-});
-
-// if the package manager is not pnpm, convert to pnpm
-if (project.packageManager !== "pnpm") {
- await convert({
- root: process.cwd(),
- to: "pnpm",
- options: {
- dry: false,
- install: true,
- },
- });
-}
-```
-
----
-
-For more information about Turborepo, visit [turbo.build/repo](https://turbo.build/repo) and follow us on Twitter ([@turborepo](https://twitter.com/turborepo))!
diff --git a/packages/turbo-workspaces/__fixtures__/invalid/index.js b/packages/turbo-workspaces/__fixtures__/invalid/index.js
deleted file mode 100644
index cd01831..0000000
--- a/packages/turbo-workspaces/__fixtures__/invalid/index.js
+++ /dev/null
@@ -1 +0,0 @@
-// nothing here
diff --git a/packages/turbo-workspaces/__fixtures__/npm/monorepo/apps/docs/package.json b/packages/turbo-workspaces/__fixtures__/npm/monorepo/apps/docs/package.json
deleted file mode 100644
index e488bc3..0000000
--- a/packages/turbo-workspaces/__fixtures__/npm/monorepo/apps/docs/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "docs",
- "version": "1.0.0",
- "private": true,
- "dependencies": {
- "ui": "*"
- },
- "devDependencies": {
- "tsconfig": "1.0.0"
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/npm/monorepo/apps/web/package.json b/packages/turbo-workspaces/__fixtures__/npm/monorepo/apps/web/package.json
deleted file mode 100644
index 163cee3..0000000
--- a/packages/turbo-workspaces/__fixtures__/npm/monorepo/apps/web/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "web",
- "version": "0.0.0",
- "private": true,
- "dependencies": {
- "ui": "*"
- },
- "devDependencies": {
- "tsconfig": "*"
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/npm/monorepo/package-lock.json b/packages/turbo-workspaces/__fixtures__/npm/monorepo/package-lock.json
deleted file mode 100644
index 6b6842b..0000000
--- a/packages/turbo-workspaces/__fixtures__/npm/monorepo/package-lock.json
+++ /dev/null
@@ -1,385 +0,0 @@
-{
- "name": "npm-workspaces",
- "version": "0.0.0",
- "lockfileVersion": 2,
- "requires": true,
- "packages": {
- "": {
- "name": "npm-workspaces",
- "version": "0.0.0",
- "workspaces": [
- "apps/*",
- "packages/*"
- ],
- "engines": {
- "node": ">=14.0.0"
- }
- },
- "apps/docs": {
- "version": "1.0.0",
- "dependencies": {
- "ui": "*"
- },
- "devDependencies": {
- "tsconfig": "1.0.0"
- }
- },
- "apps/docs/node_modules/tsconfig": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-1.0.0.tgz",
- "integrity": "sha512-26lVKF/0MdkCnaU9t45wH8bsVH8nRKRt0zrvku/j/dD5uE+8v9vDfBS8/sVRs6ZjADXbcFvirN93kOpxdIszqQ==",
- "dev": true,
- "dependencies": {
- "globby": "^2.1.0",
- "xtend": "^4.0.0"
- }
- },
- "apps/web": {
- "version": "0.0.0",
- "dependencies": {
- "ui": "*"
- },
- "devDependencies": {
- "tsconfig": "*"
- }
- },
- "node_modules/array-union": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz",
- "integrity": "sha512-Dxr6QJj/RdU/hCaBjOfxW+q6lyuVE6JFWIrAUpuOOhoJJoQ99cUn3igRaHVB5P9WrgFVN0FfArM3x0cueOU8ng==",
- "dev": true,
- "dependencies": {
- "array-uniq": "^1.0.1"
- },
- "engines": {
- "node": ">=0.10.0"
- }
- },
- "node_modules/array-uniq": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz",
- "integrity": "sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q==",
- "dev": true,
- "engines": {
- "node": ">=0.10.0"
- }
- },
- "node_modules/async": {
- "version": "1.5.2",
- "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
- "integrity": "sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w==",
- "dev": true
- },
- "node_modules/balanced-match": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
- "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
- "dev": true
- },
- "node_modules/brace-expansion": {
- "version": "1.1.11",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
- "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
- "dev": true,
- "dependencies": {
- "balanced-match": "^1.0.0",
- "concat-map": "0.0.1"
- }
- },
- "node_modules/concat-map": {
- "version": "0.0.1",
- "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
- "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
- "dev": true
- },
- "node_modules/docs": {
- "resolved": "apps/docs",
- "link": true
- },
- "node_modules/glob": {
- "version": "5.0.15",
- "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz",
- "integrity": "sha512-c9IPMazfRITpmAAKi22dK1VKxGDX9ehhqfABDriL/lzO92xcUKEJPQHrVA/2YHSNFB4iFlykVmWvwo48nr3OxA==",
- "dev": true,
- "dependencies": {
- "inflight": "^1.0.4",
- "inherits": "2",
- "minimatch": "2 || 3",
- "once": "^1.3.0",
- "path-is-absolute": "^1.0.0"
- },
- "engines": {
- "node": "*"
- }
- },
- "node_modules/globby": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/globby/-/globby-2.1.0.tgz",
- "integrity": "sha512-CqRID2dMaN4Zi9PANiQHhmKaGu7ZASehBLnaDogjR9L3L1EqAGFhflafT0IrSN/zm9xFk+KMTXZCN8pUYOiO/Q==",
- "dev": true,
- "dependencies": {
- "array-union": "^1.0.1",
- "async": "^1.2.1",
- "glob": "^5.0.3",
- "object-assign": "^3.0.0"
- },
- "engines": {
- "node": ">=0.10.0"
- }
- },
- "node_modules/inflight": {
- "version": "1.0.6",
- "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
- "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
- "dev": true,
- "dependencies": {
- "once": "^1.3.0",
- "wrappy": "1"
- }
- },
- "node_modules/inherits": {
- "version": "2.0.4",
- "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
- "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
- "dev": true
- },
- "node_modules/minimatch": {
- "version": "3.1.2",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
- "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
- "dev": true,
- "dependencies": {
- "brace-expansion": "^1.1.7"
- },
- "engines": {
- "node": "*"
- }
- },
- "node_modules/object-assign": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz",
- "integrity": "sha512-jHP15vXVGeVh1HuaA2wY6lxk+whK/x4KBG88VXeRma7CCun7iGD5qPc4eYykQ9sdQvg8jkwFKsSxHln2ybW3xQ==",
- "dev": true,
- "engines": {
- "node": ">=0.10.0"
- }
- },
- "node_modules/once": {
- "version": "1.4.0",
- "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
- "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
- "dev": true,
- "dependencies": {
- "wrappy": "1"
- }
- },
- "node_modules/path-is-absolute": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
- "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
- "dev": true,
- "engines": {
- "node": ">=0.10.0"
- }
- },
- "node_modules/tsconfig": {
- "resolved": "packages/tsconfig",
- "link": true
- },
- "node_modules/ui": {
- "resolved": "packages/ui",
- "link": true
- },
- "node_modules/web": {
- "resolved": "apps/web",
- "link": true
- },
- "node_modules/wrappy": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
- "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
- "dev": true
- },
- "node_modules/xtend": {
- "version": "4.0.2",
- "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
- "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
- "dev": true,
- "engines": {
- "node": ">=0.4"
- }
- },
- "packages/tsconfig": {
- "version": "1.0.0"
- },
- "packages/ui": {
- "version": "0.0.0",
- "devDependencies": {
- "tsconfig": "*"
- }
- }
- },
- "dependencies": {
- "array-union": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz",
- "integrity": "sha512-Dxr6QJj/RdU/hCaBjOfxW+q6lyuVE6JFWIrAUpuOOhoJJoQ99cUn3igRaHVB5P9WrgFVN0FfArM3x0cueOU8ng==",
- "dev": true,
- "requires": {
- "array-uniq": "^1.0.1"
- }
- },
- "array-uniq": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz",
- "integrity": "sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q==",
- "dev": true
- },
- "async": {
- "version": "1.5.2",
- "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
- "integrity": "sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w==",
- "dev": true
- },
- "balanced-match": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
- "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
- "dev": true
- },
- "brace-expansion": {
- "version": "1.1.11",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
- "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
- "dev": true,
- "requires": {
- "balanced-match": "^1.0.0",
- "concat-map": "0.0.1"
- }
- },
- "concat-map": {
- "version": "0.0.1",
- "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
- "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
- "dev": true
- },
- "docs": {
- "version": "file:apps/docs",
- "requires": {
- "tsconfig": "1.0.0",
- "ui": "*"
- },
- "dependencies": {
- "tsconfig": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-1.0.0.tgz",
- "integrity": "sha512-26lVKF/0MdkCnaU9t45wH8bsVH8nRKRt0zrvku/j/dD5uE+8v9vDfBS8/sVRs6ZjADXbcFvirN93kOpxdIszqQ==",
- "dev": true,
- "requires": {
- "globby": "^2.1.0",
- "xtend": "^4.0.0"
- }
- }
- }
- },
- "glob": {
- "version": "5.0.15",
- "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz",
- "integrity": "sha512-c9IPMazfRITpmAAKi22dK1VKxGDX9ehhqfABDriL/lzO92xcUKEJPQHrVA/2YHSNFB4iFlykVmWvwo48nr3OxA==",
- "dev": true,
- "requires": {
- "inflight": "^1.0.4",
- "inherits": "2",
- "minimatch": "2 || 3",
- "once": "^1.3.0",
- "path-is-absolute": "^1.0.0"
- }
- },
- "globby": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/globby/-/globby-2.1.0.tgz",
- "integrity": "sha512-CqRID2dMaN4Zi9PANiQHhmKaGu7ZASehBLnaDogjR9L3L1EqAGFhflafT0IrSN/zm9xFk+KMTXZCN8pUYOiO/Q==",
- "dev": true,
- "requires": {
- "array-union": "^1.0.1",
- "async": "^1.2.1",
- "glob": "^5.0.3",
- "object-assign": "^3.0.0"
- }
- },
- "inflight": {
- "version": "1.0.6",
- "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
- "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
- "dev": true,
- "requires": {
- "once": "^1.3.0",
- "wrappy": "1"
- }
- },
- "inherits": {
- "version": "2.0.4",
- "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
- "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
- "dev": true
- },
- "minimatch": {
- "version": "3.1.2",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
- "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
- "dev": true,
- "requires": {
- "brace-expansion": "^1.1.7"
- }
- },
- "object-assign": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz",
- "integrity": "sha512-jHP15vXVGeVh1HuaA2wY6lxk+whK/x4KBG88VXeRma7CCun7iGD5qPc4eYykQ9sdQvg8jkwFKsSxHln2ybW3xQ==",
- "dev": true
- },
- "once": {
- "version": "1.4.0",
- "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
- "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
- "dev": true,
- "requires": {
- "wrappy": "1"
- }
- },
- "path-is-absolute": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
- "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
- "dev": true
- },
- "tsconfig": {
- "version": "file:packages/tsconfig"
- },
- "ui": {
- "version": "file:packages/ui",
- "requires": {
- "tsconfig": "*"
- }
- },
- "web": {
- "version": "file:apps/web",
- "requires": {
- "tsconfig": "*",
- "ui": "*"
- }
- },
- "wrappy": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
- "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
- "dev": true
- },
- "xtend": {
- "version": "4.0.2",
- "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
- "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
- "dev": true
- }
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/npm/monorepo/package.json b/packages/turbo-workspaces/__fixtures__/npm/monorepo/package.json
deleted file mode 100644
index b1242c7..0000000
--- a/packages/turbo-workspaces/__fixtures__/npm/monorepo/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "name": "npm-workspaces",
- "version": "0.0.0",
- "private": true,
- "workspaces": [
- "apps/*",
- "packages/*"
- ],
- "engines": {
- "node": ">=14.0.0"
- },
- "dependencies": {},
- "packageManager": "npm@8.19.4"
-}
diff --git a/packages/turbo-workspaces/__fixtures__/npm/monorepo/packages/tsconfig/package.json b/packages/turbo-workspaces/__fixtures__/npm/monorepo/packages/tsconfig/package.json
deleted file mode 100644
index 0d32af3..0000000
--- a/packages/turbo-workspaces/__fixtures__/npm/monorepo/packages/tsconfig/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "tsconfig",
- "version": "1.0.0",
- "private": true
-}
diff --git a/packages/turbo-workspaces/__fixtures__/npm/monorepo/packages/ui/package.json b/packages/turbo-workspaces/__fixtures__/npm/monorepo/packages/ui/package.json
deleted file mode 100644
index 1e05d1a..0000000
--- a/packages/turbo-workspaces/__fixtures__/npm/monorepo/packages/ui/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "ui",
- "version": "0.0.0",
- "devDependencies": {
- "tsconfig": "*"
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/npm/non-monorepo/package-lock.json b/packages/turbo-workspaces/__fixtures__/npm/non-monorepo/package-lock.json
deleted file mode 100644
index 067bf21..0000000
--- a/packages/turbo-workspaces/__fixtures__/npm/non-monorepo/package-lock.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "name": "npm",
- "version": "0.0.0",
- "lockfileVersion": 2,
- "requires": true,
- "packages": {
- "": {
- "name": "npm",
- "version": "0.0.0"
- }
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/npm/non-monorepo/package.json b/packages/turbo-workspaces/__fixtures__/npm/non-monorepo/package.json
deleted file mode 100644
index 47f30c6..0000000
--- a/packages/turbo-workspaces/__fixtures__/npm/non-monorepo/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "name": "npm",
- "version": "0.0.0",
- "private": true,
- "packageManager": "npm@8.19.4"
-}
diff --git a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/apps/docs/package.json b/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/apps/docs/package.json
deleted file mode 100644
index 835a58f..0000000
--- a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/apps/docs/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "docs",
- "version": "0.0.0",
- "private": true,
- "dependencies": {
- "ui": "workspace:*"
- },
- "devDependencies": {
- "tsconfig": "workspace:*"
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/apps/web/package.json b/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/apps/web/package.json
deleted file mode 100644
index 77c2e0f..0000000
--- a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/apps/web/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "web",
- "version": "0.0.0",
- "private": true,
- "dependencies": {
- "ui": "workspace:*"
- },
- "devDependencies": {
- "tsconfig": "workspace:*"
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/package.json b/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/package.json
deleted file mode 100644
index e3627d8..0000000
--- a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/package.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "name": "pnpm-workspaces",
- "version": "0.0.0",
- "private": true,
- "engines": {
- "node": ">=14.0.0"
- },
- "dependencies": {},
- "packageManager": "pnpm@7.12.1"
-}
diff --git a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/packages/tsconfig/package.json b/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/packages/tsconfig/package.json
deleted file mode 100644
index 3f40629..0000000
--- a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/packages/tsconfig/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "tsconfig",
- "version": "0.0.0",
- "private": true
-}
diff --git a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/packages/ui/package.json b/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/packages/ui/package.json
deleted file mode 100644
index 601ca4a..0000000
--- a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/packages/ui/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "ui",
- "version": "0.0.0",
- "devDependencies": {
- "tsconfig": "workspace:*"
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/pnpm-lock.yaml b/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/pnpm-lock.yaml
deleted file mode 100644
index 84c04af..0000000
--- a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/pnpm-lock.yaml
+++ /dev/null
@@ -1,33 +0,0 @@
-lockfileVersion: 5.4
-
-importers:
-
- .:
- specifiers: {}
-
- apps/docs:
- specifiers:
- tsconfig: workspace:*
- ui: workspace:*
- dependencies:
- ui: link:../../packages/ui
- devDependencies:
- tsconfig: link:../../packages/tsconfig
-
- apps/web:
- specifiers:
- tsconfig: workspace:*
- ui: workspace:*
- dependencies:
- ui: link:../../packages/ui
- devDependencies:
- tsconfig: link:../../packages/tsconfig
-
- packages/tsconfig:
- specifiers: {}
-
- packages/ui:
- specifiers:
- tsconfig: workspace:*
- devDependencies:
- tsconfig: link:../tsconfig
diff --git a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/pnpm-workspace.yaml b/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/pnpm-workspace.yaml
deleted file mode 100644
index 3ff5faa..0000000
--- a/packages/turbo-workspaces/__fixtures__/pnpm/monorepo/pnpm-workspace.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-packages:
- - "apps/*"
- - "packages/*"
diff --git a/packages/turbo-workspaces/__fixtures__/pnpm/non-monorepo/package.json b/packages/turbo-workspaces/__fixtures__/pnpm/non-monorepo/package.json
deleted file mode 100644
index 00885fa..0000000
--- a/packages/turbo-workspaces/__fixtures__/pnpm/non-monorepo/package.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "pnpm",
- "version": "0.0.0",
- "private": true,
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "pnpm@7.12.1"
-}
diff --git a/packages/turbo-workspaces/__fixtures__/pnpm/non-monorepo/pnpm-lock.yaml b/packages/turbo-workspaces/__fixtures__/pnpm/non-monorepo/pnpm-lock.yaml
deleted file mode 100644
index 84c04af..0000000
--- a/packages/turbo-workspaces/__fixtures__/pnpm/non-monorepo/pnpm-lock.yaml
+++ /dev/null
@@ -1,33 +0,0 @@
-lockfileVersion: 5.4
-
-importers:
-
- .:
- specifiers: {}
-
- apps/docs:
- specifiers:
- tsconfig: workspace:*
- ui: workspace:*
- dependencies:
- ui: link:../../packages/ui
- devDependencies:
- tsconfig: link:../../packages/tsconfig
-
- apps/web:
- specifiers:
- tsconfig: workspace:*
- ui: workspace:*
- dependencies:
- ui: link:../../packages/ui
- devDependencies:
- tsconfig: link:../../packages/tsconfig
-
- packages/tsconfig:
- specifiers: {}
-
- packages/ui:
- specifiers:
- tsconfig: workspace:*
- devDependencies:
- tsconfig: link:../tsconfig
diff --git a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/apps/docs/package.json b/packages/turbo-workspaces/__fixtures__/yarn/monorepo/apps/docs/package.json
deleted file mode 100644
index d3a490c..0000000
--- a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/apps/docs/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "docs",
- "version": "0.0.0",
- "private": true,
- "dependencies": {
- "ui": "*"
- },
- "devDependencies": {
- "tsconfig": "*"
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/apps/web/package.json b/packages/turbo-workspaces/__fixtures__/yarn/monorepo/apps/web/package.json
deleted file mode 100644
index 163cee3..0000000
--- a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/apps/web/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "web",
- "version": "0.0.0",
- "private": true,
- "dependencies": {
- "ui": "*"
- },
- "devDependencies": {
- "tsconfig": "*"
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/package.json b/packages/turbo-workspaces/__fixtures__/yarn/monorepo/package.json
deleted file mode 100644
index 002944b..0000000
--- a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "name": "yarn-workspaces",
- "version": "0.0.0",
- "private": true,
- "workspaces": [
- "apps/*",
- "packages/*"
- ],
- "engines": {
- "node": ">=14.0.0"
- },
- "dependencies": {},
- "packageManager": "yarn@1.22.19"
-}
diff --git a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/packages/tsconfig/package.json b/packages/turbo-workspaces/__fixtures__/yarn/monorepo/packages/tsconfig/package.json
deleted file mode 100644
index 3f40629..0000000
--- a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/packages/tsconfig/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "tsconfig",
- "version": "0.0.0",
- "private": true
-}
diff --git a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/packages/ui/package.json b/packages/turbo-workspaces/__fixtures__/yarn/monorepo/packages/ui/package.json
deleted file mode 100644
index 1e05d1a..0000000
--- a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/packages/ui/package.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "name": "ui",
- "version": "0.0.0",
- "devDependencies": {
- "tsconfig": "*"
- }
-}
diff --git a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/yarn.lock b/packages/turbo-workspaces/__fixtures__/yarn/monorepo/yarn.lock
deleted file mode 100644
index fb57ccd..0000000
--- a/packages/turbo-workspaces/__fixtures__/yarn/monorepo/yarn.lock
+++ /dev/null
@@ -1,4 +0,0 @@
-# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
-# yarn lockfile v1
-
-
diff --git a/packages/turbo-workspaces/__fixtures__/yarn/non-monorepo/package.json b/packages/turbo-workspaces/__fixtures__/yarn/non-monorepo/package.json
deleted file mode 100644
index 970aa3e..0000000
--- a/packages/turbo-workspaces/__fixtures__/yarn/non-monorepo/package.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "yarn",
- "version": "0.0.0",
- "private": true,
- "dependencies": {},
- "devDependencies": {},
- "packageManager": "yarn@1.22.19"
-}
diff --git a/packages/turbo-workspaces/__fixtures__/yarn/non-monorepo/yarn.lock b/packages/turbo-workspaces/__fixtures__/yarn/non-monorepo/yarn.lock
deleted file mode 100644
index fb57ccd..0000000
--- a/packages/turbo-workspaces/__fixtures__/yarn/non-monorepo/yarn.lock
+++ /dev/null
@@ -1,4 +0,0 @@
-# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
-# yarn lockfile v1
-
-
diff --git a/packages/turbo-workspaces/__tests__/index.test.ts b/packages/turbo-workspaces/__tests__/index.test.ts
deleted file mode 100644
index 21753be..0000000
--- a/packages/turbo-workspaces/__tests__/index.test.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-import path from "path";
-import * as turboUtils from "@turbo/utils";
-import { setupTestFixtures } from "@turbo/test-utils";
-import { getWorkspaceDetails, convert } from "../src";
-import { generateConvertMatrix } from "./test-utils";
-import execa from "execa";
-
-jest.mock("execa", () => jest.fn());
-
-describe("Node entrypoint", () => {
- const { useFixture } = setupTestFixtures({
- directory: path.join(__dirname, "../"),
- });
-
- describe("convert", () => {
- test.each(generateConvertMatrix())(
- "detects $fixtureType project using $fixtureManager and converts to $toManager (interactive=$interactive dry=$dry install=$install)",
- async ({
- fixtureManager,
- fixtureType,
- toManager,
- interactive,
- dry,
- install,
- }) => {
- const mockedGetAvailablePackageManagers = jest
- .spyOn(turboUtils, "getAvailablePackageManagers")
- .mockResolvedValue({
- npm: {
- available: true,
- version: "8.19.2",
- },
- yarn: {
- available: true,
- version: "1.22.19",
- },
- pnpm: {
- available: true,
- version: "7.29.1",
- },
- });
-
- const { root } = useFixture({
- fixture: `./${fixtureManager}/${fixtureType}`,
- });
-
- // read
- const details = await getWorkspaceDetails({ root });
- expect(details.packageManager).toBe(fixtureManager);
-
- // convert
- const convertWrapper = () =>
- convert({
- root,
- to: toManager,
- options: { interactive, dry, skipInstall: !install },
- });
-
- if (fixtureManager === toManager) {
- await expect(convertWrapper()).rejects.toThrowError(
- "You are already using this package manager"
- );
- } else {
- await expect(convertWrapper()).resolves.toBeUndefined();
- // read again
- const convertedDetails = await getWorkspaceDetails({
- root,
- });
- expect(mockedGetAvailablePackageManagers).toHaveBeenCalled();
-
- if (dry) {
- expect(convertedDetails.packageManager).toBe(fixtureManager);
- } else {
- if (install) {
- expect(execa).toHaveBeenCalled();
- }
- expect(convertedDetails.packageManager).toBe(toManager);
- }
- }
-
- mockedGetAvailablePackageManagers.mockRestore();
- }
- );
- });
-});
diff --git a/packages/turbo-workspaces/__tests__/managers.test.ts b/packages/turbo-workspaces/__tests__/managers.test.ts
deleted file mode 100644
index 73c5073..0000000
--- a/packages/turbo-workspaces/__tests__/managers.test.ts
+++ /dev/null
@@ -1,285 +0,0 @@
-import path from "path";
-import { setupTestFixtures } from "@turbo/test-utils";
-import { Logger } from "../src/logger";
-import MANAGERS from "../src/managers";
-import { PackageJson } from "../src/types";
-import fs from "fs-extra";
-import {
- generateDetectMatrix,
- generateCreateMatrix,
- generateRemoveMatrix,
- generateReadMatrix,
- generateCleanMatrix,
- generateConvertLockMatrix,
-} from "./test-utils";
-
-jest.mock("execa", () => jest.fn());
-
-describe("managers", () => {
- const { useFixture } = setupTestFixtures({
- directory: path.join(__dirname, "../"),
- });
-
- describe("detect", () => {
- test.each(generateDetectMatrix())(
- "$project $type project detected by $manager manager - (expect: $result)",
- async ({ project, manager, type, result }) => {
- const { root } = useFixture({ fixture: `./${project}/${type}` });
-
- const detectResult = await MANAGERS[manager].detect({
- workspaceRoot: root,
- });
-
- expect(detectResult).toEqual(result);
- }
- );
- });
-
- describe("create", () => {
- test.each(generateCreateMatrix())(
- "creates $manager project from $project $type project (interactive=$interactive, dry=$dry)",
- async ({ project, manager, type, interactive, dry }) => {
- expect.assertions(2);
-
- const { root } = useFixture({ fixture: `./${project}/${type}` });
- const testProject = await MANAGERS[project].read({
- workspaceRoot: root,
- });
-
- expect(testProject.packageManager).toEqual(project);
-
- await MANAGERS[manager].create({
- project: testProject,
- to: { name: manager, version: "1.2.3" },
- logger: new Logger({ interactive, dry }),
- options: {
- interactive,
- dry,
- },
- });
-
- if (dry) {
- expect(
- await MANAGERS[project].detect({ workspaceRoot: root })
- ).toEqual(true);
- } else {
- expect(
- await MANAGERS[manager].detect({ workspaceRoot: root })
- ).toEqual(true);
- }
- }
- );
- });
-
- describe("remove", () => {
- test.each(generateRemoveMatrix())(
- "removes $fixtureManager from $fixtureManager $fixtureType project when moving to $toManager (withNodeModules=$withNodeModules, interactive=$interactive, dry=$dry)",
- async ({
- fixtureManager,
- fixtureType,
- toManager,
- withNodeModules,
- interactive,
- dry,
- }) => {
- const { root, readJson, readYaml } = useFixture({
- fixture: `./${fixtureManager}/${fixtureType}`,
- });
- const project = await MANAGERS[fixtureManager].read({
- workspaceRoot: root,
- });
- expect(project.packageManager).toEqual(fixtureManager);
-
- if (withNodeModules) {
- fs.ensureDirSync(project.paths.nodeModules);
- }
-
- await MANAGERS[fixtureManager].remove({
- project,
- to: { name: toManager, version: "1.2.3" },
- logger: new Logger({ interactive, dry }),
- options: {
- interactive,
- dry,
- },
- });
-
- if (withNodeModules) {
- expect(fs.existsSync(project.paths.nodeModules)).toEqual(dry);
- }
-
- const packageJson = readJson<PackageJson>(project.paths.packageJson);
- if (dry) {
- expect(packageJson?.packageManager).toBeDefined();
- expect(packageJson?.packageManager?.split("@")[0]).toEqual(
- fixtureManager
- );
- if (fixtureType === "basic") {
- if (fixtureManager === "pnpm") {
- expect(project.paths.workspaceConfig).toBeDefined();
- if (project.paths.workspaceConfig) {
- const workspaceConfig = readYaml<{ packages: Array<string> }>(
- project.paths.workspaceConfig
- );
- expect(workspaceConfig?.packages).toBeDefined();
- expect(workspaceConfig?.packages).toEqual(
- project.workspaceData.globs
- );
- }
- } else {
- expect(packageJson?.workspaces).toBeDefined();
- expect(packageJson?.workspaces).toEqual(
- project.workspaceData.globs
- );
- }
- }
- } else {
- expect(packageJson?.packageManager).toBeUndefined();
- if (fixtureType === "basic") {
- expect(packageJson?.workspaces).toBeUndefined();
-
- if (fixtureManager === "pnpm") {
- expect(project.paths.workspaceConfig).toBeDefined();
- if (project.paths.workspaceConfig) {
- const workspaceConfig = readYaml<{ packages: Array<string> }>(
- project.paths.workspaceConfig
- );
- expect(workspaceConfig).toBeUndefined();
- }
- }
- }
- }
- }
- );
- });
-
- describe("read", () => {
- test.each(generateReadMatrix())(
- "reads $toManager workspaces from $fixtureManager $fixtureType project - (shouldThrow: $shouldThrow)",
- async ({ fixtureManager, fixtureType, toManager, shouldThrow }) => {
- const { root, directoryName } = useFixture({
- fixture: `./${fixtureManager}/${fixtureType}`,
- });
-
- const read = async () =>
- MANAGERS[toManager].read({ workspaceRoot: path.join(root) });
- if (shouldThrow) {
- if (toManager === "pnpm") {
- expect(read).rejects.toThrow(`Not a pnpm project`);
- } else if (toManager === "yarn") {
- expect(read).rejects.toThrow(`Not a yarn project`);
- } else if (toManager === "npm") {
- expect(read).rejects.toThrow(`Not an npm project`);
- }
- return;
- }
- const project = await MANAGERS[toManager].read({
- workspaceRoot: path.join(root),
- });
-
- expect(project.name).toEqual(
- fixtureType === "monorepo" ? `${toManager}-workspaces` : toManager
- );
- expect(project.packageManager).toEqual(toManager);
-
- // paths
- expect(project.paths.root).toMatch(
- new RegExp(`^.*\/${directoryName}$`)
- );
- expect(project.paths.packageJson).toMatch(
- new RegExp(`^.*\/${directoryName}\/package.json$`)
- );
-
- if (fixtureManager === "pnpm") {
- new RegExp(`^.*\/${directoryName}\/pnpm-lock.yaml$`);
- } else if (fixtureManager === "yarn") {
- new RegExp(`^.*\/${directoryName}\/yarn.lock$`);
- } else if (fixtureManager === "npm") {
- new RegExp(`^.*\/${directoryName}\/package-lock.json$`);
- } else {
- throw new Error("Invalid fixtureManager");
- }
-
- if (fixtureType === "non-monorepo") {
- expect(project.workspaceData.workspaces).toEqual([]);
- expect(project.workspaceData.globs).toEqual([]);
- } else {
- expect(project.workspaceData.globs).toEqual(["apps/*", "packages/*"]);
- project.workspaceData.workspaces.forEach((workspace) => {
- const type = ["web", "docs"].includes(workspace.name)
- ? "apps"
- : "packages";
- expect(workspace.paths.packageJson).toMatch(
- new RegExp(
- `^.*${directoryName}\/${type}\/${workspace.name}\/package.json$`
- )
- );
- expect(workspace.paths.root).toMatch(
- new RegExp(`^.*${directoryName}\/${type}\/${workspace.name}$`)
- );
- });
- }
- }
- );
- });
-
- describe("clean", () => {
- test.each(generateCleanMatrix())(
- "cleans $fixtureManager $fixtureType project (interactive=$interactive, dry=$dry)",
- async ({ fixtureManager, fixtureType, interactive, dry }) => {
- const { root } = useFixture({
- fixture: `./${fixtureManager}/${fixtureType}`,
- });
-
- const project = await MANAGERS[fixtureManager].read({
- workspaceRoot: root,
- });
-
- expect(project.packageManager).toEqual(fixtureManager);
-
- await MANAGERS[fixtureManager].clean({
- project,
- logger: new Logger({ interactive, dry }),
- options: {
- interactive,
- dry,
- },
- });
-
- expect(fs.existsSync(project.paths.lockfile)).toEqual(dry);
- }
- );
- });
-
- describe("convertLock", () => {
- test.each(generateConvertLockMatrix())(
- "converts lockfile for $fixtureManager $fixtureType project to $toManager format (interactive=$interactive, dry=$dry)",
- async ({ fixtureManager, fixtureType, toManager, interactive, dry }) => {
- const { root, exists } = useFixture({
- fixture: `./${fixtureManager}/${fixtureType}`,
- });
-
- const project = await MANAGERS[fixtureManager].read({
- workspaceRoot: root,
- });
-
- expect(project.packageManager).toEqual(fixtureManager);
-
- await MANAGERS[toManager].convertLock({
- project,
- logger: new Logger(),
- options: {
- interactive,
- dry,
- },
- });
-
- if (fixtureManager !== toManager) {
- expect(exists(project.paths.lockfile)).toEqual(dry);
- } else {
- expect(exists(project.paths.lockfile)).toEqual(true);
- }
- }
- );
- });
-});
diff --git a/packages/turbo-workspaces/__tests__/test-utils.ts b/packages/turbo-workspaces/__tests__/test-utils.ts
deleted file mode 100644
index 4d6c7c9..0000000
--- a/packages/turbo-workspaces/__tests__/test-utils.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-import { PackageManager } from "../src/types";
-
-const PACKAGE_MANAGERS: Array<PackageManager> = ["pnpm", "npm", "yarn"];
-const REPO_TYPES = ["monorepo", "non-monorepo"];
-const BOOLEAN_OPTIONS = [true, false];
-
-export function generateConvertMatrix() {
- const matrix = [];
- for (const fixtureManager of PACKAGE_MANAGERS) {
- for (const fixtureType of REPO_TYPES) {
- for (const toManager of PACKAGE_MANAGERS) {
- for (const interactive of BOOLEAN_OPTIONS) {
- for (const dry of BOOLEAN_OPTIONS) {
- for (const install of BOOLEAN_OPTIONS) {
- matrix.push({
- fixtureManager,
- fixtureType,
- toManager,
- interactive,
- dry,
- install,
- });
- }
- }
- }
- }
- }
- }
- return matrix;
-}
-
-export function generateDetectMatrix() {
- const matrix = [];
- for (const project of PACKAGE_MANAGERS) {
- for (const manager of PACKAGE_MANAGERS) {
- for (const type of REPO_TYPES) {
- matrix.push({
- project,
- manager,
- type,
- result: project === manager,
- });
- }
- }
- }
- return matrix;
-}
-
-export function generateCreateMatrix() {
- const matrix = [];
- for (const project of PACKAGE_MANAGERS) {
- for (const manager of PACKAGE_MANAGERS) {
- for (const type of REPO_TYPES) {
- for (const interactive of BOOLEAN_OPTIONS) {
- for (const dry of BOOLEAN_OPTIONS) {
- matrix.push({
- project,
- manager,
- type,
- interactive,
- dry,
- });
- }
- }
- }
- }
- }
- return matrix;
-}
-
-export function generateReadMatrix() {
- const matrix = [];
- for (const fixtureManager of PACKAGE_MANAGERS) {
- for (const fixtureType of REPO_TYPES) {
- for (const toManager of PACKAGE_MANAGERS) {
- matrix.push({
- fixtureManager,
- fixtureType,
- toManager,
- shouldThrow: fixtureManager !== toManager,
- });
- }
- }
- }
-
- return matrix;
-}
-
-export function generateRemoveMatrix() {
- const matrix = [];
- for (const fixtureManager of PACKAGE_MANAGERS) {
- for (const fixtureType of REPO_TYPES) {
- for (const toManager of PACKAGE_MANAGERS) {
- for (const withNodeModules of BOOLEAN_OPTIONS) {
- for (const interactive of BOOLEAN_OPTIONS) {
- for (const dry of BOOLEAN_OPTIONS) {
- matrix.push({
- fixtureManager,
- fixtureType,
- withNodeModules,
- toManager,
- interactive,
- dry,
- });
- }
- }
- }
- }
- }
- }
- return matrix;
-}
-
-export function generateCleanMatrix() {
- const matrix = [];
- for (const fixtureManager of PACKAGE_MANAGERS) {
- for (const fixtureType of REPO_TYPES) {
- for (const interactive of BOOLEAN_OPTIONS) {
- for (const dry of BOOLEAN_OPTIONS) {
- matrix.push({
- fixtureManager,
- fixtureType,
- interactive,
- dry,
- });
- }
- }
- }
- }
- return matrix;
-}
-
-export function generateConvertLockMatrix() {
- const matrix = [];
- for (const fixtureManager of PACKAGE_MANAGERS) {
- for (const fixtureType of REPO_TYPES) {
- for (const toManager of PACKAGE_MANAGERS) {
- for (const interactive of BOOLEAN_OPTIONS) {
- for (const dry of BOOLEAN_OPTIONS) {
- matrix.push({
- fixtureManager,
- fixtureType,
- toManager,
- interactive,
- dry,
- });
- }
- }
- }
- }
- }
- return matrix;
-}
diff --git a/packages/turbo-workspaces/jest.config.js b/packages/turbo-workspaces/jest.config.js
deleted file mode 100644
index 2658950..0000000
--- a/packages/turbo-workspaces/jest.config.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
- preset: "ts-jest/presets/js-with-ts",
- testEnvironment: "node",
- testPathIgnorePatterns: ["/__fixtures__/", "/__tests__/test-utils.ts"],
- coveragePathIgnorePatterns: ["/__fixtures__/", "/__tests__/test-utils.ts"],
- transformIgnorePatterns: ["/node_modules/(?!(ansi-regex)/)"],
- modulePathIgnorePatterns: ["<rootDir>/node_modules", "<rootDir>/dist"],
- collectCoverage: true,
- verbose: true,
- coverageThreshold: {
- global: {
- branches: 83,
- functions: 87,
- lines: 93,
- statements: 93,
- },
- },
-};
diff --git a/packages/turbo-workspaces/package.json b/packages/turbo-workspaces/package.json
deleted file mode 100644
index 5dd2490..0000000
--- a/packages/turbo-workspaces/package.json
+++ /dev/null
@@ -1,66 +0,0 @@
-{
- "name": "@turbo/workspaces",
- "version": "1.9.4-canary.2",
- "description": "Tools for working with package managers",
- "homepage": "https://turbo.build/repo",
- "license": "MPL-2.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/turbo",
- "directory": "packages/turbo-workspaces"
- },
- "bugs": {
- "url": "https://github.com/vercel/turbo/issues"
- },
- "bin": "dist/cli.js",
- "main": "dist/index.js",
- "types": "dist/index.d.ts",
- "scripts": {
- "build": "tsup",
- "dev": "tsup --watch",
- "test": "jest",
- "lint": "eslint src/**/*.ts",
- "check-types": "tsc --noEmit"
- },
- "dependencies": {
- "chalk": "2.4.2",
- "commander": "^10.0.0",
- "execa": "5.1.1",
- "fast-glob": "^3.2.12",
- "fs-extra": "^10.1.0",
- "gradient-string": "^2.0.0",
- "inquirer": "^8.0.0",
- "js-yaml": "^4.1.0",
- "ora": "4.1.1",
- "rimraf": "^3.0.2",
- "semver": "^7.3.5",
- "update-check": "^1.5.4"
- },
- "devDependencies": {
- "@types/chalk-animation": "^1.6.0",
- "@types/fs-extra": "^9.0.13",
- "@types/gradient-string": "^1.1.2",
- "@types/inquirer": "^7.3.1",
- "@types/jest": "^27.4.0",
- "@types/js-yaml": "^4.0.5",
- "@types/node": "^16.11.12",
- "@types/rimraf": "^3.0.2",
- "@types/semver": "^7.3.9",
- "eslint": "^7.23.0",
- "jest": "^27.4.3",
- "semver": "^7.3.5",
- "strip-ansi": "^6.0.1",
- "ts-jest": "^27.1.1",
- "@turbo/tsconfig": "workspace:*",
- "tsup": "^5.10.3",
- "@turbo/test-utils": "workspace:*",
- "@turbo/utils": "workspace:*",
- "typescript": "^4.5.5"
- },
- "files": [
- "dist"
- ],
- "publishConfig": {
- "access": "public"
- }
-}
diff --git a/packages/turbo-workspaces/src/cli.ts b/packages/turbo-workspaces/src/cli.ts
deleted file mode 100644
index 3ae7a45..0000000
--- a/packages/turbo-workspaces/src/cli.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/env node
-
-import chalk from "chalk";
-import { Command } from "commander";
-
-import { summary, convert } from "./commands";
-import cliPkg from "../package.json";
-import { ConvertError } from "./errors";
-
-const workspacesCli = new Command();
-
-workspacesCli
- .name("@turbo/workspaces")
- .description("Tools for working with package manager workspaces")
- .version(cliPkg.version, "-v, --version", "output the current version");
-
-// convert
-workspacesCli
- .command("convert")
- .description("Convert project between workspace managers")
- .argument("[path]", "Project root")
- .argument("[package-manager]", "Package manager to convert to")
- .option(
- "--skip-install",
- "Do not run a package manager install after conversion",
- false
- )
- .option("--dry", "Dry run (no changes are made to files)", false)
- .option(
- "--force",
- "Bypass Git safety checks and forcibly run conversion",
- false
- )
- .action(convert);
-
-// summary
-workspacesCli
- .command("summary")
- .description("Display a summary of the specified project")
- .argument("[path]", "Project root")
- .action(summary);
-
-workspacesCli.parseAsync().catch((error) => {
- console.log();
- if (error instanceof ConvertError) {
- console.log(chalk.red(error.message));
- } else {
- console.log(chalk.red("Unexpected error. Please report it as a bug:"));
- console.log(error.message);
- }
- console.log();
- process.exit(1);
-});
diff --git a/packages/turbo-workspaces/src/commands/convert/index.ts b/packages/turbo-workspaces/src/commands/convert/index.ts
deleted file mode 100644
index 6cc82fc..0000000
--- a/packages/turbo-workspaces/src/commands/convert/index.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import { ConvertCommandArgument, ConvertCommandOptions } from "./types";
-import inquirer from "inquirer";
-import { Logger } from "../../logger";
-import chalk from "chalk";
-import { getAvailablePackageManagers } from "@turbo/utils";
-import { directoryInfo } from "../../utils";
-import getWorkspaceDetails from "../../getWorkspaceDetails";
-import { PackageManager } from "../../types";
-import { convertProject } from "../../convert";
-
-function isPackageManagerDisabled({
- packageManager,
- currentWorkspaceManger,
- availablePackageManagers,
-}: {
- packageManager: PackageManager;
- currentWorkspaceManger: PackageManager;
- availablePackageManagers: Record<PackageManager, { available: boolean }>;
-}) {
- if (currentWorkspaceManger === packageManager) {
- return "already in use";
- }
-
- if (!availablePackageManagers[packageManager].available) {
- return "not installed";
- }
-
- return false;
-}
-
-export default async function convertCommand(
- directory: ConvertCommandArgument,
- packageManager: ConvertCommandArgument,
- options: ConvertCommandOptions
-) {
- const logger = new Logger(options);
-
- logger.hero();
- logger.header("Welcome, let's convert your project.");
- logger.blankLine();
-
- const directoryAnswer = await inquirer.prompt<{
- directoryInput: string;
- }>({
- type: "input",
- name: "directoryInput",
- message: "Where is the root of your repo?",
- when: !directory,
- default: ".",
- validate: (directory: string) => {
- const { exists, absolute } = directoryInfo({ directory });
- if (exists) {
- return true;
- } else {
- return `Directory ${chalk.dim(`(${absolute})`)} does not exist`;
- }
- },
- filter: (directory: string) => directory.trim(),
- });
-
- const { directoryInput: selectedDirectory = directory } = directoryAnswer;
- const { exists, absolute: root } = directoryInfo({
- directory: selectedDirectory,
- });
- if (!exists) {
- console.error(`Directory ${chalk.dim(`(${root})`)} does not exist`);
- return process.exit(1);
- }
-
- const [project, availablePackageManagers] = await Promise.all([
- getWorkspaceDetails({ root }),
- getAvailablePackageManagers(),
- ]);
-
- const packageManagerAnswer = await inquirer.prompt<{
- packageManagerInput?: PackageManager;
- }>({
- name: "packageManagerInput",
- type: "list",
- message: `Convert from ${project.packageManager} workspaces to:`,
- when:
- !packageManager ||
- !Object.keys(availablePackageManagers).includes(packageManager),
- choices: ["npm", "pnpm", "yarn"].map((p) => ({
- name: `${p} workspaces`,
- value: p,
- disabled: isPackageManagerDisabled({
- packageManager: p as PackageManager,
- currentWorkspaceManger: project.packageManager,
- availablePackageManagers,
- }),
- })),
- });
- const {
- packageManagerInput:
- selectedPackageManager = packageManager as PackageManager,
- } = packageManagerAnswer;
-
- await convertProject({
- project,
- to: {
- name: selectedPackageManager,
- version: availablePackageManagers[selectedPackageManager]
- .version as string,
- },
- logger,
- options,
- });
-}
diff --git a/packages/turbo-workspaces/src/commands/convert/types.ts b/packages/turbo-workspaces/src/commands/convert/types.ts
deleted file mode 100644
index a7b9deb..0000000
--- a/packages/turbo-workspaces/src/commands/convert/types.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export type ConvertCommandArgument = string;
-export type ConvertCommandOptions = {
- dry: boolean;
- force: boolean;
- skipInstall: boolean;
-};
diff --git a/packages/turbo-workspaces/src/commands/index.ts b/packages/turbo-workspaces/src/commands/index.ts
deleted file mode 100644
index 423e959..0000000
--- a/packages/turbo-workspaces/src/commands/index.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export { default as summary } from "./summary";
-export { default as convert } from "./convert";
-
-export type { SummaryCommandArgument } from "./summary/types";
-export type {
- ConvertCommandArgument,
- ConvertCommandOptions,
-} from "./convert/types";
diff --git a/packages/turbo-workspaces/src/commands/summary/index.ts b/packages/turbo-workspaces/src/commands/summary/index.ts
deleted file mode 100644
index 9696a14..0000000
--- a/packages/turbo-workspaces/src/commands/summary/index.ts
+++ /dev/null
@@ -1,98 +0,0 @@
-import inquirer from "inquirer";
-import path from "path";
-import { Logger } from "../../logger";
-import chalk from "chalk";
-import { SummaryCommandArgument } from "./types";
-import { directoryInfo } from "../../utils";
-import getWorkspaceDetails from "../../getWorkspaceDetails";
-import { Workspace } from "../../types";
-
-export default async function summary(directory: SummaryCommandArgument) {
- const logger = new Logger();
- logger.hero();
-
- const answer = await inquirer.prompt<{
- directoryInput?: string;
- }>({
- type: "input",
- name: "directoryInput",
- message: "Where is the root of the repo?",
- when: !directory,
- default: ".",
- validate: (directory: string) => {
- const { exists, absolute } = directoryInfo({ directory });
- if (exists) {
- return true;
- } else {
- return `Directory ${chalk.dim(`(${absolute})`)} does not exist`;
- }
- },
- filter: (directory: string) => directory.trim(),
- });
-
- const { directoryInput: selectedDirectory = directory as string } = answer;
- const { exists, absolute: root } = directoryInfo({
- directory: selectedDirectory,
- });
- if (!exists) {
- console.error(`Directory ${chalk.dim(`(${root})`)} does not exist`);
- return process.exit(1);
- }
-
- const project = await getWorkspaceDetails({ root });
-
- const numWorkspaces = project.workspaceData.workspaces.length;
- const hasWorkspaces = numWorkspaces > 0;
- // group workspaces
- const workspacesByDirectory: Record<string, Array<Workspace>> = {};
- project.workspaceData.workspaces.forEach((workspace) => {
- const workspacePath = path.relative(root, workspace.paths.root);
- const rootDirectory = workspacePath.split(path.sep)[0];
- if (!workspacesByDirectory[rootDirectory]) {
- workspacesByDirectory[rootDirectory] = [];
- }
- workspacesByDirectory[rootDirectory].push(workspace);
- });
-
- const renderWorkspace = (w: Workspace) => {
- return `${w.name} (${chalk.italic(
- `./${path.relative(root, w.paths.root)}`
- )})`;
- };
-
- const renderDirectory = ({
- number,
- directory,
- workspaces,
- }: {
- number: number;
- directory: string;
- workspaces: Array<Workspace>;
- }) => {
- logger.indented(2, `${number}. ${chalk.bold(directory)}`);
- workspaces.forEach((workspace, idx) => {
- logger.indented(3, `${idx + 1}. ${renderWorkspace(workspace)}`);
- });
- };
-
- // repo header
- logger.header(`Repository Summary`);
- logger.indented(1, `${chalk.underline(project.name)}:`);
- // workspace manager header
- logger.indented(
- 1,
- `Package Manager: ${chalk.bold(chalk.italic(project.packageManager))}`
- );
- if (hasWorkspaces) {
- // workspaces header
- logger.indented(1, `Workspaces (${chalk.bold(numWorkspaces.toString())}):`);
- Object.keys(workspacesByDirectory).forEach((directory, idx) => {
- renderDirectory({
- number: idx + 1,
- directory,
- workspaces: workspacesByDirectory[directory],
- });
- });
- logger.blankLine();
- }
-}
diff --git a/packages/turbo-workspaces/src/commands/summary/types.ts b/packages/turbo-workspaces/src/commands/summary/types.ts
deleted file mode 100644
index 0cc5830..0000000
--- a/packages/turbo-workspaces/src/commands/summary/types.ts
+++ /dev/null
@@ -1 +0,0 @@
-export type SummaryCommandArgument = string;
diff --git a/packages/turbo-workspaces/src/convert.ts b/packages/turbo-workspaces/src/convert.ts
deleted file mode 100644
index 9f481c1..0000000
--- a/packages/turbo-workspaces/src/convert.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import chalk from "chalk";
-import managers from "./managers";
-import { Project, Options, PackageManagerDetails } from "./types";
-import install from "./install";
-import { Logger } from "./logger";
-import { ConvertError } from "./errors";
-
-/*
- * Convert a project using workspaces from one package manager to another.
-
- Steps are run in the following order:
- 1. managerFrom.remove
- 2. managerTo.create
- 3. managerTo.convertLock
- 3. install
- 4. managerFrom.clean
-
-*/
-export async function convertProject({
- project,
- to,
- logger,
- options,
-}: {
- project: Project;
- to: PackageManagerDetails;
- logger: Logger;
- options?: Options;
-}) {
- logger.header(
- `Converting project from ${project.packageManager} to ${to.name}.`
- );
-
- if (project.packageManager == to.name) {
- throw new ConvertError("You are already using this package manager", {
- type: "package_manager-already_in_use",
- });
- }
-
- // remove old workspace data
- await managers[project.packageManager].remove({
- project,
- to,
- logger,
- options,
- });
-
- // create new workspace data
- await managers[to.name].create({ project, to, logger, options });
-
- logger.mainStep("Installing dependencies");
- if (!options?.skipInstall) {
- await managers[to.name].convertLock({ project, logger, options });
- await install({ project, to, logger, options });
- } else {
- logger.subStep(chalk.yellow("Skipping install"));
- }
-
- logger.mainStep(`Cleaning up ${project.packageManager} workspaces`);
- await managers[project.packageManager].clean({ project, logger });
-}
diff --git a/packages/turbo-workspaces/src/errors.ts b/packages/turbo-workspaces/src/errors.ts
deleted file mode 100644
index aa2fabe..0000000
--- a/packages/turbo-workspaces/src/errors.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-export type ConvertErrorType =
- // package manager general
- | "package_manager-unexpected"
- | "package_manager-already_in_use"
- | "package_manager-unable_to_detect"
- | "package_manager-unsupported_version"
- // package manager specific
- | "pnpm-workspace_parse_error"
- // package.json
- | "package_json-parse_error"
- | "package_json-missing"
- // other
- | "invalid_directory"
- | "error_removing_node_modules"
- // default
- | "unknown";
-
-export type ConvertErrorOptions = {
- type?: ConvertErrorType;
-};
-
-export class ConvertError extends Error {
- public type: ConvertErrorType;
-
- constructor(message: string, opts?: ConvertErrorOptions) {
- super(message);
- this.name = "ConvertError";
- this.type = opts?.type ?? "unknown";
- Error.captureStackTrace(this, ConvertError);
- }
-}
diff --git a/packages/turbo-workspaces/src/getWorkspaceDetails.ts b/packages/turbo-workspaces/src/getWorkspaceDetails.ts
deleted file mode 100644
index ad86a97..0000000
--- a/packages/turbo-workspaces/src/getWorkspaceDetails.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { ConvertError } from "./errors";
-import managers from "./managers";
-import { Project } from "./types";
-import { directoryInfo } from "./utils";
-
-export default async function getWorkspaceDetails({
- root,
-}: {
- root: string;
-}): Promise<Project> {
- const { exists, absolute: workspaceRoot } = directoryInfo({
- directory: root,
- });
- if (!exists) {
- throw new ConvertError(
- `Could not find directory at ${workspaceRoot}. Ensure the directory exists.`,
- {
- type: "invalid_directory",
- }
- );
- }
-
- for (const { detect, read } of Object.values(managers)) {
- if (await detect({ workspaceRoot })) {
- return read({ workspaceRoot });
- }
- }
-
- throw new ConvertError(
- "Could not determine package manager. Add `packageManager` to `package.json` or ensure a lockfile is present.",
- {
- type: "package_manager-unable_to_detect",
- }
- );
-}
diff --git a/packages/turbo-workspaces/src/index.ts b/packages/turbo-workspaces/src/index.ts
deleted file mode 100644
index c7fc6b8..0000000
--- a/packages/turbo-workspaces/src/index.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { getAvailablePackageManagers } from "@turbo/utils";
-import getWorkspaceDetails from "./getWorkspaceDetails";
-import { convertProject } from "./convert";
-import { Logger } from "./logger";
-import install, { getPackageManagerMeta } from "./install";
-import { ConvertError } from "./errors";
-import MANAGERS from "./managers";
-
-import type {
- PackageManager,
- Options,
- InstallArgs,
- Workspace,
- Project,
-} from "./types";
-import type { ConvertErrorType } from "./errors";
-
-async function convert({
- root,
- to,
- options,
-}: {
- root: string;
- to: PackageManager;
- options?: Options;
-}) {
- const logger = new Logger({ ...options, interactive: false });
- const [project, availablePackageManagers] = await Promise.all([
- getWorkspaceDetails({ root }),
- getAvailablePackageManagers(),
- ]);
- await convertProject({
- project,
- to: {
- name: to,
- version: availablePackageManagers[to].version as PackageManager,
- },
- logger,
- options,
- });
-}
-
-export type {
- PackageManager,
- Options,
- InstallArgs,
- Workspace,
- Project,
- ConvertErrorType,
-};
-export {
- convert,
- getWorkspaceDetails,
- install,
- MANAGERS,
- getPackageManagerMeta,
- ConvertError,
-};
diff --git a/packages/turbo-workspaces/src/install.ts b/packages/turbo-workspaces/src/install.ts
deleted file mode 100644
index ad5f741..0000000
--- a/packages/turbo-workspaces/src/install.ts
+++ /dev/null
@@ -1,125 +0,0 @@
-import execa from "execa";
-import ora from "ora";
-import { satisfies } from "semver";
-import { ConvertError } from "./errors";
-import { Logger } from "./logger";
-import {
- PackageManager,
- PackageManagerDetails,
- PackageManagerInstallDetails,
- InstallArgs,
-} from "./types";
-
-export const PACKAGE_MANAGERS: Record<
- PackageManager,
- Array<PackageManagerInstallDetails>
-> = {
- npm: [
- {
- name: "npm",
- template: "npm",
- command: "npm",
- installArgs: ["install"],
- version: "latest",
- executable: "npx",
- semver: "*",
- default: true,
- },
- ],
- pnpm: [
- {
- name: "pnpm6",
- template: "pnpm",
- command: "pnpm",
- installArgs: ["install"],
- version: "latest-6",
- executable: "pnpx",
- semver: "6.x",
- },
- {
- name: "pnpm",
- template: "pnpm",
- command: "pnpm",
- installArgs: ["install"],
- version: "latest",
- executable: "pnpm dlx",
- semver: ">=7",
- default: true,
- },
- ],
- yarn: [
- {
- name: "yarn",
- template: "yarn",
- command: "yarn",
- installArgs: ["install"],
- version: "1.x",
- executable: "npx",
- semver: "<2",
- default: true,
- },
- {
- name: "berry",
- template: "berry",
- command: "yarn",
- installArgs: ["install", "--no-immutable"],
- version: "stable",
- executable: "yarn dlx",
- semver: ">=2",
- },
- ],
-};
-
-export function getPackageManagerMeta(packageManager: PackageManagerDetails) {
- const { version, name } = packageManager;
- if (version) {
- return PACKAGE_MANAGERS[name].find((manager) =>
- satisfies(version, manager.semver)
- );
- } else {
- return PACKAGE_MANAGERS[name].find((manager) => {
- return manager.default;
- });
- }
-}
-
-export default async function install(args: InstallArgs) {
- const { to, logger, options } = args;
-
- const installLogger = logger ?? new Logger(options);
- const packageManager = getPackageManagerMeta(to);
-
- if (!packageManager) {
- throw new ConvertError("Unsupported package manager version.", {
- type: "package_manager-unsupported_version",
- });
- }
-
- installLogger.subStep(
- `running "${packageManager.command} ${packageManager.installArgs}"`
- );
- if (!options?.dry) {
- let spinner;
- if (installLogger?.interactive) {
- spinner = ora({
- text: "installing dependencies...",
- spinner: {
- frames: installLogger.installerFrames(),
- },
- }).start();
- }
-
- try {
- await execa(packageManager.command, packageManager.installArgs, {
- cwd: args.project.paths.root,
- });
- if (spinner) {
- spinner.stop();
- }
- installLogger.subStep(`dependencies installed`);
- } catch (err) {
- installLogger.subStepFailure(`failed to install dependencies`);
- throw err;
- }
- }
-}
diff --git a/packages/turbo-workspaces/src/logger.ts b/packages/turbo-workspaces/src/logger.ts
deleted file mode 100644
index 222c89a..0000000
--- a/packages/turbo-workspaces/src/logger.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import chalk from "chalk";
-import gradient from "gradient-string";
-
-const INDENTATION = 2;
-
-export class Logger {
- interactive: boolean;
- dry: boolean;
- step: number;
-
- constructor({
- interactive,
- dry,
- }: { interactive?: boolean; dry?: boolean } = {}) {
- this.interactive = interactive ?? true;
- this.dry = dry ?? false;
- this.step = 1;
- }
-
- logger(...args: any[]) {
- if (this.interactive) {
- console.log(...args);
- }
- }
-
- indented(level: number, ...args: any[]) {
- this.logger(" ".repeat(INDENTATION * level), ...args);
- }
-
- header(title: string) {
- this.blankLine();
- this.logger(chalk.bold(title));
- }
-
- installerFrames() {
- const prefix = `${" ".repeat(INDENTATION)} - ${
- this.dry ? chalk.yellow("SKIPPED | ") : chalk.green("OK | ")
- }`;
- return [`${prefix} `, `${prefix}> `, `${prefix}>> `, `${prefix}>>>`];
- }
-
- gradient(text: string | number) {
- const turboGradient = gradient("#0099F7", "#F11712");
- return turboGradient(text.toString());
- }
-
- hero() {
- this.logger(chalk.bold(this.gradient(`\n>>> TURBOREPO\n`)));
- }
-
- info(...args: any[]) {
- this.logger(...args);
- }
-
- mainStep(title: string) {
- this.blankLine();
- this.logger(`${this.step}. ${chalk.underline(title)}`);
- this.step += 1;
- }
-
- subStep(...args: any[]) {
- this.logger(
- " ".repeat(INDENTATION),
- `-`,
- this.dry ? chalk.yellow("SKIPPED |") : chalk.green("OK |"),
- ...args
- );
- }
-
- subStepFailure(...args: any[]) {
- this.logger(" ".repeat(INDENTATION), `-`, chalk.red("ERROR |"), ...args);
- }
-
- rootHeader() {
- this.blankLine();
- this.indented(2, "Root:");
- }
-
- rootStep(...args: any[]) {
- this.logger(
- " ".repeat(INDENTATION * 3),
- `-`,
- this.dry ? chalk.yellow("SKIPPED |") : chalk.green("OK |"),
- ...args
- );
- }
-
- workspaceHeader() {
- this.blankLine();
- this.indented(2, "Workspaces:");
- }
-
- workspaceStep(...args: any[]) {
- this.logger(
- " ".repeat(INDENTATION * 3),
- `-`,
- this.dry ? chalk.yellow("SKIPPED |") : chalk.green("OK |"),
- ...args
- );
- }
-
- blankLine() {
- this.logger();
- }
-
- error(...args: any[]) {
- console.error(...args);
- }
-}
diff --git a/packages/turbo-workspaces/src/managers/index.ts b/packages/turbo-workspaces/src/managers/index.ts
deleted file mode 100644
index e026aed..0000000
--- a/packages/turbo-workspaces/src/managers/index.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import pnpm from "./pnpm";
-import npm from "./npm";
-import yarn from "./yarn";
-import { ManagerHandler, PackageManager } from "../types";
-
-const MANAGERS: Record<PackageManager, ManagerHandler> = {
- pnpm,
- yarn,
- npm,
-};
-export default MANAGERS;
diff --git a/packages/turbo-workspaces/src/managers/npm.ts b/packages/turbo-workspaces/src/managers/npm.ts
deleted file mode 100644
index 26fd76a..0000000
--- a/packages/turbo-workspaces/src/managers/npm.ts
+++ /dev/null
@@ -1,223 +0,0 @@
-import fs from "fs-extra";
-import path from "path";
-import { ConvertError } from "../errors";
-import updateDependencies from "../updateDependencies";
-import {
- DetectArgs,
- ReadArgs,
- CreateArgs,
- RemoveArgs,
- CleanArgs,
- Project,
- ConvertArgs,
- ManagerHandler,
-} from "../types";
-import {
- getMainStep,
- getWorkspaceInfo,
- getPackageJson,
- expandWorkspaces,
- getWorkspacePackageManager,
- expandPaths,
-} from "../utils";
-
-/**
- * Check if a given project is using npm workspaces
- * Verify by checking for the existence of:
- * 1. package-lock.json
- * 2. packageManager field in package.json
- */
-async function detect(args: DetectArgs): Promise<boolean> {
- const lockFile = path.join(args.workspaceRoot, "package-lock.json");
- const packageManager = getWorkspacePackageManager({
- workspaceRoot: args.workspaceRoot,
- });
- return fs.existsSync(lockFile) || packageManager === "npm";
-}
-
-/**
- Read workspace data from npm workspaces into generic format
-*/
-async function read(args: ReadArgs): Promise<Project> {
- const isNpm = await detect(args);
- if (!isNpm) {
- throw new ConvertError("Not an npm project", {
- type: "package_manager-unexpected",
- });
- }
-
- const packageJson = getPackageJson(args);
- const { name, description } = getWorkspaceInfo(args);
- return {
- name,
- description,
- packageManager: "npm",
- paths: expandPaths({
- root: args.workspaceRoot,
- lockFile: "package-lock.json",
- }),
- workspaceData: {
- globs: packageJson.workspaces || [],
- workspaces: expandWorkspaces({
- workspaceGlobs: packageJson.workspaces,
- ...args,
- }),
- },
- };
-}
-
-/**
- * Create npm workspaces from generic format
- *
- * Creating npm workspaces involves:
- * 1. Adding the workspaces field in package.json
- * 2. Setting the packageManager field in package.json
- * 3. Updating all workspace package.json dependencies to ensure correct format
- */
-async function create(args: CreateArgs): Promise<void> {
- const { project, options, to, logger } = args;
- const hasWorkspaces = project.workspaceData.globs.length > 0;
-
- logger.mainStep(
- getMainStep({ packageManager: "npm", action: "create", project })
- );
- const packageJson = getPackageJson({ workspaceRoot: project.paths.root });
- logger.rootHeader();
-
- // package manager
- logger.rootStep(
- `adding "packageManager" field to ${path.relative(
- project.paths.root,
- project.paths.packageJson
- )}`
- );
- packageJson.packageManager = `${to.name}@${to.version}`;
-
- if (hasWorkspaces) {
- // workspaces field
- logger.rootStep(
- `adding "workspaces" field to ${path.relative(
- project.paths.root,
- project.paths.packageJson
- )}`
- );
- packageJson.workspaces = project.workspaceData.globs;
-
- // write package.json here instead of deferring to avoid negating the changes made by updateDependencies
- if (!options?.dry) {
- fs.writeJSONSync(project.paths.packageJson, packageJson, { spaces: 2 });
- }
-
- // root dependencies
- updateDependencies({
- workspace: { name: "root", paths: project.paths },
- project,
- to,
- logger,
- options,
- });
-
- // workspace dependencies
- logger.workspaceHeader();
- project.workspaceData.workspaces.forEach((workspace) =>
- updateDependencies({ workspace, project, to, logger, options })
- );
- } else {
- if (!options?.dry) {
- fs.writeJSONSync(project.paths.packageJson, packageJson, { spaces: 2 });
- }
- }
-}
-
-/**
- * Remove npm workspace data
- * Removing npm workspaces involves:
- * 1. Removing the workspaces field from package.json
- * 2. Removing the node_modules directory
- */
-async function remove(args: RemoveArgs): Promise<void> {
- const { project, logger, options } = args;
- const hasWorkspaces = project.workspaceData.globs.length > 0;
-
- logger.mainStep(
- getMainStep({ packageManager: "npm", action: "remove", project })
- );
- const packageJson = getPackageJson({ workspaceRoot: project.paths.root });
-
- if (hasWorkspaces) {
- logger.subStep(
- `removing "workspaces" field in ${project.name} root "package.json"`
- );
- delete packageJson.workspaces;
- }
-
- logger.subStep(
- `removing "packageManager" field in ${project.name} root "package.json"`
- );
- delete packageJson.packageManager;
-
- if (!options?.dry) {
- fs.writeJSONSync(project.paths.packageJson, packageJson, { spaces: 2 });
-
- // collect all workspace node_modules directories
- const allModulesDirs = [
- project.paths.nodeModules,
- ...project.workspaceData.workspaces.map((w) => w.paths.nodeModules),
- ];
- try {
- logger.subStep(`removing "node_modules"`);
- await Promise.all(
- allModulesDirs.map((dir) =>
- fs.rm(dir, { recursive: true, force: true })
- )
- );
- } catch (err) {
- throw new ConvertError("Failed to remove node_modules", {
- type: "error_removing_node_modules",
- });
- }
- }
-}
-
-/**
- * Clean is called post install, and is used to clean up any files
- * from this package manager that were needed for install,
- * but not required after migration
- */
-async function clean(args: CleanArgs): Promise<void> {
- const { project, logger, options } = args;
-
- logger.subStep(
- `removing ${path.relative(project.paths.root, project.paths.lockfile)}`
- );
- if (!options?.dry) {
- fs.rmSync(project.paths.lockfile, { force: true });
- }
-}
-
-/**
- * Attempts to convert an existing, non npm lockfile to an npm lockfile
- *
- * If this is not possible, the non npm lockfile is removed
- */
-async function convertLock(args: ConvertArgs): Promise<void> {
- const { project, options } = args;
-
- if (project.packageManager !== "npm") {
- // remove the lockfile
- if (!options?.dry) {
- fs.rmSync(project.paths.lockfile, { force: true });
- }
- }
-}
-
-const npm: ManagerHandler = {
- detect,
- read,
- create,
- remove,
- clean,
- convertLock,
-};
-
-export default npm;
diff --git a/packages/turbo-workspaces/src/managers/pnpm.ts b/packages/turbo-workspaces/src/managers/pnpm.ts
deleted file mode 100644
index 747e578..0000000
--- a/packages/turbo-workspaces/src/managers/pnpm.ts
+++ /dev/null
@@ -1,238 +0,0 @@
-import fs from "fs-extra";
-import path from "path";
-import execa from "execa";
-import { ConvertError } from "../errors";
-import updateDependencies from "../updateDependencies";
-import {
- DetectArgs,
- ReadArgs,
- CreateArgs,
- RemoveArgs,
- ConvertArgs,
- CleanArgs,
- Project,
- ManagerHandler,
-} from "../types";
-import {
- getMainStep,
- expandPaths,
- getWorkspaceInfo,
- expandWorkspaces,
- getPnpmWorkspaces,
- getPackageJson,
- getWorkspacePackageManager,
-} from "../utils";
-
-/**
- * Check if a given project is using pnpm workspaces
- * Verify by checking for the existence of:
- * 1. pnpm-workspace.yaml
- * 2. pnpm-workspace.yaml
- */
-async function detect(args: DetectArgs): Promise<boolean> {
- const lockFile = path.join(args.workspaceRoot, "pnpm-lock.yaml");
- const workspaceFile = path.join(args.workspaceRoot, "pnpm-workspace.yaml");
- const packageManager = getWorkspacePackageManager({
- workspaceRoot: args.workspaceRoot,
- });
- return (
- fs.existsSync(lockFile) ||
- fs.existsSync(workspaceFile) ||
- packageManager === "pnpm"
- );
-}
-
-/**
- Read workspace data from pnpm workspaces into generic format
-*/
-async function read(args: ReadArgs): Promise<Project> {
- const isPnpm = await detect(args);
- if (!isPnpm) {
- throw new ConvertError("Not a pnpm project", {
- type: "package_manager-unexpected",
- });
- }
-
- const { name, description } = getWorkspaceInfo(args);
- return {
- name,
- description,
- packageManager: "pnpm",
- paths: expandPaths({
- root: args.workspaceRoot,
- lockFile: "pnpm-lock.yaml",
- workspaceConfig: "pnpm-workspace.yaml",
- }),
- workspaceData: {
- globs: getPnpmWorkspaces(args),
- workspaces: expandWorkspaces({
- workspaceGlobs: getPnpmWorkspaces(args),
- ...args,
- }),
- },
- };
-}
-
-/**
- * Create pnpm workspaces from generic format
- *
- * Creating pnpm workspaces involves:
- * 1. Create pnpm-workspace.yaml
- * 2. Setting the packageManager field in package.json
- * 3. Updating all workspace package.json dependencies to ensure correct format
- */
-async function create(args: CreateArgs): Promise<void> {
- const { project, to, logger, options } = args;
- const hasWorkspaces = project.workspaceData.globs.length > 0;
-
- logger.mainStep(
- getMainStep({ action: "create", packageManager: "pnpm", project })
- );
-
- const packageJson = getPackageJson({ workspaceRoot: project.paths.root });
- logger.rootHeader();
- packageJson.packageManager = `${to.name}@${to.version}`;
- logger.rootStep(
- `adding "packageManager" field to ${project.name} root "package.json"`
- );
-
- // write the changes
- if (!options?.dry) {
- fs.writeJSONSync(project.paths.packageJson, packageJson, { spaces: 2 });
-
- if (hasWorkspaces) {
- logger.rootStep(`adding "pnpm-workspace.yaml"`);
- fs.writeFileSync(
- path.join(project.paths.root, "pnpm-workspace.yaml"),
- `packages:\n${project.workspaceData.globs
- .map((w) => ` - "${w}"`)
- .join("\n")}`
- );
- }
- }
-
- if (hasWorkspaces) {
- // root dependencies
- updateDependencies({
- workspace: { name: "root", paths: project.paths },
- project,
- to,
- logger,
- options,
- });
-
- // workspace dependencies
- logger.workspaceHeader();
- project.workspaceData.workspaces.forEach((workspace) =>
- updateDependencies({ workspace, project, to, logger, options })
- );
- }
-}
-
-/**
- * Remove pnpm workspace data
- *
- * Cleaning up from pnpm involves:
- * 1. Removing the pnpm-workspace.yaml file
- * 2. Removing the pnpm-lock.yaml file
- * 3. Removing the node_modules directory
- */
-async function remove(args: RemoveArgs): Promise<void> {
- const { project, logger, options } = args;
- const hasWorkspaces = project.workspaceData.globs.length > 0;
-
- logger.mainStep(
- getMainStep({ action: "remove", packageManager: "pnpm", project })
- );
- const packageJson = getPackageJson({ workspaceRoot: project.paths.root });
-
- if (project.paths.workspaceConfig && hasWorkspaces) {
- logger.subStep(`removing "pnpm-workspace.yaml"`);
- if (!options?.dry) {
- fs.rmSync(project.paths.workspaceConfig, { force: true });
- }
- }
-
- logger.subStep(
- `removing "packageManager" field in ${project.name} root "package.json"`
- );
- delete packageJson.packageManager;
-
- if (!options?.dry) {
- fs.writeJSONSync(project.paths.packageJson, packageJson, { spaces: 2 });
-
- // collect all workspace node_modules directories
- const allModulesDirs = [
- project.paths.nodeModules,
- ...project.workspaceData.workspaces.map((w) => w.paths.nodeModules),
- ];
-
- try {
- logger.subStep(`removing "node_modules"`);
- await Promise.all(
- allModulesDirs.map((dir) =>
- fs.rm(dir, { recursive: true, force: true })
- )
- );
- } catch (err) {
- throw new ConvertError("Failed to remove node_modules", {
- type: "error_removing_node_modules",
- });
- }
- }
-}
-
-/**
- * Clean is called post install, and is used to clean up any files
- * from this package manager that were needed for install,
- * but not required after migration
- */
-async function clean(args: CleanArgs): Promise<void> {
- const { project, logger, options } = args;
-
- logger.subStep(
- `removing ${path.relative(project.paths.root, project.paths.lockfile)}`
- );
- if (!options?.dry) {
- fs.rmSync(project.paths.lockfile, { force: true });
- }
-}
-
-/**
- * Attempts to convert an existing, non pnpm lockfile to a pnpm lockfile
- *
- * If this is not possible, the non pnpm lockfile is removed
- */
-async function convertLock(args: ConvertArgs): Promise<void> {
- const { project, logger, options } = args;
-
- if (project.packageManager !== "pnpm") {
- logger.subStep(
- `converting ${path.relative(
- project.paths.root,
- project.paths.lockfile
- )} to pnpm-lock.yaml`
- );
- if (!options?.dry && fs.existsSync(project.paths.lockfile)) {
- try {
- await execa("pnpm", ["import"], {
- stdio: "ignore",
- cwd: project.paths.root,
- });
- } finally {
- fs.rmSync(project.paths.lockfile, { force: true });
- }
- }
- }
-}
-
-const pnpm: ManagerHandler = {
- detect,
- read,
- create,
- remove,
- clean,
- convertLock,
-};
-
-export default pnpm;
diff --git a/packages/turbo-workspaces/src/managers/yarn.ts b/packages/turbo-workspaces/src/managers/yarn.ts
deleted file mode 100644
index 9bef53f..0000000
--- a/packages/turbo-workspaces/src/managers/yarn.ts
+++ /dev/null
@@ -1,222 +0,0 @@
-import fs from "fs-extra";
-import path from "path";
-import { ConvertError } from "../errors";
-import updateDependencies from "../updateDependencies";
-import {
- DetectArgs,
- ReadArgs,
- CreateArgs,
- RemoveArgs,
- ConvertArgs,
- CleanArgs,
- Project,
-} from "../types";
-import {
- getMainStep,
- getWorkspaceInfo,
- getPackageJson,
- expandPaths,
- expandWorkspaces,
- getWorkspacePackageManager,
-} from "../utils";
-
-/**
- * Check if a given project is using yarn workspaces
- * Verify by checking for the existence of:
- * 1. yarn.lock
- * 2. packageManager field in package.json
- */
-async function detect(args: DetectArgs): Promise<boolean> {
- const lockFile = path.join(args.workspaceRoot, "yarn.lock");
- const packageManager = getWorkspacePackageManager({
- workspaceRoot: args.workspaceRoot,
- });
- return fs.existsSync(lockFile) || packageManager === "yarn";
-}
-
-/**
- Read workspace data from yarn workspaces into generic format
-*/
-async function read(args: ReadArgs): Promise<Project> {
- const isYarn = await detect(args);
- if (!isYarn) {
- throw new ConvertError("Not a yarn project", {
- type: "package_manager-unexpected",
- });
- }
-
- const packageJson = getPackageJson(args);
- const { name, description } = getWorkspaceInfo(args);
- return {
- name,
- description,
- packageManager: "yarn",
- paths: expandPaths({
- root: args.workspaceRoot,
- lockFile: "yarn.lock",
- }),
- workspaceData: {
- globs: packageJson.workspaces || [],
- workspaces: expandWorkspaces({
- workspaceGlobs: packageJson.workspaces,
- ...args,
- }),
- },
- };
-}
-
-/**
- * Create yarn workspaces from generic format
- *
- * Creating yarn workspaces involves:
- * 1. Adding the workspaces field in package.json
- * 2. Setting the packageManager field in package.json
- * 3. Updating all workspace package.json dependencies to ensure correct format
- */
-async function create(args: CreateArgs): Promise<void> {
- const { project, to, logger, options } = args;
- const hasWorkspaces = project.workspaceData.globs.length > 0;
-
- logger.mainStep(
- getMainStep({ packageManager: "yarn", action: "create", project })
- );
- const packageJson = getPackageJson({ workspaceRoot: project.paths.root });
- logger.rootHeader();
-
- // package manager
- logger.rootStep(
- `adding "packageManager" field to ${path.relative(
- project.paths.root,
- project.paths.packageJson
- )}`
- );
- packageJson.packageManager = `${to.name}@${to.version}`;
-
- if (hasWorkspaces) {
- // workspaces field
- logger.rootStep(
- `adding "workspaces" field to ${path.relative(
- project.paths.root,
- project.paths.packageJson
- )}`
- );
- packageJson.workspaces = project.workspaceData.globs;
-
- if (!options?.dry) {
- fs.writeJSONSync(project.paths.packageJson, packageJson, { spaces: 2 });
- }
-
- // root dependencies
- updateDependencies({
- workspace: { name: "root", paths: project.paths },
- project,
- to,
- logger,
- options,
- });
-
- // workspace dependencies
- logger.workspaceHeader();
- project.workspaceData.workspaces.forEach((workspace) =>
- updateDependencies({ workspace, project, to, logger, options })
- );
- } else {
- if (!options?.dry) {
- fs.writeJSONSync(project.paths.packageJson, packageJson, { spaces: 2 });
- }
- }
-}
-
-/**
- * Remove yarn workspace data
- *
- * Removing yarn workspaces involves:
- * 1. Removing the workspaces field from package.json
- * 2. Removing the node_modules directory
- */
-async function remove(args: RemoveArgs): Promise<void> {
- const { project, logger, options } = args;
- const hasWorkspaces = project.workspaceData.globs.length > 0;
-
- logger.mainStep(
- getMainStep({ packageManager: "yarn", action: "remove", project })
- );
- const packageJson = getPackageJson({ workspaceRoot: project.paths.root });
-
- if (hasWorkspaces) {
- logger.subStep(
- `removing "workspaces" field in ${project.name} root "package.json"`
- );
- delete packageJson.workspaces;
- }
-
- logger.subStep(
- `removing "packageManager" field in ${project.name} root "package.json"`
- );
- delete packageJson.packageManager;
-
- if (!options?.dry) {
- fs.writeJSONSync(project.paths.packageJson, packageJson, { spaces: 2 });
-
- // collect all workspace node_modules directories
- const allModulesDirs = [
- project.paths.nodeModules,
- ...project.workspaceData.workspaces.map((w) => w.paths.nodeModules),
- ];
- try {
- logger.subStep(`removing "node_modules"`);
- await Promise.all(
- allModulesDirs.map((dir) =>
- fs.rm(dir, { recursive: true, force: true })
- )
- );
- } catch (err) {
- throw new ConvertError("Failed to remove node_modules", {
- type: "error_removing_node_modules",
- });
- }
- }
-}
-
-/**
- * Clean is called post install, and is used to clean up any files
- * from this package manager that were needed for install,
- * but not required after migration
- */
-async function clean(args: CleanArgs): Promise<void> {
- const { project, logger, options } = args;
-
- logger.subStep(
- `removing ${path.relative(project.paths.root, project.paths.lockfile)}`
- );
- if (!options?.dry) {
- fs.rmSync(project.paths.lockfile, { force: true });
- }
-}
-
-/**
- * Attempts to convert an existing, non yarn lockfile to a yarn lockfile
- *
- * If this is not possible, the non yarn lockfile is removed
- */
-async function convertLock(args: ConvertArgs): Promise<void> {
- const { project, options } = args;
-
- if (project.packageManager !== "yarn") {
- // remove the lockfile
- if (!options?.dry) {
- fs.rmSync(project.paths.lockfile, { force: true });
- }
- }
-}
-
-const yarn = {
- detect,
- read,
- create,
- remove,
- clean,
- convertLock,
-};
-
-export default yarn;
diff --git a/packages/turbo-workspaces/src/types.ts b/packages/turbo-workspaces/src/types.ts
deleted file mode 100644
index 9240f09..0000000
--- a/packages/turbo-workspaces/src/types.ts
+++ /dev/null
@@ -1,127 +0,0 @@
-import { Logger } from "./logger";
-
-export type PackageManager = "npm" | "pnpm" | "yarn";
-export type PackageManagerDetails = {
- name: PackageManager;
- version?: string;
-};
-
-export type Project = {
- name: string;
- description?: string;
- packageManager: PackageManager;
- paths: {
- root: string;
- packageJson: string;
- lockfile: string;
- nodeModules: string;
- // pnpm workspace config file
- workspaceConfig?: string;
- };
- workspaceData: {
- globs: Array<string>;
- workspaces: Array<Workspace>;
- };
-};
-
-export type Workspace = {
- name: string;
- description?: string;
- paths: {
- root: string;
- packageJson: string;
- nodeModules: string;
- };
-};
-
-export type WorkspaceInfo = Pick<Workspace, "name" | "description">;
-
-export type DependencyList = Record<string, string>;
-
-export type PackageJsonDependencies = {
- dependencies?: DependencyList;
- devDependencies?: DependencyList;
- peerDependencies?: DependencyList;
- optionalDependencies?: DependencyList;
-};
-
-export type PackageJson = PackageJsonDependencies & {
- name?: string;
- description?: string;
- workspaces?: Array<string>;
- packageManager?: string;
-};
-
-export type DetectArgs = {
- workspaceRoot: string;
-};
-
-export type ReadArgs = {
- workspaceRoot: string;
-};
-
-export type CreateArgs = {
- project: Project;
- to: PackageManagerDetails;
- logger: Logger;
- options?: Options;
-};
-
-export type RemoveArgs = {
- project: Project;
- to: PackageManagerDetails;
- logger: Logger;
- options?: Options;
-};
-
-export type CleanArgs = {
- project: Project;
- logger: Logger;
- options?: Options;
-};
-
-export type ConvertArgs = {
- project: Project;
- logger: Logger;
- options?: Options;
-};
-
-export type InstallArgs = {
- project: Project;
- to: PackageManagerDetails;
- logger?: Logger;
- options?: Options;
-};
-
-export type Options = {
- dry?: boolean;
- skipInstall?: boolean;
- interactive?: boolean;
-};
-
-export type PackageManagerInstallDetails = {
- name: string;
- template: string;
- command: PackageManager;
- installArgs: string[];
- version: string;
- executable: string;
- semver: string;
- default?: boolean;
-};
-
-export type ManagerDetect = (args: DetectArgs) => Promise<boolean>;
-export type ManagerRead = (args: ReadArgs) => Promise<Project>;
-export type ManagerCreate = (args: CreateArgs) => Promise<void>;
-export type ManagerRemove = (args: RemoveArgs) => Promise<void>;
-export type ManagerClean = (args: CleanArgs) => Promise<void>;
-export type ManagerConvert = (args: ConvertArgs) => Promise<void>;
-
-export type ManagerHandler = {
- detect: ManagerDetect;
- read: ManagerRead;
- create: ManagerCreate;
- remove: ManagerRemove;
- clean: ManagerClean;
- convertLock: ManagerConvert;
-};
diff --git a/packages/turbo-workspaces/src/updateDependencies.ts b/packages/turbo-workspaces/src/updateDependencies.ts
deleted file mode 100644
index 5461ed0..0000000
--- a/packages/turbo-workspaces/src/updateDependencies.ts
+++ /dev/null
@@ -1,135 +0,0 @@
-import fs from "fs-extra";
-import chalk from "chalk";
-import path from "path";
-import {
- Project,
- Workspace,
- DependencyList,
- PackageManagerDetails,
- Options,
- PackageJsonDependencies,
-} from "./types";
-import { Logger } from "./logger";
-import { getPackageJson } from "./utils";
-
-function updateDependencyList({
- dependencyList,
- project,
- to,
-}: {
- dependencyList: DependencyList;
- project: Project;
- to: PackageManagerDetails;
-}): { dependencyList: DependencyList; updated: Array<string> } {
- const updated: Array<string> = [];
- project.workspaceData.workspaces.forEach((workspace) => {
- const { name } = workspace;
- if (dependencyList[name]) {
- const workspaceVersion = dependencyList[name];
- const version = workspaceVersion.startsWith("workspace:")
- ? workspaceVersion.slice("workspace:".length)
- : workspaceVersion;
- dependencyList[name] =
- to.name === "pnpm" ? `workspace:${version}` : version;
- updated.push(name);
- }
- });
-
- return { dependencyList, updated };
-}
-
-export default function updateDependencies({
- project,
- workspace,
- to,
- logger,
- options,
-}: {
- workspace: Workspace;
- project: Project;
- to: PackageManagerDetails;
- logger: Logger;
- options?: Options;
-}): void {
- // this step isn't required if moving between yarn / npm
- if (
- ["yarn", "npm"].includes(to.name) &&
- ["yarn", "npm"].includes(project.packageManager)
- ) {
- return;
- }
-
- // update all dependencies
- const workspacePackageJson = getPackageJson({
- workspaceRoot: workspace.paths.root,
- });
-
- // collect stats as we go for consolidated output at the end
- const stats: Record<keyof PackageJsonDependencies, Array<string>> = {
- dependencies: [],
- devDependencies: [],
- peerDependencies: [],
- optionalDependencies: [],
- };
-
- const allDependencyKeys: Array<keyof PackageJsonDependencies> = [
- "dependencies",
- "devDependencies",
- "peerDependencies",
- "optionalDependencies",
- ];
-
- allDependencyKeys.forEach((depKey) => {
- const depList = workspacePackageJson[depKey];
- if (depList) {
- const { updated, dependencyList } = updateDependencyList({
- dependencyList: depList,
- project,
- to,
- });
-
- workspacePackageJson[depKey] = dependencyList;
- stats[depKey] = updated;
- }
- });
-
- const toLog = (key: keyof PackageJsonDependencies) => {
- const total = stats[key].length;
- if (total > 0) {
- return `${chalk.green(total.toString())} ${key}`;
- }
- return undefined;
- };
-
- const allChanges = allDependencyKeys.map(toLog).filter(Boolean);
- const workspaceLocation = `./${path.relative(
- project.paths.root,
- workspace.paths.packageJson
- )}`;
- if (allChanges.length >= 1) {
- let logLine = "updating";
- allChanges.forEach((stat, idx) => {
- if (allChanges.length === 1) {
- logLine += ` ${stat} in ${workspaceLocation}`;
- } else {
- if (idx === allChanges.length - 1) {
- logLine += `and ${stat} in ${workspaceLocation}`;
- } else {
- logLine += ` ${stat}, `;
- }
- }
- });
-
- logger.workspaceStep(logLine);
- } else {
- logger.workspaceStep(
- `no workspace dependencies found in ${workspaceLocation}`
- );
- }
-
- if (!options?.dry) {
- fs.writeJSONSync(workspace.paths.packageJson, workspacePackageJson, {
- spaces: 2,
- });
- }
-}
diff --git a/packages/turbo-workspaces/src/utils.ts b/packages/turbo-workspaces/src/utils.ts
deleted file mode 100644
index 8290203..0000000
--- a/packages/turbo-workspaces/src/utils.ts
+++ /dev/null
@@ -1,197 +0,0 @@
-import fs from "fs-extra";
-import path from "path";
-import glob from "fast-glob";
-import yaml from "js-yaml";
-import {
- PackageJson,
- PackageManager,
- Project,
- Workspace,
- WorkspaceInfo,
-} from "./types";
-import { ConvertError } from "./errors";
-
-// adapted from https://github.com/nodejs/corepack/blob/cae770694e62f15fed33dd8023649d77d96023c1/sources/specUtils.ts#L14
-const PACKAGE_MANAGER_REGEX = /^(?!_)(.+)@(.+)$/;
-
-function getPackageJson({
- workspaceRoot,
-}: {
- workspaceRoot: string;
-}): PackageJson {
- const packageJsonPath = path.join(workspaceRoot, "package.json");
- try {
- return fs.readJsonSync(packageJsonPath, "utf8");
- } catch (err) {
- if (err && typeof err === "object" && "code" in err) {
- if (err.code === "ENOENT") {
- throw new ConvertError(`no "package.json" found at ${workspaceRoot}`, {
- type: "package_json-missing",
- });
- }
- if (err.code === "EJSONPARSE") {
- throw new ConvertError(
- `failed to parse "package.json" at ${workspaceRoot}`,
- {
- type: "package_json-parse_error",
- }
- );
- }
- }
- throw new Error(
- `unexpected error reading "package.json" at ${workspaceRoot}`
- );
- }
-}
-
-function getWorkspacePackageManager({
- workspaceRoot,
-}: {
- workspaceRoot: string;
-}): string | undefined {
- const { packageManager } = getPackageJson({ workspaceRoot });
- if (packageManager) {
- try {
- const match = packageManager.match(PACKAGE_MANAGER_REGEX);
- if (match) {
- const [_, manager] = match;
- return manager;
- }
- } catch (err) {
- // this won't always exist.
- }
- }
- return undefined;
-}
-
-function getWorkspaceInfo({
- workspaceRoot,
-}: {
- workspaceRoot: string;
-}): WorkspaceInfo {
- const packageJson = getPackageJson({ workspaceRoot });
- const workspaceDirectory = path.basename(workspaceRoot);
-
- const { name = workspaceDirectory, description } = packageJson;
-
- return {
- name,
- description,
- };
-}
-
-function getPnpmWorkspaces({
- workspaceRoot,
-}: {
- workspaceRoot: string;
-}): Array<string> {
- const workspaceFile = path.join(workspaceRoot, "pnpm-workspace.yaml");
- if (fs.existsSync(workspaceFile)) {
- try {
- const workspaceConfig = yaml.load(fs.readFileSync(workspaceFile, "utf8"));
- // validate it's the type we expect
- if (
- workspaceConfig instanceof Object &&
- "packages" in workspaceConfig &&
- Array.isArray(workspaceConfig.packages)
- ) {
- return workspaceConfig.packages as Array<string>;
- }
- } catch (err) {
- throw new ConvertError(`failed to parse ${workspaceFile}`, {
- type: "pnpm-workspace_parse_error",
- });
- }
- }
-
- return [];
-}
-
-function expandPaths({
- root,
- lockFile,
- workspaceConfig,
-}: {
- root: string;
- lockFile: string;
- workspaceConfig?: string;
-}) {
- const fromRoot = (p: string) => path.join(root, p);
- const paths: Project["paths"] = {
- root,
- lockfile: fromRoot(lockFile),
- packageJson: fromRoot("package.json"),
- nodeModules: fromRoot("node_modules"),
- };
-
- if (workspaceConfig) {
- paths.workspaceConfig = fromRoot(workspaceConfig);
- }
-
- return paths;
-}
-
-function expandWorkspaces({
- workspaceRoot,
- workspaceGlobs,
-}: {
- workspaceRoot: string;
- workspaceGlobs?: string[];
-}): Array<Workspace> {
- if (!workspaceGlobs) {
- return [];
- }
- return workspaceGlobs
- .flatMap((workspaceGlob) => {
- const workspacePackageJsonGlob = `${workspaceGlob}/package.json`;
- return glob.sync(workspacePackageJsonGlob, {
- onlyFiles: true,
- absolute: true,
- cwd: workspaceRoot,
- });
- })
- .map((workspacePackageJson) => {
- const workspaceRoot = path.dirname(workspacePackageJson);
- const { name, description } = getWorkspaceInfo({ workspaceRoot });
- return {
- name,
- description,
- paths: {
- root: workspaceRoot,
- packageJson: workspacePackageJson,
- nodeModules: path.join(workspaceRoot, "node_modules"),
- },
- };
- });
-}
-
-function directoryInfo({ directory }: { directory: string }) {
- const dir = path.resolve(process.cwd(), directory);
- return { exists: fs.existsSync(dir), absolute: dir };
-}
-
-function getMainStep({
- packageManager,
- action,
- project,
-}: {
- packageManager: PackageManager;
- action: "create" | "remove";
- project: Project;
-}) {
- const hasWorkspaces = project.workspaceData.globs.length > 0;
- return `${action === "remove" ? "Removing" : "Adding"} ${packageManager} ${
- hasWorkspaces ? "workspaces" : ""
- } ${action === "remove" ? "from" : "to"} ${project.name}`;
-}
-
-export {
- getPackageJson,
- getWorkspacePackageManager,
- getWorkspaceInfo,
- expandPaths,
- expandWorkspaces,
- getPnpmWorkspaces,
- directoryInfo,
- getMainStep,
-};
diff --git a/packages/turbo-workspaces/tsconfig.json b/packages/turbo-workspaces/tsconfig.json
deleted file mode 100644
index 0620a3c..0000000
--- a/packages/turbo-workspaces/tsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "extends": "@turbo/tsconfig/library.json",
- "compilerOptions": {
- "rootDir": "."
- }
-}
diff --git a/packages/turbo-workspaces/tsup.config.ts b/packages/turbo-workspaces/tsup.config.ts
deleted file mode 100644
index 168e1de..0000000
--- a/packages/turbo-workspaces/tsup.config.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { defineConfig, Options } from "tsup";
-
-export default defineConfig((options: Options) => ({
- entry: ["src/index.ts", "src/cli.ts"],
- format: ["cjs"],
- dts: true,
- clean: true,
- minify: true,
- ...options,
-}));
diff --git a/packages/turbo-workspaces/turbo.json b/packages/turbo-workspaces/turbo.json
deleted file mode 100644
index fc0bd3b..0000000
--- a/packages/turbo-workspaces/turbo.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "../../docs/public/schema.json",
- "extends": ["//"],
- "pipeline": {
- "build": {
- "dependsOn": ["^build"]
- }
- }
-}
diff --git a/packages/turbo/.dev-mode b/packages/turbo/.dev-mode
deleted file mode 100644
index c25642e..0000000
--- a/packages/turbo/.dev-mode
+++ /dev/null
@@ -1,3 +0,0 @@
-DO NOT DELETE OR NPM PUBLISH THIS FILE.
-
-Its existence is used by `install.js` to determine if it should attempt to replace the binary with the native executable.
diff --git a/packages/turbo/README.md b/packages/turbo/README.md
deleted file mode 100644
index 97557bc..0000000
--- a/packages/turbo/README.md
+++ /dev/null
@@ -1,54 +0,0 @@
-<p align="center">
- <a href="https://turbo.build/repo">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4060187/196936123-f6e1db90-784d-4174-b774-92502b718836.png">
- <img src="https://user-images.githubusercontent.com/4060187/196936104-5797972c-ab10-4834-bd61-0d1e5f442c9c.png" height="128">
- </picture>
- <h1 align="center">Turborepo</h1>
- </a>
-</p>
-
-<p align="center">
- <a aria-label="Vercel logo" href="https://vercel.com/">
- <img src="https://img.shields.io/badge/MADE%20BY%20Vercel-000000.svg?style=for-the-badge&logo=Vercel&labelColor=000">
- </a>
- <a aria-label="NPM version" href="https://www.npmjs.com/package/turbo">
- <img alt="" src="https://img.shields.io/npm/v/turbo.svg?style=for-the-badge&labelColor=000000">
- </a>
- <a aria-label="License" href="https://github.com/vercel/turbo/blob/main/LICENSE">
- <img alt="" src="https://img.shields.io/npm/l/turbo.svg?style=for-the-badge&labelColor=000000&color=">
- </a>
- <a aria-label="Join the community on GitHub" href="https://github.com/vercel/turbo/discussions">
- <img alt="" src="https://img.shields.io/badge/Join%20the%20community-blueviolet.svg?style=for-the-badge&logo=turborepo&labelColor=000000&logoWidth=20&logoColor=white">
- </a>
-</p>
-
-## Getting Started
-
-Visit https://turbo.build/repo/docs to get started with Turborepo and read the documentation.
-
-## Community
-
-The Turborepo community can be found on [GitHub Discussions](https://github.com/vercel/turbo/discussions), where you can ask questions, voice ideas, and share your projects.
-
-To chat with other community members, you can join the [Turborepo Discord](https://turbo.build/discord)
-
-Our [Code of Conduct](https://github.com/vercel/turbo/blob/main/CODE_OF_CONDUCT.md) applies to all Turborepo community channels.
-
-## Who is using Turbo?
-
-Turbo is used by the world's leading companies. Check out the [Turbo Showcase](https://turbo.build/showcase) to learn more.
-
-## Updates
-
-Follow [@turborepo](https://twitter.com/turborepo) on Twitter and for project updates
-
-## Author
-
-- Jared Palmer ([@jaredpalmer](https://twitter.com/jaredpalmer))
-
-## Security
-
-If you believe you have found a security vulnerability in Turbo, we encourage you to responsibly disclose this and not open a public issue. We will investigate all legitimate reports. Email `security@vercel.com` to disclose any security vulnerabilities.
-
-https://vercel.com/security
diff --git a/packages/turbo/bin/turbo b/packages/turbo/bin/turbo
deleted file mode 100644
index d998261..0000000
--- a/packages/turbo/bin/turbo
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env node
-
-const { generateBinPath } = require("../node-platform");
-
-try {
- require("child_process").execFileSync(
- generateBinPath(),
- process.argv.slice(2),
- { stdio: "inherit" }
- );
-} catch(e) {
- if(e && e.status) process.exit(e.status);
- throw e;
-}
diff --git a/packages/turbo/bump-version.js b/packages/turbo/bump-version.js
deleted file mode 100644
index d3d48d1..0000000
--- a/packages/turbo/bump-version.js
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env node
-
-const fs = require("fs");
-const {
- knownUnixlikePackages,
- knownWindowsPackages,
-} = require("./node-platform");
-
-const pkg = require("./package.json");
-const file = require.resolve("./package.json");
-
-pkg.optionalDependencies = Object.fromEntries(
- Object.values({
- ...knownWindowsPackages,
- ...knownUnixlikePackages,
- })
- .sort()
- .map((x) => [x, pkg.version])
-);
-
-fs.writeFileSync(file, JSON.stringify(pkg, null, 2) + "\n");
diff --git a/packages/turbo/install.js b/packages/turbo/install.js
deleted file mode 100644
index 8b939c4..0000000
--- a/packages/turbo/install.js
+++ /dev/null
@@ -1,331 +0,0 @@
-// Most of this file is ripped from esbuild
-// @see https://github.com/evanw/esbuild/blob/master/lib/npm/node-install.ts
-// This file is MIT licensed.
-
-const nodePlatform = require("./node-platform");
-const fs = require("fs");
-const os = require("os");
-const path = require("path");
-const zlib = require("zlib");
-const https = require("https");
-const child_process = require("child_process");
-const {
- downloadedBinPath,
- TURBO_BINARY_PATH,
- pkgAndSubpathForCurrentPlatform,
-} = nodePlatform;
-const TURBO_VERSION = require("./package.json").version;
-
-const toPath = path.join(__dirname, "bin", "turbo");
-const goToPath = path.join(__dirname, "bin", "go-turbo");
-let isToPathJS = true;
-
-function validateBinaryVersion(...command) {
- command.push("--version");
- // Make sure that we get the version of the binary that was just installed
- command.push("--skip-infer");
- const stdout = child_process
- .execFileSync(command.shift(), command, {
- // Without this, this install script strangely crashes with the error
- // "EACCES: permission denied, write" but only on Ubuntu Linux when node is
- // installed from the Snap Store. This is not a problem when you download
- // the official version of node. The problem appears to be that stderr
- // (i.e. file descriptor 2) isn't writable?
- //
- // More info:
- // - https://snapcraft.io/ (what the Snap Store is)
- // - https://nodejs.org/dist/ (download the official version of node)
- // - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035
- //
- stdio: "pipe",
- })
- .toString()
- .trim();
- if (stdout !== TURBO_VERSION) {
- throw new Error(
- `Expected ${JSON.stringify(TURBO_VERSION)} but got ${JSON.stringify(
- stdout
- )}`
- );
- }
-}
-
-function isYarn() {
- const { npm_config_user_agent } = process.env;
- if (npm_config_user_agent) {
- return /\byarn\//.test(npm_config_user_agent);
- }
- return false;
-}
-
-function fetch(url) {
- return new Promise((resolve, reject) => {
- https
- .get(url, (res) => {
- if (
- (res.statusCode === 301 || res.statusCode === 302) &&
- res.headers.location
- )
- return fetch(res.headers.location).then(resolve, reject);
- if (res.statusCode !== 200)
- return reject(new Error(`Server responded with ${res.statusCode}`));
- let chunks = [];
- res.on("data", (chunk) => chunks.push(chunk));
- res.on("end", () => resolve(Buffer.concat(chunks)));
- })
- .on("error", reject);
- });
-}
-
-function extractFileFromTarGzip(buffer, subpath) {
- try {
- buffer = zlib.unzipSync(buffer);
- } catch (err) {
- throw new Error(
- `Invalid gzip data in archive: ${(err && err.message) || err}`
- );
- }
- let str = (i, n) =>
- String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
- let offset = 0;
- subpath = `package/${subpath}`;
- while (offset < buffer.length) {
- let name = str(offset, 100);
- let size = parseInt(str(offset + 124, 12), 8);
- offset += 512;
- if (!isNaN(size)) {
- if (name === subpath) return buffer.subarray(offset, offset + size);
- offset += (size + 511) & ~511;
- }
- }
- throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
-}
-
-function installUsingNPM(pkg, subpath, binPath) {
- // Erase "npm_config_global" so that "npm install --global turbo" works.
- // Otherwise this nested "npm install" will also be global, and the install
- // will deadlock waiting for the global installation lock.
- const env = { ...process.env, npm_config_global: undefined };
-
- // Create a temporary directory inside the "turbo" package with an empty
- // "package.json" file. We'll use this to run "npm install" in.
- const turboLibDir = path.dirname(require.resolve("turbo"));
- const installDir = path.join(turboLibDir, "npm-install");
- fs.mkdirSync(installDir);
- try {
- fs.writeFileSync(path.join(installDir, "package.json"), "{}");
-
- // Run "npm install" in the temporary directory which should download the
- // desired package. Try to avoid unnecessary log output. This uses the "npm"
- // command instead of a HTTP request so that it hopefully works in situations
- // where HTTP requests are blocked but the "npm" command still works due to,
- // for example, a custom configured npm registry and special firewall rules.
- child_process.execSync(
- `npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${TURBO_VERSION}`,
- { cwd: installDir, stdio: "pipe", env }
- );
-
- // Move the downloaded binary executable into place. The destination path
- // is the same one that the JavaScript API code uses so it will be able to
- // find the binary executable here later.
- const installedBinPath = path.join(
- installDir,
- "node_modules",
- pkg,
- subpath
- );
- fs.renameSync(installedBinPath, binPath);
- } finally {
- // Try to clean up afterward so we don't unnecessarily waste file system
- // space. Leaving nested "node_modules" directories can also be problematic
- // for certain tools that scan over the file tree and expect it to have a
- // certain structure.
- try {
- removeRecursive(installDir);
- } catch {
- // Removing a file or directory can randomly break on Windows, returning
- // EBUSY for an arbitrary length of time. I think this happens when some
- // other program has that file or directory open (e.g. an anti-virus
- // program). This is fine on Unix because the OS just unlinks the entry
- // but keeps the reference around until it's unused. There's nothing we
- // can do in this case so we just leave the directory there.
- }
- }
-}
-
-function removeRecursive(dir) {
- for (const entry of fs.readdirSync(dir)) {
- const entryPath = path.join(dir, entry);
- let stats;
- try {
- stats = fs.lstatSync(entryPath);
- } catch {
- continue; // Guard against https://github.com/nodejs/node/issues/4760
- }
- if (stats.isDirectory()) removeRecursive(entryPath);
- else fs.unlinkSync(entryPath);
- }
- fs.rmSync(dir);
-}
-
-function maybeOptimizePackage(binPath) {
- // Everything else that this installation does is fine, but the optimization
- // step rewrites existing files. We need to make sure that this does not
- // happen during development. We determine that by looking for a file in
- // the package that is not published in the `npm` registry.
- if (fs.existsSync(path.join(__dirname, ".dev-mode"))) {
- return;
- }
-
- // This package contains a "bin/turbo" JavaScript file that finds and runs
- // the appropriate binary executable. However, this means that running the
- // "turbo" command runs another instance of "node" which is way slower than
- // just running the binary executable directly.
- //
- // Here we optimize for this by replacing the JavaScript file with the binary
- // executable at install time. This optimization does not work on Windows
- // because on Windows the binary executable must be called "turbo.exe"
- // instead of "turbo".
- //
- // This also doesn't work with Yarn both because of lack of support for binary
- // files in Yarn 2+ (see https://github.com/yarnpkg/berry/issues/882) and
- // because Yarn (even Yarn 1?) may run the same install scripts in the same
- // place multiple times from different platforms, especially when people use
- // Docker. Avoid idempotency issues by just not optimizing when using Yarn.
- //
- // This optimization also doesn't apply when npm's "--ignore-scripts" flag is
- // used since in that case this install script will not be run.
- if (os.platform() !== "win32" && !isYarn()) {
- const optimizeBin = (from, to, temp) => {
- const tempPath = path.join(__dirname, temp);
- try {
- // First link the binary with a temporary file. If this fails and throws an
- // error, then we'll just end up doing nothing. This uses a hard link to
- // avoid taking up additional space on the file system.
- fs.linkSync(from, tempPath);
-
- // Then use rename to atomically replace the target file with the temporary
- // file. If this fails and throws an error, then we'll just end up leaving
- // the temporary file there, which is harmless.
- fs.renameSync(tempPath, to);
-
- // If we get here, then we know that the target location is now a binary
- // executable instead of a JavaScript file.
- isToPathJS = false;
-
- // If this install script is being re-run, then "renameSync" will fail
- // since the underlying inode is the same (it just returns without doing
- // anything, and without throwing an error). In that case we should remove
- // the file manually.
- fs.unlinkSync(tempPath);
- } catch {
- // Ignore errors here since this optimization is optional
- }
- };
- const goBinPath = path.join(path.dirname(binPath), "go-turbo");
- optimizeBin(goBinPath, goToPath, "bin-go-turbo");
- optimizeBin(binPath, toPath, "bin-turbo");
- }
-}
-
-async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
- // If that fails, the user could have npm configured incorrectly or could not
- // have npm installed. Try downloading directly from npm as a last resort.
- const url = `https://registry.npmjs.org/${pkg}/-/${pkg}-${TURBO_VERSION}.tgz`;
- console.error(`[turbo] Trying to download ${JSON.stringify(url)}`);
- try {
- fs.writeFileSync(
- binPath,
- extractFileFromTarGzip(await fetch(url), subpath)
- );
- fs.chmodSync(binPath, 0o755);
- } catch (e) {
- console.error(
- `[turbo] Failed to download ${JSON.stringify(url)}: ${
- (e && e.message) || e
- }`
- );
- throw e;
- }
-}
-
-async function checkAndPreparePackage() {
- // This feature was added to give external code a way to modify the binary
- // path without modifying the code itself. Do not remove this because
- // external code relies on this (in addition to turbo's own test suite).
- if (TURBO_BINARY_PATH) {
- return;
- }
-
- const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
-
- let binPath;
- try {
- // First check for the binary package from our "optionalDependencies". This
- // package should have been installed alongside this package at install time.
- binPath = require.resolve(`${pkg}/${subpath}`);
- } catch (e) {
- console.error(`[turbo] Failed to find package "${pkg}" on the file system
-
-This can happen if you use the "--no-optional" flag. The "optionalDependencies"
-package.json feature is used by turbo to install the correct binary executable
-for your current platform. This install script will now attempt to work around
-this. If that fails, you need to remove the "--no-optional" flag to use turbo.
-`);
-
- // If that didn't work, then someone probably installed turbo with the
- // "--no-optional" flag. Attempt to compensate for this by downloading the
- // package using a nested call to "npm" instead.
- //
- // THIS MAY NOT WORK. Package installation uses "optionalDependencies" for
- // a reason: manually downloading the package has a lot of obscure edge
- // cases that fail because people have customized their environment in
- // some strange way that breaks downloading. This code path is just here
- // to be helpful but it's not the supported way of installing turbo.
- binPath = downloadedBinPath(pkg, subpath);
- try {
- console.error(`[turbo] Trying to install package "${pkg}" using npm`);
- installUsingNPM(pkg, subpath, binPath);
- } catch (e2) {
- console.error(
- `[turbo] Failed to install package "${pkg}" using npm: ${
- (e2 && e2.message) || e2
- }`
- );
-
- // If that didn't also work, then something is likely wrong with the "npm"
- // command. Attempt to compensate for this by manually downloading the
- // package from the npm registry over HTTP as a last resort.
- try {
- await downloadDirectlyFromNPM(pkg, subpath, binPath);
- } catch (e3) {
- throw new Error(`Failed to install package "${pkg}"`);
- }
- }
- }
-
- maybeOptimizePackage(binPath);
-}
-
-checkAndPreparePackage().then(() => {
- try {
- if (isToPathJS) {
- // We need "node" before this command since it's a JavaScript file
- validateBinaryVersion("node", toPath);
- } else {
- // This is no longer a JavaScript file so don't run it using "node"
- validateBinaryVersion(toPath);
- }
- } catch (err) {
- if (
- process.platform === "linux" &&
- err.message &&
- err.message.includes("ENOENT")
- ) {
- console.error(
- `Error: Failed to run turbo binary, you may need to install glibc compat\nSee https://turbo.build/repo/docs/getting-started/existing-monorepo#install-turbo`
- );
- }
- throw err;
- }
-});
diff --git a/packages/turbo/node-platform.js b/packages/turbo/node-platform.js
deleted file mode 100644
index f65a662..0000000
--- a/packages/turbo/node-platform.js
+++ /dev/null
@@ -1,257 +0,0 @@
-// Most of this file is ripped from esbuild
-// @see https://github.com/evanw/esbuild/blob/master/lib/npm/node-install.ts
-// This file is MIT licensed.
-
-const fs = require("fs");
-const os = require("os");
-const path = require("path");
-
-// This feature was added to give external code a way to modify the binary
-// path without modifying the code itself. Do not remove this because
-// external code relies on this.
-const TURBO_BINARY_PATH = process.env.TURBO_BINARY_PATH;
-
-const packageDarwin_arm64 = "turbo-darwin-arm64";
-const packageDarwin_x64 = "turbo-darwin-64";
-
-const knownWindowsPackages = {
- "win32 arm64 LE": "turbo-windows-arm64",
- "win32 x64 LE": "turbo-windows-64",
-};
-
-const knownUnixlikePackages = {
- "darwin arm64 LE": packageDarwin_arm64,
- "darwin x64 LE": packageDarwin_x64,
- "linux arm64 LE": "turbo-linux-arm64",
- "linux x64 LE": "turbo-linux-64",
-};
-
-function pkgAndSubpathForCurrentPlatform() {
- let pkg;
- let subpath;
- let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
-
- if (platformKey in knownWindowsPackages) {
- pkg = knownWindowsPackages[platformKey];
- subpath = "bin/turbo.exe";
- } else if (platformKey in knownUnixlikePackages) {
- pkg = knownUnixlikePackages[platformKey];
- subpath = "bin/turbo";
- } else {
- throw new Error(`Unsupported platform: ${platformKey}`);
- }
- return { pkg, subpath };
-}
-
-function downloadedBinPath(pkg, subpath) {
- const turboLibDir = path.dirname(require.resolve("turbo"));
- return path.join(turboLibDir, `downloaded-${pkg}-${path.basename(subpath)}`);
-}
-
-function pkgForSomeOtherPlatform() {
- const libMainJS = require.resolve("turbo");
- const nodeModulesDirectory = path.dirname(
- path.dirname(path.dirname(libMainJS))
- );
- if (path.basename(nodeModulesDirectory) === "node_modules") {
- for (const unixKey in knownUnixlikePackages) {
- try {
- const pkg = knownUnixlikePackages[unixKey];
- if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg;
- } catch {}
- }
- for (const windowsKey in knownWindowsPackages) {
- try {
- const pkg = knownWindowsPackages[windowsKey];
- if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg;
- } catch {}
- }
- }
- return null;
-}
-
-function generateBinPath() {
- // This feature was added to give external code a way to modify the binary
- // path without modifying the code itself. Do not remove this because
- // external code relies on this (in addition to turbo's own test suite).
- if (TURBO_BINARY_PATH) {
- if (!fs.existsSync(TURBO_BINARY_PATH)) {
- console.warn(
- `[turbo] Ignoring bad configuration: TURBO_BINARY_PATH=${TURBO_BINARY_PATH}`
- );
- } else {
- return TURBO_BINARY_PATH;
- }
- }
-
- const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
- let binPath;
-
- try {
- // First check for the binary package from our "optionalDependencies". This
- // package should have been installed alongside this package at install time.
- binPath = require.resolve(`${pkg}/${subpath}`);
- } catch (e) {
- // If that didn't work, then someone probably installed turbo with the
- // "--no-optional" flag. Our install script attempts to compensate for this
- // by manually downloading the package instead. Check for that next.
- binPath = downloadedBinPath(pkg, subpath);
- if (!fs.existsSync(binPath)) {
- // If that didn't work too, check to see whether the package is even there
- // at all. It may not be (for a few different reasons).
- try {
- require.resolve(pkg);
- } catch {
- // If we can't find the package for this platform, then it's possible
- // that someone installed this for some other platform and is trying
- // to use it without reinstalling. That won't work of course, but
- // people do this all the time with systems like Docker. Try to be
- // helpful in that case.
- const otherPkg = pkgForSomeOtherPlatform();
- if (otherPkg) {
- let suggestions = `
-Specifically the "${otherPkg}" package is present but this platform
-needs the "${pkg}" package instead. People often get into this
-situation by installing turbo on Windows or macOS and copying "node_modules"
-into a Docker image that runs Linux, or by copying "node_modules" between
-Windows and WSL environments.
-If you are installing with npm, you can try not copying the "node_modules"
-directory when you copy the files over, and running "npm ci" or "npm install"
-on the destination platform after the copy. Or you could consider using yarn
-instead of npm which has built-in support for installing a package on multiple
-platforms simultaneously.
-If you are installing with yarn, you can try listing both this platform and the
-other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
-feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
-Keep in mind that this means multiple copies of turbo will be present.
-`;
-
- // Use a custom message for macOS-specific architecture issues
- if (
- (pkg === packageDarwin_x64 && otherPkg === packageDarwin_arm64) ||
- (pkg === packageDarwin_arm64 && otherPkg === packageDarwin_x64)
- ) {
- suggestions = `
-Specifically the "${otherPkg}" package is present but this platform
-needs the "${pkg}" package instead. People often get into this
-situation by installing turbo with npm running inside of Rosetta 2 and then
-trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
-2 is Apple's on-the-fly x86_64-to-arm64 translation service).
-If you are installing with npm, you can try ensuring that both npm and node are
-not running under Rosetta 2 and then reinstalling turbo. This likely involves
-changing how you installed npm and/or node. For example, installing node with
-the universal installer here should work: https://nodejs.org/en/download/. Or
-you could consider using yarn instead of npm which has built-in support for
-installing a package on multiple platforms simultaneously.
-If you are installing with yarn, you can try listing both "arm64" and "x64"
-in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
-https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
-Keep in mind that this means multiple copies of turbo will be present.
-`;
- }
-
- throw new Error(`
-You installed turbo for another platform than the one you're currently using.
-This won't work because turbo is written with native code and needs to
-install a platform-specific binary executable.
-${suggestions}
-Another alternative is to use the "turbo-wasm" package instead, which works
-the same way on all platforms. But it comes with a heavy performance cost and
-can sometimes be 10x slower than the "turbo" package, so you may also not
-want to do that.
-`);
- }
-
- // If that didn't work too, then maybe someone installed turbo with
- // both the "--no-optional" and the "--ignore-scripts" flags. The fix
- // for this is to just not do that. We don't attempt to handle this
- // case at all.
- //
- // In that case we try to have a nice error message if we think we know
- // what's happening. Otherwise we just rethrow the original error message.
- throw new Error(`The package "${pkg}" could not be found, and is needed by turbo.
-If you are installing turbo with npm, make sure that you don't specify the
-"--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
-of "package.json" is used by turbo to install the correct binary executable
-for your current platform.`);
- }
- throw e;
- }
- }
-
- // This code below guards against the unlikely case that the user is using
- // Yarn 2+ in PnP mode and that version is old enough that it doesn't support
- // the "preferUnplugged" setting. If that's the case, then the path to the
- // binary executable that we got above isn't actually a real path. Instead
- // it's a path to a zip file with some extra stuff appended to it.
- //
- // Yarn's PnP mode tries hard to patch Node's file system APIs to pretend
- // that these fake paths are real. So we can't check whether it's a real file
- // or not by using Node's file system APIs (e.g. "fs.existsSync") because
- // they have been patched to lie. But we can't return this fake path because
- // Yarn hasn't patched "child_process.execFileSync" to work with fake paths,
- // so attempting to execute the binary will fail.
- //
- // As a hack, we use Node's file system APIs to copy the file from the fake
- // path to a real path. This will cause Yarn's hacked file system to extract
- // the binary executable from the zip file and turn it into a real file that
- // we can execute.
- //
- // This is only done when both ".zip/" is present in the path and the
- // "pnpapi" package is present, which is a strong indication that Yarn PnP is
- // being used. There is no API at all for telling whether something is a real
- // file or not as far as I can tell. Even Yarn's own code just checks for
- // whether ".zip/" is present in the path or not.
- //
- // Note to self: One very hacky way to tell if a path is under the influence
- // of Yarn's file system hacks is to stat the file and check for the "crc"
- // property in the result. If that's present, then the file is inside a zip
- // file. However, I haven't done that here because it's not intended to be
- // used that way. Who knows what Yarn versions it does or does not work on
- // (including future versions).
- if (/\.zip\//.test(binPath)) {
- let pnpapi;
- try {
- pnpapi = require("pnpapi");
- } catch (e) {}
- if (pnpapi) {
- // Copy the executable to ".cache/turbo". The official recommendation
- // of the Yarn team is to use the directory "node_modules/.cache/turbo":
- // https://yarnpkg.com/advanced/rulebook/#packages-should-never-write-inside-their-own-folder-outside-of-postinstall
- // People that use Yarn in PnP mode find this really annoying because they
- // don't like seeing the "node_modules" directory. These people should
- // either work with Yarn to change their recommendation, or upgrade their
- // version of Yarn, since newer versions of Yarn shouldn't stick turbo's
- // binary executables in a zip file due to the "preferUnplugged" setting.
- const root = pnpapi.getPackageInformation(
- pnpapi.topLevel
- ).packageLocation;
- const binTargetPath = path.join(
- root,
- "node_modules",
- ".cache",
- "turbo",
- `pnpapi-${pkg.replace("/", "-")}-${TURBO_VERSION}-${path.basename(
- subpath
- )}`
- );
- if (!fs.existsSync(binTargetPath)) {
- fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
- fs.copyFileSync(binPath, binTargetPath);
- fs.chmodSync(binTargetPath, 0o755);
- }
- return binTargetPath;
- }
- }
-
- return binPath;
-}
-
-module.exports = {
- knownUnixlikePackages,
- knownWindowsPackages,
- generateBinPath,
- downloadedBinPath,
- pkgAndSubpathForCurrentPlatform,
- TURBO_BINARY_PATH,
-};
diff --git a/packages/turbo/package.json b/packages/turbo/package.json
deleted file mode 100644
index 4627a33..0000000
--- a/packages/turbo/package.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "name": "turbo",
- "version": "1.9.4-canary.2",
- "description": "Turborepo is a high-performance build system for JavaScript and TypeScript codebases.",
- "repository": "https://github.com/vercel/turbo",
- "bugs": "https://github.com/vercel/turbo/issues",
- "homepage": "https://turbo.build/repo",
- "license": "MPL-2.0",
- "scripts": {
- "postversion": "node bump-version.js",
- "postinstall": "node install.js"
- },
- "bin": {
- "turbo": "./bin/turbo"
- },
- "files": [
- "bin",
- "node-platform.js",
- "install.js"
- ],
- "optionalDependencies": {
- "turbo-darwin-64": "1.9.4-canary.2",
- "turbo-darwin-arm64": "1.9.4-canary.2",
- "turbo-linux-64": "1.9.4-canary.2",
- "turbo-linux-arm64": "1.9.4-canary.2",
- "turbo-windows-64": "1.9.4-canary.2",
- "turbo-windows-arm64": "1.9.4-canary.2"
- }
-}
diff --git a/packages/webpack-nmt/package.json b/packages/webpack-nmt/package.json
deleted file mode 100644
index 03f4b91..0000000
--- a/packages/webpack-nmt/package.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "name": "@vercel/webpack-nft",
- "version": "0.0.15-alpha.2",
- "license": "MPL-2.0",
- "main": "dist/index.js",
- "types": "dist/index.d.ts",
- "files": [
- "dist/**/*"
- ],
- "publishConfig": {
- "access": "public"
- },
- "dependencies": {
- "@vercel/experimental-nft": "workspace:*"
- },
- "peerDependencies": {
- "webpack": "^5.0.0"
- },
- "devDependencies": {
- "@types/webpack": "^5.28.0",
- "webpack": "^5.75.0"
- },
- "scripts": {
- "lint": "eslint src/**/*.ts"
- }
-}
diff --git a/packages/webpack-nmt/src/index.ts b/packages/webpack-nmt/src/index.ts
deleted file mode 100644
index 40c4508..0000000
--- a/packages/webpack-nmt/src/index.ts
+++ /dev/null
@@ -1,173 +0,0 @@
-import { spawn } from "child_process";
-import { join } from "path";
-
-import { Compilation, WebpackPluginInstance, Compiler } from "webpack";
-
-export interface NodeModuleTracePluginOptions {
- cwd?: string;
- // relative to cwd
- contextDirectory?: string;
- // additional PATH environment variable to use for spawning the `node-file-trace` process
- path?: string;
- // control the maximum number of files that are passed to the `node-file-trace` command
- // default is 128
- maxFiles?: number;
- // log options
- log?: {
- all?: boolean;
- detail?: boolean;
- // Default is `error`
- level?:
- | "bug"
- | "fatal"
- | "error"
- | "warning"
- | "hint"
- | "note"
- | "suggestions"
- | "info";
- };
-}
-
-export class NodeModuleTracePlugin implements WebpackPluginInstance {
- static PluginName = "NodeModuleTracePlugin";
-
- private readonly chunksToTrace = new Set<string>();
-
- constructor(private readonly options?: NodeModuleTracePluginOptions) {}
-
- apply(compiler: Compiler) {
- compiler.hooks.compilation.tap(
- NodeModuleTracePlugin.PluginName,
- (compilation) => {
- compilation.hooks.processAssets.tap(
- {
- name: NodeModuleTracePlugin.PluginName,
- stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
- },
- () => this.createTraceAssets(compilation)
- );
- }
- );
- compiler.hooks.afterEmit.tapPromise(NodeModuleTracePlugin.PluginName, () =>
- this.runTrace()
- );
- }
-
- private createTraceAssets(compilation: Compilation) {
- const outputPath = compilation.outputOptions.path!;
-
- const isTraceable = (file: string) =>
- !file.endsWith(".wasm") && !file.endsWith(".map");
-
- for (const entrypoint of compilation.entrypoints.values()) {
- const file = entrypoint.getFiles().pop();
- if (file && isTraceable(file)) {
- this.chunksToTrace.add(join(outputPath, file));
- }
- }
- }
-
- private async runTrace() {
- process.stdout.write("\n");
- const cwd = this.options?.cwd ?? process.cwd();
- const args = [
- "annotate",
- "--context-directory",
- // `npm_config_local_prefix` set by `npm` to the root of the project, include workspaces
- // `PROJECT_CWD` set by `yarn` to the root of the project, include workspaces
- this.options?.contextDirectory ??
- process.env.npm_config_local_prefix ??
- process.env.PROJECT_CWD ??
- cwd,
- "--exact",
- ];
- if (this.options?.log?.detail) {
- args.push("--log-detail");
- }
- if (this.options?.log?.all) {
- args.push("--show-all");
- }
- const logLevel = this.options?.log?.level;
- if (logLevel) {
- args.push(`--log-level`);
- args.push(logLevel);
- }
- let turboTracingPackagePath = "";
- let turboTracingBinPath = "";
- try {
- turboTracingPackagePath = require.resolve(
- "@vercel/experimental-nft/package.json"
- );
- } catch (e) {
- console.warn(
- `Could not resolve the @vercel/experimental-nft directory, turbo tracing may fail.`
- );
- }
- if (turboTracingPackagePath) {
- try {
- const turboTracingBinPackageJsonPath = require.resolve(
- `@vercel/experimental-nft-${process.platform}-${process.arch}/package.json`,
- {
- paths: [join(turboTracingPackagePath, "..")],
- }
- );
- turboTracingBinPath = join(turboTracingBinPackageJsonPath, "..");
- } catch (e) {
- console.warn(
- `Could not resolve the @vercel/experimental-nft-${process.platform}-${process.arch} directory, turbo tracing may fail.`
- );
- }
- }
- const pathSep = process.platform === "win32" ? ";" : ":";
- let paths = `${this.options?.path ?? ""}${pathSep}${process.env.PATH}`;
- if (turboTracingBinPath) {
- paths = `${turboTracingBinPath}${pathSep}${paths}`;
- }
- const maxFiles = this.options?.maxFiles ?? 128;
- let chunks = [...this.chunksToTrace];
- let restChunks = chunks.length > maxFiles ? chunks.splice(maxFiles) : [];
- while (chunks.length) {
- await traceChunks(args, paths, chunks, cwd);
- chunks = restChunks;
- if (restChunks.length) {
- restChunks = chunks.length > maxFiles ? chunks.splice(maxFiles) : [];
- }
- }
- }
-}
-
-function traceChunks(
- args: string[],
- paths: string,
- chunks: string[],
- cwd?: string
-) {
- const turboTracingProcess = spawn("node-file-trace", [...args, ...chunks], {
- stdio: "pipe",
- env: {
- ...process.env,
- PATH: paths,
- RUST_BACKTRACE: "1",
- },
- cwd,
- });
- return new Promise<void>((resolve, reject) => {
- turboTracingProcess.on("error", (err) => {
- console.error(err);
- });
- turboTracingProcess.stdout.on("data", (chunk) => {
- process.stdout.write(chunk);
- });
- turboTracingProcess.stderr.on("data", (chunk) => {
- process.stderr.write(chunk);
- });
- turboTracingProcess.once("exit", (code) => {
- if (!code) {
- resolve();
- } else {
- reject(code);
- }
- });
- });
-}
diff --git a/packages/webpack-nmt/tsconfig.json b/packages/webpack-nmt/tsconfig.json
deleted file mode 100644
index f724352..0000000
--- a/packages/webpack-nmt/tsconfig.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "compilerOptions": {
- "composite": true,
- "outDir": "./dist",
- "rootDir": "./src"
- },
- "include": ["src"]
-}