@catladder/pipeline 1.149.4 → 1.150.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.
@@ -0,0 +1,27 @@
1
+ import type { Config } from "../src";
2
+ import { createAllPipelines } from "./__utils__/helpers";
3
+ const config: Config = {
4
+ appName: "test-app",
5
+ customerName: "pan",
6
+ components: {
7
+ api: {
8
+ dir: "api",
9
+ build: {
10
+ type: "node",
11
+ },
12
+ deploy: {
13
+ type: "google-cloudrun",
14
+ projectId: "google-project-id",
15
+ region: "europe-west6",
16
+
17
+ service: {
18
+ timeout: "10m20s",
19
+ },
20
+ },
21
+ },
22
+ },
23
+ };
24
+
25
+ it("matches snapshot", async () => {
26
+ expect(await createAllPipelines(config)).toMatchSnapshot();
27
+ });
package/package.json CHANGED
@@ -52,7 +52,7 @@
52
52
  }
53
53
  ],
54
54
  "license": "MIT",
55
- "version": "1.149.4",
55
+ "version": "1.150.1",
56
56
  "scripts": {
57
57
  "build:tsc": "yarn tsc",
58
58
  "build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
@@ -10,7 +10,7 @@ import type { PartialDeep } from "../types/utils";
10
10
  import { mergeWithMergingArrays } from "../utils";
11
11
  import { getEnvironment } from "./getEnvironment";
12
12
  import { getEnvironmentContext } from "./getEnvironmentContext";
13
- import { getPackageManagerInfo } from "../pipeline/packageManager";
13
+ import { getPackageManagerInfoForComponent } from "../pipeline/packageManager";
14
14
 
15
15
  export type CreateComponentContextContext = {
16
16
  config: Config;
@@ -29,7 +29,7 @@ export const createComponentContext = async (
29
29
  );
30
30
  }
31
31
 
32
- const packageManagerInfo = await getPackageManagerInfo(
32
+ const packageManagerInfo = await getPackageManagerInfoForComponent(
33
33
  ctx.config,
34
34
  ctx.componentName,
35
35
  );
@@ -49,6 +49,7 @@ export const getServiceDeployScript = (
49
49
  "cpu-throttling": customConfig?.noCpuThrottling !== true,
50
50
  cpu: customConfig?.cpu,
51
51
  memory: customConfig?.memory,
52
+ timeout: customConfig?.timeout,
52
53
  "allow-unauthenticated": customConfig?.allowUnauthenticated ?? true,
53
54
  ingress: customConfig?.ingress ?? "all",
54
55
  "cpu-boost": true,
@@ -139,6 +139,15 @@ export type DeployConfigCloudRunService = {
139
139
  */
140
140
  memory?: Memory;
141
141
 
142
+ /**
143
+ * timeout of the service, defaults to 5 minutes.
144
+ *
145
+ * you can specify something like 10m30s. if its just a number, it will be interpreted as seconds
146
+ *
147
+ * max supported is 60min
148
+ */
149
+ timeout?: string;
150
+
142
151
  /**
143
152
  *
144
153
  * set the execution environment.
@@ -21,41 +21,36 @@ export type AllJobsContext = {
21
21
  pipelineType: PipelineType;
22
22
  };
23
23
 
24
- type AllComponentContext = {
25
- [componentName: string]: {
26
- [env: string]: ComponentContext;
27
- };
28
- };
29
-
30
24
  const createAllComponentContext = async ({
31
25
  config,
32
26
  trigger,
33
27
  pipelineType,
34
- }: AllJobsContext): Promise<AllComponentContext> => {
35
- return Object.fromEntries(
36
- await Promise.all(
37
- Object.keys(config.components).map(async (componentName) => {
38
- const envs = getAllEnvsByTrigger(config, componentName, trigger);
39
- return [
28
+ }: AllJobsContext): Promise<
29
+ Array<{
30
+ env: string;
31
+ componentName: string;
32
+ context: ComponentContext;
33
+ }>
34
+ > => {
35
+ return await Promise.all(
36
+ Object.keys(config.components).flatMap((componentName) => {
37
+ const envs = getAllEnvsByTrigger(config, componentName, trigger);
38
+ return envs.map(async (env) => {
39
+ const context = await createComponentContext({
40
+ config,
40
41
  componentName,
41
- Object.fromEntries(
42
- await Promise.all(
43
- envs.map(async (env) => {
44
- const context = await createComponentContext({
45
- config,
46
- componentName,
47
- env,
48
- trigger,
49
- pipelineType,
50
- });
42
+ env,
43
+ trigger,
44
+ pipelineType,
45
+ });
51
46
 
52
- return [env, context];
53
- }),
54
- ),
55
- ),
56
- ];
57
- }),
58
- ),
47
+ return {
48
+ env,
49
+ componentName,
50
+ context,
51
+ };
52
+ });
53
+ }),
59
54
  );
60
55
  };
61
56
 
@@ -70,18 +65,17 @@ export const createAllJobs = async ({
70
65
  pipelineType,
71
66
  });
72
67
 
73
- return Object.fromEntries(
74
- Object.entries(allComponentContext).map(([componentName, envs]) => [
75
- componentName,
76
- Object.fromEntries(
77
- Object.entries(envs).map(([env, context]) => [
78
- env,
79
- createJobsForComponentContext(context).map((job) => ({
80
- ...job,
81
- context,
82
- })),
83
- ]),
84
- ),
85
- ]),
86
- );
68
+ return allComponentContext.reduce((acc, { componentName, env, context }) => {
69
+ if (!acc[componentName]) {
70
+ acc[componentName] = {};
71
+ }
72
+ acc[componentName][env] = createJobsForComponentContext(context).map(
73
+ (job) => ({
74
+ ...job,
75
+ context,
76
+ }),
77
+ );
78
+
79
+ return acc;
80
+ }, {} as AllCatladderJobs);
87
81
  };
@@ -1,17 +1,17 @@
1
1
  import { existsSync } from "fs";
2
2
  import { join } from "path";
3
3
  import { pathEqual } from "path-equal";
4
- import type { Config, PackageManagerInfo } from "../types";
4
+ import type { Config, PackageManagerInfoComponent } from "../types";
5
5
  import {
6
6
  getWorkspaces,
7
7
  getYarnVersion,
8
8
  getWorkspaceDependencies,
9
9
  } from "./yarn/yarnUtils";
10
10
 
11
- export const getPackageManagerInfo = async (
11
+ export const getPackageManagerInfoForComponent = async (
12
12
  config: Config,
13
13
  componentName: string,
14
- ): Promise<PackageManagerInfo> => {
14
+ ): Promise<PackageManagerInfoComponent> => {
15
15
  // currently only supports yarn
16
16
  const version = await getYarnVersion();
17
17
  if (!version) throw new Error("could not get yarn version");
@@ -1,6 +1,6 @@
1
1
  import { exec } from "child-process-promise";
2
2
  import memoizee from "memoizee";
3
- import type { PackageManagerInfo, YarnWorkspace } from "../../types";
3
+ import type { PackageManagerInfoComponent, YarnWorkspace } from "../../types";
4
4
 
5
5
  const execOrFail = async (cmd: string, onFail: string): Promise<string> => {
6
6
  try {
@@ -18,7 +18,7 @@ export const getYarnVersion = memoizee(
18
18
  );
19
19
  // export for mocking
20
20
  export const getWorkspaces = memoizee(
21
- async (isClassic: boolean): Promise<PackageManagerInfo["workspaces"]> => {
21
+ async (isClassic: boolean): Promise<Array<YarnWorkspace>> => {
22
22
  return isClassic
23
23
  ? Object.values(
24
24
  JSON.parse(
@@ -66,7 +66,7 @@ export type YarnWorkspace = {
66
66
  workspaceDependencies: string[];
67
67
  mismatchedWorkspaceDependencies: string[];
68
68
  };
69
- export type YarnPackageManagerInfo = {
69
+ export type YarnPackageManagerInfoComponent = {
70
70
  type: "yarn";
71
71
  version: string;
72
72
  workspaces: YarnWorkspace[];
@@ -77,20 +77,21 @@ export type YarnPackageManagerInfo = {
77
77
  currentWorkspaceDependencies: string[];
78
78
  };
79
79
 
80
- export type PackageManagerInfo = YarnPackageManagerInfo;
80
+ export type PackageManagerInfoComponent = YarnPackageManagerInfoComponent;
81
81
 
82
82
  export type ContextBeforeConfig = {
83
83
  componentName: string;
84
84
  fullConfig: Config;
85
- packageManagerInfo?: PackageManagerInfo;
85
+ packageManagerInfo?: PackageManagerInfoComponent;
86
86
  };
87
87
 
88
- export type BuildContext = {
88
+ export type BuildContextComponent = {
89
89
  dir: string;
90
- packageManagerInfo: PackageManagerInfo;
90
+ packageManagerInfo: PackageManagerInfoComponent;
91
91
  config: BuildConfig;
92
92
  };
93
93
 
94
+ export type BuildContext = BuildContextComponent;
94
95
  export type DeployContext = {
95
96
  config: DeployConfig;
96
97
  };
@@ -104,7 +105,7 @@ export type ComponentContext = {
104
105
  *
105
106
  */
106
107
  componentConfig: ComponentConfig;
107
- build: BuildContext;
108
+ build: BuildContextComponent;
108
109
  deploy?: DeployContext | null;
109
110
  fullConfig: Config;
110
111
  environment: Environment;
@@ -114,7 +115,7 @@ export type ComponentContext = {
114
115
  /**
115
116
  * @deprecated use buildContext.packageManagerInfo instead
116
117
  */
117
- packageManagerInfo: PackageManagerInfo;
118
+ packageManagerInfo: PackageManagerInfoComponent;
118
119
 
119
120
  customJobs?: CatladderJob[];
120
121
  };