Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d4e37d5
feat(cli): prompt for worker name if not provided
johnstonmatt Aug 29, 2026
edc7199
fix(cli): gate the workers new prompts on stdin too
johnstonmatt Aug 29, 2026
93c7aa6
feat(cli): prompt for worker name if not provided
johnstonmatt Aug 29, 2026
5c84df0
fix(cli): gate the workers new prompts on stdin too
johnstonmatt Aug 29, 2026
0af0f0a
chore(workers): describe behaviour rather than its history in comments
johnstonmatt Aug 31, 2026
a74e3f9
feat(workers): bring the command family's output onto one shape
johnstonmatt Aug 29, 2026
548a185
test(cli): guard every legacy boolean flag against a required default
johnstonmatt Aug 29, 2026
1d7e06b
chore(workers): describe behaviour rather than its history in comments
johnstonmatt Aug 31, 2026
1a2236d
feat(workers logs): add `supabase workers logs`
johnstonmatt Aug 31, 2026
c4080de
feat(workers logs): print timestamps in local time
johnstonmatt Aug 31, 2026
b7c9864
feat(workers logs): add `--follow` to keep printing new lines
johnstonmatt Aug 31, 2026
2f68ad6
feat: show stream tags in worker logs when multiple sources
johnstonmatt Aug 31, 2026
c66065d
chore(workers): describe behaviour rather than its history in comments
johnstonmatt Aug 31, 2026
88e4832
Merge branch 'FUNC-840/select-workers-new-name' of https://github.com…
johnstonmatt Sep 1, 2026
9ae1f38
fix(cli): point the workers new retry at the experimental path
johnstonmatt Sep 1, 2026
12c4d1c
fix(cli): stop telling users to run a command that does not exist
johnstonmatt Sep 1, 2026
94d1e89
Merge FUNC-840/select-workers-new-name into FUNC-851/general-output-p…
johnstonmatt Sep 1, 2026
4f05bc5
Merge FUNC-851/general-output-polish into FUNC-853/workers-logs-command
johnstonmatt Sep 1, 2026
1f103f9
fix(workers): restore the experimental segment in worker span names
johnstonmatt Sep 1, 2026
de59392
fix(workers): stop echoing an empty --project-ref into retry suggestions
johnstonmatt Sep 1, 2026
d99e6b5
fix(workers): keep push's per-worker progress out of structured formats
johnstonmatt Sep 1, 2026
71af01d
docs(workers): mark the status and delete trailers as text-only
johnstonmatt Sep 1, 2026
11395a3
refactor(workers): rename workers logs --source to --kind
johnstonmatt Sep 1, 2026
6f8770d
docs(workers): mark the logs no-logs hint as text-only
johnstonmatt Sep 1, 2026
46321b4
fix(workers logs): tie the --kind choices to the stream map
johnstonmatt Sep 1, 2026
396498b
fix(workers logs): give -o priority over --output-format
johnstonmatt Sep 1, 2026
d949afd
fix(workers logs): flush telemetry when the project ref cannot resolve
johnstonmatt Sep 1, 2026
335b62a
fix(workers logs): let a Ctrl+C'd tail run its finalizers
johnstonmatt Sep 1, 2026
2597a39
fix(workers logs): stop --tail capping the follow poll
johnstonmatt Sep 1, 2026
f8575ee
fix(workers logs): make --tail 0 --follow mean what it says
johnstonmatt Sep 1, 2026
a00a02c
fix(workers logs): sanitise every rendered field, not just the guest …
johnstonmatt Sep 1, 2026
d06c876
refactor(workers logs): prefix the exported log-level type
johnstonmatt Sep 1, 2026
7009bd6
docs(workers logs): document the SIGINT exit code
johnstonmatt Sep 1, 2026
af1f813
fix(workers logs): bound ts_ms to a representable instant
johnstonmatt Sep 1, 2026
fa318ee
fix(workers logs): retry only the poll failures worth another request
johnstonmatt Sep 1, 2026
468d9e2
fix(workers logs): carry the composed line into stream-json
johnstonmatt Sep 1, 2026
008f160
Merge branch 'develop' of https://github.com/supabase/cli into FUNC-8…
johnstonmatt Sep 1, 2026
b3ea7df
Merge branch 'FUNC-840/select-workers-new-name' of https://github.com…
johnstonmatt Sep 1, 2026
c8977d0
fix(workers logs): green the checks the logs command turned red
johnstonmatt Sep 1, 2026
993fa7e
Merge remote-tracking branch 'origin/FUNC-851/general-output-polish' …
johnstonmatt Sep 1, 2026
b772491
test(config): stop a broken pipe preempting the exit-code diagnosis
johnstonmatt Sep 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { describe, expect, it } from "vitest";
import { Primitive, type Command } from "effect/unstable/cli";
import {
legacyCommandInternals,
legacyFlattenSubcommands,
legacyUserGlobalFlagParams,
} from "../docs/legacy-docs-introspection.ts";
import { legacyUnwrapParam } from "../shared/legacy-param-introspection.ts";
import { legacyRoot } from "./root.ts";

/**
* `Flag.boolean(name)` builds a bare `Single` param, and a bare `Single` is
* *required* — omitting it fails the whole command with a missing-flag error
* before the handler ever runs. Every boolean flag therefore has to be closed
* off with `Flag.withDefault(false)` or `Flag.optional`.
*
* Nothing else catches this: handler integration tests build their flags record
* directly, so they never touch the parser, and the required-ness is invisible
* to the type checker because a required boolean flag still infers as
* `boolean`. The flag only misbehaves when a real invocation omits it, which is
* precisely the invocation no handler test makes — so the guard walks the
* command tree instead of waiting for a command to be exercised end to end.
*/

/**
* The published getter for a primitive's kind — `Primitive.getTypeName`, whose
* own doc example pins `Primitive.boolean` to `"boolean"`. Reading
* `primitiveType._tag` instead would couple this guard to effect's runtime
* representation, which this repo forbids in tests as well as in source.
*
* Derived from `Primitive.boolean` rather than written as the literal
* `"boolean"`: were that name to change upstream, a hardcoded literal would
* match nothing and leave the guard silently passing every command, which is
* the one failure mode a regression test must not have.
*/
const BOOLEAN_TYPE_NAME = Primitive.getTypeName(Primitive.boolean);

function booleanFlagsRequiringAValue(command: Command.Command.Any): ReadonlyArray<string> {
const internals = legacyCommandInternals(command);
// All three parameter sets a command can be parsed with, not just its own:
// `Command.withSharedFlags` puts inherited flags on `contextConfig`, and the
// root's persistent flags arrive as `globalFlags`. A bare boolean introduced
// through either would break every command that inherits it while a guard
// reading only `config.flags` stayed green.
const params = [
...internals.config.flags,
...internals.contextConfig.flags,
...legacyUserGlobalFlagParams(command),
];

// Throws rather than skipping if effect's internal shape moves, so this
// cannot quietly degrade into a test that inspects nothing.
const own = params.flatMap((flag) => {
const unwrapped = legacyUnwrapParam(flag);
if (unwrapped === undefined) {
throw new Error(`Unrecognizable flag param on "${command.name}".`);
}
const { single, isOptional } = unwrapped;
return Primitive.getTypeName(single.primitiveType) === BOOLEAN_TYPE_NAME && !isOptional
? [`${command.name} --${single.name}`]
: [];
});

return [...own, ...legacyFlattenSubcommands(command).flatMap(booleanFlagsRequiringAValue)];
}

describe("legacy boolean flag wiring", () => {
it("gives every boolean flag a default, so omitting it is not a parse error", () => {
expect(booleanFlagsRequiringAValue(legacyRoot)).toEqual([]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,17 @@ wrapper emits for every command.

## Output Formats

| Mode | stdout | stderr |
| ----------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------- |
| text (default) | the confirmation prompt, then what was deleted and kept | that nothing local was kept, when nothing was |
| `--output-format json` | one structured result carrying `worker_name`, `project_ref`, `kept_*` | as above |
| `--output-format stream-json` | the same result as a single terminal event | as above |
| `-o json` / `yaml` / `toml` | the same payload in that encoding, and nothing else | as above |
| `-o pretty` / `table` / `csv` | the text rendering — these fall through rather than encoding | as above |
| `-o env` | refused **before** the DELETE; discovering it at emit time deleted the worker and then failed | the error |
| Mode | stdout | stderr |
| ----------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| text (default) | the confirmation prompt, then what was deleted and kept | that nothing local was kept when nothing was, and the redeploy hint |
| `--output-format json` | one structured result carrying `worker_name`, `project_ref`, `kept_*` | neither — both are text-only |
| `--output-format stream-json` | the same result as a single terminal event | neither — both are text-only |
| `-o json` / `yaml` / `toml` | the same payload in that encoding, and nothing else | neither — both are text-only |
| `-o pretty` / `table` / `csv` | the text rendering — these fall through rather than encoding | both, as in text |
| `-o env` | refused **before** the DELETE; discovering it at emit time deleted the worker and then failed | the error |

A structured emission is the end of the run: the handler returns at
`legacyEmitWorkersMachineOutput` or at `output.success`, so nothing in the text
branch below it — the kept-nothing notice and the redeploy trailer — is reached.
`-o pretty`, `table` and `csv` are the exception, since they encode nothing and
fall through to that same text branch.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Effect, Option } from "effect";
import { Output } from "../../../../../shared/output/output.service.ts";
import { emitSuccessTrailer } from "../../../../../shared/cli/success-trailer.ts";
import { legacyAqua } from "../../../../shared/legacy-colors.ts";
import { legacyRenderWorkerDetails } from "../workers.format.ts";
import {
Expand Down Expand Up @@ -232,8 +233,9 @@ export const legacyWorkersDelete = Effect.fn("legacy.experimental.workers.delete
// alone is not enough to redeploy from, so `push` would fail on the very
// command this line recommends.
if (keptSource !== undefined) {
yield* output.raw(
`Redeploy it with supabase experimental workers push ${name}${refSuffix}.\n`,
// Trailer, like every other "what to run next" line in this shell.
yield* emitSuccessTrailer(
`Redeploy it with ${legacyAqua(`supabase experimental workers push ${name}${refSuffix}`)}.\n`,
);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ describe("legacy workers delete", () => {
// Nothing local is touched — that is what makes `push` a one-command undo.
expect(existsSync(join(repo.dir, "supabase", "workers", "api", "index.js"))).toBe(true);
expect(readFileSync(join(repo.dir, "supabase", "config.toml"), "utf8")).toBe(CONFIG);
expect(out.stdoutText).toContain("supabase experimental workers push api");
// The redeploy hint is a success trailer, which lands on stderr.
expect(out.stderrText).toContain("supabase experimental workers push api");
}).pipe(Effect.provide(layer), Effect.ensuring(Effect.sync(repo.cleanup)));
});

// The refusal used to live at emit time, which on this command is *after* the
// DELETE: `--yes -o env` removed the worker and then exited non-zero with no
// payload, which a script reads as "the delete failed" and may retry.
// The refusal has to precede the DELETE. At emit time `--yes -o env` would
// remove the worker and then exit non-zero with no payload, which a script
// reads as "the delete failed" and may retry.
// Deletion never touches local files, so a malformed local config has no
// business standing between the user and a worker they named explicitly.
it.live("deletes a remote worker despite an unparseable local config", () => {
Expand Down Expand Up @@ -327,8 +328,8 @@ describe("legacy workers delete", () => {
}).pipe(Effect.provide(layer), Effect.ensuring(Effect.sync(repo.cleanup)));
});

// `interactive` follows stdout, so a plain `>` redirect reaches this branch
// even from a live terminal — the case that used to delete without asking.
// `interactive` follows stdout, so a plain `>` redirect reaches this branch even
// from a live terminal — the case where deleting without asking would be worst.
it.live("refuses when stdout is redirected and no --yes was given", () => {
const repo = project();
const { layer, http } = setupLegacyWorkers({
Expand Down Expand Up @@ -541,6 +542,63 @@ describe("legacy workers delete", () => {
}).pipe(Effect.provide(layer), Effect.ensuring(Effect.sync(repo.cleanup)));
});

it.live("pluralizes the live instance count in the confirmation", () => {
const repo = project();
const { layer, out } = setupLegacyWorkers({
workdir: repo.dir,
promptTextResponses: ["api"],
routes: {
...routes,
[getRoute]: {
status: 200,
body: {
data: workerResource({
name: "api",
instances: 3,
instanceCounts: { declared: 3, live: 2, ready: 2, stale: 0 },
}),
},
},
},
});

return Effect.gen(function* () {
yield* legacyWorkersDelete({ name: "api", projectRef: Option.none() });

expect(out.stdoutText).toContain("2 running instances will be terminated");
}).pipe(Effect.provide(layer), Effect.ensuring(Effect.sync(repo.cleanup)));
});

// Scaled to zero: there is a tally, and it says nothing is running. Warning
// about terminated instances there would invent a consequence.
it.live("promises no terminations when nothing is running", () => {
const repo = project();
const { layer, out } = setupLegacyWorkers({
workdir: repo.dir,
promptTextResponses: ["api"],
routes: {
...routes,
[getRoute]: {
status: 200,
body: {
data: workerResource({
name: "api",
instances: 2,
instanceCounts: { declared: 2, live: 0, ready: 0, stale: 0 },
}),
},
},
},
});

return Effect.gen(function* () {
yield* legacyWorkersDelete({ name: "api", projectRef: Option.none() });

expect(out.stdoutText).toContain("permanently deletes");
expect(out.stdoutText).not.toContain("will be terminated");
}).pipe(Effect.provide(layer), Effect.ensuring(Effect.sync(repo.cleanup)));
});

// An orphan — deployed from another checkout — has no local entry and no local
// directory, so there is nothing that was "kept" and `push` has no source to
// redeploy from.
Expand Down Expand Up @@ -604,7 +662,7 @@ describe("legacy workers delete", () => {
}).pipe(Effect.provide(layer), Effect.ensuring(Effect.sync(repo.cleanup)));
});

// Deletion never reads the local source, so a `source` that no longer resolves
// Deletion never reads the local source, so a `source` that does not resolve
// inside the project must not block removing the remote worker.
it.live("deletes the remote worker even when the configured source is unusable", () => {
const repo = project('project_id = "demo"\n\n[workers.api]\nsource = "../../elsewhere"\n');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ wrapper emits for every command.
| `-o json` / `yaml` / `toml` | the same payload in that encoding, and nothing else | as above |
| `-o pretty` / `table` / `csv` | the text rendering — these fall through rather than encoding | as above |
| `-o env` | refused before any request; the payload carries a `workers` array a flat `KEY=value` list cannot express | the error |

The text table omits each worker's URL — it is the same host and prefix on
every row, and carrying it made the table 137 columns wide. Every machine
format still carries `url` per worker, and `workers status` renders it.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Effect } from "effect";
import { Output } from "../../../../../shared/output/output.service.ts";
import { legacyAqua, legacyYellow } from "../../../../shared/legacy-colors.ts";
import { displayPath } from "../../../../../shared/workers/worker-paths.ts";
import { renderGlamourTable } from "../../../../output/legacy-glamour-table.ts";
import { legacyEmitWorkersMachineOutput, legacyRejectWorkersEnvOutput } from "../workers.output.ts";
import { LegacyPlatformApi } from "../../../../auth/legacy-platform-api.service.ts";
Expand Down Expand Up @@ -28,7 +30,15 @@ import type { LegacyWorkersListFlags } from "./list.command.ts";
* count from the spec. `status` is where the live tally lives.
*/

const HEADERS = ["NAME", "RUNTIME", "SIZE", "STATE", "INSTANCES", "URL"] as const;
/**
* No URL column. Every worker's URL is the same 40-odd characters of host and
* prefix with the name on the end, which pushed the table past 130 columns to
* carry one derivable field — `renderGlamourTable` sizes each column to its
* widest cell and never wraps. `workers status` renders it, vertically, for the
* same reason (see `workers.format.ts`), and every machine format still carries
* `url` per worker.
*/
const HEADERS = ["NAME", "RUNTIME", "SIZE", "STATE", "INSTANCES"] as const;

interface WorkerRow {
readonly name: string;
Expand Down Expand Up @@ -68,14 +78,21 @@ function runtimeLabel(row: WorkerRow): string {
return runtimeLabelFor(row) ?? "-";
}

/**
* `api is` / `api, box are` — the subject of both advisories below, which only
* ever differ in the verb.
*/
function nameList(names: ReadonlyArray<string>): string {
return `${names.join(", ")} ${names.length === 1 ? "is" : "are"}`;
}

function toCells(row: WorkerRow): ReadonlyArray<string> {
return [
row.name,
runtimeLabel(row),
row.deployed === undefined ? "-" : formatApiSize(row.deployed.spec.size),
stateLabel(row),
row.deployed === undefined ? "-" : String(row.deployed.spec.instances),
row.url ?? "-",
];
}

Expand Down Expand Up @@ -165,7 +182,7 @@ export const legacyWorkersList = Effect.fn("legacy.experimental.workers.list")(f

if (rows.length === 0) {
yield* output.raw(
"No workers found. Scaffold one with supabase experimental workers new <name>.\n",
`No workers found. Scaffold one with ${legacyAqua("supabase experimental workers new <name>", process.stdout)}.\n`,
);
return;
}
Expand All @@ -178,14 +195,20 @@ export const legacyWorkersList = Effect.fn("legacy.experimental.workers.list")(f
// the source directory *before* inferring a runtime and fails with
// `WorkerSourceMissingError`, so telling that user about runtime guessing
// points them at the wrong prerequisite.
//
// Both are written the way this shell writes every other heads-up that is
// not a failure: a yellow `WARNING:` prefix, then the consequence on its own
// line (`start`'s Docker-on-Windows notice is the same two-line shape). A
// single long sentence re-flows differently at every terminal width, right
// under a table that lines its columns up.
const unconfigured = rows
.filter((row) => row.deployed !== undefined && !row.configured && row.local)
.map((row) => row.name);
if (unconfigured.length > 0) {
const configDisplay = displayPath(project.projectRoot, project.configPath);
yield* output.raw(
`${unconfigured.join(", ")} ${
unconfigured.length === 1 ? "is" : "are"
} deployed but absent from supabase/config.toml: pushing from here would have to guess the runtime.\n`,
`${legacyYellow("WARNING:")} ${nameList(unconfigured)} deployed but not in ${configDisplay}.\n` +
`Pushing from here would have to guess the runtime.\n`,
"stderr",
);
}
Expand All @@ -195,9 +218,8 @@ export const legacyWorkersList = Effect.fn("legacy.experimental.workers.list")(f
.map((row) => row.name);
if (remoteOnly.length > 0) {
yield* output.raw(
`${remoteOnly.join(", ")} ${
remoteOnly.length === 1 ? "is" : "are"
} deployed but ${remoteOnly.length === 1 ? "has" : "have"} no source in this project: scaffold or restore it before pushing from here.\n`,
`${legacyYellow("WARNING:")} ${nameList(remoteOnly)} deployed with no source in this project.\n` +
`Scaffold or restore before pushing from here.\n`,
"stderr",
);
}
Expand Down
Loading
Loading