Skip to content

Commit e4a71d4

Browse files
Elon Muskclaude
andauthored
cli: environments/*.ts command sources no longer spell os projects in --help (#11227)
* fix(cli): environments/*.ts command sources no longer spell os projects in live --help output Fixes #10967 static override examples arrays, JSDoc headers, and exported class names in packages/cli/src/commands/environments/{bind,create,list,show,switch}.ts still spelled the pre-v5.0-rename `os projects <cmd>` — oclif prints examples verbatim as part of --help, so a user copy-pasting straight from `os environments bind --help` hit `Error: Command projects:bind not found.` - examples arrays and JSDoc headers: os projects -> os environments (all five files, 21 occurrences). - exported class names renamed to match their file-path-derived command id (ProjectsBind -> EnvironmentsBind, etc.) -- oclif's pattern-strategy loader derives a command's id purely from its file path, confirmed by reading processCommandIds() in @oclif/core and by building the CLI and running --help/a real invocation on all five commands after the rename. - environments.test.ts's imports and describe title updated to match, and gains a pin: every examples entry on these five commands is checked against the CLI's actual file-tree-derived command-id set (not a grep for the literal string "os projects"), so a future topic rename that misses an examples string fails a test instead of shipping. Anti-vacuity and reverse-verification (both the pre-fix line as a specimen, and a live edit-run-restore cycle) are documented in the test file's own comment. * fix(cli): widen #10967's examples-resolve pin to every command file PM review on #11227: the pin's population was a hardcoded 5-file map -- exactly the set already correct -- so it could not catch this defect class returning anywhere else, including in the register.ts/whoami.ts/logout.ts files #11221 already tracks live. Widen it to every command source under packages/cli/src/commands/**, walked the same way registeredCommandIds() already walks the tree for the id universe. examples are now read via TypeScript AST (extractExamples), not by importing every command module, to avoid making this file's cost and failure surface track the whole package's transitive import graph. extractExamples/stripInvocationPrefix now handle every invocation shape actually present in the package: plain '$ os ...', the oclif help-template form '<%= config.bin %> ...', either prefixed by one or more ENV=value assignments (including a double-quoted value containing spaces), and the { command, description } object form start.ts uses twice. The three #11221-owned files are carved out via an EXCLUDED map (file -> reason), matching the pattern in packages/create-objectstack/src/starter-comments-self-contained.test.ts's EXCLUDED: a filtered main assertion, plus a second it.each that re-runs the same predicate over the excluded files and asserts it still finds an unresolved entry -- so when #11221 lands, that assertion goes red and says to delete the entry, instead of the exclusion silently living forever. Verified: the widened pin passes (71 tests, up from 14). Reverse-verified the exclusion is load-bearing, not decorative -- temporarily cleared EXCLUDED and confirmed all three files fail by name for the expected reason (their real, currently-unresolved os auth ... examples), then restored. Re-verified the original bind.ts reverse-verification still works under the new population (a reintroduced stale example fails only that one file, all others still pass). Re-ran the full local gate battery (18 gates) clean. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2810695 commit e4a71d4

7 files changed

Lines changed: 376 additions & 47 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
"@objectstack/cli": patch
3+
---
4+
5+
fix(cli): `environments/*.ts` command sources no longer spell `os projects` in live `--help` output (#10967)
6+
7+
`static override examples` is printed verbatim as part of oclif's `--help`, and all five
8+
commands under `packages/cli/src/commands/environments/` (`bind`, `create`, `list`, `show`,
9+
`switch`) still spelled the pre-v5.0-rename `os projects <cmd>` there — a user copy-pasting
10+
straight from `os environments bind --help` hit `Error: Command projects:bind not found.`
11+
(exit 2), the same dead command #10927 fixed in `packages/cli/README.md`, this time sourced
12+
from the CLI binary itself.
13+
14+
`examples` arrays and JSDoc headers now say `os environments <cmd>`. The exported default
15+
class on each file is renamed to match its real, file-path-derived command id
16+
(`ProjectsBind``EnvironmentsBind`, etc.) — oclif's pattern-strategy loader derives a
17+
command's id purely from its file path, never from the class name, so this rename changes
18+
no runtime resolution; verified by building the CLI and running `--help` on all five
19+
commands, plus one real invocation, after the rename. `environments.test.ts`'s imports and
20+
`describe` title are updated to match, and gain a pin: every `examples` entry on these five
21+
commands is checked against the CLI's actual file-tree-derived command-id set, so a future
22+
topic rename that misses an `examples` string fails a test instead of shipping.

packages/cli/src/commands/environments/bind.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { createApiClient, requireAuth } from '../../utils/api-client.js';
99
import { formatOutput } from '../../utils/output-formatter.js';
1010

1111
/**
12-
* `os projects bind` — bind a locally-compiled artifact to an existing
12+
* `os environments bind` — bind a locally-compiled artifact to an existing
1313
* multi-environment server project.
1414
*
1515
* Equivalent to `PATCH /api/v1/cloud/environments/<id>` with
@@ -20,13 +20,13 @@ import { formatOutput } from '../../utils/output-formatter.js';
2020
* Use `--build` to compile `objectstack.config.ts` first so the artifact
2121
* reflects the latest source.
2222
*/
23-
export default class ProjectsBind extends Command {
23+
export default class EnvironmentsBind extends Command {
2424
static override description = 'Bind a local objectstack artifact to an existing project';
2525

2626
static override examples = [
27-
'$ os projects bind <project-id> --artifact ./dist/objectstack.json',
28-
'$ os projects bind <project-id> --artifact ./dist/objectstack.json --build',
29-
'$ os projects bind <project-id> --reseed',
27+
'$ os environments bind <project-id> --artifact ./dist/objectstack.json',
28+
'$ os environments bind <project-id> --artifact ./dist/objectstack.json --build',
29+
'$ os environments bind <project-id> --reseed',
3030
];
3131

3232
static override args = {
@@ -59,7 +59,7 @@ export default class ProjectsBind extends Command {
5959
};
6060

6161
async run(): Promise<void> {
62-
const { args, flags } = await this.parse(ProjectsBind);
62+
const { args, flags } = await this.parse(EnvironmentsBind);
6363

6464
try {
6565
const artifactRel = flags.artifact ?? './dist/objectstack.json';

packages/cli/src/commands/environments/create.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ import { formatOutput } from '../../utils/output-formatter.js';
77
import { readAuthConfig, writeAuthConfig } from '../../utils/auth-config.js';
88

99
/**
10-
* `os projects create` — provision a new project.
10+
* `os environments create` — provision a new project.
1111
*
1212
* Delegates to `ProjectProvisioningService.provisionProject` on the server.
1313
* On success, optionally activates the new project for the current session
1414
* and persists `activeEnvironmentId` into `~/.objectstack/credentials.json`
1515
* (unless `--no-activate` is passed).
1616
*/
17-
export default class ProjectsCreate extends Command {
17+
export default class EnvironmentsCreate extends Command {
1818
static override description = 'Provision a new project';
1919

2020
static override examples = [
21-
'$ os projects create --org 00000000-0000-0000-0000-000000000000 --name Staging',
22-
'$ os projects create --org $ORG --name Dev --plan free',
23-
'$ os projects create --org $ORG --name "Clone" --clone-from <source-id> --no-activate',
24-
'$ os projects create --org $ORG --name CRM --artifact ./examples/app-crm/dist/objectstack.json',
21+
'$ os environments create --org 00000000-0000-0000-0000-000000000000 --name Staging',
22+
'$ os environments create --org $ORG --name Dev --plan free',
23+
'$ os environments create --org $ORG --name "Clone" --clone-from <source-id> --no-activate',
24+
'$ os environments create --org $ORG --name CRM --artifact ./examples/app-crm/dist/objectstack.json',
2525
];
2626

2727
static override flags = {
@@ -56,7 +56,7 @@ export default class ProjectsCreate extends Command {
5656
};
5757

5858
async run(): Promise<void> {
59-
const { flags } = await this.parse(ProjectsCreate);
59+
const { flags } = await this.parse(EnvironmentsCreate);
6060

6161
try {
6262
const { client, token } = await createApiClient({ url: flags.url, token: flags.token });

0 commit comments

Comments
 (0)