create-zfb 0.1.0-next.25 → 0.1.0-next.26
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 +24 -3
- 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
|
}
|
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.26",
|
|
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.26"
|
|
39
39
|
}
|
|
40
40
|
}
|