@greatstore/cli 0.0.13 → 0.0.14

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 CHANGED
@@ -3,6 +3,11 @@
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.14 — 2026-05-24
7
+
8
+ ### Changed
9
+ - `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.
10
+
6
11
  ## 0.0.13 — 2026-05-24
7
12
 
8
13
  ### Changed
package/dist/cli.js CHANGED
@@ -1254,9 +1254,10 @@ async function buildCommand(args) {
1254
1254
  if (target && queue.length === 0) {
1255
1255
  throw new Error(`No component named "${target}" in ./${COMPONENTS_DIR}`);
1256
1256
  }
1257
- const { build, reactPlugin } = await loadVite(root);
1257
+ const { build, reactPlugin, transformWithEsbuild } = await loadVite(root);
1258
1258
  for (const name of queue) {
1259
1259
  const dir = path7.join(root, COMPONENTS_DIR, name);
1260
+ const bundlePath = path7.join(dir, "bundle.js");
1260
1261
  await build({
1261
1262
  plugins: [reactPlugin()],
1262
1263
  logLevel: "warn",
@@ -1283,8 +1284,21 @@ async function buildCommand(args) {
1283
1284
  sourcemap: false
1284
1285
  }
1285
1286
  });
1286
- process.stdout.write(`built ${COMPONENTS_DIR}/${name}/bundle.js
1287
- `);
1287
+ const beforeBytes = fs7.statSync(bundlePath).size;
1288
+ const src = fs7.readFileSync(bundlePath, "utf8");
1289
+ const { code } = await transformWithEsbuild(src, bundlePath, {
1290
+ minify: true,
1291
+ legalComments: "none",
1292
+ target: "esnext",
1293
+ loader: "js",
1294
+ sourcemap: false
1295
+ });
1296
+ fs7.writeFileSync(bundlePath, code);
1297
+ const afterBytes = Buffer.byteLength(code, "utf8");
1298
+ process.stdout.write(
1299
+ `built ${COMPONENTS_DIR}/${name}/bundle.js (${formatBytes(afterBytes)}, ${pctSmaller(beforeBytes, afterBytes)} smaller)
1300
+ `
1301
+ );
1288
1302
  }
1289
1303
  process.stdout.write(
1290
1304
  `
@@ -1299,6 +1313,14 @@ function listComponents(root) {
1299
1313
  return fs7.statSync(candidate).isDirectory() && fs7.existsSync(path7.join(candidate, "component.tsx"));
1300
1314
  }).sort();
1301
1315
  }
1316
+ function formatBytes(n) {
1317
+ if (n < 1024) return `${n} B`;
1318
+ return `${(n / 1024).toFixed(1)} KB`;
1319
+ }
1320
+ function pctSmaller(before, after) {
1321
+ if (before === 0) return "0%";
1322
+ return `${Math.round((1 - after / before) * 100)}%`;
1323
+ }
1302
1324
  async function loadVite(root) {
1303
1325
  const localRequire = createRequire(path7.join(root, "package.json"));
1304
1326
  const vitePath = resolveEsmEntry(localRequire, "vite");
@@ -1320,6 +1342,12 @@ async function loadVite(root) {
1320
1342
  `Loaded \`vite\` from ${vitePath} but couldn't find its \`build()\` export. Reinstall vite (>= 5) and retry.`
1321
1343
  );
1322
1344
  }
1345
+ const transformWithEsbuild = viteMod.transformWithEsbuild ?? viteMod.default?.transformWithEsbuild;
1346
+ if (typeof transformWithEsbuild !== "function") {
1347
+ throw new Error(
1348
+ `Loaded \`vite\` from ${vitePath} but couldn't find its \`transformWithEsbuild()\` export. Reinstall vite (>= 5) and retry.`
1349
+ );
1350
+ }
1323
1351
  const reactMod = await import(reactPath);
1324
1352
  const reactPlugin = reactMod.default ?? reactMod;
1325
1353
  if (typeof reactPlugin !== "function") {
@@ -1329,7 +1357,8 @@ async function loadVite(root) {
1329
1357
  }
1330
1358
  return {
1331
1359
  build,
1332
- reactPlugin
1360
+ reactPlugin,
1361
+ transformWithEsbuild
1333
1362
  };
1334
1363
  }
1335
1364
  function resolveEsmEntry(req, specifier) {
@@ -1402,8 +1431,8 @@ function recentChangelog(text, minItems = 15) {
1402
1431
  }
1403
1432
 
1404
1433
  // src/index.ts
1405
- var VERSION = true ? "0.0.13" : "0.0.0-dev";
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" : "";
1434
+ var VERSION = true ? "0.0.14" : "0.0.0-dev";
1435
+ 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.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
1436
  var HELP = `gs \u2014 GreatStore CLI (v${VERSION})
1408
1437
 
1409
1438
  Usage:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greatstore/cli",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "CLI for authoring and shipping GreatStore custom components.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",