commercebuild-cli 0.0.30 → 0.0.32

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,95 @@
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@latest 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 Apps** 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 Apps extension uses it with `--no-editor` to open the
73
+ folder in its own window.
74
+
75
+ ## Working locally
76
+
77
+ The online editor's actions have these equivalents, all run in the
78
+ project folder (npm shown; yarn and pnpm work the same — the project
79
+ declares no package manager, and `open` writes an `.npmrc` so pnpm hoists
80
+ like npm):
81
+
82
+ | Online editor | Local | What it does |
83
+ | ---------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
84
+ | (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. |
85
+ | 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. No conflict check: the last writer wins, so pick one place to edit an app. 700 KB cap, same as the editor. |
86
+ | Deploy | `npm run deploy` (`extension commit`) | Builds a new version from `src/**` plus the root manifests, `.gitignore` and the AI / README files. |
87
+ | 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@latest extension release --upload <uploadId>` (printed in the message) or release the version in the store admin. |
88
+
89
+ `npm run dev` previews the app against your store (open the storefront with
90
+ `?devSource=http://localhost:25521`).
91
+
92
+ The editor's **Export** button produces the same project as `extension
93
+ open` (one zip, ready to run), and its **Import** takes such a folder back
94
+ — minus the machine-local files (`.env*`, `.npmrc`, lockfiles), which it
95
+ never reads from a zip.