@catladder/cli 0.0.0-next-2eda2fde → 0.0.0-next-a2f59d07

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 (31) hide show
  1. package/dist/apps/cli/src/adapters/terminal.d.ts +8 -0
  2. package/dist/apps/cli/src/adapters/terminal.js +9 -2
  3. package/dist/apps/cli/src/adapters/terminal.js.map +1 -1
  4. package/dist/apps/cli/src/apps/catenv/catenv.d.ts +5 -0
  5. package/dist/apps/cli/src/apps/catenv/catenv.js +10 -1
  6. package/dist/apps/cli/src/apps/catenv/catenv.js.map +1 -1
  7. package/dist/apps/cli/src/catenv.js +7 -0
  8. package/dist/apps/cli/src/catenv.js.map +1 -1
  9. package/dist/apps/cli/src/utils/gitlab.js +5 -0
  10. package/dist/apps/cli/src/utils/gitlab.js.map +1 -1
  11. package/dist/apps/cli/src/vault/VaultManager.js +6 -1
  12. package/dist/apps/cli/src/vault/VaultManager.js.map +1 -1
  13. package/dist/bundles/catci/index.js +5 -5
  14. package/dist/bundles/catenv/index.js +12257 -6871
  15. package/dist/bundles/cli/index.js +80846 -87002
  16. package/dist/bundles/skills/catladder-migrate-package-manager/SKILL.md +7 -0
  17. package/dist/bundles/skills/catladder-migrate-package-manager/references/yarn-to-pnpm-differences.md +6 -0
  18. package/dist/packages/pipeline/src/pipeline/packageManager.js +3 -3
  19. package/dist/packages/pipeline/src/pipeline/packageManager.js.map +1 -1
  20. package/dist/packages/pipeline/src/pipeline/projectFiles.d.ts +10 -0
  21. package/dist/packages/pipeline/src/pipeline/projectFiles.js +17 -0
  22. package/dist/packages/pipeline/src/pipeline/projectFiles.js.map +1 -0
  23. package/dist/skills/catladder-migrate-package-manager/SKILL.md +7 -0
  24. package/dist/skills/catladder-migrate-package-manager/references/yarn-to-pnpm-differences.md +6 -0
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +12 -6
  27. package/src/adapters/terminal.ts +16 -2
  28. package/src/apps/catenv/catenv.ts +15 -1
  29. package/src/catenv.ts +12 -0
  30. package/src/utils/gitlab.ts +7 -0
  31. package/src/vault/VaultManager.ts +4 -1
package/package.json CHANGED
@@ -53,19 +53,19 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "0.0.0-next-2eda2fde",
56
+ "version": "0.0.0-next-a2f59d07",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
60
- "test": "yarn run lint",
61
- "build": "yarn build:compile && yarn build:bundle && yarn build:copy-images && yarn build:skill-cli-reference && yarn build:copy-skills",
60
+ "test": "pnpm run lint",
61
+ "build": "pnpm run build:compile && pnpm run build:bundle && pnpm run build:copy-images && pnpm run build:skill-cli-reference && pnpm run build:copy-skills",
62
62
  "build:bundle": "./scripts/bundle",
63
63
  "build:copy-images": "rm -rf dist/runner-images dist/bundles/runner-images && cp -R ../../runner-images dist/runner-images && cp -R ../../runner-images dist/bundles/runner-images",
64
64
  "build:copy-skills": "rm -rf dist/skills dist/bundles/skills && cp -R ../../skills dist/skills && cp -R ../../skills dist/bundles/skills",
65
65
  "build:skill-cli-reference": "tsx src/scripts/generateCliSkillReference.ts",
66
- "build:compile": "yarn tsc && yarn tsc-alias",
66
+ "build:compile": "tsc && tsc-alias",
67
67
  "dev:own-catenv": "cd ../../ && node apps/cli/bin/catenv-dev",
68
- "build:watch": "tsc-watch --onSuccess \"yarn dev:own-catenv\""
68
+ "build:watch": "tsc-watch --onSuccess \"pnpm run dev:own-catenv\""
69
69
  },
70
70
  "bin": {
71
71
  "catenv": "./bin/catenv",
@@ -80,10 +80,12 @@
80
80
  "@catladder/bash": "workspace:*",
81
81
  "@catladder/pipeline": "workspace:*",
82
82
  "@changesets/parse": "^0.4.3",
83
+ "@gitbeaker/core": "^39.28.0",
83
84
  "@gitbeaker/rest": "^39.28.0",
84
85
  "@inquirer/prompts": "^8.4.3",
85
86
  "@kubernetes/client-node": "^0.16.2",
86
87
  "@tsconfig/node14": "^1.0.1",
88
+ "@types/child-process-promise": "^2.2.6",
87
89
  "@types/common-tags": "^1.8.4",
88
90
  "@types/fs-extra": "^5.0.4",
89
91
  "@types/lodash-es": "^4.17.12",
@@ -102,17 +104,21 @@
102
104
  "connection-string-parser": "^1.0.4",
103
105
  "date-fns": "^3.6.0",
104
106
  "fs-extra": "^7.0.1",
107
+ "jiti": "^2.7.0",
105
108
  "lodash-es": "^4.18.1",
106
109
  "memoizee": "^0.4.17",
107
110
  "node-fetch": "^2.3.0",
108
111
  "open": "^8.4.0",
112
+ "path-equal": "1.2.5",
109
113
  "prettier": "^3.3.3",
114
+ "slugify": "^1.6.6",
110
115
  "tmp-promise": "^2.0.2",
111
116
  "ts-results-es": "^4.2.0",
112
117
  "tsc-alias": "^1.8.16",
113
118
  "tsc-watch": "^7.2.0",
114
119
  "typescript": "^5.4.5",
115
- "yaml": "^2.5.0"
120
+ "yaml": "^2.5.0",
121
+ "zod": "^4.4.3"
116
122
  },
117
123
  "dependencies": {
118
124
  "tsx": "^4.21.0"
@@ -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
- console.log(message);
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 = createNonInteractiveIO({ vaultMode: options?.vaultMode });
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();
@@ -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
- this.mode === "auto" || this.mode === "refresh",
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
  }