@catladder/pipeline 1.145.0 → 1.146.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/bundles/catladder-gitlab/index.js +1 -1
  2. package/dist/constants.js +1 -1
  3. package/dist/context/getEnvironmentVariables.js +1 -2
  4. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +1 -2
  5. package/dist/deploy/kubernetes/kubeValues.js +1 -3
  6. package/dist/pipeline/generatePipelineFiles.js +15 -5
  7. package/dist/tsconfig.tsbuildinfo +1 -1
  8. package/dist/types/config.d.ts +1 -1
  9. package/dist/types/jobs.d.ts +1 -1
  10. package/examples/__utils__/helpers.ts +2 -2
  11. package/package.json +1 -1
  12. package/scripts/generate-gitlab-ci-types.ts +2 -2
  13. package/src/bash/BashExpression.ts +4 -4
  14. package/src/bash/bashExpressionPerPipelineType.ts +1 -1
  15. package/src/bash/replaceAsync.ts +4 -4
  16. package/src/build/base/__tests__/createArtifactsConfig.test.ts +3 -3
  17. package/src/build/base/createAppBuildJob.ts +3 -3
  18. package/src/build/base/createArtifactsConfig.ts +2 -2
  19. package/src/build/base/index.ts +1 -1
  20. package/src/build/base/writeDotEnv.ts +1 -1
  21. package/src/build/custom/__tests__/testJob.test.ts +1 -1
  22. package/src/build/custom/buildJob.ts +2 -2
  23. package/src/build/custom/testJob.ts +3 -3
  24. package/src/build/docker.ts +7 -7
  25. package/src/build/index.ts +1 -1
  26. package/src/build/node/buildJob.ts +2 -2
  27. package/src/build/node/cache.ts +4 -4
  28. package/src/build/node/meteor.ts +1 -1
  29. package/src/build/node/testJob.ts +3 -3
  30. package/src/build/node/yarn.ts +7 -7
  31. package/src/config/configruedEnvs.ts +6 -6
  32. package/src/config/readConfig.ts +2 -2
  33. package/src/context/__tests__/resolveReferences.test.ts +1 -1
  34. package/src/context/getBuildInfoVariables.ts +5 -5
  35. package/src/context/getEnvConfig.ts +1 -1
  36. package/src/context/getEnvType.ts +1 -1
  37. package/src/context/getEnvironment.ts +1 -1
  38. package/src/context/getEnvironmentContext.ts +2 -2
  39. package/src/context/getEnvironmentVariables.ts +12 -12
  40. package/src/context/getReviewSlug.ts +2 -2
  41. package/src/context/index.ts +3 -3
  42. package/src/context/resolveReferences.ts +12 -9
  43. package/src/context/transformJobOnlyVars.ts +1 -1
  44. package/src/context/utils/envVars.ts +3 -3
  45. package/src/deploy/base/deploy.ts +5 -5
  46. package/src/deploy/base/index.ts +1 -1
  47. package/src/deploy/base/rollback.ts +1 -1
  48. package/src/deploy/base/stop.ts +1 -1
  49. package/src/deploy/cloudRun/artifactsRegistry.ts +5 -5
  50. package/src/deploy/cloudRun/cleanup.ts +3 -3
  51. package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -3
  52. package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +10 -10
  53. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +4 -4
  54. package/src/deploy/cloudRun/createJobs/common.ts +1 -1
  55. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +7 -7
  56. package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +1 -1
  57. package/src/deploy/cloudRun/createJobs/index.ts +1 -1
  58. package/src/deploy/cloudRun/createJobs/volumes.ts +2 -2
  59. package/src/deploy/cloudRun/index.ts +10 -6
  60. package/src/deploy/cloudRun/utils/createArgsString.ts +1 -1
  61. package/src/deploy/cloudRun/utils/database.ts +5 -5
  62. package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +1 -1
  63. package/src/deploy/cloudRun/utils/jobName.ts +1 -1
  64. package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +1 -1
  65. package/src/deploy/cloudSql/utils.ts +2 -2
  66. package/src/deploy/index.ts +3 -3
  67. package/src/deploy/kubernetes/cloudSql/index.ts +3 -3
  68. package/src/deploy/kubernetes/deployJob.ts +6 -6
  69. package/src/deploy/kubernetes/index.ts +1 -1
  70. package/src/deploy/kubernetes/kubeEnv.ts +1 -1
  71. package/src/deploy/kubernetes/kubeValues.ts +5 -5
  72. package/src/deploy/kubernetes/mongodb.ts +1 -1
  73. package/src/deploy/kubernetes/processSecretsAsFiles.ts +3 -3
  74. package/src/deploy/utils.ts +2 -2
  75. package/src/pipeline/createAllJobs.ts +4 -4
  76. package/src/pipeline/createChildPipeline.ts +2 -2
  77. package/src/pipeline/createJobsForComponent.ts +3 -3
  78. package/src/pipeline/createMainPipeline.ts +20 -17
  79. package/src/pipeline/generatePipelineFiles.ts +21 -12
  80. package/src/pipeline/getPipelineStages.ts +1 -1
  81. package/src/pipeline/gitlab/createGitlabJobs.ts +24 -24
  82. package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +6 -6
  83. package/src/pipeline/packageManager.ts +2 -2
  84. package/src/pipeline/yarn/yarnUtils.ts +7 -7
  85. package/src/types/config.ts +2 -2
  86. package/src/types/context.ts +1 -1
  87. package/src/types/environmentContext.ts +1 -1
  88. package/src/types/jobs.ts +1 -1
  89. package/src/types/utils.ts +4 -4
  90. package/src/utils/gitlab.ts +1 -1
  91. package/src/utils/index.ts +2 -2
  92. package/src/utils/writeFiles.ts +2 -2
@@ -8,7 +8,7 @@ export default async function replaceAsync(
8
8
  replacer: (
9
9
  substring: string,
10
10
  ...args: any[]
11
- ) => Promise<string | BashExpression>
11
+ ) => Promise<string | BashExpression>,
12
12
  ) {
13
13
  const wasBashExpression = string instanceof BashExpression;
14
14
  try {
@@ -24,12 +24,12 @@ export default async function replaceAsync(
24
24
  const result = replacer.apply(undefined, args);
25
25
  values.push(result);
26
26
  return "";
27
- }
27
+ },
28
28
  );
29
29
  const resolvedValues = await Promise.all(values);
30
30
 
31
31
  const containsBashExpression = resolvedValues.some(
32
- (value) => value instanceof BashExpression
32
+ (value) => value instanceof BashExpression,
33
33
  );
34
34
 
35
35
  const result = String.prototype.replace.call(
@@ -37,7 +37,7 @@ export default async function replaceAsync(
37
37
  searchValue,
38
38
  function () {
39
39
  return resolvedValues.shift()?.toString() ?? "";
40
- }
40
+ },
41
41
  );
42
42
  if (wasBashExpression || containsBashExpression) {
43
43
  return new BashExpression(result);
@@ -13,13 +13,13 @@ describe("createArtifactsConfig", () => {
13
13
  coverage_report: { coverage_format: "cobertura", path: "some" },
14
14
  terraform: "something",
15
15
  },
16
- })
16
+ }),
17
17
  ).toMatchSnapshot();
18
18
  });
19
19
 
20
20
  it("returns junit parts of artifactsReports", () => {
21
21
  expect(
22
- createArtifactsConfig(".", { junit: ["report.xml"] })
22
+ createArtifactsConfig(".", { junit: ["report.xml"] }),
23
23
  ).toMatchSnapshot();
24
24
  });
25
25
 
@@ -33,7 +33,7 @@ describe("createArtifactsConfig", () => {
33
33
  junit: "full-report.xml",
34
34
  terraform: "something",
35
35
  },
36
- }
36
+ },
37
37
  );
38
38
  expect(result).toMatchSnapshot();
39
39
  expect(result?.artifacts?.reports?.junit).toHaveLength(2);
@@ -15,7 +15,7 @@ import { writeDotEnv } from "./writeDotEnv";
15
15
  export type AppBuildJobDefinition = Partial<CatladderJob>;
16
16
  export const createAppBuildJob = (
17
17
  context: Context,
18
- { script, variables, runnerVariables, ...def }: AppBuildJobDefinition
18
+ { script, variables, runnerVariables, ...def }: AppBuildJobDefinition,
19
19
  ): CatladderJob => {
20
20
  return merge(
21
21
  {
@@ -50,11 +50,11 @@ export const createAppBuildJob = (
50
50
  paths: [join(context.componentConfig.dir, "__build_info.json")],
51
51
  reports: {
52
52
  junit: context.componentConfig.build.artifactsReports?.junit?.map(
53
- (p) => join(context.componentConfig.dir, p)
53
+ (p) => join(context.componentConfig.dir, p),
54
54
  ),
55
55
  },
56
56
  },
57
57
  },
58
- def
58
+ def,
59
59
  );
60
60
  };
@@ -6,7 +6,7 @@ import type { OptionalArtifacts } from "../custom/testJob";
6
6
  export const createArtifactsConfig = (
7
7
  rootPath: string,
8
8
  artifactsReports?: BuildConfigArtifactsReports,
9
- artifacts?: Artifacts
9
+ artifacts?: Artifacts,
10
10
  ): OptionalArtifacts =>
11
11
  artifactsReports || artifacts
12
12
  ? {
@@ -26,7 +26,7 @@ export const createArtifactsConfig = (
26
26
  .filter(Array.isArray)
27
27
  .reduce(
28
28
  (acc, curr) => [...acc, ...curr.map((p) => join(rootPath, p))],
29
- []
29
+ [],
30
30
  ),
31
31
  },
32
32
  },
@@ -13,7 +13,7 @@ export const createBuildJobs = (
13
13
  definitions: {
14
14
  appBuild?: AppBuildJobDefinition;
15
15
  dockerBuild: DockerBuildJobDefinition;
16
- }
16
+ },
17
17
  ): CatladderJob[] => {
18
18
  return [
19
19
  ...(definitions.appBuild
@@ -14,7 +14,7 @@ export const writeDotEnv = (context: Context) => {
14
14
  // filter out null and undefined values
15
15
  .filter(([, value]) => !isNil(value))
16
16
  .map(
17
- ([key, value]) => `${key}=${value?.toString().replaceAll("\n", "\\n")}`
17
+ ([key, value]) => `${key}=${value?.toString().replaceAll("\n", "\\n")}`,
18
18
  )
19
19
  .join("\n");
20
20
 
@@ -20,7 +20,7 @@ describe("createCustomTestJobs", () => {
20
20
  it("throws error when not build type custom", () => {
21
21
  componentConfig.build.type = "node";
22
22
  expect(() => createCustomTestJobs(baseContext)).toThrowError(
23
- "deploy config is not custom"
23
+ "deploy config is not custom",
24
24
  );
25
25
  componentConfig.build.type = "custom";
26
26
  });
@@ -34,7 +34,7 @@ export const createCustomBuildJobs = (context: Context): CatladderJob[] => {
34
34
  join(context.componentConfig.dir, "__build_info.json"),
35
35
  join(context.componentConfig.dir, "dist"),
36
36
  ...(buildConfig.artifactsPaths?.map((path) =>
37
- join(context.componentConfig.dir, path)
37
+ join(context.componentConfig.dir, path),
38
38
  ) ?? []),
39
39
  ],
40
40
  expire_in: "1 day",
@@ -44,7 +44,7 @@ export const createCustomBuildJobs = (context: Context): CatladderJob[] => {
44
44
  dockerBuild: {
45
45
  script: getDockerBuildDefaultScript(
46
46
  context,
47
- buildConfig.docker?.type === "nginx" ? "ensureNginxDockerfile" : ""
47
+ buildConfig.docker?.type === "nginx" ? "ensureNginxDockerfile" : "",
48
48
  ),
49
49
 
50
50
  variables: {},
@@ -48,7 +48,7 @@ export const createCustomTestJobs = (context: Context): CatladderJob[] => {
48
48
  ...createArtifactsConfig(
49
49
  context.componentConfig.dir,
50
50
  buildConfig.audit?.artifactsReports,
51
- buildConfig.audit?.artifacts
51
+ buildConfig.audit?.artifacts,
52
52
  ),
53
53
  }
54
54
  : null;
@@ -63,7 +63,7 @@ export const createCustomTestJobs = (context: Context): CatladderJob[] => {
63
63
  ...createArtifactsConfig(
64
64
  context.componentConfig.dir,
65
65
  buildConfig.lint?.artifactsReports,
66
- buildConfig.lint?.artifacts
66
+ buildConfig.lint?.artifacts,
67
67
  ),
68
68
  }
69
69
  : null;
@@ -77,7 +77,7 @@ export const createCustomTestJobs = (context: Context): CatladderJob[] => {
77
77
  ...createArtifactsConfig(
78
78
  context.componentConfig.dir,
79
79
  buildConfig.test?.artifactsReports,
80
- buildConfig.test?.artifacts
80
+ buildConfig.test?.artifacts,
81
81
  ),
82
82
  }
83
83
  : null;
@@ -76,7 +76,7 @@ export const getDockerBuildVariables = (context: Context) => {
76
76
  export const DOCKER_BUILD_JOB_NAME = "🔨 docker";
77
77
 
78
78
  export const getDockerJobBaseProps = (
79
- context: Context
79
+ context: Context,
80
80
  ): Pick<
81
81
  CatladderJob,
82
82
  "image" | "services" | "variables" | "runnerVariables"
@@ -97,7 +97,7 @@ export const getDockerJobBaseProps = (
97
97
  export type DockerBuildJobDefinition = Partial<CatladderJob>;
98
98
  export const createDockerBuildJobBase = (
99
99
  context: Context,
100
- { script, ...def }: Partial<CatladderJob>
100
+ { script, ...def }: Partial<CatladderJob>,
101
101
  ): CatladderJob => {
102
102
  return merge(
103
103
  {
@@ -114,7 +114,7 @@ export const createDockerBuildJobBase = (
114
114
  ...getDockerBuildRunnerVariables(),
115
115
  },
116
116
  },
117
- def
117
+ def,
118
118
  );
119
119
  };
120
120
 
@@ -130,23 +130,23 @@ export const gitlabDockerLogin = (context: Context) =>
130
130
 
131
131
  export const getDockerBuildDefaultScript = (
132
132
  context: Context,
133
- ensureDockerFileScript?: string
133
+ ensureDockerFileScript?: string,
134
134
  ) =>
135
135
  [
136
136
  ensureDockerFileScript,
137
137
  ...collapseableSection(
138
138
  "docker-login",
139
- "Docker Login"
139
+ "Docker Login",
140
140
  )(gitlabDockerLogin(context)),
141
141
  ...collapseableSection(
142
142
  "docker-build",
143
- "Docker build"
143
+ "Docker build",
144
144
  )([
145
145
  "docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", //BUILDKIT_INLINE_CACHE, see https://testdriven.io/blog/faster-ci-builds-with-docker-cache/
146
146
  ]),
147
147
  ...collapseableSection(
148
148
  "docker-push",
149
- "Docker push and tag"
149
+ "Docker push and tag",
150
150
  )([
151
151
  "docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG",
152
152
  "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE",
@@ -14,7 +14,7 @@ export type BuildTypes = {
14
14
  [type in BuildConfigType]: {
15
15
  jobs: (context: Context) => CatladderJob[];
16
16
  defaults: (
17
- envContext: EnvironmentContext<BuildConfigType, any>
17
+ envContext: EnvironmentContext<BuildConfigType, any>,
18
18
  ) => Partial<Extract<BuildConfig, { type: type }>>;
19
19
  };
20
20
  };
@@ -46,7 +46,7 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
46
46
  join(dir, "dist"),
47
47
  join(dir, ".next"),
48
48
  ...(buildConfig.artifactsPaths?.map((path) =>
49
- join(dir, path)
49
+ join(dir, path),
50
50
  ) ?? []),
51
51
  ]),
52
52
  expire_in: "1 day",
@@ -61,7 +61,7 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
61
61
  context,
62
62
  buildConfig.type === "node-static" || buildConfig.type === "storybook"
63
63
  ? "ensureNginxDockerfile"
64
- : "ensureNodeDockerfile"
64
+ : "ensureNodeDockerfile",
65
65
  ),
66
66
  cache: [...getYarnCache(context, "pull")],
67
67
  variables: {
@@ -6,7 +6,7 @@ import { uniq } from "lodash";
6
6
 
7
7
  export const getYarnCache = (
8
8
  context: Context,
9
- policy = "pull-push"
9
+ policy = "pull-push",
10
10
  ): GitlabJobCache[] => {
11
11
  const componentIsInWorkspace =
12
12
  context.packageManagerInfo?.componentIsInWorkspace;
@@ -27,7 +27,7 @@ export const getYarnCache = (
27
27
 
28
28
  export const getNodeModulesCache = (
29
29
  context: Context,
30
- policy = "pull-push"
30
+ policy = "pull-push",
31
31
  ): GitlabJobCache[] => {
32
32
  const componentIsInWorkspace =
33
33
  context.packageManagerInfo?.componentIsInWorkspace;
@@ -46,7 +46,7 @@ export const getNodeModulesCache = (
46
46
  ? uniq([
47
47
  "node_modules",
48
48
  ...(context.packageManagerInfo?.workspaces.map((w) =>
49
- join(w.location, "node_modules")
49
+ join(w.location, "node_modules"),
50
50
  ) ?? []),
51
51
  ])
52
52
  : [join(context.componentConfig.dir, "node_modules")]),
@@ -56,7 +56,7 @@ export const getNodeModulesCache = (
56
56
  };
57
57
  export const getNodeCache = (
58
58
  context: Context,
59
- policy = "pull-push"
59
+ policy = "pull-push",
60
60
  ): GitlabJobCache[] => {
61
61
  return [
62
62
  ...getYarnCache(context, policy),
@@ -18,7 +18,7 @@ const getMeteorCache = (context: Context): GitlabJobCache[] => [
18
18
  paths: [
19
19
  join(
20
20
  context.componentConfig.dir,
21
- ".meteor/local/resolver-result-cache.json"
21
+ ".meteor/local/resolver-result-cache.json",
22
22
  ),
23
23
  join(context.componentConfig.dir, ".meteor/local/plugin-cache"),
24
24
  join(context.componentConfig.dir, ".meteor/local/isopacks"),
@@ -47,7 +47,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
47
47
  ...createArtifactsConfig(
48
48
  context.componentConfig.dir,
49
49
  buildConfig.audit?.artifactsReports,
50
- buildConfig.audit?.artifacts
50
+ buildConfig.audit?.artifacts,
51
51
  ),
52
52
  }
53
53
  : null;
@@ -68,7 +68,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
68
68
  ...createArtifactsConfig(
69
69
  context.componentConfig.dir,
70
70
  buildConfig.lint?.artifactsReports,
71
- buildConfig.lint?.artifacts
71
+ buildConfig.lint?.artifacts,
72
72
  ),
73
73
  }
74
74
  : null;
@@ -90,7 +90,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
90
90
  ...createArtifactsConfig(
91
91
  context.componentConfig.dir,
92
92
  buildConfig.test?.artifactsReports,
93
- buildConfig.test?.artifacts
93
+ buildConfig.test?.artifacts,
94
94
  ),
95
95
  }
96
96
  : null;
@@ -19,7 +19,7 @@ const getYarnInstallCommand = (context: Context) => {
19
19
  export const ensureNodeVersion = (context: Context) =>
20
20
  collapseableSection(
21
21
  "nodeinstall",
22
- "Ensure node version"
22
+ "Ensure node version",
23
23
  )([
24
24
  "if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi",
25
25
  "if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi",
@@ -29,7 +29,7 @@ export const getYarnInstall = (
29
29
  context: Context,
30
30
  options?: {
31
31
  noCustomPostInstall: boolean;
32
- }
32
+ },
33
33
  ) => {
34
34
  const postInstall =
35
35
  "postInstall" in context.componentConfig.build
@@ -39,12 +39,12 @@ export const getYarnInstall = (
39
39
  ...ensureNodeVersion(context),
40
40
  ...collapseableSection(
41
41
  "yarninstall",
42
- "Yarn install"
42
+ "Yarn install",
43
43
  )([getYarnInstallCommand(context)]),
44
44
  ...(postInstall && !options?.noCustomPostInstall
45
45
  ? collapseableSection(
46
46
  "postinstall",
47
- "Custom post install"
47
+ "Custom post install",
48
48
  )(ensureArray(postInstall) ?? [])
49
49
  : []),
50
50
  ];
@@ -59,14 +59,14 @@ export const getDockerAppCopyAndBuildScript = (context: Context) => {
59
59
  RUN ${YARN_INSTALL_CLASSIC} --production --ignore-scripts
60
60
  ${DOCKER_COPY_FILES}
61
61
  RUN ${YARN_INSTALL_CLASSIC} --production
62
- `.trim()
62
+ `.trim(),
63
63
  );
64
64
  }
65
65
 
66
66
  // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
67
67
  // trying to import those fail on this version
68
68
  const doesNotShipWithBuiltInPlugins = ["2", "3"].some((v) =>
69
- context.packageManagerInfo?.version.startsWith(v)
69
+ context.packageManagerInfo?.version.startsWith(v),
70
70
  );
71
71
  const maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins
72
72
  ? "RUN yarn plugin import workspace-tools"
@@ -80,6 +80,6 @@ ${DOCKER_COPY_FILES}
80
80
  ${maybeAddWorkspaceToolsCommand}
81
81
  RUN ${YARN_BERRY_PROD_REBUILD}
82
82
 
83
- `.trim()
83
+ `.trim(),
84
84
  );
85
85
  };
@@ -4,25 +4,25 @@ import { DEFAULT_ENV_TYPES, getEnvTypesByTrigger } from "../types";
4
4
  const getConfiguredAndDefaultEnvs = (
5
5
  config: Config,
6
6
  componentName: string,
7
- envTypes: EnvType[]
7
+ envTypes: EnvType[],
8
8
  ) => {
9
9
  const configuredEnvs = config.components[componentName].env ?? {};
10
10
  // the default envs have the same name as the env types
11
11
  // these can be disabled with settimg them to `false`
12
12
  // this is the list of all not disabled envs. These are always returned
13
13
  const enabledDefaultEnvs = envTypes.filter(
14
- (e) => configuredEnvs[e] !== false
14
+ (e) => configuredEnvs[e] !== false,
15
15
  );
16
16
 
17
17
  const configuredCustomEnvs = Object.entries(
18
- config.components[componentName].env ?? {}
18
+ config.components[componentName].env ?? {},
19
19
  )
20
20
  .filter(
21
21
  ([, config]) =>
22
22
  config &&
23
23
  "type" in config &&
24
24
  config.type &&
25
- envTypes.includes(config.type)
25
+ envTypes.includes(config.type),
26
26
  )
27
27
  .map(([envName]) => envName);
28
28
 
@@ -36,7 +36,7 @@ export const getAllEnvs = (config: Config, componentName: string) => {
36
36
  export const getAllEnvsInAllComponents = (config: Config) => {
37
37
  return [
38
38
  ...new Set(
39
- Object.keys(config.components).flatMap((c) => getAllEnvs(config, c))
39
+ Object.keys(config.components).flatMap((c) => getAllEnvs(config, c)),
40
40
  ),
41
41
  ];
42
42
  };
@@ -44,7 +44,7 @@ export const getAllEnvsInAllComponents = (config: Config) => {
44
44
  export const getAllEnvsByTrigger = (
45
45
  config: Config,
46
46
  componentName: string,
47
- trigger: PipelineTrigger
47
+ trigger: PipelineTrigger,
48
48
  ) => {
49
49
  const envTypesByTrigger = getEnvTypesByTrigger(trigger);
50
50
  return getConfiguredAndDefaultEnvs(config, componentName, envTypesByTrigger);
@@ -14,7 +14,7 @@ function requireUncached(module: string) {
14
14
  }
15
15
 
16
16
  export const readConfigSync = (
17
- directory: string = process.cwd()
17
+ directory: string = process.cwd(),
18
18
  ): { config: Config; path: string; ext: string } | null => {
19
19
  register({
20
20
  cwd: directory,
@@ -25,7 +25,7 @@ export const readConfigSync = (
25
25
  });
26
26
 
27
27
  const found = ["ts", "js", "yml", "yaml"].find((extension) =>
28
- existsSync(fullPath(directory, extension))
28
+ existsSync(fullPath(directory, extension)),
29
29
  );
30
30
  if (found) {
31
31
  const filePath = fullPath(directory, found);
@@ -6,7 +6,7 @@ import {
6
6
 
7
7
  const unpackBashExpressions = (obj: Record<string, string | BashExpression>) =>
8
8
  Object.fromEntries(
9
- Object.entries(obj).map(([key, value]) => [key, value.toString()])
9
+ Object.entries(obj).map(([key, value]) => [key, value.toString()]),
10
10
  );
11
11
  describe("resolveReferences", () => {
12
12
  it("replaces occurences of ${componentName:VARIABLE_NAME}", async () => {
@@ -10,13 +10,13 @@ const BUILD_TIME: BashExpressionPerPipelineType = {
10
10
 
11
11
  const BUILD_ID: BashExpressionPerPipelineType = {
12
12
  default: new BashExpression(
13
- `$(git describe --tags 2>/dev/null || git rev-parse HEAD)`
13
+ `$(git describe --tags 2>/dev/null || git rev-parse HEAD)`,
14
14
  ),
15
15
  };
16
16
  const CURRENT_VERSION: BashExpressionPerPipelineType = {
17
17
  default: new BashExpression(
18
18
  // because we do shallow fetch, we need to ask the origin
19
- `$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\///'); [ -z "$tag" ] && echo "v0.0.0" || echo "$tag")`
19
+ `$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\///'); [ -z "$tag" ] && echo "v0.0.0" || echo "$tag")`,
20
20
  ),
21
21
  };
22
22
 
@@ -26,15 +26,15 @@ export const getBuildInfoVariables = (ctx: EnvironmentContext<any, any>) => {
26
26
  return {
27
27
  BUILD_INFO_BUILD_ID: getBashExpressionPerPipelineType(
28
28
  BUILD_ID,
29
- pipelineType
29
+ pipelineType,
30
30
  ),
31
31
  BUILD_INFO_BUILD_TIME: getBashExpressionPerPipelineType(
32
32
  BUILD_TIME,
33
- pipelineType
33
+ pipelineType,
34
34
  ),
35
35
  BUILD_INFO_CURRENT_VERSION: getBashExpressionPerPipelineType(
36
36
  CURRENT_VERSION,
37
- pipelineType
37
+ pipelineType,
38
38
  ),
39
39
  };
40
40
  };
@@ -5,7 +5,7 @@ import { mergeWithMergingArrays } from "../utils";
5
5
  export const getEnvConfig = (
6
6
  config: Config,
7
7
  componentName: string,
8
- env: string
8
+ env: string,
9
9
  ): EnvConfigWithComponent => {
10
10
  const defaultConfig = config.components[componentName];
11
11
  if (!defaultConfig) {
@@ -5,7 +5,7 @@ export const getEnvType = (
5
5
  env: string,
6
6
  envConfig: {
7
7
  type?: EnvType;
8
- }
8
+ },
9
9
  ): EnvType => {
10
10
  if (envConfig.type) return envConfig.type;
11
11
 
@@ -5,7 +5,7 @@ import { getEnvironmentContext } from "./getEnvironmentContext";
5
5
  import { getEnvironmentVariables } from "./getEnvironmentVariables";
6
6
 
7
7
  export const getEnvironment = async (
8
- ctx: CreateContextContext
8
+ ctx: CreateContextContext,
9
9
  ): Promise<Environment> => {
10
10
  const { env } = ctx;
11
11
  const variables = await getEnvironmentVariables(ctx);
@@ -9,7 +9,7 @@ import { getReviewSlug } from "./getReviewSlug";
9
9
 
10
10
  const getEnvironmentSlugPrefix = (
11
11
  env: string,
12
- reviewSlug: StringOrBashExpression | null
12
+ reviewSlug: StringOrBashExpression | null,
13
13
  ): StringOrBashExpression => {
14
14
  if (reviewSlug) {
15
15
  return joinBashExpressions([env, reviewSlug], "-");
@@ -33,7 +33,7 @@ export const getEnvironmentContext = ({
33
33
 
34
34
  const fullName = joinBashExpressions(
35
35
  [config.customerName, config.appName, environmentSlug],
36
- "-"
36
+ "-",
37
37
  );
38
38
 
39
39
  return {
@@ -53,7 +53,7 @@ export type PredefinedVariables = BasePredefinedVariables & {
53
53
 
54
54
  export const getEnvironmentVariables = async (
55
55
  ctx: CreateContextContext,
56
- alreadyVisited: Record<string, Record<string, boolean>> = {} // to prevent endless loop
56
+ alreadyVisited: Record<string, Record<string, boolean>> = {}, // to prevent endless loop
57
57
  ): Promise<EnvironmentVariables> => {
58
58
  const environmentContext = getEnvironmentContext(ctx);
59
59
 
@@ -88,7 +88,7 @@ export const getEnvironmentVariables = async (
88
88
  } else {
89
89
  const additionalEnvVars = deployConfigRaw
90
90
  ? DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(
91
- environmentContext as never
91
+ environmentContext as never,
92
92
  )
93
93
  : {};
94
94
 
@@ -116,7 +116,7 @@ export const getEnvironmentVariables = async (
116
116
 
117
117
  const additionalSecretKeys = deployConfigRaw
118
118
  ? DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(
119
- environmentContext as never
119
+ environmentContext as never,
120
120
  )
121
121
  : [];
122
122
 
@@ -127,18 +127,18 @@ export const getEnvironmentVariables = async (
127
127
  const secretEnvVars = makeSecretEnvVarMapping(
128
128
  env,
129
129
  componentName,
130
- secretEnvVarKeys
130
+ secretEnvVarKeys,
131
131
  );
132
132
  // this is deprecated, we now support: $componentname:FOO
133
133
  const legacyFromComponents = envConfigRaw.vars?.fromComponents ?? {};
134
134
  const publicEnvVarsRawWithLegacyFromComponents = merge(
135
135
  {},
136
136
  translateLegacyFromComponents(legacyFromComponents),
137
- publicEnvVarsRaw
137
+ publicEnvVarsRaw,
138
138
  );
139
139
 
140
140
  const publicEnvVarsRawSanitized = stringifyValues(
141
- publicEnvVarsRawWithLegacyFromComponents
141
+ publicEnvVarsRawWithLegacyFromComponents,
142
142
  );
143
143
 
144
144
  const envVarsRaw = addIndexVar({
@@ -155,11 +155,11 @@ export const getEnvironmentVariables = async (
155
155
  ...ctx,
156
156
  componentName: otherComponentName,
157
157
  },
158
- alreadyVisited
158
+ alreadyVisited,
159
159
  );
160
160
  return otherEnvVars;
161
161
  },
162
- alreadyVisited
162
+ alreadyVisited,
163
163
  )) as typeof envVarsRaw;
164
164
 
165
165
  return {
@@ -169,12 +169,12 @@ export const getEnvironmentVariables = async (
169
169
  build: await transformJobOnlyVars(
170
170
  env,
171
171
  componentName,
172
- (buildConfigRaw && buildConfigRaw.jobVars) || null
172
+ (buildConfigRaw && buildConfigRaw.jobVars) || null,
173
173
  ),
174
174
  deploy: await transformJobOnlyVars(
175
175
  env,
176
176
  componentName,
177
- (deployConfigRaw && deployConfigRaw.jobVars) || null
177
+ (deployConfigRaw && deployConfigRaw.jobVars) || null,
178
178
  ),
179
179
  },
180
180
 
@@ -188,11 +188,11 @@ const sanitizeForEnVar = (s: string) => s.replace(/-/g, "_");
188
188
  export const getSecretVarName = (
189
189
  env: string,
190
190
  componentName: string,
191
- key: string
191
+ key: string,
192
192
  ) => `CL_${sanitizeForEnVar(env)}_${sanitizeForEnVar(componentName)}_${key}`; // remove dash from component name
193
193
 
194
194
  const addIndexVar = <V extends Record<string, unknown>>(
195
- vars: V
195
+ vars: V,
196
196
  ): V & { _ALL_ENV_VAR_KEYS: string } => ({
197
197
  ...vars,
198
198
  _ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars)),
@@ -10,14 +10,14 @@ import { getEnvType } from "./getEnvType";
10
10
  const REVIEW_SLUG: BashExpressionPerPipelineType = {
11
11
  default: "unknown-review-slug",
12
12
  gitlab: new BashExpression(
13
- `$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })`
13
+ `$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })`,
14
14
  ),
15
15
  };
16
16
 
17
17
  export const getReviewSlug = (
18
18
  envConfig: EnvConfigWithComponent,
19
19
  env: string,
20
- pipelineType?: PipelineType
20
+ pipelineType?: PipelineType,
21
21
  ): StringOrBashExpression | null => {
22
22
  const envType = getEnvType(env, envConfig);
23
23
  if (envType === "review") {