create-dormer 0.0.0-stage → 0.1.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/README.md +15 -2
- package/bin/create-dormer.mjs +46 -0
- package/package.json +21 -4
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-dormer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`npm create dormer my-app -- --template react` scaffolds a Dormer desktop application and installs its
|
|
4
|
+
dependencies. Templates: `vanilla`, `react`, `vue`, `svelte`. The native host binary arrives through
|
|
5
|
+
`@dormer/cli`'s optional dependency on the prebuilt `@dormer/host-<platform>-<arch>` package for your
|
|
6
|
+
platform, so no Rust toolchain is needed.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm create dormer my-app -- --template react
|
|
10
|
+
cd my-app
|
|
11
|
+
npm run dev # Vite with HMR + the Node.js backend + a native window
|
|
12
|
+
npm run package # installers through dormer-bundle (@dormer/bundle-<platform>-<arch>)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The wrapper runs `dormer create` from `@dormer/cli` and then `npm install` (or the package manager that
|
|
16
|
+
invoked it: pnpm, yarn, bun). `--no-install` skips the install step.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// `npm create dormer <dir> -- --template react` (also `npx create-dormer`, `pnpm create dormer`,
|
|
3
|
+
// `yarn create dormer`). Thin wrapper: runs `dormer create` from the @dormer/cli this package depends on,
|
|
4
|
+
// then installs the new app's dependencies with the package manager that invoked us.
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
|
|
10
|
+
// @dormer/cli has an exports map; resolve its package root through "./package.json" (exported) with a
|
|
11
|
+
// fallback through the main entry (<pkg>/src/index.ts) for older copies.
|
|
12
|
+
function cliPackageDir() {
|
|
13
|
+
try { return path.dirname(fileURLToPath(import.meta.resolve("@dormer/cli/package.json"))); }
|
|
14
|
+
catch { return path.dirname(path.dirname(fileURLToPath(import.meta.resolve("@dormer/cli")))); }
|
|
15
|
+
}
|
|
16
|
+
const cliBin = path.join(cliPackageDir(), "bin", "dormer.mjs");
|
|
17
|
+
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
if (args.length === 0 || args.includes("-h") || args.includes("--help")) {
|
|
20
|
+
console.log(`usage: npm create dormer <dir> -- [--template vanilla|react|vue|svelte] [--no-install]
|
|
21
|
+
|
|
22
|
+
Creates a Dormer desktop app: a Node.js backend (src/main.ts, @dormer/api), a Vite renderer
|
|
23
|
+
(renderer/, @dormer/renderer) and dormer.config.json, then installs dependencies.
|
|
24
|
+
Next: cd <dir> && npm run dev`);
|
|
25
|
+
process.exit(args.length === 0 ? 64 : 0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const install = !args.includes("--no-install");
|
|
29
|
+
const cliArgs = args.filter((a) => a !== "--no-install");
|
|
30
|
+
if (!cliArgs.some((a) => a === "--template" || a.startsWith("--template="))) cliArgs.push("--template", "react");
|
|
31
|
+
|
|
32
|
+
// npm_config_user_agent tells us which package manager ran `create`; mirror it for the install step.
|
|
33
|
+
const ua = process.env.npm_config_user_agent ?? "";
|
|
34
|
+
const pm = ua.startsWith("pnpm") ? "pnpm" : ua.startsWith("yarn") ? "yarn" : ua.startsWith("bun") ? "bun" : "npm";
|
|
35
|
+
if (!cliArgs.includes("--pm")) cliArgs.push("--pm", pm);
|
|
36
|
+
|
|
37
|
+
const created = spawnSync(process.execPath, [cliBin, "create", ...cliArgs], { stdio: "inherit" });
|
|
38
|
+
if (created.status !== 0) process.exit(created.status ?? 1);
|
|
39
|
+
|
|
40
|
+
const dir = cliArgs.find((a) => !a.startsWith("-") && !["vanilla", "react", "vue", "svelte", pm].includes(a));
|
|
41
|
+
if (install && dir && existsSync(dir)) {
|
|
42
|
+
console.log(`\n[create-dormer] installing dependencies with ${pm}…`);
|
|
43
|
+
const installed = spawnSync(pm, ["install"], { cwd: dir, stdio: "inherit", shell: process.platform === "win32" });
|
|
44
|
+
if (installed.status !== 0) process.exit(installed.status ?? 1);
|
|
45
|
+
console.log(`\n[create-dormer] done. Next:\n cd ${dir}\n ${pm === "npm" ? "npm run" : pm} dev`);
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-dormer",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "npm create dormer: scaffold a Dormer desktop app (Node.js backend + system WebView) from a template",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0 OR MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-dormer": "bin/create-dormer.mjs"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@dormer/cli": "0.1.0"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22.6"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
}
|
|
23
|
+
}
|