@catladder/cli 0.0.0-next-a9386ffe → 0.0.0-next-1d12aca2
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/apps/cli/src/adapters/terminal.d.ts +8 -0
- package/dist/apps/cli/src/adapters/terminal.js +9 -2
- package/dist/apps/cli/src/adapters/terminal.js.map +1 -1
- package/dist/apps/cli/src/apps/catenv/catenv.d.ts +5 -0
- package/dist/apps/cli/src/apps/catenv/catenv.js +10 -1
- package/dist/apps/cli/src/apps/catenv/catenv.js.map +1 -1
- package/dist/apps/cli/src/catenv.js +7 -0
- package/dist/apps/cli/src/catenv.js.map +1 -1
- package/dist/apps/cli/src/utils/gitlab.js +5 -0
- package/dist/apps/cli/src/utils/gitlab.js.map +1 -1
- package/dist/apps/cli/src/vault/VaultManager.js +6 -1
- package/dist/apps/cli/src/vault/VaultManager.js.map +1 -1
- package/dist/bundles/catenv/index.js +17447 -8872
- package/dist/bundles/cli/index.js +51 -25
- package/dist/bundles/skills/catladder-builds/references/build-types.md +10 -0
- package/dist/bundles/skills/catladder-migrate-package-manager/SKILL.md +7 -1
- package/dist/bundles/skills/catladder-migrate-package-manager/references/yarn-to-pnpm-differences.md +10 -1
- package/dist/packages/pipeline/src/build/node/packageManagerInstall.d.ts +7 -4
- package/dist/packages/pipeline/src/build/node/packageManagerInstall.js +17 -8
- package/dist/packages/pipeline/src/build/node/packageManagerInstall.js.map +1 -1
- package/dist/packages/pipeline/src/build/node/testJob.js +14 -14
- package/dist/packages/pipeline/src/build/node/testJob.js.map +1 -1
- package/dist/packages/pipeline/src/build/types.d.ts +17 -3
- package/dist/packages/pipeline/src/build/types.js.map +1 -1
- package/dist/skills/catladder-builds/references/build-types.md +10 -0
- package/dist/skills/catladder-migrate-package-manager/SKILL.md +7 -1
- package/dist/skills/catladder-migrate-package-manager/references/yarn-to-pnpm-differences.md +10 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/adapters/terminal.ts +16 -2
- package/src/apps/catenv/catenv.ts +15 -1
- package/src/catenv.ts +12 -0
- package/src/utils/gitlab.ts +7 -0
- package/src/vault/VaultManager.ts +4 -1
package/package.json
CHANGED
package/src/adapters/terminal.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
PromptChoice,
|
|
8
8
|
} from "../core/types";
|
|
9
9
|
import { MissingInputError } from "../core/types";
|
|
10
|
+
import type { SecretsMode } from "../vault";
|
|
10
11
|
import { BaseContext } from "./baseContext";
|
|
11
12
|
import { createVaultManagerGetter } from "./vaultManagerAccess";
|
|
12
13
|
|
|
@@ -82,6 +83,13 @@ export interface TerminalOptions {
|
|
|
82
83
|
interactive?: boolean;
|
|
83
84
|
/** If true, all confirm() calls return true without prompting (--yes flag) */
|
|
84
85
|
yes?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* log to stderr instead of stdout (catenv: stdout may be evaluated
|
|
88
|
+
* by direnv or piped, so only data belongs there)
|
|
89
|
+
*/
|
|
90
|
+
logToStderr?: boolean;
|
|
91
|
+
/** how to interact with the secrets vault (--vault-mode) */
|
|
92
|
+
vaultMode?: SecretsMode;
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
class TerminalContext<
|
|
@@ -187,9 +195,15 @@ export function createTerminalContext<TInputs extends InputsSchema>(
|
|
|
187
195
|
export function createTerminalIO(options: TerminalOptions = {}): IO {
|
|
188
196
|
const io: IO = {
|
|
189
197
|
interactive: options.interactive ?? process.stdin.isTTY === true,
|
|
190
|
-
getVaultManager: createVaultManagerGetter(() => io
|
|
198
|
+
getVaultManager: createVaultManagerGetter(() => io, {
|
|
199
|
+
mode: options.vaultMode,
|
|
200
|
+
}),
|
|
191
201
|
log(message: string): void {
|
|
192
|
-
|
|
202
|
+
if (options.logToStderr) {
|
|
203
|
+
console.error(message);
|
|
204
|
+
} else {
|
|
205
|
+
console.log(message);
|
|
206
|
+
}
|
|
193
207
|
},
|
|
194
208
|
async confirm(message: string): Promise<boolean> {
|
|
195
209
|
if (options.yes) return true;
|
|
@@ -10,11 +10,17 @@ import {
|
|
|
10
10
|
} from "@catladder/pipeline";
|
|
11
11
|
import type { SecretsMode } from "../../vault";
|
|
12
12
|
import { createNonInteractiveIO } from "../../adapters/nonInteractive";
|
|
13
|
+
import { createTerminalIO } from "../../adapters/terminal";
|
|
13
14
|
|
|
14
15
|
type Options = {
|
|
15
16
|
verbose?: boolean;
|
|
16
17
|
printVariables?: boolean;
|
|
17
18
|
vaultMode?: SecretsMode;
|
|
19
|
+
/**
|
|
20
|
+
* whether prompting is allowed (token setup, vault unlock). Callers
|
|
21
|
+
* pass the TTY detection result; direnv/turbo/CI runs come out false.
|
|
22
|
+
*/
|
|
23
|
+
interactive?: boolean;
|
|
18
24
|
};
|
|
19
25
|
export default async (choice?: Choice, options?: Options) => {
|
|
20
26
|
const config = await getProjectConfig();
|
|
@@ -22,7 +28,15 @@ export default async (choice?: Choice, options?: Options) => {
|
|
|
22
28
|
return;
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
const io =
|
|
31
|
+
const io = options?.interactive
|
|
32
|
+
? // logs still go to stderr: even on a TTY, stdout is reserved for
|
|
33
|
+
// data (--print-variables) and may be piped
|
|
34
|
+
createTerminalIO({
|
|
35
|
+
interactive: true,
|
|
36
|
+
logToStderr: true,
|
|
37
|
+
vaultMode: options?.vaultMode,
|
|
38
|
+
})
|
|
39
|
+
: createNonInteractiveIO({ vaultMode: options?.vaultMode });
|
|
26
40
|
const context = { ...createCatenvContext(config), io };
|
|
27
41
|
if (options?.verbose) {
|
|
28
42
|
printVerboseBanner();
|
package/src/catenv.ts
CHANGED
|
@@ -27,6 +27,10 @@ program
|
|
|
27
27
|
.choices(["auto", "no-prompt", "offline", "refresh"])
|
|
28
28
|
.default("auto"),
|
|
29
29
|
)
|
|
30
|
+
.option(
|
|
31
|
+
"--non-interactive",
|
|
32
|
+
"never prompt (token setup, vault unlock) — assumed automatically when not attached to a terminal (direnv, turbo, CI)",
|
|
33
|
+
)
|
|
30
34
|
.action(
|
|
31
35
|
(
|
|
32
36
|
envComponent: string | undefined,
|
|
@@ -34,12 +38,20 @@ program
|
|
|
34
38
|
verbose?: boolean;
|
|
35
39
|
printVariables?: boolean;
|
|
36
40
|
vaultMode: SecretsMode;
|
|
41
|
+
nonInteractive?: boolean;
|
|
37
42
|
},
|
|
38
43
|
) => {
|
|
44
|
+
// interactive iff a human is attached: direnv captures stdout,
|
|
45
|
+
// turbo/CI pipe it — all of those auto-degrade to non-interactive
|
|
46
|
+
const interactive =
|
|
47
|
+
!opts.nonInteractive &&
|
|
48
|
+
process.stdin.isTTY === true &&
|
|
49
|
+
process.stdout.isTTY === true;
|
|
39
50
|
catenv(envComponent ? parseChoice(envComponent) : null, {
|
|
40
51
|
verbose: opts.verbose ?? false,
|
|
41
52
|
printVariables: opts.printVariables ?? false,
|
|
42
53
|
vaultMode: opts.vaultMode,
|
|
54
|
+
interactive,
|
|
43
55
|
}).then(() => {
|
|
44
56
|
// we have to exit manually, because we have some file watches
|
|
45
57
|
process.exit();
|
package/src/utils/gitlab.ts
CHANGED
|
@@ -45,6 +45,13 @@ export const getGitlabToken = async (io: IO | null) => {
|
|
|
45
45
|
);
|
|
46
46
|
process.exit(1);
|
|
47
47
|
}
|
|
48
|
+
if (!io.interactive) {
|
|
49
|
+
// don't start the setup wizard in a context that cannot prompt
|
|
50
|
+
// (direnv, turbo, CI) — fail with the remedy instead
|
|
51
|
+
throw new Error(
|
|
52
|
+
"gitlab token missing — run `catenv` (or any `catladder` command) once in a terminal to set it up",
|
|
53
|
+
);
|
|
54
|
+
}
|
|
48
55
|
await setupGitlabToken(io);
|
|
49
56
|
}
|
|
50
57
|
return getPreference(TOKEN_KEY);
|
|
@@ -63,7 +63,10 @@ export class VaultManager {
|
|
|
63
63
|
return new BitwardenVault(
|
|
64
64
|
this.config,
|
|
65
65
|
vaultConfig,
|
|
66
|
-
|
|
66
|
+
// unlock prompts need a mode that allows them AND an IO that
|
|
67
|
+
// can actually prompt (catenv under direnv/turbo/CI cannot)
|
|
68
|
+
(this.mode === "auto" || this.mode === "refresh") &&
|
|
69
|
+
(this.io?.interactive ?? true),
|
|
67
70
|
);
|
|
68
71
|
}
|
|
69
72
|
}
|