@kidecms/core 0.1.11 → 0.14.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.
Files changed (180) hide show
  1. package/LICENSE +21 -0
  2. package/admin/components/AssetsGrid.tsx +366 -173
  3. package/admin/components/BlockEditor.tsx +260 -679
  4. package/admin/components/CheckboxField.tsx +2 -2
  5. package/admin/components/CollaborationReviewBar.tsx +384 -0
  6. package/admin/components/ColorField.tsx +87 -0
  7. package/admin/components/CommandPalette.tsx +169 -0
  8. package/admin/components/ContentEditor.tsx +687 -0
  9. package/admin/components/DocumentActions.tsx +4 -2
  10. package/admin/components/DocumentsDataTable.tsx +91 -10
  11. package/admin/components/FieldControl.astro +151 -26
  12. package/admin/components/FocalPointSelector.tsx +27 -1
  13. package/admin/components/InternalLinkPicker.tsx +4 -3
  14. package/admin/components/LinkField.tsx +126 -0
  15. package/admin/components/RelationField.tsx +105 -26
  16. package/admin/components/RepeaterInput.tsx +46 -0
  17. package/admin/components/RichTextEditor.tsx +44 -9
  18. package/admin/components/SharedSectionBlockField.tsx +93 -0
  19. package/admin/components/SidebarUserMenu.tsx +1 -1
  20. package/admin/components/Toast.astro +1 -1
  21. package/admin/components/TreeItemsEditor.tsx +20 -19
  22. package/admin/components/TreeSelect.tsx +2 -2
  23. package/admin/components/YoutubeField.tsx +48 -0
  24. package/admin/components/block-fields.tsx +777 -0
  25. package/admin/components/content-block-spec.ts +114 -0
  26. package/admin/components/slash-command.tsx +242 -0
  27. package/admin/components/tree-utils.ts +14 -2
  28. package/admin/components/ui/badge.tsx +2 -3
  29. package/admin/components/ui/button.tsx +5 -4
  30. package/admin/components/ui/checkbox.tsx +1 -1
  31. package/admin/components/ui/input.tsx +1 -1
  32. package/admin/components/ui/select.tsx +1 -1
  33. package/admin/components/ui/table.tsx +1 -1
  34. package/admin/components/ui/textarea.tsx +1 -1
  35. package/admin/layouts/AdminLayout.astro +323 -123
  36. package/admin/lib/access.ts +54 -0
  37. package/admin/lib/collaboration.ts +178 -0
  38. package/admin/lib/edit-data.ts +448 -0
  39. package/admin/views/AccessDeniedView.astro +8 -0
  40. package/admin/views/EditView.astro +706 -0
  41. package/admin/views/ListView.astro +202 -0
  42. package/admin/views/RecentView.astro +76 -0
  43. package/admin/views/SinglesView.astro +65 -0
  44. package/admin/views/edit/EditScripts.astro +145 -0
  45. package/admin/views/edit/ReverseReferencesList.astro +68 -0
  46. package/core/admin.ts +193 -0
  47. package/core/ai.ts +87 -0
  48. package/core/api.ts +1392 -0
  49. package/core/assets.ts +336 -0
  50. package/core/audit.ts +86 -0
  51. package/core/auth-config.ts +44 -0
  52. package/core/auth.ts +303 -0
  53. package/core/collaboration.ts +276 -0
  54. package/core/content.ts +27 -0
  55. package/core/create-admin.ts +28 -0
  56. package/core/define.ts +623 -0
  57. package/core/field-model.ts +172 -0
  58. package/core/generator.ts +519 -0
  59. package/core/http.ts +42 -0
  60. package/core/image.ts +219 -0
  61. package/core/index.ts +211 -0
  62. package/core/locks.ts +52 -0
  63. package/core/log.ts +37 -0
  64. package/core/migrate.ts +278 -0
  65. package/core/rate-limit.ts +110 -0
  66. package/core/request-scope.ts +33 -0
  67. package/core/richtext.ts +1 -0
  68. package/core/runtime.ts +63 -0
  69. package/core/schema.ts +32 -0
  70. package/core/search.ts +489 -0
  71. package/core/seed.ts +101 -0
  72. package/core/shared-sections.ts +96 -0
  73. package/core/tasks.ts +176 -0
  74. package/core/values.ts +433 -0
  75. package/core/webhooks.ts +85 -0
  76. package/core/youtube.ts +39 -0
  77. package/internals/cli.mjs +34 -0
  78. package/internals/context.ts +67 -0
  79. package/internals/create-admin.ts +40 -0
  80. package/internals/describe.ts +25 -0
  81. package/internals/eject.ts +144 -0
  82. package/internals/generator.ts +11 -0
  83. package/internals/integration.ts +481 -0
  84. package/internals/mcp.ts +397 -0
  85. package/internals/project.ts +31 -0
  86. package/internals/push.ts +160 -0
  87. package/internals/reindex.ts +11 -0
  88. package/internals/restore.ts +257 -0
  89. package/internals/seed.ts +15 -0
  90. package/internals/upgrade.ts +785 -0
  91. package/{virtual.d.ts → internals/virtual.d.ts} +39 -5
  92. package/middleware/auth.ts +130 -17
  93. package/middleware/push.ts +121 -0
  94. package/package.json +55 -67
  95. package/platform/cloudflare/cf-env.ts +60 -0
  96. package/platform/cloudflare/database.ts +28 -0
  97. package/platform/cloudflare/globals.d.ts +5 -0
  98. package/platform/cloudflare/storage.ts +33 -0
  99. package/platform/cloudflare/uploads-route.ts +37 -0
  100. package/platform/node/database.ts +39 -0
  101. package/platform/node/storage.ts +52 -0
  102. package/routes/admin/[...path].astro +71 -0
  103. package/routes/{pages/admin → admin}/assets/[id].astro +25 -19
  104. package/routes/admin/assets/index.astro +90 -0
  105. package/routes/{pages/admin/login.astro → admin/forgot-password.astro} +21 -19
  106. package/routes/{pages/admin → admin}/invite.astro +13 -6
  107. package/routes/admin/login.astro +103 -0
  108. package/routes/admin/reset-password.astro +73 -0
  109. package/routes/{pages/admin → admin}/setup.astro +32 -8
  110. package/routes/api/{cms/[collection] → [collection]}/[...path].ts +67 -15
  111. package/routes/api/admin/search.ts +89 -0
  112. package/routes/api/{cms/assets → assets}/[id].ts +24 -14
  113. package/routes/api/{cms/assets → assets}/index.ts +4 -2
  114. package/routes/api/assets/upload.ts +147 -0
  115. package/routes/api/auth/forgot-password.ts +77 -0
  116. package/routes/api/{cms/auth → auth}/invite.ts +41 -9
  117. package/routes/api/auth/login.ts +167 -0
  118. package/routes/api/{cms/auth → auth}/logout.ts +11 -2
  119. package/routes/api/auth/reset-password.ts +85 -0
  120. package/routes/api/auth/setup.ts +110 -0
  121. package/routes/api/auth/sso/[provider]/start.ts +34 -0
  122. package/routes/api/collaboration/index.ts +106 -0
  123. package/routes/api/cron/_authorize.ts +25 -0
  124. package/routes/api/{cms/cron → cron}/publish.ts +3 -9
  125. package/routes/api/cron/tasks.ts +34 -0
  126. package/routes/api/forms/submit/[slug].ts +143 -0
  127. package/routes/api/img/[...path].ts +65 -0
  128. package/routes/api/{cms/preview → preview}/render.ts +8 -3
  129. package/routes/api/{cms/references → references}/[collection]/[id].ts +31 -1
  130. package/routes/api/webhooks/[provider].ts +54 -0
  131. package/README.md +0 -28
  132. package/dist/admin.d.ts +0 -33
  133. package/dist/admin.js +0 -92
  134. package/dist/ai.d.ts +0 -15
  135. package/dist/ai.js +0 -70
  136. package/dist/api.d.ts +0 -14
  137. package/dist/api.js +0 -833
  138. package/dist/assets.d.ts +0 -51
  139. package/dist/assets.js +0 -163
  140. package/dist/auth.d.ts +0 -30
  141. package/dist/auth.js +0 -132
  142. package/dist/content.d.ts +0 -3
  143. package/dist/content.js +0 -29
  144. package/dist/create-admin.d.ts +0 -5
  145. package/dist/create-admin.js +0 -23
  146. package/dist/define.d.ts +0 -254
  147. package/dist/define.js +0 -36
  148. package/dist/generator.d.ts +0 -9
  149. package/dist/generator.js +0 -370
  150. package/dist/image.d.ts +0 -9
  151. package/dist/image.js +0 -69
  152. package/dist/index.d.ts +0 -28
  153. package/dist/index.js +0 -16
  154. package/dist/integration.d.ts +0 -14
  155. package/dist/integration.js +0 -327
  156. package/dist/locks.d.ts +0 -7
  157. package/dist/locks.js +0 -37
  158. package/dist/richtext.d.ts +0 -1
  159. package/dist/richtext.js +0 -1
  160. package/dist/runtime.d.ts +0 -24
  161. package/dist/runtime.js +0 -26
  162. package/dist/schema.d.ts +0 -17
  163. package/dist/schema.js +0 -13
  164. package/dist/seed.d.ts +0 -2
  165. package/dist/seed.js +0 -84
  166. package/dist/values.d.ts +0 -8
  167. package/dist/values.js +0 -102
  168. package/dist/webhooks.d.ts +0 -2
  169. package/dist/webhooks.js +0 -73
  170. package/routes/api/cms/assets/upload.ts +0 -112
  171. package/routes/api/cms/auth/login.ts +0 -124
  172. package/routes/api/cms/auth/setup.ts +0 -77
  173. package/routes/api/cms/img/[...path].ts +0 -24
  174. package/routes/pages/admin/[...path].astro +0 -1107
  175. package/routes/pages/admin/assets/index.astro +0 -63
  176. /package/routes/api/{cms/ai → ai}/alt-text.ts +0 -0
  177. /package/routes/api/{cms/ai → ai}/seo.ts +0 -0
  178. /package/routes/api/{cms/ai → ai}/translate.ts +0 -0
  179. /package/routes/api/{cms/assets → assets}/folders.ts +0 -0
  180. /package/routes/api/{cms/locks → locks}/[...path].ts +0 -0
@@ -0,0 +1,39 @@
1
+ // Pure, dependency-free YouTube URL helpers. Imported directly by path
2
+ // (`@/cms/core/youtube`) from both the public Astro renderer and the admin React
3
+ // field, so it must stay free of any server-only imports.
4
+
5
+ /**
6
+ * Extract the 11-character video id from any common YouTube URL form:
7
+ * `watch?v=`, `youtu.be/`, `/embed/`, `/shorts/`, `/v/`. Accepts a bare id too.
8
+ * Returns null when no id can be parsed.
9
+ */
10
+ export function getYoutubeId(url: string | null | undefined): string | null {
11
+ if (!url) return null;
12
+ const trimmed = url.trim();
13
+
14
+ // A bare 11-char id (the value editors sometimes paste).
15
+ if (/^[a-zA-Z0-9_-]{11}$/.test(trimmed)) return trimmed;
16
+
17
+ const patterns = [
18
+ /[?&]v=([a-zA-Z0-9_-]{11})/, // watch?v=ID
19
+ /youtu\.be\/([a-zA-Z0-9_-]{11})/, // youtu.be/ID
20
+ /\/embed\/([a-zA-Z0-9_-]{11})/, // /embed/ID
21
+ /\/shorts\/([a-zA-Z0-9_-]{11})/, // /shorts/ID
22
+ /\/v\/([a-zA-Z0-9_-]{11})/, // /v/ID
23
+ ];
24
+ for (const re of patterns) {
25
+ const match = trimmed.match(re);
26
+ if (match) return match[1];
27
+ }
28
+ return null;
29
+ }
30
+
31
+ /** Thumbnail URL for a video id (hqdefault always exists for valid ids). */
32
+ export function youtubeThumbnail(id: string): string {
33
+ return `https://img.youtube.com/vi/${id}/hqdefault.jpg`;
34
+ }
35
+
36
+ /** Privacy-enhanced (no-cookie) embed URL for a video id. */
37
+ export function youtubeEmbedUrl(id: string): string {
38
+ return `https://www.youtube-nocookie.com/embed/${id}`;
39
+ }
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `kide <command>` — runs the CMS runner scripts against the project in cwd.
4
+ * Plain JS launcher: registers tsx, then imports the TypeScript script, so the
5
+ * same bin works whether the runtime is an installed package or an embedded
6
+ * workspace package.
7
+ */
8
+ import { register } from "tsx/esm/api";
9
+
10
+ const COMMANDS = {
11
+ generate: "./generator.ts",
12
+ push: "./push.ts",
13
+ seed: "./seed.ts",
14
+ admin: "./create-admin.ts",
15
+ reindex: "./reindex.ts",
16
+ describe: "./describe.ts",
17
+ upgrade: "./upgrade.ts",
18
+ restore: "./restore.ts",
19
+ eject: "./eject.ts",
20
+ mcp: "./mcp.ts",
21
+ };
22
+
23
+ const [command, ...rest] = process.argv.slice(2);
24
+
25
+ if (!command || !(command in COMMANDS)) {
26
+ console.error(`Usage: kide <command> [options]\n\nCommands:\n ${Object.keys(COMMANDS).join("\n ")}`);
27
+ process.exit(command ? 1 : 0);
28
+ }
29
+
30
+ // Scripts parse their own flags from process.argv.slice(2).
31
+ process.argv = [process.argv[0], process.argv[1], ...rest];
32
+
33
+ register();
34
+ await import(new URL(COMMANDS[command], import.meta.url).href);
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Bootstrap the CMS for a standalone Node script — migrations, seeds, one-off
3
+ * maintenance — run via `node --import tsx scripts/<file>.ts`.
4
+ *
5
+ * `createCmsContext()` wires the runtime (DB / storage / email adapters) by
6
+ * loading the project's `src/cms/runtime.ts`, so you don't have to remember the
7
+ * import-order dance. It then hands back the typed API plus the handles a
8
+ * script usually needs.
9
+ *
10
+ * import { createCmsContext } from "@kidecms/core/context";
11
+ *
12
+ * const { cms, assets, flush, dispose } = await createCmsContext();
13
+ * await cms.posts.create({ title: "…" }, { _system: true, _skipSearch: true });
14
+ * await flush(); // drain fire-and-forget search/audit tasks before exit
15
+ * await dispose(); // flush + close the DB connection
16
+ *
17
+ * For bulk imports, pass `{ _system: true, _skipSearch: true }` to writes and
18
+ * call `reindex()` once at the end instead of indexing per document.
19
+ */
20
+ import {
21
+ assets,
22
+ closeDb,
23
+ createCms,
24
+ describeModel,
25
+ ensureSearchSchema,
26
+ flushTasks,
27
+ folders,
28
+ getDb,
29
+ importDocuments,
30
+ reindexAll,
31
+ type ImportItem,
32
+ } from "../core";
33
+ import { loadProjectConfig, loadProjectRuntime } from "./project";
34
+
35
+ export const createCmsContext = async () => {
36
+ await loadProjectRuntime(); // side effect: configureCmsRuntime()
37
+ const config = await loadProjectConfig();
38
+ const cms = createCms(config);
39
+ const db = await getDb();
40
+ return {
41
+ /** Typed local API: `cms.posts.create(...)`, `cms.pages.deleteMany(...)`, … */
42
+ cms,
43
+ /** Drizzle instance for the dev SQLite database (escape hatch). */
44
+ db,
45
+ /** Asset store: `assets.upload(file, { alt, dedupe })`. */
46
+ assets,
47
+ folders,
48
+ /** The resolved CMS config. */
49
+ config,
50
+ /** Validate + create a batch of documents. Pass `{ dryRun: true }` for a report only. */
51
+ load: (items: ImportItem[], options?: { dryRun?: boolean; context?: Record<string, unknown> }) =>
52
+ importDocuments(cms as Record<string, any>, config, items, options),
53
+ /** The machine-readable content model (same as `.kide/model.json`). */
54
+ model: () => describeModel(config),
55
+ /** Rebuild the search index for all searchable collections (uses this config's locales). */
56
+ reindex: () => reindexAll(config.collections, config.locales?.supported ?? []),
57
+ /** Create the FTS search schema if missing (call before indexing). */
58
+ ensureSearchSchema,
59
+ /** Await all fire-and-forget search/audit tasks queued so far. */
60
+ flush: flushTasks,
61
+ /** Flush pending tasks, then close the database connection. */
62
+ dispose: async () => {
63
+ await flushTasks();
64
+ await closeDb();
65
+ },
66
+ };
67
+ };
@@ -0,0 +1,40 @@
1
+ import { createInterface } from "node:readline";
2
+ import { closeDb, createAdminUser, MIN_PASSWORD_LENGTH } from "../core";
3
+ import { loadProjectRuntime } from "./project";
4
+
5
+ await loadProjectRuntime();
6
+
7
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
8
+ const ask = (question: string): Promise<string> =>
9
+ new Promise((resolve) => rl.question(question, (answer) => resolve(answer.trim())));
10
+
11
+ async function main() {
12
+ const name = await ask("Name: ");
13
+ if (!name) {
14
+ console.error("Name is required.");
15
+ process.exit(1);
16
+ }
17
+
18
+ const email = await ask("Email: ");
19
+ if (!email) {
20
+ console.error("Email is required.");
21
+ process.exit(1);
22
+ }
23
+
24
+ const password = await ask("Password: ");
25
+ if (!password || password.length < MIN_PASSWORD_LENGTH) {
26
+ console.error(`Password must be at least ${MIN_PASSWORD_LENGTH} characters.`);
27
+ process.exit(1);
28
+ }
29
+
30
+ rl.close();
31
+
32
+ await createAdminUser({ name, email, password });
33
+ console.log(`Admin user "${name}" created.`);
34
+ await closeDb();
35
+ }
36
+
37
+ main().catch((error) => {
38
+ console.error(error.message);
39
+ process.exit(1);
40
+ });
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `pnpm cms:describe` — emit the content-model manifest a migration agent reads
3
+ * INSTEAD of reverse-engineering the codebase:
4
+ * - `.kide/model.json` — machine-readable (collections, fields, controls,
5
+ * value shapes, block registry, content-AST schema, field-type table)
6
+ * - `MODEL.md` — the same, human/agent-readable
7
+ *
8
+ * Pure config → manifest; no database needed.
9
+ */
10
+ import { mkdirSync, writeFileSync } from "node:fs";
11
+ import path from "node:path";
12
+
13
+ import { describeModel, renderModelMarkdown } from "../core";
14
+ import { loadProjectConfig } from "./project";
15
+
16
+ const config = await loadProjectConfig();
17
+
18
+ const outDir = path.join(process.cwd(), ".kide");
19
+ mkdirSync(outDir, { recursive: true });
20
+
21
+ const model = describeModel(config);
22
+ writeFileSync(path.join(outDir, "model.json"), JSON.stringify(model, null, 2) + "\n");
23
+ writeFileSync(path.join(process.cwd(), "MODEL.md"), renderModelMarkdown(config));
24
+
25
+ console.log(`[cms:describe] wrote .kide/model.json (${model.collections.length} collections) and MODEL.md`);
@@ -0,0 +1,144 @@
1
+ /**
2
+ * `kide eject` — convert a package-mode project to embedded mode by copying the
3
+ * installed @kidecms/core source into src/cms/ and linking it as a pnpm
4
+ * workspace package. Import specifiers are identical in both modes, so no code
5
+ * changes — only where the package resolves from.
6
+ *
7
+ * Ejecting is one-way: from here on you own the runtime source and upgrades
8
+ * use the release-packet flow. To try embedded mode without committing, run
9
+ * eject on a branch. For a single small tweak in package mode, prefer
10
+ * `pnpm patch @kidecms/core` over ejecting.
11
+ */
12
+ import { execFileSync } from "node:child_process";
13
+ import { cpSync, existsSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
14
+ import path from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+
17
+ const MANAGED_DIRS = ["admin", "client", "core", "internals", "middleware", "platform", "routes"];
18
+
19
+ const USAGE = `Usage: kide eject [--allow-dirty]
20
+
21
+ Copies the installed @kidecms/core source into src/cms/ and links it as a pnpm
22
+ workspace package. One-way — evaluate on a branch, or use \`pnpm patch\` for
23
+ small package-mode tweaks.
24
+
25
+ Options:
26
+ --allow-dirty Eject even with uncommitted changes in the worktree
27
+ --help Show this help`;
28
+
29
+ // Strict argv handling: this command is irreversible, so an unrecognized flag
30
+ // (including the removed --undo/--force) must never fall through into eject.
31
+ let allowDirty = false;
32
+ for (const arg of process.argv.slice(2)) {
33
+ if (arg === "--allow-dirty") {
34
+ allowDirty = true;
35
+ } else if (arg === "--help" || arg === "-h") {
36
+ console.log(USAGE);
37
+ process.exit(0);
38
+ } else if (arg === "--undo" || arg === "--force") {
39
+ console.error(`[kide:eject] ${arg} was removed — eject is one-way. Re-scaffold in package mode to go back.`);
40
+ process.exit(1);
41
+ } else {
42
+ console.error(`[kide:eject] Unknown option: ${arg}\n\n${USAGE}`);
43
+ process.exit(1);
44
+ }
45
+ }
46
+
47
+ const cwd = process.cwd();
48
+
49
+ // This file lives inside the installed package, so its own location IS the
50
+ // source to eject (realpath resolves pnpm's symlink into the store).
51
+ const packageRoot = path.dirname(realpathSync(path.dirname(fileURLToPath(import.meta.url))));
52
+
53
+ const corePath = path.join(cwd, "src/cms");
54
+ const rootPkgPath = path.join(cwd, "package.json");
55
+
56
+ const gitIsDirty = () => {
57
+ try {
58
+ return (
59
+ execFileSync("git", ["status", "--porcelain"], {
60
+ cwd,
61
+ encoding: "utf-8",
62
+ stdio: ["ignore", "pipe", "pipe"],
63
+ }).trim().length > 0
64
+ );
65
+ } catch {
66
+ return false; // not a git repo — nothing to protect
67
+ }
68
+ };
69
+
70
+ const readJson = (file: string) => JSON.parse(readFileSync(file, "utf-8"));
71
+
72
+ const updateStamp = (patch: Record<string, unknown>) => {
73
+ const stampPath = path.join(cwd, ".kide-version");
74
+ if (!existsSync(stampPath)) return;
75
+ const stamp = readJson(stampPath);
76
+ writeFileSync(stampPath, `${JSON.stringify({ ...stamp, ...patch }, null, 2)}\n`);
77
+ };
78
+
79
+ const eject = () => {
80
+ const rootPkg = readJson(rootPkgPath);
81
+ if (!rootPkg.dependencies?.["@kidecms/core"]) {
82
+ throw new Error("package.json has no @kidecms/core dependency — nothing to eject.");
83
+ }
84
+ if (existsSync(path.join(corePath, "core"))) {
85
+ throw new Error("src/cms/core already exists — this project looks embedded already.");
86
+ }
87
+ if (!allowDirty && gitIsDirty()) {
88
+ throw new Error("The worktree has uncommitted changes. Commit/stash them first, or rerun with --allow-dirty.");
89
+ }
90
+
91
+ // A pre-existing workspace file is the user's — never overwrite it, and only
92
+ // proceed when src/cms is already listed (checked before any mutation).
93
+ const workspacePath = path.join(cwd, "pnpm-workspace.yaml");
94
+ const hasWorkspaceFile = existsSync(workspacePath);
95
+ if (hasWorkspaceFile && !/(^|\s)-\s*["']?src\/cms["']?\s*$/m.test(readFileSync(workspacePath, "utf-8"))) {
96
+ throw new Error(
97
+ 'pnpm-workspace.yaml exists but does not list src/cms. Add "- src/cms" under `packages:` and rerun.',
98
+ );
99
+ }
100
+
101
+ const version = readJson(path.join(packageRoot, "package.json")).version as string;
102
+ console.log(`[kide:eject] Ejecting @kidecms/core@${version} into src/cms/`);
103
+
104
+ for (const dir of MANAGED_DIRS) {
105
+ cpSync(path.join(packageRoot, dir), path.join(corePath, dir), {
106
+ recursive: true,
107
+ // Judge only the path below the package root — the installed package's own
108
+ // absolute path contains node_modules segments (pnpm store).
109
+ filter: (src) => !path.relative(packageRoot, src).split(path.sep).includes("node_modules"),
110
+ });
111
+ }
112
+ cpSync(path.join(packageRoot, "package.json"), path.join(corePath, "package.json"));
113
+
114
+ if (!hasWorkspaceFile) {
115
+ writeFileSync(workspacePath, "packages:\n - src/cms\n");
116
+ }
117
+
118
+ rootPkg.dependencies["@kidecms/core"] = "workspace:*";
119
+ writeFileSync(rootPkgPath, `${JSON.stringify(rootPkg, null, 2)}\n`);
120
+
121
+ updateStamp({ mode: "embedded", ejectedAt: new Date().toISOString() });
122
+
123
+ console.log("[kide:eject] Running pnpm install...");
124
+ try {
125
+ // --no-frozen-lockfile: eject just rewrote the dep spec, so the lockfile is always stale here
126
+ execFileSync("pnpm", ["install", "--no-frozen-lockfile"], { cwd, stdio: "inherit" });
127
+ } catch {
128
+ console.error(
129
+ "[kide:eject] Files are ejected and package.json is updated, but pnpm install failed.\n" +
130
+ "[kide:eject] Fix the install error and run `pnpm install` to finish — no other step is pending.",
131
+ );
132
+ process.exit(1);
133
+ }
134
+
135
+ console.log("[kide:eject] Done. The CMS runtime now lives in src/cms/ — read, debug, and modify it freely.");
136
+ console.log("[kide:eject] Ejecting is one-way; future upgrades use the release-packet flow (pnpm cms:upgrade).");
137
+ };
138
+
139
+ try {
140
+ eject();
141
+ } catch (error) {
142
+ console.error(`[kide:eject] ${(error as Error).message}`);
143
+ process.exit(1);
144
+ }
@@ -0,0 +1,11 @@
1
+ import { generate } from "../core";
2
+ import { loadProjectConfig, projectPath } from "./project";
3
+
4
+ const config = await loadProjectConfig();
5
+
6
+ await generate(config, {
7
+ outputDir: projectPath("src/cms/.generated"),
8
+ coreImportPath: "@kidecms/core",
9
+ runtimeImportPath: "../runtime",
10
+ configImportPath: "../cms.config",
11
+ });