@xleddyl/nuxt-cms 0.8.0 → 0.8.2
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { extname, resolve, isAbsolute, join, relative, dirname } from 'node:path';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { defineNuxtModule, createResolver, useLogger, addImports, addTemplate, addServerPlugin, addTypeTemplate, addComponentsDir, addRouteMiddleware, extendPages, addServerHandler, resolvePath, addComponent } from '@nuxt/kit';
|
|
5
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
6
|
+
import { defineNuxtModule, createResolver, useLogger, addImports, addTemplate, addServerPlugin, addTypeTemplate, addComponentsDir, tryResolveModule, addRouteMiddleware, extendPages, addServerHandler, resolvePath, addComponent } from '@nuxt/kit';
|
|
7
7
|
import { introspectionFromSchema, buildSchema } from 'graphql';
|
|
8
8
|
import { minifyIntrospection, outputIntrospectionFile } from 'gql.tada/internal';
|
|
9
9
|
import { createJiti } from 'jiti';
|
|
10
10
|
import { typeName, blockTypeName as blockTypeName$1, blocksFieldTypeName, renderGraphqlSdl } from '../dist/runtime/shared/graphql-sdl.js';
|
|
11
11
|
import { migrationsDirFor } from '../dist/runtime/shared/migrations-dir.js';
|
|
12
|
-
import { entryFieldsFor, isPrivateField, blockTypeName, pageColumnFields, isTranslatableField, isTranslatableMediaField, isStringListField, pageAllFields, normalizeContentEntries, PAGE_PATH_FIELD, pageRoutes, isCollectionKind, isMultiSelect, layoutErrors, listErrors, mobileMediaKey, fieldConditions, selectOptionValues,
|
|
12
|
+
import { entryFieldsFor, isPrivateField, blockTypeName, pageColumnFields, isTranslatableField, isTranslatableMediaField, isStringListField, pageAllFields, normalizeContentEntries, PAGE_PATH_FIELD, pageRoutes, isCollectionKind, isMultiSelect, layoutErrors, listErrors, mobileMediaKey, fieldConditions, selectOptionValues, pageFieldsTableName, pageMediaTableName, CONTENT_SYSTEM_FIELDS, isRequiredField, pageFields, mediaTypeFilter, DEFAULT_MEDIA_MAX_FILE_SIZE, normalizeCmsConfig } from '../dist/runtime/shared/index.js';
|
|
13
13
|
import { previewPathErrors, DEFAULT_CMS_PREVIEW_PATH } from '../dist/runtime/shared/preview.js';
|
|
14
14
|
import { scanMediaDirectory, readMediaFileMeta } from '../dist/runtime/server/utils/media-sync.js';
|
|
15
15
|
import { createHash } from 'node:crypto';
|
|
@@ -482,8 +482,6 @@ function validateConfig(config, i18n) {
|
|
|
482
482
|
if (!source) errors.push(`${fat}: slug source '${field.from}' is not a declared field`);
|
|
483
483
|
else if (source.type !== "text")
|
|
484
484
|
errors.push(`${fat}: slug source '${field.from}' must be a text field`);
|
|
485
|
-
else if (isTranslatableField(source) && !(entry.kind === "content" && key === CONTENT_SLUG_FIELD))
|
|
486
|
-
errors.push(`${fat}: slug source '${field.from}' cannot be translatable`);
|
|
487
485
|
}
|
|
488
486
|
if (field.type === "tags") {
|
|
489
487
|
errors.push(...tagsOptionErrors(fat, field));
|
|
@@ -761,9 +759,8 @@ function columnExpr(key, field, dialect, table) {
|
|
|
761
759
|
expr = `text('${col}').unique()`;
|
|
762
760
|
break;
|
|
763
761
|
case "relation": {
|
|
764
|
-
const onDelete =
|
|
765
|
-
|
|
766
|
-
expr = `text('${col}').references(${target} => ${field.to}.id, { onDelete: '${onDelete}' })`;
|
|
762
|
+
const onDelete = relationOnDelete(field);
|
|
763
|
+
expr = field.to === table ? `text('${col}')` : `text('${col}').references(() => ${field.to}.id, { onDelete: '${onDelete}' })`;
|
|
767
764
|
if (field.cardinality === "one-to-one") expr += ".unique()";
|
|
768
765
|
break;
|
|
769
766
|
}
|
|
@@ -773,8 +770,8 @@ function columnExpr(key, field, dialect, table) {
|
|
|
773
770
|
if (isRequiredField(field)) expr += ".notNull()";
|
|
774
771
|
return ` ${key}: ${expr},`;
|
|
775
772
|
}
|
|
776
|
-
function
|
|
777
|
-
return
|
|
773
|
+
function relationOnDelete(field) {
|
|
774
|
+
return field.onDelete ?? (field.required ? "restrict" : "set null");
|
|
778
775
|
}
|
|
779
776
|
function isSelfRelation(table, field) {
|
|
780
777
|
return field.type === "relation" && !isManyToMany(field) && field.to === table;
|
|
@@ -792,6 +789,7 @@ function tableExpr(name, entry, dialect) {
|
|
|
792
789
|
const pg = dialect === "postgres";
|
|
793
790
|
const tableFn = pg ? "pgTable" : "sqliteTable";
|
|
794
791
|
const lines = [];
|
|
792
|
+
const selfReferences = [];
|
|
795
793
|
lines.push(` id: text('id').primaryKey(),`);
|
|
796
794
|
if (entry.kind === "page") lines.push(` path: text('path').notNull().unique(),`);
|
|
797
795
|
for (const [key, field] of Object.entries(
|
|
@@ -799,13 +797,22 @@ function tableExpr(name, entry, dialect) {
|
|
|
799
797
|
)) {
|
|
800
798
|
if (isManyToMany(field)) continue;
|
|
801
799
|
lines.push(columnExpr(key, field, dialect, name));
|
|
800
|
+
if (isSelfRelation(name, field))
|
|
801
|
+
selfReferences.push(
|
|
802
|
+
`foreignKey({ columns: [table.${key}], foreignColumns: [table.id] }).onDelete('${relationOnDelete(
|
|
803
|
+
field
|
|
804
|
+
)}')`
|
|
805
|
+
);
|
|
802
806
|
}
|
|
803
807
|
if (entry.drafts) lines.push(` status: text('status').notNull().default('draft'),`);
|
|
804
808
|
if (isCollectionKind(entry)) lines.push(` createdAt: ${nowExpr(pg, "created_at")},`);
|
|
805
809
|
lines.push(` updatedAt: ${nowExpr(pg, "updated_at")},`);
|
|
810
|
+
const extra = selfReferences.length ? `, table => [
|
|
811
|
+
${selfReferences.join(",\n ")},
|
|
812
|
+
]` : "";
|
|
806
813
|
return `export const ${name} = ${tableFn}('${name}', {
|
|
807
814
|
${lines.join("\n")}
|
|
808
|
-
})`;
|
|
815
|
+
}${extra})`;
|
|
809
816
|
}
|
|
810
817
|
function joinTableExpr(name, key, field, dialect) {
|
|
811
818
|
const pg = dialect === "postgres";
|
|
@@ -888,18 +895,14 @@ function renderSchemaFile(config, dialect, resolveImport = (s) => s) {
|
|
|
888
895
|
core.add("jsonb");
|
|
889
896
|
if (pg) core.add("timestamp");
|
|
890
897
|
if (fields.some(isManyToMany) || rowsEntries.length) core.add("primaryKey");
|
|
891
|
-
|
|
898
|
+
if (derived.some(
|
|
892
899
|
([name, entry]) => Object.values(entry.kind === "page" ? pageColumnFields(entry) : entry.fields).some(
|
|
893
900
|
(field) => isSelfRelation(name, field)
|
|
894
901
|
)
|
|
895
|
-
)
|
|
902
|
+
))
|
|
903
|
+
core.add("foreignKey");
|
|
896
904
|
const imports = [
|
|
897
905
|
...pg ? [] : [`import { sql } from '${resolveImport("drizzle-orm")}'`],
|
|
898
|
-
...hasSelfRelation ? [
|
|
899
|
-
`import type { ${anyColumnType(dialect)} } from '${resolveImport(
|
|
900
|
-
`drizzle-orm/${pg ? "pg-core" : "sqlite-core"}`
|
|
901
|
-
)}'`
|
|
902
|
-
] : [],
|
|
903
906
|
`import { ${[...core].sort().join(", ")} } from '${resolveImport(
|
|
904
907
|
`drizzle-orm/${pg ? "pg-core" : "sqlite-core"}`
|
|
905
908
|
)}'`
|
|
@@ -1548,6 +1551,9 @@ const module$1 = defineNuxtModule({
|
|
|
1548
1551
|
"nuxt-auth-utils": {},
|
|
1549
1552
|
"@xleddyl/443-components-vue/nuxt": {
|
|
1550
1553
|
defaults: {
|
|
1554
|
+
composables: false,
|
|
1555
|
+
css: false,
|
|
1556
|
+
fonts: false,
|
|
1551
1557
|
editor: true,
|
|
1552
1558
|
icons: {
|
|
1553
1559
|
collections: [
|
|
@@ -1918,11 +1924,6 @@ const module$1 = defineNuxtModule({
|
|
|
1918
1924
|
getContents: () => renderBrandFile(resolveBrand(resolved.admin, brandPaths).brand)
|
|
1919
1925
|
});
|
|
1920
1926
|
nuxt.options.alias["#cms-brand"] = brandTemplate.dst;
|
|
1921
|
-
nuxt.options.css.push(
|
|
1922
|
-
resolveImport("@fontsource-variable/geist/index.css"),
|
|
1923
|
-
resolveImport("@fontsource-variable/geist-mono/index.css"),
|
|
1924
|
-
resolver.resolve("./runtime/assets/cms.css")
|
|
1925
|
-
);
|
|
1926
1927
|
nuxt.hook("app:templates", (app) => {
|
|
1927
1928
|
app.layouts["cms-admin"] = {
|
|
1928
1929
|
name: "cms-admin",
|
|
@@ -1934,6 +1935,23 @@ const module$1 = defineNuxtModule({
|
|
|
1934
1935
|
};
|
|
1935
1936
|
});
|
|
1936
1937
|
addComponentsDir({ path: resolver.resolve("./runtime/app/components") });
|
|
1938
|
+
nuxt.hook("app:resolve", (app) => {
|
|
1939
|
+
app.plugins = app.plugins.filter(
|
|
1940
|
+
(plugin) => !/[\\/]443-components-vue[\\/]dist[\\/]nuxt[\\/]runtime[\\/](theme|locale)(\.mjs)?$/.test(
|
|
1941
|
+
plugin.src
|
|
1942
|
+
)
|
|
1943
|
+
);
|
|
1944
|
+
});
|
|
1945
|
+
nuxt.hook("modules:done", async () => {
|
|
1946
|
+
const include = nuxt.options.vite.optimizeDeps?.include;
|
|
1947
|
+
if (!include) return;
|
|
1948
|
+
const rootUrl = pathToFileURL(`${nuxt.options.rootDir}/`).href;
|
|
1949
|
+
nuxt.options.vite.optimizeDeps.include = await Promise.all(
|
|
1950
|
+
include.map(
|
|
1951
|
+
async (entry) => entry.startsWith("@tiptap/") && !await tryResolveModule(entry, rootUrl) ? `@xleddyl/nuxt-cms > ${entry}` : entry
|
|
1952
|
+
)
|
|
1953
|
+
);
|
|
1954
|
+
});
|
|
1937
1955
|
addRouteMiddleware({
|
|
1938
1956
|
name: "cms-auth",
|
|
1939
1957
|
path: resolver.resolve("./runtime/app/middleware/cms-auth")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer theme, base, k, components, utilities;@import "@xleddyl/443-components-vue/style.css";@import "@xleddyl/443-components-vue/editor/style.css";@import "@fontsource-variable/geist/index.css";@import "@fontsource-variable/geist-mono/index.css";@import "./cms.css";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xleddyl/nuxt-cms",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Lightweight CMS that ships with your Nuxt app: runs on the Nitro server, content types defined in code, /cms admin panel, GraphQL API, SQLite or Postgres. No external CMS needed!",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Edoardo Alberti (https://github.com/xleddyl)",
|