create-zfb 0.1.0-next.7 → 0.1.0-next.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/README.md CHANGED
@@ -11,3 +11,5 @@ npm create zfb@latest my-site
11
11
  ```
12
12
 
13
13
  This creates a new project directory `my-site/` bootstrapped from the built-in `basic-blog` template. For full documentation, configuration options, and CLI reference, see the [`@takazudo/zfb` docs](https://takazudomodular.com/pj/zudo-front-builder/).
14
+
15
+ > **pnpm 11 note:** pnpm 11's `minimumReleaseAge` may install a previous release of `create-zfb` within ~48h of any new release. If `create-zfb` warns about a stale install at startup, re-run with `pnpm create zfb@latest --config.minimumReleaseAge=0` or `npm create zfb@latest`.
@@ -5,6 +5,61 @@ import { dirname, join } from "node:path";
5
5
 
6
6
  const require = createRequire(import.meta.url);
7
7
 
8
+ // Returns -1 if a < b, 0 if a === b, 1 if a > b.
9
+ // Handles prerelease suffixes: 0.1.0-next.6 < 0.1.0-next.8 < 0.1.0
10
+ function compareSemver(a, b) {
11
+ const splitRelease = (v) => {
12
+ const [main, pre] = v.split(/-(.+)/, 2);
13
+ return { parts: main.split(".").map(Number), pre: pre ?? null };
14
+ };
15
+ const ra = splitRelease(a);
16
+ const rb = splitRelease(b);
17
+ for (let i = 0; i < Math.max(ra.parts.length, rb.parts.length); i++) {
18
+ const pa = ra.parts[i] ?? 0;
19
+ const pb = rb.parts[i] ?? 0;
20
+ if (pa !== pb) return pa < pb ? -1 : 1;
21
+ }
22
+ // same numeric parts — prerelease is less than no prerelease (semver rule)
23
+ if (ra.pre !== null && rb.pre === null) return -1;
24
+ if (ra.pre === null && rb.pre !== null) return 1;
25
+ if (ra.pre !== null && rb.pre !== null) {
26
+ if (ra.pre < rb.pre) return -1;
27
+ if (ra.pre > rb.pre) return 1;
28
+ }
29
+ return 0;
30
+ }
31
+
32
+ try {
33
+ const ownPkg = require("../package.json");
34
+ const version = ownPkg.version;
35
+ const controller = new AbortController();
36
+ const timer = setTimeout(() => controller.abort(), 1500);
37
+ const res = await fetch("https://registry.npmjs.org/create-zfb/latest", {
38
+ signal: controller.signal,
39
+ headers: {
40
+ "User-Agent": `create-zfb/${version}`,
41
+ Accept: "application/json",
42
+ },
43
+ });
44
+ clearTimeout(timer);
45
+ if (res.ok) {
46
+ const data = await res.json();
47
+ const latest = data?.version;
48
+ if (typeof latest === "string" && typeof version === "string") {
49
+ if (compareSemver(version, latest) < 0) {
50
+ process.stderr.write(
51
+ `[create-zfb] You are running create-zfb@${version} but @latest is ${latest}.\n` +
52
+ `[create-zfb] pnpm 11's minimumReleaseAge may have downgraded the install.\n` +
53
+ `[create-zfb] Re-run with: pnpm create zfb@latest --config.minimumReleaseAge=0\n` +
54
+ `[create-zfb] Or use: npm create zfb@latest\n`,
55
+ );
56
+ }
57
+ }
58
+ }
59
+ } catch {
60
+ // silently skip on any error: network failure, timeout (AbortError), parse error, etc.
61
+ }
62
+
8
63
  const zfbPkgJson = require.resolve("@takazudo/zfb/package.json");
9
64
  const zfbBin = join(dirname(zfbPkgJson), "bin", "zfb.mjs");
10
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-zfb",
3
- "version": "0.1.0-next.7",
3
+ "version": "0.1.0-next.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Scaffold a new zfb static-site project: `npm create zfb@latest my-site`",
@@ -31,7 +31,10 @@
31
31
  "CHANGELOG.md",
32
32
  "LICENSE"
33
33
  ],
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
34
37
  "dependencies": {
35
- "@takazudo/zfb": "0.1.0-next.7"
38
+ "@takazudo/zfb": "0.1.0-next.9"
36
39
  }
37
40
  }