@homepages/create-workspace 0.9.0 → 0.9.1

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/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // `npm create @homepages/workspace <name>` — stamp a workspace container: shared
3
3
  // root context + one working starter template, then install and git-init.
4
4
  import { execFileSync } from "node:child_process";
5
- import { existsSync, readFileSync, realpathSync } from "node:fs";
5
+ import { existsSync, realpathSync } from "node:fs";
6
6
  import { mkdir } from "node:fs/promises";
7
7
  import { dirname, join, resolve } from "node:path";
8
8
  import { createInterface } from "node:readline/promises";
@@ -10,6 +10,14 @@ import { fileURLToPath } from "node:url";
10
10
  import { stampTree } from "./stamp.js";
11
11
  const ASSETS = join(dirname(fileURLToPath(import.meta.url)), "..", "scaffold");
12
12
  const NAME_RE = /^[a-z][a-z0-9-]*$/;
13
+ /**
14
+ * The kit's caret pin. The kit versions independently of this scaffolder, so
15
+ * it cannot be derived from this package's own version and is a committed
16
+ * constant — same reasoning as ESLINT_PLUGIN_VERSION below — bumped when the
17
+ * kit releases a new minor. A scaffolded workspace pinned to a stale range
18
+ * never picks up the kit's current contract.
19
+ */
20
+ const KIT_VERSION = "0.9.0";
13
21
  /**
14
22
  * The authoring ESLint preset's caret pin. Unlike the kit it cannot be derived from
15
23
  * this package's own version — @homepages/eslint-plugin-template versions
@@ -28,13 +36,33 @@ const ESLINT_PLUGIN_VERSION = "0.1.0";
28
36
  * "command not found", which reads as a broken scaffold rather than a missing pin.
29
37
  */
30
38
  const TEMPLATE_CLI_VERSION = "0.1.0";
39
+ /**
40
+ * The dev media pack's caret pin. Same committed-constant reasoning as the pins
41
+ * above — the pack versions independently of this scaffolder.
42
+ *
43
+ * The pack is what the `dev` server serves asset BYTES from: the kit carries only
44
+ * the manifest (copied into its dist at build time), so a workspace without this
45
+ * dependency has an index of media it cannot resolve a single pixel of, and every
46
+ * fixture image renders broken.
47
+ *
48
+ * It is a devDependency, not a dependency: media is dev-time authoring content, in
49
+ * the same category as vite and the rest of the toolchain, and nothing in a packed
50
+ * template references it.
51
+ *
52
+ * This range must cover the pack's actual published version on npm, or a
53
+ * scaffolded workspace outside this monorepo dies on `npm install` with a 404 —
54
+ * the drift guard in `src/index.test.ts` (the stamped dev-media range covers the
55
+ * pack's actual version) fails the moment this constant falls behind a real bump.
56
+ */
57
+ const DEV_MEDIA_VERSION = "0.0.0";
31
58
  export async function scaffoldWorkspace(name, targetDir, opts) {
32
59
  await mkdir(targetDir, { recursive: true });
33
60
  await stampTree(join(ASSETS, "workspace"), targetDir, {
34
61
  WORKSPACE_NAME: name,
35
- KIT_VERSION: opts.kitVersion,
62
+ KIT_VERSION: opts.kitVersion ?? KIT_VERSION,
36
63
  ESLINT_PLUGIN_VERSION: opts.eslintPluginVersion ?? ESLINT_PLUGIN_VERSION,
37
64
  TEMPLATE_CLI_VERSION: opts.templateCliVersion ?? TEMPLATE_CLI_VERSION,
65
+ DEV_MEDIA_VERSION: opts.devMediaVersion ?? DEV_MEDIA_VERSION,
38
66
  });
39
67
  await stampTree(join(ASSETS, "template"), join(targetDir, "templates", "starter"), {
40
68
  TEMPLATE_KEY: "starter",
@@ -45,17 +73,6 @@ export async function scaffoldWorkspace(name, targetDir, opts) {
45
73
  if (opts.install !== false)
46
74
  execFileSync("npm", ["install"], { cwd: targetDir, stdio: "inherit" });
47
75
  }
48
- /**
49
- * The kit version to caret-pin: this scaffolder is published version-synced
50
- * with the kit, so its own `version` IS the kit version. Read at runtime
51
- * (rather than a static JSON import) because `../package.json` sits outside
52
- * `rootDir: "src"` and trips TS6059 under a static import.
53
- */
54
- function kitVersion() {
55
- const raw = readFileSync(new URL("../package.json", import.meta.url), "utf8");
56
- const pkg = JSON.parse(raw);
57
- return typeof pkg.version === "string" ? pkg.version : "0.0.0";
58
- }
59
76
  async function promptName() {
60
77
  const rl = createInterface({ input: process.stdin, output: process.stdout });
61
78
  try {
@@ -77,7 +94,7 @@ async function main() {
77
94
  process.stderr.write(`create-workspace: ${name}/ already exists.\n`);
78
95
  return 1;
79
96
  }
80
- await scaffoldWorkspace(name, targetDir, { kitVersion: kitVersion() });
97
+ await scaffoldWorkspace(name, targetDir, {});
81
98
  process.stdout.write(`\nCreated ${name}/\n\n` +
82
99
  ` cd ${name}\n` +
83
100
  ` npm run dev # preview the starter (the island hydrates)\n` +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homepages/create-workspace",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Scaffold a HomePages template workspace.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -13,6 +13,7 @@
13
13
  "react-dom": "^19.0.0"
14
14
  },
15
15
  "devDependencies": {
16
+ "@homepages/dev-media": "^{{DEV_MEDIA_VERSION}}",
16
17
  "@homepages/eslint-plugin-template": "^{{ESLINT_PLUGIN_VERSION}}",
17
18
  "@homepages/template-cli": "^{{TEMPLATE_CLI_VERSION}}",
18
19
  "@tailwindcss/cli": "^4.3.0",