@catladder/cli 0.0.0-next-aea5d3ad → 0.0.0-next-2b60440e
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.
- package/dist/bundles/cli/index.js +705 -229
- package/dist/bundles/runner-images/semantic-release/Dockerfile +15 -12
- package/dist/bundles/runner-images/semantic-release/scripts/semanticRelease +10 -1
- package/dist/bundles/skills/catladder-cli/references/commands.md +37 -2
- package/dist/bundles/skills/catladder-secrets/SKILL.md +42 -9
- package/dist/cli/src/commands/index.d.ts +4 -0
- package/dist/cli/src/commands/index.js +9 -1
- package/dist/cli/src/commands/index.js.map +1 -1
- package/dist/cli/src/commands/project/commandConfigSecrets.d.ts +6 -1
- package/dist/cli/src/commands/project/commandConfigSecrets.js +56 -15
- package/dist/cli/src/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/cli/src/commands/project/secrets/commandSecretsList.d.ts +24 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsList.js +64 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsList.js.map +1 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsPull.d.ts +19 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsPull.js +48 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsPull.js.map +1 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsPush.d.ts +19 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsPush.js +74 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsPush.js.map +1 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsSet.d.ts +24 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsSet.js +82 -0
- package/dist/cli/src/commands/project/secrets/commandSecretsSet.js.map +1 -0
- package/dist/cli/src/commands/project/secrets/document.d.ts +47 -0
- package/dist/cli/src/commands/project/secrets/document.js +180 -0
- package/dist/cli/src/commands/project/secrets/document.js.map +1 -0
- package/dist/cli/src/commands/project/secrets/parseKeysInput.d.ts +2 -0
- package/dist/cli/src/commands/project/secrets/parseKeysInput.js +10 -0
- package/dist/cli/src/commands/project/secrets/parseKeysInput.js.map +1 -0
- package/dist/cli/src/commands/project/secrets/scope.d.ts +35 -0
- package/dist/cli/src/commands/project/secrets/scope.js +113 -0
- package/dist/cli/src/commands/project/secrets/scope.js.map +1 -0
- package/dist/cli/src/utils/readStdin.d.ts +2 -0
- package/dist/cli/src/utils/readStdin.js +13 -0
- package/dist/cli/src/utils/readStdin.js.map +1 -0
- package/dist/runner-images/semantic-release/Dockerfile +15 -12
- package/dist/runner-images/semantic-release/scripts/semanticRelease +10 -1
- package/dist/skills/catladder-cli/references/commands.md +37 -2
- package/dist/skills/catladder-secrets/SKILL.md +42 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/commands/index.ts +4 -0
- package/src/commands/project/commandConfigSecrets.ts +76 -15
- package/src/commands/project/secrets/__tests__/document.test.ts +122 -0
- package/src/commands/project/secrets/commandSecretsList.ts +75 -0
- package/src/commands/project/secrets/commandSecretsPull.ts +55 -0
- package/src/commands/project/secrets/commandSecretsPush.ts +100 -0
- package/src/commands/project/secrets/commandSecretsSet.ts +102 -0
- package/src/commands/project/secrets/document.ts +269 -0
- package/src/commands/project/secrets/parseKeysInput.ts +8 -0
- package/src/commands/project/secrets/scope.ts +151 -0
- package/src/utils/readStdin.ts +8 -0
- package/dist/cli/src/apps/cli/commands/project/commandConfigSecrets.d.ts +0 -2
- package/dist/cli/src/apps/cli/commands/project/commandConfigSecrets.js +0 -206
- package/dist/cli/src/apps/cli/commands/project/commandConfigSecrets.js.map +0 -1
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +0 -322
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
# job images are addressed by a content hash of this directory — the
|
|
2
2
|
# build must be reproducible, so every dependency is pinned exactly.
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
FROM node:
|
|
3
|
+
# node:24 satisfies the newer plugins' engine requirements
|
|
4
|
+
# (@semantic-release/git and @semantic-release/changelog need node >=24.15).
|
|
5
|
+
FROM node:24-alpine
|
|
6
6
|
|
|
7
7
|
RUN apk add --no-cache bash git git-lfs
|
|
8
8
|
|
|
9
9
|
# add semantic release
|
|
10
|
-
# NOTE:
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
10
|
+
# NOTE: pin every dependency exactly. These are the semantic-release@25 line
|
|
11
|
+
# (all ESM — v25 loads plugins via dynamic import, so changelog@7/git@11 are
|
|
12
|
+
# fine). Every plugin declares `semantic-release` as a peer dependency, so a
|
|
13
|
+
# plugin major that outpaces the semantic-release major fails the release job
|
|
14
|
+
# with "plugins configuration is invalid" — bump them together. Upstream
|
|
15
|
+
# @semantic-release/git replaces the old panter fork; see
|
|
16
|
+
# scripts/semanticRelease for why the commit message is hardcoded.
|
|
14
17
|
RUN yarn global add \
|
|
15
|
-
semantic-release@
|
|
18
|
+
semantic-release@25.0.8 \
|
|
16
19
|
@semantic-release/commit-analyzer@13.0.1 \
|
|
17
20
|
@semantic-release/release-notes-generator@14.1.1 \
|
|
18
|
-
|
|
19
|
-
@semantic-release/changelog@
|
|
20
|
-
@semantic-release/gitlab@
|
|
21
|
-
@semantic-release/exec@
|
|
21
|
+
@semantic-release/git@11.0.0 \
|
|
22
|
+
@semantic-release/changelog@7.0.0 \
|
|
23
|
+
@semantic-release/gitlab@13.3.3 \
|
|
24
|
+
@semantic-release/exec@7.1.0
|
|
22
25
|
|
|
23
26
|
RUN mkdir -p /scripts
|
|
24
27
|
COPY ./scripts/* /scripts/
|
|
@@ -77,8 +77,17 @@ if [ ! -e .releaserc ]; then
|
|
|
77
77
|
],
|
|
78
78
|
"@semantic-release/release-notes-generator",
|
|
79
79
|
"@semantic-release/changelog",
|
|
80
|
+
# message prefix hardcoded to "release" on purpose. Ideally this would be
|
|
81
|
+
# "chore(\${branch.type})", but upstream @semantic-release/git passes the
|
|
82
|
+
# branch *name* (not the object) into the template, so \${branch.type} is
|
|
83
|
+
# never available (see https://github.com/semantic-release/git/pull/213,
|
|
84
|
+
# open/ignored since 2020 — the README documents branch.type but the code
|
|
85
|
+
# never wired it up; the old panter fork existed only to patch this). On the
|
|
86
|
+
# default branch branch.type is always "release", and the pipeline
|
|
87
|
+
# loop-prevention rule keys on the literal "chore(release)" prefix, so keep
|
|
88
|
+
# this literal. Don't "fix" it back to \${branch.type}.
|
|
80
89
|
["@semantic-release/git", {
|
|
81
|
-
"message": "chore(
|
|
90
|
+
"message": "chore(release): \${nextRelease.version}\n\n\${nextRelease.notes}"
|
|
82
91
|
}]${PUBLISH_PLUGIN}
|
|
83
92
|
],
|
|
84
93
|
"branches": [
|
|
@@ -107,9 +107,10 @@ restores a project db from one source to another target
|
|
|
107
107
|
|
|
108
108
|
## `catladder project config-secrets [envComponent]`
|
|
109
109
|
|
|
110
|
-
setup/update secrets
|
|
110
|
+
setup/update secrets in the vault via your editor
|
|
111
111
|
|
|
112
|
-
- `envComponent` (positional):
|
|
112
|
+
- `envComponent` (positional): scope: env:component, env:, :component or empty for everything
|
|
113
|
+
- `--key <value>`: only edit these secrets (comma-separated keys)
|
|
113
114
|
|
|
114
115
|
## `catladder project doctor [component]`
|
|
115
116
|
|
|
@@ -226,6 +227,40 @@ clears all backups
|
|
|
226
227
|
|
|
227
228
|
- `--keep <value>`: How many backups should we keep? (default: 1)
|
|
228
229
|
|
|
230
|
+
## `catladder project secrets-list [envComponent]`
|
|
231
|
+
|
|
232
|
+
lists the declared secrets of a scope with their set/unset status (values only with --reveal)
|
|
233
|
+
|
|
234
|
+
- `envComponent` (positional): scope: env:component, env:, :component or empty for everything
|
|
235
|
+
- `--key <value>`: only these secrets (comma-separated keys)
|
|
236
|
+
- `--reveal`: also print the secret values (default: false)
|
|
237
|
+
- `--check`: exit with an error when any secret is unset (for CI/agents) (default: false)
|
|
238
|
+
|
|
239
|
+
## `catladder project secrets-pull [envComponent]`
|
|
240
|
+
|
|
241
|
+
prints the current secrets of a scope as yaml (unset ones as a placeholder) — edit and feed to secrets-push
|
|
242
|
+
|
|
243
|
+
- `envComponent` (positional): scope: env:component, env:, :component or empty for everything
|
|
244
|
+
- `--key <value>`: only these secrets (comma-separated keys)
|
|
245
|
+
- `--out <value>`: write the yaml to this file instead of stdout
|
|
246
|
+
|
|
247
|
+
## `catladder project secrets-push [envComponent]`
|
|
248
|
+
|
|
249
|
+
writes secrets from a yaml document (secrets-pull format, --file or stdin) to the vault; may be partial
|
|
250
|
+
|
|
251
|
+
- `envComponent` (positional): scope: env:component, env:, :component or empty for everything
|
|
252
|
+
- `--key <value>`: only write these secrets (comma-separated keys)
|
|
253
|
+
- `--file <value>`: yaml file to push (component → env → key: value); stdin when omitted
|
|
254
|
+
|
|
255
|
+
## `catladder project secrets-set [envComponent] [key]`
|
|
256
|
+
|
|
257
|
+
sets one secret — in one env (dev:web), one env everywhere (dev:), or all envs of a component (:web); value via --value, --value-file or stdin
|
|
258
|
+
|
|
259
|
+
- `envComponent` (positional): scope: env:component, env:, or :component
|
|
260
|
+
- `key` (positional): which secret?
|
|
261
|
+
- `--value <value>`: the secret value (prefer --value-file or stdin over shell history)
|
|
262
|
+
- `--value-file <value>`: read the secret value from this file
|
|
263
|
+
|
|
229
264
|
## `catladder project secrets-sync-github [repo] [env]`
|
|
230
265
|
|
|
231
266
|
copies all secrets from the vault to github repo secrets (same names), for the github pipeline
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: catladder-secrets
|
|
3
|
-
description: Managing environment variables and secrets in a catladder project. Use when adding or changing env vars in catladder.ts (vars.public / vars.secret), when a secret value must be set or
|
|
3
|
+
description: Managing environment variables and secrets in a catladder project. Use when adding or changing env vars in catladder.ts (vars.public / vars.secret), when a secret value must be set, rotated or checked, when secrets need syncing to GitHub, or when local .env / direnv environment questions come up. Triggers on "env var", "secret", "vars", "catenv", ".env", "config-secrets", "secrets-set", "secrets-list", "rotate a secret", "set a secret".
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Env vars and secrets with catladder
|
|
@@ -34,18 +34,51 @@ commit.
|
|
|
34
34
|
## Setting secret values
|
|
35
35
|
|
|
36
36
|
Secret values are managed through the catladder CLI — never by editing
|
|
37
|
-
files in the repo
|
|
37
|
+
files in the repo. All secrets commands accept a **scope**:
|
|
38
|
+
`dev:web` (one env of one component), `dev:` (one env, all
|
|
39
|
+
components), `:web` (all envs of one component), or nothing (everything).
|
|
40
|
+
|
|
41
|
+
Check what is declared and what is still unset (never prints values
|
|
42
|
+
unless `--reveal` is passed):
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
yarn catladder project secrets-list
|
|
46
|
+
yarn catladder project secrets-list --check # non-zero exit when something is unset
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Set a single secret (the usual case — also for rotating one value
|
|
50
|
+
across all envs via the `:component` scope):
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
echo -n "the-value" | yarn catladder project secrets-set dev:web API_KEY
|
|
54
|
+
yarn catladder project secrets-set :web API_KEY --value-file /path/to/value
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Prefer stdin or `--value-file` over `--value` so values stay out of
|
|
58
|
+
shell history. **Never pass a real secret value you found in the
|
|
59
|
+
conversation without the user having provided it for this purpose.**
|
|
60
|
+
|
|
61
|
+
Bulk-edit several secrets as a YAML document
|
|
62
|
+
(`component → env → key: value`):
|
|
38
63
|
|
|
39
64
|
```sh
|
|
40
|
-
yarn catladder project
|
|
65
|
+
yarn catladder project secrets-pull dev: --out /tmp/secrets.yml # unset ones appear as "🚨 FILL ME"
|
|
66
|
+
# edit the file, then:
|
|
67
|
+
yarn catladder project secrets-push dev: --file /tmp/secrets.yml # partial docs are fine
|
|
41
68
|
```
|
|
42
69
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
70
|
+
`secrets-push` skips placeholder/empty values, rejects undeclared
|
|
71
|
+
keys, and may be partial — only the provided keys are written. Both
|
|
72
|
+
support `--key KEY1,KEY2` to narrow further. Delete the temp file
|
|
73
|
+
afterwards; never commit it.
|
|
74
|
+
|
|
75
|
+
Humans may instead use the interactive editor flow
|
|
76
|
+
(`project config-secrets`, opens `$EDITOR`); as an agent, use the
|
|
77
|
+
commands above.
|
|
78
|
+
|
|
79
|
+
All of these write to the secrets vault (the source of truth) and
|
|
80
|
+
automatically mirror to the enabled CI backends — which vault is
|
|
81
|
+
configured makes no difference to the commands.
|
|
49
82
|
|
|
50
83
|
## GitHub pipelines
|
|
51
84
|
|
|
@@ -11,6 +11,10 @@ export { commandOpenEnv } from "./project/commandOpenEnv";
|
|
|
11
11
|
export { commandOpenGit } from "./project/commandOpenGit";
|
|
12
12
|
export { commandCloudSqlProxy } from "./project/commandCloudSqlProxy";
|
|
13
13
|
export { commandConfigSecrets } from "./project/commandConfigSecrets";
|
|
14
|
+
export { commandSecretsPull } from "./project/secrets/commandSecretsPull";
|
|
15
|
+
export { commandSecretsPush } from "./project/secrets/commandSecretsPush";
|
|
16
|
+
export { commandSecretsSet } from "./project/secrets/commandSecretsSet";
|
|
17
|
+
export { commandSecretsList } from "./project/secrets/commandSecretsList";
|
|
14
18
|
export { commandSecretsClearBackups } from "./project/commandSecretsClearBackups";
|
|
15
19
|
export { commandSecretsSyncGithub } from "./project/commandSecretsSyncGithub";
|
|
16
20
|
export { commandOpenLogs } from "./project/commandOpenLogs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.commandStarwars = exports.commandDadjoke = exports.commandSecurityAuditCreate = exports.commandSecurityAuditEvaluate = exports.commandSecurityAuditCiJob = exports.commandRestoreDb = exports.commandMongoDestroyMember = exports.commandMongoPortForward = exports.commandMongoGetShell = exports.commandTriggerCronjobProject = exports.commandDeleteProject = exports.commandPauseProject = exports.commandDeletePods = exports.commandGetShell = exports.commandListPods = exports.commandNamespace = exports.commandSecurityEvaluate = exports.commandProjectRestoreDb = exports.commandCiJobLog = exports.commandCiJobOpen = exports.commandDoctor = exports.commandSetup = exports.commandGetMyTotalWorktime = exports.commandRenewToken = exports.commandTriggerCronjobGeneral = exports.commandOpenLogs = exports.commandSecretsSyncGithub = exports.commandSecretsClearBackups = exports.commandConfigSecrets = exports.commandCloudSqlProxy = exports.commandOpenGit = exports.commandOpenEnv = exports.commandPortForward = exports.commandEnvVars = exports.commandKubePortForward = exports.commandKubeGetShell = exports.commandKubeStopPortforward = exports.commandKubeListPods = exports.commandKubeListSecrets = exports.commandKubeListNamespaces = exports.commandKubeCurrentContext = void 0;
|
|
3
|
+
exports.commandStarwars = exports.commandDadjoke = exports.commandSecurityAuditCreate = exports.commandSecurityAuditEvaluate = exports.commandSecurityAuditCiJob = exports.commandRestoreDb = exports.commandMongoDestroyMember = exports.commandMongoPortForward = exports.commandMongoGetShell = exports.commandTriggerCronjobProject = exports.commandDeleteProject = exports.commandPauseProject = exports.commandDeletePods = exports.commandGetShell = exports.commandListPods = exports.commandNamespace = exports.commandSecurityEvaluate = exports.commandProjectRestoreDb = exports.commandCiJobLog = exports.commandCiJobOpen = exports.commandDoctor = exports.commandSetup = exports.commandGetMyTotalWorktime = exports.commandRenewToken = exports.commandTriggerCronjobGeneral = exports.commandOpenLogs = exports.commandSecretsSyncGithub = exports.commandSecretsClearBackups = exports.commandSecretsList = exports.commandSecretsSet = exports.commandSecretsPush = exports.commandSecretsPull = exports.commandConfigSecrets = exports.commandCloudSqlProxy = exports.commandOpenGit = exports.commandOpenEnv = exports.commandPortForward = exports.commandEnvVars = exports.commandKubePortForward = exports.commandKubeGetShell = exports.commandKubeStopPortforward = exports.commandKubeListPods = exports.commandKubeListSecrets = exports.commandKubeListNamespaces = exports.commandKubeCurrentContext = void 0;
|
|
4
4
|
// General commands
|
|
5
5
|
var commandKubeCurrentContext_1 = require("./general/commandKubeCurrentContext");
|
|
6
6
|
Object.defineProperty(exports, "commandKubeCurrentContext", { enumerable: true, get: function () { return commandKubeCurrentContext_1.commandKubeCurrentContext; } });
|
|
@@ -29,6 +29,14 @@ var commandCloudSqlProxy_1 = require("./project/commandCloudSqlProxy");
|
|
|
29
29
|
Object.defineProperty(exports, "commandCloudSqlProxy", { enumerable: true, get: function () { return commandCloudSqlProxy_1.commandCloudSqlProxy; } });
|
|
30
30
|
var commandConfigSecrets_1 = require("./project/commandConfigSecrets");
|
|
31
31
|
Object.defineProperty(exports, "commandConfigSecrets", { enumerable: true, get: function () { return commandConfigSecrets_1.commandConfigSecrets; } });
|
|
32
|
+
var commandSecretsPull_1 = require("./project/secrets/commandSecretsPull");
|
|
33
|
+
Object.defineProperty(exports, "commandSecretsPull", { enumerable: true, get: function () { return commandSecretsPull_1.commandSecretsPull; } });
|
|
34
|
+
var commandSecretsPush_1 = require("./project/secrets/commandSecretsPush");
|
|
35
|
+
Object.defineProperty(exports, "commandSecretsPush", { enumerable: true, get: function () { return commandSecretsPush_1.commandSecretsPush; } });
|
|
36
|
+
var commandSecretsSet_1 = require("./project/secrets/commandSecretsSet");
|
|
37
|
+
Object.defineProperty(exports, "commandSecretsSet", { enumerable: true, get: function () { return commandSecretsSet_1.commandSecretsSet; } });
|
|
38
|
+
var commandSecretsList_1 = require("./project/secrets/commandSecretsList");
|
|
39
|
+
Object.defineProperty(exports, "commandSecretsList", { enumerable: true, get: function () { return commandSecretsList_1.commandSecretsList; } });
|
|
32
40
|
var commandSecretsClearBackups_1 = require("./project/commandSecretsClearBackups");
|
|
33
41
|
Object.defineProperty(exports, "commandSecretsClearBackups", { enumerable: true, get: function () { return commandSecretsClearBackups_1.commandSecretsClearBackups; } });
|
|
34
42
|
var commandSecretsSyncGithub_1 = require("./project/commandSecretsSyncGithub");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/index.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,iFAAgF;AAAvE,sIAAA,yBAAyB,OAAA;A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AAA,yBAAyB,OAAA;AAClC,wFAAuF;AAA9E,4IAAA,4BAA4B,OAAA;AACrC,oFAAmF;AAA1E,wIAAA,0BAA0B,OAAA;AAEnC,eAAe;AACf,uDAAsD;AAA7C,gHAAA,cAAc,OAAA;AACvB,yDAAwD;AAA/C,kHAAA,eAAe,OAAA"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export declare const commandConfigSecrets: import("../../core").CommandDef<{
|
|
2
2
|
readonly envComponent: {
|
|
3
3
|
readonly type: "string";
|
|
4
|
-
readonly message: "
|
|
4
|
+
readonly message: "scope: env:component, env:, :component or empty for everything";
|
|
5
5
|
readonly positional: true;
|
|
6
6
|
readonly required: false;
|
|
7
7
|
readonly choices: () => Promise<string[]>;
|
|
8
8
|
};
|
|
9
|
+
readonly key: {
|
|
10
|
+
readonly type: "string";
|
|
11
|
+
readonly message: "only edit these secrets (comma-separated keys)";
|
|
12
|
+
readonly required: false;
|
|
13
|
+
};
|
|
9
14
|
}>;
|
|
@@ -1,34 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.commandConfigSecrets = void 0;
|
|
4
|
+
const common_tags_1 = require("common-tags");
|
|
4
5
|
const defineCommand_1 = require("../../core/defineCommand");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// so for now we bridge it.
|
|
6
|
+
const editAsFile_1 = require("../../utils/editAsFile");
|
|
7
|
+
const promise_1 = require("../../utils/promise");
|
|
8
|
+
const document_1 = require("./secrets/document");
|
|
9
|
+
const scope_1 = require("./secrets/scope");
|
|
10
|
+
const parseKeysInput_1 = require("./secrets/parseKeysInput");
|
|
11
11
|
exports.commandConfigSecrets = (0, defineCommand_1.defineCommand)({
|
|
12
12
|
name: "project config-secrets",
|
|
13
|
-
description: "setup/update secrets
|
|
13
|
+
description: "setup/update secrets in the vault via your editor",
|
|
14
14
|
group: "project",
|
|
15
15
|
inputs: {
|
|
16
16
|
envComponent: {
|
|
17
17
|
type: "string",
|
|
18
|
-
message: "
|
|
18
|
+
message: "scope: env:component, env:, :component or empty for everything",
|
|
19
19
|
positional: true,
|
|
20
20
|
required: false,
|
|
21
|
-
choices: async () => (0,
|
|
21
|
+
choices: async () => (0, scope_1.secretsScopeChoices)(),
|
|
22
|
+
},
|
|
23
|
+
key: {
|
|
24
|
+
type: "string",
|
|
25
|
+
message: "only edit these secrets (comma-separated keys)",
|
|
26
|
+
required: false,
|
|
22
27
|
},
|
|
23
28
|
},
|
|
24
29
|
execute: async (ctx) => {
|
|
25
30
|
const envComponent = await ctx.get("envComponent");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
await (0,
|
|
31
|
+
const keys = (0, parseKeysInput_1.parseKeysInput)(await ctx.get("key"));
|
|
32
|
+
if (!ctx.interactive) {
|
|
33
|
+
throw new Error("project config-secrets opens an editor and needs an interactive terminal — " +
|
|
34
|
+
"use `project secrets-pull`, `project secrets-push` or `project secrets-set` instead");
|
|
35
|
+
}
|
|
36
|
+
const scope = await (0, scope_1.resolveSecretsScope)(envComponent);
|
|
37
|
+
const scoped = await (0, scope_1.getScopedSecretKeys)(scope, keys);
|
|
38
|
+
let document = await (0, document_1.buildSecretsDocument)(ctx, scoped);
|
|
39
|
+
let hasErrors = true;
|
|
40
|
+
while (hasErrors) {
|
|
41
|
+
document = await (0, editAsFile_1.editAsFile)(document, (0, common_tags_1.stripIndents) `
|
|
42
|
+
Please fill in all secrets for:
|
|
43
|
+
|
|
44
|
+
${(0, scope_1.formatScope)(scoped)}
|
|
45
|
+
|
|
46
|
+
`);
|
|
47
|
+
const problems = (0, document_1.checkSecretsDocument)(document, scoped, {
|
|
48
|
+
requireComplete: true,
|
|
49
|
+
});
|
|
50
|
+
hasErrors = problems.length > 0;
|
|
51
|
+
if (hasErrors) {
|
|
52
|
+
ctx.log("");
|
|
53
|
+
ctx.log("😿 Oh no! There is something wrong:");
|
|
54
|
+
ctx.log("");
|
|
55
|
+
problems.forEach((problem) => ctx.log(problem));
|
|
56
|
+
ctx.log("");
|
|
57
|
+
await (0, promise_1.delay)(1000);
|
|
58
|
+
const shouldContinue = await ctx.confirm("Try again? 🤔");
|
|
59
|
+
if (!shouldContinue) {
|
|
60
|
+
throw new Error("abort");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const { writes, skipped } = (0, document_1.collectSecretsWrites)(document, scoped);
|
|
65
|
+
if (skipped.length > 0) {
|
|
66
|
+
ctx.log("");
|
|
67
|
+
ctx.log("⏭️ these secrets are still unset and will not be written:");
|
|
68
|
+
skipped.forEach((entry) => ctx.log(` - ${entry}`));
|
|
69
|
+
}
|
|
70
|
+
await (0, document_1.writeSecretsAndMirror)(ctx, writes);
|
|
71
|
+
ctx.log("done! 😻");
|
|
72
|
+
ctx.log("");
|
|
32
73
|
},
|
|
33
74
|
});
|
|
34
75
|
//# sourceMappingURL=commandConfigSecrets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandConfigSecrets.js","sourceRoot":"","sources":["../../../../../src/commands/project/commandConfigSecrets.ts"],"names":[],"mappings":";;;AAAA,4DAAyD;AACzD
|
|
1
|
+
{"version":3,"file":"commandConfigSecrets.js","sourceRoot":"","sources":["../../../../../src/commands/project/commandConfigSecrets.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,4DAAyD;AACzD,uDAAoD;AACpD,iDAA4C;AAC5C,iDAK4B;AAC5B,2CAKyB;AACzB,6DAA0D;AAE7C,QAAA,oBAAoB,GAAG,IAAA,6BAAa,EAAC;IAChD,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EAAE,mDAAmD;IAChE,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE;QACN,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,gEAAgE;YACzE,UAAU,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Z,GAAG,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;gBAC/C,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACZ,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;gBAChD,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAEZ,MAAM,IAAA,eAAK,EAAC,IAAI,CAAC,CAAC;gBAClB,MAAM,cAAc,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;gBAC1D,IAAI,CAAC,cAAc,EAAE,CAAC;oBACpB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC3B,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,+BAAoB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACnE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACZ,GAAG,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;YACrE,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,IAAA,gCAAqB,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACzC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACpB,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const commandSecretsList: import("../../../core").CommandDef<{
|
|
2
|
+
readonly envComponent: {
|
|
3
|
+
readonly type: "string";
|
|
4
|
+
readonly message: "scope: env:component, env:, :component or empty for everything";
|
|
5
|
+
readonly positional: true;
|
|
6
|
+
readonly required: false;
|
|
7
|
+
readonly choices: () => Promise<string[]>;
|
|
8
|
+
};
|
|
9
|
+
readonly key: {
|
|
10
|
+
readonly type: "string";
|
|
11
|
+
readonly message: "only these secrets (comma-separated keys)";
|
|
12
|
+
readonly required: false;
|
|
13
|
+
};
|
|
14
|
+
readonly reveal: {
|
|
15
|
+
readonly type: "boolean";
|
|
16
|
+
readonly message: "also print the secret values";
|
|
17
|
+
readonly default: false;
|
|
18
|
+
};
|
|
19
|
+
readonly check: {
|
|
20
|
+
readonly type: "boolean";
|
|
21
|
+
readonly message: "exit with an error when any secret is unset (for CI/agents)";
|
|
22
|
+
readonly default: false;
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commandSecretsList = void 0;
|
|
4
|
+
const pipeline_1 = require("../../../../../pipeline/src/index.js");
|
|
5
|
+
const defineCommand_1 = require("../../../core/defineCommand");
|
|
6
|
+
const scope_1 = require("./scope");
|
|
7
|
+
const parseKeysInput_1 = require("./parseKeysInput");
|
|
8
|
+
exports.commandSecretsList = (0, defineCommand_1.defineCommand)({
|
|
9
|
+
name: "project secrets-list",
|
|
10
|
+
description: "lists the declared secrets of a scope with their set/unset status (values only with --reveal)",
|
|
11
|
+
group: "project",
|
|
12
|
+
inputs: {
|
|
13
|
+
envComponent: {
|
|
14
|
+
type: "string",
|
|
15
|
+
message: "scope: env:component, env:, :component or empty for everything",
|
|
16
|
+
positional: true,
|
|
17
|
+
required: false,
|
|
18
|
+
choices: async () => (0, scope_1.secretsScopeChoices)(),
|
|
19
|
+
},
|
|
20
|
+
key: {
|
|
21
|
+
type: "string",
|
|
22
|
+
message: "only these secrets (comma-separated keys)",
|
|
23
|
+
required: false,
|
|
24
|
+
},
|
|
25
|
+
reveal: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
message: "also print the secret values",
|
|
28
|
+
default: false,
|
|
29
|
+
},
|
|
30
|
+
check: {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
message: "exit with an error when any secret is unset (for CI/agents)",
|
|
33
|
+
default: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
execute: async (ctx) => {
|
|
37
|
+
const scope = await (0, scope_1.resolveSecretsScope)(await ctx.get("envComponent"));
|
|
38
|
+
const scoped = await (0, scope_1.getScopedSecretKeys)(scope, (0, parseKeysInput_1.parseKeysInput)(await ctx.get("key")));
|
|
39
|
+
const reveal = await ctx.get("reveal");
|
|
40
|
+
const names = scoped.flatMap(({ env, componentName, keys }) => keys.map((key) => (0, pipeline_1.getSecretVarName)(env, componentName, key)));
|
|
41
|
+
const values = await (await ctx.getVaultManager()).readSecrets(names, ctx);
|
|
42
|
+
let unsetCount = 0;
|
|
43
|
+
let setCount = 0;
|
|
44
|
+
for (const { env, componentName, keys } of scoped) {
|
|
45
|
+
for (const key of keys) {
|
|
46
|
+
const value = values[(0, pipeline_1.getSecretVarName)(env, componentName, key)];
|
|
47
|
+
if (value === undefined) {
|
|
48
|
+
unsetCount += 1;
|
|
49
|
+
ctx.log(`🚨 ${env}:${componentName} ${key} (unset)`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
setCount += 1;
|
|
53
|
+
ctx.log(`✅ ${env}:${componentName} ${key}` + (reveal ? ` = ${value}` : ""));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
ctx.log("");
|
|
58
|
+
ctx.log(`${setCount} set, ${unsetCount} unset`);
|
|
59
|
+
if ((await ctx.get("check")) && unsetCount > 0) {
|
|
60
|
+
throw new Error(`${unsetCount} secrets are unset`);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=commandSecretsList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandSecretsList.js","sourceRoot":"","sources":["../../../../../../src/commands/project/secrets/commandSecretsList.ts"],"names":[],"mappings":";;;AAAA,kDAAuD;AACvD,+DAA4D;AAC5D,mCAIiB;AACjB,qDAAkD;AAErC,QAAA,kBAAkB,GAAG,IAAA,6BAAa,EAAC;IAC9C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EACT,+FAA+F;IACjG,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE;QACN,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,gEAAgE;YACzE,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,2BAAmB,GAAE;SAC3C;QACD,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,2CAA2C;YACpD,QAAQ,EAAE,KAAK;SAChB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,8BAA8B;YACvC,OAAO,EAAE,KAAK;SACf;QACD,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,6DAA6D;YACtE,OAAO,EAAE,KAAK;SACf;KACF;IACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACrB,MAAM,KAAK,GAAG,MAAM,IAAA,2BAAmB,EAAC,MAAM,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;QACvE,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAmB,EACtC,KAAK,EACL,IAAA,+BAAc,EAAC,MAAM,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CACrC,CAAC;QACF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEvC,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,CAC5D,IA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AC,GAAG,UAAU,oBAAoB,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const commandSecretsPull: import("../../../core").CommandDef<{
|
|
2
|
+
readonly envComponent: {
|
|
3
|
+
readonly type: "string";
|
|
4
|
+
readonly message: "scope: env:component, env:, :component or empty for everything";
|
|
5
|
+
readonly positional: true;
|
|
6
|
+
readonly required: false;
|
|
7
|
+
readonly choices: () => Promise<string[]>;
|
|
8
|
+
};
|
|
9
|
+
readonly key: {
|
|
10
|
+
readonly type: "string";
|
|
11
|
+
readonly message: "only these secrets (comma-separated keys)";
|
|
12
|
+
readonly required: false;
|
|
13
|
+
};
|
|
14
|
+
readonly out: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly message: "write the yaml to this file instead of stdout";
|
|
17
|
+
readonly required: false;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commandSecretsPull = void 0;
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const yaml_1 = require("yaml");
|
|
6
|
+
const defineCommand_1 = require("../../../core/defineCommand");
|
|
7
|
+
const document_1 = require("./document");
|
|
8
|
+
const scope_1 = require("./scope");
|
|
9
|
+
const parseKeysInput_1 = require("./parseKeysInput");
|
|
10
|
+
exports.commandSecretsPull = (0, defineCommand_1.defineCommand)({
|
|
11
|
+
name: "project secrets-pull",
|
|
12
|
+
description: "prints the current secrets of a scope as yaml (unset ones as a placeholder) — edit and feed to secrets-push",
|
|
13
|
+
group: "project",
|
|
14
|
+
inputs: {
|
|
15
|
+
envComponent: {
|
|
16
|
+
type: "string",
|
|
17
|
+
message: "scope: env:component, env:, :component or empty for everything",
|
|
18
|
+
positional: true,
|
|
19
|
+
required: false,
|
|
20
|
+
choices: async () => (0, scope_1.secretsScopeChoices)(),
|
|
21
|
+
},
|
|
22
|
+
key: {
|
|
23
|
+
type: "string",
|
|
24
|
+
message: "only these secrets (comma-separated keys)",
|
|
25
|
+
required: false,
|
|
26
|
+
},
|
|
27
|
+
out: {
|
|
28
|
+
type: "string",
|
|
29
|
+
message: "write the yaml to this file instead of stdout",
|
|
30
|
+
required: false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
execute: async (ctx) => {
|
|
34
|
+
const scope = await (0, scope_1.resolveSecretsScope)(await ctx.get("envComponent"));
|
|
35
|
+
const scoped = await (0, scope_1.getScopedSecretKeys)(scope, (0, parseKeysInput_1.parseKeysInput)(await ctx.get("key")));
|
|
36
|
+
const document = await (0, document_1.buildSecretsDocument)(ctx, scoped);
|
|
37
|
+
const yaml = (0, yaml_1.stringify)(document, { aliasDuplicateObjects: false });
|
|
38
|
+
const out = await ctx.get("out");
|
|
39
|
+
if (out) {
|
|
40
|
+
await (0, fs_extra_1.writeFile)(out, yaml);
|
|
41
|
+
ctx.log(`wrote secrets to ${out} — ⚠️ contains secret values, don't commit it`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
ctx.log(yaml);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=commandSecretsPull.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandSecretsPull.js","sourceRoot":"","sources":["../../../../../../src/commands/project/secrets/commandSecretsPull.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,+BAAiC;AACjC,+DAA4D;AAC5D,yCAAkD;AAClD,mCAIiB;AACjB,qDAAkD;AAErC,QAAA,kBAAkB,GAAG,IAAA,6BAAa,EAAC;IAC9C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EACT,6GAA6G;IAC/G,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE;QACN,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,OAAO,EAA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envComponent: {
|
|
3
|
+
readonly type: "string";
|
|
4
|
+
readonly message: "scope: env:component, env:, :component or empty for everything";
|
|
5
|
+
readonly positional: true;
|
|
6
|
+
readonly required: false;
|
|
7
|
+
readonly choices: () => Promise<string[]>;
|
|
8
|
+
};
|
|
9
|
+
readonly key: {
|
|
10
|
+
readonly type: "string";
|
|
11
|
+
readonly message: "only write these secrets (comma-separated keys)";
|
|
12
|
+
readonly required: false;
|
|
13
|
+
};
|
|
14
|
+
readonly file: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly message: "yaml file to push (component → env → key: value); stdin when omitted";
|
|
17
|
+
readonly required: false;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commandSecretsPush = void 0;
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const yaml_1 = require("yaml");
|
|
6
|
+
const defineCommand_1 = require("../../../core/defineCommand");
|
|
7
|
+
const readStdin_1 = require("../../../utils/readStdin");
|
|
8
|
+
const document_1 = require("./document");
|
|
9
|
+
const scope_1 = require("./scope");
|
|
10
|
+
const parseKeysInput_1 = require("./parseKeysInput");
|
|
11
|
+
exports.commandSecretsPush = (0, defineCommand_1.defineCommand)({
|
|
12
|
+
name: "project secrets-push",
|
|
13
|
+
description: "writes secrets from a yaml document (secrets-pull format, --file or stdin) to the vault; may be partial",
|
|
14
|
+
group: "project",
|
|
15
|
+
inputs: {
|
|
16
|
+
envComponent: {
|
|
17
|
+
type: "string",
|
|
18
|
+
message: "scope: env:component, env:, :component or empty for everything",
|
|
19
|
+
positional: true,
|
|
20
|
+
required: false,
|
|
21
|
+
choices: async () => (0, scope_1.secretsScopeChoices)(),
|
|
22
|
+
},
|
|
23
|
+
key: {
|
|
24
|
+
type: "string",
|
|
25
|
+
message: "only write these secrets (comma-separated keys)",
|
|
26
|
+
required: false,
|
|
27
|
+
},
|
|
28
|
+
file: {
|
|
29
|
+
type: "string",
|
|
30
|
+
message: "yaml file to push (component → env → key: value); stdin when omitted",
|
|
31
|
+
required: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
execute: async (ctx) => {
|
|
35
|
+
const scope = await (0, scope_1.resolveSecretsScope)(await ctx.get("envComponent"));
|
|
36
|
+
const scoped = await (0, scope_1.getScopedSecretKeys)(scope, (0, parseKeysInput_1.parseKeysInput)(await ctx.get("key")));
|
|
37
|
+
const file = await ctx.get("file");
|
|
38
|
+
if (!file && process.stdin.isTTY) {
|
|
39
|
+
throw new Error("nothing to push — pass --file <secrets.yml> or pipe yaml (secrets-pull format) to stdin");
|
|
40
|
+
}
|
|
41
|
+
const raw = file
|
|
42
|
+
? (await (0, fs_extra_1.readFile)(file)).toString("utf-8")
|
|
43
|
+
: await (0, readStdin_1.readStdin)();
|
|
44
|
+
const document = (0, yaml_1.parse)(raw);
|
|
45
|
+
if (!document || typeof document !== "object") {
|
|
46
|
+
throw new Error("the document must be a yaml object: component → env → key: value (see secrets-pull)");
|
|
47
|
+
}
|
|
48
|
+
const problems = (0, document_1.checkSecretsDocument)(document, scoped, {
|
|
49
|
+
requireComplete: false,
|
|
50
|
+
});
|
|
51
|
+
if (problems.length > 0) {
|
|
52
|
+
throw new Error("😿 the document does not match the config:\n" +
|
|
53
|
+
problems.map((problem) => ` - ${problem}`).join("\n"));
|
|
54
|
+
}
|
|
55
|
+
const { writes, skipped } = (0, document_1.collectSecretsWrites)(document, scoped);
|
|
56
|
+
if (skipped.length > 0) {
|
|
57
|
+
ctx.log("⏭️ skipping placeholder/empty values:");
|
|
58
|
+
skipped.forEach((entry) => ctx.log(` - ${entry}`));
|
|
59
|
+
}
|
|
60
|
+
if (writes.length === 0) {
|
|
61
|
+
ctx.log("no secrets to write 🤷");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
ctx.log("about to write:");
|
|
65
|
+
writes.forEach(({ env, componentName, secrets }) => ctx.log(` - ${env}:${componentName}: ${Object.keys(secrets).join(", ")}`));
|
|
66
|
+
const confirmed = await ctx.confirm("continue? 🤔");
|
|
67
|
+
if (!confirmed) {
|
|
68
|
+
throw new Error("abort");
|
|
69
|
+
}
|
|
70
|
+
await (0, document_1.writeSecretsAndMirror)(ctx, writes);
|
|
71
|
+
ctx.log("done! 😻");
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=commandSecretsPush.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandSecretsPush.js","sourceRoot":"","sources":["../../../../../../src/commands/project/secrets/commandSecretsPush.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AACpC,+BAA6B;AAC7B,+DAA4D;AAC5D,wDAAqD;AAErD,yCAIoB;AACpB,mCAIiB;AACjB,qDAAkD;AAErC,QAAA,kBAAkB,GAAG,IAAA,6BAAa,EAAC;IAC9C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EACT,yGAAyG;IAC3G,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE;QACN,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,gEAAgE;YACzE,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,2BAAmB,GAAE;SAC3C;QACD,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,iDAAiD;YAC1D,QAAQ,EAAE,KAAK;SAChB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,OAAO,EACL,sEAAsE;YACxE,QAAQ,EAAE,KAAK;SAChB;KACF;IACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACrB,MAAM,KAAK,GAAG,MAAM,IAAA,2BAAmB,EAAC,MAAM,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;QACvE,MAAM,MA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