@greatstore/cli 0.0.11-beta.3 → 0.0.12
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 +8 -18
- package/dist/cli.js +70 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,34 +3,24 @@
|
|
|
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.
|
|
6
|
+
## 0.0.12 — 2026-05-24
|
|
7
7
|
|
|
8
|
-
###
|
|
9
|
-
-
|
|
8
|
+
### Fixed
|
|
9
|
+
- `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.
|
|
10
10
|
|
|
11
|
-
## 0.0.11
|
|
11
|
+
## 0.0.11 — 2026-05-24
|
|
12
12
|
|
|
13
13
|
### Added
|
|
14
|
+
- 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).
|
|
14
15
|
- `gs build [<name>]` — 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.
|
|
15
|
-
|
|
16
|
-
### Changed
|
|
17
|
-
- `gs init` no longer writes a `build.mjs`. Scaffolded `package.json` scripts run `gs build`.
|
|
18
|
-
|
|
19
|
-
## 0.0.11-beta.1 — 2026-05-24
|
|
20
|
-
|
|
21
|
-
### Changed
|
|
22
|
-
- `gs init` errors on a fresh root without `--store <slug>` (no placeholder slug is written). On an existing root, passing `--store` errors — a project is pinned to one store.
|
|
23
|
-
|
|
24
|
-
## 0.0.11-beta.0 — 2026-05-24
|
|
25
|
-
|
|
26
|
-
### Added
|
|
27
|
-
- Multi-component projects: scaffold one root, then add N components under `components/<name>/`.
|
|
28
|
-
- `gs init` (no args) writes the project root. `gs init <name>` adds a component (auto-scaffolds the root if missing).
|
|
29
16
|
- `gs push` (no args) hashes each component against `.gssync.json` and uploads only the changed ones.
|
|
30
17
|
- `gs pull` (no args, or `*`) batch-pulls every remote component. Components with uncommitted local edits are skipped with a warning; `--force` overwrites.
|
|
18
|
+
- Public `CHANGELOG.md`. `gs --version` now prints the most recent entries.
|
|
31
19
|
|
|
32
20
|
### Changed
|
|
33
21
|
- 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.
|
|
22
|
+
- `gs init` errors on a fresh root without `--store <slug>` (no placeholder slug is written). On an existing root, passing `--store` errors.
|
|
23
|
+
- `gs init` no longer writes `build.mjs`. Scaffolded `package.json` scripts run `gs build`.
|
|
34
24
|
|
|
35
25
|
## 0.0.10 — 2026-05-23
|
|
36
26
|
|
package/dist/cli.js
CHANGED
|
@@ -92,7 +92,7 @@ async function captureLoopbackToken(options) {
|
|
|
92
92
|
const open = options.openBrowser ?? ((url) => openInBrowser(url, options.browserCmdEnv));
|
|
93
93
|
const server = http.createServer();
|
|
94
94
|
try {
|
|
95
|
-
await new Promise((
|
|
95
|
+
await new Promise((resolve5) => server.listen(0, "127.0.0.1", resolve5));
|
|
96
96
|
const address = server.address();
|
|
97
97
|
const redirectUri = `http://127.0.0.1:${address.port}${CALLBACK_PATH}`;
|
|
98
98
|
const authUrl = `${options.navBaseUrl}/connect_oauth_done?redirect_uri=${encodeURIComponent(redirectUri)}&state=${encodeURIComponent(state)}`;
|
|
@@ -104,7 +104,7 @@ async function captureLoopbackToken(options) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
function waitForCallback(server, expectedState, timeoutMs) {
|
|
107
|
-
return new Promise((
|
|
107
|
+
return new Promise((resolve5, reject) => {
|
|
108
108
|
let settled = false;
|
|
109
109
|
const settle = (fn) => {
|
|
110
110
|
if (settled) return;
|
|
@@ -150,7 +150,7 @@ function waitForCallback(server, expectedState, timeoutMs) {
|
|
|
150
150
|
res.writeHead(200, { "content-type": "text/html" });
|
|
151
151
|
res.end(SUCCESS_HTML);
|
|
152
152
|
clearTimeout(timer);
|
|
153
|
-
settle(() =>
|
|
153
|
+
settle(() => resolve5({ token }));
|
|
154
154
|
});
|
|
155
155
|
});
|
|
156
156
|
}
|
|
@@ -966,11 +966,11 @@ async function deleteCommand(args) {
|
|
|
966
966
|
`);
|
|
967
967
|
}
|
|
968
968
|
function prompt(question) {
|
|
969
|
-
return new Promise((
|
|
969
|
+
return new Promise((resolve5) => {
|
|
970
970
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
971
971
|
rl.question(question, (answer) => {
|
|
972
972
|
rl.close();
|
|
973
|
-
|
|
973
|
+
resolve5(answer);
|
|
974
974
|
});
|
|
975
975
|
});
|
|
976
976
|
}
|
|
@@ -1296,28 +1296,86 @@ function listComponents(root) {
|
|
|
1296
1296
|
}
|
|
1297
1297
|
async function loadVite(root) {
|
|
1298
1298
|
const localRequire = createRequire(path7.join(root, "package.json"));
|
|
1299
|
-
const vitePath =
|
|
1299
|
+
const vitePath = resolveEsmEntry(localRequire, "vite");
|
|
1300
1300
|
if (!vitePath) {
|
|
1301
1301
|
throw new Error(
|
|
1302
1302
|
"Cannot find `vite` in this project. Run `npm install` first."
|
|
1303
1303
|
);
|
|
1304
1304
|
}
|
|
1305
|
-
const reactPath =
|
|
1305
|
+
const reactPath = resolveEsmEntry(localRequire, "@vitejs/plugin-react");
|
|
1306
1306
|
if (!reactPath) {
|
|
1307
1307
|
throw new Error(
|
|
1308
1308
|
"Cannot find `@vitejs/plugin-react` in this project. Run `npm install` first."
|
|
1309
1309
|
);
|
|
1310
1310
|
}
|
|
1311
1311
|
const viteMod = await import(vitePath);
|
|
1312
|
+
const build = viteMod.build ?? viteMod.default?.build;
|
|
1313
|
+
if (typeof build !== "function") {
|
|
1314
|
+
throw new Error(
|
|
1315
|
+
`Loaded \`vite\` from ${vitePath} but couldn't find its \`build()\` export. Reinstall vite (>= 5) and retry.`
|
|
1316
|
+
);
|
|
1317
|
+
}
|
|
1312
1318
|
const reactMod = await import(reactPath);
|
|
1313
|
-
|
|
1319
|
+
const reactPlugin = reactMod.default ?? reactMod;
|
|
1320
|
+
if (typeof reactPlugin !== "function") {
|
|
1321
|
+
throw new Error(
|
|
1322
|
+
`Loaded \`@vitejs/plugin-react\` from ${reactPath} but couldn't find its default export.`
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
return {
|
|
1326
|
+
build,
|
|
1327
|
+
reactPlugin
|
|
1328
|
+
};
|
|
1314
1329
|
}
|
|
1315
|
-
function
|
|
1330
|
+
function resolveEsmEntry(req, specifier) {
|
|
1331
|
+
let anchor;
|
|
1332
|
+
try {
|
|
1333
|
+
anchor = req.resolve(specifier);
|
|
1334
|
+
} catch {
|
|
1335
|
+
return null;
|
|
1336
|
+
}
|
|
1337
|
+
const pkgJsonPath = findOwningPackageJson(anchor, specifier);
|
|
1338
|
+
if (!pkgJsonPath) return null;
|
|
1339
|
+
const pkgDir = path7.dirname(pkgJsonPath);
|
|
1340
|
+
let pkg;
|
|
1316
1341
|
try {
|
|
1317
|
-
|
|
1342
|
+
pkg = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf8"));
|
|
1318
1343
|
} catch {
|
|
1319
1344
|
return null;
|
|
1320
1345
|
}
|
|
1346
|
+
const fromExports = pickImportEntry(pkg.exports);
|
|
1347
|
+
const entry = fromExports ?? (typeof pkg.module === "string" ? pkg.module : null) ?? (typeof pkg.main === "string" ? pkg.main : null);
|
|
1348
|
+
if (!entry) return null;
|
|
1349
|
+
return path7.resolve(pkgDir, entry);
|
|
1350
|
+
}
|
|
1351
|
+
function findOwningPackageJson(start, specifier) {
|
|
1352
|
+
let dir = path7.dirname(start);
|
|
1353
|
+
while (true) {
|
|
1354
|
+
const candidate = path7.join(dir, "package.json");
|
|
1355
|
+
if (fs7.existsSync(candidate)) {
|
|
1356
|
+
try {
|
|
1357
|
+
const parsed = JSON.parse(fs7.readFileSync(candidate, "utf8"));
|
|
1358
|
+
if (parsed.name === specifier) return candidate;
|
|
1359
|
+
} catch {
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
const parent = path7.dirname(dir);
|
|
1363
|
+
if (parent === dir) return null;
|
|
1364
|
+
dir = parent;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
function pickImportEntry(exports) {
|
|
1368
|
+
if (typeof exports !== "object" || exports === null) return null;
|
|
1369
|
+
const map = exports;
|
|
1370
|
+
const dot = map["."] ?? exports;
|
|
1371
|
+
if (typeof dot !== "object" || dot === null) return null;
|
|
1372
|
+
const imp = dot.import;
|
|
1373
|
+
if (typeof imp === "string") return imp;
|
|
1374
|
+
if (typeof imp === "object" && imp !== null) {
|
|
1375
|
+
const def = imp.default;
|
|
1376
|
+
if (typeof def === "string") return def;
|
|
1377
|
+
}
|
|
1378
|
+
return null;
|
|
1321
1379
|
}
|
|
1322
1380
|
|
|
1323
1381
|
// src/changelog.ts
|
|
@@ -1339,8 +1397,8 @@ function recentChangelog(text, minItems = 15) {
|
|
|
1339
1397
|
}
|
|
1340
1398
|
|
|
1341
1399
|
// src/index.ts
|
|
1342
|
-
var VERSION = true ? "0.0.
|
|
1343
|
-
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.
|
|
1400
|
+
var VERSION = true ? "0.0.12" : "0.0.0-dev";
|
|
1401
|
+
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.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" : "";
|
|
1344
1402
|
var HELP = `gs \u2014 GreatStore CLI (v${VERSION})
|
|
1345
1403
|
|
|
1346
1404
|
Usage:
|