Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 12 additions & 12 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ fileignoreconfig:
ignore_detectors:
- filename
- filename: src/environments/environment.presenter.ts
checksum: 505f5e76e34ab9081cb0d57d6c017799bf0c7d86a08bb77201c6737a1affbaef
checksum: a0bede780ca4e4e95ebef6f4aac9aa9badb88e12beb794062e6be55fe3c6cb24
ignore_detectors:
- filename
- filename: src/environments/environment.presenter.test.ts
checksum: 9120a7bc0ce7e7307be8bc76e5e7133f13c0ed186bcb932de9e9fba364a30c99
checksum: 6d05bb10a3aca5d55b9526f395efa7f7b5b0c647533c36558bbdc6481c23fae3
ignore_detectors:
- filename
- filename: src/environments/environment.resolver.ts
Expand Down Expand Up @@ -236,7 +236,7 @@ fileignoreconfig:
- "a project name passed on argv to the project resolver"
- "expect\\(Object.keys\\(DEPENDENCIES\\)\\).toEqual\\(\\['project', 'env'\\]\\)"
- filename: AGENTS.md
checksum: a22a2af80687d90bacdcb57392c85afce3f97eb09ac8347c32e6da80809bcb75
checksum: 46584ecc6343552c40b96b2b5c76a60c1b87ef454fa82f9c901086bcd408b090
allowed_patterns:
- "Do not add an exemption to a guard to make a new file pass"
- "passes its own error wording to `client.request\\(req, MESSAGES\\)`"
Expand All @@ -247,9 +247,9 @@ fileignoreconfig:
- "a test passes `var`, `env-file` and `from-stack`"
- "an in-flight secret registry to redact against"
- filename: src/core/project-config.ts
checksum: 1f19da706128ee78e1fe20d8624626038893d908a7061b3f2633e741a77c93b6
checksum: 9f0c3b2633d311d9f51ea57d3ec6a081b0102c9ebdb3cf37f08f46d00267e069
- filename: src/core/project-config.test.ts
checksum: 65c0a613ec77d4dc6727224d4d097de4a02b300339286db692dbaea9379565ae
checksum: 55746e82d59077579975cf306633a03e6c2471b89fe29ab549c2050113a82c60
- filename: src/core/resolve.ts
checksum: a5608d22286efdd4915639faff6e05a588e60e205c74e0398e389822eb8c7292
- filename: src/core/resolve.test.ts
Expand All @@ -265,13 +265,13 @@ fileignoreconfig:
- filename: test/integration/projects-delete.test.ts
checksum: 19784ba572daac76e6ef0b004c19cdb9c3f9cb22f738b3ab0e22c694e049026c
- filename: src/core/launch-command.ts
checksum: 91ec87522df77d8ed593c95e1a2259d1555acbd1dee95ad8ca4d6c3fa9c61468
checksum: 2d08f5559ad8700462e7dd0b2768305a47f5b0b87f43b961bdbf1767a0e2540b
- filename: src/core/launch-command.test.ts
checksum: 44f0639fe66598ba2f3ba0ddc7edd68381f7aa36e3be5323ecbe5d101a1953a2
checksum: d0ba482a3e05a3e73ed4d3f8087af6de52e692d0105d064982ba11dd8072df1b
- filename: src/projects/project.inputs.test.ts
checksum: 8242f4d40388f1a7f1d08c11d2571cb45a9294069a8248a5272bc5606807bb60
- filename: test/integration/projects-command-flows.test.ts
checksum: 1731d2350269ae9b6f7c2837db8e14575f94a9a3fa11f8f86c532717378d99ce
checksum: ede00ae963c4d64ec41dce31cb59d7d58c22ebff18ae670be55192e43fa94290
- filename: src/core/redact.test.ts
checksum: ae497ea8c3a4c3f12217d2c4c028a1da3d1324e18362d68c355ba8120902bcb3
- filename: src/commands/launch/projects/list.test.ts
Expand All @@ -281,7 +281,7 @@ fileignoreconfig:
- filename: src/commands/launch/projects/get.test.ts
checksum: 3aeffc4e4742ea9c5b3d9e6c5ea2248ced1d19a273bbc7d7948d471774b0d739
- filename: test/integration/projects-list-command.test.ts
checksum: 5f49dc7f384fb9e33c8fb91f1c67b17ffc2fd3bbde3663f90f820056407e98a0
checksum: 6e294022573c525a0788f99bbea5cd6cfda3140079190e6fb078bd2c52ea1c6b
- filename: src/functions/cloud-functions.test.ts
checksum: a9d4515bdc953808a1dda094b62dd19af4eed432a553d9f14773b85f1c5346cc
- filename: src/functions/function.errors.ts
Expand Down Expand Up @@ -309,7 +309,7 @@ fileignoreconfig:
- filename: src/core/search-list.test.ts
checksum: 4e5db3cd6a213db71c51bf5ac8d6a5547ea9ca137d425c00026453e5c3b543b7
- filename: src/core/catalog.test.ts
checksum: 950d5cbb8ebdbe13cf13908b72d5409f7fdf7515c9d93a7c84045efcf4420543
checksum: 5f79096b43a3b3c6b03f6c86e8f2fbd5c77424e9889a74fd9de12852814620bd
- filename: test/credential-guard.setup.ts
checksum: 519ccbeb0552fdb1d5f27308c56477c0258ee6cc0adec8f618e8e5bc047cbf6d
- filename: src/environments/types.ts
Expand Down Expand Up @@ -355,7 +355,7 @@ fileignoreconfig:
- filename: src/stacks/stacks.api.ts
checksum: d59622ca6411b93d5469a1895b08ccde4b9cd83fbb909c82076ea70d74b5e1e4
- filename: src/variables/variable.chooser.ts
checksum: 767bbcee93b0c10c5c9d0b526ce57770cc6323be52d8a4cc1c0452c880b5ab8e
checksum: 7b286b31c49e7501fed220cc6d8c082a451bf8c81b0202242545cff7031e22bb
- filename: src/variables/variable.create.test.ts
checksum: a2650ca8e081afcf76c801d20e2df4baa96f814d1513080ba24971db0ae3a1bf
- filename: src/variables/variable.dotenv.test.ts
Expand Down Expand Up @@ -475,7 +475,7 @@ fileignoreconfig:
- filename: src/secrets/secrets.api.ts
checksum: be8e726215a79dbf99f26449d268dacd1b8baad823f74b7c4b0748f6d828402c
- filename: src/commands/launch/secrets/list.ts
checksum: 4de3fb4afae29e7e98b3629f61d769597810e7682e336edd28c589515d81e47a
checksum: fea24dc39cd63d2f3b0721c386958388e80df4f885de906c3d3b976c9f77fe10
- filename: src/secrets/secrets.errors.ts
checksum: 4a3a6cc9af567658149bdcba8dc5dd0de2a6cb2294bd6f1018b253e709ff1436
- filename: src/secrets/secrets.api.test.ts
Expand Down
5 changes: 4 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ file and line that broke its rule, and each was proven red by reintroducing its
| `test/guards/tty-streams.test.ts` | `stdin.isTTY`, and the `isTTY` it becomes on the service context, are read only to decide whether the CLI may prompt (a read next to a prompt or a refusal to prompt) or on the plumbing lines that carry it there. Anything deciding what to draw reads `outputIsTTY` / `process.stdout.isTTY`. | D6: heartbeat drawn into a redirected file |
| `test/integration/deployments-request-bodies.test.ts` | A deployments mutation puts on the wire only the fields the management service DTO declares - `{commitHash?, uploadUid?}` for a create, `{deployment, reason?}` for a rollback - and never `environment`, which is the URL path. The service validates with `whitelist` and `forbidNonWhitelisted`, so any other key is a bare 400. | Live harness: `deployments:create` and `:rollback` sent `{environment, ...}` and failed with `Bad request` |
| `test/integration/retired-commands.test.ts` (named commands) | Every `launch:…` command named anywhere in `src` - a retirement message, a failure hint, an example - is either a registered command or on `PLANNED_COMMANDS` with the ticket that builds it, and a command drops off that list once it ships. | Review: retirement messages and hints pointed at commands the beta does not have |
| `test/guards/whole-number-flags.test.ts` | No source declares `Flags.integer`. A number flag is built with `wholeNumberFlag` in `src/core/catalog.ts`, whose parse throws a `FlagValueError` naming the flag and its range, so a bad value prints one sentence and exits 2 instead of oclif's `Parsing --limit` / `Expected an integer…` text. | Section 10.6: `--limit abc`, `--limit 0` and `--skip -1` printed raw oclif text |
| `test/guards/narrow-terminal.test.ts` | The real list and detail tables (`env:list`, `env:get`, `deployments:list`, `deployments:get`, `projects:list`, `projects:get`), drawn at 30 to 100 columns, print no line wider than the terminal, no ellipsis, and every UID whole on one line; a detail table also prints every field label whole and never as a `FIELD`/`VALUE` record. `renderTable` shrinks the widest column first, never below `minWidth` (`UID_WIDTH` for UID and detail-value columns) or ten characters, never shrinks a `label` column, and wraps cell text instead of cutting it. When the columns cannot fit, a detail table prints `<field> <value>` lines and any other table prints each record as a stacked `LABEL value` list; a value that would not fit beside its label goes on its own line indented two spaces. A UID is never wrapped, so 26 columns (two spaces and a UID) is the narrowest terminal the guarantee holds for. | Section 10.9: only the first column shrank, so `env:list` stayed 135 wide and `deployments:list` cut the deployment UID; PR #302 review: detail labels broke mid-word near 45 columns |
| `test/guards/prompt-funnel.test.ts` | Every prompt goes through `LaunchCommand`'s `ux`, built once as `cancelOnInterrupt(terminalUx)`, so Ctrl-C at any prompt exits 3. `terminalUx` (`src/core/terminal-ux.ts`) asks cli-utilities' own inquirer instance (`promptLibrary()`) directly, because `cliux.inquire` catches inquirer 12's `ExitPromptError` and calls `process.exit(130)` itself. In raw mode Ctrl-C reaches inquirer as typed input, not as a process `SIGINT`: an `@inquirer/core` prompt (input, list, checkbox, confirm) rejects with `ExitPromptError`, which the wrapper turns into `CancelledError`; the legacy `search-list` rejects with `AbortPromptError` and then raises a real `SIGINT`, so the wrapper cancels on the rejection at once and stays attached only to absorb that signal. The wrapper stays attached to `SIGINT` until the signal has reached every listener (it detaches in a microtask): inquirer's `cli-cursor` loads `signal-exit`, which re-raises `SIGINT` - exit 130 - when it finds itself the only listener, so a `once` listener made every list and checkbox prompt exit 130 (`src/core/interruptible-ux.test.ts` pins it). No source calls `cliux.inquire` / `prompt` / `confirm` under any name, hands `cliux` on as a value, imports a prompt library, uses `promptLibrary` outside `search-list.ts` and `terminal-ux.ts`, or uses `terminalUx` anywhere but that one funnel line; `search-list.ts` may register a type but never prompt. `test/integration/prompt-ctrl-c-on-a-terminal.test.ts` types a real Ctrl-C at each kind of prompt on a pseudo-terminal, because a simulated `SIGINT` is what let CL-8790 through. `test/support/pty/press-ctrl-c.py <marker> <command...>` (Python's stdlib `pty`, so `npm test` needs `python3`) runs the command on a pty, types Ctrl-C once `<marker>` is on screen and prints the exit code: negative for a signal death (-2 is SIGINT), 124 if `<marker>` never appeared, 125 if the command was still running 30 s later (it is killed). `ctrl-c-prompt.fixture.ts` calls `process.exit` with the error's exit code, as oclif's `Errors.handle` does for the CLI. | D2: Ctrl-C exited 130; CL-8790: it did again after cli-utilities 2 |

A new prompt, request, render path or command is covered by these guards without being listed in
Expand Down Expand Up @@ -638,7 +640,8 @@ it (`projectConfigLoader`), so a V1 file whose branch blocks disagree does not b
flags already supply everything; a file named with `--config` is still read at once.

**The config-file notice.** When any input came from the file, `LaunchCommand.init` prints one line
through `this.ux.print` (stdout, like every other line the CLI prints), worded by
to **stderr** (`writeToStderr`), so a captured stdout such as `url=$(csdx launch:site:open …)` holds
only the command's own output, worded by
`configSourceNotice` in `src/core/project-config.ts` from the `configLabel` of each such input and the
**full path** of the file actually read (a relative `--config` is resolved first): `Using the
organization and project UIDs from /Users/me/site/.cs-launch.json.` (one input: `Using the project UID
Expand Down
7 changes: 1 addition & 6 deletions src/commands/launch/deployments/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { UsageError } from '../../../core/errors';
import { LaunchCommand } from '../../../core/launch-command';
import { flagsFor, inputs } from '../../../core/inputs';
import { renderTable } from '../../../core/render';
import {
DEPLOYMENT_DETAIL_COLUMNS,
DEPLOYMENT_VALUE_COLUMN,
deploymentDetailRows,
} from '../../../deployments/deployment.presenter';
import { DEPLOYMENT_DETAIL_COLUMNS, deploymentDetailRows } from '../../../deployments/deployment.presenter';
import { fetchDeployment } from '../../../deployments/deployment.resolver';

const getInputs = inputs({
Expand Down Expand Up @@ -48,7 +44,6 @@ export default class DeploymentsGet extends LaunchCommand<typeof getInputs> {
DEPLOYMENT_DETAIL_COLUMNS,
deploymentDetailRows(deployment, project.projectType !== 'FILEUPLOAD', scope),
process.stdout.columns,
DEPLOYMENT_VALUE_COLUMN,
this.services.outputIsTTY,
);
}
Expand Down
1 change: 0 additions & 1 deletion src/commands/launch/deployments/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default class DeploymentsList extends LaunchCommand<typeof listInputs> {
deploymentColumns(project.projectType !== 'FILEUPLOAD'),
deployments,
process.stdout.columns,
undefined,
this.services.outputIsTTY,
);
renderPagination(this.ux, { ...page.pagination, skip: this.resolved.skip }, deployments.length);
Expand Down
7 changes: 1 addition & 6 deletions src/commands/launch/env/get.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { LaunchCommand } from '../../../core/launch-command';
import { flagsFor, inputs } from '../../../core/inputs';
import { renderTable } from '../../../core/render';
import {
ENVIRONMENT_DETAIL_COLUMNS,
ENVIRONMENT_VALUE_COLUMN,
environmentDetailRows,
} from '../../../environments/environment.presenter';
import { ENVIRONMENT_DETAIL_COLUMNS, environmentDetailRows } from '../../../environments/environment.presenter';

const getInputs = inputs({ org: { required: true }, project: { required: true }, env: { required: true } });

Expand All @@ -30,7 +26,6 @@ export default class EnvironmentsGet extends LaunchCommand<typeof getInputs> {
ENVIRONMENT_DETAIL_COLUMNS,
environmentDetailRows({ ...environment, project: this.resolved.project }, project.projectType !== 'FILEUPLOAD'),
process.stdout.columns,
ENVIRONMENT_VALUE_COLUMN,
this.services.outputIsTTY,
);
}
Expand Down
1 change: 0 additions & 1 deletion src/commands/launch/env/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default class EnvironmentsList extends LaunchCommand<typeof listInputs> {
environmentColumns(project.projectType !== 'FILEUPLOAD'),
page.environments,
process.stdout.columns,
undefined,
this.services.outputIsTTY,
);
renderPagination(this.ux, { ...page.pagination, skip: this.resolved.skip }, page.environments.length);
Expand Down
11 changes: 2 additions & 9 deletions src/commands/launch/projects/get.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LaunchCommand } from '../../../core/launch-command';
import { flagsFor, inputs } from '../../../core/inputs';
import { renderTable } from '../../../core/render';
import { PROJECT_DESCRIPTION_COLUMN, PROJECT_DETAIL_COLUMNS } from '../../../projects/project.presenter';
import { PROJECT_DETAIL_COLUMNS } from '../../../projects/project.presenter';

const getInputs = inputs({ org: { required: true }, project: { required: true } });

Expand All @@ -20,13 +20,6 @@ export default class ProjectsGet extends LaunchCommand<typeof getInputs> {
project: this.resolved.project,
});

renderTable(
this.ux,
PROJECT_DETAIL_COLUMNS,
[result],
process.stdout.columns,
PROJECT_DESCRIPTION_COLUMN,
this.services.outputIsTTY,
);
renderTable(this.ux, PROJECT_DETAIL_COLUMNS, [result], process.stdout.columns, this.services.outputIsTTY);
}
}
9 changes: 1 addition & 8 deletions src/commands/launch/projects/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ export default class ProjectsList extends LaunchCommand<typeof listInputs> {
skip: this.resolved.skip,
});

renderTable(
this.ux,
PROJECT_COLUMNS,
page.projects,
process.stdout.columns,
undefined,
this.services.outputIsTTY,
);
renderTable(this.ux, PROJECT_COLUMNS, page.projects, process.stdout.columns, this.services.outputIsTTY);
renderPagination(this.ux, { ...page.pagination, skip: this.resolved.skip }, page.projects.length);
}
}
9 changes: 1 addition & 8 deletions src/commands/launch/secrets/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ export default class SecretsList extends LaunchCommand<typeof listInputs> {
return;
}

renderTable(
this.ux,
secretColumns(),
secrets,
process.stdout.columns,
undefined,
this.services.outputIsTTY === true,
);
renderTable(this.ux, secretColumns(), secrets, process.stdout.columns, this.services.outputIsTTY === true);
}
}
1 change: 0 additions & 1 deletion src/commands/launch/variables/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default class VariablesList extends LaunchCommand<typeof listInputs> {
variableColumns(environment.updatedAt),
page.variables,
process.stdout.columns,
undefined,
this.services.outputIsTTY,
);
renderPagination(this.ux, page.pagination, page.variables.length);
Expand Down
51 changes: 38 additions & 13 deletions src/core/catalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Parser } from '@oclif/core';

import { coreFlags } from './catalog';
import { CLIENT_MAX_LIMIT } from './constants';
import { FlagValueError } from './errors';

async function parse(argv: string[]): Promise<Record<string, unknown>> {
const { flags } = await Parser.parse(argv, { flags: coreFlags });
Expand Down Expand Up @@ -33,30 +34,54 @@ describe('coreFlags', () => {
await expect(parse(['-c', './.cs-launch.json'])).rejects.toThrow(/Nonexistent flag: -c/);
});

it('advertises the limit range in the flag itself, not only in the help text', () => {
expect(coreFlags.limit).toMatchObject({ min: 1, max: CLIENT_MAX_LIMIT });
it('advertises the limit range in the help text', () => {
expect(coreFlags.limit.description).toBe(`Number of records to fetch (1-${CLIENT_MAX_LIMIT})`);
});

it('advertises the skip floor in the flag itself', () => {
expect(coreFlags.skip).toMatchObject({ min: 0 });
expect((coreFlags.skip as unknown as { max?: number }).max).toBeUndefined();
});

it.each([['1'], ['2'], [String(CLIENT_MAX_LIMIT)]])('accepts the in-range limit %s', async (limit) => {
it.each([['1'], ['2'], [String(CLIENT_MAX_LIMIT)], [' 7 ']])('accepts the in-range limit %p', async (limit) => {
await expect(parse(['--limit', limit])).resolves.toMatchObject({ limit: Number(limit) });
});

it.each([['0'], ['-1'], [String(CLIENT_MAX_LIMIT + 1)], ['99999']])('rejects the out-of-range limit %s', async (limit) => {
await expect(parse(['--limit', limit])).rejects.toThrow(/Expected an integer/);
});
it.each([['0'], ['-1'], [String(CLIENT_MAX_LIMIT + 1)], ['99999'], ['abc'], ['1.5'], ['1e2'], ['0x10'], [''], [' ']])(
'rejects the limit %p with one sentence naming the flag and its range',
async (limit) => {
const failure = await parse(['--limit', limit]).catch((error: unknown) => error);

expect(failure).toBeInstanceOf(FlagValueError);
expect((failure as FlagValueError).detail).toBe(
`Invalid --limit value "${limit}". Provide a whole number from 1 to ${CLIENT_MAX_LIMIT}.`,
);
},
);

it.each([['0'], ['5'], ['1000000']])('accepts the non-negative skip %s', async (skip) => {
await expect(parse(['--skip', skip])).resolves.toMatchObject({ skip: Number(skip) });
});

it.each([['-1'], ['-5']])('rejects the negative skip %s', async (skip) => {
await expect(parse(['--skip', skip])).rejects.toThrow(/Expected an integer/);
it.each([['-1'], ['-5'], ['abc'], ['2.5']])(
'rejects the skip %p with one sentence naming the flag and its floor',
async (skip) => {
const failure = await parse(['--skip', skip]).catch((error: unknown) => error);

expect(failure).toBeInstanceOf(FlagValueError);
expect((failure as FlagValueError).detail).toBe(
`Invalid --skip value "${skip}". Provide a whole number of 0 or more.`,
);
},
);

it.each([['9'.repeat(400)], ['1' + '0'.repeat(21)], [String(Number.MAX_SAFE_INTEGER + 1)]])(
'rejects a skip too large to send exactly, rather than letting %p reach the API as Infinity or 1e+21',
async (skip) => {
const failure = await parse(['--skip', skip]).catch((error: unknown) => error);

expect(failure).toBeInstanceOf(FlagValueError);
expect((failure as FlagValueError).detail).toBe(`Invalid --skip value "${skip}". Provide a whole number of 0 or more.`);
},
);

it('accepts the largest skip that can be sent exactly', async () => {
await expect(parse(['--skip', String(Number.MAX_SAFE_INTEGER)])).resolves.toMatchObject({ skip: Number.MAX_SAFE_INTEGER });
});

it('leaves limit and skip absent when neither is passed so the resolution defaults still apply', async () => {
Expand Down
Loading
Loading