@catladder/pipeline 0.0.0-refactor-docker-de6b3576 → 0.0.0-refactor-docker-9fda97e9

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 (85) hide show
  1. package/dist/bundles/catladder-gitlab/index.js +8 -4
  2. package/dist/constants.js +1 -1
  3. package/dist/context/getEnvironmentVariables.js +2 -1
  4. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +2 -1
  5. package/dist/deploy/kubernetes/kubeValues.js +3 -1
  6. package/dist/tsconfig.tsbuildinfo +1 -1
  7. package/dist/types/config.d.ts +1 -1
  8. package/dist/types/jobs.d.ts +1 -1
  9. package/examples/__utils__/helpers.ts +2 -2
  10. package/package.json +1 -1
  11. package/scripts/generate-gitlab-ci-types.ts +2 -2
  12. package/src/bash/BashExpression.ts +4 -4
  13. package/src/bash/bashExpressionPerPipelineType.ts +1 -1
  14. package/src/bash/replaceAsync.ts +4 -4
  15. package/src/build/base/__tests__/createArtifactsConfig.test.ts +3 -3
  16. package/src/build/base/createArtifactsConfig.ts +2 -2
  17. package/src/build/base/writeDotEnv.ts +1 -1
  18. package/src/build/custom/__tests__/testJob.test.ts +1 -1
  19. package/src/build/custom/testJob.ts +3 -3
  20. package/src/build/index.ts +1 -1
  21. package/src/build/node/cache.ts +4 -4
  22. package/src/build/node/testJob.ts +3 -3
  23. package/src/build/node/yarn.ts +7 -7
  24. package/src/config/configruedEnvs.ts +6 -6
  25. package/src/config/readConfig.ts +2 -2
  26. package/src/context/__tests__/resolveReferences.test.ts +1 -1
  27. package/src/context/getBuildInfoVariables.ts +5 -5
  28. package/src/context/getEnvConfig.ts +1 -1
  29. package/src/context/getEnvType.ts +1 -1
  30. package/src/context/getEnvironment.ts +1 -1
  31. package/src/context/getEnvironmentContext.ts +2 -2
  32. package/src/context/getEnvironmentVariables.ts +12 -12
  33. package/src/context/getReviewSlug.ts +2 -2
  34. package/src/context/index.ts +3 -3
  35. package/src/context/resolveReferences.ts +9 -12
  36. package/src/context/transformJobOnlyVars.ts +1 -1
  37. package/src/context/utils/envVars.ts +3 -3
  38. package/src/deploy/base/deploy.ts +5 -5
  39. package/src/deploy/base/index.ts +1 -1
  40. package/src/deploy/base/rollback.ts +1 -1
  41. package/src/deploy/base/stop.ts +1 -1
  42. package/src/deploy/cloudRun/artifactsRegistry.ts +5 -5
  43. package/src/deploy/cloudRun/cleanup.ts +3 -3
  44. package/src/deploy/cloudRun/cloudRunRevisions.ts +3 -3
  45. package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +10 -10
  46. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +4 -4
  47. package/src/deploy/cloudRun/createJobs/common.ts +1 -1
  48. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +7 -7
  49. package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +1 -1
  50. package/src/deploy/cloudRun/createJobs/index.ts +1 -1
  51. package/src/deploy/cloudRun/createJobs/volumes.ts +2 -2
  52. package/src/deploy/cloudRun/index.ts +6 -10
  53. package/src/deploy/cloudRun/utils/createArgsString.ts +1 -1
  54. package/src/deploy/cloudRun/utils/database.ts +5 -5
  55. package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +1 -1
  56. package/src/deploy/cloudRun/utils/jobName.ts +1 -1
  57. package/src/deploy/cloudRun/utils/removeFirstLinesFromCommandOutput.ts +1 -1
  58. package/src/deploy/cloudSql/utils.ts +2 -2
  59. package/src/deploy/index.ts +3 -3
  60. package/src/deploy/kubernetes/cloudSql/index.ts +3 -3
  61. package/src/deploy/kubernetes/deployJob.ts +6 -6
  62. package/src/deploy/kubernetes/index.ts +1 -1
  63. package/src/deploy/kubernetes/kubeEnv.ts +1 -1
  64. package/src/deploy/kubernetes/kubeValues.ts +5 -5
  65. package/src/deploy/kubernetes/mongodb.ts +1 -1
  66. package/src/deploy/kubernetes/processSecretsAsFiles.ts +3 -3
  67. package/src/deploy/utils.ts +2 -2
  68. package/src/pipeline/createAllJobs.ts +4 -4
  69. package/src/pipeline/createChildPipeline.ts +2 -2
  70. package/src/pipeline/createJobsForComponent.ts +3 -3
  71. package/src/pipeline/createMainPipeline.ts +17 -20
  72. package/src/pipeline/generatePipelineFiles.ts +3 -3
  73. package/src/pipeline/getPipelineStages.ts +1 -1
  74. package/src/pipeline/gitlab/createGitlabJobs.ts +24 -24
  75. package/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts +6 -6
  76. package/src/pipeline/packageManager.ts +2 -2
  77. package/src/pipeline/yarn/yarnUtils.ts +7 -7
  78. package/src/types/config.ts +2 -2
  79. package/src/types/context.ts +1 -1
  80. package/src/types/environmentContext.ts +1 -1
  81. package/src/types/jobs.ts +1 -1
  82. package/src/types/utils.ts +4 -4
  83. package/src/utils/gitlab.ts +1 -1
  84. package/src/utils/index.ts +2 -2
  85. 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);
@@ -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
  },
@@ -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
  });
@@ -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;
@@ -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
  };
@@ -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),
@@ -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") {
@@ -23,11 +23,11 @@ export type CreateContextContext = {
23
23
  };
24
24
 
25
25
  export const createContext = async (
26
- ctx: CreateContextContext,
26
+ ctx: CreateContextContext
27
27
  ): Promise<Context> => {
28
28
  if (!/^[a-z0-9-]+$/.test(ctx.componentName)) {
29
29
  throw new Error(
30
- "componentName may only contain lower case letters, numbers and -",
30
+ "componentName may only contain lower case letters, numbers and -"
31
31
  );
32
32
  }
33
33
 
@@ -53,7 +53,7 @@ export const createContext = async (
53
53
  };
54
54
  const componentConfig = mergeWithMergingArrays(
55
55
  defaults,
56
- componentConfigWithoutDefaults,
56
+ componentConfigWithoutDefaults
57
57
  );
58
58
 
59
59
  return {
@@ -12,9 +12,9 @@ export const resolveReferences = async (
12
12
  vars: Record<string, string | BashExpression | undefined | null>,
13
13
  getOtherVariables?: (
14
14
  componentName: string,
15
- alreadyVisited: Record<string, Record<string, boolean>>,
15
+ alreadyVisited: Record<string, Record<string, boolean>>
16
16
  ) => Promise<UnspecifiedEnvVars>,
17
- alreadyVisitedBase: Record<string, Record<string, boolean>> = {},
17
+ alreadyVisitedBase: Record<string, Record<string, boolean>> = {}
18
18
  ) => {
19
19
  /**
20
20
  *
@@ -22,10 +22,7 @@ export const resolveReferences = async (
22
22
  */
23
23
  const replaceSingleValue = async (
24
24
  value: string | BashExpression,
25
- alreadyVisited: Record<
26
- string,
27
- Record<string, boolean>
28
- > = alreadyVisitedBase,
25
+ alreadyVisited: Record<string, Record<string, boolean>> = alreadyVisitedBase
29
26
  ): Promise<string | BashExpression> => {
30
27
  if (REGEX.test(value.toString())) {
31
28
  // we consider variables that got references in it BashExpressions, because the replacement may be one
@@ -44,7 +41,7 @@ export const resolveReferences = async (
44
41
  });
45
42
  const result = componentName
46
43
  ? (await getOtherVariables?.(componentName, newAlreadyVisited).then(
47
- (r) => r?.[variableName],
44
+ (r) => r?.[variableName]
48
45
  )) ?? null
49
46
  : vars[variableName]; // is self reference
50
47
 
@@ -54,7 +51,7 @@ export const resolveReferences = async (
54
51
  : match;
55
52
 
56
53
  return replaced;
57
- },
54
+ }
58
55
  );
59
56
  } else {
60
57
  return value;
@@ -74,13 +71,13 @@ export const resolveReferences = async (
74
71
  ? await replaceSingleValue(value)
75
72
  : null,
76
73
  ];
77
- }),
78
- ),
74
+ })
75
+ )
79
76
  ) as Record<string, BashExpression>;
80
77
  };
81
78
 
82
79
  export const translateLegacyFromComponents = (
83
- fromComponents: Record<string, Record<string, string>>,
80
+ fromComponents: Record<string, Record<string, string>>
84
81
  ) => {
85
82
  return Object.fromEntries(
86
83
  Object.entries(fromComponents).flatMap(([componentName, variables]) => {
@@ -88,6 +85,6 @@ export const translateLegacyFromComponents = (
88
85
  ourName,
89
86
  "${" + componentName + ":" + otherName + "}",
90
87
  ]);
91
- }),
88
+ })
92
89
  );
93
90
  };
@@ -16,7 +16,7 @@ import {
16
16
  export const transformJobOnlyVars = async (
17
17
  env: string,
18
18
  componentName: string,
19
- vars: EnvVars | null,
19
+ vars: EnvVars | null
20
20
  ): Promise<{
21
21
  envVars: UnspecifiedEnvVars;
22
22
  secretEnvVarKeys: SecretEnvVar[];
@@ -8,7 +8,7 @@ export const stringifyValues = (obj: Record<string, unknown>) =>
8
8
  Object.entries(obj).map(([key, value]) => [
9
9
  key,
10
10
  isObject(value) ? JSON.stringify(value) : `${value}`,
11
- ]),
11
+ ])
12
12
  );
13
13
 
14
14
  export const stringListToSecreteEnvVarList = (keys: string[]): SecretEnvVar[] =>
@@ -16,12 +16,12 @@ export const stringListToSecreteEnvVarList = (keys: string[]): SecretEnvVar[] =>
16
16
  export const makeSecretEnvVarMapping = (
17
17
  env: string,
18
18
  componentName: string,
19
- secretEnvVars: SecretEnvVar[],
19
+ secretEnvVars: SecretEnvVar[]
20
20
  ) => {
21
21
  return Object.fromEntries(
22
22
  secretEnvVars.map(({ key }) => [
23
23
  key,
24
24
  getBashVariable(getSecretVarName(env, componentName, key)),
25
- ]),
25
+ ])
26
26
  );
27
27
  };