create-zfb 0.1.0-next.3 → 0.1.0-next.30

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
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ > **Newer releases:** see https://takazudomodular.com/pj/zudo-front-builder/docs/changelog/ for v0.1.0-next.5 and later. Entries below are historical (kept for npm readers).
4
+
5
+ ## 0.1.0-next.4
6
+
7
+ Scaffolded projects now pin to the exact CLI version (`=<ver>` instead of `^<ver>`) in the generated `package.json`. This is a meaningful behavior change: previously `npm create zfb@latest` could silently resolve a compatible stable release once `0.1.0` lands; the exact pin prevents that. See #343.
8
+
3
9
  ## 0.1.0-next.1
4
10
 
5
11
  Initial public prerelease on npm.
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,90 @@ 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
+ // Drop SemVer build metadata (`+...`) before splitting — it is ignored
13
+ // for precedence and would otherwise yield NaN numeric parts.
14
+ const [main, pre] = v.split("+")[0].split(/-(.+)/, 2);
15
+ return { parts: main.split(".").map(Number), pre: pre ?? null };
16
+ };
17
+ const ra = splitRelease(a);
18
+ const rb = splitRelease(b);
19
+ for (let i = 0; i < Math.max(ra.parts.length, rb.parts.length); i++) {
20
+ const pa = ra.parts[i] ?? 0;
21
+ const pb = rb.parts[i] ?? 0;
22
+ if (pa !== pb) return pa < pb ? -1 : 1;
23
+ }
24
+ // same numeric parts — prerelease is less than no prerelease (semver rule)
25
+ if (ra.pre !== null && rb.pre === null) return -1;
26
+ if (ra.pre === null && rb.pre !== null) return 1;
27
+ if (ra.pre !== null && rb.pre !== null) {
28
+ // Compare dot-separated prerelease identifiers per semver: numeric
29
+ // identifiers compare numerically (so next.9 < next.10), numeric ranks
30
+ // below alphanumeric, and a shorter prefix ranks lower. Plain string
31
+ // `<`/`>` would order next.10 before next.9 lexicographically.
32
+ const sa = ra.pre.split(".");
33
+ const sb = rb.pre.split(".");
34
+ for (let i = 0; i < Math.max(sa.length, sb.length); i++) {
35
+ if (sa[i] === undefined) return -1;
36
+ if (sb[i] === undefined) return 1;
37
+ const na = /^\d+$/.test(sa[i]);
38
+ const nb = /^\d+$/.test(sb[i]);
39
+ if (na && nb) {
40
+ const da = Number(sa[i]);
41
+ const db = Number(sb[i]);
42
+ if (da !== db) return da < db ? -1 : 1;
43
+ } else if (na !== nb) {
44
+ return na ? -1 : 1;
45
+ } else if (sa[i] !== sb[i]) {
46
+ return sa[i] < sb[i] ? -1 : 1;
47
+ }
48
+ }
49
+ }
50
+ return 0;
51
+ }
52
+
53
+ try {
54
+ const ownPkg = require("../package.json");
55
+ const version = ownPkg.version;
56
+ const controller = new AbortController();
57
+ const timer = setTimeout(() => controller.abort(), 1500);
58
+ let res;
59
+ try {
60
+ res = await fetch("https://registry.npmjs.org/create-zfb/latest", {
61
+ signal: controller.signal,
62
+ headers: {
63
+ "User-Agent": `create-zfb/${version}`,
64
+ Accept: "application/json",
65
+ },
66
+ });
67
+ if (res.ok) {
68
+ const data = await res.json();
69
+ const latest = data?.version;
70
+ if (typeof latest === "string" && typeof version === "string") {
71
+ if (compareSemver(version, latest) < 0) {
72
+ process.stderr.write(
73
+ `[create-zfb] You are running create-zfb@${version} but @latest is ${latest}.\n` +
74
+ `[create-zfb] pnpm 11's minimumReleaseAge may have downgraded the install.\n` +
75
+ `[create-zfb] Re-run with: pnpm create zfb@latest --config.minimumReleaseAge=0\n` +
76
+ `[create-zfb] Or use: npm create zfb@latest\n`,
77
+ );
78
+ }
79
+ }
80
+ }
81
+ } finally {
82
+ // Keep the abort signal armed across both the header and body reads.
83
+ // Only cancel the timer once the body has been fully consumed (or on
84
+ // any error path), so a proxy that stalls after headers cannot hang
85
+ // the scaffolder indefinitely.
86
+ clearTimeout(timer);
87
+ }
88
+ } catch {
89
+ // silently skip on any error: network failure, timeout (AbortError), parse error, etc.
90
+ }
91
+
8
92
  const zfbPkgJson = require.resolve("@takazudo/zfb/package.json");
9
93
  const zfbBin = join(dirname(zfbPkgJson), "bin", "zfb.mjs");
10
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-zfb",
3
- "version": "0.1.0-next.3",
3
+ "version": "0.1.0-next.30",
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.3"
38
+ "@takazudo/zfb": "0.1.0-next.30"
36
39
  }
37
40
  }