Skip to content

Commit

Permalink
feat(cli): disable package.json config support
Browse files Browse the repository at this point in the history
  • Loading branch information
tknickman committed Jan 9, 2023
1 parent d8ff712 commit fae5198
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
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

0 comments on commit fae5198

Please sign in to comment.