@pippit-dev/cli 0.0.8 → 0.0.9

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/checksums.txt CHANGED
@@ -1,6 +1,6 @@
1
- d403f987a5f3cf416d0d183d0b7f45c6cd13ac36da37ca29480e8c9b53af75ea pippit-cli-0.0.8-darwin-amd64.tar.gz
2
- 69aa116a8dd6086f00769ac71aca9cb83c5ffe058187c42c212d35aadb06d817 pippit-cli-0.0.8-darwin-arm64.tar.gz
3
- cdb856501d5472f226bf061073aa2d2af2f61b28151ca908e48e1acc8d1261b4 pippit-cli-0.0.8-linux-amd64.tar.gz
4
- 6a8013ca271df7ddebba3ffcc4ed76ef79404ad6105893cda7db2969a5f51595 pippit-cli-0.0.8-linux-arm64.tar.gz
5
- 1fff575ecbef2d8ed5cc5c05b87d08dbad6f68b3aa1c5da13957cac9f887b4ce pippit-cli-0.0.8-windows-amd64.zip
6
- bfe3160bad9d536a7510486233cbe4bada0581996b142812edcabb741cc5d2de pippit-cli-0.0.8-windows-arm64.zip
1
+ 3f9cf3a1fabbc3d178c89c3d8044c18d86110faf7d26ffa469930319d13d68e6 pippit-cli-0.0.9-darwin-amd64.tar.gz
2
+ 5e14f8ce6034564d9646918e49f8f2d7b6178708518b528c3f95a0af67bd3cd5 pippit-cli-0.0.9-darwin-arm64.tar.gz
3
+ 91e90ab17b577b402c7676965b701df7d317b90a2e2b717929bdadce96158a71 pippit-cli-0.0.9-linux-amd64.tar.gz
4
+ dad9fe0a930c91c52036290a121d721e7a100e80700b1b90807988a577a79342 pippit-cli-0.0.9-linux-arm64.tar.gz
5
+ 62af305df2c5d5b6cfaa615f36cb0f014007ed35df8c4ffdf07b527e09993842 pippit-cli-0.0.9-windows-amd64.zip
6
+ c6d40c79e4bf777ad71caba29191a4fc3a25f34f9643157ce08ec270b8d6eb42 pippit-cli-0.0.9-windows-arm64.zip
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pippit-dev/cli",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Pippit CLI",
5
5
  "bin": {
6
6
  "pippit-cli": "scripts/run.js"
@@ -35,6 +35,7 @@
35
35
  "scripts/platform.js",
36
36
  "scripts/run.js",
37
37
  "scripts/skills.js",
38
+ "scripts/version-check.js",
38
39
  "checksums.txt",
39
40
  "README.md",
40
41
  "LICENSE"
package/scripts/run.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const { execFileSync } = require("child_process");
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
+ const { maybeWarnNewVersion } = require("./version-check");
6
7
 
7
8
  const ext = process.platform === "win32" ? ".exe" : "";
8
9
  const bin = path.join(__dirname, "..", "bin", "pippit-cli" + ext);
@@ -39,6 +40,8 @@ if (process.platform === "win32" && fs.existsSync(oldBin)) {
39
40
  if (args[0] === "install") {
40
41
  require("./install-wizard.js");
41
42
  } else {
43
+ maybeWarnNewVersion(args);
44
+
42
45
  if (!fs.existsSync(bin)) {
43
46
  try {
44
47
  execFileSync(process.execPath, [path.join(__dirname, "install.js")], {
@@ -0,0 +1,96 @@
1
+ const fs = require("fs");
2
+ const os = require("os");
3
+ const path = require("path");
4
+ const { runSilent } = require("./platform");
5
+ const { DEFAULT_PKG } = require("./skills");
6
+
7
+ const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
8
+
9
+ function defaultCacheFile() {
10
+ return path.join(os.homedir(), ".pippit-cli", "version-check.json");
11
+ }
12
+
13
+ function currentVersion() {
14
+ return require("../package.json").version.replace(/-.*$/, "");
15
+ }
16
+
17
+ function parseSemver(version) {
18
+ const match = String(version || "").trim().match(/^v?(\d+)\.(\d+)\.(\d+)/);
19
+ if (!match) return null;
20
+ return match.slice(1).map(Number);
21
+ }
22
+
23
+ function compareSemver(a, b) {
24
+ const parsedA = parseSemver(a);
25
+ const parsedB = parseSemver(b);
26
+ if (!parsedA || !parsedB) return 0;
27
+ for (let i = 0; i < 3; i++) {
28
+ const diff = parsedA[i] - parsedB[i];
29
+ if (diff !== 0) return diff;
30
+ }
31
+ return 0;
32
+ }
33
+
34
+ function readCache(cacheFile) {
35
+ try {
36
+ return JSON.parse(fs.readFileSync(cacheFile, "utf8"));
37
+ } catch (_) {
38
+ return null;
39
+ }
40
+ }
41
+
42
+ function writeCache(cacheFile, data) {
43
+ try {
44
+ fs.mkdirSync(path.dirname(cacheFile), { recursive: true });
45
+ fs.writeFileSync(cacheFile, JSON.stringify(data), "utf8");
46
+ } catch (_) {
47
+ // Version checks must never block normal CLI commands.
48
+ }
49
+ }
50
+
51
+ function fetchLatestVersion(pkg = DEFAULT_PKG) {
52
+ return runSilent("npm", ["view", pkg, "version"], { timeout: 3000 }).toString().trim();
53
+ }
54
+
55
+ function shouldSkip(args, env) {
56
+ const cmd = args[0];
57
+ return (
58
+ env.PIPPIT_CLI_DISABLE_UPDATE_CHECK === "1" ||
59
+ env.CI ||
60
+ cmd === "install" ||
61
+ cmd === "update"
62
+ );
63
+ }
64
+
65
+ function maybeWarnNewVersion(args = [], opts = {}) {
66
+ const env = opts.env || process.env;
67
+ if (shouldSkip(args, env)) return;
68
+
69
+ const now = opts.now || Date.now();
70
+ const cacheFile = opts.cacheFile || defaultCacheFile();
71
+ const cache = readCache(cacheFile);
72
+ const cacheFresh = cache && now - cache.checkedAt < CHECK_INTERVAL_MS;
73
+
74
+ let latest = cacheFresh ? cache.latest : "";
75
+ if (!latest) {
76
+ try {
77
+ latest = (opts.fetchLatestVersion || fetchLatestVersion)(opts.pkg || DEFAULT_PKG);
78
+ writeCache(cacheFile, { latest, checkedAt: now });
79
+ } catch (_) {
80
+ return;
81
+ }
82
+ }
83
+
84
+ const current = opts.currentVersion || currentVersion();
85
+ if (compareSemver(latest, current) <= 0) return;
86
+
87
+ const warn = opts.warn || console.error;
88
+ warn(`[pippit-cli] New version available: ${current} -> ${latest}. Run: pippit-cli update`);
89
+ }
90
+
91
+ module.exports = {
92
+ CHECK_INTERVAL_MS,
93
+ compareSemver,
94
+ maybeWarnNewVersion,
95
+ parseSemver,
96
+ };