Skip to content

Commit 132c886

Browse files
committed
Fix dry-run+yes delete gate, add publish tests, scrub upstream docs
- Block DELETE when --dry-run is unsupported even if --yes is set - Run typecheck and unit tests in the release-please publish job - Remove internal api-server, Linear, and monorepo references from docs
1 parent 6a9c41c commit 132c886

5 files changed

Lines changed: 41 additions & 13 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ jobs:
6161
- name: Install dependencies
6262
run: pnpm install --frozen-lockfile
6363

64+
- name: Typecheck
65+
run: pnpm test:typescript
66+
67+
- name: Unit tests
68+
run: pnpm test
69+
6470
- name: Build the package
6571
run: pnpm build
6672

AGENTS.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ This package is the `amp` CLI: the human- and agent-facing surface over the
44
Amplitude Developer API. It is vended publicly as a standalone repo, so it is
55
held to a higher bar than internal code.
66

7-
The OpenAPI spec in the parent `api-server` package is the contract; this CLI is
8-
a thin, generated client over it. Before changing command behavior, auth, or the
9-
generated manifest, read the parent `../AGENTS.md` and
10-
`../docs/golden-standards.md`.
7+
The OpenAPI spec bundled in `openapi/bundled/` is the contract; this CLI is a
8+
thin, generated client over it. Do not hand-edit `src/generated/` or
9+
`openapi/bundled/` — regenerate those artifacts when the API contract changes.
1110

1211
## Tenets
1312

docs/cli.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,10 @@ Manual checklist:
126126
5. **Flags write** — create → get → update description → archive dry-run → archive
127127
6. **Events** — list → create → update → (optional delete with `--yes`)
128128

129-
Known upstream issue: `flags update --enabled false` fails for deployment-less
130-
flags ([MCP-414](https://linear.app/amplitude/issue/MCP-414)). Avoid that path
131-
in smoke tests until fixed.
129+
Known issue: `flags update --enabled false` fails for deployment-less flags.
130+
Avoid that path in smoke tests until fixed.
132131

133-
## Local api-server
132+
## Local API server
134133

135134
Point at a running local server:
136135

@@ -142,7 +141,5 @@ amp --base-url http://localhost:3036 context
142141

143142
Do not edit by hand:
144143

145-
- `src/generated/cli-manifest.ts` — from `api-server/scripts/generate-cli-manifest.ts`
146-
- `openapi/bundled/*` — copied from `api-server/openapi/bundled/`
147-
148-
Regenerate via `pnpm build:openapi` in the parent `api-server` package.
144+
- `src/generated/cli-manifest.ts`
145+
- `openapi/bundled/*`

src/run.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ describe('deleteGateDecision', () => {
8484
}),
8585
).toBe('block');
8686
});
87+
88+
it('does not let --yes override an unsupported --dry-run', () => {
89+
expect(
90+
deleteGateDecision({
91+
...base,
92+
dryRunRequested: true,
93+
dryRunSupported: false,
94+
yes: true,
95+
}),
96+
).toBe('block');
97+
});
8798
});
8899

89100
describe('runOperation', () => {
@@ -285,4 +296,16 @@ describe('runOperation', () => {
285296
).rejects.toThrow('does not support --dry-run');
286297
expect(fetchMock).not.toHaveBeenCalled();
287298
});
299+
300+
it('refuses an unsupported --dry-run even when --yes is set', async () => {
301+
await expect(
302+
runOperation(deleteWithoutDryRun, {
303+
token: 'amp_test',
304+
id: 'w_1',
305+
'dry-run': true,
306+
yes: true,
307+
}),
308+
).rejects.toThrow('does not support --dry-run');
309+
expect(fetchMock).not.toHaveBeenCalled();
310+
});
288311
});

src/run.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export function deleteGateDecision(options: {
3838
if (!options.isDelete) {
3939
return 'proceed';
4040
}
41+
if (options.dryRunRequested && !options.dryRunSupported) {
42+
return options.isTTY ? 'confirm' : 'block';
43+
}
4144
if (options.dryRunRequested && options.dryRunSupported) {
4245
return 'proceed';
4346
}
@@ -70,7 +73,7 @@ async function ensureDeleteAllowed(
7073
if (decision === 'block') {
7174
if (dryRunRequested && !dryRunSupported) {
7275
throw new Error(
73-
`\`amp ${operation.command.join(' ')}\` does not support --dry-run. Pass --yes to confirm, or run it in an interactive terminal.`,
76+
`\`amp ${operation.command.join(' ')}\` does not support --dry-run. Remove --dry-run and pass --yes to confirm, or run it in an interactive terminal.`,
7477
);
7578
}
7679
throw new Error(

0 commit comments

Comments
 (0)