octocms 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agentDocs-W6CQBLWC.js → agentDocs-M3R2CPUQ.js} +2 -2
- package/dist/{chunk-AQACHV5O.js → chunk-DCDFWNC6.js} +59 -6
- package/dist/chunk-DCDFWNC6.js.map +1 -0
- package/dist/chunk-GL7FGEA4.js +7 -0
- package/dist/{chunk-YQQT73XR.js.map → chunk-GL7FGEA4.js.map} +1 -1
- package/dist/cli/index.js +4 -4
- package/dist/cli/lib/templates.js +58 -5
- package/dist/cli/lib/templates.js.map +1 -1
- package/dist/{init-62DCMFY2.js → init-W645ZB34.js} +20 -15
- package/dist/init-W645ZB34.js.map +1 -0
- package/dist/{update-RWXTBSDH.js → update-QNJRYPMC.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-AQACHV5O.js.map +0 -1
- package/dist/chunk-YQQT73XR.js +0 -7
- package/dist/init-62DCMFY2.js.map +0 -1
- /package/dist/{agentDocs-W6CQBLWC.js.map → agentDocs-M3R2CPUQ.js.map} +0 -0
- /package/dist/{update-RWXTBSDH.js.map → update-QNJRYPMC.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
agentsMdSection,
|
|
3
3
|
agentsMdTemplate
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DCDFWNC6.js";
|
|
5
5
|
import {
|
|
6
6
|
log
|
|
7
7
|
} from "./chunk-6PHFHGTZ.js";
|
|
@@ -35,4 +35,4 @@ async function agentDocsCommand(projectRoot) {
|
|
|
35
35
|
export {
|
|
36
36
|
agentDocsCommand
|
|
37
37
|
};
|
|
38
|
-
//# sourceMappingURL=agentDocs-
|
|
38
|
+
//# sourceMappingURL=agentDocs-M3R2CPUQ.js.map
|
|
@@ -172,15 +172,44 @@ ${CONFIG_INIT_IMPORT}
|
|
|
172
172
|
export { mediaRoute as GET } from 'octocms/admin/mediaRoute';
|
|
173
173
|
`;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function buildStarterSchema(opts) {
|
|
176
|
+
const git = { baseBranch: opts.baseBranch };
|
|
177
|
+
if (opts.pointerBranch) git.publishedPointerBranch = opts.pointerBranch;
|
|
178
|
+
return {
|
|
179
|
+
projectName: opts.projectName,
|
|
180
|
+
git,
|
|
181
|
+
contentFolder: "cms/content",
|
|
182
|
+
mediaContentFolder: "cms/media",
|
|
183
|
+
mediaFolder: "public/media",
|
|
184
|
+
mediaAllowedFormats: ["png", "jpg", "jpeg", "gif", "webp", "svg", "avif"],
|
|
185
|
+
collections: {
|
|
186
|
+
helloPage: {
|
|
187
|
+
label: "Hello Page",
|
|
188
|
+
fields: {
|
|
189
|
+
title: { label: "Title", format: "string", entryTitle: true, required: true },
|
|
190
|
+
description: { label: "Description", format: "text" }
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function schemaJsonTemplate(opts) {
|
|
197
|
+
return JSON.stringify(buildStarterSchema(opts), null, 2) + "\n";
|
|
198
|
+
}
|
|
199
|
+
function generatedSchemaShimTemplate(opts) {
|
|
176
200
|
const gitBlock = opts.pointerBranch ? ` git: {
|
|
177
201
|
baseBranch: '${opts.baseBranch}',
|
|
178
202
|
publishedPointerBranch: '${opts.pointerBranch}',
|
|
179
203
|
},` : ` git: { baseBranch: '${opts.baseBranch}' },`;
|
|
180
|
-
return
|
|
181
|
-
|
|
204
|
+
return `/*
|
|
205
|
+
* AUTO-GENERATED \u2014 DO NOT EDIT.
|
|
206
|
+
* Generated from cms/schema.json.
|
|
207
|
+
* Run \`npx octocms types:gen\` to regenerate.
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
import { defineConfig } from 'octocms/defineConfig';
|
|
182
211
|
|
|
183
|
-
const
|
|
212
|
+
export const schema = defineConfig({
|
|
184
213
|
projectName: '${opts.projectName}',
|
|
185
214
|
${gitBlock}
|
|
186
215
|
contentFolder: 'cms/content',
|
|
@@ -197,8 +226,30 @@ ${gitBlock}
|
|
|
197
226
|
},
|
|
198
227
|
},
|
|
199
228
|
});
|
|
229
|
+
`;
|
|
230
|
+
}
|
|
231
|
+
function octoConfigTemplate(_opts) {
|
|
232
|
+
return `import type { Config } from 'octocms/types';
|
|
233
|
+
import { schema } from './__generated__/schema';
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The schema is defined in \`cms/schema.json\` (source of truth \u2014 hand-editable
|
|
237
|
+
* and editable through the Content Model UI). \`npx octocms types:gen\` mirrors
|
|
238
|
+
* it into \`cms/__generated__/schema.ts\` as a literal-typed \`defineConfig()\`
|
|
239
|
+
* call so the downstream \`query()\` API can infer narrow collection / field /
|
|
240
|
+
* format types (which a plain JSON import cannot preserve).
|
|
241
|
+
*
|
|
242
|
+
* \`npm run types:check\` fails if the JSON and the generated shim drift.
|
|
243
|
+
*/
|
|
244
|
+
const _typedConfigOctoCMS = schema;
|
|
200
245
|
|
|
201
|
-
|
|
246
|
+
/** Runtime config \u2014 widened to \`Config\` for dynamic indexing in CMS internals. */
|
|
247
|
+
export const configOctoCMS: Config = _typedConfigOctoCMS as Config;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Exact literal type of the config \u2014 use this for type-level inference only
|
|
251
|
+
* (e.g. the \`query()\` API derives collection/field names from it).
|
|
252
|
+
*/
|
|
202
253
|
export type OctoConfig = typeof _typedConfigOctoCMS;
|
|
203
254
|
`;
|
|
204
255
|
}
|
|
@@ -357,6 +408,8 @@ export {
|
|
|
357
408
|
nextAuthRouteTemplate,
|
|
358
409
|
agentChatRouteTemplate,
|
|
359
410
|
mediaRouteTemplate,
|
|
411
|
+
schemaJsonTemplate,
|
|
412
|
+
generatedSchemaShimTemplate,
|
|
360
413
|
octoConfigTemplate,
|
|
361
414
|
nextConfigTemplate,
|
|
362
415
|
demoHelloPageJson,
|
|
@@ -367,4 +420,4 @@ export {
|
|
|
367
420
|
agentsMdTemplate,
|
|
368
421
|
tsconfigPaths
|
|
369
422
|
};
|
|
370
|
-
//# sourceMappingURL=chunk-
|
|
423
|
+
//# sourceMappingURL=chunk-DCDFWNC6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../cli/lib/templates.ts"],"sourcesContent":["/**\n * File templates used by `octocms init` and `octocms update`.\n */\n\nconst CODEGEN_BANNER = `/*\n * AUTO-GENERATED — DO NOT EDIT.\n * Generated from cms/octocms.config.ts.\n * Run \\`npx octocms types:gen\\` to regenerate.\n */\n\n`;\n\n/** Static cms/__generated__/types.ts for the helloPage demo schema. */\nexport const generatedTypesTemplate =\n CODEGEN_BANNER +\n `import type { EntryStatus } from 'octocms/types';\n\nexport interface HelloPageFields {\n title: string;\n description: string;\n}\n\nexport interface HelloPageEntry {\n sys: { id: string; type: 'helloPage'; status: EntryStatus };\n fields: HelloPageFields;\n}\n\nexport type AnyEntry = HelloPageEntry;\n\nexport type EntryMap = {\n helloPage: HelloPageEntry;\n};\n`;\n\n/** Static cms/__generated__/enums.ts for the helloPage demo schema. */\nexport const generatedEnumsTemplate =\n CODEGEN_BANNER +\n `export const CollectionName = {\n HelloPage: 'helloPage',\n} as const;\nexport type CollectionName = (typeof CollectionName)[keyof typeof CollectionName];\n\nexport const COLLECTION_NAMES = ['helloPage'] as const;\n\nexport const FieldFormat = {\n String: 'string',\n Text: 'text',\n Markdown: 'markdown',\n Boolean: 'boolean',\n Reference: 'reference',\n Image: 'image',\n Number: 'number',\n Datetime: 'datetime',\n Json: 'json',\n Slug: 'slug',\n Select: 'select',\n Url: 'url',\n Color: 'color',\n Conditional: 'conditional',\n Richtext: 'richtext',\n} as const;\nexport type FieldFormat = (typeof FieldFormat)[keyof typeof FieldFormat];\n`;\n\n/** Static cms/__generated__/content.d.ts for the helloPage demo schema. */\nexport const generatedContentDeclsTemplate =\n CODEGEN_BANNER +\n `import type { EntryStatus } from 'octocms/types';\n\n// Raw on-disk types (before query() processing).\nexport interface RawHelloPageFields {\n title: string;\n description: string;\n}\n\nexport interface RawHelloPageEntry {\n sys: { id: string; type: 'helloPage'; status: EntryStatus };\n fields: RawHelloPageFields;\n}\n`;\n\n/** Static cms/__generated__/index.ts — always the same shape. */\nexport const generatedIndexTemplate =\n CODEGEN_BANNER +\n `export * from './types';\nexport * from './enums';\nexport * from './query';\n`;\n\n/** Static cms/__generated__/query.ts — always the same shape (schema-independent). */\nexport const generatedQueryTemplate =\n CODEGEN_BANNER +\n `import { createQuery } from 'octocms/query';\nimport { configOctoCMS, type OctoConfig } from '../octocms.config';\nimport type { EntryMap } from './types';\n\n// configOctoCMS is widened to Config for admin internals; cast back to OctoConfig so\n// createQuery preserves literal collection/field names for type-safe queries.\nexport const query = createQuery<EntryMap, OctoConfig>(configOctoCMS as unknown as OctoConfig);\n`;\n\n/** Static cms/__generated__/configInit.ts — always the same shape (schema-independent). */\nexport const generatedConfigInitTemplate =\n CODEGEN_BANNER +\n `import { configOctoCMS } from '../octocms.config';\nimport { setConfig } from 'octocms/lib/configStore';\n\nsetConfig(configOctoCMS);\n`;\n\n/**\n * All scaffolded files import the generated config initialiser via the bare\n * specifier `cms/__generated__/configInit`. Resolution works in two layers:\n *\n * - TypeScript IntelliSense: the consumer's `tsconfig.json` `paths` (added\n * by `octocms init`).\n * - Bundler: an alias registered by `withOctoCMS()` so Webpack and Turbopack\n * resolve the bare specifier from anywhere — including `app/layout.tsx`,\n * route handlers at any depth, and files inside `node_modules/octocms/`.\n *\n * This eliminates the previous depth-counting (`'../../../cms/...'`) that was\n * a recurring source of off-by-one bugs across templates and routes.\n */\nconst CONFIG_INIT_IMPORT = \"import 'cms/__generated__/configInit';\";\n\n/**\n * Minimal root layout written when `app/layout.tsx` does not already exist.\n * The configInit import is the critical side-effect; the rest is a Next.js\n * boilerplate shell.\n */\nexport const rootLayoutTemplate = `${CONFIG_INIT_IMPORT}\nimport type { Metadata } from 'next';\n\nexport const metadata: Metadata = {\n title: 'My App',\n};\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n );\n}\n`;\n\n/** The one-liner prepended to an existing root layout to register the config. */\nexport const rootLayoutConfigInitImport = `${CONFIG_INIT_IMPORT}\\n`;\n\nexport function buildAdminLayoutTemplate(): string {\n return `${CONFIG_INIT_IMPORT}\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin';\n`;\n}\n\n/**\n * Catch-all admin route — every \\`/cms/*\\` URL renders the package's\n * \\`AdminApp\\` async server component (awaits \\`params\\`, no outer Suspense).\n * Side-effect-imports \\`configInit\\` so server-action bundles register\n * \\`setConfig()\\` even when Next.js does not load \\`layout.tsx\\` for the POST.\n */\nexport function buildAdminPageTemplate(): string {\n return `// Registers setConfig() for server actions — some POST bundles skip layout.tsx.\n${CONFIG_INIT_IMPORT}\n\nexport { AdminApp as default } from 'octocms/admin';\n`;\n}\n\n/**\n * Admin error boundary — rendered by Next.js when anything in the catch-all\n * tree throws during render. Re-uses the shared \\`AdminErrorView\\` so GitHub\n * config / auth / availability / rate-limit copy stays consistent with the\n * public-page error boundary.\n */\nexport const adminErrorTemplate = `'use client';\n\nexport { AdminError as default } from 'octocms/admin';\n`;\n\n/**\n * Historical template values used by \\`octocms update\\` to recognise an\n * unmodified install when migrating between routing models. Each entry is\n * the literal file content shipped by a previous OctoCMS version. If a\n * user-app file matches one of these byte-for-byte, \\`update\\` will replace\n * it with the current template; otherwise it leaves it alone.\n */\nexport const LEGACY_ADMIN_LAYOUT_TEMPLATES: ReadonlyArray<string> = [\n // 0.4.x — re-exported from the deep path.\n `import '../../cms/__generated__/configInit';\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin/pages/AdminLayout';\n`,\n // 0.5.x — barrel re-export with depth-counted relative configInit import.\n `import '../../cms/__generated__/configInit';\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin';\n`,\n];\n\nexport const LEGACY_ADMIN_CATCH_ALL_TEMPLATES: ReadonlyArray<string> = [\n // 0.4.x — re-exported from the deep path.\n `export { AdminApp as default } from 'octocms/admin/AdminApp';\n`,\n // 0.5.x — barrel re-export without configInit on the page (server actions could miss setConfig).\n `export { AdminApp as default } from 'octocms/admin';\n`,\n // 0.5.x with depth-counted configInit (replaced by bare-specifier alias).\n `// Registers setConfig() for server actions — some POST bundles skip layout.tsx.\nimport '../../../cms/__generated__/configInit';\n\nexport { AdminApp as default } from 'octocms/admin';\n`,\n];\n\nexport const nextAuthRouteTemplate = `import NextAuth from 'next-auth';\nimport { authOptions } from 'octocms/admin/auth';\n\nconst handler = NextAuth(authOptions);\n\nexport { handler as GET, handler as POST };\n`;\n\n/**\n * Build a thin re-export Route Handler for the chat-agent SSE endpoint.\n *\n * The actual handler lives in `octocms/agent/chatApi.ts`\n * (`chatRoute` / `chatStatusRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so\n * `getAgentConfig()` resolves on cold start (Route Handlers don't run\n * `app/layout.tsx`); and\n * 2. re-exports `chatRoute` as `POST` and `chatStatusRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic and can be\n * placed under `app/` or `src/app/` without code changes.\n */\nexport function agentChatRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` + \\`agentConfig\\` into the\n// runtime stores so \\`getAgentConfig()\\` resolves on cold start. Route Handlers\n// don't run \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { chatRoute as POST, chatStatusRoute as GET } from 'octocms/agent';\n`;\n}\n\n/**\n * Build a thin re-export Route Handler for the `/media/[...slug]` proxy.\n *\n * The actual handler lives in `octocms/admin/mediaRoute.ts`\n * (`mediaRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so `getConfig()`\n * resolves on cold start (Route Handlers don't run `app/layout.tsx`); and\n * 2. re-exports `mediaRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic.\n */\nexport function mediaRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` into the runtime store so\n// \\`getConfig()\\` resolves on cold start. Route Handlers don't run\n// \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { mediaRoute as GET } from 'octocms/admin/mediaRoute';\n`;\n}\n\n/**\n * Build a thin re-export Route Handler for the public-site `/api/search`\n * endpoint consumed by the `SearchBox` component shipped at\n * `octocms/components/public`.\n *\n * The actual handler lives in `octocms/admin/searchRoute.ts`\n * (`searchRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so `getConfig()`\n * resolves on cold start (Route Handlers don't run `app/layout.tsx`); and\n * 2. re-exports `searchRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic.\n */\nexport function searchRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` into the runtime store so\n// \\`getConfig()\\` resolves on cold start. Route Handlers don't run\n// \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { searchRoute as GET } from 'octocms/admin/searchRoute';\n`;\n}\n\ntype SchemaInitOpts = { projectName: string; baseBranch: string; pointerBranch?: string };\n\n/**\n * The starter schema used by `octocms init`. The data lives in `cms/schema.json`\n * (source of truth — hand-editable + edited by the Content Model UI). The other\n * two scaffolded files (`cms/__generated__/schema.ts` and `cms/octocms.config.ts`)\n * mirror this same shape — keep them aligned by editing here only and letting\n * `npx octocms types:gen` regenerate the rest in the user's project.\n */\nfunction buildStarterSchema(opts: SchemaInitOpts): Record<string, unknown> {\n const git: Record<string, string> = { baseBranch: opts.baseBranch };\n if (opts.pointerBranch) git.publishedPointerBranch = opts.pointerBranch;\n return {\n projectName: opts.projectName,\n git,\n contentFolder: 'cms/content',\n mediaContentFolder: 'cms/media',\n mediaFolder: 'public/media',\n mediaAllowedFormats: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'avif'],\n collections: {\n helloPage: {\n label: 'Hello Page',\n fields: {\n title: { label: 'Title', format: 'string', entryTitle: true, required: true },\n description: { label: 'Description', format: 'text' },\n },\n },\n },\n };\n}\n\n/**\n * `cms/schema.json` — the source of truth. The Content Model UI (`/cms/model`)\n * reads and writes this file via `getSchema()` / `saveSchema()` server actions.\n */\nexport function schemaJsonTemplate(opts: SchemaInitOpts): string {\n return JSON.stringify(buildStarterSchema(opts), null, 2) + '\\n';\n}\n\n/**\n * `cms/__generated__/schema.ts` — auto-generated literal-typed mirror of\n * `cms/schema.json`. Required because `query()` infers narrow collection /\n * field / format types from the literal `defineConfig()` call — a plain JSON\n * import cannot preserve those literals.\n *\n * `npx octocms types:gen` regenerates this from `cms/schema.json` after every\n * schema edit (and `npm run types:check` fails on drift).\n */\nexport function generatedSchemaShimTemplate(opts: SchemaInitOpts): string {\n const gitBlock = opts.pointerBranch\n ? ` git: {\\n baseBranch: '${opts.baseBranch}',\\n publishedPointerBranch: '${opts.pointerBranch}',\\n },`\n : ` git: { baseBranch: '${opts.baseBranch}' },`;\n return `/*\n * AUTO-GENERATED — DO NOT EDIT.\n * Generated from cms/schema.json.\n * Run \\`npx octocms types:gen\\` to regenerate.\n */\n\nimport { defineConfig } from 'octocms/defineConfig';\n\nexport const schema = defineConfig({\n projectName: '${opts.projectName}',\n${gitBlock}\n contentFolder: 'cms/content',\n mediaContentFolder: 'cms/media',\n mediaFolder: 'public/media',\n mediaAllowedFormats: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'avif'],\n collections: {\n helloPage: {\n label: 'Hello Page',\n fields: {\n title: { label: 'Title', format: 'string', entryTitle: true, required: true },\n description: { label: 'Description', format: 'text' },\n },\n },\n },\n});\n`;\n}\n\n/**\n * `cms/octocms.config.ts` — thin TS binding. Imports the literal-typed\n * `schema` from the generated shim and re-exports it as `configOctoCMS` (the\n * runtime `Config`) and `OctoConfig` (the literal type used by `query()`).\n *\n * Hand-edits should go to `cms/schema.json`. After editing the JSON, run\n * `npx octocms types:gen` to refresh `cms/__generated__/schema.ts`.\n */\nexport function octoConfigTemplate(_opts: SchemaInitOpts): string {\n return `import type { Config } from 'octocms/types';\nimport { schema } from './__generated__/schema';\n\n/**\n * The schema is defined in \\`cms/schema.json\\` (source of truth — hand-editable\n * and editable through the Content Model UI). \\`npx octocms types:gen\\` mirrors\n * it into \\`cms/__generated__/schema.ts\\` as a literal-typed \\`defineConfig()\\`\n * call so the downstream \\`query()\\` API can infer narrow collection / field /\n * format types (which a plain JSON import cannot preserve).\n *\n * \\`npm run types:check\\` fails if the JSON and the generated shim drift.\n */\nconst _typedConfigOctoCMS = schema;\n\n/** Runtime config — widened to \\`Config\\` for dynamic indexing in CMS internals. */\nexport const configOctoCMS: Config = _typedConfigOctoCMS as Config;\n\n/**\n * Exact literal type of the config — use this for type-level inference only\n * (e.g. the \\`query()\\` API derives collection/field names from it).\n */\nexport type OctoConfig = typeof _typedConfigOctoCMS;\n`;\n}\n\nexport function nextConfigTemplate(): string {\n return `import type { NextConfig } from 'next';\nimport { withOctoCMS } from 'octocms/config';\nimport { configOctoCMS } from './cms/octocms.config';\n\nexport { configOctoCMS } from './cms/octocms.config';\nexport type { OctoConfig } from './cms/octocms.config';\n\nconst nextConfig: NextConfig = {};\n\nexport default withOctoCMS(nextConfig, configOctoCMS);\n`;\n}\n\nexport function demoHelloPageJson(): string {\n return JSON.stringify(\n {\n sys: { id: '0000', type: 'helloPage', status: 'merged' },\n fields: {\n title: 'Hello World',\n description: 'Welcome to your new OctoCMS site! Edit this content in the CMS admin panel.',\n },\n },\n null,\n 2,\n );\n}\n\nexport const helloPageTemplate = `import { query } from 'cms/__generated__/query';\n\nexport default async function HelloPage() {\n const page = await query('helloPage').first();\n if (!page) return null;\n return (\n <main>\n <h1>{page.fields.title}</h1>\n <p>{page.fields.description}</p>\n </main>\n );\n}\n`;\n\nexport function readmeTemplate(projectName: string): string {\n return `# ${projectName}\n\nBuilt with [OctoCMS](https://octocms.com) — a file-based CMS on Next.js.\n\n## Setup\n\n### 1. Install dependencies\n\n\\`\\`\\`bash\nnpm install octocms next-auth @tanstack/react-query @mdxeditor/editor \\\\\n @radix-ui/react-avatar @radix-ui/react-dialog @radix-ui/react-dropdown-menu \\\\\n @radix-ui/react-label @radix-ui/react-select @radix-ui/react-slot \\\\\n @radix-ui/react-tabs @radix-ui/react-toast \\\\\n class-variance-authority clsx glob lucide-react minisearch octokit \\\\\n react-markdown rehype-sanitize remark-gfm remark-mdx \\\\\n sharp slugify sonner tailwind-merge zod\n\\`\\`\\`\n\n> The exact list (with the right \\`octocms\\` version pin) is also printed by \\`npx octocms init\\` — copy it from there.\n\n### 2. Create a GitHub App\n\nFollow the [OctoCMS GitHub App setup guide](https://octocms.com/docs/github-app) to create a GitHub App for authentication.\n\n### 3. Configure environment variables\n\nCopy the values from your GitHub App into \\`.env.local\\`:\n\n\\`\\`\\`bash\n# GitHub App credentials (required for CMS auth)\nGITHUB_ID=your_github_app_client_id\nGITHUB_SECRET=your_github_app_client_secret\n\n# NextAuth (generate secret: openssl rand -base64 32)\nNEXTAUTH_SECRET=your_nextauth_secret\nNEXTAUTH_URL=http://localhost:3000\n\n# GitHub repo for content storage (required in production)\nGITHUB_REPO_OWNER=your_github_username_or_org\nGITHUB_REPO_NAME=your_repo_name\n\n# Optional: static GitHub token for private repos / higher API rate limits\n# CMS_GITHUB_TOKEN=your_github_pat\n\\`\\`\\`\n\n### 4. Run the dev server\n\n\\`\\`\\`bash\nnpm run dev\n\\`\\`\\`\n\nOpen [http://localhost:3000/cms](http://localhost:3000/cms) to access the CMS admin.\n`;\n}\n\nexport function envLocalTemplate(): string {\n return `# GitHub App credentials (required for CMS auth)\n# Create a GitHub App at: https://github.com/settings/apps/new\nGITHUB_ID=\nGITHUB_SECRET=\n\n# NextAuth secret — generate with: openssl rand -base64 32\nNEXTAUTH_SECRET=\nNEXTAUTH_URL=http://localhost:3000\n\n# GitHub repo for content storage (required in production)\nGITHUB_REPO_OWNER=\nGITHUB_REPO_NAME=\n\n# Optional: static GitHub token for private repos or higher API rate limits\n# CMS_GITHUB_TOKEN=\n`;\n}\n\nconst AGENT_DOCS_MARKER = '<!-- octocms:agent-docs -->';\n\nexport function agentsMdSection(): string {\n return `${AGENT_DOCS_MARKER}\n## OctoCMS — AI Content Management\n\nFor tasks that involve creating, editing, or deleting CMS content directly (without the admin UI), read the auto-generated agent docs:\n\n- **\\`octocms/docs/overview.md\\`** — How to find, create, update, and delete content entries via file operations\n- **\\`octocms/docs/schema.md\\`** — Per-collection field definitions, example JSON, and file path conventions\n\nThese docs are generated from \\`cms/octocms.config.ts\\`. Regenerate after schema changes: \\`npm run agent-docs:gen\\`.`;\n}\n\nexport function agentsMdTemplate(): string {\n return `# Project Guidelines\n\n${agentsMdSection()}\n`;\n}\n\nexport function tsconfigPaths(): Record<string, string[]> {\n return {\n 'cms/__generated__': ['./cms/__generated__/index.ts'],\n 'cms/__generated__/*': ['./cms/__generated__/*'],\n '@/*': ['./src/*'],\n };\n}\n"],"mappings":";AAIA,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAShB,IAAM,yBACX,iBACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBK,IAAM,yBACX,iBACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BK,IAAM,gCACX,iBACA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AO;AAAA,QACP,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,IAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAc1B,SAAS,eAAe,aAA6B;AAC1D,SAAO,KAAK,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDzB;AAEO,SAAS,mBAA2B;AACzC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBT;AAEA,IAAM,oBAAoB;AAEnB,SAAS,kBAA0B;AACxC,SAAO,GAAG,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS7B;AAEO,SAAS,mBAA2B;AACzC,SAAO;AAAA;AAAA,EAEP,gBAAgB,CAAC;AAAA;AAEnB;AAEO,SAAS,gBAA0C;AACxD,SAAO;AAAA,IACL,qBAAqB,CAAC,8BAA8B;AAAA,IACpD,uBAAuB,CAAC,uBAAuB;AAAA,IAC/C,OAAO,CAAC,SAAS;AAAA,EACnB;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"octocms\",\n \"version\": \"0.4.
|
|
1
|
+
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"octocms\",\n \"version\": \"0.4.9\",\n \"description\": \"A file-based CMS for Next.js — schema-driven, Git-backed, no database\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"keywords\": [\n \"cms\",\n \"nextjs\",\n \"headless-cms\",\n \"git-cms\",\n \"content-management\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/octocms/octocms.git\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"require\": \"./dist/index.cjs\",\n \"import\": \"./dist/index.js\"\n },\n \"./query\": {\n \"types\": \"./dist/query.d.ts\",\n \"require\": \"./dist/query.cjs\",\n \"import\": \"./dist/query.js\"\n },\n \"./config\": {\n \"types\": \"./dist/config.d.ts\",\n \"require\": \"./dist/config.cjs\",\n \"import\": \"./dist/config.js\"\n },\n \"./defineConfig\": {\n \"types\": \"./dist/defineConfig.d.ts\",\n \"require\": \"./dist/defineConfig.cjs\",\n \"import\": \"./dist/defineConfig.js\"\n },\n \"./types\": {\n \"types\": \"./dist/types.d.ts\",\n \"require\": \"./dist/types.cjs\",\n \"import\": \"./dist/types.js\"\n },\n \"./withOctoCMS\": {\n \"types\": \"./dist/withOctoCMS.d.ts\",\n \"require\": \"./dist/withOctoCMS.cjs\",\n \"import\": \"./dist/withOctoCMS.js\"\n },\n \"./agent\": {\n \"types\": \"./dist/agent/index.d.ts\",\n \"require\": \"./dist/agent/index.cjs\",\n \"import\": \"./dist/agent/index.js\"\n },\n \"./schema\": {\n \"types\": \"./dist/schema/index.d.ts\",\n \"import\": \"./dist/schema/index.js\"\n },\n \"./components/public\": {\n \"types\": \"./dist/components/public/index.d.ts\",\n \"require\": \"./dist/components/public/index.cjs\",\n \"import\": \"./dist/components/public/index.js\"\n },\n \"./lib/configStore\": {\n \"types\": \"./dist/lib/configStore.d.ts\",\n \"require\": \"./dist/lib/configStore.cjs\",\n \"import\": \"./dist/lib/configStore.js\"\n },\n \"./admin\": {\n \"types\": \"./dist/admin/index.d.ts\",\n \"import\": \"./dist/admin/index.js\"\n },\n \"./admin/*\": {\n \"types\": \"./dist/admin/*.d.ts\",\n \"import\": \"./dist/admin/*.js\"\n },\n \"./components/*\": {\n \"types\": \"./dist/components/*.d.ts\",\n \"import\": \"./dist/components/*.js\"\n },\n \"./hooks/*\": {\n \"types\": \"./dist/hooks/*.d.ts\",\n \"import\": \"./dist/hooks/*.js\"\n },\n \"./lib/*\": {\n \"types\": \"./dist/lib/*.d.ts\",\n \"import\": \"./dist/lib/*.js\"\n },\n \"./schema/*\": {\n \"types\": \"./dist/schema/*.d.ts\",\n \"import\": \"./dist/schema/*.js\"\n },\n \"./utils/*\": {\n \"types\": \"./dist/utils/*.d.ts\",\n \"import\": \"./dist/utils/*.js\"\n },\n \"./globals.css\": \"./globals.css\",\n \"./docs/*\": \"./docs/*\"\n },\n \"bin\": {\n \"octocms\": \"dist/cli/index.js\"\n },\n \"files\": [\n \"dist\",\n \"docs\",\n \"globals.css\"\n ],\n \"scripts\": {\n \"build\": \"tsup && tsc -p tsconfig.build.json && cp globals.css dist/globals.css\",\n \"prepublishOnly\": \"npm run checks && npm run build\",\n \"lint\": \"oxlint .\",\n \"lint:fix\": \"oxlint --fix .\",\n \"fmt\": \"oxfmt .\",\n \"fmt:check\": \"oxfmt --check .\",\n \"test\": \"vitest\",\n \"test:run\": \"vitest run\",\n \"ts-check\": \"tsc --noEmit --incremental false\",\n \"checks\": \"npm run lint && npm run ts-check && npm run fmt:check && npm run test:run\",\n \"checks:fix\": \"npm run lint:fix && npm run fmt && npm run test:run\"\n },\n \"peerDependencies\": {\n \"@anthropic-ai/sdk\": \">=0.91\",\n \"@huggingface/transformers\": \">=4\",\n \"@mdxeditor/editor\": \">=3\",\n \"@radix-ui/react-avatar\": \">=1\",\n \"@radix-ui/react-dialog\": \">=1\",\n \"@radix-ui/react-dropdown-menu\": \">=2\",\n \"@radix-ui/react-label\": \">=2\",\n \"@radix-ui/react-select\": \">=2\",\n \"@radix-ui/react-slot\": \">=1\",\n \"@radix-ui/react-tabs\": \">=1\",\n \"@radix-ui/react-toast\": \">=1\",\n \"@tanstack/react-query\": \">=5\",\n \"class-variance-authority\": \">=0.7\",\n \"clsx\": \">=2\",\n \"glob\": \">=11\",\n \"lucide-react\": \">=1\",\n \"mammoth\": \">=1.12\",\n \"minisearch\": \">=7\",\n \"next\": \">=15\",\n \"next-auth\": \">=4\",\n \"octokit\": \">=4\",\n \"openai\": \">=4\",\n \"pdfjs-dist\": \">=4\",\n \"react\": \">=18\",\n \"react-dom\": \">=18\",\n \"react-markdown\": \">=10\",\n \"rehype-sanitize\": \">=6\",\n \"remark-gfm\": \">=4\",\n \"remark-mdx\": \">=3\",\n \"sharp\": \">=0.34\",\n \"slugify\": \">=1\",\n \"sonner\": \">=2\",\n \"tailwind-merge\": \">=3\",\n \"zod\": \">=4\"\n },\n \"peerDependenciesMeta\": {\n \"@anthropic-ai/sdk\": {\n \"optional\": true\n },\n \"@huggingface/transformers\": {\n \"optional\": true\n },\n \"mammoth\": {\n \"optional\": true\n },\n \"openai\": {\n \"optional\": true\n },\n \"pdfjs-dist\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@tanstack/react-query\": \"^5.100.9\",\n \"@testing-library/dom\": \"^10.4.1\",\n \"@testing-library/react\": \"^16.3.2\",\n \"@types/node\": \"^20\",\n \"@types/react\": \"^19.2.14\",\n \"@types/react-dom\": \"^19.2.3\",\n \"@vitejs/plugin-react\": \"^6.0.1\",\n \"jsdom\": \"^29.0.1\",\n \"oxfmt\": \"^0.11.0\",\n \"oxlint\": \"^0.17.0\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.9.3\",\n \"vite-tsconfig-paths\": \"^6.1.1\",\n \"vitest\": \"^4.1.2\"\n }\n}\n"],"mappings":";AAEE,cAAW;","names":[]}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
version
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-GL7FGEA4.js";
|
|
5
5
|
import {
|
|
6
6
|
resolveProjectRoot
|
|
7
7
|
} from "../chunk-TG624CCO.js";
|
|
@@ -164,7 +164,7 @@ async function main() {
|
|
|
164
164
|
try {
|
|
165
165
|
switch (command) {
|
|
166
166
|
case "init": {
|
|
167
|
-
const { initCommand } = await import("../init-
|
|
167
|
+
const { initCommand } = await import("../init-W645ZB34.js");
|
|
168
168
|
await initCommand(process.cwd(), { yes: flags.yes === true });
|
|
169
169
|
break;
|
|
170
170
|
}
|
|
@@ -195,13 +195,13 @@ async function main() {
|
|
|
195
195
|
}
|
|
196
196
|
case "update": {
|
|
197
197
|
const projectRoot = resolveProjectRoot();
|
|
198
|
-
const { updateCommand } = await import("../update-
|
|
198
|
+
const { updateCommand } = await import("../update-QNJRYPMC.js");
|
|
199
199
|
await updateCommand(projectRoot);
|
|
200
200
|
break;
|
|
201
201
|
}
|
|
202
202
|
case "agent-docs": {
|
|
203
203
|
const projectRoot = resolveProjectRoot();
|
|
204
|
-
const { agentDocsCommand } = await import("../agentDocs-
|
|
204
|
+
const { agentDocsCommand } = await import("../agentDocs-M3R2CPUQ.js");
|
|
205
205
|
await agentDocsCommand(projectRoot);
|
|
206
206
|
break;
|
|
207
207
|
}
|
|
@@ -181,15 +181,44 @@ ${CONFIG_INIT_IMPORT}
|
|
|
181
181
|
export { searchRoute as GET } from 'octocms/admin/searchRoute';
|
|
182
182
|
`;
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function buildStarterSchema(opts) {
|
|
185
|
+
const git = { baseBranch: opts.baseBranch };
|
|
186
|
+
if (opts.pointerBranch) git.publishedPointerBranch = opts.pointerBranch;
|
|
187
|
+
return {
|
|
188
|
+
projectName: opts.projectName,
|
|
189
|
+
git,
|
|
190
|
+
contentFolder: "cms/content",
|
|
191
|
+
mediaContentFolder: "cms/media",
|
|
192
|
+
mediaFolder: "public/media",
|
|
193
|
+
mediaAllowedFormats: ["png", "jpg", "jpeg", "gif", "webp", "svg", "avif"],
|
|
194
|
+
collections: {
|
|
195
|
+
helloPage: {
|
|
196
|
+
label: "Hello Page",
|
|
197
|
+
fields: {
|
|
198
|
+
title: { label: "Title", format: "string", entryTitle: true, required: true },
|
|
199
|
+
description: { label: "Description", format: "text" }
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function schemaJsonTemplate(opts) {
|
|
206
|
+
return JSON.stringify(buildStarterSchema(opts), null, 2) + "\n";
|
|
207
|
+
}
|
|
208
|
+
function generatedSchemaShimTemplate(opts) {
|
|
185
209
|
const gitBlock = opts.pointerBranch ? ` git: {
|
|
186
210
|
baseBranch: '${opts.baseBranch}',
|
|
187
211
|
publishedPointerBranch: '${opts.pointerBranch}',
|
|
188
212
|
},` : ` git: { baseBranch: '${opts.baseBranch}' },`;
|
|
189
|
-
return
|
|
190
|
-
|
|
213
|
+
return `/*
|
|
214
|
+
* AUTO-GENERATED \u2014 DO NOT EDIT.
|
|
215
|
+
* Generated from cms/schema.json.
|
|
216
|
+
* Run \`npx octocms types:gen\` to regenerate.
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
import { defineConfig } from 'octocms/defineConfig';
|
|
191
220
|
|
|
192
|
-
const
|
|
221
|
+
export const schema = defineConfig({
|
|
193
222
|
projectName: '${opts.projectName}',
|
|
194
223
|
${gitBlock}
|
|
195
224
|
contentFolder: 'cms/content',
|
|
@@ -206,8 +235,30 @@ ${gitBlock}
|
|
|
206
235
|
},
|
|
207
236
|
},
|
|
208
237
|
});
|
|
238
|
+
`;
|
|
239
|
+
}
|
|
240
|
+
function octoConfigTemplate(_opts) {
|
|
241
|
+
return `import type { Config } from 'octocms/types';
|
|
242
|
+
import { schema } from './__generated__/schema';
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The schema is defined in \`cms/schema.json\` (source of truth \u2014 hand-editable
|
|
246
|
+
* and editable through the Content Model UI). \`npx octocms types:gen\` mirrors
|
|
247
|
+
* it into \`cms/__generated__/schema.ts\` as a literal-typed \`defineConfig()\`
|
|
248
|
+
* call so the downstream \`query()\` API can infer narrow collection / field /
|
|
249
|
+
* format types (which a plain JSON import cannot preserve).
|
|
250
|
+
*
|
|
251
|
+
* \`npm run types:check\` fails if the JSON and the generated shim drift.
|
|
252
|
+
*/
|
|
253
|
+
const _typedConfigOctoCMS = schema;
|
|
209
254
|
|
|
210
|
-
|
|
255
|
+
/** Runtime config \u2014 widened to \`Config\` for dynamic indexing in CMS internals. */
|
|
256
|
+
export const configOctoCMS: Config = _typedConfigOctoCMS as Config;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Exact literal type of the config \u2014 use this for type-level inference only
|
|
260
|
+
* (e.g. the \`query()\` API derives collection/field names from it).
|
|
261
|
+
*/
|
|
211
262
|
export type OctoConfig = typeof _typedConfigOctoCMS;
|
|
212
263
|
`;
|
|
213
264
|
}
|
|
@@ -364,6 +415,7 @@ export {
|
|
|
364
415
|
generatedEnumsTemplate,
|
|
365
416
|
generatedIndexTemplate,
|
|
366
417
|
generatedQueryTemplate,
|
|
418
|
+
generatedSchemaShimTemplate,
|
|
367
419
|
generatedTypesTemplate,
|
|
368
420
|
helloPageTemplate,
|
|
369
421
|
mediaRouteTemplate,
|
|
@@ -373,6 +425,7 @@ export {
|
|
|
373
425
|
readmeTemplate,
|
|
374
426
|
rootLayoutConfigInitImport,
|
|
375
427
|
rootLayoutTemplate,
|
|
428
|
+
schemaJsonTemplate,
|
|
376
429
|
searchRouteTemplate,
|
|
377
430
|
tsconfigPaths
|
|
378
431
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../cli/lib/templates.ts"],"sourcesContent":["/**\n * File templates used by `octocms init` and `octocms update`.\n */\n\nconst CODEGEN_BANNER = `/*\n * AUTO-GENERATED — DO NOT EDIT.\n * Generated from cms/octocms.config.ts.\n * Run \\`npx octocms types:gen\\` to regenerate.\n */\n\n`;\n\n/** Static cms/__generated__/types.ts for the helloPage demo schema. */\nexport const generatedTypesTemplate =\n CODEGEN_BANNER +\n `import type { EntryStatus } from 'octocms/types';\n\nexport interface HelloPageFields {\n title: string;\n description: string;\n}\n\nexport interface HelloPageEntry {\n sys: { id: string; type: 'helloPage'; status: EntryStatus };\n fields: HelloPageFields;\n}\n\nexport type AnyEntry = HelloPageEntry;\n\nexport type EntryMap = {\n helloPage: HelloPageEntry;\n};\n`;\n\n/** Static cms/__generated__/enums.ts for the helloPage demo schema. */\nexport const generatedEnumsTemplate =\n CODEGEN_BANNER +\n `export const CollectionName = {\n HelloPage: 'helloPage',\n} as const;\nexport type CollectionName = (typeof CollectionName)[keyof typeof CollectionName];\n\nexport const COLLECTION_NAMES = ['helloPage'] as const;\n\nexport const FieldFormat = {\n String: 'string',\n Text: 'text',\n Markdown: 'markdown',\n Boolean: 'boolean',\n Reference: 'reference',\n Image: 'image',\n Number: 'number',\n Datetime: 'datetime',\n Json: 'json',\n Slug: 'slug',\n Select: 'select',\n Url: 'url',\n Color: 'color',\n Conditional: 'conditional',\n Richtext: 'richtext',\n} as const;\nexport type FieldFormat = (typeof FieldFormat)[keyof typeof FieldFormat];\n`;\n\n/** Static cms/__generated__/content.d.ts for the helloPage demo schema. */\nexport const generatedContentDeclsTemplate =\n CODEGEN_BANNER +\n `import type { EntryStatus } from 'octocms/types';\n\n// Raw on-disk types (before query() processing).\nexport interface RawHelloPageFields {\n title: string;\n description: string;\n}\n\nexport interface RawHelloPageEntry {\n sys: { id: string; type: 'helloPage'; status: EntryStatus };\n fields: RawHelloPageFields;\n}\n`;\n\n/** Static cms/__generated__/index.ts — always the same shape. */\nexport const generatedIndexTemplate =\n CODEGEN_BANNER +\n `export * from './types';\nexport * from './enums';\nexport * from './query';\n`;\n\n/** Static cms/__generated__/query.ts — always the same shape (schema-independent). */\nexport const generatedQueryTemplate =\n CODEGEN_BANNER +\n `import { createQuery } from 'octocms/query';\nimport { configOctoCMS, type OctoConfig } from '../octocms.config';\nimport type { EntryMap } from './types';\n\n// configOctoCMS is widened to Config for admin internals; cast back to OctoConfig so\n// createQuery preserves literal collection/field names for type-safe queries.\nexport const query = createQuery<EntryMap, OctoConfig>(configOctoCMS as unknown as OctoConfig);\n`;\n\n/** Static cms/__generated__/configInit.ts — always the same shape (schema-independent). */\nexport const generatedConfigInitTemplate =\n CODEGEN_BANNER +\n `import { configOctoCMS } from '../octocms.config';\nimport { setConfig } from 'octocms/lib/configStore';\n\nsetConfig(configOctoCMS);\n`;\n\n/**\n * All scaffolded files import the generated config initialiser via the bare\n * specifier `cms/__generated__/configInit`. Resolution works in two layers:\n *\n * - TypeScript IntelliSense: the consumer's `tsconfig.json` `paths` (added\n * by `octocms init`).\n * - Bundler: an alias registered by `withOctoCMS()` so Webpack and Turbopack\n * resolve the bare specifier from anywhere — including `app/layout.tsx`,\n * route handlers at any depth, and files inside `node_modules/octocms/`.\n *\n * This eliminates the previous depth-counting (`'../../../cms/...'`) that was\n * a recurring source of off-by-one bugs across templates and routes.\n */\nconst CONFIG_INIT_IMPORT = \"import 'cms/__generated__/configInit';\";\n\n/**\n * Minimal root layout written when `app/layout.tsx` does not already exist.\n * The configInit import is the critical side-effect; the rest is a Next.js\n * boilerplate shell.\n */\nexport const rootLayoutTemplate = `${CONFIG_INIT_IMPORT}\nimport type { Metadata } from 'next';\n\nexport const metadata: Metadata = {\n title: 'My App',\n};\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n );\n}\n`;\n\n/** The one-liner prepended to an existing root layout to register the config. */\nexport const rootLayoutConfigInitImport = `${CONFIG_INIT_IMPORT}\\n`;\n\nexport function buildAdminLayoutTemplate(): string {\n return `${CONFIG_INIT_IMPORT}\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin';\n`;\n}\n\n/**\n * Catch-all admin route — every \\`/cms/*\\` URL renders the package's\n * \\`AdminApp\\` async server component (awaits \\`params\\`, no outer Suspense).\n * Side-effect-imports \\`configInit\\` so server-action bundles register\n * \\`setConfig()\\` even when Next.js does not load \\`layout.tsx\\` for the POST.\n */\nexport function buildAdminPageTemplate(): string {\n return `// Registers setConfig() for server actions — some POST bundles skip layout.tsx.\n${CONFIG_INIT_IMPORT}\n\nexport { AdminApp as default } from 'octocms/admin';\n`;\n}\n\n/**\n * Admin error boundary — rendered by Next.js when anything in the catch-all\n * tree throws during render. Re-uses the shared \\`AdminErrorView\\` so GitHub\n * config / auth / availability / rate-limit copy stays consistent with the\n * public-page error boundary.\n */\nexport const adminErrorTemplate = `'use client';\n\nexport { AdminError as default } from 'octocms/admin';\n`;\n\n/**\n * Historical template values used by \\`octocms update\\` to recognise an\n * unmodified install when migrating between routing models. Each entry is\n * the literal file content shipped by a previous OctoCMS version. If a\n * user-app file matches one of these byte-for-byte, \\`update\\` will replace\n * it with the current template; otherwise it leaves it alone.\n */\nexport const LEGACY_ADMIN_LAYOUT_TEMPLATES: ReadonlyArray<string> = [\n // 0.4.x — re-exported from the deep path.\n `import '../../cms/__generated__/configInit';\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin/pages/AdminLayout';\n`,\n // 0.5.x — barrel re-export with depth-counted relative configInit import.\n `import '../../cms/__generated__/configInit';\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin';\n`,\n];\n\nexport const LEGACY_ADMIN_CATCH_ALL_TEMPLATES: ReadonlyArray<string> = [\n // 0.4.x — re-exported from the deep path.\n `export { AdminApp as default } from 'octocms/admin/AdminApp';\n`,\n // 0.5.x — barrel re-export without configInit on the page (server actions could miss setConfig).\n `export { AdminApp as default } from 'octocms/admin';\n`,\n // 0.5.x with depth-counted configInit (replaced by bare-specifier alias).\n `// Registers setConfig() for server actions — some POST bundles skip layout.tsx.\nimport '../../../cms/__generated__/configInit';\n\nexport { AdminApp as default } from 'octocms/admin';\n`,\n];\n\nexport const nextAuthRouteTemplate = `import NextAuth from 'next-auth';\nimport { authOptions } from 'octocms/admin/auth';\n\nconst handler = NextAuth(authOptions);\n\nexport { handler as GET, handler as POST };\n`;\n\n/**\n * Build a thin re-export Route Handler for the chat-agent SSE endpoint.\n *\n * The actual handler lives in `octocms/agent/chatApi.ts`\n * (`chatRoute` / `chatStatusRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so\n * `getAgentConfig()` resolves on cold start (Route Handlers don't run\n * `app/layout.tsx`); and\n * 2. re-exports `chatRoute` as `POST` and `chatStatusRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic and can be\n * placed under `app/` or `src/app/` without code changes.\n */\nexport function agentChatRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` + \\`agentConfig\\` into the\n// runtime stores so \\`getAgentConfig()\\` resolves on cold start. Route Handlers\n// don't run \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { chatRoute as POST, chatStatusRoute as GET } from 'octocms/agent';\n`;\n}\n\n/**\n * Build a thin re-export Route Handler for the `/media/[...slug]` proxy.\n *\n * The actual handler lives in `octocms/admin/mediaRoute.ts`\n * (`mediaRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so `getConfig()`\n * resolves on cold start (Route Handlers don't run `app/layout.tsx`); and\n * 2. re-exports `mediaRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic.\n */\nexport function mediaRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` into the runtime store so\n// \\`getConfig()\\` resolves on cold start. Route Handlers don't run\n// \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { mediaRoute as GET } from 'octocms/admin/mediaRoute';\n`;\n}\n\n/**\n * Build a thin re-export Route Handler for the public-site `/api/search`\n * endpoint consumed by the `SearchBox` component shipped at\n * `octocms/components/public`.\n *\n * The actual handler lives in `octocms/admin/searchRoute.ts`\n * (`searchRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so `getConfig()`\n * resolves on cold start (Route Handlers don't run `app/layout.tsx`); and\n * 2. re-exports `searchRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic.\n */\nexport function searchRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` into the runtime store so\n// \\`getConfig()\\` resolves on cold start. Route Handlers don't run\n// \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { searchRoute as GET } from 'octocms/admin/searchRoute';\n`;\n}\n\nexport function octoConfigTemplate(opts: { projectName: string; baseBranch: string; pointerBranch?: string }): string {\n const gitBlock = opts.pointerBranch\n ? ` git: {\\n baseBranch: '${opts.baseBranch}',\\n publishedPointerBranch: '${opts.pointerBranch}',\\n },`\n : ` git: { baseBranch: '${opts.baseBranch}' },`;\n\n return `import type { Config } from 'octocms/types';\nimport { defineConfig } from 'octocms/config';\n\nconst _typedConfigOctoCMS = defineConfig({\n projectName: '${opts.projectName}',\n${gitBlock}\n contentFolder: 'cms/content',\n mediaContentFolder: 'cms/media',\n mediaFolder: 'public/media',\n mediaAllowedFormats: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'avif'],\n collections: {\n helloPage: {\n label: 'Hello Page',\n fields: {\n title: { label: 'Title', format: 'string', entryTitle: true, required: true },\n description: { label: 'Description', format: 'text' },\n },\n },\n },\n});\n\nexport const configOctoCMS: Config = _typedConfigOctoCMS;\nexport type OctoConfig = typeof _typedConfigOctoCMS;\n`;\n}\n\nexport function nextConfigTemplate(): string {\n return `import type { NextConfig } from 'next';\nimport { withOctoCMS } from 'octocms/config';\nimport { configOctoCMS } from './cms/octocms.config';\n\nexport { configOctoCMS } from './cms/octocms.config';\nexport type { OctoConfig } from './cms/octocms.config';\n\nconst nextConfig: NextConfig = {};\n\nexport default withOctoCMS(nextConfig, configOctoCMS);\n`;\n}\n\nexport function demoHelloPageJson(): string {\n return JSON.stringify(\n {\n sys: { id: '0000', type: 'helloPage', status: 'merged' },\n fields: {\n title: 'Hello World',\n description: 'Welcome to your new OctoCMS site! Edit this content in the CMS admin panel.',\n },\n },\n null,\n 2,\n );\n}\n\nexport const helloPageTemplate = `import { query } from 'cms/__generated__/query';\n\nexport default async function HelloPage() {\n const page = await query('helloPage').first();\n if (!page) return null;\n return (\n <main>\n <h1>{page.fields.title}</h1>\n <p>{page.fields.description}</p>\n </main>\n );\n}\n`;\n\nexport function readmeTemplate(projectName: string): string {\n return `# ${projectName}\n\nBuilt with [OctoCMS](https://octocms.com) — a file-based CMS on Next.js.\n\n## Setup\n\n### 1. Install dependencies\n\n\\`\\`\\`bash\nnpm install octocms next-auth @tanstack/react-query @mdxeditor/editor \\\\\n @radix-ui/react-avatar @radix-ui/react-dialog @radix-ui/react-dropdown-menu \\\\\n @radix-ui/react-label @radix-ui/react-select @radix-ui/react-slot \\\\\n @radix-ui/react-tabs @radix-ui/react-toast \\\\\n class-variance-authority clsx glob lucide-react minisearch octokit \\\\\n react-markdown rehype-sanitize remark-gfm remark-mdx \\\\\n sharp slugify sonner tailwind-merge zod\n\\`\\`\\`\n\n> The exact list (with the right \\`octocms\\` version pin) is also printed by \\`npx octocms init\\` — copy it from there.\n\n### 2. Create a GitHub App\n\nFollow the [OctoCMS GitHub App setup guide](https://octocms.com/docs/github-app) to create a GitHub App for authentication.\n\n### 3. Configure environment variables\n\nCopy the values from your GitHub App into \\`.env.local\\`:\n\n\\`\\`\\`bash\n# GitHub App credentials (required for CMS auth)\nGITHUB_ID=your_github_app_client_id\nGITHUB_SECRET=your_github_app_client_secret\n\n# NextAuth (generate secret: openssl rand -base64 32)\nNEXTAUTH_SECRET=your_nextauth_secret\nNEXTAUTH_URL=http://localhost:3000\n\n# GitHub repo for content storage (required in production)\nGITHUB_REPO_OWNER=your_github_username_or_org\nGITHUB_REPO_NAME=your_repo_name\n\n# Optional: static GitHub token for private repos / higher API rate limits\n# CMS_GITHUB_TOKEN=your_github_pat\n\\`\\`\\`\n\n### 4. Run the dev server\n\n\\`\\`\\`bash\nnpm run dev\n\\`\\`\\`\n\nOpen [http://localhost:3000/cms](http://localhost:3000/cms) to access the CMS admin.\n`;\n}\n\nexport function envLocalTemplate(): string {\n return `# GitHub App credentials (required for CMS auth)\n# Create a GitHub App at: https://github.com/settings/apps/new\nGITHUB_ID=\nGITHUB_SECRET=\n\n# NextAuth secret — generate with: openssl rand -base64 32\nNEXTAUTH_SECRET=\nNEXTAUTH_URL=http://localhost:3000\n\n# GitHub repo for content storage (required in production)\nGITHUB_REPO_OWNER=\nGITHUB_REPO_NAME=\n\n# Optional: static GitHub token for private repos or higher API rate limits\n# CMS_GITHUB_TOKEN=\n`;\n}\n\nconst AGENT_DOCS_MARKER = '<!-- octocms:agent-docs -->';\n\nexport function agentsMdSection(): string {\n return `${AGENT_DOCS_MARKER}\n## OctoCMS — AI Content Management\n\nFor tasks that involve creating, editing, or deleting CMS content directly (without the admin UI), read the auto-generated agent docs:\n\n- **\\`octocms/docs/overview.md\\`** — How to find, create, update, and delete content entries via file operations\n- **\\`octocms/docs/schema.md\\`** — Per-collection field definitions, example JSON, and file path conventions\n\nThese docs are generated from \\`cms/octocms.config.ts\\`. Regenerate after schema changes: \\`npm run agent-docs:gen\\`.`;\n}\n\nexport function agentsMdTemplate(): string {\n return `# Project Guidelines\n\n${agentsMdSection()}\n`;\n}\n\nexport function tsconfigPaths(): Record<string, string[]> {\n return {\n 'cms/__generated__': ['./cms/__generated__/index.ts'],\n 'cms/__generated__/*': ['./cms/__generated__/*'],\n '@/*': ['./src/*'],\n };\n}\n"],"mappings":";AAIA,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAShB,MAAM,yBAC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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDzB;AAEO,SAAS,mBAA2B;AACzC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBT;AAEA,MAAM,oBAAoB;AAEnB,SAAS,kBAA0B;AACxC,SAAO,GAAG,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS7B;AAEO,SAAS,mBAA2B;AACzC,SAAO;AAAA;AAAA,EAEP,gBAAgB,CAAC;AAAA;AAEnB;AAEO,SAAS,gBAA0C;AACxD,SAAO;AAAA,IACL,qBAAqB,CAAC,8BAA8B;AAAA,IACpD,uBAAuB,CAAC,uBAAuB;AAAA,IAC/C,OAAO,CAAC,SAAS;AAAA,EACnB;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../cli/lib/templates.ts"],"sourcesContent":["/**\n * File templates used by `octocms init` and `octocms update`.\n */\n\nconst CODEGEN_BANNER = `/*\n * AUTO-GENERATED — DO NOT EDIT.\n * Generated from cms/octocms.config.ts.\n * Run \\`npx octocms types:gen\\` to regenerate.\n */\n\n`;\n\n/** Static cms/__generated__/types.ts for the helloPage demo schema. */\nexport const generatedTypesTemplate =\n CODEGEN_BANNER +\n `import type { EntryStatus } from 'octocms/types';\n\nexport interface HelloPageFields {\n title: string;\n description: string;\n}\n\nexport interface HelloPageEntry {\n sys: { id: string; type: 'helloPage'; status: EntryStatus };\n fields: HelloPageFields;\n}\n\nexport type AnyEntry = HelloPageEntry;\n\nexport type EntryMap = {\n helloPage: HelloPageEntry;\n};\n`;\n\n/** Static cms/__generated__/enums.ts for the helloPage demo schema. */\nexport const generatedEnumsTemplate =\n CODEGEN_BANNER +\n `export const CollectionName = {\n HelloPage: 'helloPage',\n} as const;\nexport type CollectionName = (typeof CollectionName)[keyof typeof CollectionName];\n\nexport const COLLECTION_NAMES = ['helloPage'] as const;\n\nexport const FieldFormat = {\n String: 'string',\n Text: 'text',\n Markdown: 'markdown',\n Boolean: 'boolean',\n Reference: 'reference',\n Image: 'image',\n Number: 'number',\n Datetime: 'datetime',\n Json: 'json',\n Slug: 'slug',\n Select: 'select',\n Url: 'url',\n Color: 'color',\n Conditional: 'conditional',\n Richtext: 'richtext',\n} as const;\nexport type FieldFormat = (typeof FieldFormat)[keyof typeof FieldFormat];\n`;\n\n/** Static cms/__generated__/content.d.ts for the helloPage demo schema. */\nexport const generatedContentDeclsTemplate =\n CODEGEN_BANNER +\n `import type { EntryStatus } from 'octocms/types';\n\n// Raw on-disk types (before query() processing).\nexport interface RawHelloPageFields {\n title: string;\n description: string;\n}\n\nexport interface RawHelloPageEntry {\n sys: { id: string; type: 'helloPage'; status: EntryStatus };\n fields: RawHelloPageFields;\n}\n`;\n\n/** Static cms/__generated__/index.ts — always the same shape. */\nexport const generatedIndexTemplate =\n CODEGEN_BANNER +\n `export * from './types';\nexport * from './enums';\nexport * from './query';\n`;\n\n/** Static cms/__generated__/query.ts — always the same shape (schema-independent). */\nexport const generatedQueryTemplate =\n CODEGEN_BANNER +\n `import { createQuery } from 'octocms/query';\nimport { configOctoCMS, type OctoConfig } from '../octocms.config';\nimport type { EntryMap } from './types';\n\n// configOctoCMS is widened to Config for admin internals; cast back to OctoConfig so\n// createQuery preserves literal collection/field names for type-safe queries.\nexport const query = createQuery<EntryMap, OctoConfig>(configOctoCMS as unknown as OctoConfig);\n`;\n\n/** Static cms/__generated__/configInit.ts — always the same shape (schema-independent). */\nexport const generatedConfigInitTemplate =\n CODEGEN_BANNER +\n `import { configOctoCMS } from '../octocms.config';\nimport { setConfig } from 'octocms/lib/configStore';\n\nsetConfig(configOctoCMS);\n`;\n\n/**\n * All scaffolded files import the generated config initialiser via the bare\n * specifier `cms/__generated__/configInit`. Resolution works in two layers:\n *\n * - TypeScript IntelliSense: the consumer's `tsconfig.json` `paths` (added\n * by `octocms init`).\n * - Bundler: an alias registered by `withOctoCMS()` so Webpack and Turbopack\n * resolve the bare specifier from anywhere — including `app/layout.tsx`,\n * route handlers at any depth, and files inside `node_modules/octocms/`.\n *\n * This eliminates the previous depth-counting (`'../../../cms/...'`) that was\n * a recurring source of off-by-one bugs across templates and routes.\n */\nconst CONFIG_INIT_IMPORT = \"import 'cms/__generated__/configInit';\";\n\n/**\n * Minimal root layout written when `app/layout.tsx` does not already exist.\n * The configInit import is the critical side-effect; the rest is a Next.js\n * boilerplate shell.\n */\nexport const rootLayoutTemplate = `${CONFIG_INIT_IMPORT}\nimport type { Metadata } from 'next';\n\nexport const metadata: Metadata = {\n title: 'My App',\n};\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n );\n}\n`;\n\n/** The one-liner prepended to an existing root layout to register the config. */\nexport const rootLayoutConfigInitImport = `${CONFIG_INIT_IMPORT}\\n`;\n\nexport function buildAdminLayoutTemplate(): string {\n return `${CONFIG_INIT_IMPORT}\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin';\n`;\n}\n\n/**\n * Catch-all admin route — every \\`/cms/*\\` URL renders the package's\n * \\`AdminApp\\` async server component (awaits \\`params\\`, no outer Suspense).\n * Side-effect-imports \\`configInit\\` so server-action bundles register\n * \\`setConfig()\\` even when Next.js does not load \\`layout.tsx\\` for the POST.\n */\nexport function buildAdminPageTemplate(): string {\n return `// Registers setConfig() for server actions — some POST bundles skip layout.tsx.\n${CONFIG_INIT_IMPORT}\n\nexport { AdminApp as default } from 'octocms/admin';\n`;\n}\n\n/**\n * Admin error boundary — rendered by Next.js when anything in the catch-all\n * tree throws during render. Re-uses the shared \\`AdminErrorView\\` so GitHub\n * config / auth / availability / rate-limit copy stays consistent with the\n * public-page error boundary.\n */\nexport const adminErrorTemplate = `'use client';\n\nexport { AdminError as default } from 'octocms/admin';\n`;\n\n/**\n * Historical template values used by \\`octocms update\\` to recognise an\n * unmodified install when migrating between routing models. Each entry is\n * the literal file content shipped by a previous OctoCMS version. If a\n * user-app file matches one of these byte-for-byte, \\`update\\` will replace\n * it with the current template; otherwise it leaves it alone.\n */\nexport const LEGACY_ADMIN_LAYOUT_TEMPLATES: ReadonlyArray<string> = [\n // 0.4.x — re-exported from the deep path.\n `import '../../cms/__generated__/configInit';\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin/pages/AdminLayout';\n`,\n // 0.5.x — barrel re-export with depth-counted relative configInit import.\n `import '../../cms/__generated__/configInit';\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin';\n`,\n];\n\nexport const LEGACY_ADMIN_CATCH_ALL_TEMPLATES: ReadonlyArray<string> = [\n // 0.4.x — re-exported from the deep path.\n `export { AdminApp as default } from 'octocms/admin/AdminApp';\n`,\n // 0.5.x — barrel re-export without configInit on the page (server actions could miss setConfig).\n `export { AdminApp as default } from 'octocms/admin';\n`,\n // 0.5.x with depth-counted configInit (replaced by bare-specifier alias).\n `// Registers setConfig() for server actions — some POST bundles skip layout.tsx.\nimport '../../../cms/__generated__/configInit';\n\nexport { AdminApp as default } from 'octocms/admin';\n`,\n];\n\nexport const nextAuthRouteTemplate = `import NextAuth from 'next-auth';\nimport { authOptions } from 'octocms/admin/auth';\n\nconst handler = NextAuth(authOptions);\n\nexport { handler as GET, handler as POST };\n`;\n\n/**\n * Build a thin re-export Route Handler for the chat-agent SSE endpoint.\n *\n * The actual handler lives in `octocms/agent/chatApi.ts`\n * (`chatRoute` / `chatStatusRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so\n * `getAgentConfig()` resolves on cold start (Route Handlers don't run\n * `app/layout.tsx`); and\n * 2. re-exports `chatRoute` as `POST` and `chatStatusRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic and can be\n * placed under `app/` or `src/app/` without code changes.\n */\nexport function agentChatRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` + \\`agentConfig\\` into the\n// runtime stores so \\`getAgentConfig()\\` resolves on cold start. Route Handlers\n// don't run \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { chatRoute as POST, chatStatusRoute as GET } from 'octocms/agent';\n`;\n}\n\n/**\n * Build a thin re-export Route Handler for the `/media/[...slug]` proxy.\n *\n * The actual handler lives in `octocms/admin/mediaRoute.ts`\n * (`mediaRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so `getConfig()`\n * resolves on cold start (Route Handlers don't run `app/layout.tsx`); and\n * 2. re-exports `mediaRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic.\n */\nexport function mediaRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` into the runtime store so\n// \\`getConfig()\\` resolves on cold start. Route Handlers don't run\n// \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { mediaRoute as GET } from 'octocms/admin/mediaRoute';\n`;\n}\n\n/**\n * Build a thin re-export Route Handler for the public-site `/api/search`\n * endpoint consumed by the `SearchBox` component shipped at\n * `octocms/components/public`.\n *\n * The actual handler lives in `octocms/admin/searchRoute.ts`\n * (`searchRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so `getConfig()`\n * resolves on cold start (Route Handlers don't run `app/layout.tsx`); and\n * 2. re-exports `searchRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic.\n */\nexport function searchRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` into the runtime store so\n// \\`getConfig()\\` resolves on cold start. Route Handlers don't run\n// \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { searchRoute as GET } from 'octocms/admin/searchRoute';\n`;\n}\n\ntype SchemaInitOpts = { projectName: string; baseBranch: string; pointerBranch?: string };\n\n/**\n * The starter schema used by `octocms init`. The data lives in `cms/schema.json`\n * (source of truth — hand-editable + edited by the Content Model UI). The other\n * two scaffolded files (`cms/__generated__/schema.ts` and `cms/octocms.config.ts`)\n * mirror this same shape — keep them aligned by editing here only and letting\n * `npx octocms types:gen` regenerate the rest in the user's project.\n */\nfunction buildStarterSchema(opts: SchemaInitOpts): Record<string, unknown> {\n const git: Record<string, string> = { baseBranch: opts.baseBranch };\n if (opts.pointerBranch) git.publishedPointerBranch = opts.pointerBranch;\n return {\n projectName: opts.projectName,\n git,\n contentFolder: 'cms/content',\n mediaContentFolder: 'cms/media',\n mediaFolder: 'public/media',\n mediaAllowedFormats: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'avif'],\n collections: {\n helloPage: {\n label: 'Hello Page',\n fields: {\n title: { label: 'Title', format: 'string', entryTitle: true, required: true },\n description: { label: 'Description', format: 'text' },\n },\n },\n },\n };\n}\n\n/**\n * `cms/schema.json` — the source of truth. The Content Model UI (`/cms/model`)\n * reads and writes this file via `getSchema()` / `saveSchema()` server actions.\n */\nexport function schemaJsonTemplate(opts: SchemaInitOpts): string {\n return JSON.stringify(buildStarterSchema(opts), null, 2) + '\\n';\n}\n\n/**\n * `cms/__generated__/schema.ts` — auto-generated literal-typed mirror of\n * `cms/schema.json`. Required because `query()` infers narrow collection /\n * field / format types from the literal `defineConfig()` call — a plain JSON\n * import cannot preserve those literals.\n *\n * `npx octocms types:gen` regenerates this from `cms/schema.json` after every\n * schema edit (and `npm run types:check` fails on drift).\n */\nexport function generatedSchemaShimTemplate(opts: SchemaInitOpts): string {\n const gitBlock = opts.pointerBranch\n ? ` git: {\\n baseBranch: '${opts.baseBranch}',\\n publishedPointerBranch: '${opts.pointerBranch}',\\n },`\n : ` git: { baseBranch: '${opts.baseBranch}' },`;\n return `/*\n * AUTO-GENERATED — DO NOT EDIT.\n * Generated from cms/schema.json.\n * Run \\`npx octocms types:gen\\` to regenerate.\n */\n\nimport { defineConfig } from 'octocms/defineConfig';\n\nexport const schema = defineConfig({\n projectName: '${opts.projectName}',\n${gitBlock}\n contentFolder: 'cms/content',\n mediaContentFolder: 'cms/media',\n mediaFolder: 'public/media',\n mediaAllowedFormats: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'avif'],\n collections: {\n helloPage: {\n label: 'Hello Page',\n fields: {\n title: { label: 'Title', format: 'string', entryTitle: true, required: true },\n description: { label: 'Description', format: 'text' },\n },\n },\n },\n});\n`;\n}\n\n/**\n * `cms/octocms.config.ts` — thin TS binding. Imports the literal-typed\n * `schema` from the generated shim and re-exports it as `configOctoCMS` (the\n * runtime `Config`) and `OctoConfig` (the literal type used by `query()`).\n *\n * Hand-edits should go to `cms/schema.json`. After editing the JSON, run\n * `npx octocms types:gen` to refresh `cms/__generated__/schema.ts`.\n */\nexport function octoConfigTemplate(_opts: SchemaInitOpts): string {\n return `import type { Config } from 'octocms/types';\nimport { schema } from './__generated__/schema';\n\n/**\n * The schema is defined in \\`cms/schema.json\\` (source of truth — hand-editable\n * and editable through the Content Model UI). \\`npx octocms types:gen\\` mirrors\n * it into \\`cms/__generated__/schema.ts\\` as a literal-typed \\`defineConfig()\\`\n * call so the downstream \\`query()\\` API can infer narrow collection / field /\n * format types (which a plain JSON import cannot preserve).\n *\n * \\`npm run types:check\\` fails if the JSON and the generated shim drift.\n */\nconst _typedConfigOctoCMS = schema;\n\n/** Runtime config — widened to \\`Config\\` for dynamic indexing in CMS internals. */\nexport const configOctoCMS: Config = _typedConfigOctoCMS as Config;\n\n/**\n * Exact literal type of the config — use this for type-level inference only\n * (e.g. the \\`query()\\` API derives collection/field names from it).\n */\nexport type OctoConfig = typeof _typedConfigOctoCMS;\n`;\n}\n\nexport function nextConfigTemplate(): string {\n return `import type { NextConfig } from 'next';\nimport { withOctoCMS } from 'octocms/config';\nimport { configOctoCMS } from './cms/octocms.config';\n\nexport { configOctoCMS } from './cms/octocms.config';\nexport type { OctoConfig } from './cms/octocms.config';\n\nconst nextConfig: NextConfig = {};\n\nexport default withOctoCMS(nextConfig, configOctoCMS);\n`;\n}\n\nexport function demoHelloPageJson(): string {\n return JSON.stringify(\n {\n sys: { id: '0000', type: 'helloPage', status: 'merged' },\n fields: {\n title: 'Hello World',\n description: 'Welcome to your new OctoCMS site! Edit this content in the CMS admin panel.',\n },\n },\n null,\n 2,\n );\n}\n\nexport const helloPageTemplate = `import { query } from 'cms/__generated__/query';\n\nexport default async function HelloPage() {\n const page = await query('helloPage').first();\n if (!page) return null;\n return (\n <main>\n <h1>{page.fields.title}</h1>\n <p>{page.fields.description}</p>\n </main>\n );\n}\n`;\n\nexport function readmeTemplate(projectName: string): string {\n return `# ${projectName}\n\nBuilt with [OctoCMS](https://octocms.com) — a file-based CMS on Next.js.\n\n## Setup\n\n### 1. Install dependencies\n\n\\`\\`\\`bash\nnpm install octocms next-auth @tanstack/react-query @mdxeditor/editor \\\\\n @radix-ui/react-avatar @radix-ui/react-dialog @radix-ui/react-dropdown-menu \\\\\n @radix-ui/react-label @radix-ui/react-select @radix-ui/react-slot \\\\\n @radix-ui/react-tabs @radix-ui/react-toast \\\\\n class-variance-authority clsx glob lucide-react minisearch octokit \\\\\n react-markdown rehype-sanitize remark-gfm remark-mdx \\\\\n sharp slugify sonner tailwind-merge zod\n\\`\\`\\`\n\n> The exact list (with the right \\`octocms\\` version pin) is also printed by \\`npx octocms init\\` — copy it from there.\n\n### 2. Create a GitHub App\n\nFollow the [OctoCMS GitHub App setup guide](https://octocms.com/docs/github-app) to create a GitHub App for authentication.\n\n### 3. Configure environment variables\n\nCopy the values from your GitHub App into \\`.env.local\\`:\n\n\\`\\`\\`bash\n# GitHub App credentials (required for CMS auth)\nGITHUB_ID=your_github_app_client_id\nGITHUB_SECRET=your_github_app_client_secret\n\n# NextAuth (generate secret: openssl rand -base64 32)\nNEXTAUTH_SECRET=your_nextauth_secret\nNEXTAUTH_URL=http://localhost:3000\n\n# GitHub repo for content storage (required in production)\nGITHUB_REPO_OWNER=your_github_username_or_org\nGITHUB_REPO_NAME=your_repo_name\n\n# Optional: static GitHub token for private repos / higher API rate limits\n# CMS_GITHUB_TOKEN=your_github_pat\n\\`\\`\\`\n\n### 4. Run the dev server\n\n\\`\\`\\`bash\nnpm run dev\n\\`\\`\\`\n\nOpen [http://localhost:3000/cms](http://localhost:3000/cms) to access the CMS admin.\n`;\n}\n\nexport function envLocalTemplate(): string {\n return `# GitHub App credentials (required for CMS auth)\n# Create a GitHub App at: https://github.com/settings/apps/new\nGITHUB_ID=\nGITHUB_SECRET=\n\n# NextAuth secret — generate with: openssl rand -base64 32\nNEXTAUTH_SECRET=\nNEXTAUTH_URL=http://localhost:3000\n\n# GitHub repo for content storage (required in production)\nGITHUB_REPO_OWNER=\nGITHUB_REPO_NAME=\n\n# Optional: static GitHub token for private repos or higher API rate limits\n# CMS_GITHUB_TOKEN=\n`;\n}\n\nconst AGENT_DOCS_MARKER = '<!-- octocms:agent-docs -->';\n\nexport function agentsMdSection(): string {\n return `${AGENT_DOCS_MARKER}\n## OctoCMS — AI Content Management\n\nFor tasks that involve creating, editing, or deleting CMS content directly (without the admin UI), read the auto-generated agent docs:\n\n- **\\`octocms/docs/overview.md\\`** — How to find, create, update, and delete content entries via file operations\n- **\\`octocms/docs/schema.md\\`** — Per-collection field definitions, example JSON, and file path conventions\n\nThese docs are generated from \\`cms/octocms.config.ts\\`. Regenerate after schema changes: \\`npm run agent-docs:gen\\`.`;\n}\n\nexport function agentsMdTemplate(): string {\n return `# Project Guidelines\n\n${agentsMdSection()}\n`;\n}\n\nexport function tsconfigPaths(): Record<string, string[]> {\n return {\n 'cms/__generated__': ['./cms/__generated__/index.ts'],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A;AAAA;AAAA;AAgBT;AAEA,MAAM,oBAAoB;AAEnB,SAAS,kBAA0B;AACxC,SAAO,GAAG,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS7B;AAEO,SAAS,mBAA2B;AACzC,SAAO;AAAA;AAAA,EAEP,gBAAgB,CAAC;AAAA;AAEnB;AAEO,SAAS,gBAA0C;AACxD,SAAO;AAAA,IACL,qBAAqB,CAAC,8BAA8B;AAAA,IACpD,uBAAuB,CAAC,uBAAuB;AAAA,IAC/C,OAAO,CAAC,SAAS;AAAA,EACnB;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
version
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GL7FGEA4.js";
|
|
4
4
|
import {
|
|
5
5
|
adminErrorTemplate,
|
|
6
6
|
agentChatRouteTemplate,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
generatedEnumsTemplate,
|
|
14
14
|
generatedIndexTemplate,
|
|
15
15
|
generatedQueryTemplate,
|
|
16
|
+
generatedSchemaShimTemplate,
|
|
16
17
|
generatedTypesTemplate,
|
|
17
18
|
helloPageTemplate,
|
|
18
19
|
mediaRouteTemplate,
|
|
@@ -22,8 +23,9 @@ import {
|
|
|
22
23
|
readmeTemplate,
|
|
23
24
|
rootLayoutConfigInitImport,
|
|
24
25
|
rootLayoutTemplate,
|
|
26
|
+
schemaJsonTemplate,
|
|
25
27
|
tsconfigPaths
|
|
26
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-DCDFWNC6.js";
|
|
27
29
|
import {
|
|
28
30
|
fmt,
|
|
29
31
|
log
|
|
@@ -116,8 +118,10 @@ function detectDevPort(projectRoot) {
|
|
|
116
118
|
async function initCommand(projectRoot, options = {}) {
|
|
117
119
|
log.header("Initialize a new project");
|
|
118
120
|
const octoConfigPath = join(projectRoot, "cms", "octocms.config.ts");
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
const schemaJsonPath = join(projectRoot, "cms", "schema.json");
|
|
122
|
+
const octoConfigInitialized = existsSync(octoConfigPath) && /export\s+const\s+configOctoCMS/.test(readFileSync(octoConfigPath, "utf8"));
|
|
123
|
+
if (octoConfigInitialized || existsSync(schemaJsonPath)) {
|
|
124
|
+
log.error("cms/ already contains an OctoCMS install \u2014 this project is already initialized.");
|
|
121
125
|
log.info("Use `octocms update` to regenerate admin route files.");
|
|
122
126
|
process.exitCode = 1;
|
|
123
127
|
return;
|
|
@@ -189,16 +193,17 @@ async function initCommand(projectRoot, options = {}) {
|
|
|
189
193
|
log.blank();
|
|
190
194
|
log.info("Updating configuration...");
|
|
191
195
|
mkdirSync(join(projectRoot, "cms"), { recursive: true });
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
);
|
|
201
|
-
|
|
196
|
+
const schemaOpts = {
|
|
197
|
+
projectName: answers.projectName,
|
|
198
|
+
baseBranch: answers.baseBranch,
|
|
199
|
+
pointerBranch: answers.usePointerBranch ? answers.pointerBranch : void 0
|
|
200
|
+
};
|
|
201
|
+
writeFileSync(join(projectRoot, "cms", "schema.json"), schemaJsonTemplate(schemaOpts), "utf8");
|
|
202
|
+
log.success("cms/schema.json \u2014 source of truth");
|
|
203
|
+
writeFileSync(join(generatedDir, "schema.ts"), generatedSchemaShimTemplate(schemaOpts), "utf8");
|
|
204
|
+
log.success("cms/__generated__/schema.ts");
|
|
205
|
+
writeFileSync(octoConfigPath, octoConfigTemplate(schemaOpts), "utf8");
|
|
206
|
+
log.success("cms/octocms.config.ts \u2014 schema binding");
|
|
202
207
|
writeFileSync(nextConfigPath, nextConfigTemplate(), "utf8");
|
|
203
208
|
log.success("next.config.ts \u2014 Next.js wrapper");
|
|
204
209
|
const tsconfigPath = join(projectRoot, "tsconfig.json");
|
|
@@ -259,4 +264,4 @@ async function initCommand(projectRoot, options = {}) {
|
|
|
259
264
|
export {
|
|
260
265
|
initCommand
|
|
261
266
|
};
|
|
262
|
-
//# sourceMappingURL=init-
|
|
267
|
+
//# sourceMappingURL=init-W645ZB34.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../cli/commands/init.ts"],"sourcesContent":["/**\n * `octocms init` — Initialize OctoCMS in a Next.js project.\n *\n * Writes the full CMS config inline into `next.config.ts`, creates admin\n * route files, demo content, and updates `tsconfig.json` with required\n * path aliases.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport readline from 'readline';\n\nimport { version as CLI_VERSION } from '../../package.json';\nimport { fmt, log } from '../lib/logger';\n\nimport {\n adminErrorTemplate,\n buildAdminLayoutTemplate,\n buildAdminPageTemplate,\n agentChatRouteTemplate,\n mediaRouteTemplate,\n demoHelloPageJson,\n envLocalTemplate,\n generatedConfigInitTemplate,\n generatedSchemaShimTemplate,\n generatedContentDeclsTemplate,\n generatedEnumsTemplate,\n generatedIndexTemplate,\n generatedQueryTemplate,\n generatedTypesTemplate,\n helloPageTemplate,\n nextAuthRouteTemplate,\n nextConfigTemplate,\n octoConfigTemplate,\n schemaJsonTemplate,\n readmeTemplate,\n rootLayoutConfigInitImport,\n rootLayoutTemplate,\n tsconfigPaths,\n} from '../lib/templates';\n\n/**\n * Required (non-optional) peer dependencies of `octocms`, excluding\n * `next` / `react` / `react-dom` which any Next.js project already has.\n *\n * Keep in sync with `octocms/package.json` `peerDependencies` minus the\n * entries flagged `optional: true` in `peerDependenciesMeta`. The\n * `init.test.ts` `keeps REQUIRED_PEER_DEPS in sync` test enforces this.\n */\nconst REQUIRED_PEER_DEPS: readonly string[] = [\n '@mdxeditor/editor',\n '@radix-ui/react-avatar',\n '@radix-ui/react-dialog',\n '@radix-ui/react-dropdown-menu',\n '@radix-ui/react-label',\n '@radix-ui/react-select',\n '@radix-ui/react-slot',\n '@radix-ui/react-tabs',\n '@radix-ui/react-toast',\n '@tanstack/react-query',\n 'class-variance-authority',\n 'clsx',\n 'glob',\n 'lucide-react',\n 'minisearch',\n 'next-auth',\n 'octokit',\n 'react-markdown',\n 'rehype-sanitize',\n 'remark-gfm',\n 'remark-mdx',\n 'sharp',\n 'slugify',\n 'sonner',\n 'tailwind-merge',\n 'zod',\n];\n\nexport type InitOptions = {\n /** Accept all defaults without prompting. */\n yes?: boolean;\n};\n\ntype InitAnswers = {\n projectName: string;\n baseBranch: string;\n usePointerBranch: boolean;\n pointerBranch: string;\n};\n\nasync function prompt(rl: readline.Interface, question: string, defaultValue?: string): Promise<string> {\n const suffix = defaultValue ? ` (${defaultValue})` : '';\n return new Promise((resolve) => {\n rl.question(` ? ${question}${suffix}: `, (answer) => {\n resolve(answer.trim() || defaultValue || '');\n });\n });\n}\n\nasync function confirm(rl: readline.Interface, question: string, defaultYes = false): Promise<boolean> {\n const hint = defaultYes ? 'Y/n' : 'y/N';\n const answer = await prompt(rl, `${question} (${hint})`);\n if (!answer) return defaultYes;\n return answer.toLowerCase().startsWith('y');\n}\n\nasync function gatherAnswers(options: InitOptions): Promise<InitAnswers> {\n if (options.yes) {\n return {\n projectName: 'My CMS',\n baseBranch: 'main',\n usePointerBranch: false,\n pointerBranch: '',\n };\n }\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n try {\n const projectName = await prompt(rl, 'Project name', 'My CMS');\n const baseBranch = await prompt(rl, 'Git base branch', 'main');\n const usePointerBranch = await confirm(rl, 'Use a separate published pointer branch?');\n let pointerBranch = '';\n if (usePointerBranch) {\n pointerBranch = await prompt(rl, 'Pointer branch name', 'cms/publish-pointer');\n }\n\n return { projectName, baseBranch, usePointerBranch, pointerBranch };\n } finally {\n rl.close();\n }\n}\n\n/** Detect the dev port from the project's package.json dev script. Defaults to 3000. */\nfunction detectDevPort(projectRoot: string): number {\n try {\n const pkg = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8')) as {\n scripts?: Record<string, string>;\n };\n const devScript = pkg.scripts?.dev ?? '';\n const match = /(?:-p|--port)[= ](\\d+)/.exec(devScript);\n if (match) return parseInt(match[1], 10);\n } catch {\n // ignore\n }\n return 3000;\n}\n\nexport async function initCommand(projectRoot: string, options: InitOptions = {}): Promise<void> {\n log.header('Initialize a new project');\n\n // Already initialized if cms/octocms.config.ts already exports configOctoCMS,\n // OR if the schema source-of-truth file already exists. Either is enough.\n const octoConfigPath = join(projectRoot, 'cms', 'octocms.config.ts');\n const schemaJsonPath = join(projectRoot, 'cms', 'schema.json');\n const octoConfigInitialized =\n existsSync(octoConfigPath) && /export\\s+const\\s+configOctoCMS/.test(readFileSync(octoConfigPath, 'utf8'));\n if (octoConfigInitialized || existsSync(schemaJsonPath)) {\n log.error('cms/ already contains an OctoCMS install — this project is already initialized.');\n log.info('Use `octocms update` to regenerate admin route files.');\n process.exitCode = 1;\n return;\n }\n const nextConfigPath = join(projectRoot, 'next.config.ts');\n\n if (!existsSync(join(projectRoot, 'package.json'))) {\n log.error('No package.json found — run this inside a Next.js project.');\n process.exitCode = 1;\n return;\n }\n\n const answers = await gatherAnswers(options);\n\n log.blank();\n log.info('Creating files...');\n\n // Admin route files — three thin re-exports. The package owns dispatch +\n // per-component Suspense + skeletons via the `octocms/admin` barrel.\n const cmsRouteDir = join(projectRoot, 'app', 'cms');\n mkdirSync(join(cmsRouteDir, '[[...path]]'), { recursive: true });\n\n writeFileSync(join(cmsRouteDir, 'layout.tsx'), buildAdminLayoutTemplate(), 'utf8');\n log.success('app/cms/layout.tsx');\n\n writeFileSync(join(cmsRouteDir, '[[...path]]', 'page.tsx'), buildAdminPageTemplate(), 'utf8');\n log.success('app/cms/[[...path]]/page.tsx');\n\n writeFileSync(join(cmsRouteDir, 'error.tsx'), adminErrorTemplate, 'utf8');\n log.success('app/cms/error.tsx');\n\n // Root layout — ensure configInit is imported so public page serverless functions\n // initialize the OctoCMS config on cold start (not just admin routes).\n const rootLayoutPath = join(projectRoot, 'app', 'layout.tsx');\n if (!existsSync(rootLayoutPath)) {\n writeFileSync(rootLayoutPath, rootLayoutTemplate, 'utf8');\n log.success('app/layout.tsx — created with configInit import');\n } else {\n const existing = readFileSync(rootLayoutPath, 'utf8');\n if (!existing.includes('configInit')) {\n writeFileSync(rootLayoutPath, rootLayoutConfigInitImport + existing, 'utf8');\n log.success('app/layout.tsx — added configInit import');\n } else {\n log.success('app/layout.tsx — configInit import already present');\n }\n }\n\n // NextAuth API route\n const authRouteDir = join(projectRoot, 'app', 'api', 'auth', '[...nextauth]');\n mkdirSync(authRouteDir, { recursive: true });\n writeFileSync(join(authRouteDir, 'route.ts'), nextAuthRouteTemplate, 'utf8');\n log.success('app/api/auth/[...nextauth]/route.ts');\n\n // Chat-agent routes — thin re-exports of handlers in `octocms/agent`.\n // The handlers are opt-in (the agent feature is gated by config + provider\n // key at runtime); shipping the routes by default costs nothing when the\n // agent is disabled — every endpoint 404s in that case.\n const chatRouteDir = join(projectRoot, 'app', 'api', 'agent');\n mkdirSync(chatRouteDir, { recursive: true });\n writeFileSync(join(chatRouteDir, 'route.ts'), agentChatRouteTemplate(), 'utf8');\n log.success('app/api/agent/route.ts');\n\n // Note: chat-agent proposal accept/reject are server actions\n // (`acceptProposalAction` / `rejectProposalAction` in\n // `octocms/admin/actions/agent.ts`), called directly from `useChatStream` —\n // no public endpoint files are scaffolded.\n\n // Media proxy route — thin re-export of `mediaRoute` from `octocms/admin/mediaRoute`.\n // Vercel's filesystem is immutable after build, so images committed from the\n // CMS UI never land in `public/media/` on the running instance — routing\n // them through a Route Handler lets the GitHub-API path serve them.\n const mediaRouteDir = join(projectRoot, 'app', 'media', '[...slug]');\n mkdirSync(mediaRouteDir, { recursive: true });\n writeFileSync(join(mediaRouteDir, 'route.ts'), mediaRouteTemplate(), 'utf8');\n log.success('app/media/[...slug]/route.ts');\n\n // Hello page demo route\n mkdirSync(join(projectRoot, 'app', 'hello'), { recursive: true });\n writeFileSync(join(projectRoot, 'app', 'hello', 'page.tsx'), helloPageTemplate, 'utf8');\n log.success('app/hello/page.tsx');\n\n // Demo content\n const contentDir = join(projectRoot, 'cms', 'content', 'helloPage');\n mkdirSync(contentDir, { recursive: true });\n writeFileSync(join(contentDir, 'helloPage-0000.json'), demoHelloPageJson(), 'utf8');\n log.success('cms/content/helloPage/helloPage-0000.json');\n\n // cms/__generated__/ — write static starter files (schema-accurate for helloPage demo)\n // These are valid immediately; re-run `npx octocms types:gen` after editing the schema.\n const generatedDir = join(projectRoot, 'cms', '__generated__');\n mkdirSync(generatedDir, { recursive: true });\n const generatedFiles: [string, string][] = [\n ['types.ts', generatedTypesTemplate],\n ['enums.ts', generatedEnumsTemplate],\n ['content.d.ts', generatedContentDeclsTemplate],\n ['index.ts', generatedIndexTemplate],\n ['query.ts', generatedQueryTemplate],\n ['configInit.ts', generatedConfigInitTemplate],\n ];\n for (const [name, content] of generatedFiles) {\n writeFileSync(join(generatedDir, name), content, 'utf8');\n log.success(`cms/__generated__/${name}`);\n }\n\n // Media directory\n mkdirSync(join(projectRoot, 'public', 'media'), { recursive: true });\n\n // Schema source of truth + literal-typed shim + thin TS binding.\n log.blank();\n log.info('Updating configuration...');\n mkdirSync(join(projectRoot, 'cms'), { recursive: true });\n const schemaOpts = {\n projectName: answers.projectName,\n baseBranch: answers.baseBranch,\n pointerBranch: answers.usePointerBranch ? answers.pointerBranch : undefined,\n };\n // cms/schema.json — source of truth (Content Model UI reads/writes here).\n writeFileSync(join(projectRoot, 'cms', 'schema.json'), schemaJsonTemplate(schemaOpts), 'utf8');\n log.success('cms/schema.json — source of truth');\n // cms/__generated__/schema.ts — literal-typed mirror used by `query()`.\n writeFileSync(join(generatedDir, 'schema.ts'), generatedSchemaShimTemplate(schemaOpts), 'utf8');\n log.success('cms/__generated__/schema.ts');\n // cms/octocms.config.ts — thin TS binding that re-exports the generated shim.\n writeFileSync(octoConfigPath, octoConfigTemplate(schemaOpts), 'utf8');\n log.success('cms/octocms.config.ts — schema binding');\n\n // next.config.ts — write the thin Next.js wrapper\n writeFileSync(nextConfigPath, nextConfigTemplate(), 'utf8');\n log.success('next.config.ts — Next.js wrapper');\n\n // tsconfig.json\n const tsconfigPath = join(projectRoot, 'tsconfig.json');\n if (existsSync(tsconfigPath)) {\n try {\n const raw = readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(raw);\n if (!tsconfig.compilerOptions) tsconfig.compilerOptions = {};\n if (!tsconfig.compilerOptions.paths) tsconfig.compilerOptions.paths = {};\n const requiredPaths = tsconfigPaths();\n let changed = false;\n for (const [alias, targets] of Object.entries(requiredPaths)) {\n if (!tsconfig.compilerOptions.paths[alias]) {\n tsconfig.compilerOptions.paths[alias] = targets;\n changed = true;\n }\n }\n if (changed) {\n writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + '\\n', 'utf8');\n log.success('tsconfig.json — added path aliases');\n } else {\n log.success('tsconfig.json — path aliases already present');\n }\n } catch {\n log.warn('tsconfig.json — could not parse; add path aliases manually');\n }\n } else {\n log.warn('tsconfig.json not found — create one with the required path aliases');\n }\n\n // .env.local — write stub only if it doesn't already exist\n const envLocalPath = join(projectRoot, '.env.local');\n if (!existsSync(envLocalPath)) {\n writeFileSync(envLocalPath, envLocalTemplate(), 'utf8');\n log.success('.env.local — environment variable stubs');\n } else {\n log.success('.env.local — already exists, skipped');\n }\n\n // README.md — write only if it doesn't already exist\n const readmePath = join(projectRoot, 'README.md');\n if (!existsSync(readmePath)) {\n writeFileSync(readmePath, readmeTemplate(answers.projectName), 'utf8');\n log.success('README.md — setup guide');\n } else {\n log.success('README.md — already exists, skipped');\n }\n\n const port = detectDevPort(projectRoot);\n log.blank();\n log.info('Next steps:');\n log.info(' 1. Install dependencies:');\n log.info(` ${fmt.cyan(`npm install octocms@${CLI_VERSION} ${REQUIRED_PEER_DEPS.join(' ')}`)}`);\n log.info(' 2. Fill in GitHub App credentials in .env.local (see README.md)');\n log.info(' 3. Run: npm run dev');\n log.info(` 4. Visit demo page: http://localhost:${port}/hello`);\n log.info(` 5. Visit CMS admin: http://localhost:${port}/cms`);\n log.info('');\n log.info(' After editing cms/octocms.config.ts, regenerate types:');\n log.info(' npx octocms types:gen');\n log.blank();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,YAAY;AACrB,OAAO,cAAc;AAuCrB,IAAM,qBAAwC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAcA,eAAe,OAAO,IAAwB,UAAkB,cAAwC;AACtG,QAAM,SAAS,eAAe,KAAK,YAAY,MAAM;AACrD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,OAAG,SAAS,OAAO,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW;AACpD,cAAQ,OAAO,KAAK,KAAK,gBAAgB,EAAE;AAAA,IAC7C,CAAC;AAAA,EACH,CAAC;AACH;AAEA,eAAe,QAAQ,IAAwB,UAAkB,aAAa,OAAyB;AACrG,QAAM,OAAO,aAAa,QAAQ;AAClC,QAAM,SAAS,MAAM,OAAO,IAAI,GAAG,QAAQ,KAAK,IAAI,GAAG;AACvD,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,OAAO,YAAY,EAAE,WAAW,GAAG;AAC5C;AAEA,eAAe,cAAc,SAA4C;AACvE,MAAI,QAAQ,KAAK;AACf,WAAO;AAAA,MACL,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAClB,eAAe;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,KAAK,SAAS,gBAA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,MAAI,CAAC,WAAW,YAAY,GAAG;AAC7B,kBAAc,cAAc,iBAAiB,GAAG,MAAM;AACtD,QAAI,QAAQ,8CAAyC;AAAA,EACvD,OAAO;AACL,QAAI,QAAQ,2CAAsC;AAAA,EACpD;AAGA,QAAM,aAAa,KAAK,aAAa,WAAW;AAChD,MAAI,CAAC,WAAW,UAAU,GAAG;AAC3B,kBAAc,YAAY,eAAe,QAAQ,WAAW,GAAG,MAAM;AACrE,QAAI,QAAQ,8BAAyB;AAAA,EACvC,OAAO;AACL,QAAI,QAAQ,0CAAqC;AAAA,EACnD;AAEA,QAAM,OAAO,cAAc,WAAW;AACtC,MAAI,MAAM;AACV,MAAI,KAAK,aAAa;AACtB,MAAI,KAAK,4BAA4B;AACrC,MAAI,KAAK,QAAQ,IAAI,KAAK,uBAAuB,OAAW,IAAI,mBAAmB,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE;AACjG,MAAI,KAAK,mEAAmE;AAC5E,MAAI,KAAK,uBAAuB;AAChC,MAAI,KAAK,0CAA0C,IAAI,QAAQ;AAC/D,MAAI,KAAK,2CAA2C,IAAI,MAAM;AAC9D,MAAI,KAAK,EAAE;AACX,MAAI,KAAK,0DAA0D;AACnE,MAAI,KAAK,yBAAyB;AAClC,MAAI,MAAM;AACZ;","names":[]}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
mediaRouteTemplate,
|
|
9
9
|
nextAuthRouteTemplate,
|
|
10
10
|
rootLayoutConfigInitImport
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-DCDFWNC6.js";
|
|
12
12
|
import {
|
|
13
13
|
log
|
|
14
14
|
} from "./chunk-6PHFHGTZ.js";
|
|
@@ -173,4 +173,4 @@ async function updateCommand(projectRoot) {
|
|
|
173
173
|
export {
|
|
174
174
|
updateCommand
|
|
175
175
|
};
|
|
176
|
-
//# sourceMappingURL=update-
|
|
176
|
+
//# sourceMappingURL=update-QNJRYPMC.js.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/lib/templates.ts"],"sourcesContent":["/**\n * File templates used by `octocms init` and `octocms update`.\n */\n\nconst CODEGEN_BANNER = `/*\n * AUTO-GENERATED — DO NOT EDIT.\n * Generated from cms/octocms.config.ts.\n * Run \\`npx octocms types:gen\\` to regenerate.\n */\n\n`;\n\n/** Static cms/__generated__/types.ts for the helloPage demo schema. */\nexport const generatedTypesTemplate =\n CODEGEN_BANNER +\n `import type { EntryStatus } from 'octocms/types';\n\nexport interface HelloPageFields {\n title: string;\n description: string;\n}\n\nexport interface HelloPageEntry {\n sys: { id: string; type: 'helloPage'; status: EntryStatus };\n fields: HelloPageFields;\n}\n\nexport type AnyEntry = HelloPageEntry;\n\nexport type EntryMap = {\n helloPage: HelloPageEntry;\n};\n`;\n\n/** Static cms/__generated__/enums.ts for the helloPage demo schema. */\nexport const generatedEnumsTemplate =\n CODEGEN_BANNER +\n `export const CollectionName = {\n HelloPage: 'helloPage',\n} as const;\nexport type CollectionName = (typeof CollectionName)[keyof typeof CollectionName];\n\nexport const COLLECTION_NAMES = ['helloPage'] as const;\n\nexport const FieldFormat = {\n String: 'string',\n Text: 'text',\n Markdown: 'markdown',\n Boolean: 'boolean',\n Reference: 'reference',\n Image: 'image',\n Number: 'number',\n Datetime: 'datetime',\n Json: 'json',\n Slug: 'slug',\n Select: 'select',\n Url: 'url',\n Color: 'color',\n Conditional: 'conditional',\n Richtext: 'richtext',\n} as const;\nexport type FieldFormat = (typeof FieldFormat)[keyof typeof FieldFormat];\n`;\n\n/** Static cms/__generated__/content.d.ts for the helloPage demo schema. */\nexport const generatedContentDeclsTemplate =\n CODEGEN_BANNER +\n `import type { EntryStatus } from 'octocms/types';\n\n// Raw on-disk types (before query() processing).\nexport interface RawHelloPageFields {\n title: string;\n description: string;\n}\n\nexport interface RawHelloPageEntry {\n sys: { id: string; type: 'helloPage'; status: EntryStatus };\n fields: RawHelloPageFields;\n}\n`;\n\n/** Static cms/__generated__/index.ts — always the same shape. */\nexport const generatedIndexTemplate =\n CODEGEN_BANNER +\n `export * from './types';\nexport * from './enums';\nexport * from './query';\n`;\n\n/** Static cms/__generated__/query.ts — always the same shape (schema-independent). */\nexport const generatedQueryTemplate =\n CODEGEN_BANNER +\n `import { createQuery } from 'octocms/query';\nimport { configOctoCMS, type OctoConfig } from '../octocms.config';\nimport type { EntryMap } from './types';\n\n// configOctoCMS is widened to Config for admin internals; cast back to OctoConfig so\n// createQuery preserves literal collection/field names for type-safe queries.\nexport const query = createQuery<EntryMap, OctoConfig>(configOctoCMS as unknown as OctoConfig);\n`;\n\n/** Static cms/__generated__/configInit.ts — always the same shape (schema-independent). */\nexport const generatedConfigInitTemplate =\n CODEGEN_BANNER +\n `import { configOctoCMS } from '../octocms.config';\nimport { setConfig } from 'octocms/lib/configStore';\n\nsetConfig(configOctoCMS);\n`;\n\n/**\n * All scaffolded files import the generated config initialiser via the bare\n * specifier `cms/__generated__/configInit`. Resolution works in two layers:\n *\n * - TypeScript IntelliSense: the consumer's `tsconfig.json` `paths` (added\n * by `octocms init`).\n * - Bundler: an alias registered by `withOctoCMS()` so Webpack and Turbopack\n * resolve the bare specifier from anywhere — including `app/layout.tsx`,\n * route handlers at any depth, and files inside `node_modules/octocms/`.\n *\n * This eliminates the previous depth-counting (`'../../../cms/...'`) that was\n * a recurring source of off-by-one bugs across templates and routes.\n */\nconst CONFIG_INIT_IMPORT = \"import 'cms/__generated__/configInit';\";\n\n/**\n * Minimal root layout written when `app/layout.tsx` does not already exist.\n * The configInit import is the critical side-effect; the rest is a Next.js\n * boilerplate shell.\n */\nexport const rootLayoutTemplate = `${CONFIG_INIT_IMPORT}\nimport type { Metadata } from 'next';\n\nexport const metadata: Metadata = {\n title: 'My App',\n};\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n );\n}\n`;\n\n/** The one-liner prepended to an existing root layout to register the config. */\nexport const rootLayoutConfigInitImport = `${CONFIG_INIT_IMPORT}\\n`;\n\nexport function buildAdminLayoutTemplate(): string {\n return `${CONFIG_INIT_IMPORT}\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin';\n`;\n}\n\n/**\n * Catch-all admin route — every \\`/cms/*\\` URL renders the package's\n * \\`AdminApp\\` async server component (awaits \\`params\\`, no outer Suspense).\n * Side-effect-imports \\`configInit\\` so server-action bundles register\n * \\`setConfig()\\` even when Next.js does not load \\`layout.tsx\\` for the POST.\n */\nexport function buildAdminPageTemplate(): string {\n return `// Registers setConfig() for server actions — some POST bundles skip layout.tsx.\n${CONFIG_INIT_IMPORT}\n\nexport { AdminApp as default } from 'octocms/admin';\n`;\n}\n\n/**\n * Admin error boundary — rendered by Next.js when anything in the catch-all\n * tree throws during render. Re-uses the shared \\`AdminErrorView\\` so GitHub\n * config / auth / availability / rate-limit copy stays consistent with the\n * public-page error boundary.\n */\nexport const adminErrorTemplate = `'use client';\n\nexport { AdminError as default } from 'octocms/admin';\n`;\n\n/**\n * Historical template values used by \\`octocms update\\` to recognise an\n * unmodified install when migrating between routing models. Each entry is\n * the literal file content shipped by a previous OctoCMS version. If a\n * user-app file matches one of these byte-for-byte, \\`update\\` will replace\n * it with the current template; otherwise it leaves it alone.\n */\nexport const LEGACY_ADMIN_LAYOUT_TEMPLATES: ReadonlyArray<string> = [\n // 0.4.x — re-exported from the deep path.\n `import '../../cms/__generated__/configInit';\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin/pages/AdminLayout';\n`,\n // 0.5.x — barrel re-export with depth-counted relative configInit import.\n `import '../../cms/__generated__/configInit';\nimport 'octocms/globals.css';\nimport '@mdxeditor/editor/style.css';\n\nexport { AdminLayout as default, metadata } from 'octocms/admin';\n`,\n];\n\nexport const LEGACY_ADMIN_CATCH_ALL_TEMPLATES: ReadonlyArray<string> = [\n // 0.4.x — re-exported from the deep path.\n `export { AdminApp as default } from 'octocms/admin/AdminApp';\n`,\n // 0.5.x — barrel re-export without configInit on the page (server actions could miss setConfig).\n `export { AdminApp as default } from 'octocms/admin';\n`,\n // 0.5.x with depth-counted configInit (replaced by bare-specifier alias).\n `// Registers setConfig() for server actions — some POST bundles skip layout.tsx.\nimport '../../../cms/__generated__/configInit';\n\nexport { AdminApp as default } from 'octocms/admin';\n`,\n];\n\nexport const nextAuthRouteTemplate = `import NextAuth from 'next-auth';\nimport { authOptions } from 'octocms/admin/auth';\n\nconst handler = NextAuth(authOptions);\n\nexport { handler as GET, handler as POST };\n`;\n\n/**\n * Build a thin re-export Route Handler for the chat-agent SSE endpoint.\n *\n * The actual handler lives in `octocms/agent/chatApi.ts`\n * (`chatRoute` / `chatStatusRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so\n * `getAgentConfig()` resolves on cold start (Route Handlers don't run\n * `app/layout.tsx`); and\n * 2. re-exports `chatRoute` as `POST` and `chatStatusRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic and can be\n * placed under `app/` or `src/app/` without code changes.\n */\nexport function agentChatRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` + \\`agentConfig\\` into the\n// runtime stores so \\`getAgentConfig()\\` resolves on cold start. Route Handlers\n// don't run \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { chatRoute as POST, chatStatusRoute as GET } from 'octocms/agent';\n`;\n}\n\n/**\n * Build a thin re-export Route Handler for the `/media/[...slug]` proxy.\n *\n * The actual handler lives in `octocms/admin/mediaRoute.ts`\n * (`mediaRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so `getConfig()`\n * resolves on cold start (Route Handlers don't run `app/layout.tsx`); and\n * 2. re-exports `mediaRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic.\n */\nexport function mediaRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` into the runtime store so\n// \\`getConfig()\\` resolves on cold start. Route Handlers don't run\n// \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { mediaRoute as GET } from 'octocms/admin/mediaRoute';\n`;\n}\n\n/**\n * Build a thin re-export Route Handler for the public-site `/api/search`\n * endpoint consumed by the `SearchBox` component shipped at\n * `octocms/components/public`.\n *\n * The actual handler lives in `octocms/admin/searchRoute.ts`\n * (`searchRoute`). The user-app file just:\n * 1. side-effect-imports `cms/__generated__/configInit` so `getConfig()`\n * resolves on cold start (Route Handlers don't run `app/layout.tsx`); and\n * 2. re-exports `searchRoute` as `GET`.\n *\n * The configInit import uses the bare specifier (resolved by the bundler\n * alias from `withOctoCMS()`), so the route file is depth-agnostic.\n */\nexport function searchRouteTemplate(): string {\n return `// Side-effect import: registers \\`configOctoCMS\\` into the runtime store so\n// \\`getConfig()\\` resolves on cold start. Route Handlers don't run\n// \\`app/layout.tsx\\`, so this import has to live here.\n${CONFIG_INIT_IMPORT}\n\nexport { searchRoute as GET } from 'octocms/admin/searchRoute';\n`;\n}\n\nexport function octoConfigTemplate(opts: { projectName: string; baseBranch: string; pointerBranch?: string }): string {\n const gitBlock = opts.pointerBranch\n ? ` git: {\\n baseBranch: '${opts.baseBranch}',\\n publishedPointerBranch: '${opts.pointerBranch}',\\n },`\n : ` git: { baseBranch: '${opts.baseBranch}' },`;\n\n return `import type { Config } from 'octocms/types';\nimport { defineConfig } from 'octocms/config';\n\nconst _typedConfigOctoCMS = defineConfig({\n projectName: '${opts.projectName}',\n${gitBlock}\n contentFolder: 'cms/content',\n mediaContentFolder: 'cms/media',\n mediaFolder: 'public/media',\n mediaAllowedFormats: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'avif'],\n collections: {\n helloPage: {\n label: 'Hello Page',\n fields: {\n title: { label: 'Title', format: 'string', entryTitle: true, required: true },\n description: { label: 'Description', format: 'text' },\n },\n },\n },\n});\n\nexport const configOctoCMS: Config = _typedConfigOctoCMS;\nexport type OctoConfig = typeof _typedConfigOctoCMS;\n`;\n}\n\nexport function nextConfigTemplate(): string {\n return `import type { NextConfig } from 'next';\nimport { withOctoCMS } from 'octocms/config';\nimport { configOctoCMS } from './cms/octocms.config';\n\nexport { configOctoCMS } from './cms/octocms.config';\nexport type { OctoConfig } from './cms/octocms.config';\n\nconst nextConfig: NextConfig = {};\n\nexport default withOctoCMS(nextConfig, configOctoCMS);\n`;\n}\n\nexport function demoHelloPageJson(): string {\n return JSON.stringify(\n {\n sys: { id: '0000', type: 'helloPage', status: 'merged' },\n fields: {\n title: 'Hello World',\n description: 'Welcome to your new OctoCMS site! Edit this content in the CMS admin panel.',\n },\n },\n null,\n 2,\n );\n}\n\nexport const helloPageTemplate = `import { query } from 'cms/__generated__/query';\n\nexport default async function HelloPage() {\n const page = await query('helloPage').first();\n if (!page) return null;\n return (\n <main>\n <h1>{page.fields.title}</h1>\n <p>{page.fields.description}</p>\n </main>\n );\n}\n`;\n\nexport function readmeTemplate(projectName: string): string {\n return `# ${projectName}\n\nBuilt with [OctoCMS](https://octocms.com) — a file-based CMS on Next.js.\n\n## Setup\n\n### 1. Install dependencies\n\n\\`\\`\\`bash\nnpm install octocms next-auth @tanstack/react-query @mdxeditor/editor \\\\\n @radix-ui/react-avatar @radix-ui/react-dialog @radix-ui/react-dropdown-menu \\\\\n @radix-ui/react-label @radix-ui/react-select @radix-ui/react-slot \\\\\n @radix-ui/react-tabs @radix-ui/react-toast \\\\\n class-variance-authority clsx glob lucide-react minisearch octokit \\\\\n react-markdown rehype-sanitize remark-gfm remark-mdx \\\\\n sharp slugify sonner tailwind-merge zod\n\\`\\`\\`\n\n> The exact list (with the right \\`octocms\\` version pin) is also printed by \\`npx octocms init\\` — copy it from there.\n\n### 2. Create a GitHub App\n\nFollow the [OctoCMS GitHub App setup guide](https://octocms.com/docs/github-app) to create a GitHub App for authentication.\n\n### 3. Configure environment variables\n\nCopy the values from your GitHub App into \\`.env.local\\`:\n\n\\`\\`\\`bash\n# GitHub App credentials (required for CMS auth)\nGITHUB_ID=your_github_app_client_id\nGITHUB_SECRET=your_github_app_client_secret\n\n# NextAuth (generate secret: openssl rand -base64 32)\nNEXTAUTH_SECRET=your_nextauth_secret\nNEXTAUTH_URL=http://localhost:3000\n\n# GitHub repo for content storage (required in production)\nGITHUB_REPO_OWNER=your_github_username_or_org\nGITHUB_REPO_NAME=your_repo_name\n\n# Optional: static GitHub token for private repos / higher API rate limits\n# CMS_GITHUB_TOKEN=your_github_pat\n\\`\\`\\`\n\n### 4. Run the dev server\n\n\\`\\`\\`bash\nnpm run dev\n\\`\\`\\`\n\nOpen [http://localhost:3000/cms](http://localhost:3000/cms) to access the CMS admin.\n`;\n}\n\nexport function envLocalTemplate(): string {\n return `# GitHub App credentials (required for CMS auth)\n# Create a GitHub App at: https://github.com/settings/apps/new\nGITHUB_ID=\nGITHUB_SECRET=\n\n# NextAuth secret — generate with: openssl rand -base64 32\nNEXTAUTH_SECRET=\nNEXTAUTH_URL=http://localhost:3000\n\n# GitHub repo for content storage (required in production)\nGITHUB_REPO_OWNER=\nGITHUB_REPO_NAME=\n\n# Optional: static GitHub token for private repos or higher API rate limits\n# CMS_GITHUB_TOKEN=\n`;\n}\n\nconst AGENT_DOCS_MARKER = '<!-- octocms:agent-docs -->';\n\nexport function agentsMdSection(): string {\n return `${AGENT_DOCS_MARKER}\n## OctoCMS — AI Content Management\n\nFor tasks that involve creating, editing, or deleting CMS content directly (without the admin UI), read the auto-generated agent docs:\n\n- **\\`octocms/docs/overview.md\\`** — How to find, create, update, and delete content entries via file operations\n- **\\`octocms/docs/schema.md\\`** — Per-collection field definitions, example JSON, and file path conventions\n\nThese docs are generated from \\`cms/octocms.config.ts\\`. Regenerate after schema changes: \\`npm run agent-docs:gen\\`.`;\n}\n\nexport function agentsMdTemplate(): string {\n return `# Project Guidelines\n\n${agentsMdSection()}\n`;\n}\n\nexport function tsconfigPaths(): Record<string, string[]> {\n return {\n 'cms/__generated__': ['./cms/__generated__/index.ts'],\n 'cms/__generated__/*': ['./cms/__generated__/*'],\n '@/*': ['./src/*'],\n };\n}\n"],"mappings":";AAIA,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAShB,IAAM,yBACX,iBACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBK,IAAM,yBACX,iBACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BK,IAAM,gCACX,iBACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeK,IAAM,yBACX,iBACA;AAAA;AAAA;AAAA;AAMK,IAAM,yBACX,iBACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUK,IAAM,8BACX,iBACA;AAAA;AAAA;AAAA;AAAA;AAmBF,IAAM,qBAAqB;AAOpB,IAAM,qBAAqB,GAAG,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBhD,IAAM,6BAA6B,GAAG,kBAAkB;AAAA;AAExD,SAAS,2BAAmC;AACjD,SAAO,GAAG,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAM9B;AAQO,SAAS,yBAAiC;AAC/C,SAAO;AAAA,EACP,kBAAkB;AAAA;AAAA;AAAA;AAIpB;AAQO,IAAM,qBAAqB;AAAA;AAAA;AAAA;AAY3B,IAAM,gCAAuD;AAAA;AAAA,EAElE;AAAA;AAAA;AAAA;AAA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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDzB;AAEO,SAAS,mBAA2B;AACzC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBT;AAEA,IAAM,oBAAoB;AAEnB,SAAS,kBAA0B;AACxC,SAAO,GAAG,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS7B;AAEO,SAAS,mBAA2B;AACzC,SAAO;AAAA;AAAA,EAEP,gBAAgB,CAAC;AAAA;AAEnB;AAEO,SAAS,gBAA0C;AACxD,SAAO;AAAA,IACL,qBAAqB,CAAC,8BAA8B;AAAA,IACpD,uBAAuB,CAAC,uBAAuB;AAAA,IAC/C,OAAO,CAAC,SAAS;AAAA,EACnB;AACF;","names":[]}
|
package/dist/chunk-YQQT73XR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/commands/init.ts"],"sourcesContent":["/**\n * `octocms init` — Initialize OctoCMS in a Next.js project.\n *\n * Writes the full CMS config inline into `next.config.ts`, creates admin\n * route files, demo content, and updates `tsconfig.json` with required\n * path aliases.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport readline from 'readline';\n\nimport { version as CLI_VERSION } from '../../package.json';\nimport { fmt, log } from '../lib/logger';\n\nimport {\n adminErrorTemplate,\n buildAdminLayoutTemplate,\n buildAdminPageTemplate,\n agentChatRouteTemplate,\n mediaRouteTemplate,\n demoHelloPageJson,\n envLocalTemplate,\n generatedConfigInitTemplate,\n generatedContentDeclsTemplate,\n generatedEnumsTemplate,\n generatedIndexTemplate,\n generatedQueryTemplate,\n generatedTypesTemplate,\n helloPageTemplate,\n nextAuthRouteTemplate,\n nextConfigTemplate,\n octoConfigTemplate,\n readmeTemplate,\n rootLayoutConfigInitImport,\n rootLayoutTemplate,\n tsconfigPaths,\n} from '../lib/templates';\n\n/**\n * Required (non-optional) peer dependencies of `octocms`, excluding\n * `next` / `react` / `react-dom` which any Next.js project already has.\n *\n * Keep in sync with `octocms/package.json` `peerDependencies` minus the\n * entries flagged `optional: true` in `peerDependenciesMeta`. The\n * `init.test.ts` `keeps REQUIRED_PEER_DEPS in sync` test enforces this.\n */\nconst REQUIRED_PEER_DEPS: readonly string[] = [\n '@mdxeditor/editor',\n '@radix-ui/react-avatar',\n '@radix-ui/react-dialog',\n '@radix-ui/react-dropdown-menu',\n '@radix-ui/react-label',\n '@radix-ui/react-select',\n '@radix-ui/react-slot',\n '@radix-ui/react-tabs',\n '@radix-ui/react-toast',\n '@tanstack/react-query',\n 'class-variance-authority',\n 'clsx',\n 'glob',\n 'lucide-react',\n 'minisearch',\n 'next-auth',\n 'octokit',\n 'react-markdown',\n 'rehype-sanitize',\n 'remark-gfm',\n 'remark-mdx',\n 'sharp',\n 'slugify',\n 'sonner',\n 'tailwind-merge',\n 'zod',\n];\n\nexport type InitOptions = {\n /** Accept all defaults without prompting. */\n yes?: boolean;\n};\n\ntype InitAnswers = {\n projectName: string;\n baseBranch: string;\n usePointerBranch: boolean;\n pointerBranch: string;\n};\n\nasync function prompt(rl: readline.Interface, question: string, defaultValue?: string): Promise<string> {\n const suffix = defaultValue ? ` (${defaultValue})` : '';\n return new Promise((resolve) => {\n rl.question(` ? ${question}${suffix}: `, (answer) => {\n resolve(answer.trim() || defaultValue || '');\n });\n });\n}\n\nasync function confirm(rl: readline.Interface, question: string, defaultYes = false): Promise<boolean> {\n const hint = defaultYes ? 'Y/n' : 'y/N';\n const answer = await prompt(rl, `${question} (${hint})`);\n if (!answer) return defaultYes;\n return answer.toLowerCase().startsWith('y');\n}\n\nasync function gatherAnswers(options: InitOptions): Promise<InitAnswers> {\n if (options.yes) {\n return {\n projectName: 'My CMS',\n baseBranch: 'main',\n usePointerBranch: false,\n pointerBranch: '',\n };\n }\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n try {\n const projectName = await prompt(rl, 'Project name', 'My CMS');\n const baseBranch = await prompt(rl, 'Git base branch', 'main');\n const usePointerBranch = await confirm(rl, 'Use a separate published pointer branch?');\n let pointerBranch = '';\n if (usePointerBranch) {\n pointerBranch = await prompt(rl, 'Pointer branch name', 'cms/publish-pointer');\n }\n\n return { projectName, baseBranch, usePointerBranch, pointerBranch };\n } finally {\n rl.close();\n }\n}\n\n/** Detect the dev port from the project's package.json dev script. Defaults to 3000. */\nfunction detectDevPort(projectRoot: string): number {\n try {\n const pkg = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8')) as {\n scripts?: Record<string, string>;\n };\n const devScript = pkg.scripts?.dev ?? '';\n const match = /(?:-p|--port)[= ](\\d+)/.exec(devScript);\n if (match) return parseInt(match[1], 10);\n } catch {\n // ignore\n }\n return 3000;\n}\n\nexport async function initCommand(projectRoot: string, options: InitOptions = {}): Promise<void> {\n log.header('Initialize a new project');\n\n // Already initialized if cms/octocms.config.ts already contains defineConfig\n const octoConfigPath = join(projectRoot, 'cms', 'octocms.config.ts');\n if (existsSync(octoConfigPath) && readFileSync(octoConfigPath, 'utf8').includes('defineConfig')) {\n log.error('cms/octocms.config.ts already contains defineConfig — this project is already initialized.');\n log.info('Use `octocms update` to regenerate admin route files.');\n process.exitCode = 1;\n return;\n }\n const nextConfigPath = join(projectRoot, 'next.config.ts');\n\n if (!existsSync(join(projectRoot, 'package.json'))) {\n log.error('No package.json found — run this inside a Next.js project.');\n process.exitCode = 1;\n return;\n }\n\n const answers = await gatherAnswers(options);\n\n log.blank();\n log.info('Creating files...');\n\n // Admin route files — three thin re-exports. The package owns dispatch +\n // per-component Suspense + skeletons via the `octocms/admin` barrel.\n const cmsRouteDir = join(projectRoot, 'app', 'cms');\n mkdirSync(join(cmsRouteDir, '[[...path]]'), { recursive: true });\n\n writeFileSync(join(cmsRouteDir, 'layout.tsx'), buildAdminLayoutTemplate(), 'utf8');\n log.success('app/cms/layout.tsx');\n\n writeFileSync(join(cmsRouteDir, '[[...path]]', 'page.tsx'), buildAdminPageTemplate(), 'utf8');\n log.success('app/cms/[[...path]]/page.tsx');\n\n writeFileSync(join(cmsRouteDir, 'error.tsx'), adminErrorTemplate, 'utf8');\n log.success('app/cms/error.tsx');\n\n // Root layout — ensure configInit is imported so public page serverless functions\n // initialize the OctoCMS config on cold start (not just admin routes).\n const rootLayoutPath = join(projectRoot, 'app', 'layout.tsx');\n if (!existsSync(rootLayoutPath)) {\n writeFileSync(rootLayoutPath, rootLayoutTemplate, 'utf8');\n log.success('app/layout.tsx — created with configInit import');\n } else {\n const existing = readFileSync(rootLayoutPath, 'utf8');\n if (!existing.includes('configInit')) {\n writeFileSync(rootLayoutPath, rootLayoutConfigInitImport + existing, 'utf8');\n log.success('app/layout.tsx — added configInit import');\n } else {\n log.success('app/layout.tsx — configInit import already present');\n }\n }\n\n // NextAuth API route\n const authRouteDir = join(projectRoot, 'app', 'api', 'auth', '[...nextauth]');\n mkdirSync(authRouteDir, { recursive: true });\n writeFileSync(join(authRouteDir, 'route.ts'), nextAuthRouteTemplate, 'utf8');\n log.success('app/api/auth/[...nextauth]/route.ts');\n\n // Chat-agent routes — thin re-exports of handlers in `octocms/agent`.\n // The handlers are opt-in (the agent feature is gated by config + provider\n // key at runtime); shipping the routes by default costs nothing when the\n // agent is disabled — every endpoint 404s in that case.\n const chatRouteDir = join(projectRoot, 'app', 'api', 'agent');\n mkdirSync(chatRouteDir, { recursive: true });\n writeFileSync(join(chatRouteDir, 'route.ts'), agentChatRouteTemplate(), 'utf8');\n log.success('app/api/agent/route.ts');\n\n // Note: chat-agent proposal accept/reject are server actions\n // (`acceptProposalAction` / `rejectProposalAction` in\n // `octocms/admin/actions/agent.ts`), called directly from `useChatStream` —\n // no public endpoint files are scaffolded.\n\n // Media proxy route — thin re-export of `mediaRoute` from `octocms/admin/mediaRoute`.\n // Vercel's filesystem is immutable after build, so images committed from the\n // CMS UI never land in `public/media/` on the running instance — routing\n // them through a Route Handler lets the GitHub-API path serve them.\n const mediaRouteDir = join(projectRoot, 'app', 'media', '[...slug]');\n mkdirSync(mediaRouteDir, { recursive: true });\n writeFileSync(join(mediaRouteDir, 'route.ts'), mediaRouteTemplate(), 'utf8');\n log.success('app/media/[...slug]/route.ts');\n\n // Hello page demo route\n mkdirSync(join(projectRoot, 'app', 'hello'), { recursive: true });\n writeFileSync(join(projectRoot, 'app', 'hello', 'page.tsx'), helloPageTemplate, 'utf8');\n log.success('app/hello/page.tsx');\n\n // Demo content\n const contentDir = join(projectRoot, 'cms', 'content', 'helloPage');\n mkdirSync(contentDir, { recursive: true });\n writeFileSync(join(contentDir, 'helloPage-0000.json'), demoHelloPageJson(), 'utf8');\n log.success('cms/content/helloPage/helloPage-0000.json');\n\n // cms/__generated__/ — write static starter files (schema-accurate for helloPage demo)\n // These are valid immediately; re-run `npx octocms types:gen` after editing the schema.\n const generatedDir = join(projectRoot, 'cms', '__generated__');\n mkdirSync(generatedDir, { recursive: true });\n const generatedFiles: [string, string][] = [\n ['types.ts', generatedTypesTemplate],\n ['enums.ts', generatedEnumsTemplate],\n ['content.d.ts', generatedContentDeclsTemplate],\n ['index.ts', generatedIndexTemplate],\n ['query.ts', generatedQueryTemplate],\n ['configInit.ts', generatedConfigInitTemplate],\n ];\n for (const [name, content] of generatedFiles) {\n writeFileSync(join(generatedDir, name), content, 'utf8');\n log.success(`cms/__generated__/${name}`);\n }\n\n // Media directory\n mkdirSync(join(projectRoot, 'public', 'media'), { recursive: true });\n\n // cms/octocms.config.ts — write the OctoCMS schema\n log.blank();\n log.info('Updating configuration...');\n mkdirSync(join(projectRoot, 'cms'), { recursive: true });\n writeFileSync(\n octoConfigPath,\n octoConfigTemplate({\n projectName: answers.projectName,\n baseBranch: answers.baseBranch,\n pointerBranch: answers.usePointerBranch ? answers.pointerBranch : undefined,\n }),\n 'utf8',\n );\n log.success('cms/octocms.config.ts — OctoCMS schema');\n\n // next.config.ts — write the thin Next.js wrapper\n writeFileSync(nextConfigPath, nextConfigTemplate(), 'utf8');\n log.success('next.config.ts — Next.js wrapper');\n\n // tsconfig.json\n const tsconfigPath = join(projectRoot, 'tsconfig.json');\n if (existsSync(tsconfigPath)) {\n try {\n const raw = readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(raw);\n if (!tsconfig.compilerOptions) tsconfig.compilerOptions = {};\n if (!tsconfig.compilerOptions.paths) tsconfig.compilerOptions.paths = {};\n const requiredPaths = tsconfigPaths();\n let changed = false;\n for (const [alias, targets] of Object.entries(requiredPaths)) {\n if (!tsconfig.compilerOptions.paths[alias]) {\n tsconfig.compilerOptions.paths[alias] = targets;\n changed = true;\n }\n }\n if (changed) {\n writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + '\\n', 'utf8');\n log.success('tsconfig.json — added path aliases');\n } else {\n log.success('tsconfig.json — path aliases already present');\n }\n } catch {\n log.warn('tsconfig.json — could not parse; add path aliases manually');\n }\n } else {\n log.warn('tsconfig.json not found — create one with the required path aliases');\n }\n\n // .env.local — write stub only if it doesn't already exist\n const envLocalPath = join(projectRoot, '.env.local');\n if (!existsSync(envLocalPath)) {\n writeFileSync(envLocalPath, envLocalTemplate(), 'utf8');\n log.success('.env.local — environment variable stubs');\n } else {\n log.success('.env.local — already exists, skipped');\n }\n\n // README.md — write only if it doesn't already exist\n const readmePath = join(projectRoot, 'README.md');\n if (!existsSync(readmePath)) {\n writeFileSync(readmePath, readmeTemplate(answers.projectName), 'utf8');\n log.success('README.md — setup guide');\n } else {\n log.success('README.md — already exists, skipped');\n }\n\n const port = detectDevPort(projectRoot);\n log.blank();\n log.info('Next steps:');\n log.info(' 1. Install dependencies:');\n log.info(` ${fmt.cyan(`npm install octocms@${CLI_VERSION} ${REQUIRED_PEER_DEPS.join(' ')}`)}`);\n log.info(' 2. Fill in GitHub App credentials in .env.local (see README.md)');\n log.info(' 3. Run: npm run dev');\n log.info(` 4. Visit demo page: http://localhost:${port}/hello`);\n log.info(` 5. Visit CMS admin: http://localhost:${port}/cms`);\n log.info('');\n log.info(' After editing cms/octocms.config.ts, regenerate types:');\n log.info(' npx octocms types:gen');\n log.blank();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,YAAY;AACrB,OAAO,cAAc;AAqCrB,IAAM,qBAAwC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAcA,eAAe,OAAO,IAAwB,UAAkB,cAAwC;AACtG,QAAM,SAAS,eAAe,KAAK,YAAY,MAAM;AACrD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,OAAG,SAAS,OAAO,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW;AACpD,cAAQ,OAAO,KAAK,KAAK,gBAAgB,EAAE;AAAA,IAC7C,CAAC;AAAA,EACH,CAAC;AACH;AAEA,eAAe,QAAQ,IAAwB,UAAkB,aAAa,OAAyB;AACrG,QAAM,OAAO,aAAa,QAAQ;AAClC,QAAM,SAAS,MAAM,OAAO,IAAI,GAAG,QAAQ,KAAK,IAAI,GAAG;AACvD,MAAI,CAAC,OAAQ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