@catladder/pipeline 1.148.0 → 1.149.0

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 (59) hide show
  1. package/dist/bundles/catladder-gitlab/index.js +2 -2
  2. package/dist/config/__tests__/getAllEnvs.test.d.ts +1 -0
  3. package/dist/config/__tests__/getAllEnvs.test.js +79 -0
  4. package/dist/config/__tests__/getAllEnvsInAllComponents.test.d.ts +1 -0
  5. package/dist/config/__tests__/getAllEnvsInAllComponents.test.js +73 -0
  6. package/dist/constants.js +1 -1
  7. package/dist/context/getBuildInfoVariables.js +1 -1
  8. package/dist/deploy/cloudRun/createJobs/common.js +1 -1
  9. package/dist/deploy/sbom.js +2 -2
  10. package/dist/pipeline/__tests__/getPipelineStages.test.d.ts +1 -0
  11. package/dist/pipeline/__tests__/getPipelineStages.test.js +73 -0
  12. package/dist/pipeline/getPipelineStages.d.ts +3 -4
  13. package/dist/pipeline/getPipelineStages.js +6 -5
  14. package/dist/tsconfig.tsbuildinfo +1 -1
  15. package/dist/utils/writeFiles.d.ts +5 -1
  16. package/dist/utils/writeFiles.js +10 -2
  17. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +20 -41
  18. package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +20 -41
  19. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +20 -41
  20. package/examples/__snapshots__/cloud-run-no-service.ts.snap +20 -41
  21. package/examples/__snapshots__/cloud-run-non-public.ts.snap +20 -41
  22. package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +20 -41
  23. package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +20 -41
  24. package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +20 -41
  25. package/examples/__snapshots__/cloud-run-storybook.ts.snap +20 -41
  26. package/examples/__snapshots__/cloud-run-with-ngnix.ts.snap +20 -41
  27. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +40 -61
  28. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +40 -61
  29. package/examples/__snapshots__/cloud-run-with-worker.ts.snap +20 -41
  30. package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +20 -41
  31. package/examples/__snapshots__/custom-build-job.ts.snap +20 -41
  32. package/examples/__snapshots__/custom-deploy.ts.snap +16 -37
  33. package/examples/__snapshots__/custom-envs.ts.snap +6 -27
  34. package/examples/__snapshots__/custom-sbom-java.ts.snap +20 -41
  35. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +28 -49
  36. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +28 -49
  37. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +28 -49
  38. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +56 -77
  39. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +28 -49
  40. package/examples/__snapshots__/local-dot-env.ts.snap +20 -41
  41. package/examples/__snapshots__/meteor-kubernetes.ts.snap +28 -49
  42. package/examples/__snapshots__/multiline-var.ts.snap +48 -69
  43. package/examples/__snapshots__/native-app.ts.snap +36 -57
  44. package/examples/__snapshots__/node-build-with-custom-image.ts.snap +20 -41
  45. package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +20 -41
  46. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +48 -90
  47. package/examples/__snapshots__/wait-for-other-deploy.ts.snap +24 -45
  48. package/package.json +1 -1
  49. package/src/config/__tests__/__snapshots__/getAllEnvs.test.ts.snap +31 -0
  50. package/src/config/__tests__/__snapshots__/getAllEnvsInAllComponents.test.ts.snap +15 -0
  51. package/src/config/__tests__/getAllEnvs.test.ts +71 -0
  52. package/src/config/__tests__/getAllEnvsInAllComponents.test.ts +63 -0
  53. package/src/context/getBuildInfoVariables.ts +1 -1
  54. package/src/deploy/cloudRun/createJobs/common.ts +1 -1
  55. package/src/deploy/sbom.ts +2 -2
  56. package/src/pipeline/__tests__/__snapshots__/getPipelineStages.test.ts.snap +69 -0
  57. package/src/pipeline/__tests__/getPipelineStages.test.ts +63 -0
  58. package/src/pipeline/getPipelineStages.ts +6 -5
  59. package/src/utils/writeFiles.ts +14 -1
@@ -0,0 +1,63 @@
1
+ import { type DeployConfigKubernetesCluster } from "../..";
2
+ import type { Config } from "../../types";
3
+ import { getPipelineStages } from "../getPipelineStages";
4
+
5
+ describe("getPipelineStages()", () => {
6
+ const cluster: DeployConfigKubernetesCluster = {
7
+ type: "gcloud",
8
+ name: "mega-cluster",
9
+ projectId: "super-google-project",
10
+ region: "ch-blabla",
11
+ };
12
+ const SIMPLE_CONFIG1: Config = {
13
+ appName: "my-app",
14
+ customerName: "pan",
15
+ components: {
16
+ app1: {
17
+ dir: "dir1",
18
+ build: {
19
+ type: "node",
20
+ },
21
+ deploy: { type: "kubernetes", cluster },
22
+ },
23
+ app2: {
24
+ dir: "dir2",
25
+ build: {
26
+ type: "node",
27
+ },
28
+ deploy: { type: "kubernetes", cluster },
29
+ env: {
30
+ dev2: {
31
+ type: "dev",
32
+ },
33
+ review2: {
34
+ type: "review",
35
+ },
36
+ stage2: {
37
+ type: "stage",
38
+ },
39
+ prod2: {
40
+ type: "prod",
41
+ },
42
+ },
43
+ },
44
+ app3: {
45
+ dir: "dir2",
46
+ build: {
47
+ type: "node",
48
+ },
49
+ deploy: { type: "kubernetes", cluster },
50
+ env: {
51
+ dev: false,
52
+ review: false,
53
+ stage: false,
54
+ prod: false,
55
+ },
56
+ },
57
+ },
58
+ };
59
+
60
+ it("should return all envs for SIMPLE_CONFIG1", () => {
61
+ expect(getPipelineStages(SIMPLE_CONFIG1)).toMatchSnapshot();
62
+ });
63
+ });
@@ -3,13 +3,14 @@ import type { Config } from "../types/config";
3
3
  import { BASE_STAGES } from "../types/jobs";
4
4
 
5
5
  /**
6
- *
7
- while technically not required, we group different envs in its own stage
8
- each job from `createJobs` that is defined as `envMode: "stagePerEnv"` will have `deploy dev`, etc. instead of just `deploy`
9
- this is just so that it looks nicer in gitlab and makes running mutliple manual tasks more easy to use
6
+ * while technically not required, we group different envs in its own stage
7
+ * each job from `createJobs` that is defined as `envMode: "stagePerEnv"` will have `deploy dev`, etc. instead of just `deploy`
8
+ * this is just so that it looks nicer in gitlab and makes running mutliple manual tasks more easy to use
10
9
  */
11
10
  export function getPipelineStages(config: Config) {
12
- const allEnvs = getAllEnvsInAllComponents(config);
11
+ const allEnvs = getAllEnvsInAllComponents(config).filter(
12
+ (e) => e !== "local",
13
+ );
13
14
  const stages = BASE_STAGES.reduce<string[]>(
14
15
  (acc, baseStage) => [
15
16
  ...acc,
@@ -33,8 +33,21 @@ export const writeGeneratedFile = async (
33
33
  );
34
34
  };
35
35
 
36
+ type StringifyOptions = Exclude<
37
+ Parameters<typeof stringify>[2],
38
+ null | undefined | string | number
39
+ >;
40
+ export const yamlStringifyOptions: StringifyOptions = {
41
+ // prevents colapsing long command statements into multiple lines
42
+ lineWidth: 0,
43
+ // represent multi line commands as single line json strings
44
+ doubleQuotedAsJSON: true,
45
+ // Better readability when bash commands most often use double quotes
46
+ singleQuote: true,
47
+ };
48
+
36
49
  export const writeYamlfile = async (path: string, data: any) => {
37
- await writeGeneratedFile(path, stringify(data), {
50
+ await writeGeneratedFile(path, stringify(data, yamlStringifyOptions), {
38
51
  commentChar: "#",
39
52
  });
40
53
  };