commercebuild-cli 0.0.31 → 0.0.33-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # commercebuild-cli
2
+
3
+ Command-line companion to the commercebuild store admin's app editor: it
4
+ downloads a custom app to your machine, saves it back to the online draft,
5
+ and builds or releases a version — the editor's Save / Deploy / Release
6
+ buttons, as commands.
7
+
8
+ Run it through `npx`; nothing needs installing globally:
9
+
10
+ ```
11
+ npx commercebuild-cli@rc extension open <appId> --store https://<your-store>/
12
+ ```
13
+
14
+ (`npm install -g commercebuild-cli` works too if you prefer a global
15
+ install.)
16
+
17
+ ## Open an app in VS Code or Cursor (`extension open`)
18
+
19
+ The store admin's app editor has an open-in-editor button (VS Code by
20
+ default; the dropdown next to it picks Cursor, and the choice is
21
+ remembered). With the **commercebuild App Studio** extension installed in that
22
+ editor it opens
23
+ `vscode://commercebuild.vscode-store-app/open?app=<appId>&store=<url>`
24
+ (`cursor://…` for Cursor); the extension confirms the working folder, runs
25
+ `extension open` in the background (with `--no-editor --json`) and opens
26
+ the result in the current window. Without the extension the button shows
27
+ the same command to copy (with `--editor cursor` when Cursor was picked).
28
+
29
+ What `open` does:
30
+
31
+ - Downloads a **complete, fresh copy** of the app's current online
32
+ **draft** (falling back to the released upload, then the latest upload)
33
+ into `./<name>` under the current directory. If that folder already has
34
+ content, the copy goes to `./<name>(1)`, `(2)`, … — an earlier download
35
+ is never touched. `--dir` picks another location (same suffix rule),
36
+ `COMMERCEBUILD_APPS_DIR` a fixed root.
37
+ - Writes `.env` (`COMMERCEBUILD_STORE_URL`) and `.npmrc`
38
+ (`node-linker=hoisted`, for pnpm); makes sure `.gitignore` covers
39
+ `node_modules`, `dist`, `.env`, `.DS_Store`, `*.log`, vite's `.vite/` and
40
+ Yarn Berry's `.pnp.*` / `.yarn/{cache,unplugged,install-state.gz,build-state.yml}`
41
+ — never lockfiles (the file is created when the app has none — apps made
42
+ in the online editor don't — otherwise only the missing lines are
43
+ appended); adds `save` / `deploy` / `release` scripts to `package.json`
44
+ when they are missing. Then launches VS Code (`--editor cursor` or
45
+ `$COMMERCEBUILD_EDITOR` for another editor, `--no-editor` to skip).
46
+ Files the project already has are never changed.
47
+ - Adds a `type-check` script (`commercebuild-extension type-check`, the
48
+ SDK's own `tsc --noEmit`) **only** when the project's declared
49
+ `@commercebuild/extension` range can resolve to a version that has it
50
+ (0.0.21 or newer) — an older SDK exits 0 on the unknown subcommand, which
51
+ would look like a passing check. A pinned old range (`0.0.18`, `^0.0.18`)
52
+ or a missing declaration gets a warning with the upgrade command instead;
53
+ an existing `type-check` script is never touched. Lockfiles are never
54
+ downloaded, so `^0.*` resolves to the newest SDK on `npm install`.
55
+ - Creates `README.md` (how to develop locally, the editor's Save / Deploy /
56
+ Release as npm scripts, how to use the AI files), `AGENTS.md` and
57
+ `CLAUDE.md` at the project root when the download lacks them (the
58
+ editor's scaffold, its Export and `extension create` write the same
59
+ files). They are project source: saved in the draft, included in
60
+ deploys, never overwritten. They point Claude Code, Cursor, Codex and
61
+ Copilot at the platform guide in
62
+ `node_modules/@commercebuild/extension/AGENTS.md` and hold a "Project
63
+ notes" section for app-specific rules that the online assistant reads
64
+ too. Gemini CLI reads `GEMINI.md` unless `.gemini/settings.json` sets
65
+ `{ "context": { "fileName": ["AGENTS.md", "GEMINI.md"] } }`.
66
+ - **Never installs dependencies.** The source comes from a shared draft, so
67
+ nothing from it is executed; run `npm install` (or yarn / pnpm) yourself
68
+ after looking at the project.
69
+ - No editor installed? The download still succeeds (exit 0); the command
70
+ prints the folder and a warning instead of launching anything.
71
+ - `--json` prints `{dir, source, files}` on stdout (errors as `{error}`);
72
+ the commercebuild App Studio extension uses it with `--no-editor` to open the
73
+ folder in its own window.
74
+
75
+ ## Signing in (`auth`)
76
+
77
+ `auth login --store <url>` signs in through the store admin's consent page
78
+ in your browser and keeps the token pair in your operating system's
79
+ keychain; `auth info` lists the stores you are signed in to and `auth
80
+ logout` signs out.
81
+
82
+ `auth token [--store <url>] [--json]` prints a current access token for a
83
+ signed-in store (the current one by default), renewed first when it has
84
+ less than 5 minutes left. Only the token goes to stdout; `--json` prints
85
+ `{accessToken, expiresAt, storeUrl, adminUrl, storeId}` instead, and an
86
+ error as `{error, code}` (`code` is `not-signed-in` when there is no
87
+ sign-in to use), with exit code 1. The commercebuild App Studio
88
+ extension's assistant panel gets its token this way. Treat the output like
89
+ a password.
90
+
91
+ ## Working locally
92
+
93
+ The online editor's actions have these equivalents, all run in the
94
+ project folder (npm shown; yarn and pnpm work the same — the project
95
+ declares no package manager, and `open` writes an `.npmrc` so pnpm hoists
96
+ like npm):
97
+
98
+ | Online editor | Local | What it does |
99
+ | ---------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
100
+ | (build errors) | `npm run type-check` | The SDK's TypeScript over the project (`tsc --noEmit`), exit code = tsc's. Run after every change; the online editor's compile errors are the equivalent. |
101
+ | Save | `npm run save` (`extension save`) | Zips the project (minus `node_modules`, `dist`, `.git`, `.env*`, `.npmrc`, lockfiles, logs, binary files) and **replaces** the online draft — the editor shows it on next load. A save based on an older revision than the online one is refused unless `--force` is given. Held to the platform's draft cap (5 MB by default), same as the editor. |
102
+ | Deploy | `npm run deploy` (`extension commit`) | Builds a new version from `src/**` plus the root manifests, `.gitignore` and the AI / README files. `-m "…"` gives the build's description; without it the CLI asks (a script must pass it). |
103
+ | Deploy → Release | `npm run release` (`extension release`) | Builds and makes the version live. Waits up to 15 min for the build, retrying failed status polls; if it stops waiting, the build continues on the server — finish with `npx commercebuild-cli@rc extension release --build <buildRef>` (printed in the message) or release the version in the store admin. |
104
+
105
+ `npm run dev` previews the app against your store (open the storefront with
106
+ `?devSource=http://localhost:25521`).
107
+
108
+ The editor's **Export** button produces the same project as `extension
109
+ open` (one zip, ready to run), and its **Import** takes such a folder back
110
+ — minus the machine-local files (`.env*`, `.npmrc`, lockfiles), which it
111
+ never reads from a zip.