You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 345c900
Browse filesBrowse the repository at this point in the historyBrowse files
It reaches deployments, git and uploads, for create
144
+
stacks/ the Contentstack stack and delivery-token lookups behind --from-stack, through the
145
+
CmaSession (no Launch endpoint)
146
+
variables/ the shared variable-source resolver (--var, --dotenv, --from-stack, a detected .env file), the
147
+
read-modify-write writer behind launch:variables:set / :unset, and the masked
148
+
presenter behind :list. It has no repository of its own: it reads and writes through
149
+
environments, and reads the stack template through its own VariablesApi. EnvironmentBuilder calls back into it for the create commands, so the
150
+
two folders each name the other in the layering allow-list
144
151
deployments/ the deployment repository, the status classification, the
145
152
wait/stream loop and LogTail that projects:create, deployments:create
146
153
and logs:get all drive, and the DeploymentFollower that watches one
@@ -314,6 +321,48 @@ the yellow `Project not deleted.` and exits 3 (`EXIT_CANCELLED`) without the `Er
314
321
`CancelledError` would print; Ctrl-C at the question is still a `CancelledError`. The success line is
315
322
the green `✔ Project deleted successfully.`, matching `projects:update`.
316
323
324
+
**Environment variables (`launch:variables:*`).** There is no per-variable endpoint, so `set` and `unset`
325
+
are `GET .../environments/:uid`, merge locally, then `PUT` the complete `environmentVariables` array and
326
+
nothing else: the update body is partial on the server, so no other environment field can be dropped by it.
327
+
Every source is resolved and every value prompted for before the `GET`, so no user interaction sits between
328
+
the read and the write; `unset` reads once to validate the keys and name the environment, confirms, then
329
+
reads again immediately before the `PUT`. Two writers racing lose one change - the API offers no ETag and no
330
+
partial update (CL-7179 is the proposed `PATCH`) - and FR34 asks that this be documented rather than treated
331
+
as a defect.
332
+
333
+
`collectVariables` in `src/variables/variable.sources.ts` is the one resolver: stack (`--from-stack`), then
334
+
`--dotenv`, then `--var`, later wins, and the summary line names every source's new keys and every override.
335
+
With no source flag, `set` on a terminal shows the `Add variables from` checklist (`chooseSources` in
336
+
`src/variables/variable.chooser.ts`, shared with the create commands, which add a `Skip` choice); ticking nothing
337
+
prints a yellow `Skipped adding variables.` and sends nothing (sources that supply no variable print a yellow
338
+
`No changes made.`). Without a terminal, `set` auto-detects `.env.local` then `.env`
339
+
under `--data-dir`, always printing the file it chose, and fails with exit 2 when there is none. A bare `--var KEY` is a hidden prompt on a terminal, a stdin read for exactly one bare key without one, and
340
+
exit 2 naming `--dotenv -` for two or more. The API refuses an empty value, so `KEY=` is a usage error naming
341
+
the key, and an empty value inside a dotenv file is skipped with its key reported. No value reaches stdout, a
342
+
prompt message, a confirmation or an error: `list` masks through `redactedColumn`, and a failed `PUT` is worded from
343
+
`ENVIRONMENT_ERROR_MESSAGES`, never from the API's own text.
344
+
345
+
`projects:create` and `env:create` take `--var` and `--dotenv` and reach the same resolver through
346
+
`EnvironmentBuilder`, which asks last - after Contentstack Authentication, where V1 asked - with no auto-detection.
347
+
With neither flag it offers a checkbox over the sources plus `Skip adding environment variables`, which cannot be
348
+
combined with the others; without a terminal it sends an empty list.
349
+
350
+
**`--from-stack` and `--alias`.**`--from-stack` is a bare flag on `variables:set`, `projects:create` and
351
+
`env:create`; `--alias <name>` (`-a`) names a delivery token saved with `csdx auth:tokens:add`, and is a usage error
352
+
without `--from-stack` (`aliasRequiresFromStack`). With an alias the token is read from the `tokens` config object
353
+
(indexed by alias, so a dot in the alias is safe) and must be a delivery token with an environment. Without an alias
354
+
a terminal gets a stack picker then a delivery-token picker (names only); without a terminal it is a usage error
355
+
naming `--alias`. The five variables come from `GET /cms/environment-variables` (API host and CDN, scheme stripped)
356
+
plus the stack's API key, the token and its environment. `src/stacks/` owns the Contentstack stack lookups through
357
+
`CmaSession.fetchStacks` / `fetchDeliveryTokens`, which page 100 at a time; `variables` may import `stacks` and
358
+
`environments` and nothing else (`RESOURCE_EDGES`). A delivery token value is never printed or logged.
359
+
360
+
Two harness traps. `@oclif/test`'s `runCommand` joins argv with spaces and splits it again, so a value containing a
361
+
space must be passed pre-quoted there (`'"MSG=hello world"'`); the real parser keeps it whole, which
362
+
`src/variables/variable.inputs.test.ts` proves against `Parser.parse`. And a test that lets a bare key reach the
363
+
non-terminal path reads the real `process.stdin` and hangs the run, so such a test must answer on a terminal or
364
+
fake `readStdin`.
365
+
317
366
**A prompt never answers with something that is not on its list.** Two mechanisms, chosen by
318
367
whether the choices need searching. `askOption` in `src/core/prompt.ts` is the
319
368
default and the only choice helper left; the two prompts that still need a search box build their
@@ -740,10 +789,9 @@ not a total one, so a large archive that is still moving is never cut off.
740
789
It uses `node:http`/`node:https` rather than `fetch` so `nock` can intercept it - nock 13 does not see
741
790
undici's `fetch`.
742
791
743
-
**Environment variables and argv.**`environmentVariables` is always `[]` on create: the variable
744
-
sources are CL-7169. The shape is built by a function that takes no input at all, so there is no
745
-
argv path into it to grow by accident, and a test passes `var`, `env-file` and `from-stack` into the
746
-
request to prove the body is unchanged. **No secret may reach argv** (FR30, G16).
792
+
**Environment variables and argv.** On create, `environmentVariables` comes only from `variablesForCreate`, called last by
793
+
`EnvironmentBuilder`, so the sources are the explicit `--var`, `--dotenv` and `--from-stack` inputs and the prompt
794
+
checklist and nothing else; the create summary says `ready to set` because the environment does not exist yet. **No secret may reach argv** (FR30, G16).
747
795
748
796
**Cross-flag rules.** A rule that is pure flag-versus-flag and evaluable from argv alone belongs in
749
797
oclif's native `exclusive` / `relationships` on the flag definition, where it also shows in `--help` -
0 commit comments