create-kitsuden 0.0.0-stage → 0.9.0-beta

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Victor Antinori Broce
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,38 @@
1
- # Temporary Holding Version
1
+ # create-kitsuden
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
+ `npm create kitsuden`: a new [Kitsuden](https://github.com/Kitsuden/kitsuden)
4
+ project, with its secrets generated.
5
+
6
+ ```bash
7
+ npm create kitsuden@beta my-app
8
+ cd my-app
9
+ docker compose up -d
10
+ ```
11
+
12
+ Two modes:
13
+
14
+ - **docker** (default): a `docker-compose.yml` and a `.env` for the published
15
+ images (`ghcr.io/kitsuden/kitsuden/api` and `admin`, tag `0.9.0-beta` unless you
16
+ pass `--image-tag`). Nothing is downloaded to scaffold: the templates travel
17
+ inside this package.
18
+ - **local**: a checkout of the source, to run with Bun and pnpm
19
+ (`--mode local`; needs `git`, or `--source <path>` to an existing checkout).
20
+
21
+ ```
22
+ npm create kitsuden@beta [folder] -- [options]
23
+
24
+ --mode <docker|local> docker (default) or local
25
+ --instance <name> prefix of containers and volumes (docker)
26
+ --registry <prefix> image registry (default ghcr.io/kitsuden/kitsuden)
27
+ --image-tag <tag> image tag (default: this package's version)
28
+ --source <url|path> local mode: where to clone from
29
+ --ref <branch|tag> local mode: what to clone
30
+ --api-port, --admin-port, --db-port, --valkey-port <n>
31
+ --skip-checks do not look for free ports or an install with the same name
32
+ -y, --yes ask nothing (folder defaults to kitsuden-app)
33
+ -h, --help
34
+ ```
35
+
36
+ The `.env` it writes holds the generated passwords: keep it out of version control.
37
+
38
+ Requires Node.js 20+, and Docker for the docker mode. MIT.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { main } from "../src/cli.mjs";
3
+
4
+ process.exitCode = await main();
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "create-kitsuden",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.9.0-beta",
4
+ "description": "npm create kitsuden: a new Kitsuden project (Docker with prebuilt images, or local development) with its secrets generated.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Kitsuden/kitsuden.git",
9
+ "directory": "packages/create-kitsuden"
10
+ },
11
+ "homepage": "https://github.com/Kitsuden/kitsuden/tree/main/packages/create-kitsuden#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/Kitsuden/kitsuden/issues"
14
+ },
15
+ "type": "module",
16
+ "bin": {
17
+ "create-kitsuden": "bin/create-kitsuden.mjs"
18
+ },
19
+ "exports": {
20
+ ".": "./src/index.mjs"
21
+ },
22
+ "files": [
23
+ "bin",
24
+ "src",
25
+ "templates"
26
+ ],
27
+ "engines": {
28
+ "node": ">=20"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "sync-templates": "node scripts/sync-templates.mjs"
35
+ }
6
36
  }
package/src/cli.mjs ADDED
@@ -0,0 +1,128 @@
1
+ /**
2
+ * The command: `npm create kitsuden [folder] [-- options]`.
3
+ */
4
+ import { createInterface } from "node:readline/promises";
5
+ import { parseArgs } from "node:util";
6
+
7
+ import { DEFAULT_REGISTRY, DEFAULT_SOURCE, scaffold, VERSION } from "./index.mjs";
8
+
9
+ const HELP = `create-kitsuden ${VERSION}: a new Kitsuden project
10
+
11
+ npm create kitsuden@latest [folder] -- [options]
12
+
13
+ Options:
14
+ --mode <docker|local> docker (default): docker-compose.yml + .env for the published
15
+ images; nothing is downloaded to scaffold.
16
+ local: a checkout of the source, to run with Bun and pnpm.
17
+ --instance <name> prefix of containers and volumes (docker; default: from the folder)
18
+ --registry <prefix> image registry (default ${DEFAULT_REGISTRY})
19
+ --image-tag <tag> image tag (default ${VERSION})
20
+ --source <url|path> local mode: where to clone from (default ${DEFAULT_SOURCE});
21
+ a path to a checkout you have works offline
22
+ --ref <branch|tag> local mode: what to clone
23
+ --api-port, --admin-port, --db-port, --valkey-port <n> fixed ports
24
+ --skip-checks do not look for free ports or for an install with the same name
25
+ -y, --yes ask nothing (folder defaults to "kitsuden-app")
26
+ -h, --help
27
+ `;
28
+
29
+ const OPTIONS = {
30
+ mode: { type: "string" },
31
+ instance: { type: "string" },
32
+ registry: { type: "string" },
33
+ "image-tag": { type: "string" },
34
+ source: { type: "string" },
35
+ ref: { type: "string" },
36
+ "api-port": { type: "string" },
37
+ "admin-port": { type: "string" },
38
+ "db-port": { type: "string" },
39
+ "valkey-port": { type: "string" },
40
+ "skip-checks": { type: "boolean" },
41
+ yes: { type: "boolean", short: "y" },
42
+ help: { type: "boolean", short: "h" },
43
+ };
44
+
45
+ function port(value, name) {
46
+ if (value === undefined) return undefined;
47
+ const n = Number(value);
48
+ if (!Number.isInteger(n) || n < 1 || n > 65535)
49
+ throw new Error(`--${name}: not a port (${value})`);
50
+ return n;
51
+ }
52
+
53
+ export async function main(
54
+ argv = process.argv.slice(2),
55
+ io = { stdin: process.stdin, stdout: process.stdout, stderr: process.stderr }
56
+ ) {
57
+ let parsed;
58
+ try {
59
+ parsed = parseArgs({ args: argv, options: OPTIONS, allowPositionals: true, strict: true });
60
+ } catch (e) {
61
+ io.stderr.write(`${e.message}\n\n${HELP}`);
62
+ return 2;
63
+ }
64
+ const { values: v, positionals } = parsed;
65
+ if (v.help) {
66
+ io.stdout.write(HELP);
67
+ return 0;
68
+ }
69
+ const interactive = !v.yes && Boolean(io.stdin.isTTY);
70
+ let dir = positionals[0];
71
+ let mode = v.mode;
72
+ if (interactive && (!dir || !mode)) {
73
+ const rl = createInterface({ input: io.stdin, output: io.stdout });
74
+ try {
75
+ if (!dir)
76
+ dir = (await rl.question("Project folder (kitsuden-app): ")).trim() || "kitsuden-app";
77
+ if (!mode) {
78
+ const a = (
79
+ await rl.question(
80
+ "How will it run?\n 1) Docker, with the published images (recommended)\n 2) Local development from the source (Bun + pnpm)\nChoose 1 or 2 (1): "
81
+ )
82
+ ).trim();
83
+ mode = a === "2" || a === "local" ? "local" : "docker";
84
+ }
85
+ } finally {
86
+ rl.close();
87
+ }
88
+ }
89
+ dir ??= "kitsuden-app";
90
+ mode ??= "docker";
91
+
92
+ try {
93
+ const ports = {};
94
+ for (const k of ["api", "admin", "db", "valkey"]) {
95
+ const p = port(v[`${k}-port`], `${k}-port`);
96
+ if (p !== undefined) ports[k] = p;
97
+ }
98
+ const started = Date.now();
99
+ const r = await scaffold({
100
+ dir,
101
+ mode,
102
+ instance: v.instance,
103
+ registry: v.registry,
104
+ imageTag: v["image-tag"],
105
+ source: v.source,
106
+ ref: v.ref,
107
+ ports,
108
+ probe: !v["skip-checks"],
109
+ });
110
+ const seconds = ((Date.now() - started) / 1000).toFixed(1);
111
+ io.stdout.write(`\nKitsuden project in ${r.dir} (${r.mode}, ${seconds}s).\n`);
112
+ if (r.instance && r.instance !== "kitsuden")
113
+ io.stdout.write(`Instance "${r.instance}": its containers, volumes and ports are its own.\n`);
114
+ if (r.files.length) io.stdout.write(`Wrote: ${r.files.join(", ")}\n`);
115
+ if (r.kept?.length) io.stdout.write(`Kept as they were: ${r.kept.join(", ")}\n`);
116
+ io.stdout.write("The secrets are in .env: never commit it, and keep a copy.\n\nNext:\n");
117
+ for (const step of r.next) io.stdout.write(` ${step}\n`);
118
+ if (r.mode === "docker")
119
+ io.stdout.write(
120
+ "\nIf `docker pull` says the image does not exist, that version is not published yet:\n" +
121
+ "build the images from a checkout of the repository with ./install.sh instead.\n"
122
+ );
123
+ return 0;
124
+ } catch (e) {
125
+ io.stderr.write(`create-kitsuden: ${e instanceof Error ? e.message : e}\n`);
126
+ return 1;
127
+ }
128
+ }
@@ -0,0 +1,65 @@
1
+ export declare const VERSION: string;
2
+ export declare const DEFAULT_REGISTRY: string;
3
+ export declare const DEFAULT_SOURCE: string;
4
+ export declare const INSTALL_MARKER: string;
5
+ export declare const LOCAL_MARKER: string;
6
+ export declare const TEMPLATE_FILES: readonly string[];
7
+
8
+ export interface Ports {
9
+ api: number;
10
+ admin: number;
11
+ db: number;
12
+ valkey: number;
13
+ }
14
+
15
+ export declare function templatesDir(): string;
16
+ export declare function secret(): string;
17
+ export declare function checkInstance(name: string): string;
18
+ export declare function instanceFromName(name: string): string;
19
+ export declare function instanceInUse(instance: string): boolean;
20
+ export declare function portFree(port: number): Promise<boolean>;
21
+ export declare function freePort(start: number, taken?: Set<number>): Promise<number>;
22
+
23
+ export declare function renderProductionEnv(
24
+ example: string,
25
+ opts: {
26
+ instance: string;
27
+ ports: Ports;
28
+ apiImage: string;
29
+ adminImage: string;
30
+ secret?: () => string;
31
+ }
32
+ ): string;
33
+
34
+ export declare function composeForImages(text: string, version: string): string;
35
+
36
+ export declare function renderLocalEnv(
37
+ apiExample: string,
38
+ opts: { ports: Ports; secret?: () => string }
39
+ ): { root: string; api: string };
40
+
41
+ export interface ScaffoldOptions {
42
+ dir: string;
43
+ mode?: "docker" | "local";
44
+ instance?: string;
45
+ ports?: Partial<Ports>;
46
+ probe?: boolean;
47
+ registry?: string;
48
+ imageTag?: string;
49
+ source?: string;
50
+ ref?: string;
51
+ secret?: () => string;
52
+ }
53
+
54
+ export interface ScaffoldResult {
55
+ dir: string;
56
+ mode: "docker" | "local";
57
+ instance?: string;
58
+ ports: Ports;
59
+ cloned?: boolean;
60
+ files: string[];
61
+ kept?: string[];
62
+ next: string[];
63
+ }
64
+
65
+ export declare function scaffold(o: ScaffoldOptions): Promise<ScaffoldResult>;