Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(cli): disable package.json config support #3221

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions cli/internal/fs/turbo_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ func ReadTurboConfig(rootPath turbopath.AbsoluteSystemPath, rootPackageJSON *Pac
}

// If pkg.Turbo exists, log a warning and delete it from the representation
// TODO: turn off this warning eventually
if hasLegacyConfig {
log.Printf("[WARNING] Ignoring \"turbo\" key in package.json, using %s instead.", configFile)
rootPackageJSON.LegacyTurboConfig = nil
Expand All @@ -178,11 +177,9 @@ func ReadTurboConfig(rootPath turbopath.AbsoluteSystemPath, rootPackageJSON *Pac
return turboJSON, nil
}

// Use pkg.Turbo if the configFile doesn't exist and we want the fallback feature
// TODO: turn this fallback off eventually
// If the configFile doesn't exist, but a legacy config does, log that it's deprecated and return an error
if hasLegacyConfig {
log.Printf("[DEPRECATED] \"turbo\" in package.json is deprecated. Migrate to %s by running \"npx @turbo/codemod create-turbo-config\"\n", configFile)
return rootPackageJSON.LegacyTurboConfig, nil
}

// If there's no turbo.json and no turbo key in package.json, return an error.
Expand Down
21 changes: 3 additions & 18 deletions cli/internal/fs/turbo_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,10 @@ func Test_ReadTurboConfig_Legacy(t *testing.T) {
t.Fatalf("invalid parse: %#v", pkgJSONReadErr)
}

turboJSON, turboJSONReadErr := ReadTurboConfig(testDir, rootPackageJSON)

if turboJSONReadErr != nil {
t.Fatalf("invalid parse: %#v", turboJSONReadErr)
}

pipelineExpected := map[string]TaskDefinition{
"build": {
Outputs: TaskOutputs{},
TopologicalDependencies: []string{},
EnvVarDependencies: []string{},
TaskDependencies: []string{},
ShouldCache: true,
OutputMode: util.FullTaskOutput,
},
}
_, turboJSONReadErr := ReadTurboConfig(testDir, rootPackageJSON)

validateOutput(t, turboJSON, pipelineExpected)
assert.Empty(t, turboJSON.RemoteCacheOptions)
expectedErrorMsg := "Could not find turbo.json. Follow directions at https://turbo.build/repo/docs to create one: file does not exist"
assert.EqualErrorf(t, turboJSONReadErr, expectedErrorMsg, "Error should be: %v, got: %v", expectedErrorMsg, turboJSONReadErr)
}

func Test_ReadTurboConfig_BothCorrectAndLegacy(t *testing.T) {
Expand Down