@greatstore/cli 0.0.13 → 0.0.15
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/CHANGELOG.md +10 -0
- package/dist/cli.js +53 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to `@greatstore/cli` are recorded here. The format
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/).
|
|
5
5
|
|
|
6
|
+
## 0.0.15 — 2026-05-24
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- `gs init <name>` scaffold now declares the four GreatStore-injected lifecycle props (`onSendMessage`, `onCallTool`, `onClose`, and the new `onError(message)`) on the `Props` interface with inline comments. `onError` lets a component surface in-flight failures (failed fetch, host-page action rejected, invalid host state) back to the in-store AI so it can apologize or self-correct on its next turn. Render-time crashes are reported automatically by the GreatStore error boundary — `onError` is for *expected* failures the boundary can't catch.
|
|
10
|
+
|
|
11
|
+
## 0.0.14 — 2026-05-24
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- `gs build` output is now whitespace-minified. Vite's lib mode in `es` format only minifies identifiers / syntax and preserves all whitespace + `/* @__PURE__ */` annotations for downstream tree-shaking. Since the bundles are loaded directly by the browser at runtime (no downstream bundler), the CLI now post-processes each `bundle.js` with `esbuild.transform` to collapse whitespace and strip legal comments — typically ~50% smaller files, cheaper to host and faster to ship.
|
|
15
|
+
|
|
6
16
|
## 0.0.13 — 2026-05-24
|
|
7
17
|
|
|
8
18
|
### Changed
|
package/dist/cli.js
CHANGED
|
@@ -1118,7 +1118,25 @@ function component(name) {
|
|
|
1118
1118
|
return `import React from "react";
|
|
1119
1119
|
|
|
1120
1120
|
interface Props {
|
|
1121
|
+
// ---- Your tool args ----
|
|
1121
1122
|
// Add fields here matching manifest.json#inputSchema.properties.
|
|
1123
|
+
|
|
1124
|
+
// ---- GreatStore-injected lifecycle props (always present) ----
|
|
1125
|
+
// Send text into the chat as if the shopper typed it.
|
|
1126
|
+
onSendMessage: (text: string) => void;
|
|
1127
|
+
// Chain into another remote-component tool by name.
|
|
1128
|
+
onCallTool: (name: string, args: Record<string, unknown>) => void;
|
|
1129
|
+
// Dismiss the host slot (over-input clears the overlay, fullscreen
|
|
1130
|
+
// reverts the pane, inline is a no-op).
|
|
1131
|
+
onClose: () => void;
|
|
1132
|
+
// Tell the in-store AI something went wrong so it can apologize or
|
|
1133
|
+
// self-correct on its next turn. Use for *expected* failures inside
|
|
1134
|
+
// async handlers (failed fetch, host-page action rejected, invalid
|
|
1135
|
+
// host state). Render-time crashes are reported automatically by
|
|
1136
|
+
// the GreatStore error boundary \u2014 you don't need a try/catch just
|
|
1137
|
+
// to forward exceptions. The message is read by the AI, not the
|
|
1138
|
+
// shopper, so write it like a short engineering note.
|
|
1139
|
+
onError: (message: string) => void;
|
|
1122
1140
|
}
|
|
1123
1141
|
|
|
1124
1142
|
export default function ${pascal(name)}(_props: Props): React.ReactElement {
|
|
@@ -1254,9 +1272,10 @@ async function buildCommand(args) {
|
|
|
1254
1272
|
if (target && queue.length === 0) {
|
|
1255
1273
|
throw new Error(`No component named "${target}" in ./${COMPONENTS_DIR}`);
|
|
1256
1274
|
}
|
|
1257
|
-
const { build, reactPlugin } = await loadVite(root);
|
|
1275
|
+
const { build, reactPlugin, transformWithEsbuild } = await loadVite(root);
|
|
1258
1276
|
for (const name of queue) {
|
|
1259
1277
|
const dir = path7.join(root, COMPONENTS_DIR, name);
|
|
1278
|
+
const bundlePath = path7.join(dir, "bundle.js");
|
|
1260
1279
|
await build({
|
|
1261
1280
|
plugins: [reactPlugin()],
|
|
1262
1281
|
logLevel: "warn",
|
|
@@ -1283,8 +1302,21 @@ async function buildCommand(args) {
|
|
|
1283
1302
|
sourcemap: false
|
|
1284
1303
|
}
|
|
1285
1304
|
});
|
|
1286
|
-
|
|
1287
|
-
|
|
1305
|
+
const beforeBytes = fs7.statSync(bundlePath).size;
|
|
1306
|
+
const src = fs7.readFileSync(bundlePath, "utf8");
|
|
1307
|
+
const { code } = await transformWithEsbuild(src, bundlePath, {
|
|
1308
|
+
minify: true,
|
|
1309
|
+
legalComments: "none",
|
|
1310
|
+
target: "esnext",
|
|
1311
|
+
loader: "js",
|
|
1312
|
+
sourcemap: false
|
|
1313
|
+
});
|
|
1314
|
+
fs7.writeFileSync(bundlePath, code);
|
|
1315
|
+
const afterBytes = Buffer.byteLength(code, "utf8");
|
|
1316
|
+
process.stdout.write(
|
|
1317
|
+
`built ${COMPONENTS_DIR}/${name}/bundle.js (${formatBytes(afterBytes)}, ${pctSmaller(beforeBytes, afterBytes)} smaller)
|
|
1318
|
+
`
|
|
1319
|
+
);
|
|
1288
1320
|
}
|
|
1289
1321
|
process.stdout.write(
|
|
1290
1322
|
`
|
|
@@ -1299,6 +1331,14 @@ function listComponents(root) {
|
|
|
1299
1331
|
return fs7.statSync(candidate).isDirectory() && fs7.existsSync(path7.join(candidate, "component.tsx"));
|
|
1300
1332
|
}).sort();
|
|
1301
1333
|
}
|
|
1334
|
+
function formatBytes(n) {
|
|
1335
|
+
if (n < 1024) return `${n} B`;
|
|
1336
|
+
return `${(n / 1024).toFixed(1)} KB`;
|
|
1337
|
+
}
|
|
1338
|
+
function pctSmaller(before, after) {
|
|
1339
|
+
if (before === 0) return "0%";
|
|
1340
|
+
return `${Math.round((1 - after / before) * 100)}%`;
|
|
1341
|
+
}
|
|
1302
1342
|
async function loadVite(root) {
|
|
1303
1343
|
const localRequire = createRequire(path7.join(root, "package.json"));
|
|
1304
1344
|
const vitePath = resolveEsmEntry(localRequire, "vite");
|
|
@@ -1320,6 +1360,12 @@ async function loadVite(root) {
|
|
|
1320
1360
|
`Loaded \`vite\` from ${vitePath} but couldn't find its \`build()\` export. Reinstall vite (>= 5) and retry.`
|
|
1321
1361
|
);
|
|
1322
1362
|
}
|
|
1363
|
+
const transformWithEsbuild = viteMod.transformWithEsbuild ?? viteMod.default?.transformWithEsbuild;
|
|
1364
|
+
if (typeof transformWithEsbuild !== "function") {
|
|
1365
|
+
throw new Error(
|
|
1366
|
+
`Loaded \`vite\` from ${vitePath} but couldn't find its \`transformWithEsbuild()\` export. Reinstall vite (>= 5) and retry.`
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1323
1369
|
const reactMod = await import(reactPath);
|
|
1324
1370
|
const reactPlugin = reactMod.default ?? reactMod;
|
|
1325
1371
|
if (typeof reactPlugin !== "function") {
|
|
@@ -1329,7 +1375,8 @@ async function loadVite(root) {
|
|
|
1329
1375
|
}
|
|
1330
1376
|
return {
|
|
1331
1377
|
build,
|
|
1332
|
-
reactPlugin
|
|
1378
|
+
reactPlugin,
|
|
1379
|
+
transformWithEsbuild
|
|
1333
1380
|
};
|
|
1334
1381
|
}
|
|
1335
1382
|
function resolveEsmEntry(req, specifier) {
|
|
@@ -1402,8 +1449,8 @@ function recentChangelog(text, minItems = 15) {
|
|
|
1402
1449
|
}
|
|
1403
1450
|
|
|
1404
1451
|
// src/index.ts
|
|
1405
|
-
var VERSION = true ? "0.0.
|
|
1406
|
-
var CHANGELOG = true ? "# Changelog\n\nAll notable changes to `@greatstore/cli` are recorded here. The format\nfollows [Keep a Changelog](https://keepachangelog.com/).\n\n## 0.0.13 \u2014 2026-05-24\n\n### Changed\n- `gs build` now prints a closing hint naming the next steps (`gs push`, then `gs publish <name>`) so AI assistants driving the CLI don't stop at \"built\" and leave the change unshipped.\n\n## 0.0.12 \u2014 2026-05-24\n\n### Fixed\n- `gs build` failed with `Error: build is not a function` because `require.resolve(\"vite\")` lands on Vite 5's deprecated CJS entry. The CLI now walks `vite/package.json#exports.import` to load the ESM build, and falls back to the CJS-default shape if a host package ships only CJS.\n\n## 0.0.11 \u2014 2026-05-24\n\n### Added\n- Multi-component projects: scaffold one root, then add N components under `components/<name>/`. `gs init` (no args) writes the project root; `gs init <name>` adds a component (auto-scaffolds the root if missing).\n- `gs build [<name>]` \u2014 compiles every `components/<name>/bundle.js` via the project's local Vite. Externals + runtime shim paths now live in the CLI, so future versions can adjust them without a re-scaffold.\n- `gs push` (no args) hashes each component against `.gssync.json` and uploads only the changed ones.\n- `gs pull` (no args, or `*`) batch-pulls every remote component. Components with uncommitted local edits are skipped with a warning; `--force` overwrites.\n- Public `CHANGELOG.md`. `gs --version` now prints the most recent entries.\n\n### Changed\n- A project folder ships to exactly one store. Only `gs init` accepts `--store`; every other command reads the slug from `.gsrc`. The legacy single-component layout is rejected with a migration hint.\n- `gs init` errors on a fresh root without `--store <slug>` (no placeholder slug is written). On an existing root, passing `--store` errors.\n- `gs init` no longer writes `build.mjs`. Scaffolded `package.json` scripts run `gs build`.\n\n## 0.0.10 \u2014 2026-05-23\n\n### Changed\n- The OAuth callback tab opened by `gs login` auto-closes once credentials are persisted.\n\n## 0.0.9 \u2014 2026-05-23\n\n### Changed\n- `gs init` scaffold writes a `displayName` into the generated manifest so the admin Builder UI has a friendlier label.\n\n## 0.0.8 \u2014 2026-05-23\n\n### Changed\n- `gs push` and `gs publish` print a permalink to the component's card in the admin Builder panel.\n\n## 0.0.6 \u2014 2026-05-23\n\n### Changed\n- `gs --version` reads the version from `cli/package.json` at build time so it can't drift from the published release.\n\n## 0.0.4 \u2014 2026-05-23\n\n### Changed\n- Scaffolded projects produce browser-ready bundles (React + runtime shim wired up).\n\n## 0.0.3 \u2014 2026-05-23\n\n### Changed\n- Trimmed public README to the essentials.\n\n## 0.0.2 \u2014 2026-05-23\n\n### Fixed\n- Read the nav OAuth callback parameter as `code` instead of `token`.\n" : "";
|
|
1452
|
+
var VERSION = true ? "0.0.15" : "0.0.0-dev";
|
|
1453
|
+
var CHANGELOG = true ? "# Changelog\n\nAll notable changes to `@greatstore/cli` are recorded here. The format\nfollows [Keep a Changelog](https://keepachangelog.com/).\n\n## 0.0.15 \u2014 2026-05-24\n\n### Added\n- `gs init <name>` scaffold now declares the four GreatStore-injected lifecycle props (`onSendMessage`, `onCallTool`, `onClose`, and the new `onError(message)`) on the `Props` interface with inline comments. `onError` lets a component surface in-flight failures (failed fetch, host-page action rejected, invalid host state) back to the in-store AI so it can apologize or self-correct on its next turn. Render-time crashes are reported automatically by the GreatStore error boundary \u2014 `onError` is for *expected* failures the boundary can't catch.\n\n## 0.0.14 \u2014 2026-05-24\n\n### Changed\n- `gs build` output is now whitespace-minified. Vite's lib mode in `es` format only minifies identifiers / syntax and preserves all whitespace + `/* @__PURE__ */` annotations for downstream tree-shaking. Since the bundles are loaded directly by the browser at runtime (no downstream bundler), the CLI now post-processes each `bundle.js` with `esbuild.transform` to collapse whitespace and strip legal comments \u2014 typically ~50% smaller files, cheaper to host and faster to ship.\n\n## 0.0.13 \u2014 2026-05-24\n\n### Changed\n- `gs build` now prints a closing hint naming the next steps (`gs push`, then `gs publish <name>`) so AI assistants driving the CLI don't stop at \"built\" and leave the change unshipped.\n\n## 0.0.12 \u2014 2026-05-24\n\n### Fixed\n- `gs build` failed with `Error: build is not a function` because `require.resolve(\"vite\")` lands on Vite 5's deprecated CJS entry. The CLI now walks `vite/package.json#exports.import` to load the ESM build, and falls back to the CJS-default shape if a host package ships only CJS.\n\n## 0.0.11 \u2014 2026-05-24\n\n### Added\n- Multi-component projects: scaffold one root, then add N components under `components/<name>/`. `gs init` (no args) writes the project root; `gs init <name>` adds a component (auto-scaffolds the root if missing).\n- `gs build [<name>]` \u2014 compiles every `components/<name>/bundle.js` via the project's local Vite. Externals + runtime shim paths now live in the CLI, so future versions can adjust them without a re-scaffold.\n- `gs push` (no args) hashes each component against `.gssync.json` and uploads only the changed ones.\n- `gs pull` (no args, or `*`) batch-pulls every remote component. Components with uncommitted local edits are skipped with a warning; `--force` overwrites.\n- Public `CHANGELOG.md`. `gs --version` now prints the most recent entries.\n\n### Changed\n- A project folder ships to exactly one store. Only `gs init` accepts `--store`; every other command reads the slug from `.gsrc`. The legacy single-component layout is rejected with a migration hint.\n- `gs init` errors on a fresh root without `--store <slug>` (no placeholder slug is written). On an existing root, passing `--store` errors.\n- `gs init` no longer writes `build.mjs`. Scaffolded `package.json` scripts run `gs build`.\n\n## 0.0.10 \u2014 2026-05-23\n\n### Changed\n- The OAuth callback tab opened by `gs login` auto-closes once credentials are persisted.\n\n## 0.0.9 \u2014 2026-05-23\n\n### Changed\n- `gs init` scaffold writes a `displayName` into the generated manifest so the admin Builder UI has a friendlier label.\n\n## 0.0.8 \u2014 2026-05-23\n\n### Changed\n- `gs push` and `gs publish` print a permalink to the component's card in the admin Builder panel.\n\n## 0.0.6 \u2014 2026-05-23\n\n### Changed\n- `gs --version` reads the version from `cli/package.json` at build time so it can't drift from the published release.\n\n## 0.0.4 \u2014 2026-05-23\n\n### Changed\n- Scaffolded projects produce browser-ready bundles (React + runtime shim wired up).\n\n## 0.0.3 \u2014 2026-05-23\n\n### Changed\n- Trimmed public README to the essentials.\n\n## 0.0.2 \u2014 2026-05-23\n\n### Fixed\n- Read the nav OAuth callback parameter as `code` instead of `token`.\n" : "";
|
|
1407
1454
|
var HELP = `gs \u2014 GreatStore CLI (v${VERSION})
|
|
1408
1455
|
|
|
1409
1456
|
Usage:
|