@catladder/cli 5.2.0 → 5.3.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 (88) hide show
  1. package/dist/apps/cli/src/commands/project/commandPortForward.js +1 -1
  2. package/dist/apps/cli/src/commands/project/commandPortForward.js.map +1 -1
  3. package/dist/apps/cli/src/commands/project/secrets/scope.js +25 -2
  4. package/dist/apps/cli/src/commands/project/secrets/scope.js.map +1 -1
  5. package/dist/apps/cli/src/config/getProjectConfig.js +4 -1
  6. package/dist/apps/cli/src/config/getProjectConfig.js.map +1 -1
  7. package/dist/apps/cli/src/secrets/github.js +4 -2
  8. package/dist/apps/cli/src/secrets/github.js.map +1 -1
  9. package/dist/bundles/catenv/index.js +390 -106
  10. package/dist/bundles/cli/index.js +420 -111
  11. package/dist/bundles/skills/catladder-config/SKILL.md +34 -2
  12. package/dist/bundles/skills/catladder-deploys/SKILL.md +5 -0
  13. package/dist/bundles/skills/catladder-pipelines/SKILL.md +10 -1
  14. package/dist/bundles/skills/catladder-secrets/SKILL.md +6 -0
  15. package/dist/packages/pipeline/src/backends/github/GithubBackend.js +23 -3
  16. package/dist/packages/pipeline/src/backends/github/GithubBackend.js.map +1 -1
  17. package/dist/packages/pipeline/src/backends/github/createGithubJobs.js +2 -2
  18. package/dist/packages/pipeline/src/backends/github/createGithubJobs.js.map +1 -1
  19. package/dist/packages/pipeline/src/backends/gitlab/GitlabBackend.js +18 -2
  20. package/dist/packages/pipeline/src/backends/gitlab/GitlabBackend.js.map +1 -1
  21. package/dist/packages/pipeline/src/backends/gitlab/createGitlabJobs.js +2 -2
  22. package/dist/packages/pipeline/src/backends/gitlab/createGitlabJobs.js.map +1 -1
  23. package/dist/packages/pipeline/src/backends/gitlab/createGitlabPipeline.d.ts +6 -1
  24. package/dist/packages/pipeline/src/backends/gitlab/createGitlabPipeline.js +8 -1
  25. package/dist/packages/pipeline/src/backends/gitlab/createGitlabPipeline.js.map +1 -1
  26. package/dist/packages/pipeline/src/config/configruedEnvs.d.ts +9 -2
  27. package/dist/packages/pipeline/src/config/configruedEnvs.js +54 -5
  28. package/dist/packages/pipeline/src/config/configruedEnvs.js.map +1 -1
  29. package/dist/packages/pipeline/src/context/createAllComponentsContext.d.ts +2 -2
  30. package/dist/packages/pipeline/src/context/createComponentContext.d.ts +2 -2
  31. package/dist/packages/pipeline/src/context/createWorkspaceContext.d.ts +2 -2
  32. package/dist/packages/pipeline/src/context/getEnvConfig.js +35 -19
  33. package/dist/packages/pipeline/src/context/getEnvConfig.js.map +1 -1
  34. package/dist/packages/pipeline/src/context/getEnvInherit.d.ts +20 -0
  35. package/dist/packages/pipeline/src/context/getEnvInherit.js +72 -0
  36. package/dist/packages/pipeline/src/context/getEnvInherit.js.map +1 -0
  37. package/dist/packages/pipeline/src/context/getEnvInstance.d.ts +4 -0
  38. package/dist/packages/pipeline/src/context/{getReviewSlug.js → getEnvInstance.js} +13 -9
  39. package/dist/packages/pipeline/src/context/getEnvInstance.js.map +1 -0
  40. package/dist/packages/pipeline/src/context/getEnvOn.d.ts +13 -0
  41. package/dist/packages/pipeline/src/context/getEnvOn.js +28 -0
  42. package/dist/packages/pipeline/src/context/getEnvOn.js.map +1 -0
  43. package/dist/packages/pipeline/src/context/getEnvType.d.ts +8 -2
  44. package/dist/packages/pipeline/src/context/getEnvType.js +27 -5
  45. package/dist/packages/pipeline/src/context/getEnvType.js.map +1 -1
  46. package/dist/packages/pipeline/src/context/getEnvironment.js +3 -0
  47. package/dist/packages/pipeline/src/context/getEnvironment.js.map +1 -1
  48. package/dist/packages/pipeline/src/context/getEnvironmentContext.js +18 -8
  49. package/dist/packages/pipeline/src/context/getEnvironmentContext.js.map +1 -1
  50. package/dist/packages/pipeline/src/context/getEnvironmentVariables.d.ts +1 -1
  51. package/dist/packages/pipeline/src/context/getEnvironmentVariables.js +4 -4
  52. package/dist/packages/pipeline/src/context/getEnvironmentVariables.js.map +1 -1
  53. package/dist/packages/pipeline/src/context/index.d.ts +1 -0
  54. package/dist/packages/pipeline/src/context/index.js +1 -0
  55. package/dist/packages/pipeline/src/context/index.js.map +1 -1
  56. package/dist/packages/pipeline/src/deploy/base/deploy.js +11 -1
  57. package/dist/packages/pipeline/src/deploy/base/deploy.js.map +1 -1
  58. package/dist/packages/pipeline/src/deploy/cloudRun/artifactsRegistry.js +5 -4
  59. package/dist/packages/pipeline/src/deploy/cloudRun/artifactsRegistry.js.map +1 -1
  60. package/dist/packages/pipeline/src/deploy/cloudRun/cleanup.js +8 -2
  61. package/dist/packages/pipeline/src/deploy/cloudRun/cleanup.js.map +1 -1
  62. package/dist/packages/pipeline/src/deploy/cloudRun/index.js +2 -2
  63. package/dist/packages/pipeline/src/deploy/cloudRun/index.js.map +1 -1
  64. package/dist/packages/pipeline/src/deploy/cloudRun/utils/getServiceName.js +2 -2
  65. package/dist/packages/pipeline/src/deploy/cloudRun/utils/getServiceName.js.map +1 -1
  66. package/dist/packages/pipeline/src/deploy/kubernetes/index.js +3 -3
  67. package/dist/packages/pipeline/src/deploy/kubernetes/index.js.map +1 -1
  68. package/dist/packages/pipeline/src/deploy/pages/deployJob.js +3 -2
  69. package/dist/packages/pipeline/src/deploy/pages/deployJob.js.map +1 -1
  70. package/dist/packages/pipeline/src/deploy/types/googleCloudRun.d.ts +9 -0
  71. package/dist/packages/pipeline/src/types/config.d.ts +126 -9
  72. package/dist/packages/pipeline/src/types/config.js +11 -10
  73. package/dist/packages/pipeline/src/types/config.js.map +1 -1
  74. package/dist/packages/pipeline/src/types/context.d.ts +22 -3
  75. package/dist/packages/pipeline/src/types/context.js.map +1 -1
  76. package/dist/packages/pipeline/src/types/environmentContext.d.ts +29 -0
  77. package/dist/skills/catladder-config/SKILL.md +34 -2
  78. package/dist/skills/catladder-deploys/SKILL.md +5 -0
  79. package/dist/skills/catladder-pipelines/SKILL.md +10 -1
  80. package/dist/skills/catladder-secrets/SKILL.md +6 -0
  81. package/dist/tsconfig.tsbuildinfo +1 -1
  82. package/package.json +1 -1
  83. package/src/commands/project/commandPortForward.ts +1 -1
  84. package/src/commands/project/secrets/scope.ts +38 -2
  85. package/src/config/getProjectConfig.ts +9 -1
  86. package/src/secrets/github.ts +8 -5
  87. package/dist/packages/pipeline/src/context/getReviewSlug.d.ts +0 -4
  88. package/dist/packages/pipeline/src/context/getReviewSlug.js.map +0 -1
@@ -3,7 +3,8 @@ import type { BuildConfigFromWorkspace, BuildConfigStandalone, WorkspaceBuildCon
3
3
  import type { PredefinedVariables, SecretEnvVar } from "../context";
4
4
  import type { DeployConfig } from "../deploy";
5
5
  import type { VariableValue } from "../../../bash/src/index.js";
6
- import type { ComponentConfig, Config, EnvType, PipelineTrigger } from "./config";
6
+ import type { ComponentConfig, Config, EnvPipelineTrigger, EnvType } from "./config";
7
+ import type { EnvironmentInstance } from "./environmentContext";
7
8
  import type { BaseStage, CatladderJob, CatladderJobSpec } from "./jobs";
8
9
  import type { PipelineType } from "./pipeline";
9
10
  export type UnspecifiedEnvVars = Record<string, VariableValue | undefined | null>;
@@ -29,8 +30,14 @@ export type Environment = {
29
30
  * the environment slug without component name.
30
31
  */
31
32
  slugPrefix: StringOrBashExpression;
33
+ /**
34
+ * how the env is instantiated — `instance.type === "review"` is the
35
+ * way to find out whether this is a review app
36
+ */
37
+ instance: EnvironmentInstance;
32
38
  /**
33
39
  * the review slug, if it is a review app, null otherwise
40
+ * @deprecated use `instance` — the review variant carries the slug
34
41
  */
35
42
  reviewSlug: StringOrBashExpression | null;
36
43
  /**
@@ -38,6 +45,18 @@ export type Environment = {
38
45
  */
39
46
  slug: StringOrBashExpression;
40
47
  envType: EnvType;
48
+ /**
49
+ * the resolved `autoStop` config (component override, then the
50
+ * project-wide environment config — see {@link EnvironmentConfig.autoStop});
51
+ * undefined means the env type's default applies
52
+ */
53
+ autoStop?: string | false;
54
+ /**
55
+ * the env whose secret values this env uses — the env itself unless
56
+ * it shares another env's secrets via `inherit`. All secret variable
57
+ * names are built with this env.
58
+ */
59
+ secretsEnv: string;
41
60
  } & EnvironmentEnvVarPart;
42
61
  export type YarnWorkspace = {
43
62
  name: string;
@@ -136,7 +155,7 @@ export type ComponentContext<BC extends BuildContextComponent = BuildContextComp
136
155
  deploy?: DeployContext | null;
137
156
  fullConfig: Config;
138
157
  environment: Environment;
139
- trigger?: PipelineTrigger;
158
+ trigger?: EnvPipelineTrigger;
140
159
  pipelineType?: PipelineType;
141
160
  packageManagerInfo: Promise<PackageManagerInfoComponent>;
142
161
  customJobs?: CatladderJobSpec[];
@@ -159,7 +178,7 @@ export type WorkspaceContext = {
159
178
  packageManagerInfo: Promise<PackageManagerInfoBase>;
160
179
  components: Array<ComponentContext>;
161
180
  build: BuildContextWorkspace;
162
- trigger: PipelineTrigger;
181
+ trigger: EnvPipelineTrigger;
163
182
  pipelineType: PipelineType;
164
183
  env: string;
165
184
  };
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/types/context.ts"],"names":[],"mappings":";;;AAiNO,MAAM,iCAAiC,GAAG,CAC/C,OAAgD,EACK,EAAE;IACvD,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;AAC7C,CAAC,CAAC;AAJW,QAAA,iCAAiC,qCAI5C;AAEK,MAAM,iCAAiC,GAAG,CAC/C,OAAgD,EACQ,EAAE;IAC1D,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC;AAChD,CAAC,CAAC;AAJW,QAAA,iCAAiC,qCAI5C"}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/types/context.ts"],"names":[],"mappings":";;;AAsOO,MAAM,iCAAiC,GAAG,CAC/C,OAAgD,EACK,EAAE;IACvD,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;AAC7C,CAAC,CAAC;AAJW,QAAA,iCAAiC,qCAI5C;AAEK,MAAM,iCAAiC,GAAG,CAC/C,OAAgD,EACQ,EAAE;IAC1D,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC;AAChD,CAAC,CAAC;AAJW,QAAA,iCAAiC,qCAI5C"}
@@ -3,20 +3,49 @@ import type { BuildConfig } from "../build";
3
3
  import type { DeployConfig } from "../deploy";
4
4
  import type { Config, EnvConfigWithComponent, EnvType } from "./config";
5
5
  import type { PipelineType } from "./pipeline";
6
+ /**
7
+ * how an environment is instantiated:
8
+ * - "stable": one long-lived instance (dev, stage, prod, branch envs)
9
+ * - "review": one instance per merge/pull request (`on: "mr"`),
10
+ * addressed by the runtime review slug (mr<iid> / pr<number>)
11
+ */
12
+ export type EnvironmentInstance = {
13
+ type: "stable";
14
+ } | {
15
+ type: "review";
16
+ reviewSlug: StringOrBashExpression;
17
+ };
6
18
  export type EnvironmentContext<B extends BuildConfig = BuildConfig, D extends DeployConfig = DeployConfig> = {
7
19
  envConfigRaw: EnvConfigWithComponent;
8
20
  buildConfigRaw: false | B;
9
21
  deployConfigRaw: false | D;
10
22
  env: string;
11
23
  envType: EnvType;
24
+ /**
25
+ * the resolved autoStop config (component override, then project-wide
26
+ * environment config); undefined means the env type's default applies
27
+ */
28
+ autoStop?: string | false;
29
+ /**
30
+ * the env whose secret values this env uses — the env itself unless
31
+ * it shares another env's secrets via `inherit`. All secret variable
32
+ * names are built with this env.
33
+ */
34
+ secretsEnv: string;
12
35
  componentName: string;
13
36
  fullName: StringOrBashExpression;
14
37
  /**
15
38
  * the environment slug without component name.
16
39
  */
17
40
  environmentSlugPrefix: StringOrBashExpression;
41
+ /**
42
+ * how the env is instantiated — `instance.type === "review"` is the
43
+ * way to find out whether this is a review app
44
+ */
45
+ instance: EnvironmentInstance;
18
46
  /**
19
47
  * the review slug, if it is a review app, null otherwise
48
+ * @deprecated use `instance` — the review variant carries the slug
20
49
  */
21
50
  reviewSlug: StringOrBashExpression | null;
22
51
  /**
@@ -33,6 +33,10 @@ const config = {
33
33
  appName: "my-app",
34
34
  customerName: "pan",
35
35
  pipelines: { gitlab: true, github: true }, // which CI systems to generate
36
+ environments: { // optional: project-wide env declarations/tuning
37
+ review: { autoStop: "3 days" },
38
+ next: { type: "dev", on: { branch: "next" } }, // extra branch-tracking env
39
+ },
36
40
  components: {
37
41
  www: {
38
42
  dir: "frontend", // working directory of this component
@@ -59,8 +63,36 @@ Key concepts:
59
63
  - **Environments**: `dev` (deployed on push to the main branch),
60
64
  `review` (per merge/pull request), `stage` and `prod` (deployed on
61
65
  tagged releases), `local` (only for local development via catenv).
62
- Per-env overrides live under `env.<name>` and can override vars,
63
- deploy settings, and more.
66
+ Environments are project-wide: the top-level `environments` config
67
+ declares and tunes them consistently for all components, while
68
+ per-component `env.<name>` entries only carry component-local
69
+ overrides (vars, deploy settings, host, autoStop) or `false` to opt
70
+ the component out. In `environments`:
71
+ - `on` — when the env deploys: `"mainBranch"`, `"mr"`,
72
+ `"taggedRelease"`, `{ branch: "next" }` (a stable env deploying on
73
+ pushes to that branch), or `false` (in no pipeline). `on: "mr"`
74
+ makes an env a review app (one instance per MR/PR, torn down on
75
+ close). Defaults from the env type.
76
+ - `autoStop` — how long a stoppable environment stays up after its
77
+ last deploy before gitlab stops it (e.g. `"3 days"`; `false`
78
+ disables). Defaults: review `"1 week"`, dev `"4 weeks"`, others
79
+ never. GitLab only — github review apps stop when their PR closes.
80
+ Components can override it per env (`env.<name>.autoStop`).
81
+ - Extra envs are declared with any name plus a `type` — the env type
82
+ acts as a preset: it supplies all defaults (trigger, autoStop,
83
+ deploy policy) and the env's identity for tooling (`ENV_TYPE`),
84
+ everything overridable. Every component deploys to a declared env
85
+ unless it opts out:
86
+ `environments: { next: { type: "dev", on: { branch: "next" } } }`.
87
+ - `inherit` — make an env inherit from another env:
88
+ `inherit: "dev"` gives it dev's per-component config overrides
89
+ (merged below its own; `host` and `type` never inherit, the env
90
+ type is implied from the inherited env) AND dev's secret values —
91
+ all-or-nothing: its jobs reference dev's `CL_DEV_*` variables and
92
+ it has no secret store of its own (manage secrets via dev; rotating
93
+ affects both). The object form separates the axes:
94
+ `inherit: { config: "dev" }` inherits config only,
95
+ `inherit: { config: "dev", secrets: "dev" }` both.
64
96
  - **Pipelines**: `pipelines: { gitlab: true, github: true }` selects
65
97
  which CI systems get generated files. Options objects instead of
66
98
  `true` allow per-pipeline settings (e.g. `runnerVariables`,
@@ -78,6 +78,11 @@ Everything app-level lives under `values`:
78
78
  completion jobs, and always-on background worker pools.
79
79
  - `cloudSql` — attach an (unmanaged) CloudSQL instance; choose the
80
80
  connection-string format (`prisma` default, `rails`, `jdbc`).
81
+ `deleteDatabaseOnStop` controls whether the database is dropped when
82
+ the environment stops (default: true for review envs, false else).
83
+ - `revisionsToKeep` — how many inactive revisions (the rollback
84
+ history) the post-deploy cleanup keeps; older revisions and their
85
+ images are deleted. Default: 5 on prod envs, 0 everywhere else.
81
86
  - `execute` — run a script/job/HTTP call at a deploy lifecycle point
82
87
  (`preDeploy`/`postDeploy`/`preStop`/`postStop`) or on a `schedule`.
83
88
  Prefer this over the deprecated `when`/`schedule` fields on `jobs`.
@@ -11,11 +11,20 @@ generated YAML.
11
11
 
12
12
  ## Triggers and environments
13
13
 
14
- | Trigger | Runs on | Deploys to |
14
+ | Trigger | Runs on | Deploys to (default) |
15
15
  |---|---|---|
16
16
  | `mainBranch` | push to the main branch | `dev` |
17
17
  | `mr` | merge/pull requests | `review` (one app per MR/PR) |
18
18
  | `taggedRelease` | git tags | `stage`, `prod` |
19
+ | `{ branch: "<name>" }` | push to that branch | envs declaring it via `on` |
20
+
21
+ The trigger of each env is its `on` in the top-level `environments`
22
+ config (project-wide — components cannot diverge), defaulting from the
23
+ env type as in the table. An env with `on: { branch: "next" }` gets its
24
+ own pipeline (gitlab: rules on `$CI_COMMIT_BRANCH`; github: a
25
+ `catladder-branch-<name>.yml` workflow) and deploys as one stable,
26
+ branch-tracking environment — unlike review apps, it is not
27
+ per-instance and is stopped via the manual stop job/workflow.
19
28
 
20
29
  Generated layout:
21
30
 
@@ -38,6 +38,12 @@ files in the repo. All secrets commands accept a **scope**:
38
38
  `dev:web` (one env of one component), `dev:` (one env, all
39
39
  components), `:web` (all envs of one component), or nothing (everything).
40
40
 
41
+ An env that shares another env's secrets (top-level
42
+ `environments.<name>.inherit`, e.g. a `next` branch env inheriting from
43
+ dev) has **no secret store of its own** — its jobs reference the source
44
+ env's variables directly, so it never appears in secrets scopes: manage
45
+ (and rotate) the values via the source env, which affects both.
46
+
41
47
  Check what is declared and what is still unset (never prints values
42
48
  unless `--reveal` is passed):
43
49