@inquir/compute-cli 0.1.2 → 0.1.4
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/README.md +117 -19
- package/dist/commands/codegen.d.ts.map +1 -1
- package/dist/commands/codegen.js +3 -0
- package/dist/commands/codegen.js.map +1 -1
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +99 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/debug.d.ts.map +1 -1
- package/dist/commands/debug.js +2 -10
- package/dist/commands/debug.js.map +1 -1
- package/dist/commands/delete.d.ts +2 -0
- package/dist/commands/delete.d.ts.map +1 -0
- package/dist/commands/delete.js +50 -0
- package/dist/commands/delete.js.map +1 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +122 -16
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/deploys.d.ts.map +1 -1
- package/dist/commands/deploys.js +10 -4
- package/dist/commands/deploys.js.map +1 -1
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +137 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +44 -17
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/invoke.d.ts.map +1 -1
- package/dist/commands/invoke.js +13 -6
- package/dist/commands/invoke.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +32 -1
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +5 -0
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/logout.js +3 -0
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +11 -7
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/rollback.d.ts.map +1 -1
- package/dist/commands/rollback.js +12 -6
- package/dist/commands/rollback.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +12 -5
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +11 -4
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync-status.d.ts.map +1 -1
- package/dist/commands/sync-status.js +12 -6
- package/dist/commands/sync-status.js.map +1 -1
- package/dist/commands/use.d.ts.map +1 -1
- package/dist/commands/use.js +44 -5
- package/dist/commands/use.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +11 -6
- package/dist/commands/whoami.js.map +1 -1
- package/dist/commands/workspaces.d.ts.map +1 -1
- package/dist/commands/workspaces.js +10 -5
- package/dist/commands/workspaces.js.map +1 -1
- package/dist/index.js +94 -65
- package/dist/index.js.map +1 -1
- package/dist/utils/api.d.ts +10 -0
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +14 -1
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/args.d.ts +6 -0
- package/dist/utils/args.d.ts.map +1 -1
- package/dist/utils/args.js +101 -12
- package/dist/utils/args.js.map +1 -1
- package/dist/utils/assets.d.ts +7 -0
- package/dist/utils/assets.d.ts.map +1 -1
- package/dist/utils/assets.js +18 -0
- package/dist/utils/assets.js.map +1 -1
- package/dist/utils/auth.d.ts +3 -0
- package/dist/utils/auth.d.ts.map +1 -1
- package/dist/utils/auth.js +42 -13
- package/dist/utils/auth.js.map +1 -1
- package/dist/utils/context.d.ts +29 -0
- package/dist/utils/context.d.ts.map +1 -0
- package/dist/utils/context.js +76 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/deploy-follow.d.ts.map +1 -1
- package/dist/utils/deploy-follow.js +7 -1
- package/dist/utils/deploy-follow.js.map +1 -1
- package/dist/utils/ensure-auth.d.ts +8 -0
- package/dist/utils/ensure-auth.d.ts.map +1 -0
- package/dist/utils/ensure-auth.js +27 -0
- package/dist/utils/ensure-auth.js.map +1 -0
- package/dist/utils/errors.d.ts +54 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +221 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/output.d.ts +11 -1
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +51 -7
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/package-metadata.d.ts +3 -0
- package/dist/utils/package-metadata.d.ts.map +1 -0
- package/dist/utils/package-metadata.js +22 -0
- package/dist/utils/package-metadata.js.map +1 -0
- package/dist/utils/payload.d.ts.map +1 -1
- package/dist/utils/payload.js +4 -4
- package/dist/utils/payload.js.map +1 -1
- package/dist/utils/prompt.d.ts +22 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +67 -0
- package/dist/utils/prompt.js.map +1 -0
- package/dist/utils/redact.d.ts +14 -0
- package/dist/utils/redact.d.ts.map +1 -0
- package/dist/utils/redact.js +45 -0
- package/dist/utils/redact.js.map +1 -0
- package/dist/utils/version.d.ts +8 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +21 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -107,51 +107,112 @@ OIDC auth), or run `inquir deploy --ci`.
|
|
|
107
107
|
|
|
108
108
|
## Commands
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
**Project & local dev**
|
|
111
|
+
|
|
112
|
+
- `inquir init [--name <name>] [--skip-install]` - scaffold `inquir.config.json`, folders, and a sample function. Interactive on a TTY (prompts for the project name); guides you to `login`/`run`/`deploy` afterward.
|
|
111
113
|
- `inquir codegen` - discover assets and generate `.inquir/generated/client.ts` + `registry.json`.
|
|
112
|
-
- `inquir list` - list
|
|
114
|
+
- `inquir list [--remote]` - list local assets, or deployed remote functions with `--remote`.
|
|
113
115
|
- `inquir run <asset>` - run a local asset.
|
|
114
116
|
- `inquir debug <asset>` - run locally with inspector enabled.
|
|
117
|
+
- `inquir sync status` - compare local hashes with remote hashes (`in-sync`, `drift`, `missing`).
|
|
118
|
+
|
|
119
|
+
**Auth & workspaces**
|
|
120
|
+
|
|
115
121
|
- `inquir login` - authenticate the CLI (browser pairing, `--browserless`, or `--token`).
|
|
116
122
|
- `inquir logout` - remove the stored token + active workspace for the current environment.
|
|
117
123
|
- `inquir whoami` - show the signed-in user, active workspace, and role.
|
|
118
124
|
- `inquir workspaces` - list the workspaces you belong to.
|
|
119
|
-
- `inquir use <slug|id
|
|
120
|
-
|
|
125
|
+
- `inquir use <slug|id> [--local]` - set the active workspace; `--local` links *this project* by writing `workspace` into `inquir.config.json`.
|
|
126
|
+
|
|
127
|
+
**Deploy & run remotely**
|
|
128
|
+
|
|
121
129
|
- `inquir deploy <asset>` - package, upload, and deploy a function (async; streams build logs).
|
|
130
|
+
- `inquir invoke <asset>` - invoke remote function by name / linked local name.
|
|
131
|
+
- `inquir logs <asset>` - show recent remote invocation history.
|
|
122
132
|
- `inquir deploys <function>` - list deploy history for a remote function.
|
|
123
133
|
- `inquir status <deployId>` - show a deploy's status (`--follow` to stream logs).
|
|
124
134
|
- `inquir rollback <function> [deployId]` - roll back to a previous successful deploy.
|
|
125
|
-
- `inquir
|
|
126
|
-
|
|
135
|
+
- `inquir delete <function>` - delete a remote function (asks for confirmation; `--yes` to skip).
|
|
136
|
+
|
|
137
|
+
**Diagnostics & config**
|
|
138
|
+
|
|
139
|
+
- `inquir doctor` - diagnose environment, credentials, and API connectivity (`--json` for a report).
|
|
140
|
+
- `inquir config [show|get <key>|set <key> <value>|path]` - view/edit CLI configuration.
|
|
141
|
+
- `inquir help [command]` - show grouped help, or help for one command.
|
|
127
142
|
|
|
128
143
|
### `deploy` flags
|
|
129
144
|
|
|
130
145
|
```bash
|
|
131
146
|
inquir deploy hello # package + async deploy, stream build logs
|
|
132
|
-
inquir deploy hello --
|
|
147
|
+
inquir deploy hello --stage staging # target a deploy stage (alias: --environment)
|
|
148
|
+
inquir deploy hello --set KEY=val --set OTHER=val # set environment variables (repeatable)
|
|
149
|
+
inquir deploy hello --env-file .env.production # load env vars from a dotenv file
|
|
150
|
+
inquir deploy hello --memory 512 --timeout 60000 # memory (MB) / timeout (ms)
|
|
151
|
+
inquir deploy hello --layer <layerId> --layer <id2> # attach layers (repeatable)
|
|
133
152
|
inquir deploy hello --no-logs # queue and wait for completion without streaming
|
|
134
153
|
inquir deploy hello --ci # plain output, non-zero exit on failure (for CI)
|
|
135
154
|
inquir deploy hello --dry-run # validate + package only; no create/deploy
|
|
136
155
|
inquir deploy hello --json # machine-readable result
|
|
137
156
|
```
|
|
138
157
|
|
|
139
|
-
|
|
158
|
+
> Note: `--env` selects a named **credential environment** from your config; `--stage`
|
|
159
|
+
> (alias `--environment`) selects the **deploy stage** (production/staging/preview). They
|
|
160
|
+
> are different — don't confuse them.
|
|
140
161
|
|
|
141
162
|
## Global Flags
|
|
142
163
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
164
|
+
Global flags work in **any position** (before or after the command) and accept both
|
|
165
|
+
`--flag value` and `--flag=value`:
|
|
166
|
+
|
|
167
|
+
- `--json` - machine-readable output (implies no color).
|
|
168
|
+
- `--debug` - verbose diagnostics + stack traces (also `INQUIR_DEBUG=1`).
|
|
169
|
+
- `--quiet` - suppress status chatter (errors + requested results only).
|
|
170
|
+
- `--no-color` - disable ANSI color (also honoured: `NO_COLOR`, `FORCE_COLOR`).
|
|
171
|
+
- `--yes`, `-y` - assume "yes" for confirmations (required for destructive ops in CI).
|
|
172
|
+
- `--cwd <path>` - run as if from this directory (alias: `--config`, which also accepts a config file path).
|
|
173
|
+
- `--env <name>` - select a named credential environment from the config.
|
|
146
174
|
- `--workspace <slug|id>` - target a specific workspace for this command (user-scoped login).
|
|
175
|
+
- `--api-url <url>` - override the API base URL.
|
|
176
|
+
- `--token <pat>` - use a Personal Access Token (non-interactive / CI).
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
inquir run hello --cwd ./services/api
|
|
180
|
+
inquir --workspace acme-prod deploy hello
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Exit codes
|
|
184
|
+
|
|
185
|
+
| Code | Meaning |
|
|
186
|
+
|------|---------|
|
|
187
|
+
| `0` | success |
|
|
188
|
+
| `1` | runtime error (build failed, not found, server error) |
|
|
189
|
+
| `2` | usage / validation error (bad flags, missing args) |
|
|
190
|
+
| `3` | network / timeout |
|
|
191
|
+
| `4` | authentication required / forbidden |
|
|
192
|
+
| `130` | interrupted (Ctrl+C / SIGINT) |
|
|
147
193
|
|
|
148
|
-
|
|
194
|
+
A bare `Ctrl+C` aborts cleanly — the CLI prints `Aborted (SIGINT).` to stderr and
|
|
195
|
+
exits `130`, leaving stdout untouched (safe for piping) and no stack trace.
|
|
196
|
+
|
|
197
|
+
With `--json`, errors are emitted as a structured envelope on stdout:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{ "ok": false, "error": { "code": "AUTH_REQUIRED", "title": "You are not logged in", "message": "…", "requestId": "…" } }
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## CI usage
|
|
204
|
+
|
|
205
|
+
In CI / non-TTY, the CLI never prompts; supply credentials via env and use `--ci`/`--yes`:
|
|
149
206
|
|
|
150
207
|
```bash
|
|
151
|
-
|
|
152
|
-
|
|
208
|
+
export INQUIR_TOKEN="$INQUIR_PAT" # or INQUIR_API_KEY for a workspace key
|
|
209
|
+
export INQUIR_WORKSPACE="acme-prod" # optional: target workspace
|
|
210
|
+
inquir deploy hello --ci --json
|
|
153
211
|
```
|
|
154
212
|
|
|
213
|
+
For GitHub Actions, prefer the [`@inquir/deploy-action`](../deploy-action) GitHub Action
|
|
214
|
+
(supports keyless OIDC auth).
|
|
215
|
+
|
|
155
216
|
## Payload Input
|
|
156
217
|
|
|
157
218
|
`run` and `invoke` support:
|
|
@@ -160,20 +221,41 @@ inquir --config ./inquir.config.json run hello
|
|
|
160
221
|
- `--payload-file ./payload.json`
|
|
161
222
|
- stdin piping
|
|
162
223
|
|
|
224
|
+
Shell quoting differs by platform. To pass inline JSON:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# macOS / Linux (bash, zsh) — single-quote the JSON:
|
|
228
|
+
inquir invoke hello --payload '{"name":"World"}'
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
```powershell
|
|
232
|
+
# Windows PowerShell — single-quote the JSON:
|
|
233
|
+
inquir invoke hello --payload '{"name":"World"}'
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
```bat
|
|
237
|
+
:: Windows cmd.exe — escape the inner double quotes:
|
|
238
|
+
inquir invoke hello --payload "{\"name\":\"World\"}"
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
When quoting gets awkward (especially on Windows), prefer `--payload-file ./payload.json`
|
|
242
|
+
or pipe via stdin: `type payload.json | inquir invoke hello`.
|
|
243
|
+
|
|
163
244
|
## Remote Auth / Environment
|
|
164
245
|
|
|
165
246
|
The CLI resolves each credential field independently, in this order (first match
|
|
166
247
|
wins):
|
|
167
248
|
|
|
168
|
-
1. CLI flags / `--env <name>` selection
|
|
249
|
+
1. CLI flags (`--api-url`, `--token`, `--workspace`) / `--env <name>` selection
|
|
169
250
|
2. Environment variables (`LAMBDA_*` are legacy fallbacks):
|
|
170
251
|
- `INQUIR_API_URL`, `INQUIR_API_KEY`
|
|
171
252
|
- `INQUIR_TOKEN` — a Personal Access Token (takes precedence over `apiKey`)
|
|
172
253
|
- `INQUIR_WORKSPACE` — active workspace (slug or id)
|
|
173
254
|
- `INQUIR_ENV` — pick a named environment
|
|
174
255
|
3. Selected environment in the config file
|
|
175
|
-
4.
|
|
176
|
-
5.
|
|
256
|
+
4. Project link — `workspace` in the local `inquir.config.json` (set by `inquir use --local`); applies to the workspace only, below flags/env
|
|
257
|
+
5. Top-level config file values
|
|
258
|
+
6. Default `apiUrl` of `https://api.inquir.org` (override with env/config for local dev)
|
|
177
259
|
|
|
178
260
|
When both a `token` (PAT) and an `apiKey` are present, the PAT wins. The active
|
|
179
261
|
`workspaceId` is only applied to user-scoped credentials (PAT/session); for a
|
|
@@ -181,8 +263,8 @@ workspace-scoped API key it is ignored unless you pass `--workspace` explicitly.
|
|
|
181
263
|
|
|
182
264
|
Config file locations:
|
|
183
265
|
|
|
184
|
-
- `~/.inquir/config.json` (preferred, written by `inquir login` / `use`)
|
|
185
|
-
- `~/.lambda-cli/config.json` (legacy fallback)
|
|
266
|
+
- `~/.inquir/config.json` (preferred, written by `inquir login` / `use`; saved with `0600` permissions)
|
|
267
|
+
- `~/.lambda-cli/config.json` (legacy fallback — **credentials only**; the legacy `apiUrl` is intentionally ignored so you aren't silently pinned to `localhost`)
|
|
186
268
|
|
|
187
269
|
Example (written/managed by `inquir login`, `inquir use`, `inquir logout`):
|
|
188
270
|
|
|
@@ -201,6 +283,22 @@ Example (written/managed by `inquir login`, `inquir use`, `inquir logout`):
|
|
|
201
283
|
}
|
|
202
284
|
```
|
|
203
285
|
|
|
286
|
+
## Troubleshooting
|
|
287
|
+
|
|
288
|
+
Start with `inquir doctor` — it checks the CLI/Node version, config file, credential,
|
|
289
|
+
API connectivity + latency, active workspace, and local project, and prints a fix for any
|
|
290
|
+
failing check.
|
|
291
|
+
|
|
292
|
+
| Symptom | Likely cause / fix |
|
|
293
|
+
|---------|--------------------|
|
|
294
|
+
| `You are not logged in` (exit 4) | No credential resolved. Run `inquir login`, or set `INQUIR_TOKEN`/`INQUIR_API_KEY` in CI. |
|
|
295
|
+
| `Permission denied` (exit 4) | Wrong workspace or insufficient role. Check `inquir whoami`; switch with `inquir use`. |
|
|
296
|
+
| `Not found` for a function | Wrong name or workspace. `inquir list --remote` to see what exists in the active workspace. |
|
|
297
|
+
| Commands hit `localhost` unexpectedly | A stale `apiUrl` in config/env. Check `inquir config show`; override with `--api-url` or `INQUIR_API_URL`. |
|
|
298
|
+
| Network error (exit 3) | Can't reach the API. Verify connectivity and `--api-url`; re-run `inquir doctor`. |
|
|
299
|
+
| Garbled output in logs/CI | Disable color with `--no-color` or `NO_COLOR=1` (color auto-disables when not a TTY and in `--json`). |
|
|
300
|
+
| Need raw detail for a failure | Re-run with `--debug` for stack traces and the response body (secrets are redacted). |
|
|
301
|
+
|
|
204
302
|
## Publishing to npm (maintainers)
|
|
205
303
|
|
|
206
304
|
The CLI (`@inquir/compute-cli`) depends on the SDK (`@inquir/compute`), so the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/commands/codegen.ts"],"names":[],"mappings":"AASA,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/commands/codegen.ts"],"names":[],"mappings":"AASA,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAqClE"}
|
package/dist/commands/codegen.js
CHANGED
|
@@ -7,6 +7,9 @@ export async function codegenCommand(args) {
|
|
|
7
7
|
printCommandHelp('codegen', 'codegen [options]', [
|
|
8
8
|
'--config <path> Path to workspace or config file',
|
|
9
9
|
'--json Machine-readable JSON output',
|
|
10
|
+
], [
|
|
11
|
+
'inquir codegen',
|
|
12
|
+
'inquir codegen --cwd ./services/api',
|
|
10
13
|
]);
|
|
11
14
|
return;
|
|
12
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/commands/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,cAAc,EACd,gCAAgC,EAChC,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,GAAG,E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|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAcA,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA6FjE"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { hasFlag, readEnvironmentFlag, readJsonFlag, readPositionalArgs } from '../utils/args.js';
|
|
2
|
+
import { getConfigFilePath, resolveAuthConfig, updateEnvironmentConfig } from '../utils/auth.js';
|
|
3
|
+
import { buildApiOptions } from '../utils/context.js';
|
|
4
|
+
import { usageError } from '../utils/errors.js';
|
|
5
|
+
import { bold, dim, printCommandHelp, printLine, printSuccess } from '../utils/output.js';
|
|
6
|
+
import { maskToken } from '../utils/redact.js';
|
|
7
|
+
const SETTABLE_KEYS = ['apiUrl', 'workspace', 'token', 'apiKey'];
|
|
8
|
+
function isSettableKey(key) {
|
|
9
|
+
return SETTABLE_KEYS.includes(key);
|
|
10
|
+
}
|
|
11
|
+
export async function configCommand(args) {
|
|
12
|
+
if (hasFlag(args, '--help') || hasFlag(args, '-h')) {
|
|
13
|
+
printCommandHelp('config', 'config [show|get <key>|set <key> <value>|path]', [
|
|
14
|
+
'show Show resolved configuration (default)',
|
|
15
|
+
'get <key> Print a single value (apiUrl|workspace|token|apiKey)',
|
|
16
|
+
'set <key> <value> Persist a value (writes to the active --env slice)',
|
|
17
|
+
'path Print the config file path',
|
|
18
|
+
'--env <name> Operate on a named credential environment',
|
|
19
|
+
'--json Machine-readable output (show/get)',
|
|
20
|
+
], [
|
|
21
|
+
'inquir config show',
|
|
22
|
+
'inquir config get apiUrl',
|
|
23
|
+
'inquir config set apiUrl https://api.inquir.org',
|
|
24
|
+
'inquir config path',
|
|
25
|
+
]);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const positionals = readPositionalArgs(args);
|
|
29
|
+
const sub = positionals[0] ?? 'show';
|
|
30
|
+
const json = readJsonFlag(args);
|
|
31
|
+
const environment = readEnvironmentFlag(args);
|
|
32
|
+
if (sub === 'path') {
|
|
33
|
+
printLine(getConfigFilePath());
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (sub === 'set') {
|
|
37
|
+
const key = positionals[1];
|
|
38
|
+
const value = positionals[2];
|
|
39
|
+
if (!key || value === undefined) {
|
|
40
|
+
throw usageError('Usage: inquir config set <key> <value>', 'inquir config set apiUrl https://api.inquir.org');
|
|
41
|
+
}
|
|
42
|
+
if (!isSettableKey(key)) {
|
|
43
|
+
throw usageError(`Unknown config key: ${key}. Settable: ${SETTABLE_KEYS.join(', ')}`);
|
|
44
|
+
}
|
|
45
|
+
await updateEnvironmentConfig(environment, (slice) => {
|
|
46
|
+
if (key === 'workspace')
|
|
47
|
+
slice.workspaceId = value;
|
|
48
|
+
else
|
|
49
|
+
slice[key] = value;
|
|
50
|
+
});
|
|
51
|
+
printSuccess(`Set ${key}${environment ? ` (env: ${environment})` : ''}.`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (sub === 'get') {
|
|
55
|
+
const key = positionals[1];
|
|
56
|
+
if (!key || !isSettableKey(key)) {
|
|
57
|
+
throw usageError(`Usage: inquir config get <${SETTABLE_KEYS.join('|')}>`);
|
|
58
|
+
}
|
|
59
|
+
const resolved = await resolveAuthConfig(buildApiOptions(args));
|
|
60
|
+
const value = key === 'apiUrl' ? resolved.apiUrl
|
|
61
|
+
: key === 'workspace' ? resolved.workspaceId
|
|
62
|
+
: key === 'token' ? (resolved.token ? maskToken(resolved.token) : undefined)
|
|
63
|
+
: resolved.apiKey ? maskToken(resolved.apiKey) : undefined;
|
|
64
|
+
if (json) {
|
|
65
|
+
printLine(JSON.stringify({ [key]: value ?? null }, null, 2));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
printLine(value ?? '(not set)');
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (sub !== 'show') {
|
|
73
|
+
throw usageError(`Unknown config subcommand: ${sub}`, 'inquir config show');
|
|
74
|
+
}
|
|
75
|
+
// show
|
|
76
|
+
const resolved = await resolveAuthConfig(buildApiOptions(args));
|
|
77
|
+
const credentialKind = resolved.token ? 'token' : resolved.apiKey ? 'apiKey' : null;
|
|
78
|
+
const view = {
|
|
79
|
+
configPath: getConfigFilePath(),
|
|
80
|
+
apiUrl: resolved.apiUrl,
|
|
81
|
+
workspace: resolved.workspaceId ?? null,
|
|
82
|
+
credential: credentialKind
|
|
83
|
+
? { kind: credentialKind, value: maskToken(resolved.token ?? resolved.apiKey) }
|
|
84
|
+
: null,
|
|
85
|
+
user: resolved.user ?? null,
|
|
86
|
+
};
|
|
87
|
+
if (json) {
|
|
88
|
+
printLine(JSON.stringify(view, null, 2));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
printLine(`${bold('Config file:')} ${view.configPath}`);
|
|
92
|
+
printLine(`${bold('API URL:')} ${view.apiUrl}`);
|
|
93
|
+
printLine(`${bold('Workspace:')} ${view.workspace ?? dim('(none)')}`);
|
|
94
|
+
printLine(`${bold('Credential:')} ${view.credential ? `${view.credential.kind} ${dim(view.credential.value)}` : dim('(none — run `inquir login`)')}`);
|
|
95
|
+
if (view.user) {
|
|
96
|
+
printLine(`${bold('User:')} ${view.user.name ?? ''} ${dim(`<${view.user.email ?? view.user.id}>`)}`.trimStart());
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,qB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/E,CAAC,CAAC,IAAI;QACR,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,IAAI;KAC5B,CAAC;IAEF,IAAI,IAAI,EAAE,CAAC;QACT,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACzC,OAAO;IACT,CAAC;IAED,SAAS,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACxD,SAAS,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,SAAS,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvE,SAAS,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC;IACtJ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;IACzH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/commands/debug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/commands/debug.ts"],"names":[],"mappings":"AAEA,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAIhE"}
|
package/dist/commands/debug.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import { hasFlag } from '../utils/args.js';
|
|
2
|
-
import { printCommandHelp } from '../utils/output.js';
|
|
3
1
|
import { runCommand } from './run.js';
|
|
4
2
|
export async function debugCommand(args) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
'--payload <json> JSON payload string',
|
|
8
|
-
'--payload-file <path> Path to JSON payload file',
|
|
9
|
-
'--config <path> Path to workspace or config file',
|
|
10
|
-
]);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
3
|
+
// `debug` is `run` with the inspector enabled; runCommand renders the matching
|
|
4
|
+
// `--help` output (titled "debug") so the two stay in sync.
|
|
13
5
|
await runCommand(args, true);
|
|
14
6
|
}
|
|
15
7
|
//# sourceMappingURL=debug.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/commands/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/commands/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAc;IAC/C,+EAA+E;IAC/E,4DAA4D;IAC5D,MAAM,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":"AAOA,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDjE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { hasFlag, readJsonFlag, readPositionalArgs } from '../utils/args.js';
|
|
2
|
+
import { deleteRemoteFunction, requireAuth, resolveRemoteFunction } from '../utils/api.js';
|
|
3
|
+
import { buildApiOptions, runtime } from '../utils/context.js';
|
|
4
|
+
import { CliError, ExitCode, usageError } from '../utils/errors.js';
|
|
5
|
+
import { printCommandHelp, printLine, printSuccess } from '../utils/output.js';
|
|
6
|
+
import { canPrompt, confirm } from '../utils/prompt.js';
|
|
7
|
+
export async function deleteCommand(args) {
|
|
8
|
+
if (hasFlag(args, '--help') || hasFlag(args, '-h')) {
|
|
9
|
+
printCommandHelp('delete', 'delete <function> [options]', [
|
|
10
|
+
'--yes, -y Skip the confirmation prompt (required in CI/non-TTY)',
|
|
11
|
+
'--workspace Target workspace (slug or id)',
|
|
12
|
+
'--json Machine-readable JSON output',
|
|
13
|
+
], [
|
|
14
|
+
'inquir delete hello',
|
|
15
|
+
'inquir delete hello --yes # skip confirmation (CI/non-TTY)',
|
|
16
|
+
]);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const [identifier] = readPositionalArgs(args);
|
|
20
|
+
if (!identifier) {
|
|
21
|
+
throw usageError('Missing function name or id', 'inquir delete <name|id>');
|
|
22
|
+
}
|
|
23
|
+
const apiOptions = buildApiOptions(args);
|
|
24
|
+
await requireAuth(apiOptions);
|
|
25
|
+
const fn = await resolveRemoteFunction(identifier, apiOptions);
|
|
26
|
+
const json = readJsonFlag(args);
|
|
27
|
+
if (!runtime().yes) {
|
|
28
|
+
if (!canPrompt()) {
|
|
29
|
+
throw new CliError('Refusing to delete without confirmation', {
|
|
30
|
+
code: 'CONFIRMATION_REQUIRED',
|
|
31
|
+
exitCode: ExitCode.USAGE,
|
|
32
|
+
explanation: `Deleting "${fn.name}" is irreversible.`,
|
|
33
|
+
fix: 'Re-run with --yes to confirm in non-interactive mode.',
|
|
34
|
+
command: `inquir delete ${identifier} --yes`,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const ok = await confirm(`Delete remote function "${fn.name}" (${fn.id})? This cannot be undone.`, false);
|
|
38
|
+
if (!ok) {
|
|
39
|
+
printLine('Aborted.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
await deleteRemoteFunction(fn.id, apiOptions);
|
|
44
|
+
if (json) {
|
|
45
|
+
printLine(JSON.stringify({ ok: true, deleted: { id: fn.id, name: fn.name } }, null, 2));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
printSuccess(`Deleted function ${fn.name} (${fn.id}).`);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAc;IAChD,IAAI,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACnD,gBAAgB,CAAC,QAAQ,EAAE,6BAA6B,EAAE;YACxD,sEAAsE;YACtE,8CAA8C;YAC9C,6CAA6C;SAC9C,EAAE;YACD,qBAAqB;YACrB,+D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AAE,EAAE,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACxF,OAAO;IACT,CAAC;IACD,YAAY,CAAC,oBAAoB,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAyFA,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgLjE"}
|