From 84991077d5c53414d9972d87d462d282d076d5b2 Mon Sep 17 00:00:00 2001 From: Ben Merckx Date: Fri, 2 Feb 2024 10:56:08 +0100 Subject: [PATCH] Move createCMS to alinea/core and update init command and docs --- apps/demo/src/cms.tsx | 4 +- apps/dev/cms.tsx | 4 +- .../web/content/pages/docs/configuration.json | 12 +--- apps/web/content/pages/docs/deploy.json | 5 +- src/cli/Init.ts | 2 +- src/cli/static/init/cms.js | 63 ++++++++++--------- src/core.ts | 1 + src/index.ts | 6 +- 8 files changed, 47 insertions(+), 50 deletions(-) diff --git a/apps/demo/src/cms.tsx b/apps/demo/src/cms.tsx index b18103e26..85d62f135 100644 --- a/apps/demo/src/cms.tsx +++ b/apps/demo/src/cms.tsx @@ -1,4 +1,4 @@ -import {createNextCMS} from 'alinea/next' +import {createCMS} from 'alinea/next' import {config} from '../alinea.config' -export const cms = createNextCMS(config) +export const cms = createCMS(config) diff --git a/apps/dev/cms.tsx b/apps/dev/cms.tsx index 9b01a00b8..6bddfe2a4 100644 --- a/apps/dev/cms.tsx +++ b/apps/dev/cms.tsx @@ -1,5 +1,5 @@ -import alinea, {createCMS} from 'alinea' -import {Entry} from 'alinea/core' +import alinea from 'alinea' +import {Entry, createCMS} from 'alinea/core' import {IcRoundTranslate} from 'alinea/ui/icons/IcRoundTranslate' import {IcRoundUploadFile} from 'alinea/ui/icons/IcRoundUploadFile' import {position} from './src/PositionField' diff --git a/apps/web/content/pages/docs/configuration.json b/apps/web/content/pages/docs/configuration.json index 2fd3dbcb0..dc479be36 100644 --- a/apps/web/content/pages/docs/configuration.json +++ b/apps/web/content/pages/docs/configuration.json @@ -15,21 +15,11 @@ { "id": "2a4tC7lBmNMZUuJDec7zsG4st62", "type": "CodeBlock", - "code": "import {createNextCMS} from 'alinea'\n\nexport const cms = createNextCMS({\n workspaces, schema, dashboard, preview\n})", + "code": "import {createCMS} from 'alinea/next'\n\nexport const cms = createCMS({\n workspaces, schema, dashboard, preview\n})", "fileName": "cms.tsx", "language": "", "compact": false }, - { - "type": "paragraph", - "textAlign": "left", - "content": [ - { - "type": "text", - "text": "The `alinea` package exports a general purpose `createCMS` function as well as framework specific functions such as `createNextCMS`. The framework specific instances expose helper methods to help integrate the content into your framework of choice." - } - ] - }, { "type": "heading", "textAlign": "left", diff --git a/apps/web/content/pages/docs/deploy.json b/apps/web/content/pages/docs/deploy.json index 2faf3487f..9ee717c0d 100644 --- a/apps/web/content/pages/docs/deploy.json +++ b/apps/web/content/pages/docs/deploy.json @@ -1,5 +1,6 @@ { "title": "Deploy", + "navigationTitle": "", "body": [ { "type": "paragraph", @@ -66,7 +67,7 @@ { "id": "2YlDwmJLzaL93bp5gYZmshbJG1P", "type": "CodeBlock", - "code": "export const cms = createNextCMS({\n // schema and workspaces ...\n dashboard: {\n handlerUrl: '/api/cms',\n staticFile: 'public/admin.html',\n dashboardUrl: '/admin.html'\n }\n})", + "code": "export const cms = createCMS({\n // schema and workspaces ...\n dashboard: {\n handlerUrl: '/api/cms',\n staticFile: 'public/admin.html',\n dashboardUrl: '/admin.html'\n }\n})", "fileName": "", "language": "", "compact": false @@ -99,4 +100,4 @@ "type": "Docs", "index": "Zp" } -} +} \ No newline at end of file diff --git a/src/cli/Init.ts b/src/cli/Init.ts index 1d3a861f3..700f6c301 100644 --- a/src/cli/Init.ts +++ b/src/cli/Init.ts @@ -66,7 +66,7 @@ export async function init(options: InitOptions) { 'utf-8' ) const configFileContents = options.next - ? configFile.replaceAll('createCMS', 'createNextCMS') + ? configFile.replaceAll('alinea/core', 'alinea/next') : configFile const hasSrcDir = (await outcome(fs.stat(path.join(cwd, 'src')))).isSuccess() const configFileLocation = path.join( diff --git a/src/cli/static/init/cms.js b/src/cli/static/init/cms.js index 912035309..6552b1efd 100644 --- a/src/cli/static/init/cms.js +++ b/src/cli/static/init/cms.js @@ -1,31 +1,32 @@ -import alinea, {createCMS} from 'alinea' - -const Page = alinea.type('Page', { - title: alinea.text('Title'), - path: alinea.path('Path') -}) - -export const cms = createCMS({ - schema: { - Page - }, - workspaces: { - main: alinea.workspace('Example', { - pages: alinea.root('Example project', { - welcome: alinea.page( - Page({ - title: 'Welcome' - }) - ), - [alinea.meta]: { - contains: ['Page'] - } - }), - media: alinea.media(), - [alinea.meta]: { - source: 'content', - mediaDir: 'public' - } - }) - } -}) +import alinea from 'alinea' +import {createCMS} from 'alinea/core' + +const Page = alinea.type('Page', { + title: alinea.text('Title'), + path: alinea.path('Path') +}) + +export const cms = createCMS({ + schema: { + Page + }, + workspaces: { + main: alinea.workspace('Example', { + pages: alinea.root('Example project', { + welcome: alinea.page( + Page({ + title: 'Welcome' + }) + ), + [alinea.meta]: { + contains: ['Page'] + } + }), + media: alinea.media(), + [alinea.meta]: { + source: 'content', + mediaDir: 'public' + } + }) + } +}) diff --git a/src/core.ts b/src/core.ts index d22913e83..8e081acff 100644 --- a/src/core.ts +++ b/src/core.ts @@ -31,6 +31,7 @@ export * from './core/Type.js' export * from './core/User.js' export * from './core/View.js' export * from './core/Workspace.js' +export {createCMS} from './core/driver/DefaultDriver.js' export * from './core/field/ListField.js' export * from './core/field/RecordField.js' export * from './core/field/RichTextField.js' diff --git a/src/index.ts b/src/index.ts index 116fe9e0d..ee99f3519 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,4 +9,8 @@ export {createNextCMS} /** @deprecated Use import {createCMS} from 'alinea/next' instead */ const createNextCMS = _createNextCMS -export * from 'alinea/core/driver/DefaultDriver' +// Default CMS constructor - deprecated +import {createCMS as _createCMS} from 'alinea/core/driver/DefaultDriver' +export {createCMS} +/** @deprecated Use import {createCMS} from 'alinea/core' instead */ +const createCMS = _createCMS