create-start-serenojs 0.0.0-stage → 0.1.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.
Files changed (32) hide show
  1. package/README.md +129 -2
  2. package/dist/args.d.ts +14 -0
  3. package/dist/args.js +54 -0
  4. package/dist/banner.d.ts +1 -0
  5. package/dist/banner.js +18 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +244 -0
  8. package/dist/pm.d.ts +9 -0
  9. package/dist/pm.js +17 -0
  10. package/dist/template.d.ts +12 -0
  11. package/dist/template.js +92 -0
  12. package/package.json +49 -3
  13. package/templates/starter/.agents/skills/serenojs-schema/SKILL.md +165 -0
  14. package/templates/starter/.agents/skills/serenojs-schema/assets/collection.template.ts +27 -0
  15. package/templates/starter/.agents/skills/serenojs-schema/references/fields.md +121 -0
  16. package/templates/starter/README.md +190 -0
  17. package/templates/starter/gitignore +11 -0
  18. package/templates/starter/package.json +33 -0
  19. package/templates/starter/public/.gitkeep +0 -0
  20. package/templates/starter/serenojs.config.ts +33 -0
  21. package/templates/starter/src/global.d.ts +1 -0
  22. package/templates/starter/src/middleware/no-trailing-slash.ts +14 -0
  23. package/templates/starter/src/middleware/serenojs.ts +9 -0
  24. package/templates/starter/src/pages/_layout.tsx +13 -0
  25. package/templates/starter/src/pages/index.tsx +319 -0
  26. package/templates/starter/src/pages.gen.ts +23 -0
  27. package/templates/starter/src/schemas/index.ts +17 -0
  28. package/templates/starter/src/schemas/locales.ts +27 -0
  29. package/templates/starter/src/schemas/todos.ts +38 -0
  30. package/templates/starter/src/styles.css +741 -0
  31. package/templates/starter/tsconfig.json +32 -0
  32. package/templates/starter/waku.config.ts +20 -0
package/README.md CHANGED
@@ -1,3 +1,130 @@
1
- # Temporary Holding Version
1
+ # create-start-serenojs
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Scaffold a [SerenoJS](https://github.com/eutobias/serenojs) project —
4
+ Waku + `@eutobias/serenojs` + SQLite, with the admin panel, REST API, auth,
5
+ media uploads and backups already wired up.
6
+
7
+ ## Usage
8
+
9
+ ```sh
10
+ npm create start-serenojs@latest my-app
11
+ # or
12
+ pnpm create start-serenojs my-app
13
+ # or
14
+ yarn create start-serenojs my-app
15
+ # or
16
+ bun create start-serenojs my-app
17
+ ```
18
+
19
+ You can also run the binary directly:
20
+
21
+ ```sh
22
+ npx create-start-serenojs my-app
23
+ ```
24
+
25
+ Omit the directory to be prompted for one:
26
+
27
+ ```sh
28
+ npm create start-serenojs@latest
29
+ ```
30
+
31
+ After scaffolding:
32
+
33
+ ```sh
34
+ cd my-app
35
+ pnpm dev
36
+ ```
37
+
38
+ Open <http://localhost:3000/admin> and sign in with
39
+ `admin@example.com` / `admin123`.
40
+
41
+ ## Options
42
+
43
+ | Option | Effect |
44
+ | --- | --- |
45
+ | `-h`, `--help` | Show help |
46
+ | `-v`, `--version` | Show the version |
47
+ | `-y`, `--yes` | Accept all defaults, never prompt |
48
+ | `--no-install` | Copy the template without installing dependencies |
49
+ | `--no-git` | Do not initialize a git repository |
50
+ | `--pm <name>` | Force the package manager: `pnpm`, `npm`, `yarn` or `bun` |
51
+
52
+ The package manager is detected from the command that invoked the CLI
53
+ (`npm_config_user_agent`), falling back to `pnpm`. `--pm` overrides it.
54
+
55
+ When `--yes` is used, a directory argument is required — the CLI never writes
56
+ into the current directory implicitly.
57
+
58
+ ## What gets created
59
+
60
+ ```
61
+ my-app/
62
+ serenojs.config.ts
63
+ waku.config.ts
64
+ tsconfig.json
65
+ .agents/
66
+ skills/ # coding-agent skills (e.g. serenojs-schema)
67
+ src/
68
+ schemas/ # todos example collection + locales
69
+ middleware/ # mounts the SerenoJS Hono app
70
+ pages/ # todos example app
71
+ styles.css # example app styles
72
+ public/
73
+ README.md
74
+ ```
75
+
76
+ The generated `package.json` uses the published `@eutobias/serenojs` range;
77
+ legacy `workspace:` specs are still normalized when present.
78
+
79
+ If a git repository is requested, the CLI runs `git init`, stages the files and
80
+ attempts an initial commit. The commit is skipped silently when git user
81
+ configuration is missing — the repository is still initialized.
82
+
83
+ ## Template
84
+
85
+ The template lives in [`templates/starter`](./templates/starter) and is the
86
+ single source of truth for the starter app — it is not copied from another
87
+ directory. The same folder is a pnpm workspace package (`serenojs-starter`) so
88
+ it can be developed and built in this repository.
89
+
90
+ The starter includes a small example app (todos CRUD) that consumes the public
91
+ REST API. You are free to use any component library or styling solution; the
92
+ admin panel brings its own bundled styles and is not affected by the host app.
93
+
94
+ Template-only files:
95
+
96
+ - `gitignore` is renamed to `.gitignore` on scaffold (npm strips dotfiles
97
+ named `.gitignore` from published packages).
98
+ - `.npmignore` and build/runtime artifacts (`.data`, `dist`, `node_modules`,
99
+ `public/files`, `.waku`) are never copied.
100
+ - `.agents/skills/` is copied as-is, so generated projects ship the same agent
101
+ skills (currently `serenojs-schema`).
102
+
103
+ ## Development
104
+
105
+ ```sh
106
+ pnpm install
107
+ pnpm build:create # compile src -> dist
108
+ node packages/create-start-serenojs/dist/index.js --help
109
+ pnpm --filter create-start-serenojs test
110
+ ```
111
+
112
+ To exercise the template in this repository:
113
+
114
+ ```sh
115
+ pnpm dev # builds the package + admin, runs the starter
116
+ ```
117
+
118
+ ## Publishing
119
+
120
+ ```sh
121
+ pnpm pack:create # build + tarball, for inspection
122
+ pnpm publish:create # build + publish to npm
123
+ ```
124
+
125
+ Both scripts live in the monorepo root. `prepack` builds `dist/`
126
+ automatically. The published tarball contains `dist/`, the template and this
127
+ README.
128
+
129
+ Publish `@eutobias/serenojs` first: the template depends on the published
130
+ version (`^0.1.1` after the scaffold rewrite).
package/dist/args.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { type PackageManager } from "./pm.js";
2
+ export declare class UsageError extends Error {
3
+ }
4
+ export type CliOptions = {
5
+ help: boolean;
6
+ version: boolean;
7
+ directory: string | undefined;
8
+ yes: boolean;
9
+ install: boolean;
10
+ git: boolean;
11
+ pm: PackageManager | undefined;
12
+ };
13
+ export declare const HELP = "create-start-serenojs\n\nScaffold a SerenoJS project (Waku + @eutobias/serenojs + SQLite).\n\nUsage:\n create-start-serenojs [directory] [options]\n\nOptions:\n -h, --help Show this help\n -v, --version Show the version\n -y, --yes Accept all defaults (no prompts)\n --no-install Skip dependency installation\n --no-git Skip git initialization\n --pm <name> Force a package manager: pnpm, npm, yarn or bun\n";
14
+ export declare function parseCliArgs(argv: string[]): CliOptions;
package/dist/args.js ADDED
@@ -0,0 +1,54 @@
1
+ import { parseArgs } from "node:util";
2
+ import { isPackageManager } from "./pm.js";
3
+ export class UsageError extends Error {
4
+ }
5
+ export const HELP = `create-start-serenojs
6
+
7
+ Scaffold a SerenoJS project (Waku + @eutobias/serenojs + SQLite).
8
+
9
+ Usage:
10
+ create-start-serenojs [directory] [options]
11
+
12
+ Options:
13
+ -h, --help Show this help
14
+ -v, --version Show the version
15
+ -y, --yes Accept all defaults (no prompts)
16
+ --no-install Skip dependency installation
17
+ --no-git Skip git initialization
18
+ --pm <name> Force a package manager: pnpm, npm, yarn or bun
19
+ `;
20
+ export function parseCliArgs(argv) {
21
+ const { values, positionals } = parseArgs({
22
+ args: argv,
23
+ options: {
24
+ help: { type: "boolean", short: "h", default: false },
25
+ version: { type: "boolean", short: "v", default: false },
26
+ yes: { type: "boolean", short: "y", default: false },
27
+ "no-install": { type: "boolean", default: false },
28
+ "no-git": { type: "boolean", default: false },
29
+ pm: { type: "string" },
30
+ },
31
+ allowPositionals: true,
32
+ strict: true,
33
+ });
34
+ if (positionals.length > 1) {
35
+ throw new UsageError("Please provide a single project directory.");
36
+ }
37
+ let pm;
38
+ const pmValue = values.pm;
39
+ if (pmValue !== undefined) {
40
+ if (!isPackageManager(pmValue)) {
41
+ throw new UsageError(`Unknown package manager "${pmValue}". Use pnpm, npm, yarn or bun.`);
42
+ }
43
+ pm = pmValue;
44
+ }
45
+ return {
46
+ help: values.help,
47
+ version: values.version,
48
+ directory: positionals[0],
49
+ yes: values.yes,
50
+ install: !values["no-install"],
51
+ git: !values["no-git"],
52
+ pm,
53
+ };
54
+ }
@@ -0,0 +1 @@
1
+ export declare function printBanner(): void;
package/dist/banner.js ADDED
@@ -0,0 +1,18 @@
1
+ import pc from "picocolors";
2
+ /**
3
+ * Hand-drawn ANSI Shadow wordmark. Kept as a literal so the CLI has a visual
4
+ * identity without pulling in a font/figlet dependency.
5
+ */
6
+ const LOGO = [
7
+ "███████╗███████╗██████╗ ███████╗███╗ ██╗ ██████╗ ██╗███████╗",
8
+ "██╔════╝██╔════╝██╔══██╗██╔════╝████╗ ██║██╔═══██╗ ██║██╔════╝",
9
+ "███████╗█████╗ ██████╔╝█████╗ ██╔██╗ ██║██║ ██║ ██║███████╗",
10
+ "╚════██║██╔══╝ ██╔══██╗██╔══╝ ██║╚██╗██║██║ ██║██ ██║╚════██║",
11
+ "███████║███████╗██║ ██║███████╗██║ ╚████║╚██████╔╝╚█████╔╝███████║",
12
+ "╚══════╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚════╝ ╚══════╝",
13
+ ];
14
+ const TAGLINE = "Schema-driven CMS for Waku · SQLite · Admin included";
15
+ export function printBanner() {
16
+ const lines = LOGO.map((line) => pc.cyan(line)).join("\n");
17
+ process.stdout.write(`\n${lines}\n${pc.dim(` ${TAGLINE}`)}\n\n`);
18
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,244 @@
1
+ #!/usr/bin/env node
2
+ import { spawn, spawnSync } from "node:child_process";
3
+ import { readFileSync } from "node:fs";
4
+ import { mkdir, readdir, stat } from "node:fs/promises";
5
+ import { basename, relative, resolve } from "node:path";
6
+ import { cancel, confirm, intro, isCancel, log, note, outro, spinner, text, } from "@clack/prompts";
7
+ import pc from "picocolors";
8
+ import { HELP, parseCliArgs, UsageError } from "./args.js";
9
+ import { printBanner } from "./banner.js";
10
+ import { detectPackageManager, devCommand } from "./pm.js";
11
+ import { copyTemplate, normalizePackageName } from "./template.js";
12
+ const prettyOutput = Boolean(process.stdout.isTTY);
13
+ class CancelledError extends Error {
14
+ constructor() {
15
+ super("Cancelled");
16
+ this.name = "CancelledError";
17
+ }
18
+ }
19
+ function unwrap(value) {
20
+ if (isCancel(value))
21
+ throw new CancelledError();
22
+ return value;
23
+ }
24
+ function readVersion() {
25
+ const raw = readFileSync(new URL("../package.json", import.meta.url), "utf8");
26
+ return JSON.parse(raw).version ?? "0.0.0";
27
+ }
28
+ async function assertUsableDirectory(targetDir) {
29
+ try {
30
+ const info = await stat(targetDir);
31
+ if (!info.isDirectory()) {
32
+ throw new UsageError(`"${targetDir}" already exists and is not a directory.`);
33
+ }
34
+ const entries = (await readdir(targetDir)).filter((entry) => entry !== ".DS_Store");
35
+ if (entries.length > 0) {
36
+ throw new UsageError(`Directory "${targetDir}" is not empty. Choose another directory or remove its contents.`);
37
+ }
38
+ }
39
+ catch (error) {
40
+ if (error.code === "ENOENT")
41
+ return;
42
+ if (error instanceof UsageError)
43
+ throw error;
44
+ throw new UsageError(`Cannot use "${targetDir}": ${error.message}`);
45
+ }
46
+ }
47
+ function spawnCommand(command, args, cwd, captureOutput) {
48
+ return new Promise((resolvePromise, rejectPromise) => {
49
+ const child = spawn(command, args, {
50
+ cwd,
51
+ shell: process.platform === "win32",
52
+ stdio: captureOutput ? ["ignore", "pipe", "pipe"] : "inherit",
53
+ });
54
+ let output = "";
55
+ child.stdout?.on("data", (chunk) => {
56
+ output += chunk.toString();
57
+ });
58
+ child.stderr?.on("data", (chunk) => {
59
+ output += chunk.toString();
60
+ });
61
+ child.on("error", rejectPromise);
62
+ child.on("close", (code) => {
63
+ if (code === 0) {
64
+ resolvePromise();
65
+ return;
66
+ }
67
+ if (output.trim().length > 0) {
68
+ process.stderr.write(`${output.trimEnd()}\n`);
69
+ }
70
+ rejectPromise(new Error(`"${command} ${args.join(" ")}" exited with code ${code ?? "unknown"}.`));
71
+ });
72
+ });
73
+ }
74
+ async function installDependencies(pm, targetDir) {
75
+ if (!prettyOutput) {
76
+ process.stdout.write(`\nInstalling dependencies with ${pm}...\n`);
77
+ await spawnCommand(pm, ["install"], targetDir, false);
78
+ return;
79
+ }
80
+ const progress = spinner();
81
+ progress.start(`Installing dependencies with ${pm}`);
82
+ try {
83
+ await spawnCommand(pm, ["install"], targetDir, true);
84
+ progress.stop("Dependencies installed");
85
+ }
86
+ catch (error) {
87
+ progress.error("Installation failed");
88
+ throw error;
89
+ }
90
+ }
91
+ function runGitInit(targetDir) {
92
+ const init = spawnSync("git", ["init"], {
93
+ cwd: targetDir,
94
+ stdio: "ignore",
95
+ shell: process.platform === "win32",
96
+ });
97
+ if (init.error || init.status !== 0)
98
+ return false;
99
+ spawnSync("git", ["add", "-A"], {
100
+ cwd: targetDir,
101
+ stdio: "ignore",
102
+ shell: process.platform === "win32",
103
+ });
104
+ spawnSync("git", ["commit", "-m", "Initial commit"], {
105
+ cwd: targetDir,
106
+ stdio: "ignore",
107
+ shell: process.platform === "win32",
108
+ });
109
+ return true;
110
+ }
111
+ function nextStepLines(targetDir, pm, install) {
112
+ const location = relative(process.cwd(), targetDir) || ".";
113
+ const lines = [];
114
+ if (location !== ".")
115
+ lines.push(`cd ${location}`);
116
+ if (!install)
117
+ lines.push(`${pm} install`);
118
+ if (lines.length > 0)
119
+ lines.push("");
120
+ lines.push(devCommand(pm));
121
+ lines.push("");
122
+ lines.push("Admin: http://localhost:3000/admin");
123
+ lines.push("Login: admin@example.com / admin123");
124
+ return lines;
125
+ }
126
+ function printNextSteps(targetDir, pm, install) {
127
+ const lines = nextStepLines(targetDir, pm, install);
128
+ if (prettyOutput) {
129
+ note(lines.join("\n"), "Next steps");
130
+ outro(pc.green("Project ready."));
131
+ return;
132
+ }
133
+ const body = lines
134
+ .map((line) => (line.length > 0 ? ` ${line}` : ""))
135
+ .join("\n");
136
+ process.stdout.write(`\nDone. Next steps:\n\n${body}\n`);
137
+ }
138
+ async function main(argv) {
139
+ const options = parseCliArgs(argv);
140
+ if (options.version) {
141
+ process.stdout.write(`${readVersion()}\n`);
142
+ return 0;
143
+ }
144
+ if (options.help) {
145
+ process.stdout.write(HELP);
146
+ return 0;
147
+ }
148
+ const interactive = !options.yes &&
149
+ Boolean(process.stdin.isTTY) &&
150
+ Boolean(process.stdout.isTTY);
151
+ if (prettyOutput) {
152
+ printBanner();
153
+ intro(pc.cyan(pc.bold("create-start-serenojs")));
154
+ }
155
+ let directory = options.directory;
156
+ if (!directory) {
157
+ if (!interactive) {
158
+ throw new UsageError("Missing project directory. Usage: create-start-serenojs <directory>");
159
+ }
160
+ directory = unwrap(await text({
161
+ message: "Where should we create your project?",
162
+ placeholder: "my-app",
163
+ defaultValue: "my-app",
164
+ validate: (value) => (value ?? "").trim().length === 0
165
+ ? "Please enter a directory name."
166
+ : undefined,
167
+ }));
168
+ }
169
+ const targetDir = resolve(process.cwd(), directory);
170
+ const packageName = normalizePackageName(basename(targetDir) || "my-serenojs-app");
171
+ const pm = options.pm ?? detectPackageManager();
172
+ let install = options.install;
173
+ let git = options.git;
174
+ if (interactive) {
175
+ if (install) {
176
+ install = unwrap(await confirm({
177
+ message: `Install dependencies with ${pm}?`,
178
+ initialValue: true,
179
+ }));
180
+ }
181
+ if (git) {
182
+ git = unwrap(await confirm({
183
+ message: "Initialize a git repository?",
184
+ initialValue: true,
185
+ }));
186
+ }
187
+ }
188
+ await assertUsableDirectory(targetDir);
189
+ await mkdir(targetDir, { recursive: true });
190
+ await copyTemplate(targetDir, packageName);
191
+ if (prettyOutput) {
192
+ log.success(`Created ${pc.bold(packageName)} in ${pc.dim(targetDir)}`);
193
+ }
194
+ else {
195
+ process.stdout.write(`Created ${packageName} in ${targetDir}\n`);
196
+ }
197
+ if (install)
198
+ await installDependencies(pm, targetDir);
199
+ if (git) {
200
+ const initialized = runGitInit(targetDir);
201
+ if (prettyOutput) {
202
+ if (initialized)
203
+ log.success("Initialized a git repository.");
204
+ else
205
+ log.warn("Skipped git initialization (git is not available).");
206
+ }
207
+ else if (initialized) {
208
+ process.stdout.write("Initialized a git repository.\n");
209
+ }
210
+ else {
211
+ process.stdout.write("Skipped git initialization (git is not available).\n");
212
+ }
213
+ }
214
+ printNextSteps(targetDir, pm, install);
215
+ return 0;
216
+ }
217
+ main(process.argv.slice(2))
218
+ .then((code) => {
219
+ process.exitCode = code;
220
+ })
221
+ .catch((error) => {
222
+ if (error instanceof CancelledError) {
223
+ if (prettyOutput)
224
+ cancel("Setup cancelled.");
225
+ else
226
+ process.stderr.write("\nCancelled.\n");
227
+ process.exitCode = 130;
228
+ return;
229
+ }
230
+ const message = error instanceof Error ? error.message : "Unexpected error.";
231
+ if (prettyOutput) {
232
+ log.error(message);
233
+ if (error instanceof UsageError) {
234
+ log.info("Run create-start-serenojs --help to see the available options.");
235
+ }
236
+ }
237
+ else {
238
+ process.stderr.write(`\nError: ${message}\n`);
239
+ if (error instanceof UsageError) {
240
+ process.stderr.write("Run create-start-serenojs --help to see the available options.\n");
241
+ }
242
+ }
243
+ process.exitCode = 1;
244
+ });
package/dist/pm.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
2
+ export declare function isPackageManager(value: string): value is PackageManager;
3
+ /**
4
+ * Detect the package manager that invoked the CLI from the user agent set by
5
+ * `npm create` / `pnpm create` / `yarn create` / `bun create`.
6
+ */
7
+ export declare function detectPackageManager(): PackageManager;
8
+ /** Command used to print the "next steps" instructions. */
9
+ export declare function devCommand(pm: PackageManager): string;
package/dist/pm.js ADDED
@@ -0,0 +1,17 @@
1
+ const PACKAGE_MANAGERS = ["pnpm", "npm", "yarn", "bun"];
2
+ export function isPackageManager(value) {
3
+ return PACKAGE_MANAGERS.includes(value);
4
+ }
5
+ /**
6
+ * Detect the package manager that invoked the CLI from the user agent set by
7
+ * `npm create` / `pnpm create` / `yarn create` / `bun create`.
8
+ */
9
+ export function detectPackageManager() {
10
+ const userAgent = process.env.npm_config_user_agent ?? "";
11
+ const name = userAgent.split(" ")[0]?.split("/")[0] ?? "";
12
+ return isPackageManager(name) ? name : "pnpm";
13
+ }
14
+ /** Command used to print the "next steps" instructions. */
15
+ export function devCommand(pm) {
16
+ return pm === "npm" ? "npm run dev" : `${pm} dev`;
17
+ }
@@ -0,0 +1,12 @@
1
+ /** Absolute path to the bundled starter template. */
2
+ export declare const TEMPLATE_DIR: string;
3
+ /**
4
+ * Turn an arbitrary directory name into a valid npm package name.
5
+ * Spaces and invalid characters become dashes; uppercase is folded.
6
+ */
7
+ export declare function normalizePackageName(input: string): string;
8
+ /**
9
+ * Copy the starter template into `targetDir`, renaming the template-only
10
+ * `gitignore` file and replacing workspace dependency specs with real versions.
11
+ */
12
+ export declare function copyTemplate(targetDir: string, packageName: string): Promise<void>;
@@ -0,0 +1,92 @@
1
+ import { cp, mkdir, readFile, rename, writeFile } from "node:fs/promises";
2
+ import { join, relative, sep } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ /** Absolute path to the bundled starter template. */
5
+ export const TEMPLATE_DIR = fileURLToPath(new URL("../templates/starter", import.meta.url));
6
+ const SKIPPED_DIRECTORIES = new Set([
7
+ "node_modules",
8
+ "dist",
9
+ "dist-server",
10
+ ".data",
11
+ ".waku",
12
+ "__data",
13
+ "__public",
14
+ ".git",
15
+ ]);
16
+ const SKIPPED_FILES = new Set([".npmignore", ".DS_Store"]);
17
+ const SKIPPED_PATHS = new Set(["public/files"]);
18
+ /**
19
+ * Turn an arbitrary directory name into a valid npm package name.
20
+ * Spaces and invalid characters become dashes; uppercase is folded.
21
+ */
22
+ export function normalizePackageName(input) {
23
+ const value = input.trim();
24
+ const scoped = value.startsWith("@") && value.includes("/");
25
+ const parts = (scoped ? value.slice(1) : value)
26
+ .split("/")
27
+ .map(sanitizeNamePart)
28
+ .filter((part) => part.length > 0);
29
+ if (parts.length === 0) {
30
+ throw new Error(`Cannot derive a package name from "${input}". Pass a directory name with at least one letter or number.`);
31
+ }
32
+ const name = parts.join("/");
33
+ return scoped ? `@${name}` : name;
34
+ }
35
+ function sanitizeNamePart(part) {
36
+ return part
37
+ .toLowerCase()
38
+ .replace(/[^a-z0-9._~-]+/g, "-")
39
+ .replace(/-{2,}/g, "-")
40
+ .replace(/^[._-]+/, "")
41
+ .replace(/[.-]+$/, "");
42
+ }
43
+ function shouldCopy(source) {
44
+ const relativePath = relative(TEMPLATE_DIR, source);
45
+ if (relativePath === "")
46
+ return true;
47
+ const segments = relativePath.split(sep);
48
+ if (segments.some((segment) => SKIPPED_DIRECTORIES.has(segment)))
49
+ return false;
50
+ if (SKIPPED_FILES.has(segments[segments.length - 1] ?? ""))
51
+ return false;
52
+ for (const skippedPath of SKIPPED_PATHS) {
53
+ if (relativePath === skippedPath ||
54
+ relativePath.startsWith(`${skippedPath}${sep}`)) {
55
+ return false;
56
+ }
57
+ }
58
+ return true;
59
+ }
60
+ /**
61
+ * Copy the starter template into `targetDir`, renaming the template-only
62
+ * `gitignore` file and replacing workspace dependency specs with real versions.
63
+ */
64
+ export async function copyTemplate(targetDir, packageName) {
65
+ await mkdir(targetDir, { recursive: true });
66
+ await cp(TEMPLATE_DIR, targetDir, {
67
+ recursive: true,
68
+ filter: shouldCopy,
69
+ });
70
+ await rename(join(targetDir, "gitignore"), join(targetDir, ".gitignore"));
71
+ await rewritePackageJson(join(targetDir, "package.json"), packageName);
72
+ }
73
+ async function rewritePackageJson(packageJsonPath, packageName) {
74
+ const raw = await readFile(packageJsonPath, "utf8");
75
+ const pkg = JSON.parse(raw);
76
+ pkg.name = packageName;
77
+ for (const key of [
78
+ "dependencies",
79
+ "devDependencies",
80
+ "peerDependencies",
81
+ ]) {
82
+ const dependencies = pkg[key];
83
+ if (!dependencies)
84
+ continue;
85
+ for (const [dependency, spec] of Object.entries(dependencies)) {
86
+ if (spec.startsWith("workspace:")) {
87
+ dependencies[dependency] = spec.slice("workspace:".length);
88
+ }
89
+ }
90
+ }
91
+ await writeFile(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
92
+ }
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "create-start-serenojs",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Scaffold a SerenoJS starter (Waku + @eutobias/serenojs).",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Tobias Taurian <eutobias@gmail.com>",
8
+ "homepage": "https://github.com/eutobias/serenojs#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/eutobias/serenojs.git",
12
+ "directory": "packages/create-start-serenojs"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/eutobias/serenojs/issues"
16
+ },
17
+ "keywords": [
18
+ "serenojs",
19
+ "cms",
20
+ "waku",
21
+ "starter",
22
+ "scaffold",
23
+ "create"
24
+ ],
25
+ "bin": {
26
+ "create-start-serenojs": "./dist/index.js"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "templates",
31
+ "README.md"
32
+ ],
33
+ "engines": {
34
+ "node": ">=22.15"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^26.6.2"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "dependencies": {
43
+ "@clack/prompts": "^1.8.1",
44
+ "picocolors": "^1.1.1"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc -p tsconfig.build.json",
48
+ "dev": "tsc -p tsconfig.build.json --watch",
49
+ "typecheck": "tsc -p tsconfig.json --noEmit",
50
+ "test": "pnpm run build && node --test tests/*.test.mjs"
51
+ }
6
52
  }