Buckets:
| # Parameters | |
| Parameters are typed inputs to a build. You declare them as class fields — just | |
| like targets — and read the resolved value inside a target. The execution engine | |
| resolves every parameter **before any target runs**, from (in order of | |
| precedence): | |
| 1. a command-line flag — `--environment production` or | |
| `--environment=production` | |
| 2. an environment variable — `ENVIRONMENT` | |
| 3. a [secret source](./secrets.md) declared with `.from(...)` | |
| 4. the declared default | |
| <!-- check --> | |
| ```ts | |
| import { Build, parameter, run, target } from "@zuke/core"; | |
| class Deploy extends Build { | |
| environment = parameter("Target environment") | |
| .options("dev", "staging", "production") | |
| .required(); | |
| workers = parameter("Parallel upload workers").number().default(4); | |
| preview = parameter("Print actions without performing them").boolean(); | |
| // A required list: `.required()` comes before `.array()` — the reverse order | |
| // does not type-check. | |
| repos = parameter("Repos to deploy").required().array(); | |
| deploy = target().executes(() => { | |
| if (this.preview.value) console.log("(preview)"); | |
| console.log( | |
| `Deploying ${this.repos.value.join(", ")} to ${this.environment.value} ` + | |
| `with ${this.workers.value} workers`, | |
| ); | |
| }); | |
| } | |
| await run(Deploy); | |
| ``` | |
| ```sh | |
| zuke deploy --environment production --workers 8 --repos api,web --preview | |
| ENVIRONMENT=staging REPOS=api,web zuke deploy # values from the environment | |
| ``` | |
| ## Declaring | |
| `parameter(description?)` starts a **string** parameter. Configure it fluently; | |
| each call refines the value type, so `value` is exactly as strong as the | |
| declaration: | |
| | Method | Effect | `value` type | | |
| | -------------------- | --------------------------------------------- | --------------------- | | |
| | `parameter("…")` | optional string | `string \| undefined` | | |
| | `.number()` | parse as a number | `number \| undefined` | | |
| | `.boolean()` | a flag; defaults to `false` | `boolean` | | |
| | `.options("a", "b")` | restrict a string to choices | unchanged | | |
| | `.default(v)` | provide a default | non-optional (`T`) | | |
| | `.required()` | must be supplied | non-optional (`T`) | | |
| | `.env("NAME")` | override the env var name | unchanged | | |
| | `.secret()` | mark the value sensitive (masked everywhere) | unchanged | | |
| | `.from(source)` | resolve from a [secret manager](./secrets.md) | unchanged | | |
| | `.array()` | a comma-separated / repeatable list | `T[]` | | |
| `.number()` and `.boolean()` come first (they change the kind); `.options()` | |
| applies to strings; `.required()`/`.default()` set optionality; and `.array()` | |
| comes **last** and composes with everything before it — so a required list is | |
| `.required().array()` (in that order). A required parameter with no value (and | |
| no default) fails the build before any target runs, with a message naming the | |
| flag and env var — unless it can be supplied interactively (below). | |
| ## Lists | |
| `.array()` turns a string parameter into a list. On the command line, a comma | |
| separates values **or** the flag is repeated (the two are equivalent); blank | |
| entries are dropped. An unsupplied **optional** list defaults to `[]`; make it | |
| `.required().array()` to reject a missing value instead (the required flag | |
| carries through `.array()`). | |
| ```ts | |
| tags = parameter("Image tags").array(); | |
| // deploy = target().executes(() => console.log(this.tags.value)); // string[] | |
| ``` | |
| ```sh | |
| zuke deploy --tags latest,canary # ["latest", "canary"] | |
| zuke deploy --tags latest --tags canary # same result | |
| TAGS=latest,canary zuke deploy # from the environment | |
| ``` | |
| `.array()` composes with the kind and choices declared before it — every | |
| **element** is validated, not just the raw string: | |
| ```ts | |
| // number[]: each entry parsed as a number; "1,x" is rejected. | |
| workers = parameter("Worker ids").number().array(); | |
| // each element must be one of the choices; "api,nope" is rejected. | |
| services = parameter("Services").options("api", "web", "worker").array(); | |
| // required list: missing --repos fails the build (not a silent []). | |
| repos = parameter("Repos to deploy").required().array(); | |
| ``` | |
| ## Secrets | |
| `.secret()` marks a value sensitive. Its resolved value is **redacted from all | |
| of Zuke's output** — every banner, target status, summary, and error message — | |
| and, under GitHub Actions, Zuke also emits an `::add-mask::` so the runner masks | |
| it in its own logs. | |
| ```ts | |
| token = parameter("Deploy token").secret().required(); | |
| ``` | |
| Pair `.secret()` with `.from(source)` to fetch the value from a secret manager | |
| (1Password, Vault, a mounted file, …) instead of the environment: | |
| ```ts | |
| import { execSecret } from "@zuke/core"; | |
| token = parameter("Deploy token") | |
| .secret() | |
| .from( | |
| execSecret((s) => s.command("op").arg("read", "op://vault/deploy/token")), | |
| ); | |
| ``` | |
| The [Secrets guide](./secrets.md) covers sources, resolution precedence, and the | |
| exact redaction guarantee (and its boundary) in full. | |
| ## Interactive input | |
| When a required parameter is missing and the build runs at an interactive | |
| terminal (a TTY, not CI), Zuke prompts for the value instead of failing. On CI | |
| or non-interactive runs it still errors, so automation stays deterministic. | |
| ## Reading | |
| Read a parameter inside a target body via `this.<name>.value`. The value is | |
| fully typed: a `.required()` or `.default()` parameter is non-optional, while a | |
| plain optional parameter is `T | undefined`. Reading `.value` before the build | |
| has resolved parameters (e.g. at construction time) throws. | |
| ## Naming | |
| The flag and environment variable are derived from the property name: | |
| `environment` → `--environment` / `ENVIRONMENT`; a camelCase name like | |
| `targetEnv` → `--target-env` / `TARGET_ENV`. A nested group joins with the same | |
| separator, so `runs.limit` → `--runs-limit` / `RUNS_LIMIT`. | |
| The rule is one dash (or underscore) at **each lower-to-upper transition**. A | |
| run of capitals has no internal transition and so stays together — but a digit | |
| ends a run, which is where the rule surprises people: | |
| | Property name | Flag | Environment variable | | |
| | ------------- | ------------- | -------------------- | | |
| | `apiURL` | `--api-url` | `API_URL` | | |
| | `useHTTPS` | `--use-https` | `USE_HTTPS` | | |
| | `skipE2E` | `--skip-e2-e` | `SKIP_E2_E` | | |
| | `runE2E` | `--run-e2-e` | `RUN_E2_E` | | |
| `skipE2E` gives `--skip-e2-e` because the `2` ends the run of capitals, making | |
| `2E` a transition of its own. Two ways out, and the first is often enough: | |
| - **Name it so the rule agrees with you.** `skipE2e` → `--skip-e2e`. | |
| - **Declare the flag.** `.flag("--skip-e2e")` sets the spelling explicitly, and | |
| the leading dashes are optional. | |
| ```ts | |
| class CI extends Build { | |
| skipE2E = parameter("skip the E2E suite").flag("--skip-e2e").boolean(); | |
| } | |
| ``` | |
| A declared flag **replaces** the derived one: only it is accepted on the command | |
| line, and it is what `--help`, `--list --json`, shell completions and a | |
| registered build's descriptor all show. It must be lowercase letters, digits and | |
| dashes starting with a letter, it may not be a built-in flag (see below), and no | |
| two parameters may claim the same one — each is a `ParameterError` when the | |
| build loads, naming the field. | |
| The environment variable is derived separately and is unaffected by a declared | |
| flag; override that half with `.env("NAME")`. | |
| ### Names a parameter may not use | |
| Two sets of names are refused when the build is loaded, with a `ParameterError` | |
| naming the field: | |
| - **A name that renders as a built-in CLI flag** — `actor` → `--actor`, | |
| `actorKind` → `--actor-kind`, `limit` → `--limit`, and so on for every flag | |
| `zuke --help` lists. The parser matches a built-in first, so the flag means | |
| the built-in and not the parameter: `--actor=alice` attributes the run and | |
| leaves the parameter unresolved. | |
| Such a parameter is not wholly dead — its environment variable still resolves | |
| it, as does an MCP `run:<target>` call — and that is exactly why it is refused | |
| rather than merely documented. It works until someone reaches for its flag, | |
| and then the value quietly does something else. | |
| - **`dryRun`, `confirm` and `operatorToken`** — the control keys an MCP | |
| `run:<target>` tool adds to its input schema alongside the build's parameters, | |
| which would shadow a parameter of the same name. | |
| Only the rendered flag matters, so a longer or nested name is fine: `actorName` | |
| → `--actor-name` and a grouped `runs.limit` → `--runs-limit` both stay usable. | |
| Rename the field, or declare a different flag with `.flag("--…")`. What is not | |
| available is keeping the colliding spelling, because the alternative is a flag | |
| that silently belongs to something else. | |
| ## Without the CLI | |
| Resolution lives in the execution engine, not the CLI, so a programmatic | |
| [`execute`](./programmatic-api.md) call resolves parameters too — pass raw | |
| values via `params` and/or rely on environment variables: | |
| ```ts | |
| import { discoverTargets, execute } from "@zuke/core"; | |
| const build = new Deploy(); | |
| const deploy = discoverTargets(build).get("deploy"); | |
| if (deploy) { | |
| await execute(build, deploy, { params: { environment: "production" } }); | |
| } | |
| ``` | |
Xet Storage Details
- Size:
- 9.53 kB
- Xet hash:
- 842f4ca99ca9c94b84bdd524abaea6236e5da43db17ba5efaf2017de7d06ae6f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.