-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add ability to define a globalEnv key in turbo.json #1950
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "name": "test-repo" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| // Both global declarations with duplicates | ||
| "globalDependencies": ["$FOO", "$BAR", "somefile.txt", "somefile.txt"], | ||
| // some invalid values | ||
| "globalEnv": ["FOO", "BAZ", "$QUX"], | ||
| "pipeline": { | ||
| "task1": { | ||
| "dependsOn": ["$A"] | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,43 +23,36 @@ var _defaultEnvVars = []string{ | |
| "VERCEL_ANALYTICS_ID", | ||
| } | ||
|
|
||
| func calculateGlobalHash(rootpath turbopath.AbsolutePath, rootPackageJSON *fs.PackageJSON, pipeline fs.Pipeline, externalGlobalDependencies []string, packageManager *packagemanager.PackageManager, logger hclog.Logger, env []string) (string, error) { | ||
| // Calculate the global hash | ||
| globalDeps := make(util.Set) | ||
|
|
||
| func calculateGlobalHash(rootpath turbopath.AbsolutePath, rootPackageJSON *fs.PackageJSON, pipeline fs.Pipeline, envVarDependencies []string, globalFileDependencies []string, packageManager *packagemanager.PackageManager, logger hclog.Logger, env []string) (string, error) { | ||
|
||
| // Calculate env var dependencies | ||
| globalHashableEnvNames := []string{} | ||
| globalHashableEnvPairs := []string{} | ||
| // Calculate global file and env var dependencies | ||
| for _, builtinEnvVar := range _defaultEnvVars { | ||
| globalHashableEnvNames = append(globalHashableEnvNames, builtinEnvVar) | ||
| globalHashableEnvPairs = append(globalHashableEnvPairs, fmt.Sprintf("%v=%v", builtinEnvVar, os.Getenv(builtinEnvVar))) | ||
| } | ||
| if len(externalGlobalDependencies) > 0 { | ||
| var globs []string | ||
| for _, v := range externalGlobalDependencies { | ||
| if strings.HasPrefix(v, "$") { | ||
| trimmed := strings.TrimPrefix(v, "$") | ||
| globalHashableEnvNames = append(globalHashableEnvNames, trimmed) | ||
| globalHashableEnvPairs = append(globalHashableEnvPairs, fmt.Sprintf("%v=%v", trimmed, os.Getenv(trimmed))) | ||
| } else { | ||
| globs = append(globs, v) | ||
| } | ||
| } | ||
|
|
||
| if len(globs) > 0 { | ||
| ignores, err := packageManager.GetWorkspaceIgnores(rootpath) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| // Calculate global env var dependencies | ||
| for _, v := range envVarDependencies { | ||
| globalHashableEnvNames = append(globalHashableEnvNames, v) | ||
| globalHashableEnvPairs = append(globalHashableEnvPairs, fmt.Sprintf("%v=%v", v, os.Getenv(v))) | ||
| } | ||
|
|
||
| // Calculate global file dependencies | ||
| globalDeps := make(util.Set) | ||
| if len(globalFileDependencies) > 0 { | ||
mehulkar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ignores, err := packageManager.GetWorkspaceIgnores(rootpath) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| f, err := globby.GlobFiles(rootpath.ToStringDuringMigration(), globs, ignores) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| f, err := globby.GlobFiles(rootpath.ToStringDuringMigration(), globalFileDependencies, ignores) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| for _, val := range f { | ||
| globalDeps.Add(val) | ||
| } | ||
| for _, val := range f { | ||
| globalDeps.Add(val) | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.