create-zfb 0.1.0-next.25 → 0.1.0-next.27
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/bin/create-zfb.mjs +51 -22
- package/package.json +2 -2
package/bin/create-zfb.mjs
CHANGED
|
@@ -9,7 +9,9 @@ const require = createRequire(import.meta.url);
|
|
|
9
9
|
// Handles prerelease suffixes: 0.1.0-next.6 < 0.1.0-next.8 < 0.1.0
|
|
10
10
|
function compareSemver(a, b) {
|
|
11
11
|
const splitRelease = (v) => {
|
|
12
|
-
|
|
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);
|
|
13
15
|
return { parts: main.split(".").map(Number), pre: pre ?? null };
|
|
14
16
|
};
|
|
15
17
|
const ra = splitRelease(a);
|
|
@@ -23,8 +25,27 @@ function compareSemver(a, b) {
|
|
|
23
25
|
if (ra.pre !== null && rb.pre === null) return -1;
|
|
24
26
|
if (ra.pre === null && rb.pre !== null) return 1;
|
|
25
27
|
if (ra.pre !== null && rb.pre !== null) {
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
}
|
|
28
49
|
}
|
|
29
50
|
return 0;
|
|
30
51
|
}
|
|
@@ -34,27 +55,35 @@ try {
|
|
|
34
55
|
const version = ownPkg.version;
|
|
35
56
|
const controller = new AbortController();
|
|
36
57
|
const timer = setTimeout(() => controller.abort(), 1500);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
`[create-zfb]
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
}
|
|
56
79
|
}
|
|
57
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);
|
|
58
87
|
}
|
|
59
88
|
} catch {
|
|
60
89
|
// silently skip on any error: network failure, timeout (AbortError), parse error, etc.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-zfb",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.27",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Scaffold a new zfb static-site project: `npm create zfb@latest my-site`",
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"node": ">=18"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@takazudo/zfb": "0.1.0-next.
|
|
38
|
+
"@takazudo/zfb": "0.1.0-next.27"
|
|
39
39
|
}
|
|
40
40
|
}
|