create-kedge 0.9.0 → 0.10.0
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/package.json +4 -1
- package/src/create.mjs +36 -1
- package/template.json +1 -1
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-kedge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/chandeldivyam/Kedge.git",
|
|
8
8
|
"directory": "packages/create-kedge"
|
|
9
9
|
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=24"
|
|
12
|
+
},
|
|
10
13
|
"type": "module",
|
|
11
14
|
"description": "npx create-kedge my-store: a new Kedge store from the starter.",
|
|
12
15
|
"bin": {
|
package/src/create.mjs
CHANGED
|
@@ -71,9 +71,33 @@ export function write(dir, files) {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* The oldest Node and pnpm a store is tested on (p0.10 §3): `kedge generate`
|
|
76
|
+
* reads with `node:sqlite` (D-039), and the template's pnpm-workspace.yaml
|
|
77
|
+
* relies on `allowBuilds` to let workerd and esbuild fetch their binaries. The
|
|
78
|
+
* clean-machine run is what proves these; every package's `engines.node` says the same.
|
|
79
|
+
*/
|
|
80
|
+
export const MIN_NODE = 24;
|
|
81
|
+
export const MIN_PNPM = 11;
|
|
82
|
+
|
|
83
|
+
/** What this machine lacks, with the one command that fixes it; null when nothing. */
|
|
84
|
+
export function environmentProblem({ node, pnpm, install }) {
|
|
85
|
+
const major = (v) => Number(/^v?(\d+)\./.exec(v ?? "")?.[1] ?? 0);
|
|
86
|
+
if (major(node) < MIN_NODE)
|
|
87
|
+
return `Kedge needs Node ${MIN_NODE} or newer, and this is ${node}: install it from https://nodejs.org (or \`nvm install ${MIN_NODE}\`), then run this again`;
|
|
88
|
+
if (!install) return null;
|
|
89
|
+
if (!pnpm) return `Kedge stores install with pnpm, which isn't on the path: run \`npm install --global pnpm@${MIN_PNPM}\`, then run this again`;
|
|
90
|
+
if (major(pnpm) < MIN_PNPM)
|
|
91
|
+
return `Kedge needs pnpm ${MIN_PNPM} or newer, and this is ${pnpm}: run \`npm install --global pnpm@${MIN_PNPM}\`, then run this again`;
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
74
95
|
const USAGE = `usage: create-kedge <directory> [--name <name>] [--from-packs <dir>] [--no-install] [--no-git]`;
|
|
75
96
|
|
|
76
|
-
export function main(
|
|
97
|
+
export function main(
|
|
98
|
+
argv,
|
|
99
|
+
{ template, run = spawnSync, log = console.log, error = console.error, node = process.versions.node } = {},
|
|
100
|
+
) {
|
|
77
101
|
const flags = new Set(argv.filter((a) => a.startsWith("--no-")));
|
|
78
102
|
const value = (f) => {
|
|
79
103
|
const i = argv.indexOf(f);
|
|
@@ -85,6 +109,17 @@ export function main(argv, { template, run = spawnSync, log = console.log, error
|
|
|
85
109
|
error(USAGE);
|
|
86
110
|
return 2;
|
|
87
111
|
}
|
|
112
|
+
// Before anything is written: a half-made store on a machine that can't install it helps no one.
|
|
113
|
+
const pnpm = flags.has("--no-install") ? null : run("pnpm", ["--version"], { encoding: "utf8" });
|
|
114
|
+
const problem = environmentProblem({
|
|
115
|
+
node,
|
|
116
|
+
pnpm: pnpm?.status === 0 ? String(pnpm.stdout ?? "").trim() : null,
|
|
117
|
+
install: !flags.has("--no-install"),
|
|
118
|
+
});
|
|
119
|
+
if (problem) {
|
|
120
|
+
error(problem);
|
|
121
|
+
return 1;
|
|
122
|
+
}
|
|
88
123
|
const dir = resolve(target);
|
|
89
124
|
if (existsSync(dir) && readdirSync(dir).length > 0) {
|
|
90
125
|
error(`${dir} isn't empty`);
|