@takuhon/cli 0.8.2 → 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/admin-bundle/assets/index-C2-9nYVF.js +9 -0
- package/admin-bundle/assets/style-Cyep5p4h.css +2 -0
- package/admin-bundle/index.html +14 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +276 -13
- package/dist/index.js.map +1 -1
- package/dist/init.js +79 -34
- package/dist/init.js.map +1 -1
- package/package.json +7 -3
package/dist/init.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
// src/init.ts
|
|
4
4
|
import { realpathSync } from "fs";
|
|
5
|
+
import { rm } from "fs/promises";
|
|
5
6
|
import { basename, resolve } from "path";
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7
8
|
import { parseArgs } from "util";
|
|
8
9
|
import { cancel as cancel2, intro, outro } from "@clack/prompts";
|
|
9
10
|
|
|
@@ -102,8 +103,9 @@ async function promptLicense() {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
// src/scaffold/index.ts
|
|
105
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
106
|
+
import { cp, mkdir, writeFile } from "fs/promises";
|
|
106
107
|
import { dirname, join } from "path";
|
|
108
|
+
import { fileURLToPath } from "url";
|
|
107
109
|
|
|
108
110
|
// src/scaffold/env-example.ts
|
|
109
111
|
function renderEnvExample() {
|
|
@@ -170,9 +172,9 @@ function buildPackageJson(opts) {
|
|
|
170
172
|
deploy: "wrangler deploy"
|
|
171
173
|
},
|
|
172
174
|
dependencies: {
|
|
173
|
-
"@takuhon/api": "^0.
|
|
174
|
-
"@takuhon/cloudflare": "^0.
|
|
175
|
-
"@takuhon/core": "^0.
|
|
175
|
+
"@takuhon/api": "^0.10.0",
|
|
176
|
+
"@takuhon/cloudflare": "^0.10.0",
|
|
177
|
+
"@takuhon/core": "^0.10.0",
|
|
176
178
|
hono: "^4.0.0"
|
|
177
179
|
},
|
|
178
180
|
devDependencies: {
|
|
@@ -207,32 +209,31 @@ A [Takuhon](https://github.com/takuhon-dev/takuhon) profile deployment, running
|
|
|
207
209
|
|
|
208
210
|
> **Status**: pre-deploy. Edit \`takuhon.json\`, provision Cloudflare KV, then \`pnpm deploy\`.
|
|
209
211
|
|
|
210
|
-
> **Heads-up \u2014 Takuhon is in a pre-publish phase.**
|
|
211
|
-
>
|
|
212
|
-
> The \`@takuhon/api\`, \`@takuhon/core\`, and \`@takuhon/cloudflare\` packages
|
|
213
|
-
> referenced in \`package.json\` are not yet on the npm registry.
|
|
214
|
-
> \`pnpm install\` will fail in this directory until they ship. See *Develop*
|
|
215
|
-
> below for the workspace-link recipe in the meantime.
|
|
216
|
-
|
|
217
212
|
## What is Takuhon?
|
|
218
213
|
|
|
219
214
|
Takuhon lets you own your profile as a portable JSON document and publish it as a mobile-first profile page plus a public API (JSON-LD for AI agents and search engines included).
|
|
220
215
|
|
|
221
216
|
## Setup
|
|
222
217
|
|
|
223
|
-
1. **
|
|
218
|
+
1. **Install dependencies.**
|
|
219
|
+
|
|
220
|
+
\`\`\`sh
|
|
221
|
+
pnpm install
|
|
222
|
+
\`\`\`
|
|
224
223
|
|
|
225
|
-
2. **
|
|
224
|
+
2. **Edit your profile.** Open \`takuhon.json\` and replace the sample fields (\`profile.displayName\`, \`links\`, \`careers\`, \`projects\`, \`skills\`) with your own.
|
|
225
|
+
|
|
226
|
+
3. **Create the Cloudflare KV namespaces** and copy the returned ids into \`wrangler.toml\`:
|
|
226
227
|
|
|
227
228
|
\`\`\`sh
|
|
228
|
-
wrangler kv namespace create TAKUHON_KV
|
|
229
|
-
wrangler kv namespace create TAKUHON_KV --preview
|
|
229
|
+
npx wrangler kv namespace create TAKUHON_KV
|
|
230
|
+
npx wrangler kv namespace create TAKUHON_KV --preview
|
|
230
231
|
\`\`\`
|
|
231
232
|
|
|
232
|
-
|
|
233
|
+
4. **Provision the admin token** as a Wrangler secret (used by \`/api/admin/*\`):
|
|
233
234
|
|
|
234
235
|
\`\`\`sh
|
|
235
|
-
openssl rand -base64 32 | wrangler secret put TAKUHON_ADMIN_TOKEN
|
|
236
|
+
openssl rand -base64 32 | npx wrangler secret put TAKUHON_ADMIN_TOKEN
|
|
236
237
|
\`\`\`
|
|
237
238
|
|
|
238
239
|
Leaving the secret unset disables admin writes entirely (every \`PUT\` / \`DELETE\` returns 401).
|
|
@@ -241,17 +242,7 @@ Takuhon lets you own your profile as a portable JSON document and publish it as
|
|
|
241
242
|
|
|
242
243
|
The Worker entry at \`src/index.ts\` composes the takuhon adapter via
|
|
243
244
|
\`createTakuhonWorker\` and serves your \`takuhon.json\` as the fallback when
|
|
244
|
-
KV has no stored profile yet.
|
|
245
|
-
clone the upstream repo and link them into this directory (substitute
|
|
246
|
-
your own absolute path for \`<takuhon-repo-path>\`):
|
|
247
|
-
|
|
248
|
-
\`\`\`sh
|
|
249
|
-
git clone https://github.com/takuhon-dev/takuhon <takuhon-repo-path>
|
|
250
|
-
( cd <takuhon-repo-path> && pnpm install && pnpm build )
|
|
251
|
-
pnpm link <takuhon-repo-path>/packages/api <takuhon-repo-path>/packages/core <takuhon-repo-path>/adapters/cloudflare
|
|
252
|
-
\`\`\`
|
|
253
|
-
|
|
254
|
-
Then:
|
|
245
|
+
KV has no stored profile yet.
|
|
255
246
|
|
|
256
247
|
\`\`\`sh
|
|
257
248
|
pnpm dev # runs \`wrangler dev\` locally
|
|
@@ -259,6 +250,12 @@ pnpm dev # runs \`wrangler dev\` locally
|
|
|
259
250
|
|
|
260
251
|
The full route map (public + admin) is documented in the [\`@takuhon/cloudflare\` README](https://github.com/takuhon-dev/takuhon/tree/main/adapters/cloudflare#readme).
|
|
261
252
|
|
|
253
|
+
## Admin
|
|
254
|
+
|
|
255
|
+
The admin form UI is served at \`/admin\` under a strict Content-Security-Policy. Its compiled bundle is committed in \`admin-dist/\` and bound as Workers Assets in \`wrangler.toml\`. Sign in with the admin token you set as the \`TAKUHON_ADMIN_TOKEN\` Wrangler secret.
|
|
256
|
+
|
|
257
|
+
The bundle is a snapshot taken when this project was created. To pick up a newer admin UI, re-run \`create-takuhon\` into a fresh directory and copy its \`admin-dist/\` over. To deploy without the form UI, remove the \`[assets]\` block from \`wrangler.toml\`; the Worker then falls back to a minimal inline editor.
|
|
258
|
+
|
|
262
259
|
## Deploy
|
|
263
260
|
|
|
264
261
|
\`\`\`sh
|
|
@@ -388,6 +385,7 @@ export default createTakuhonWorker({
|
|
|
388
385
|
function isValidWorkerName(name) {
|
|
389
386
|
return /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(name);
|
|
390
387
|
}
|
|
388
|
+
var ADMIN_DIST_DIRNAME = "admin-dist";
|
|
391
389
|
function renderWranglerToml(projectName) {
|
|
392
390
|
if (!isValidWorkerName(projectName)) {
|
|
393
391
|
throw new Error(
|
|
@@ -399,6 +397,26 @@ main = "src/index.ts"
|
|
|
399
397
|
compatibility_date = "2026-05-01"
|
|
400
398
|
compatibility_flags = ["nodejs_compat"]
|
|
401
399
|
|
|
400
|
+
# Admin SPA bundle. The React admin UI is committed in ./${ADMIN_DIST_DIRNAME}
|
|
401
|
+
# (copied here when this project was created with create-takuhon) and served at
|
|
402
|
+
# /admin.
|
|
403
|
+
#
|
|
404
|
+
# run_worker_first = true makes the Worker mediate every request: the bundle's
|
|
405
|
+
# files sit at the assets root, so without this they would shadow the public "/"
|
|
406
|
+
# route. The Worker serves the bundle only for /admin/* (attaching the strict
|
|
407
|
+
# admin CSP) and handles everything else itself.
|
|
408
|
+
#
|
|
409
|
+
# SECURITY-CRITICAL: do not set run_worker_first to false or remove it. The
|
|
410
|
+
# Worker is the only thing that attaches the strict admin CSP (plus HSTS /
|
|
411
|
+
# no-store) to the admin assets; serving them directly would expose the admin UI
|
|
412
|
+
# with no policy. To deploy without the form UI, remove this whole [assets]
|
|
413
|
+
# block \u2014 the Worker then falls back to a minimal inline editor.
|
|
414
|
+
[assets]
|
|
415
|
+
directory = "${ADMIN_DIST_DIRNAME}"
|
|
416
|
+
binding = "ASSETS"
|
|
417
|
+
run_worker_first = true
|
|
418
|
+
not_found_handling = "single-page-application"
|
|
419
|
+
|
|
402
420
|
# Replace the placeholder ids after running:
|
|
403
421
|
# wrangler kv namespace create TAKUHON_KV
|
|
404
422
|
# wrangler kv namespace create TAKUHON_KV --preview
|
|
@@ -462,6 +480,23 @@ async function writeProject(opts) {
|
|
|
462
480
|
function isNodeErrnoException(err) {
|
|
463
481
|
return err instanceof Error && typeof err.code === "string";
|
|
464
482
|
}
|
|
483
|
+
function resolveAdminBundleDir() {
|
|
484
|
+
return fileURLToPath(new URL("../admin-bundle", import.meta.url));
|
|
485
|
+
}
|
|
486
|
+
async function copyAdminBundle(opts) {
|
|
487
|
+
const bundleDir = opts.bundleDir ?? resolveAdminBundleDir();
|
|
488
|
+
const dest = join(opts.targetDir, ADMIN_DIST_DIRNAME);
|
|
489
|
+
try {
|
|
490
|
+
await cp(bundleDir, dest, { recursive: true });
|
|
491
|
+
} catch (err) {
|
|
492
|
+
const code = isNodeErrnoException(err) ? ` (${err.code})` : "";
|
|
493
|
+
throw new Error(
|
|
494
|
+
`Failed to copy the admin UI bundle from @takuhon/cli${code}. Reinstall or upgrade @takuhon/cli and try again.`,
|
|
495
|
+
{ cause: err }
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
return { dest };
|
|
499
|
+
}
|
|
465
500
|
|
|
466
501
|
// src/init.ts
|
|
467
502
|
function parseCliArgs(argv) {
|
|
@@ -562,16 +597,26 @@ Names must be lowercase, start and end with a letter or digit, and contain only
|
|
|
562
597
|
}
|
|
563
598
|
throw err;
|
|
564
599
|
}
|
|
600
|
+
try {
|
|
601
|
+
await copyAdminBundle({ targetDir });
|
|
602
|
+
} catch (err) {
|
|
603
|
+
await rm(targetDir, { recursive: true, force: true });
|
|
604
|
+
cancel2(err instanceof Error ? err.message : "Failed to copy the admin UI bundle.");
|
|
605
|
+
return 1;
|
|
606
|
+
}
|
|
565
607
|
outro(
|
|
566
608
|
`Created ${projectName} (license: ${spdxId}).
|
|
567
609
|
|
|
568
610
|
Next steps:
|
|
569
611
|
cd ${parsed.targetArg}
|
|
570
|
-
# 1. Edit takuhon.json with your profile data
|
|
571
|
-
# 2. Provision Cloudflare KV: wrangler kv namespace create TAKUHON_KV
|
|
572
|
-
# 3. Set admin token: openssl rand -base64 32 | wrangler secret put TAKUHON_ADMIN_TOKEN
|
|
573
612
|
pnpm install
|
|
574
|
-
|
|
613
|
+
# 1. Edit takuhon.json with your profile data
|
|
614
|
+
# 2. Provision Cloudflare KV: npx wrangler kv namespace create TAKUHON_KV
|
|
615
|
+
# 3. Set admin token: openssl rand -base64 32 | npx wrangler secret put TAKUHON_ADMIN_TOKEN
|
|
616
|
+
pnpm dev
|
|
617
|
+
|
|
618
|
+
The admin form UI is served at /admin (bundled in admin-dist/); sign in
|
|
619
|
+
with the admin token from step 3.`
|
|
575
620
|
);
|
|
576
621
|
return 0;
|
|
577
622
|
}
|
|
@@ -588,7 +633,7 @@ function isEntrypoint() {
|
|
|
588
633
|
const entry = process.argv[1];
|
|
589
634
|
if (entry === void 0) return false;
|
|
590
635
|
try {
|
|
591
|
-
return realpathSync(entry) === realpathSync(
|
|
636
|
+
return realpathSync(entry) === realpathSync(fileURLToPath2(import.meta.url));
|
|
592
637
|
} catch {
|
|
593
638
|
return false;
|
|
594
639
|
}
|
package/dist/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/init.ts","../src/licenses.ts","../src/prompts.ts","../src/scaffold/index.ts","../src/scaffold/env-example.ts","../src/scaffold/gitignore.ts","../src/scaffold/package-json.ts","../src/scaffold/readme.ts","../src/scaffold/takuhon-json.ts","../src/scaffold/tsconfig-json.ts","../src/scaffold/worker-index-ts.ts","../src/scaffold/wrangler-toml.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Entry point for `npx create-takuhon` (and `pnpm create takuhon`).\n *\n * Usage:\n * create-takuhon <target-dir> [--license <spdxId>]\n *\n * The positional target directory is required; it must not already exist (we\n * refuse to overwrite). `--license` skips the interactive picker for CI /\n * automation use.\n */\n\nimport { realpathSync } from 'node:fs';\nimport { basename, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { parseArgs } from 'node:util';\n\nimport { cancel, intro, outro } from '@clack/prompts';\n\nimport { buildContentLicense, isValidSpdxInput } from './licenses.js';\nimport { promptLicense } from './prompts.js';\nimport { TargetDirectoryExistsError, writeProject } from './scaffold/index.js';\nimport { isValidWorkerName } from './scaffold/wrangler-toml.js';\n\ninterface CliArgs {\n readonly targetArg: string | undefined;\n readonly extraPositionals: readonly string[];\n readonly license: string | undefined;\n readonly help: boolean;\n}\n\nfunction parseCliArgs(argv: readonly string[]): CliArgs {\n const { values, positionals } = parseArgs({\n args: [...argv],\n allowPositionals: true,\n strict: true,\n options: {\n license: { type: 'string' },\n help: { type: 'boolean', short: 'h' },\n },\n });\n return {\n targetArg: positionals[0],\n extraPositionals: positionals.slice(1),\n license: values.license,\n help: values.help === true,\n };\n}\n\nfunction printHelp(): void {\n process.stdout.write(\n `Usage: create-takuhon <target-dir> [--license <spdxId>]\\n` +\n `\\n` +\n `Scaffolds a Takuhon profile deployment in <target-dir>.\\n` +\n `\\n` +\n `Options:\\n` +\n ` --license <spdxId> Skip the interactive license prompt and use the\\n` +\n ` given SPDX identifier (e.g. CC-BY-4.0, MIT,\\n` +\n ` Proprietary). Useful for CI / automation.\\n` +\n ` -h, --help Show this help.\\n`,\n );\n}\n\nasync function main(argv: readonly string[]): Promise<number> {\n let parsed: CliArgs;\n try {\n parsed = parseCliArgs(argv);\n } catch (err) {\n process.stderr.write(`${(err as Error).message}\\n\\n`);\n printHelp();\n return 2;\n }\n\n if (parsed.help) {\n printHelp();\n return 0;\n }\n\n if (parsed.targetArg === undefined) {\n process.stderr.write(`Error: missing target directory argument.\\n\\n`);\n printHelp();\n return 2;\n }\n\n if (parsed.extraPositionals.length > 0) {\n process.stderr.write(\n `Error: unexpected extra arguments: ${parsed.extraPositionals.join(' ')}\\n\\n`,\n );\n printHelp();\n return 2;\n }\n\n const targetDir = resolve(process.cwd(), parsed.targetArg);\n const projectName = basename(targetDir);\n\n if (!isValidWorkerName(projectName)) {\n process.stderr.write(\n `Error: target directory basename \"${projectName}\" is not a valid Cloudflare Worker name.\\n` +\n `Names must be lowercase, start and end with a letter or digit, and contain only ` +\n `letters, digits, and hyphens (max 63 chars).\\n`,\n );\n return 2;\n }\n\n intro('create-takuhon');\n\n let spdxId: string;\n if (parsed.license !== undefined) {\n const raw = parsed.license.trim();\n if (!isValidSpdxInput(raw)) {\n cancel(`Invalid --license value: \"${parsed.license}\"`);\n return 2;\n }\n spdxId = raw;\n } else {\n const result = await promptLicense();\n if ('cancelled' in result) {\n return 130;\n }\n spdxId = result.spdxId;\n }\n\n const license = buildContentLicense(spdxId);\n\n try {\n await writeProject({ targetDir, projectName, license });\n } catch (err) {\n if (err instanceof TargetDirectoryExistsError) {\n cancel(`Target directory already exists: ${parsed.targetArg}`);\n return 1;\n }\n throw err;\n }\n\n outro(\n `Created ${projectName} (license: ${spdxId}).\\n` +\n `\\n` +\n `Next steps:\\n` +\n ` cd ${parsed.targetArg}\\n` +\n ` # 1. Edit takuhon.json with your profile data\\n` +\n ` # 2. Provision Cloudflare KV: wrangler kv namespace create TAKUHON_KV\\n` +\n ` # 3. Set admin token: openssl rand -base64 32 | wrangler secret put TAKUHON_ADMIN_TOKEN\\n` +\n ` pnpm install\\n` +\n ` pnpm dev`,\n );\n\n return 0;\n}\n\n/**\n * Process entry point: run {@link main} and exit with its code. This is the\n * only function that calls `process.exit`, mirroring the `takuhon` entry in\n * `index.ts`. Exported so the `create-takuhon` redirect package can invoke it\n * after importing this module (`import { run } from '@takuhon/cli/init'`).\n */\nexport async function run(argv: readonly string[] = process.argv.slice(2)): Promise<void> {\n try {\n process.exit(await main(argv));\n } catch (err) {\n // Render only the message — full stack traces can leak host-machine\n // absolute paths and monorepo-internal layout into a published\n // binary's stderr output.\n process.stderr.write(`${err instanceof Error ? err.message : String(err)}\\n`);\n process.exit(1);\n }\n}\n\n/** True when this module was started directly (`node …/init.js`). */\nfunction isEntrypoint(): boolean {\n const entry = process.argv[1];\n if (entry === undefined) return false;\n try {\n return realpathSync(entry) === realpathSync(fileURLToPath(import.meta.url));\n } catch {\n return false;\n }\n}\n\nif (isEntrypoint()) {\n void run();\n}\n","/**\n * Content-license metadata and helpers for the `create-takuhon` scaffolding\n * flow.\n *\n * The four entries in `LICENSE_OPTIONS` are the curated choices the\n * interactive picker offers. \"Custom\" is handled separately by the prompt\n * flow as a free-form SPDX text input. `buildContentLicense` shapes the\n * chosen identifier into the `meta.contentLicense` fragment that lands in\n * the generated `takuhon.json`. The Takuhon profile JSON Schema accepts any\n * SPDX expression in `meta.contentLicense.spdxId`; unknown identifiers fall\n * through with `spdxId` only, and downstream UI rendering is best-effort.\n */\n\n/** A single row in the interactive license selector. */\nexport interface LicenseOption {\n /** Short label shown as the selectable label in the prompt. */\n readonly label: string;\n /** Longer hint shown alongside the label in the prompt UI. */\n readonly hint: string;\n /** SPDX identifier written to `takuhon.json` `meta.contentLicense.spdxId`. */\n readonly spdxId: string;\n /** Canonical license URL. Omitted for `Proprietary`. */\n readonly url?: string;\n}\n\n/**\n * The four curated license choices shown by the interactive picker. \"Custom\"\n * is not in this list because it triggers a free-form text prompt rather than\n * mapping to a fixed SPDX identifier here.\n */\nexport const LICENSE_OPTIONS: readonly LicenseOption[] = [\n {\n label: 'CC BY 4.0',\n hint: 'Allow reuse with attribution',\n spdxId: 'CC-BY-4.0',\n url: 'https://creativecommons.org/licenses/by/4.0/',\n },\n {\n label: 'CC BY-NC 4.0',\n hint: 'Non-commercial reuse with attribution',\n spdxId: 'CC-BY-NC-4.0',\n url: 'https://creativecommons.org/licenses/by-nc/4.0/',\n },\n {\n label: 'CC0',\n hint: 'Public domain',\n spdxId: 'CC0-1.0',\n url: 'https://creativecommons.org/publicdomain/zero/1.0/',\n },\n {\n label: 'Proprietary',\n hint: 'All rights reserved',\n spdxId: 'Proprietary',\n },\n];\n\n/**\n * Canonical URL lookup for SPDX identifiers we recognise but don't list in\n * the interactive picker. Used by `buildContentLicense` so that a user who\n * passes `--license CC-BY-SA-4.0` (or selects it via `Custom`) still gets a\n * usable `url` field in the generated `takuhon.json`.\n *\n * URLs for non-CC SPDX identifiers point at the canonical SPDX license page\n * (`spdx.org/licenses/<id>.html`). Creative Commons identifiers use the\n * `creativecommons.org` deed URL because that is the page humans expect to\n * land on (the SPDX page is metadata-only).\n */\nconst KNOWN_URL_BY_SPDX: Readonly<Record<string, string>> = {\n 'CC0-1.0': 'https://creativecommons.org/publicdomain/zero/1.0/',\n 'CC-BY-4.0': 'https://creativecommons.org/licenses/by/4.0/',\n 'CC-BY-SA-4.0': 'https://creativecommons.org/licenses/by-sa/4.0/',\n 'CC-BY-ND-4.0': 'https://creativecommons.org/licenses/by-nd/4.0/',\n 'CC-BY-NC-4.0': 'https://creativecommons.org/licenses/by-nc/4.0/',\n 'CC-BY-NC-SA-4.0': 'https://creativecommons.org/licenses/by-nc-sa/4.0/',\n 'CC-BY-NC-ND-4.0': 'https://creativecommons.org/licenses/by-nc-nd/4.0/',\n MIT: 'https://spdx.org/licenses/MIT.html',\n};\n\n/** Shape written to `takuhon.json` under `meta.contentLicense`. */\nexport interface ContentLicenseFragment {\n readonly spdxId: string;\n readonly url?: string;\n readonly rights?: string;\n}\n\n/**\n * Translate a chosen SPDX identifier into the `meta.contentLicense` fragment\n * for `takuhon.json`.\n *\n * - `Proprietary` is given a `rights` sentinel and no `url`.\n * - Known SPDX identifiers get a canonical `url`.\n * - Anything else is written as `{ spdxId }` only — the schema accepts\n * arbitrary SPDX expressions, and UI rendering is best-effort.\n */\nexport function buildContentLicense(spdxId: string): ContentLicenseFragment {\n if (spdxId === 'Proprietary') {\n return {\n spdxId: 'Proprietary',\n rights: 'All rights reserved. Contact owner for usage permission.',\n };\n }\n const url = KNOWN_URL_BY_SPDX[spdxId];\n if (url !== undefined) {\n return { spdxId, url };\n }\n return { spdxId };\n}\n\n/**\n * Light syntactic validation for a user-entered SPDX expression (the\n * `Custom` prompt branch and the `--license` flag).\n *\n * We accept any non-empty string composed of the characters that appear in\n * canonical SPDX identifiers and boolean expressions (alphanumerics, `.`,\n * `-`, `+`, parentheses, and literal spaces). Tabs and newlines are rejected\n * because real SPDX expressions never contain them. Full SPDX expression\n * parsing (`MIT OR (Apache-2.0 AND CC-BY-4.0)`) is intentionally out of\n * scope — we trust the user and let the JSON Schema's downstream validation\n * flag obvious problems.\n */\nexport function isValidSpdxInput(input: string): boolean {\n const trimmed = input.trim();\n if (trimmed === '') return false;\n return /^[A-Za-z0-9.\\-+() ]+$/.test(trimmed);\n}\n","/**\n * Interactive prompt flow for `create-takuhon`, built on `@clack/prompts`.\n *\n * A single-choice picker offers the curated `LICENSE_OPTIONS` plus a\n * `Custom` row that opens a free-form SPDX text input. Cancellation\n * (Ctrl+C or pressing Esc on a clack prompt) returns a sentinel result\n * instead of throwing so the caller can exit cleanly with a specific status\n * code.\n */\n\nimport { cancel, isCancel, select, text } from '@clack/prompts';\n\nimport { LICENSE_OPTIONS, isValidSpdxInput } from './licenses.js';\n\n/** Returned by {@link promptLicense} on successful completion. */\nexport interface PromptLicenseResult {\n /** SPDX identifier to write into `meta.contentLicense.spdxId`. */\n readonly spdxId: string;\n}\n\n/** Returned when the user cancels (Ctrl+C / Esc) instead of completing. */\nexport interface PromptCancelled {\n readonly cancelled: true;\n}\n\nconst CUSTOM_SENTINEL = '__custom__';\n\n/**\n * Run the license picker. Resolves to either the selected SPDX identifier or\n * a cancellation sentinel; never throws on user cancel.\n */\nexport async function promptLicense(): Promise<PromptLicenseResult | PromptCancelled> {\n const choice = await select<string>({\n message: 'Choose a license for your profile content:',\n options: [\n ...LICENSE_OPTIONS.map((opt) => ({\n value: opt.spdxId,\n label: opt.label,\n hint: opt.hint,\n })),\n { value: CUSTOM_SENTINEL, label: 'Custom', hint: 'enter SPDX identifier' },\n ],\n });\n\n if (isCancel(choice)) {\n cancel('Aborted.');\n return { cancelled: true };\n }\n\n if (choice !== CUSTOM_SENTINEL) {\n return { spdxId: choice };\n }\n\n const customRaw = await text({\n message: 'Enter the SPDX identifier:',\n placeholder: 'e.g. MIT, Apache-2.0, CC-BY-SA-4.0',\n validate(value): string | undefined {\n if (!isValidSpdxInput(value)) {\n return 'Must be a non-empty SPDX-like expression (alphanumerics, ., -, +, parentheses, spaces).';\n }\n return undefined;\n },\n });\n\n if (isCancel(customRaw)) {\n cancel('Aborted.');\n return { cancelled: true };\n }\n\n return { spdxId: customRaw.trim() };\n}\n","/**\n * Top-level scaffolding orchestrator for `create-takuhon`.\n *\n * `writeProject` is the single entry point used by `init.ts`. It creates the\n * target directory (must not already exist), then writes the eight files\n * that make up the scaffold: `takuhon.json`, `wrangler.toml`, `package.json`,\n * `README.md`, `.gitignore`, `.env.example`, `tsconfig.json`, and\n * `src/index.ts` (the Cloudflare Worker entry composed via\n * `createTakuhonWorker` from `@takuhon/cloudflare`).\n */\n\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\nimport { renderEnvExample } from './env-example.js';\nimport { renderGitignore } from './gitignore.js';\nimport { renderPackageJson } from './package-json.js';\nimport { renderReadme } from './readme.js';\nimport { renderTakuhonJson } from './takuhon-json.js';\nimport { renderTsconfigJson } from './tsconfig-json.js';\nimport { renderWorkerIndexTs } from './worker-index-ts.js';\nimport { renderWranglerToml } from './wrangler-toml.js';\n\nexport interface WriteProjectOptions {\n /** Absolute path of the directory to create. Must not exist. */\n readonly targetDir: string;\n /** Used for the npm `name`, Worker name, and README header. */\n readonly projectName: string;\n /** Chosen content license (already mapped via `buildContentLicense`). */\n readonly license: ContentLicenseFragment;\n}\n\nexport interface WriteProjectResult {\n /** Relative paths of files that were written (in the order written). */\n readonly files: readonly string[];\n}\n\n/**\n * Error thrown when the target directory already exists. The caller is\n * expected to render a friendly message that references the user-supplied\n * path; the `code` is stable for tests. The absolute `targetDir` is exposed\n * as a field rather than embedded in the message so that bubbling the error\n * up through generic logging does not leak filesystem layout.\n */\nexport class TargetDirectoryExistsError extends Error {\n override readonly name = 'TargetDirectoryExistsError';\n readonly code = 'TARGET_EXISTS' as const;\n constructor(readonly targetDir: string) {\n super('Target directory already exists.');\n }\n}\n\n/**\n * Create the project directory and write the scaffolded files. Order is\n * deterministic so callers (and tests) can rely on it.\n */\nexport async function writeProject(opts: WriteProjectOptions): Promise<WriteProjectResult> {\n const { targetDir, projectName, license } = opts;\n\n // mkdir with recursive: false fails if the directory exists; we surface a\n // typed error so the CLI entry can render a friendly message.\n try {\n await mkdir(targetDir, { recursive: false });\n } catch (err) {\n if (isNodeErrnoException(err) && err.code === 'EEXIST') {\n throw new TargetDirectoryExistsError(targetDir);\n }\n throw err;\n }\n\n const files: { readonly path: string; readonly content: string }[] = [\n { path: 'takuhon.json', content: renderTakuhonJson(license) },\n { path: 'wrangler.toml', content: renderWranglerToml(projectName) },\n { path: 'package.json', content: renderPackageJson({ projectName }) },\n { path: 'README.md', content: renderReadme({ projectName, license }) },\n { path: '.gitignore', content: renderGitignore() },\n { path: '.env.example', content: renderEnvExample() },\n { path: 'tsconfig.json', content: renderTsconfigJson() },\n { path: 'src/index.ts', content: renderWorkerIndexTs() },\n ];\n\n for (const { path, content } of files) {\n const fullPath = join(targetDir, path);\n const parent = dirname(fullPath);\n if (parent !== targetDir) {\n await mkdir(parent, { recursive: true });\n }\n await writeFile(fullPath, content, 'utf8');\n }\n\n return { files: files.map((f) => f.path) };\n}\n\nfunction isNodeErrnoException(err: unknown): err is NodeJS.ErrnoException {\n return err instanceof Error && typeof (err as NodeJS.ErrnoException).code === 'string';\n}\n","/**\n * Generator for the `.env.example` file in a freshly scaffolded project.\n *\n * The Wrangler-managed secrets (admin bearer token) are *not* read from `.env`\n * at deploy time — `wrangler secret put` is the source of truth. The\n * `.env.example` is therefore documentation: it lists the variables a developer\n * may want locally (e.g. for scripting or for the wrangler CLI itself) and\n * links each to its production provisioning path.\n */\n\nexport function renderEnvExample(): string {\n return `# ----------------------------------------------------------------\n# Local development variables for this Takuhon deployment.\n#\n# Production secrets (admin token) are provisioned via:\n# wrangler secret put TAKUHON_ADMIN_TOKEN\n# This file is a hint for local tooling, not a runtime source.\n# ----------------------------------------------------------------\n\n# Admin bearer token for /api/admin/* endpoints.\n# Generate with: openssl rand -base64 32\n# Then provision with:\n# echo \"$TAKUHON_ADMIN_TOKEN\" | wrangler secret put TAKUHON_ADMIN_TOKEN\nTAKUHON_ADMIN_TOKEN=\n\n# Comma-separated Origin allowlist for browser-originating admin requests.\n# Set in wrangler.toml [vars] for production. Local example:\n# TAKUHON_ADMIN_ORIGIN=https://admin.example.com,https://localhost:8787\nTAKUHON_ADMIN_ORIGIN=\n\n# Cloudflare account id (look up via \\`wrangler whoami\\`). Only needed if you\n# script Cloudflare API calls outside Wrangler itself.\nCLOUDFLARE_ACCOUNT_ID=\n`;\n}\n","/**\n * Generator for the scaffolded project's `.gitignore`.\n *\n * Covers Node, Wrangler local cache, and environment files. Kept conservative\n * — no opinions about lockfile preferences (the user picks their package\n * manager) or editor folders (per-editor patterns belong in a global ignore).\n */\n\nexport function renderGitignore(): string {\n return `# Dependencies\nnode_modules/\n\n# Wrangler local cache (do not commit; contains bundled output and tmp files)\n.wrangler/\n\n# Environment variables (commit \\`.env.example\\` instead)\n.env\n.env.local\n.env.*.local\n\n# Logs\n*.log\nnpm-debug.log*\npnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# macOS\n.DS_Store\n`;\n}\n","/**\n * Generator for the scaffolded project's `package.json`.\n *\n * Pinned dependency versions are caret ranges matched to the current\n * minor of the published `@takuhon/*` packages. Under 0.x semver, a caret\n * does not span minor versions, so the range must move forward with each\n * `@takuhon/core` minor release to keep scaffolded projects on the\n * matching schema generation. A guard test (`scaffold.test.ts`) asserts these\n * pins track the published minor, so a missed bump fails CI rather than\n * silently shipping a stale range. `hono` is included as a direct dependency for\n * projects that extend the Worker with their own Hono routes; the generated\n * `src/index.ts` reaches Takuhon's handlers through `@takuhon/cloudflare`\n * rather than importing `hono` directly. `wrangler` is a devDependency since\n * it's the deploy / dev-server tool.\n */\n\nexport interface PackageJsonOptions {\n /** Used for the npm `name` field. */\n readonly projectName: string;\n}\n\nexport function buildPackageJson(opts: PackageJsonOptions): Record<string, unknown> {\n return {\n name: opts.projectName,\n version: '0.0.0',\n private: true,\n type: 'module',\n description: 'Takuhon profile deployment.',\n scripts: {\n dev: 'wrangler dev',\n deploy: 'wrangler deploy',\n },\n dependencies: {\n '@takuhon/api': '^0.8.0',\n '@takuhon/cloudflare': '^0.8.0',\n '@takuhon/core': '^0.8.0',\n hono: '^4.0.0',\n },\n devDependencies: {\n wrangler: '^4.0.0',\n },\n engines: {\n node: '>=22.0.0',\n },\n };\n}\n\nexport function renderPackageJson(opts: PackageJsonOptions): string {\n return `${JSON.stringify(buildPackageJson(opts), null, 2)}\\n`;\n}\n","/**\n * Generator for the README.md placed in a freshly scaffolded project.\n *\n * Aims to give a first-time user enough to (1) fill in their profile data,\n * (2) provision Cloudflare KV + admin secret, and (3) `pnpm dev` / `pnpm\n * deploy` once the upstream `@takuhon/*` packages are reachable. Cross-\n * references the published `@takuhon/cloudflare` adapter README as the\n * next-step reference for the route map.\n */\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\nexport interface ReadmeOptions {\n readonly projectName: string;\n readonly license: ContentLicenseFragment;\n}\n\n/**\n * Human-readable license attribution line for the README footer. Uses the\n * canonical URL when available; falls back to plain SPDX (or\n * \"All rights reserved\" for Proprietary).\n */\nfunction formatLicenseLine(license: ContentLicenseFragment): string {\n if (license.spdxId === 'Proprietary') {\n return '**Proprietary** — all rights reserved.';\n }\n if (license.url !== undefined) {\n return `[\\`${license.spdxId}\\`](${license.url})`;\n }\n return `\\`${license.spdxId}\\``;\n}\n\nexport function renderReadme(opts: ReadmeOptions): string {\n const { projectName, license } = opts;\n const licenseLine = formatLicenseLine(license);\n return `# ${projectName}\n\nA [Takuhon](https://github.com/takuhon-dev/takuhon) profile deployment, running on Cloudflare Workers.\n\n> **Status**: pre-deploy. Edit \\`takuhon.json\\`, provision Cloudflare KV, then \\`pnpm deploy\\`.\n\n> **Heads-up — Takuhon is in a pre-publish phase.**\n>\n> The \\`@takuhon/api\\`, \\`@takuhon/core\\`, and \\`@takuhon/cloudflare\\` packages\n> referenced in \\`package.json\\` are not yet on the npm registry.\n> \\`pnpm install\\` will fail in this directory until they ship. See *Develop*\n> below for the workspace-link recipe in the meantime.\n\n## What is Takuhon?\n\nTakuhon lets you own your profile as a portable JSON document and publish it as a mobile-first profile page plus a public API (JSON-LD for AI agents and search engines included).\n\n## Setup\n\n1. **Edit your profile.** Open \\`takuhon.json\\` and replace the sample fields (\\`profile.displayName\\`, \\`links\\`, \\`careers\\`, \\`projects\\`, \\`skills\\`) with your own.\n\n2. **Create the Cloudflare KV namespaces** and copy the returned ids into \\`wrangler.toml\\`:\n\n \\`\\`\\`sh\n wrangler kv namespace create TAKUHON_KV\n wrangler kv namespace create TAKUHON_KV --preview\n \\`\\`\\`\n\n3. **Provision the admin token** as a Wrangler secret (used by \\`/api/admin/*\\`):\n\n \\`\\`\\`sh\n openssl rand -base64 32 | wrangler secret put TAKUHON_ADMIN_TOKEN\n \\`\\`\\`\n\n Leaving the secret unset disables admin writes entirely (every \\`PUT\\` / \\`DELETE\\` returns 401).\n\n## Develop\n\nThe Worker entry at \\`src/index.ts\\` composes the takuhon adapter via\n\\`createTakuhonWorker\\` and serves your \\`takuhon.json\\` as the fallback when\nKV has no stored profile yet. Until the \\`@takuhon/*\\` packages are on npm,\nclone the upstream repo and link them into this directory (substitute\nyour own absolute path for \\`<takuhon-repo-path>\\`):\n\n\\`\\`\\`sh\ngit clone https://github.com/takuhon-dev/takuhon <takuhon-repo-path>\n( cd <takuhon-repo-path> && pnpm install && pnpm build )\npnpm link <takuhon-repo-path>/packages/api <takuhon-repo-path>/packages/core <takuhon-repo-path>/adapters/cloudflare\n\\`\\`\\`\n\nThen:\n\n\\`\\`\\`sh\npnpm dev # runs \\`wrangler dev\\` locally\n\\`\\`\\`\n\nThe full route map (public + admin) is documented in the [\\`@takuhon/cloudflare\\` README](https://github.com/takuhon-dev/takuhon/tree/main/adapters/cloudflare#readme).\n\n## Deploy\n\n\\`\\`\\`sh\npnpm deploy # runs \\`wrangler deploy\\`\n\\`\\`\\`\n\n## License\n\nProfile content (\\`takuhon.json\\`) is licensed under ${licenseLine}\n\nThe deployment code is your own; pick a license appropriate for it.\n`;\n}\n","/**\n * Generator for the `takuhon.json` file written into a freshly scaffolded\n * project.\n *\n * The template is a copy of `examples/minimal-profile/takuhon.json` from the\n * monorepo. It is inlined here as a TypeScript constant rather than imported\n * from `examples/` so the published `@takuhon/cli` npm package does not need\n * to ship the examples directory.\n *\n * Only `meta.contentLicense` is rewritten per the user's choice; everything\n * else is the canonical minimal profile (one career, one project, three\n * skills, `en` locale only) that downstream `@takuhon/core` validation\n * already accepts (see `packages/core/src/__tests__/examples-fixtures.test.ts`).\n */\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\n/**\n * Build the `takuhon.json` payload as a deterministic, schema-valid object.\n * `meta.contentLicense` is filled from the supplied fragment so each\n * generated project carries the user's chosen SPDX identifier (and `url` /\n * `rights` where applicable).\n */\nexport function buildTakuhonJson(license: ContentLicenseFragment): unknown {\n return {\n schemaVersion: '0.4.0',\n profile: {\n displayName: {\n en: 'Sam Lee',\n },\n },\n links: [\n {\n id: 'github',\n type: 'github',\n url: 'https://example.com/github/sam-lee',\n featured: true,\n },\n ],\n careers: [\n {\n id: 'first-job',\n organization: {\n en: 'Example Co.',\n },\n role: {\n en: 'Junior Software Engineer',\n },\n startDate: '2026-04',\n endDate: null,\n isCurrent: true,\n },\n ],\n projects: [\n {\n id: 'personal-homepage',\n title: {\n en: 'Personal homepage',\n },\n },\n ],\n skills: [\n { id: 'html', label: 'HTML' },\n { id: 'css', label: 'CSS' },\n { id: 'javascript', label: 'JavaScript' },\n ],\n contact: {},\n settings: {\n defaultLocale: 'en',\n availableLocales: ['en'],\n },\n meta: {\n contentLicense: { ...license },\n },\n };\n}\n\n/** Serialise to a UTF-8 string with trailing newline (POSIX-friendly). */\nexport function renderTakuhonJson(license: ContentLicenseFragment): string {\n return `${JSON.stringify(buildTakuhonJson(license), null, 2)}\\n`;\n}\n","/**\n * Generator for the scaffolded project's `tsconfig.json`.\n *\n * Minimal configuration that makes the generated `src/index.ts` typecheck\n * with `tsc --noEmit` in a freshly scaffolded directory. The settings\n * mirror the upstream takuhon monorepo defaults (ES2022 target, ESNext\n * modules, strict mode, `noUncheckedIndexedAccess`) and explicitly enable\n * the two flags the Worker entry depends on:\n *\n * - `resolveJsonModule` — so `import takuhonJson from '../takuhon.json'`\n * resolves at type-check time.\n * - `moduleResolution: \"Bundler\"` — so the Wrangler / esbuild-style\n * resolution (no need for explicit file extensions) is the source of\n * truth that matches what `wrangler dev` actually runs.\n *\n * `noEmit: true` keeps `tsc` purely a type-checker; Wrangler's bundler\n * produces the deployable artifact.\n */\n\nexport function renderTsconfigJson(): string {\n const config = {\n compilerOptions: {\n target: 'ES2022',\n lib: ['ES2022'],\n module: 'ESNext',\n moduleResolution: 'Bundler',\n esModuleInterop: true,\n resolveJsonModule: true,\n isolatedModules: true,\n verbatimModuleSyntax: true,\n strict: true,\n noUncheckedIndexedAccess: true,\n noImplicitOverride: true,\n noFallthroughCasesInSwitch: true,\n skipLibCheck: true,\n noEmit: true,\n },\n include: ['src/**/*'],\n exclude: ['node_modules'],\n };\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n","/**\n * Generator for `src/index.ts` — the Cloudflare Worker entry file written\n * into a freshly scaffolded project.\n *\n * The generated file uses `createTakuhonWorker()` from `@takuhon/cloudflare`\n * so the scaffolded project does not need to know the internal wiring\n * (Hono router, KV-backed storage, edge cache purger, console audit logger).\n * The user's own `takuhon.json` is loaded via an ES module JSON import,\n * validated once at module load, and the resulting `Takuhon` value is\n * served as the fallback when KV has no stored profile yet.\n *\n * `wrangler.toml`'s `main` field already points at `src/index.ts`, and\n * `nodejs_compat` is enabled, so the file works under `wrangler dev` /\n * `wrangler deploy` without further configuration.\n */\n\nexport function renderWorkerIndexTs(): string {\n return `import { createTakuhonWorker } from '@takuhon/cloudflare';\nimport { validate } from '@takuhon/core';\n\n// Use the project's own takuhon.json as the fallback served when KV has no\n// stored profile yet. Validated once at module load so a malformed profile\n// fails fast rather than at first request.\nimport takuhonJson from '../takuhon.json' with { type: 'json' };\n\nconst fallback = validate(takuhonJson);\nif (!fallback.ok) {\n throw new Error(\n 'Project takuhon.json failed validation: ' +\n fallback.errors.map((e) => \\`\\${e.pointer}: \\${e.message}\\`).join('; '),\n );\n}\n\nconst fallbackTakuhon = fallback.data;\n\nexport default createTakuhonWorker({\n fallback: () => fallbackTakuhon,\n});\n`;\n}\n","/**\n * Generator for `wrangler.toml` in a freshly scaffolded project.\n *\n * The layout mirrors the reference Cloudflare adapter shipped in this\n * monorepo: a single KV namespace `TAKUHON_KV`, placeholder ids the user\n * fills in after running `wrangler kv namespace create`, and the\n * `TAKUHON_ADMIN_ORIGIN` var defaulting to \"\" (disabled). The admin bearer\n * token is provisioned as a Wrangler secret and is therefore not in this file.\n */\n\n/**\n * Validate a Cloudflare Worker name.\n *\n * Cloudflare itself accepts mixed-case DNS labels (1–63 chars, must not\n * start or end with a hyphen). This validator additionally enforces a\n * lowercase convention chosen for the scaffolder so that the resulting\n * `workers.dev` subdomain is predictable and matches the npm `name` field.\n */\nexport function isValidWorkerName(name: string): boolean {\n return /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(name);\n}\n\n/**\n * Render `wrangler.toml` for the given project name.\n *\n * Throws if `projectName` is not a valid Cloudflare Worker name. Callers are\n * responsible for sanitising/validating earlier in the prompt flow.\n */\nexport function renderWranglerToml(projectName: string): string {\n if (!isValidWorkerName(projectName)) {\n throw new Error(\n `Invalid Cloudflare Worker name: \"${projectName}\". Names must be lowercase, ` +\n `start with a letter or digit, and contain only letters, digits, and hyphens (max 63 chars).`,\n );\n }\n return `name = \"${projectName}\"\nmain = \"src/index.ts\"\ncompatibility_date = \"2026-05-01\"\ncompatibility_flags = [\"nodejs_compat\"]\n\n# Replace the placeholder ids after running:\n# wrangler kv namespace create TAKUHON_KV\n# wrangler kv namespace create TAKUHON_KV --preview\n[[kv_namespaces]]\nbinding = \"TAKUHON_KV\"\nid = \"REPLACE_WITH_PRODUCTION_NAMESPACE_ID\"\npreview_id = \"REPLACE_WITH_PREVIEW_NAMESPACE_ID\"\n\n# Admin Origin allowlist (comma-separated). Empty value disables the check.\n# Example for production: TAKUHON_ADMIN_ORIGIN = \"https://admin.example.com\"\n#\n# The admin bearer token MUST be provisioned as a Wrangler secret, never in\n# this file:\n# wrangler secret put TAKUHON_ADMIN_TOKEN\n# Use 32+ bytes of entropy, e.g. \\`openssl rand -base64 32\\`.\n[vars]\nTAKUHON_ADMIN_ORIGIN = \"\"\n`;\n}\n"],"mappings":";;;AAaA,SAAS,oBAAoB;AAC7B,SAAS,UAAU,eAAe;AAClC,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAE1B,SAAS,UAAAA,SAAQ,OAAO,aAAa;;;ACY9B,IAAM,kBAA4C;AAAA,EACvD;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,IACN,QAAQ;AAAA,EACV;AACF;AAaA,IAAM,oBAAsD;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B,SAAS,KAAK;AAIZ,YAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,CAAI;AAC5E,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAGA,SAAS,eAAwB;AAC/B,QAAM,QAAQ,QAAQ,KAAK,CAAC;AAC5B,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI;AACF,WAAO,aAAa,KAAK,MAAM,aAAa,cAAc,YAAY,GAAG,CAAC;AAAA,EAC5E,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,IAAI,aAAa,GAAG;AAClB,OAAK,IAAI;AACX;","names":["cancel","cancel"]}
|
|
1
|
+
{"version":3,"sources":["../src/init.ts","../src/licenses.ts","../src/prompts.ts","../src/scaffold/index.ts","../src/scaffold/env-example.ts","../src/scaffold/gitignore.ts","../src/scaffold/package-json.ts","../src/scaffold/readme.ts","../src/scaffold/takuhon-json.ts","../src/scaffold/tsconfig-json.ts","../src/scaffold/worker-index-ts.ts","../src/scaffold/wrangler-toml.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Entry point for `npx create-takuhon` (and `pnpm create takuhon`).\n *\n * Usage:\n * create-takuhon <target-dir> [--license <spdxId>]\n *\n * The positional target directory is required; it must not already exist (we\n * refuse to overwrite). `--license` skips the interactive picker for CI /\n * automation use.\n */\n\nimport { realpathSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { basename, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { parseArgs } from 'node:util';\n\nimport { cancel, intro, outro } from '@clack/prompts';\n\nimport { buildContentLicense, isValidSpdxInput } from './licenses.js';\nimport { promptLicense } from './prompts.js';\nimport { copyAdminBundle, TargetDirectoryExistsError, writeProject } from './scaffold/index.js';\nimport { isValidWorkerName } from './scaffold/wrangler-toml.js';\n\ninterface CliArgs {\n readonly targetArg: string | undefined;\n readonly extraPositionals: readonly string[];\n readonly license: string | undefined;\n readonly help: boolean;\n}\n\nfunction parseCliArgs(argv: readonly string[]): CliArgs {\n const { values, positionals } = parseArgs({\n args: [...argv],\n allowPositionals: true,\n strict: true,\n options: {\n license: { type: 'string' },\n help: { type: 'boolean', short: 'h' },\n },\n });\n return {\n targetArg: positionals[0],\n extraPositionals: positionals.slice(1),\n license: values.license,\n help: values.help === true,\n };\n}\n\nfunction printHelp(): void {\n process.stdout.write(\n `Usage: create-takuhon <target-dir> [--license <spdxId>]\\n` +\n `\\n` +\n `Scaffolds a Takuhon profile deployment in <target-dir>.\\n` +\n `\\n` +\n `Options:\\n` +\n ` --license <spdxId> Skip the interactive license prompt and use the\\n` +\n ` given SPDX identifier (e.g. CC-BY-4.0, MIT,\\n` +\n ` Proprietary). Useful for CI / automation.\\n` +\n ` -h, --help Show this help.\\n`,\n );\n}\n\nasync function main(argv: readonly string[]): Promise<number> {\n let parsed: CliArgs;\n try {\n parsed = parseCliArgs(argv);\n } catch (err) {\n process.stderr.write(`${(err as Error).message}\\n\\n`);\n printHelp();\n return 2;\n }\n\n if (parsed.help) {\n printHelp();\n return 0;\n }\n\n if (parsed.targetArg === undefined) {\n process.stderr.write(`Error: missing target directory argument.\\n\\n`);\n printHelp();\n return 2;\n }\n\n if (parsed.extraPositionals.length > 0) {\n process.stderr.write(\n `Error: unexpected extra arguments: ${parsed.extraPositionals.join(' ')}\\n\\n`,\n );\n printHelp();\n return 2;\n }\n\n const targetDir = resolve(process.cwd(), parsed.targetArg);\n const projectName = basename(targetDir);\n\n if (!isValidWorkerName(projectName)) {\n process.stderr.write(\n `Error: target directory basename \"${projectName}\" is not a valid Cloudflare Worker name.\\n` +\n `Names must be lowercase, start and end with a letter or digit, and contain only ` +\n `letters, digits, and hyphens (max 63 chars).\\n`,\n );\n return 2;\n }\n\n intro('create-takuhon');\n\n let spdxId: string;\n if (parsed.license !== undefined) {\n const raw = parsed.license.trim();\n if (!isValidSpdxInput(raw)) {\n cancel(`Invalid --license value: \"${parsed.license}\"`);\n return 2;\n }\n spdxId = raw;\n } else {\n const result = await promptLicense();\n if ('cancelled' in result) {\n return 130;\n }\n spdxId = result.spdxId;\n }\n\n const license = buildContentLicense(spdxId);\n\n try {\n await writeProject({ targetDir, projectName, license });\n } catch (err) {\n if (err instanceof TargetDirectoryExistsError) {\n cancel(`Target directory already exists: ${parsed.targetArg}`);\n return 1;\n }\n throw err;\n }\n\n // Copy the bundled admin SPA into the project so the Worker can serve the\n // form UI at /admin. On failure, remove the just-created project directory so\n // the user can retry into the same path (writeProject refuses an existing one).\n try {\n await copyAdminBundle({ targetDir });\n } catch (err) {\n await rm(targetDir, { recursive: true, force: true });\n cancel(err instanceof Error ? err.message : 'Failed to copy the admin UI bundle.');\n return 1;\n }\n\n outro(\n `Created ${projectName} (license: ${spdxId}).\\n` +\n `\\n` +\n `Next steps:\\n` +\n ` cd ${parsed.targetArg}\\n` +\n ` pnpm install\\n` +\n ` # 1. Edit takuhon.json with your profile data\\n` +\n ` # 2. Provision Cloudflare KV: npx wrangler kv namespace create TAKUHON_KV\\n` +\n ` # 3. Set admin token: openssl rand -base64 32 | npx wrangler secret put TAKUHON_ADMIN_TOKEN\\n` +\n ` pnpm dev\\n` +\n `\\n` +\n `The admin form UI is served at /admin (bundled in admin-dist/); sign in\\n` +\n `with the admin token from step 3.`,\n );\n\n return 0;\n}\n\n/**\n * Process entry point: run {@link main} and exit with its code. This is the\n * only function that calls `process.exit`, mirroring the `takuhon` entry in\n * `index.ts`. Exported so the `create-takuhon` redirect package can invoke it\n * after importing this module (`import { run } from '@takuhon/cli/init'`).\n */\nexport async function run(argv: readonly string[] = process.argv.slice(2)): Promise<void> {\n try {\n process.exit(await main(argv));\n } catch (err) {\n // Render only the message — full stack traces can leak host-machine\n // absolute paths and monorepo-internal layout into a published\n // binary's stderr output.\n process.stderr.write(`${err instanceof Error ? err.message : String(err)}\\n`);\n process.exit(1);\n }\n}\n\n/** True when this module was started directly (`node …/init.js`). */\nfunction isEntrypoint(): boolean {\n const entry = process.argv[1];\n if (entry === undefined) return false;\n try {\n return realpathSync(entry) === realpathSync(fileURLToPath(import.meta.url));\n } catch {\n return false;\n }\n}\n\nif (isEntrypoint()) {\n void run();\n}\n","/**\n * Content-license metadata and helpers for the `create-takuhon` scaffolding\n * flow.\n *\n * The four entries in `LICENSE_OPTIONS` are the curated choices the\n * interactive picker offers. \"Custom\" is handled separately by the prompt\n * flow as a free-form SPDX text input. `buildContentLicense` shapes the\n * chosen identifier into the `meta.contentLicense` fragment that lands in\n * the generated `takuhon.json`. The Takuhon profile JSON Schema accepts any\n * SPDX expression in `meta.contentLicense.spdxId`; unknown identifiers fall\n * through with `spdxId` only, and downstream UI rendering is best-effort.\n */\n\n/** A single row in the interactive license selector. */\nexport interface LicenseOption {\n /** Short label shown as the selectable label in the prompt. */\n readonly label: string;\n /** Longer hint shown alongside the label in the prompt UI. */\n readonly hint: string;\n /** SPDX identifier written to `takuhon.json` `meta.contentLicense.spdxId`. */\n readonly spdxId: string;\n /** Canonical license URL. Omitted for `Proprietary`. */\n readonly url?: string;\n}\n\n/**\n * The four curated license choices shown by the interactive picker. \"Custom\"\n * is not in this list because it triggers a free-form text prompt rather than\n * mapping to a fixed SPDX identifier here.\n */\nexport const LICENSE_OPTIONS: readonly LicenseOption[] = [\n {\n label: 'CC BY 4.0',\n hint: 'Allow reuse with attribution',\n spdxId: 'CC-BY-4.0',\n url: 'https://creativecommons.org/licenses/by/4.0/',\n },\n {\n label: 'CC BY-NC 4.0',\n hint: 'Non-commercial reuse with attribution',\n spdxId: 'CC-BY-NC-4.0',\n url: 'https://creativecommons.org/licenses/by-nc/4.0/',\n },\n {\n label: 'CC0',\n hint: 'Public domain',\n spdxId: 'CC0-1.0',\n url: 'https://creativecommons.org/publicdomain/zero/1.0/',\n },\n {\n label: 'Proprietary',\n hint: 'All rights reserved',\n spdxId: 'Proprietary',\n },\n];\n\n/**\n * Canonical URL lookup for SPDX identifiers we recognise but don't list in\n * the interactive picker. Used by `buildContentLicense` so that a user who\n * passes `--license CC-BY-SA-4.0` (or selects it via `Custom`) still gets a\n * usable `url` field in the generated `takuhon.json`.\n *\n * URLs for non-CC SPDX identifiers point at the canonical SPDX license page\n * (`spdx.org/licenses/<id>.html`). Creative Commons identifiers use the\n * `creativecommons.org` deed URL because that is the page humans expect to\n * land on (the SPDX page is metadata-only).\n */\nconst KNOWN_URL_BY_SPDX: Readonly<Record<string, string>> = {\n 'CC0-1.0': 'https://creativecommons.org/publicdomain/zero/1.0/',\n 'CC-BY-4.0': 'https://creativecommons.org/licenses/by/4.0/',\n 'CC-BY-SA-4.0': 'https://creativecommons.org/licenses/by-sa/4.0/',\n 'CC-BY-ND-4.0': 'https://creativecommons.org/licenses/by-nd/4.0/',\n 'CC-BY-NC-4.0': 'https://creativecommons.org/licenses/by-nc/4.0/',\n 'CC-BY-NC-SA-4.0': 'https://creativecommons.org/licenses/by-nc-sa/4.0/',\n 'CC-BY-NC-ND-4.0': 'https://creativecommons.org/licenses/by-nc-nd/4.0/',\n MIT: 'https://spdx.org/licenses/MIT.html',\n};\n\n/** Shape written to `takuhon.json` under `meta.contentLicense`. */\nexport interface ContentLicenseFragment {\n readonly spdxId: string;\n readonly url?: string;\n readonly rights?: string;\n}\n\n/**\n * Translate a chosen SPDX identifier into the `meta.contentLicense` fragment\n * for `takuhon.json`.\n *\n * - `Proprietary` is given a `rights` sentinel and no `url`.\n * - Known SPDX identifiers get a canonical `url`.\n * - Anything else is written as `{ spdxId }` only — the schema accepts\n * arbitrary SPDX expressions, and UI rendering is best-effort.\n */\nexport function buildContentLicense(spdxId: string): ContentLicenseFragment {\n if (spdxId === 'Proprietary') {\n return {\n spdxId: 'Proprietary',\n rights: 'All rights reserved. Contact owner for usage permission.',\n };\n }\n const url = KNOWN_URL_BY_SPDX[spdxId];\n if (url !== undefined) {\n return { spdxId, url };\n }\n return { spdxId };\n}\n\n/**\n * Light syntactic validation for a user-entered SPDX expression (the\n * `Custom` prompt branch and the `--license` flag).\n *\n * We accept any non-empty string composed of the characters that appear in\n * canonical SPDX identifiers and boolean expressions (alphanumerics, `.`,\n * `-`, `+`, parentheses, and literal spaces). Tabs and newlines are rejected\n * because real SPDX expressions never contain them. Full SPDX expression\n * parsing (`MIT OR (Apache-2.0 AND CC-BY-4.0)`) is intentionally out of\n * scope — we trust the user and let the JSON Schema's downstream validation\n * flag obvious problems.\n */\nexport function isValidSpdxInput(input: string): boolean {\n const trimmed = input.trim();\n if (trimmed === '') return false;\n return /^[A-Za-z0-9.\\-+() ]+$/.test(trimmed);\n}\n","/**\n * Interactive prompt flow for `create-takuhon`, built on `@clack/prompts`.\n *\n * A single-choice picker offers the curated `LICENSE_OPTIONS` plus a\n * `Custom` row that opens a free-form SPDX text input. Cancellation\n * (Ctrl+C or pressing Esc on a clack prompt) returns a sentinel result\n * instead of throwing so the caller can exit cleanly with a specific status\n * code.\n */\n\nimport { cancel, isCancel, select, text } from '@clack/prompts';\n\nimport { LICENSE_OPTIONS, isValidSpdxInput } from './licenses.js';\n\n/** Returned by {@link promptLicense} on successful completion. */\nexport interface PromptLicenseResult {\n /** SPDX identifier to write into `meta.contentLicense.spdxId`. */\n readonly spdxId: string;\n}\n\n/** Returned when the user cancels (Ctrl+C / Esc) instead of completing. */\nexport interface PromptCancelled {\n readonly cancelled: true;\n}\n\nconst CUSTOM_SENTINEL = '__custom__';\n\n/**\n * Run the license picker. Resolves to either the selected SPDX identifier or\n * a cancellation sentinel; never throws on user cancel.\n */\nexport async function promptLicense(): Promise<PromptLicenseResult | PromptCancelled> {\n const choice = await select<string>({\n message: 'Choose a license for your profile content:',\n options: [\n ...LICENSE_OPTIONS.map((opt) => ({\n value: opt.spdxId,\n label: opt.label,\n hint: opt.hint,\n })),\n { value: CUSTOM_SENTINEL, label: 'Custom', hint: 'enter SPDX identifier' },\n ],\n });\n\n if (isCancel(choice)) {\n cancel('Aborted.');\n return { cancelled: true };\n }\n\n if (choice !== CUSTOM_SENTINEL) {\n return { spdxId: choice };\n }\n\n const customRaw = await text({\n message: 'Enter the SPDX identifier:',\n placeholder: 'e.g. MIT, Apache-2.0, CC-BY-SA-4.0',\n validate(value): string | undefined {\n if (!isValidSpdxInput(value)) {\n return 'Must be a non-empty SPDX-like expression (alphanumerics, ., -, +, parentheses, spaces).';\n }\n return undefined;\n },\n });\n\n if (isCancel(customRaw)) {\n cancel('Aborted.');\n return { cancelled: true };\n }\n\n return { spdxId: customRaw.trim() };\n}\n","/**\n * Top-level scaffolding orchestrator for `create-takuhon`.\n *\n * `writeProject` creates the target directory (must not already exist), then\n * writes the eight files that make up the scaffold: `takuhon.json`,\n * `wrangler.toml`, `package.json`, `README.md`, `.gitignore`, `.env.example`,\n * `tsconfig.json`, and `src/index.ts` (the Cloudflare Worker entry composed via\n * `createTakuhonWorker` from `@takuhon/cloudflare`).\n *\n * `copyAdminBundle` then copies the bundled admin SPA into the project's\n * `admin-dist/` so the Worker can serve the form UI at `/admin`. `init.ts`\n * calls both in sequence.\n */\n\nimport { cp, mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\nimport { renderEnvExample } from './env-example.js';\nimport { renderGitignore } from './gitignore.js';\nimport { renderPackageJson } from './package-json.js';\nimport { renderReadme } from './readme.js';\nimport { renderTakuhonJson } from './takuhon-json.js';\nimport { renderTsconfigJson } from './tsconfig-json.js';\nimport { renderWorkerIndexTs } from './worker-index-ts.js';\nimport { ADMIN_DIST_DIRNAME, renderWranglerToml } from './wrangler-toml.js';\n\nexport interface WriteProjectOptions {\n /** Absolute path of the directory to create. Must not exist. */\n readonly targetDir: string;\n /** Used for the npm `name`, Worker name, and README header. */\n readonly projectName: string;\n /** Chosen content license (already mapped via `buildContentLicense`). */\n readonly license: ContentLicenseFragment;\n}\n\nexport interface WriteProjectResult {\n /** Relative paths of files that were written (in the order written). */\n readonly files: readonly string[];\n}\n\n/**\n * Error thrown when the target directory already exists. The caller is\n * expected to render a friendly message that references the user-supplied\n * path; the `code` is stable for tests. The absolute `targetDir` is exposed\n * as a field rather than embedded in the message so that bubbling the error\n * up through generic logging does not leak filesystem layout.\n */\nexport class TargetDirectoryExistsError extends Error {\n override readonly name = 'TargetDirectoryExistsError';\n readonly code = 'TARGET_EXISTS' as const;\n constructor(readonly targetDir: string) {\n super('Target directory already exists.');\n }\n}\n\n/**\n * Create the project directory and write the scaffolded files. Order is\n * deterministic so callers (and tests) can rely on it.\n */\nexport async function writeProject(opts: WriteProjectOptions): Promise<WriteProjectResult> {\n const { targetDir, projectName, license } = opts;\n\n // mkdir with recursive: false fails if the directory exists; we surface a\n // typed error so the CLI entry can render a friendly message.\n try {\n await mkdir(targetDir, { recursive: false });\n } catch (err) {\n if (isNodeErrnoException(err) && err.code === 'EEXIST') {\n throw new TargetDirectoryExistsError(targetDir);\n }\n throw err;\n }\n\n const files: { readonly path: string; readonly content: string }[] = [\n { path: 'takuhon.json', content: renderTakuhonJson(license) },\n { path: 'wrangler.toml', content: renderWranglerToml(projectName) },\n { path: 'package.json', content: renderPackageJson({ projectName }) },\n { path: 'README.md', content: renderReadme({ projectName, license }) },\n { path: '.gitignore', content: renderGitignore() },\n { path: '.env.example', content: renderEnvExample() },\n { path: 'tsconfig.json', content: renderTsconfigJson() },\n { path: 'src/index.ts', content: renderWorkerIndexTs() },\n ];\n\n for (const { path, content } of files) {\n const fullPath = join(targetDir, path);\n const parent = dirname(fullPath);\n if (parent !== targetDir) {\n await mkdir(parent, { recursive: true });\n }\n await writeFile(fullPath, content, 'utf8');\n }\n\n return { files: files.map((f) => f.path) };\n}\n\nfunction isNodeErrnoException(err: unknown): err is NodeJS.ErrnoException {\n return err instanceof Error && typeof (err as NodeJS.ErrnoException).code === 'string';\n}\n\n/**\n * Resolve the admin SPA bundle that ships inside this package. The bundle is\n * copied here from `apps/admin/dist` at build time (see\n * `scripts/copy-admin-bundle.mjs`) and listed in the package's `files`, so it\n * is present in the published `@takuhon/cli` tarball. Resolved relative to the\n * compiled module (`dist/init.js` or `dist/index.js`), whose sibling is\n * `admin-bundle/`.\n */\nexport function resolveAdminBundleDir(): string {\n return fileURLToPath(new URL('../admin-bundle', import.meta.url));\n}\n\nexport interface CopyAdminBundleOptions {\n /** Project directory previously created by {@link writeProject}. */\n readonly targetDir: string;\n /**\n * Source bundle directory. Defaults to the bundle shipped in this package\n * ({@link resolveAdminBundleDir}); overridable for tests.\n */\n readonly bundleDir?: string;\n}\n\nexport interface CopyAdminBundleResult {\n /** Absolute path of the directory the bundle was copied into. */\n readonly dest: string;\n}\n\n/**\n * Copy the admin SPA bundle into the scaffolded project's\n * `{@link ADMIN_DIST_DIRNAME}` directory. The generated `wrangler.toml` binds\n * this directory as `ASSETS`, and the Cloudflare Worker serves it at `/admin`\n * under a strict CSP (falling back to an inline editor when the binding is\n * absent). Kept separate from {@link writeProject} so the static-asset copy and\n * the generated-file rendering are independently testable.\n */\nexport async function copyAdminBundle(\n opts: CopyAdminBundleOptions,\n): Promise<CopyAdminBundleResult> {\n const bundleDir = opts.bundleDir ?? resolveAdminBundleDir();\n const dest = join(opts.targetDir, ADMIN_DIST_DIRNAME);\n try {\n await cp(bundleDir, dest, { recursive: true });\n } catch (err) {\n // The bundle ships inside @takuhon/cli, so a failure here means a broken\n // or incomplete install. Surface a sanitized message — the raw error would\n // embed the absolute node_modules path of this package.\n const code = isNodeErrnoException(err) ? ` (${err.code})` : '';\n throw new Error(\n `Failed to copy the admin UI bundle from @takuhon/cli${code}. ` +\n `Reinstall or upgrade @takuhon/cli and try again.`,\n { cause: err },\n );\n }\n return { dest };\n}\n","/**\n * Generator for the `.env.example` file in a freshly scaffolded project.\n *\n * The Wrangler-managed secrets (admin bearer token) are *not* read from `.env`\n * at deploy time — `wrangler secret put` is the source of truth. The\n * `.env.example` is therefore documentation: it lists the variables a developer\n * may want locally (e.g. for scripting or for the wrangler CLI itself) and\n * links each to its production provisioning path.\n */\n\nexport function renderEnvExample(): string {\n return `# ----------------------------------------------------------------\n# Local development variables for this Takuhon deployment.\n#\n# Production secrets (admin token) are provisioned via:\n# wrangler secret put TAKUHON_ADMIN_TOKEN\n# This file is a hint for local tooling, not a runtime source.\n# ----------------------------------------------------------------\n\n# Admin bearer token for /api/admin/* endpoints.\n# Generate with: openssl rand -base64 32\n# Then provision with:\n# echo \"$TAKUHON_ADMIN_TOKEN\" | wrangler secret put TAKUHON_ADMIN_TOKEN\nTAKUHON_ADMIN_TOKEN=\n\n# Comma-separated Origin allowlist for browser-originating admin requests.\n# Set in wrangler.toml [vars] for production. Local example:\n# TAKUHON_ADMIN_ORIGIN=https://admin.example.com,https://localhost:8787\nTAKUHON_ADMIN_ORIGIN=\n\n# Cloudflare account id (look up via \\`wrangler whoami\\`). Only needed if you\n# script Cloudflare API calls outside Wrangler itself.\nCLOUDFLARE_ACCOUNT_ID=\n`;\n}\n","/**\n * Generator for the scaffolded project's `.gitignore`.\n *\n * Covers Node, Wrangler local cache, and environment files. Kept conservative\n * — no opinions about lockfile preferences (the user picks their package\n * manager) or editor folders (per-editor patterns belong in a global ignore).\n */\n\nexport function renderGitignore(): string {\n return `# Dependencies\nnode_modules/\n\n# Wrangler local cache (do not commit; contains bundled output and tmp files)\n.wrangler/\n\n# Environment variables (commit \\`.env.example\\` instead)\n.env\n.env.local\n.env.*.local\n\n# Logs\n*.log\nnpm-debug.log*\npnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# macOS\n.DS_Store\n`;\n}\n","/**\n * Generator for the scaffolded project's `package.json`.\n *\n * Pinned dependency versions are caret ranges matched to the current\n * minor of the published `@takuhon/*` packages. Under 0.x semver, a caret\n * does not span minor versions, so the range must move forward with each\n * `@takuhon/core` minor release to keep scaffolded projects on the\n * matching schema generation. A guard test (`scaffold.test.ts`) asserts these\n * pins track the published minor, so a missed bump fails CI rather than\n * silently shipping a stale range. `hono` is included as a direct dependency for\n * projects that extend the Worker with their own Hono routes; the generated\n * `src/index.ts` reaches Takuhon's handlers through `@takuhon/cloudflare`\n * rather than importing `hono` directly. `wrangler` is a devDependency since\n * it's the deploy / dev-server tool.\n */\n\nexport interface PackageJsonOptions {\n /** Used for the npm `name` field. */\n readonly projectName: string;\n}\n\nexport function buildPackageJson(opts: PackageJsonOptions): Record<string, unknown> {\n return {\n name: opts.projectName,\n version: '0.0.0',\n private: true,\n type: 'module',\n description: 'Takuhon profile deployment.',\n scripts: {\n dev: 'wrangler dev',\n deploy: 'wrangler deploy',\n },\n dependencies: {\n '@takuhon/api': '^0.10.0',\n '@takuhon/cloudflare': '^0.10.0',\n '@takuhon/core': '^0.10.0',\n hono: '^4.0.0',\n },\n devDependencies: {\n wrangler: '^4.0.0',\n },\n engines: {\n node: '>=22.0.0',\n },\n };\n}\n\nexport function renderPackageJson(opts: PackageJsonOptions): string {\n return `${JSON.stringify(buildPackageJson(opts), null, 2)}\\n`;\n}\n","/**\n * Generator for the README.md placed in a freshly scaffolded project.\n *\n * Aims to give a first-time user enough to (1) install dependencies,\n * (2) fill in their profile data, (3) provision Cloudflare KV + admin\n * secret, and (4) `pnpm dev` / `pnpm deploy`. Cross-references the published\n * `@takuhon/cloudflare` adapter README as the next-step reference for the\n * route map.\n */\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\nexport interface ReadmeOptions {\n readonly projectName: string;\n readonly license: ContentLicenseFragment;\n}\n\n/**\n * Human-readable license attribution line for the README footer. Uses the\n * canonical URL when available; falls back to plain SPDX (or\n * \"All rights reserved\" for Proprietary).\n */\nfunction formatLicenseLine(license: ContentLicenseFragment): string {\n if (license.spdxId === 'Proprietary') {\n return '**Proprietary** — all rights reserved.';\n }\n if (license.url !== undefined) {\n return `[\\`${license.spdxId}\\`](${license.url})`;\n }\n return `\\`${license.spdxId}\\``;\n}\n\nexport function renderReadme(opts: ReadmeOptions): string {\n const { projectName, license } = opts;\n const licenseLine = formatLicenseLine(license);\n return `# ${projectName}\n\nA [Takuhon](https://github.com/takuhon-dev/takuhon) profile deployment, running on Cloudflare Workers.\n\n> **Status**: pre-deploy. Edit \\`takuhon.json\\`, provision Cloudflare KV, then \\`pnpm deploy\\`.\n\n## What is Takuhon?\n\nTakuhon lets you own your profile as a portable JSON document and publish it as a mobile-first profile page plus a public API (JSON-LD for AI agents and search engines included).\n\n## Setup\n\n1. **Install dependencies.**\n\n \\`\\`\\`sh\n pnpm install\n \\`\\`\\`\n\n2. **Edit your profile.** Open \\`takuhon.json\\` and replace the sample fields (\\`profile.displayName\\`, \\`links\\`, \\`careers\\`, \\`projects\\`, \\`skills\\`) with your own.\n\n3. **Create the Cloudflare KV namespaces** and copy the returned ids into \\`wrangler.toml\\`:\n\n \\`\\`\\`sh\n npx wrangler kv namespace create TAKUHON_KV\n npx wrangler kv namespace create TAKUHON_KV --preview\n \\`\\`\\`\n\n4. **Provision the admin token** as a Wrangler secret (used by \\`/api/admin/*\\`):\n\n \\`\\`\\`sh\n openssl rand -base64 32 | npx wrangler secret put TAKUHON_ADMIN_TOKEN\n \\`\\`\\`\n\n Leaving the secret unset disables admin writes entirely (every \\`PUT\\` / \\`DELETE\\` returns 401).\n\n## Develop\n\nThe Worker entry at \\`src/index.ts\\` composes the takuhon adapter via\n\\`createTakuhonWorker\\` and serves your \\`takuhon.json\\` as the fallback when\nKV has no stored profile yet.\n\n\\`\\`\\`sh\npnpm dev # runs \\`wrangler dev\\` locally\n\\`\\`\\`\n\nThe full route map (public + admin) is documented in the [\\`@takuhon/cloudflare\\` README](https://github.com/takuhon-dev/takuhon/tree/main/adapters/cloudflare#readme).\n\n## Admin\n\nThe admin form UI is served at \\`/admin\\` under a strict Content-Security-Policy. Its compiled bundle is committed in \\`admin-dist/\\` and bound as Workers Assets in \\`wrangler.toml\\`. Sign in with the admin token you set as the \\`TAKUHON_ADMIN_TOKEN\\` Wrangler secret.\n\nThe bundle is a snapshot taken when this project was created. To pick up a newer admin UI, re-run \\`create-takuhon\\` into a fresh directory and copy its \\`admin-dist/\\` over. To deploy without the form UI, remove the \\`[assets]\\` block from \\`wrangler.toml\\`; the Worker then falls back to a minimal inline editor.\n\n## Deploy\n\n\\`\\`\\`sh\npnpm deploy # runs \\`wrangler deploy\\`\n\\`\\`\\`\n\n## License\n\nProfile content (\\`takuhon.json\\`) is licensed under ${licenseLine}\n\nThe deployment code is your own; pick a license appropriate for it.\n`;\n}\n","/**\n * Generator for the `takuhon.json` file written into a freshly scaffolded\n * project.\n *\n * The template is a copy of `examples/minimal-profile/takuhon.json` from the\n * monorepo. It is inlined here as a TypeScript constant rather than imported\n * from `examples/` so the published `@takuhon/cli` npm package does not need\n * to ship the examples directory.\n *\n * Only `meta.contentLicense` is rewritten per the user's choice; everything\n * else is the canonical minimal profile (one career, one project, three\n * skills, `en` locale only) that downstream `@takuhon/core` validation\n * already accepts (see `packages/core/src/__tests__/examples-fixtures.test.ts`).\n */\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\n/**\n * Build the `takuhon.json` payload as a deterministic, schema-valid object.\n * `meta.contentLicense` is filled from the supplied fragment so each\n * generated project carries the user's chosen SPDX identifier (and `url` /\n * `rights` where applicable).\n */\nexport function buildTakuhonJson(license: ContentLicenseFragment): unknown {\n return {\n schemaVersion: '0.4.0',\n profile: {\n displayName: {\n en: 'Sam Lee',\n },\n },\n links: [\n {\n id: 'github',\n type: 'github',\n url: 'https://example.com/github/sam-lee',\n featured: true,\n },\n ],\n careers: [\n {\n id: 'first-job',\n organization: {\n en: 'Example Co.',\n },\n role: {\n en: 'Junior Software Engineer',\n },\n startDate: '2026-04',\n endDate: null,\n isCurrent: true,\n },\n ],\n projects: [\n {\n id: 'personal-homepage',\n title: {\n en: 'Personal homepage',\n },\n },\n ],\n skills: [\n { id: 'html', label: 'HTML' },\n { id: 'css', label: 'CSS' },\n { id: 'javascript', label: 'JavaScript' },\n ],\n contact: {},\n settings: {\n defaultLocale: 'en',\n availableLocales: ['en'],\n },\n meta: {\n contentLicense: { ...license },\n },\n };\n}\n\n/** Serialise to a UTF-8 string with trailing newline (POSIX-friendly). */\nexport function renderTakuhonJson(license: ContentLicenseFragment): string {\n return `${JSON.stringify(buildTakuhonJson(license), null, 2)}\\n`;\n}\n","/**\n * Generator for the scaffolded project's `tsconfig.json`.\n *\n * Minimal configuration that makes the generated `src/index.ts` typecheck\n * with `tsc --noEmit` in a freshly scaffolded directory. The settings\n * mirror the upstream takuhon monorepo defaults (ES2022 target, ESNext\n * modules, strict mode, `noUncheckedIndexedAccess`) and explicitly enable\n * the two flags the Worker entry depends on:\n *\n * - `resolveJsonModule` — so `import takuhonJson from '../takuhon.json'`\n * resolves at type-check time.\n * - `moduleResolution: \"Bundler\"` — so the Wrangler / esbuild-style\n * resolution (no need for explicit file extensions) is the source of\n * truth that matches what `wrangler dev` actually runs.\n *\n * `noEmit: true` keeps `tsc` purely a type-checker; Wrangler's bundler\n * produces the deployable artifact.\n */\n\nexport function renderTsconfigJson(): string {\n const config = {\n compilerOptions: {\n target: 'ES2022',\n lib: ['ES2022'],\n module: 'ESNext',\n moduleResolution: 'Bundler',\n esModuleInterop: true,\n resolveJsonModule: true,\n isolatedModules: true,\n verbatimModuleSyntax: true,\n strict: true,\n noUncheckedIndexedAccess: true,\n noImplicitOverride: true,\n noFallthroughCasesInSwitch: true,\n skipLibCheck: true,\n noEmit: true,\n },\n include: ['src/**/*'],\n exclude: ['node_modules'],\n };\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n","/**\n * Generator for `src/index.ts` — the Cloudflare Worker entry file written\n * into a freshly scaffolded project.\n *\n * The generated file uses `createTakuhonWorker()` from `@takuhon/cloudflare`\n * so the scaffolded project does not need to know the internal wiring\n * (Hono router, KV-backed storage, edge cache purger, console audit logger).\n * The user's own `takuhon.json` is loaded via an ES module JSON import,\n * validated once at module load, and the resulting `Takuhon` value is\n * served as the fallback when KV has no stored profile yet.\n *\n * `wrangler.toml`'s `main` field already points at `src/index.ts`, and\n * `nodejs_compat` is enabled, so the file works under `wrangler dev` /\n * `wrangler deploy` without further configuration.\n */\n\nexport function renderWorkerIndexTs(): string {\n return `import { createTakuhonWorker } from '@takuhon/cloudflare';\nimport { validate } from '@takuhon/core';\n\n// Use the project's own takuhon.json as the fallback served when KV has no\n// stored profile yet. Validated once at module load so a malformed profile\n// fails fast rather than at first request.\nimport takuhonJson from '../takuhon.json' with { type: 'json' };\n\nconst fallback = validate(takuhonJson);\nif (!fallback.ok) {\n throw new Error(\n 'Project takuhon.json failed validation: ' +\n fallback.errors.map((e) => \\`\\${e.pointer}: \\${e.message}\\`).join('; '),\n );\n}\n\nconst fallbackTakuhon = fallback.data;\n\nexport default createTakuhonWorker({\n fallback: () => fallbackTakuhon,\n});\n`;\n}\n","/**\n * Generator for `wrangler.toml` in a freshly scaffolded project.\n *\n * The layout mirrors the reference Cloudflare adapter shipped in this\n * monorepo: a single KV namespace `TAKUHON_KV`, placeholder ids the user\n * fills in after running `wrangler kv namespace create`, and the\n * `TAKUHON_ADMIN_ORIGIN` var defaulting to \"\" (disabled). The admin bearer\n * token is provisioned as a Wrangler secret and is therefore not in this file.\n */\n\n/**\n * Validate a Cloudflare Worker name.\n *\n * Cloudflare itself accepts mixed-case DNS labels (1–63 chars, must not\n * start or end with a hyphen). This validator additionally enforces a\n * lowercase convention chosen for the scaffolder so that the resulting\n * `workers.dev` subdomain is predictable and matches the npm `name` field.\n */\nexport function isValidWorkerName(name: string): boolean {\n return /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(name);\n}\n\n/**\n * In-project directory the admin SPA bundle is copied into and the scaffolded\n * `wrangler.toml` binds as `ASSETS`. Shared so the copy destination and the\n * `[assets] directory` value cannot drift apart. Defined in this leaf module\n * (which `scaffold/index.ts` already imports) to avoid an import cycle.\n */\nexport const ADMIN_DIST_DIRNAME = 'admin-dist';\n\n/**\n * Render `wrangler.toml` for the given project name.\n *\n * Throws if `projectName` is not a valid Cloudflare Worker name. Callers are\n * responsible for sanitising/validating earlier in the prompt flow.\n */\nexport function renderWranglerToml(projectName: string): string {\n if (!isValidWorkerName(projectName)) {\n throw new Error(\n `Invalid Cloudflare Worker name: \"${projectName}\". Names must be lowercase, ` +\n `start with a letter or digit, and contain only letters, digits, and hyphens (max 63 chars).`,\n );\n }\n return `name = \"${projectName}\"\nmain = \"src/index.ts\"\ncompatibility_date = \"2026-05-01\"\ncompatibility_flags = [\"nodejs_compat\"]\n\n# Admin SPA bundle. The React admin UI is committed in ./${ADMIN_DIST_DIRNAME}\n# (copied here when this project was created with create-takuhon) and served at\n# /admin.\n#\n# run_worker_first = true makes the Worker mediate every request: the bundle's\n# files sit at the assets root, so without this they would shadow the public \"/\"\n# route. The Worker serves the bundle only for /admin/* (attaching the strict\n# admin CSP) and handles everything else itself.\n#\n# SECURITY-CRITICAL: do not set run_worker_first to false or remove it. The\n# Worker is the only thing that attaches the strict admin CSP (plus HSTS /\n# no-store) to the admin assets; serving them directly would expose the admin UI\n# with no policy. To deploy without the form UI, remove this whole [assets]\n# block — the Worker then falls back to a minimal inline editor.\n[assets]\ndirectory = \"${ADMIN_DIST_DIRNAME}\"\nbinding = \"ASSETS\"\nrun_worker_first = true\nnot_found_handling = \"single-page-application\"\n\n# Replace the placeholder ids after running:\n# wrangler kv namespace create TAKUHON_KV\n# wrangler kv namespace create TAKUHON_KV --preview\n[[kv_namespaces]]\nbinding = \"TAKUHON_KV\"\nid = \"REPLACE_WITH_PRODUCTION_NAMESPACE_ID\"\npreview_id = \"REPLACE_WITH_PREVIEW_NAMESPACE_ID\"\n\n# Admin Origin allowlist (comma-separated). Empty value disables the check.\n# Example for production: TAKUHON_ADMIN_ORIGIN = \"https://admin.example.com\"\n#\n# The admin bearer token MUST be provisioned as a Wrangler secret, never in\n# this file:\n# wrangler secret put TAKUHON_ADMIN_TOKEN\n# Use 32+ bytes of entropy, e.g. \\`openssl rand -base64 32\\`.\n[vars]\nTAKUHON_ADMIN_ORIGIN = \"\"\n`;\n}\n"],"mappings":";;;AAaA,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,UAAU,eAAe;AAClC,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,iBAAiB;A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M,CAAC,GAAkB;AACxF,MAAI;AACF,YAAQ,KAAK,MAAM,KAAK,IAAI,CAAC;AAAA,EAC/B,SAAS,KAAK;AAIZ,YAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,CAAI;AAC5E,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAGA,SAAS,eAAwB;AAC/B,QAAM,QAAQ,QAAQ,KAAK,CAAC;AAC5B,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI;AACF,WAAO,aAAa,KAAK,MAAM,aAAaC,eAAc,YAAY,GAAG,CAAC;AAAA,EAC5E,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,IAAI,aAAa,GAAG;AAClB,OAAK,IAAI;AACX;","names":["fileURLToPath","cancel","cancel","fileURLToPath"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takuhon/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "create-takuhon scaffolding plus dev/validate/sync/export/migrate/restore commands",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Takuhon contributors",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"dist",
|
|
42
|
+
"admin-bundle",
|
|
42
43
|
"README.md",
|
|
43
44
|
"LICENSE",
|
|
44
45
|
"NOTICE"
|
|
@@ -52,10 +53,13 @@
|
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
55
|
"@clack/prompts": "^0.11.0",
|
|
55
|
-
"@takuhon/core": "0.
|
|
56
|
+
"@takuhon/core": "0.10.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@takuhon/admin": "0.1.0"
|
|
56
60
|
},
|
|
57
61
|
"scripts": {
|
|
58
62
|
"typecheck": "tsc",
|
|
59
|
-
"build": "tsup src/index.ts src/init.ts --format esm --dts --clean --sourcemap"
|
|
63
|
+
"build": "tsup src/index.ts src/init.ts --format esm --dts --clean --sourcemap && node scripts/copy-admin-bundle.mjs"
|
|
60
64
|
}
|
|
61
65
|
}
|