@greatstore/cli 0.0.16 → 0.0.17
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 +6 -0
- package/dist/cli.js +98 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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.17 — 2026-05-28
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- Each command now prints a one-line upgrade notice when a newer
|
|
10
|
+
`@greatstore/cli` is available on npm.
|
|
11
|
+
|
|
6
12
|
## 0.0.16 — 2026-05-28
|
|
7
13
|
|
|
8
14
|
### Changed
|
package/dist/cli.js
CHANGED
|
@@ -1448,9 +1448,104 @@ function recentChangelog(text, minItems = 15) {
|
|
|
1448
1448
|
return out.join("\n").trimEnd();
|
|
1449
1449
|
}
|
|
1450
1450
|
|
|
1451
|
+
// src/version-check.ts
|
|
1452
|
+
import * as fs8 from "fs";
|
|
1453
|
+
import * as os2 from "os";
|
|
1454
|
+
import * as path8 from "path";
|
|
1455
|
+
var NOTICE = "GreatStore CLI is still in early beta and we constantly pushing new features and security update. It is advised to update to the latest version whenever possible.";
|
|
1456
|
+
var PKG = "@greatstore/cli";
|
|
1457
|
+
var REGISTRY_URL = `https://registry.npmjs.org/${PKG}/latest`;
|
|
1458
|
+
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
1459
|
+
var FETCH_TIMEOUT_MS = 1e3;
|
|
1460
|
+
async function maybePrintUpgradeNotice(current, opts = {}) {
|
|
1461
|
+
if (!/^\d+\.\d+\.\d+/.test(current)) return;
|
|
1462
|
+
if (/-dev\b/.test(current)) return;
|
|
1463
|
+
const home = opts.home ?? os2.homedir();
|
|
1464
|
+
const now = opts.now ?? Date.now;
|
|
1465
|
+
const write2 = opts.write ?? ((line) => process.stderr.write(line));
|
|
1466
|
+
const latest = await resolveLatest({
|
|
1467
|
+
home,
|
|
1468
|
+
now: now(),
|
|
1469
|
+
...opts.fetcher ? { fetcher: opts.fetcher } : {}
|
|
1470
|
+
});
|
|
1471
|
+
if (!latest) return;
|
|
1472
|
+
if (compareSemver(latest, current) <= 0) return;
|
|
1473
|
+
write2(`${NOTICE} (installed: v${current}, latest: v${latest})
|
|
1474
|
+
|
|
1475
|
+
`);
|
|
1476
|
+
}
|
|
1477
|
+
async function resolveLatest(opts) {
|
|
1478
|
+
const cached = readCache(opts.home);
|
|
1479
|
+
if (cached && opts.now - cached.checkedAt < CACHE_TTL_MS) {
|
|
1480
|
+
return cached.latest;
|
|
1481
|
+
}
|
|
1482
|
+
const fetcher = opts.fetcher ?? fetchLatest;
|
|
1483
|
+
const fresh = await fetcher();
|
|
1484
|
+
if (fresh) {
|
|
1485
|
+
writeCache(opts.home, { latest: fresh, checkedAt: opts.now });
|
|
1486
|
+
return fresh;
|
|
1487
|
+
}
|
|
1488
|
+
return cached?.latest ?? null;
|
|
1489
|
+
}
|
|
1490
|
+
async function fetchLatest() {
|
|
1491
|
+
const ctrl = new AbortController();
|
|
1492
|
+
const timer = setTimeout(() => ctrl.abort(), FETCH_TIMEOUT_MS);
|
|
1493
|
+
try {
|
|
1494
|
+
const res = await fetch(REGISTRY_URL, {
|
|
1495
|
+
signal: ctrl.signal,
|
|
1496
|
+
headers: { accept: "application/json" }
|
|
1497
|
+
});
|
|
1498
|
+
if (!res.ok) return null;
|
|
1499
|
+
const json = await res.json();
|
|
1500
|
+
return typeof json.version === "string" ? json.version : null;
|
|
1501
|
+
} catch {
|
|
1502
|
+
return null;
|
|
1503
|
+
} finally {
|
|
1504
|
+
clearTimeout(timer);
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
function cachePath(home) {
|
|
1508
|
+
return path8.join(home, ".greatstore", "version-check.json");
|
|
1509
|
+
}
|
|
1510
|
+
function readCache(home) {
|
|
1511
|
+
try {
|
|
1512
|
+
const raw = fs8.readFileSync(cachePath(home), "utf8");
|
|
1513
|
+
const parsed = JSON.parse(raw);
|
|
1514
|
+
if (typeof parsed.latest === "string" && typeof parsed.checkedAt === "number") {
|
|
1515
|
+
return { latest: parsed.latest, checkedAt: parsed.checkedAt };
|
|
1516
|
+
}
|
|
1517
|
+
} catch {
|
|
1518
|
+
}
|
|
1519
|
+
return null;
|
|
1520
|
+
}
|
|
1521
|
+
function writeCache(home, cache) {
|
|
1522
|
+
try {
|
|
1523
|
+
const file = cachePath(home);
|
|
1524
|
+
fs8.mkdirSync(path8.dirname(file), { recursive: true });
|
|
1525
|
+
fs8.writeFileSync(file, JSON.stringify(cache));
|
|
1526
|
+
} catch {
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
function compareSemver(a, b) {
|
|
1530
|
+
const pa = parseVer(a);
|
|
1531
|
+
const pb = parseVer(b);
|
|
1532
|
+
if (!pa || !pb) return 0;
|
|
1533
|
+
for (let i = 0; i < 3; i++) {
|
|
1534
|
+
const av = pa[i];
|
|
1535
|
+
const bv = pb[i];
|
|
1536
|
+
if (av !== bv) return av - bv;
|
|
1537
|
+
}
|
|
1538
|
+
return 0;
|
|
1539
|
+
}
|
|
1540
|
+
function parseVer(v) {
|
|
1541
|
+
const m = v.match(/^(\d+)\.(\d+)\.(\d+)/);
|
|
1542
|
+
if (!m) return null;
|
|
1543
|
+
return [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1451
1546
|
// src/index.ts
|
|
1452
|
-
var VERSION = true ? "0.0.
|
|
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.16 \u2014 2026-05-28\n\n### Changed\n- Simplified error messages.\n\n## 0.0.15 \u2014 2026-05-24\n\n### Added\n- Scaffolded `component.tsx` now declares the four injected lifecycle\n props (`onSendMessage`, `onCallTool`, `onClose`, `onError`) on\n `Props`. Use `onError(message)` to report expected failures (failed\n fetch, host action rejected, invalid host state) so the AI can\n recover on its next turn. Render-time crashes are reported for you.\n\n## 0.0.14 \u2014 2026-05-24\n\n### Changed\n- `gs build` output is now whitespace-minified \u2014 typically ~50% smaller.\n\n## 0.0.13 \u2014 2026-05-24\n\n### Changed\n- `gs build` prints the next-step hint (`gs push`, then `gs publish`).\n\n## 0.0.12 \u2014 2026-05-24\n\n### Fixed\n- `gs build` failing to load Vite in some setups.\n\n## 0.0.11 \u2014 2026-05-24\n\n### Added\n- Multi-component projects. `gs init` (no args) scaffolds the project\n root; `gs init <name>` adds a component under `components/<name>/`.\n- `gs build [<name>]` \u2014 compiles every `components/<name>/bundle.js`.\n- `gs push` (no args) uploads only the components that changed.\n- `gs pull` (no args, or `*`) downloads every component. Locally\n edited components are skipped; pass `--force` to overwrite.\n- Public `CHANGELOG.md`; `gs --version` prints recent entries.\n\n### Changed\n- A project folder ships to exactly one store. Only `gs init` accepts\n `--store`; every other command reads the slug from `.gsrc`. The old\n single-component layout is rejected with a migration hint.\n- `gs init` requires `--store <slug>` for a fresh root, and rejects\n `--store` on an existing root.\n- `gs init` no longer writes `build.mjs` \u2014 scripts call `gs build`.\n\n## 0.0.10 \u2014 2026-05-23\n\n### Changed\n- The sign-in browser tab auto-closes once `gs login` finishes.\n\n## 0.0.9 \u2014 2026-05-23\n\n### Changed\n- Scaffolded manifests include a `displayName` so the admin UI has a\n friendlier label.\n\n## 0.0.8 \u2014 2026-05-23\n\n### Changed\n- `gs push` and `gs publish` print a link to view the component.\n\n## 0.0.6 \u2014 2026-05-23\n\n### Changed\n- `gs --version` reads from the published package version.\n\n## 0.0.4 \u2014 2026-05-23\n\n### Changed\n- Scaffolded projects produce browser-ready bundles out of the box.\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- Sign-in callback parameter handling.\n" : "";
|
|
1547
|
+
var VERSION = true ? "0.0.17" : "0.0.0-dev";
|
|
1548
|
+
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.17 \u2014 2026-05-28\n\n### Added\n- Each command now prints a one-line upgrade notice when a newer\n `@greatstore/cli` is available on npm.\n\n## 0.0.16 \u2014 2026-05-28\n\n### Changed\n- Simplified error messages.\n\n## 0.0.15 \u2014 2026-05-24\n\n### Added\n- Scaffolded `component.tsx` now declares the four injected lifecycle\n props (`onSendMessage`, `onCallTool`, `onClose`, `onError`) on\n `Props`. Use `onError(message)` to report expected failures (failed\n fetch, host action rejected, invalid host state) so the AI can\n recover on its next turn. Render-time crashes are reported for you.\n\n## 0.0.14 \u2014 2026-05-24\n\n### Changed\n- `gs build` output is now whitespace-minified \u2014 typically ~50% smaller.\n\n## 0.0.13 \u2014 2026-05-24\n\n### Changed\n- `gs build` prints the next-step hint (`gs push`, then `gs publish`).\n\n## 0.0.12 \u2014 2026-05-24\n\n### Fixed\n- `gs build` failing to load Vite in some setups.\n\n## 0.0.11 \u2014 2026-05-24\n\n### Added\n- Multi-component projects. `gs init` (no args) scaffolds the project\n root; `gs init <name>` adds a component under `components/<name>/`.\n- `gs build [<name>]` \u2014 compiles every `components/<name>/bundle.js`.\n- `gs push` (no args) uploads only the components that changed.\n- `gs pull` (no args, or `*`) downloads every component. Locally\n edited components are skipped; pass `--force` to overwrite.\n- Public `CHANGELOG.md`; `gs --version` prints recent entries.\n\n### Changed\n- A project folder ships to exactly one store. Only `gs init` accepts\n `--store`; every other command reads the slug from `.gsrc`. The old\n single-component layout is rejected with a migration hint.\n- `gs init` requires `--store <slug>` for a fresh root, and rejects\n `--store` on an existing root.\n- `gs init` no longer writes `build.mjs` \u2014 scripts call `gs build`.\n\n## 0.0.10 \u2014 2026-05-23\n\n### Changed\n- The sign-in browser tab auto-closes once `gs login` finishes.\n\n## 0.0.9 \u2014 2026-05-23\n\n### Changed\n- Scaffolded manifests include a `displayName` so the admin UI has a\n friendlier label.\n\n## 0.0.8 \u2014 2026-05-23\n\n### Changed\n- `gs push` and `gs publish` print a link to view the component.\n\n## 0.0.6 \u2014 2026-05-23\n\n### Changed\n- `gs --version` reads from the published package version.\n\n## 0.0.4 \u2014 2026-05-23\n\n### Changed\n- Scaffolded projects produce browser-ready bundles out of the box.\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- Sign-in callback parameter handling.\n" : "";
|
|
1454
1549
|
var HELP = `gs \u2014 GreatStore CLI (v${VERSION})
|
|
1455
1550
|
|
|
1456
1551
|
Usage:
|
|
@@ -1489,6 +1584,7 @@ Environment:
|
|
|
1489
1584
|
async function main() {
|
|
1490
1585
|
const argv = process.argv.slice(2);
|
|
1491
1586
|
const parsed = parseArgs(argv);
|
|
1587
|
+
await maybePrintUpgradeNotice(VERSION);
|
|
1492
1588
|
if (flagBool(parsed.flags, "version")) {
|
|
1493
1589
|
process.stdout.write(`gs v${VERSION}
|
|
1494
1590
|
|