@capuchoo/cli 0.2.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 (111) hide show
  1. package/README.md +351 -0
  2. package/bin/dev.cmd +3 -0
  3. package/bin/dev.js +5 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +5 -0
  6. package/dist/base-command.d.ts +15 -0
  7. package/dist/base-command.d.ts.map +1 -0
  8. package/dist/base-command.js +61 -0
  9. package/dist/base-command.js.map +1 -0
  10. package/dist/commands/auth/login.d.ts +19 -0
  11. package/dist/commands/auth/login.d.ts.map +1 -0
  12. package/dist/commands/auth/login.js +74 -0
  13. package/dist/commands/auth/login.js.map +1 -0
  14. package/dist/commands/auth/logout.d.ts +6 -0
  15. package/dist/commands/auth/logout.d.ts.map +1 -0
  16. package/dist/commands/auth/logout.js +22 -0
  17. package/dist/commands/auth/logout.js.map +1 -0
  18. package/dist/commands/auth/whoami.d.ts +9 -0
  19. package/dist/commands/auth/whoami.d.ts.map +1 -0
  20. package/dist/commands/auth/whoami.js +77 -0
  21. package/dist/commands/auth/whoami.js.map +1 -0
  22. package/dist/commands/channel/list.d.ts +9 -0
  23. package/dist/commands/channel/list.d.ts.map +1 -0
  24. package/dist/commands/channel/list.js +47 -0
  25. package/dist/commands/channel/list.js.map +1 -0
  26. package/dist/commands/config/list.d.ts +9 -0
  27. package/dist/commands/config/list.d.ts.map +1 -0
  28. package/dist/commands/config/list.js +116 -0
  29. package/dist/commands/config/list.js.map +1 -0
  30. package/dist/commands/config/set.d.ts +11 -0
  31. package/dist/commands/config/set.d.ts.map +1 -0
  32. package/dist/commands/config/set.js +44 -0
  33. package/dist/commands/config/set.js.map +1 -0
  34. package/dist/commands/deploy/native.d.ts +23 -0
  35. package/dist/commands/deploy/native.d.ts.map +1 -0
  36. package/dist/commands/deploy/native.js +39 -0
  37. package/dist/commands/deploy/native.js.map +1 -0
  38. package/dist/commands/deploy/ota.d.ts +20 -0
  39. package/dist/commands/deploy/ota.d.ts.map +1 -0
  40. package/dist/commands/deploy/ota.js +20 -0
  41. package/dist/commands/deploy/ota.js.map +1 -0
  42. package/dist/commands/init.d.ts +17 -0
  43. package/dist/commands/init.d.ts.map +1 -0
  44. package/dist/commands/init.js +232 -0
  45. package/dist/commands/init.js.map +1 -0
  46. package/dist/commands/version/bump.d.ts +13 -0
  47. package/dist/commands/version/bump.d.ts.map +1 -0
  48. package/dist/commands/version/bump.js +52 -0
  49. package/dist/commands/version/bump.js.map +1 -0
  50. package/dist/commands/version/sync.d.ts +12 -0
  51. package/dist/commands/version/sync.d.ts.map +1 -0
  52. package/dist/commands/version/sync.js +81 -0
  53. package/dist/commands/version/sync.js.map +1 -0
  54. package/dist/deploy/execute.d.ts +48 -0
  55. package/dist/deploy/execute.d.ts.map +1 -0
  56. package/dist/deploy/execute.js +280 -0
  57. package/dist/deploy/execute.js.map +1 -0
  58. package/dist/index.d.ts +2 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +2 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/pipeline/android.d.ts +37 -0
  63. package/dist/pipeline/android.d.ts.map +1 -0
  64. package/dist/pipeline/android.js +96 -0
  65. package/dist/pipeline/android.js.map +1 -0
  66. package/dist/pipeline/build.d.ts +69 -0
  67. package/dist/pipeline/build.d.ts.map +1 -0
  68. package/dist/pipeline/build.js +138 -0
  69. package/dist/pipeline/build.js.map +1 -0
  70. package/dist/pipeline/deploy.d.ts +74 -0
  71. package/dist/pipeline/deploy.d.ts.map +1 -0
  72. package/dist/pipeline/deploy.js +198 -0
  73. package/dist/pipeline/deploy.js.map +1 -0
  74. package/dist/pipeline/flavour.d.ts +66 -0
  75. package/dist/pipeline/flavour.d.ts.map +1 -0
  76. package/dist/pipeline/flavour.js +120 -0
  77. package/dist/pipeline/flavour.js.map +1 -0
  78. package/dist/pipeline/native-config.d.ts +43 -0
  79. package/dist/pipeline/native-config.d.ts.map +1 -0
  80. package/dist/pipeline/native-config.js +127 -0
  81. package/dist/pipeline/native-config.js.map +1 -0
  82. package/dist/pipeline/toolchain.d.ts +80 -0
  83. package/dist/pipeline/toolchain.d.ts.map +1 -0
  84. package/dist/pipeline/toolchain.js +146 -0
  85. package/dist/pipeline/toolchain.js.map +1 -0
  86. package/dist/pipeline/zip.d.ts +22 -0
  87. package/dist/pipeline/zip.d.ts.map +1 -0
  88. package/dist/pipeline/zip.js +188 -0
  89. package/dist/pipeline/zip.js.map +1 -0
  90. package/dist/services/cloud.d.ts +58 -0
  91. package/dist/services/cloud.d.ts.map +1 -0
  92. package/dist/services/cloud.js +89 -0
  93. package/dist/services/cloud.js.map +1 -0
  94. package/dist/utils/config.d.ts +52 -0
  95. package/dist/utils/config.d.ts.map +1 -0
  96. package/dist/utils/config.js +144 -0
  97. package/dist/utils/config.js.map +1 -0
  98. package/dist/utils/exec.d.ts +44 -0
  99. package/dist/utils/exec.d.ts.map +1 -0
  100. package/dist/utils/exec.js +136 -0
  101. package/dist/utils/exec.js.map +1 -0
  102. package/dist/utils/http.d.ts +37 -0
  103. package/dist/utils/http.d.ts.map +1 -0
  104. package/dist/utils/http.js +137 -0
  105. package/dist/utils/http.js.map +1 -0
  106. package/dist/utils/reporter.d.ts +48 -0
  107. package/dist/utils/reporter.d.ts.map +1 -0
  108. package/dist/utils/reporter.js +108 -0
  109. package/dist/utils/reporter.js.map +1 -0
  110. package/oclif.manifest.json +568 -0
  111. package/package.json +81 -0
package/README.md ADDED
@@ -0,0 +1,351 @@
1
+ @capuchoo/cli
2
+ =============
3
+
4
+ Capuchooo CLI bundles and uploads your application to the cloud. It packages builds as native
5
+ artifacts or ZIP files, then publishes them using user-defined parameters such as channels and
6
+ custom release options. Built for simple, repeatable deployments, it integrates cleanly into local
7
+ workflows and CI pipelines to ship updates quickly and reliably.
8
+
9
+ For team release operations, version ownership, GitHub Actions integration, and ecosystem
10
+ boundaries, see [CI releases](docs/ci-releases.md).
11
+
12
+ [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
13
+ [![Version](https://img.shields.io/npm/v/%40capuchoo%2Fcli.svg)](https://npmjs.org/package/@capuchoo/cli)
14
+ [![Downloads/week](https://img.shields.io/npm/dw/%40capuchoo%2Fcli.svg)](https://npmjs.org/package/@capuchoo/cli)
15
+
16
+ <!-- toc -->
17
+
18
+ - [Usage](#usage)
19
+ - [Commands](#commands)
20
+
21
+ <!-- tocstop -->
22
+
23
+ # Usage
24
+
25
+ <!-- usage -->
26
+
27
+ ```sh-session
28
+ $ npm install -g @capuchoo/cli
29
+ $ capuchoo COMMAND
30
+ running command...
31
+ $ capuchoo (--version)
32
+ @capuchoo/cli/0.2.0 win32-x64 node-v26.4.0
33
+ $ capuchoo --help [COMMAND]
34
+ USAGE
35
+ $ capuchoo COMMAND
36
+ ...
37
+ ```
38
+
39
+ <!-- usagestop -->
40
+
41
+ # Commands
42
+
43
+ <!-- commands -->
44
+
45
+ - [`capuchoo auth login`](#capuchoo-auth-login)
46
+ - [`capuchoo auth logout`](#capuchoo-auth-logout)
47
+ - [`capuchoo auth whoami`](#capuchoo-auth-whoami)
48
+ - [`capuchoo channel list`](#capuchoo-channel-list)
49
+ - [`capuchoo config list`](#capuchoo-config-list)
50
+ - [`capuchoo config set KEY VALUE`](#capuchoo-config-set-key-value)
51
+ - [`capuchoo deploy native`](#capuchoo-deploy-native)
52
+ - [`capuchoo deploy ota`](#capuchoo-deploy-ota)
53
+ - [`capuchoo help [COMMAND]`](#capuchoo-help-command)
54
+ - [`capuchoo init`](#capuchoo-init)
55
+ - [`capuchoo version bump TYPE`](#capuchoo-version-bump-type)
56
+ - [`capuchoo version sync`](#capuchoo-version-sync)
57
+
58
+ ## `capuchoo auth login`
59
+
60
+ Store an API key for the Capuchooo backend
61
+
62
+ ```
63
+ USAGE
64
+ $ capuchoo auth login [-k <value>] [-e <value>]
65
+
66
+ FLAGS
67
+ -e, --endpoint=<value> Backend base URL
68
+ -k, --api-key=<value> API key from Settings > API Keys in the dashboard
69
+
70
+ DESCRIPTION
71
+ Store an API key for the Capuchooo backend
72
+
73
+ EXAMPLES
74
+ $ capuchoo auth login
75
+
76
+ $ capuchoo auth login --endpoint https://capuchoo.internal --api-key cap_...
77
+ ```
78
+
79
+ _See code:
80
+ [src/commands/auth/login.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/auth/login.ts)_
81
+
82
+ ## `capuchoo auth logout`
83
+
84
+ Remove the stored API key
85
+
86
+ ```
87
+ USAGE
88
+ $ capuchoo auth logout
89
+
90
+ DESCRIPTION
91
+ Remove the stored API key
92
+ ```
93
+
94
+ _See code:
95
+ [src/commands/auth/logout.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/auth/logout.ts)_
96
+
97
+ ## `capuchoo auth whoami`
98
+
99
+ Show the signed-in account, and the organizations and apps it can reach
100
+
101
+ ```
102
+ USAGE
103
+ $ capuchoo auth whoami [--json]
104
+
105
+ FLAGS
106
+ --json Machine-readable output
107
+
108
+ DESCRIPTION
109
+ Show the signed-in account, and the organizations and apps it can reach
110
+ ```
111
+
112
+ _See code:
113
+ [src/commands/auth/whoami.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/auth/whoami.ts)_
114
+
115
+ ## `capuchoo channel list`
116
+
117
+ List this app's channels and what they serve
118
+
119
+ ```
120
+ USAGE
121
+ $ capuchoo channel list [--json]
122
+
123
+ FLAGS
124
+ --json Machine-readable output
125
+
126
+ DESCRIPTION
127
+ List this app's channels and what they serve
128
+ ```
129
+
130
+ _See code:
131
+ [src/commands/channel/list.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/channel/list.ts)_
132
+
133
+ ## `capuchoo config list`
134
+
135
+ Show the resolved configuration, and which build tools were found
136
+
137
+ ```
138
+ USAGE
139
+ $ capuchoo config list [--json]
140
+
141
+ FLAGS
142
+ --json Machine-readable output
143
+
144
+ DESCRIPTION
145
+ Show the resolved configuration, and which build tools were found
146
+ ```
147
+
148
+ _See code:
149
+ [src/commands/config/list.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/config/list.ts)_
150
+
151
+ ## `capuchoo config set KEY VALUE`
152
+
153
+ Set a user preference in ~/.capuchoo/config.json
154
+
155
+ ```
156
+ USAGE
157
+ $ capuchoo config set KEY VALUE
158
+
159
+ ARGUMENTS
160
+ KEY (endpoint|defaultChannel) Preference to set
161
+ VALUE New value
162
+
163
+ DESCRIPTION
164
+ Set a user preference in ~/.capuchoo/config.json
165
+
166
+ EXAMPLES
167
+ $ capuchoo config set endpoint https://capuchoo.internal
168
+
169
+ $ capuchoo config set defaultChannel staging
170
+ ```
171
+
172
+ _See code:
173
+ [src/commands/config/set.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/config/set.ts)_
174
+
175
+ ## `capuchoo deploy native`
176
+
177
+ Build and publish a native binary (APK). Users install it through the OS.
178
+
179
+ ```
180
+ USAGE
181
+ $ capuchoo deploy native [-c <value>] [-n <value>] [-v major|minor|patch] [-a] [-r] [--skip-assets] [--skip-build]
182
+ [--dry-run] [--json] [--verbose] [-y] [-p android|ios] [-t debug|release] [--allow-unsigned]
183
+
184
+ FLAGS
185
+ -a, --[no-]active Serve this release immediately
186
+ -c, --channel=<value> Channel to publish to. Its environment selects the flavour.
187
+ -n, --note=<value> Release notes shown to users
188
+ -p, --platform=<option> [default: android] Target platform
189
+ <options: android|ios>
190
+ -r, --[no-]required Users cannot postpone this release
191
+ -t, --type=<option> [default: release] Gradle variant to assemble
192
+ <options: debug|release>
193
+ -v, --version=<option> Bump the app version before publishing
194
+ <options: major|minor|patch>
195
+ -y, --yes Accept every prompt - required in CI
196
+ --allow-unsigned Publish a release build with no signature. Android will refuse to install it.
197
+ --dry-run Build and package, but upload nothing
198
+ --json Emit a machine-readable result on stdout
199
+ --skip-assets Do not regenerate launcher icons
200
+ --skip-build Publish the existing build output as-is
201
+ --verbose Stream build output to the terminal
202
+
203
+ DESCRIPTION
204
+ Build and publish a native binary (APK). Users install it through the OS.
205
+
206
+ EXAMPLES
207
+ $ capuchoo deploy native --channel staging
208
+
209
+ $ capuchoo deploy native -c production -v minor --type release
210
+
211
+ $ capuchoo deploy native -c staging --type debug -y
212
+ ```
213
+
214
+ _See code:
215
+ [src/commands/deploy/native.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/deploy/native.ts)_
216
+
217
+ ## `capuchoo deploy ota`
218
+
219
+ Publish a web bundle over the air. Does not change the installed binary.
220
+
221
+ ```
222
+ USAGE
223
+ $ capuchoo deploy ota [-c <value>] [-n <value>] [-v major|minor|patch] [-a] [-r] [--skip-assets] [--skip-build]
224
+ [--dry-run] [--json] [--verbose] [-y]
225
+
226
+ FLAGS
227
+ -a, --[no-]active Serve this release immediately
228
+ -c, --channel=<value> Channel to publish to. Its environment selects the flavour.
229
+ -n, --note=<value> Release notes shown to users
230
+ -r, --[no-]required Users cannot postpone this release
231
+ -v, --version=<option> Bump the app version before publishing
232
+ <options: major|minor|patch>
233
+ -y, --yes Accept every prompt - required in CI
234
+ --dry-run Build and package, but upload nothing
235
+ --json Emit a machine-readable result on stdout
236
+ --skip-assets Do not regenerate launcher icons
237
+ --skip-build Publish the existing build output as-is
238
+ --verbose Stream build output to the terminal
239
+
240
+ DESCRIPTION
241
+ Publish a web bundle over the air. Does not change the installed binary.
242
+
243
+ EXAMPLES
244
+ $ capuchoo deploy ota --channel staging
245
+
246
+ $ capuchoo deploy ota -c production -v patch -n 'Fixes the invoice total'
247
+
248
+ $ capuchoo deploy ota -c staging --dry-run
249
+ ```
250
+
251
+ _See code:
252
+ [src/commands/deploy/ota.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/deploy/ota.ts)_
253
+
254
+ ## `capuchoo help [COMMAND]`
255
+
256
+ Display help for capuchoo.
257
+
258
+ ```
259
+ USAGE
260
+ $ capuchoo help [COMMAND...] [-n]
261
+
262
+ ARGUMENTS
263
+ [COMMAND...] Command to show help for.
264
+
265
+ FLAGS
266
+ -n, --nested-commands Include all nested commands in the output.
267
+
268
+ DESCRIPTION
269
+ Display help for capuchoo.
270
+ ```
271
+
272
+ _See code:
273
+ [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/6.2.58/src/commands/help.ts)_
274
+
275
+ ## `capuchoo init`
276
+
277
+ Link this directory to a Capuchooo app and write .capuchoo/project.json
278
+
279
+ ```
280
+ USAGE
281
+ $ capuchoo init [-l] [-f]
282
+
283
+ FLAGS
284
+ -f, --force Overwrite an existing project.json
285
+ -l, --link Link an existing app instead of creating one
286
+
287
+ DESCRIPTION
288
+ Link this directory to a Capuchooo app and write .capuchoo/project.json
289
+
290
+ EXAMPLES
291
+ $ capuchoo init
292
+
293
+ $ capuchoo init --link
294
+ ```
295
+
296
+ _See code:
297
+ [src/commands/init.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/init.ts)_
298
+
299
+ ## `capuchoo version bump TYPE`
300
+
301
+ Raise the app's semantic version, and optionally an environment's build number
302
+
303
+ ```
304
+ USAGE
305
+ $ capuchoo version bump TYPE [-e dev|staging|prod]
306
+
307
+ ARGUMENTS
308
+ TYPE (major|minor|patch) Which part of the version to raise
309
+
310
+ FLAGS
311
+ -e, --environment=<option> Also increment this environment's native build number
312
+ <options: dev|staging|prod>
313
+
314
+ DESCRIPTION
315
+ Raise the app's semantic version, and optionally an environment's build number
316
+
317
+ EXAMPLES
318
+ $ capuchoo version bump patch
319
+
320
+ $ capuchoo version bump minor --environment staging
321
+ ```
322
+
323
+ _See code:
324
+ [src/commands/version/bump.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/version/bump.ts)_
325
+
326
+ ## `capuchoo version sync`
327
+
328
+ Show, or advance, the version and build number used for each flavour
329
+
330
+ ```
331
+ USAGE
332
+ $ capuchoo version sync [-b] [-e dev|staging|prod] [--json]
333
+
334
+ FLAGS
335
+ -b, --bump Increment the build number for the selected environments
336
+ -e, --environment=<option> Limit to one environment
337
+ <options: dev|staging|prod>
338
+ --json Machine-readable output
339
+
340
+ DESCRIPTION
341
+ Show, or advance, the version and build number used for each flavour
342
+
343
+ EXAMPLES
344
+ $ capuchoo version sync
345
+
346
+ $ capuchoo version sync --bump --environment staging
347
+ ```
348
+
349
+ _See code:
350
+ [src/commands/version/sync.ts](https://github.com/aybinv7/capuchoo/blob/v0.2.0/src/commands/version/sync.ts)_
351
+ <!-- commandsstop -->
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
2
+
3
+ import { execute } from "@oclif/core";
4
+
5
+ await execute({ development: true, dir: import.meta.url });
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execute } from "@oclif/core";
4
+
5
+ await execute({ dir: import.meta.url });
@@ -0,0 +1,15 @@
1
+ import { Command } from "@oclif/core";
2
+ /**
3
+ * Base class for every Capucho command.
4
+ *
5
+ * Two jobs, both about failure. oclif's default renderer prints the error class
6
+ * name and a stack-shaped indent, which for a deploy tool buries the one line
7
+ * that matters. And an aborted prompt raises `ExitPromptError`, which used to
8
+ * surface as an unhandled crash when a developer pressed Ctrl-C.
9
+ */
10
+ export declare abstract class BaseCommand extends Command {
11
+ protected catch(error: Error & {
12
+ exitCode?: number;
13
+ }): Promise<never>;
14
+ }
15
+ //# sourceMappingURL=base-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-command.d.ts","sourceRoot":"","sources":["../src/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC;;;;;;;GAOG;AACH,8BAAsB,WAAY,SAAQ,OAAO;cACtB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC;CAwBrF"}
@@ -0,0 +1,61 @@
1
+ import { Command } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import { HttpError } from "./utils/http.js";
4
+ /**
5
+ * Base class for every Capucho command.
6
+ *
7
+ * Two jobs, both about failure. oclif's default renderer prints the error class
8
+ * name and a stack-shaped indent, which for a deploy tool buries the one line
9
+ * that matters. And an aborted prompt raises `ExitPromptError`, which used to
10
+ * surface as an unhandled crash when a developer pressed Ctrl-C.
11
+ */
12
+ export class BaseCommand extends Command {
13
+ async catch(error) {
14
+ // Ctrl-C at a prompt is a decision, not a fault.
15
+ if (error.name === "ExitPromptError" || error.name === "AbortPromptError") {
16
+ process.stderr.write(chalk.dim("\nCancelled.\n"));
17
+ process.exit(130); // 128 + SIGINT
18
+ }
19
+ if (error instanceof HttpError) {
20
+ process.stderr.write(`\n${chalk.red("✗")} ${error.message}\n`);
21
+ // Say what the status actually means for the caller, rather than leaving
22
+ // them to interpret a bare number.
23
+ const hint = describeStatus(error.status);
24
+ if (hint)
25
+ process.stderr.write(chalk.dim(` ${hint}\n`));
26
+ process.stderr.write("\n");
27
+ process.exit(1);
28
+ }
29
+ // Multi-line messages are already formatted by the thrower (validation
30
+ // reports a bulleted list, for instance); do not re-wrap them.
31
+ const message = error.message ?? String(error);
32
+ process.stderr.write(`\n${chalk.red("✗")} ${message}\n\n`);
33
+ process.exit(typeof error.exitCode === "number" ? error.exitCode : 1);
34
+ }
35
+ }
36
+ function describeStatus(status) {
37
+ switch (status) {
38
+ case 401:
39
+ case 403: {
40
+ return "The API key was rejected, or it is not scoped to this app. Check `capuchoo auth whoami`.";
41
+ }
42
+ case 404: {
43
+ return "The server has no record with that id. If this app was deleted or recreated, re-run `capuchoo init`.";
44
+ }
45
+ case 409: {
46
+ return "That version already exists on this channel. Bump the version, or deactivate the existing release.";
47
+ }
48
+ case 413: {
49
+ return "The artefact is larger than the server accepts.";
50
+ }
51
+ case 429: {
52
+ return "Rate limited. Wait and retry.";
53
+ }
54
+ default: {
55
+ return status >= 500
56
+ ? "The server failed. This is not something the CLI can fix - retry, then check the backend logs."
57
+ : null;
58
+ }
59
+ }
60
+ }
61
+ //# sourceMappingURL=base-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-command.js","sourceRoot":"","sources":["../src/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,OAAgB,WAAY,SAAQ,OAAO;IAC5B,KAAK,CAAC,KAAK,CAAC,KAAoC;QACjE,iDAAiD;QACjD,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;YAC1E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;YAClD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe;QACpC,CAAC;QAED,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;YAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;YAE/D,yEAAyE;YACzE,mCAAmC;YACnC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC1C,IAAI,IAAI;gBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC;YACzD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,uEAAuE;QACvE,+DAA+D;QAC/D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,MAAM,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;CACF;AAED,SAAS,cAAc,CAAC,MAAc;IACpC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,OAAO,0FAA0F,CAAC;QACpG,CAAC;QACD,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,OAAO,sGAAsG,CAAC;QAChH,CAAC;QACD,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,OAAO,oGAAoG,CAAC;QAC9G,CAAC;QACD,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,OAAO,iDAAiD,CAAC;QAC3D,CAAC;QACD,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,OAAO,+BAA+B,CAAC;QACzC,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,MAAM,IAAI,GAAG;gBAClB,CAAC,CAAC,gGAAgG;gBAClG,CAAC,CAAC,IAAI,CAAC;QACX,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { BaseCommand } from "../../base-command.js";
2
+ export default class AuthLogin extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "api-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ endpoint: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ };
9
+ run(): Promise<void>;
10
+ /**
11
+ * Shared with `capuchoo init`, which offers to log in when it finds no
12
+ * credentials.
13
+ *
14
+ * Throws on failure rather than calling `this.error`, so the caller decides
15
+ * whether a failed login ends the process or just ends the login step.
16
+ */
17
+ static performLogin(flagEndpoint?: string, flagApiKey?: string): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW;IAChD,OAAgB,WAAW,SAA8C;IAEzE,OAAgB,QAAQ,WAGtB;IAEF,OAAgB,KAAK;;;MAMnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAK1B;;;;;;OAMG;WACU,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAoDrF"}
@@ -0,0 +1,74 @@
1
+ import { input, password } from "@inquirer/prompts";
2
+ import { Flags } from "@oclif/core";
3
+ import chalk from "chalk";
4
+ import ora from "ora";
5
+ import { CloudClient } from "../../services/cloud.js";
6
+ import { readGlobalConfig, updateGlobalConfig } from "../../utils/config.js";
7
+ import { BaseCommand } from "../../base-command.js";
8
+ const DEFAULT_ENDPOINT = "https://capuchoo-back.onrender.com";
9
+ export default class AuthLogin extends BaseCommand {
10
+ static description = "Store an API key for the Capucho backend";
11
+ static examples = [
12
+ "<%= config.bin %> auth login",
13
+ "<%= config.bin %> auth login --endpoint https://capucho.internal --api-key cap_...",
14
+ ];
15
+ static flags = {
16
+ "api-key": Flags.string({
17
+ char: "k",
18
+ description: "API key from Settings > API Keys in the dashboard",
19
+ }),
20
+ endpoint: Flags.string({ char: "e", description: "Backend base URL" }),
21
+ };
22
+ async run() {
23
+ const { flags } = await this.parse(AuthLogin);
24
+ await AuthLogin.performLogin(flags.endpoint, flags["api-key"]);
25
+ }
26
+ /**
27
+ * Shared with `capuchoo init`, which offers to log in when it finds no
28
+ * credentials.
29
+ *
30
+ * Throws on failure rather than calling `this.error`, so the caller decides
31
+ * whether a failed login ends the process or just ends the login step.
32
+ */
33
+ static async performLogin(flagEndpoint, flagApiKey) {
34
+ const existing = readGlobalConfig();
35
+ const endpoint = (flagEndpoint ??
36
+ (await input({
37
+ message: "Backend URL",
38
+ default: existing.endpoint ?? DEFAULT_ENDPOINT,
39
+ validate: (value) => /^https?:\/\/.+/.test(value.trim()) || "Must start with http:// or https://",
40
+ })))
41
+ .trim()
42
+ .replace(/\/+$/, "");
43
+ let apiKey = flagApiKey;
44
+ if (!apiKey) {
45
+ process.stderr.write(chalk.dim(`\n Create a key under Settings > API Keys at ${endpoint}\n\n`));
46
+ apiKey = await password({
47
+ message: "API key",
48
+ // Only a length check. The previous version required the key to start
49
+ // with "cap_", which is a server-side format decision the CLI has no
50
+ // business enforcing - a rotated prefix would have locked users out.
51
+ validate: (value) => value.trim().length >= 16 || "That key looks too short",
52
+ });
53
+ }
54
+ apiKey = apiKey.trim();
55
+ const spinner = ora({ text: "Verifying", stream: process.stderr }).start();
56
+ const profile = await new CloudClient(endpoint, apiKey).whoami();
57
+ if (!profile) {
58
+ spinner.fail("Those credentials were rejected");
59
+ throw new Error(`${endpoint} did not accept that API key. Check the key and the URL.`);
60
+ }
61
+ spinner.succeed(`Signed in as ${profile.user.email}`);
62
+ // Only what is needed to authenticate, plus who it belongs to. The old
63
+ // implementation also wrote the full app and organization lists, which went
64
+ // stale immediately - and `auth whoami` then read fields that `auth login`
65
+ // never actually saved, so it always reported no organizations.
66
+ updateGlobalConfig({
67
+ endpoint,
68
+ apiKey,
69
+ user: { id: profile.user.id, email: profile.user.email },
70
+ authenticatedAt: new Date().toISOString(),
71
+ });
72
+ }
73
+ }
74
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,6 @@
1
+ import { BaseCommand } from "../../base-command.js";
2
+ export default class AuthLogout extends BaseCommand {
3
+ static description: string;
4
+ run(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=logout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAgB,WAAW,SAA+B;IAEpD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB3B"}
@@ -0,0 +1,22 @@
1
+ import chalk from "chalk";
2
+ import { readGlobalConfig, writeGlobalConfig } from "../../utils/config.js";
3
+ import { BaseCommand } from "../../base-command.js";
4
+ export default class AuthLogout extends BaseCommand {
5
+ static description = "Remove the stored API key";
6
+ async run() {
7
+ const config = readGlobalConfig();
8
+ if (!config.apiKey) {
9
+ this.log(chalk.dim("No stored credentials to remove."));
10
+ }
11
+ else {
12
+ // The endpoint is a preference, not a credential - keeping it means the
13
+ // next login pre-fills the right server. Everything else goes.
14
+ writeGlobalConfig({ endpoint: config.endpoint });
15
+ this.log(chalk.green("Signed out. The stored API key has been removed."));
16
+ }
17
+ if (process.env.CAPUCHO_API_KEY) {
18
+ this.log(chalk.yellow("! CAPUCHO_API_KEY is set in this environment and still takes precedence."));
19
+ }
20
+ }
21
+ }
22
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,MAAM,CAAU,WAAW,GAAG,2BAA2B,CAAC;IAE1D,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;QAElC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,wEAAwE;YACxE,+DAA+D;YAC/D,iBAAiB,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC,CAAC;QAC5E,CAAC;QAED,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;YAChC,IAAI,CAAC,GAAG,CACN,KAAK,CAAC,MAAM,CAAC,0EAA0E,CAAC,CACzF,CAAC;QACJ,CAAC;IACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { BaseCommand } from "../../base-command.js";
2
+ export default class AuthWhoami extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
+ };
7
+ run(): Promise<void>;
8
+ }
9
+ //# sourceMappingURL=whoami.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/whoami.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAgB,WAAW,SACiD;IAE5E,OAAgB,KAAK;;MAEnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAoF3B"}