rimecms 0.27.6 → 0.28.1
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/adapter-sqlite/{area.js → area.server.js} +2 -2
- package/dist/adapter-sqlite/{blocks.d.ts → blocks.server.d.ts} +1 -1
- package/dist/adapter-sqlite/{blocks.js → blocks.server.js} +1 -1
- package/dist/adapter-sqlite/{collection.js → collection.server.js} +17 -8
- package/dist/adapter-sqlite/generate-schema/write.server.js +2 -2
- package/dist/adapter-sqlite/index.server.d.ts +8 -8
- package/dist/adapter-sqlite/index.server.js +7 -7
- package/dist/adapter-sqlite/{orderBy.js → orderBy.server.js} +1 -1
- package/dist/adapter-sqlite/{relations.d.ts → relations.server.d.ts} +1 -1
- package/dist/adapter-sqlite/{relations.js → relations.server.js} +1 -1
- package/dist/adapter-sqlite/{transform.js → transform.server.js} +2 -3
- package/dist/adapter-sqlite/{tree.d.ts → tree.server.d.ts} +1 -1
- package/dist/adapter-sqlite/{tree.js → tree.server.js} +1 -1
- package/dist/adapter-sqlite/url.server.d.ts +1 -1
- package/dist/core/areas/local-api.server.d.ts +1 -1
- package/dist/core/areas/local-api.server.js +1 -0
- package/dist/core/collections/api/delete.server.js +1 -1
- package/dist/core/collections/api/get.server.js +1 -1
- package/dist/core/collections/api/getById.server.js +3 -1
- package/dist/core/collections/config/augment-panel.d.ts +13 -0
- package/dist/core/collections/config/augment-panel.js +19 -0
- package/dist/core/collections/config/augment-upload.server.d.ts +1 -0
- package/dist/core/collections/config/augment-upload.server.js +1 -0
- package/dist/core/collections/config/builder.js +3 -1
- package/dist/core/collections/config/builder.server.js +3 -1
- package/dist/core/collections/local-api.server.js +3 -1
- package/dist/core/collections/operations/findById.js +3 -1
- package/dist/core/collections/upload/hooks/convert-base64.server.js +1 -1
- package/dist/core/config/auth/better-auth.server.d.ts +3 -3
- package/dist/core/config/auth/better-auth.server.js +1 -1
- package/dist/core/config/client/augment-panel.d.ts +4 -4
- package/dist/core/config/client/build-config.d.ts +5 -5
- package/dist/core/config/server/augment-directories.server.js +3 -3
- package/dist/core/config/server/augment-staff.server.d.ts +1 -1
- package/dist/core/config/server/augment-staff.server.js +1 -1
- package/dist/core/config/server/build-config.server.d.ts +12 -12
- package/dist/core/config/server/build-config.server.js +1 -1
- package/dist/core/config/server/{validate.js → validate.server.js} +61 -29
- package/dist/core/config/server/{write.js → write.server.js} +1 -1
- package/dist/core/config/shared/augment-icons.d.ts +1 -2
- package/dist/core/config/shared/get-staff-collection.d.ts +1 -1
- package/dist/core/config/shared/upload-directories.js +1 -1
- package/dist/core/config/types.d.ts +20 -8
- package/dist/core/dev/cli/build/templates.d.ts +1 -1
- package/dist/core/dev/cli/build/templates.js +5 -2
- package/dist/core/dev/cli/generate/{index.js → index.server.js} +13 -9
- package/dist/core/dev/cli/index.js +11 -6
- package/dist/core/dev/cli/init/{index.js → index.server.js} +68 -25
- package/dist/core/dev/cli/init/{packageManagerUtil.js → package-manager-util.server.js} +5 -5
- package/dist/core/dev/generate/routes/{area.d.ts → area.server.d.ts} +1 -1
- package/dist/core/dev/generate/routes/{area.js → area.server.js} +1 -1
- package/dist/core/dev/generate/routes/{collection.d.ts → collection.server.d.ts} +1 -1
- package/dist/core/dev/generate/routes/{collection.js → collection.server.js} +1 -1
- package/dist/core/dev/generate/routes/{common.d.ts → common.server.d.ts} +1 -1
- package/dist/core/dev/generate/routes/{common.js → common.server.js} +3 -3
- package/dist/core/dev/generate/routes/{index.js → index.server.js} +5 -5
- package/dist/core/dev/generate/routes/{util.js → util.server.js} +1 -1
- package/dist/core/dev/generate/types/{index.js → index.server.js} +1 -1
- package/dist/core/dev/vite/{index.js → index.server.js} +8 -4
- package/dist/core/fields/util.d.ts +13 -0
- package/dist/core/fields/util.js +77 -4
- package/dist/core/i18n/en/common.d.ts +1 -0
- package/dist/core/i18n/en/common.js +1 -0
- package/dist/core/i18n/fr/common.d.ts +1 -0
- package/dist/core/i18n/fr/common.js +1 -0
- package/dist/core/operations/hooks/before-read/populate-url.server.js +10 -2
- package/dist/core/operations/hooks/before-upsert/handle-new-version.server.js +2 -2
- package/dist/core/operations/relations/diff.server.d.ts +1 -1
- package/dist/core/operations/relations/extract.server.d.ts +1 -1
- package/dist/core/rime.server.d.ts +6 -6
- package/dist/core/rime.server.js +15 -14
- package/dist/fields/blocks/component/Block.svelte +13 -19
- package/dist/fields/blocks/component/Blocks.svelte +6 -13
- package/dist/fields/group/component/Group.svelte +6 -13
- package/dist/fields/number/component/number.css +2 -0
- package/dist/fields/relation/component/default/Default.svelte +1 -7
- package/dist/fields/relation/component/upload/upload.css +1 -10
- package/dist/fields/relation/index.d.ts +21 -6
- package/dist/fields/relation/index.js +41 -11
- package/dist/fields/rich-text/component/RichText.svelte +4 -4
- package/dist/fields/rich-text/component/bubble-menu/bubble-menu.svelte +6 -6
- package/dist/fields/rich-text/component/bubble-menu/bubble-menu.svelte.d.ts +2 -0
- package/dist/fields/rich-text/component/drag-handle/drag-handle.css +1 -0
- package/dist/fields/rich-text/component/styles/rich-text.css +0 -7
- package/dist/fields/rich-text/core/features/resource/resource.svelte +2 -9
- package/dist/fields/rich-text/core/features/upload/upload.svelte +5 -12
- package/dist/fields/rich-text/core/render-rich-text.svelte +5 -3
- package/dist/fields/rich-text/index.d.ts +1 -1
- package/dist/fields/select/component/Select.svelte +5 -11
- package/dist/fields/tabs/index.d.ts +1 -0
- package/dist/fields/tabs/index.js +3 -0
- package/dist/fields/textarea/component/TextArea.svelte +5 -13
- package/dist/fields/tree/component/TreeBlock.svelte +12 -18
- package/dist/fields/types.d.ts +3 -2
- package/dist/live.d.ts +2 -1
- package/dist/live.js +2 -1
- package/dist/panel/components/fields/Error.svelte +1 -7
- package/dist/panel/components/sections/collection/Empty.svelte +1 -0
- package/dist/panel/components/sections/collection/folder/Folder.svelte +7 -16
- package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte +1 -1
- package/dist/panel/components/sections/collection/grid/CollectionGrid.svelte +22 -12
- package/dist/panel/components/sections/collection/grid/create-directory-dialog/CreateDirectoryDialog.svelte +4 -5
- package/dist/panel/components/sections/collection/grid/grid-item/GridItem.svelte +41 -33
- package/dist/panel/components/sections/collection/grid/grid-item/GridItem.svelte.d.ts +4 -0
- package/dist/panel/components/sections/collection/header/ButtonCreate.svelte +14 -16
- package/dist/panel/components/sections/collection/header/ButtonCreate.svelte.d.ts +2 -0
- package/dist/panel/components/sections/collection/header/DisplayMode.svelte +10 -10
- package/dist/panel/components/sections/collection/header/SearchInput.svelte +2 -8
- package/dist/panel/components/sections/collection/list/CollectionList.svelte +32 -3
- package/dist/panel/components/sections/collection/list/header/Header.svelte +3 -9
- package/dist/panel/components/sections/collection/list/row/Row.svelte +34 -24
- package/dist/panel/components/sections/collection/list/row/Row.svelte.d.ts +9 -0
- package/dist/panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte +11 -1
- package/dist/panel/components/sections/document/ButtonStatus.svelte +3 -11
- package/dist/panel/components/sections/document/Document.svelte +22 -41
- package/dist/panel/components/sections/document/Document.svelte.d.ts +0 -1
- package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte +11 -21
- package/dist/panel/components/sections/live/LiveEdit.svelte +114 -0
- package/dist/panel/components/sections/live/LiveEdit.svelte.d.ts +32 -0
- package/dist/panel/components/sections/live/LiveEditPanel.svelte +53 -0
- package/dist/panel/components/sections/live/LiveEditPanel.svelte.d.ts +11 -0
- package/dist/panel/components/sections/live/LiveFloatingUI.svelte +106 -0
- package/dist/panel/components/sections/live/LiveFloatingUI.svelte.d.ts +12 -0
- package/dist/panel/components/sections/live/Provider.svelte +4 -4
- package/dist/panel/components/sections/live/Provider.svelte.d.ts +5 -3
- package/dist/panel/components/sections/live/live-edit-panel.css +12 -0
- package/dist/panel/components/ui/breadcrumb/BreadCrumb.svelte +2 -9
- package/dist/panel/components/ui/button/button.svelte +35 -54
- package/dist/panel/components/ui/calendar/calendar.css +11 -0
- package/dist/panel/components/ui/card-document/card-document.svelte +21 -14
- package/dist/panel/components/ui/card-resource/card-resource.svelte +8 -14
- package/dist/panel/components/ui/checkbox/checkbox.svelte +1 -1
- package/dist/panel/components/ui/command/command-group.css +1 -0
- package/dist/panel/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +1 -7
- package/dist/panel/components/ui/input/input.svelte +13 -23
- package/dist/panel/components/ui/label/label.css +0 -1
- package/dist/panel/components/ui/nav/NavItemButton.svelte +2 -8
- package/dist/panel/components/ui/page-header/PageHeader.svelte +6 -13
- package/dist/panel/components/ui/radio-group/radio-group.css +2 -0
- package/dist/panel/components/ui/scroll-area/scroll-area.css +0 -4
- package/dist/panel/components/ui/sheet/sheet.css +0 -16
- package/dist/panel/components/ui/tabs/tabs.css +7 -0
- package/dist/panel/context/collection.svelte.d.ts +0 -4
- package/dist/panel/context/collection.svelte.js +0 -3
- package/dist/panel/context/documentForm.svelte.js +1 -0
- package/dist/panel/context/live.svelte.d.ts +8 -20
- package/dist/panel/context/live.svelte.js +65 -35
- package/dist/panel/context/livePanel.svelte.d.ts +11 -0
- package/dist/panel/context/livePanel.svelte.js +8 -0
- package/dist/panel/pages/auth/forgot-password/ForgotPassword.svelte +1 -7
- package/dist/panel/pages/collection/Collection.svelte +3 -1
- package/dist/panel/pages/dashboard/Dashboard.svelte +52 -28
- package/dist/panel/pages/dashboard/DashboardCollection.svelte +91 -0
- package/dist/panel/pages/dashboard/DashboardCollection.svelte.d.ts +9 -0
- package/dist/panel/pages/dashboard/load.server.js +30 -14
- package/dist/panel/pages/dashboard/types.d.ts +1 -0
- package/dist/panel/pages/live/Live.svelte +244 -67
- package/dist/panel/pages/live/Live.svelte.d.ts +9 -1
- package/dist/panel/pages/live/load.server.js +14 -1
- package/dist/panel/style/index.css +562 -8
- package/dist/panel/style/mixins/index.css +1 -3
- package/dist/panel/util/upload.d.ts +1 -1
- package/dist/util/object.js +3 -0
- package/package.json +12 -10
- package/dist/panel/components/sections/document/FloatingUI.svelte +0 -81
- package/dist/panel/components/sections/document/FloatingUI.svelte.d.ts +0 -8
- package/dist/panel/components/sections/live/SidePanel.svelte +0 -61
- package/dist/panel/components/sections/live/SidePanel.svelte.d.ts +0 -14
- package/dist/panel/components/sections/live/side-panel.css +0 -15
- /package/dist/adapter-sqlite/{area.d.ts → area.server.d.ts} +0 -0
- /package/dist/adapter-sqlite/{collection.d.ts → collection.server.d.ts} +0 -0
- /package/dist/adapter-sqlite/{orderBy.d.ts → orderBy.server.d.ts} +0 -0
- /package/dist/adapter-sqlite/{transform.d.ts → transform.server.d.ts} +0 -0
- /package/dist/adapter-sqlite/{types.d.ts → types.server.d.ts} +0 -0
- /package/dist/adapter-sqlite/{types.js → types.server.js} +0 -0
- /package/dist/adapter-sqlite/{util.d.ts → util.server.d.ts} +0 -0
- /package/dist/adapter-sqlite/{util.js → util.server.js} +0 -0
- /package/dist/adapter-sqlite/{where.d.ts → where.server.d.ts} +0 -0
- /package/dist/adapter-sqlite/{where.js → where.server.js} +0 -0
- /package/dist/adapter-sqlite/{with.d.ts → with.server.d.ts} +0 -0
- /package/dist/adapter-sqlite/{with.js → with.server.js} +0 -0
- /package/dist/core/collections/upload/util/{converter.d.ts → converter.server.d.ts} +0 -0
- /package/dist/core/collections/upload/util/{converter.js → converter.server.js} +0 -0
- /package/dist/core/config/auth/{better-auth-hooks.d.ts → better-auth-hooks.server.d.ts} +0 -0
- /package/dist/core/config/auth/{better-auth-hooks.js → better-auth-hooks.server.js} +0 -0
- /package/dist/core/config/server/{augment-cors.d.ts → augment-cors.server.d.ts} +0 -0
- /package/dist/core/config/server/{augment-cors.js → augment-cors.server.js} +0 -0
- /package/dist/core/config/server/{validate.d.ts → validate.server.d.ts} +0 -0
- /package/dist/core/config/server/{write.d.ts → write.server.d.ts} +0 -0
- /package/dist/core/dev/cache/{index.d.ts → index.server.d.ts} +0 -0
- /package/dist/core/dev/cache/{index.js → index.server.js} +0 -0
- /package/dist/core/dev/cli/clear/{index.d.ts → index.server.d.ts} +0 -0
- /package/dist/core/dev/cli/clear/{index.js → index.server.js} +0 -0
- /package/dist/core/dev/cli/generate/{index.d.ts → index.server.d.ts} +0 -0
- /package/dist/core/dev/cli/init/{getPackageName.d.ts → get-package-info.server.d.ts} +0 -0
- /package/dist/core/dev/cli/init/{getPackageName.js → get-package-info.server.js} +0 -0
- /package/dist/core/dev/cli/init/{index.d.ts → index.server.d.ts} +0 -0
- /package/dist/core/dev/cli/init/{packageManagerUtil.d.ts → package-manager-util.server.d.ts} +0 -0
- /package/dist/core/dev/generate/routes/{custom-css.d.ts → custom-css.server.d.ts} +0 -0
- /package/dist/core/dev/generate/routes/{custom-css.js → custom-css.server.js} +0 -0
- /package/dist/core/dev/generate/routes/{index.d.ts → index.server.d.ts} +0 -0
- /package/dist/core/dev/generate/routes/{util.d.ts → util.server.d.ts} +0 -0
- /package/dist/core/dev/generate/sanitize/{index.d.ts → index.server.d.ts} +0 -0
- /package/dist/core/dev/generate/sanitize/{index.js → index.server.js} +0 -0
- /package/dist/core/dev/generate/types/{index.d.ts → index.server.d.ts} +0 -0
- /package/dist/core/dev/vite/{index.d.ts → index.server.d.ts} +0 -0
|
@@ -1137,7 +1137,7 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
1137
1137
|
$Infer: {
|
|
1138
1138
|
body: {
|
|
1139
1139
|
userId: string;
|
|
1140
|
-
role: "user" | "
|
|
1140
|
+
role: "user" | "admin" | "staff" | ("user" | "admin" | "staff")[];
|
|
1141
1141
|
};
|
|
1142
1142
|
};
|
|
1143
1143
|
};
|
|
@@ -1217,7 +1217,7 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
1217
1217
|
email: string;
|
|
1218
1218
|
password?: string | undefined;
|
|
1219
1219
|
name: string;
|
|
1220
|
-
role?: "user" | "
|
|
1220
|
+
role?: "user" | "admin" | "staff" | ("user" | "admin" | "staff")[] | undefined;
|
|
1221
1221
|
data?: Record<string, any> | undefined;
|
|
1222
1222
|
};
|
|
1223
1223
|
};
|
|
@@ -1761,7 +1761,7 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
1761
1761
|
permission?: never | undefined;
|
|
1762
1762
|
}) & {
|
|
1763
1763
|
userId?: string | undefined;
|
|
1764
|
-
role?: "user" | "
|
|
1764
|
+
role?: "user" | "admin" | "staff" | undefined;
|
|
1765
1765
|
};
|
|
1766
1766
|
};
|
|
1767
1767
|
};
|
|
@@ -3119,7 +3119,7 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
3119
3119
|
$Infer: {
|
|
3120
3120
|
body: {
|
|
3121
3121
|
userId: string;
|
|
3122
|
-
role: "user" | "
|
|
3122
|
+
role: "user" | "admin" | "staff" | ("user" | "admin" | "staff")[];
|
|
3123
3123
|
};
|
|
3124
3124
|
};
|
|
3125
3125
|
};
|
|
@@ -3199,7 +3199,7 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
3199
3199
|
email: string;
|
|
3200
3200
|
password?: string | undefined;
|
|
3201
3201
|
name: string;
|
|
3202
|
-
role?: "user" | "
|
|
3202
|
+
role?: "user" | "admin" | "staff" | ("user" | "admin" | "staff")[] | undefined;
|
|
3203
3203
|
data?: Record<string, any> | undefined;
|
|
3204
3204
|
};
|
|
3205
3205
|
};
|
|
@@ -3743,7 +3743,7 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
3743
3743
|
permission?: never | undefined;
|
|
3744
3744
|
}) & {
|
|
3745
3745
|
userId?: string | undefined;
|
|
3746
|
-
role?: "user" | "
|
|
3746
|
+
role?: "user" | "admin" | "staff" | undefined;
|
|
3747
3747
|
};
|
|
3748
3748
|
};
|
|
3749
3749
|
};
|
|
@@ -3956,12 +3956,12 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
3956
3956
|
};
|
|
3957
3957
|
}>;
|
|
3958
3958
|
declare function augmentConfig<T extends Config>(config: T): T & {
|
|
3959
|
-
readonly collections: readonly [import("../types.js").BuiltCollection,
|
|
3959
|
+
readonly collections: readonly [...import("../types.js").BuiltCollection[], import("../types.js").BuiltCollection];
|
|
3960
3960
|
} & {
|
|
3961
3961
|
readonly collections: import("../types.js").BuiltCollection[];
|
|
3962
3962
|
readonly areas: import("../types.js").BuiltArea[];
|
|
3963
3963
|
} & {
|
|
3964
|
-
readonly icons: import("../../../util/types.js").Dic<import("svelte").Component<import("@lucide/svelte").
|
|
3964
|
+
readonly icons: import("../../../util/types.js").Dic<import("svelte").Component<import("@lucide/svelte").LucideProps, {}, string>>;
|
|
3965
3965
|
} & {
|
|
3966
3966
|
readonly panel: {
|
|
3967
3967
|
readonly routes: Record<string, import("../types.js").CustomPanelRoute>;
|
|
@@ -3972,16 +3972,16 @@ declare function augmentConfig<T extends Config>(config: T): T & {
|
|
|
3972
3972
|
icon: import("svelte").Component<import("@lucide/svelte").IconProps>;
|
|
3973
3973
|
}[], {
|
|
3974
3974
|
readonly label: "content";
|
|
3975
|
-
readonly icon: import("svelte").Component<import("@lucide/svelte").
|
|
3975
|
+
readonly icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
3976
3976
|
}, {
|
|
3977
3977
|
readonly label: "system";
|
|
3978
|
-
readonly icon: import("svelte").Component<import("@lucide/svelte").
|
|
3978
|
+
readonly icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
3979
3979
|
}, {
|
|
3980
3980
|
readonly label: "collections";
|
|
3981
|
-
readonly icon: import("svelte").Component<import("@lucide/svelte").
|
|
3981
|
+
readonly icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
3982
3982
|
}, {
|
|
3983
3983
|
readonly label: "areas";
|
|
3984
|
-
readonly icon: import("svelte").Component<import("@lucide/svelte").
|
|
3984
|
+
readonly icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
3985
3985
|
}];
|
|
3986
3986
|
};
|
|
3987
3987
|
readonly components: {
|
|
@@ -4,7 +4,7 @@ import { augmentPlugins } from '../client/augment-plugins.js';
|
|
|
4
4
|
import { augmentIcons } from '../shared/augment-icons.js';
|
|
5
5
|
import { augmentPrototypes } from '../shared/augment-prototypes.js';
|
|
6
6
|
import { makeVersionsCollectionsAliases } from '../shared/versions-alias.server.js';
|
|
7
|
-
import { augmentCORS } from './augment-cors.js';
|
|
7
|
+
import { augmentCORS } from './augment-cors.server.js';
|
|
8
8
|
import { augmentDirectoriesServer } from './augment-directories.server.js';
|
|
9
9
|
import { augmentPanelAccess } from './augment-panel-access.server.js';
|
|
10
10
|
import { augmentPluginsServer } from './augment-plugins.server.js';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { isAuthConfig } from '../../collections/auth/util.js';
|
|
2
|
-
import cache from '../../dev/cache/index.js';
|
|
2
|
+
import cache from '../../dev/cache/index.server.js';
|
|
3
3
|
import { isFormField } from '../../fields/util.js';
|
|
4
|
+
import { logger } from '../../logger/index.server';
|
|
4
5
|
import { isBlocksFieldRaw } from '../../../fields/blocks/index.js';
|
|
5
6
|
import { isGroupFieldRaw } from '../../../fields/group/index.js';
|
|
7
|
+
import { isRelationField } from '../../../fields/relation';
|
|
6
8
|
import { isSelectField } from '../../../fields/select/index.js';
|
|
7
|
-
import { isTabsFieldRaw } from '../../../fields/tabs
|
|
9
|
+
import { isTabsFieldRaw } from '../../../fields/tabs';
|
|
8
10
|
import { isTreeFieldRaw } from '../../../fields/tree/index.js';
|
|
9
11
|
function hasDuplicates(arr) {
|
|
10
12
|
return [...new Set(arr.filter((e, i, a) => a.indexOf(e) !== i))];
|
|
@@ -45,11 +47,11 @@ function hasUsersSlug(config) {
|
|
|
45
47
|
const validateFields = (config) => {
|
|
46
48
|
let errors = [];
|
|
47
49
|
for (const collection of config.collections || []) {
|
|
48
|
-
const collectionErrors = validateDocumentFields(collection);
|
|
50
|
+
const collectionErrors = validateDocumentFields(collection, config);
|
|
49
51
|
errors = [...errors, ...collectionErrors];
|
|
50
52
|
}
|
|
51
53
|
for (const area of config.areas || []) {
|
|
52
|
-
const collectionErrors = validateDocumentFields(area);
|
|
54
|
+
const collectionErrors = validateDocumentFields(area, config);
|
|
53
55
|
errors = [...errors, ...collectionErrors];
|
|
54
56
|
}
|
|
55
57
|
return errors;
|
|
@@ -57,12 +59,12 @@ const validateFields = (config) => {
|
|
|
57
59
|
/**
|
|
58
60
|
*
|
|
59
61
|
*/
|
|
60
|
-
const validateDocumentFields = (config) => {
|
|
62
|
+
const validateDocumentFields = (documentConfig, config) => {
|
|
61
63
|
const errors = [];
|
|
62
|
-
const isCollection = (
|
|
63
|
-
const isAuth = isCollection(
|
|
64
|
+
const isCollection = (documentConfig) => documentConfig.type === 'collection';
|
|
65
|
+
const isAuth = isCollection(documentConfig) && isAuthConfig(documentConfig);
|
|
64
66
|
const registeredBlocks = {};
|
|
65
|
-
const fieldsCompiled =
|
|
67
|
+
const fieldsCompiled = documentConfig.fields.map((f) => f.compile());
|
|
66
68
|
if (isAuth) {
|
|
67
69
|
const rolesField = fieldsCompiled
|
|
68
70
|
.filter(isFormField)
|
|
@@ -73,28 +75,37 @@ const validateDocumentFields = (config) => {
|
|
|
73
75
|
.filter(isFormField)
|
|
74
76
|
.find((f) => f.name === 'email' && f.type === 'email');
|
|
75
77
|
if (!rolesField)
|
|
76
|
-
errors.push(`Field roles is missing in collection ${
|
|
77
|
-
if (!emailField &&
|
|
78
|
-
errors.push(`Field email is missing in collection ${
|
|
78
|
+
errors.push(`Field roles is missing in collection ${documentConfig.slug}`);
|
|
79
|
+
if (!emailField && documentConfig.auth.type !== 'apiKey')
|
|
80
|
+
errors.push(`Field email is missing in collection ${documentConfig.slug}`);
|
|
79
81
|
if (!nameField)
|
|
80
|
-
errors.push(`Field name is missing in collection ${
|
|
82
|
+
errors.push(`Field name is missing in collection ${documentConfig.slug}`);
|
|
81
83
|
if (!rolesField.many)
|
|
82
84
|
errors.push(`Field roles must have "many" enabled : select('roles').options(...).many(), even with a single option`);
|
|
83
85
|
}
|
|
84
86
|
const validateBlockField = (fields, blockType) => {
|
|
85
87
|
const reserved = ['path', 'type', 'ownerId', 'position', 'locale'];
|
|
86
88
|
for (const key of reserved) {
|
|
87
|
-
if (fields
|
|
89
|
+
if (fields
|
|
90
|
+
.filter(isFormField)
|
|
91
|
+
.map((f) => f.name)
|
|
92
|
+
.filter((name) => name === key).length > 1) {
|
|
88
93
|
errors.push(`${key} is a reserved field in blocks (block ${blockType})`);
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
96
|
};
|
|
92
|
-
const
|
|
97
|
+
const validateRelationField = (field) => {
|
|
98
|
+
const collectionsSlugs = (config.collections || []).map((c) => c.slug);
|
|
99
|
+
if (!collectionsSlugs.includes(field.relationTo)) {
|
|
100
|
+
errors.push(`Relation field ${field.name} references unknown collection ${field.relationTo}, in ${documentConfig.type} ${documentConfig.slug}`);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const validateFields = (fields) => {
|
|
93
104
|
// Check for field name duplication at this level
|
|
94
|
-
const duplicates = hasDuplicates(fields.map((f) => f.name));
|
|
105
|
+
const duplicates = hasDuplicates(fields.filter(isFormField).map((f) => f.name));
|
|
95
106
|
if (duplicates.length) {
|
|
96
107
|
for (const duplicate of duplicates) {
|
|
97
|
-
errors.push(`Duplicate field '${duplicate}' in ${
|
|
108
|
+
errors.push(`Duplicate field '${duplicate}' in ${documentConfig.type} '${documentConfig.slug}'`);
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
111
|
function validateFieldName(name) {
|
|
@@ -104,16 +115,33 @@ const validateDocumentFields = (config) => {
|
|
|
104
115
|
// Check if string matches pattern and doesn't contain spaces or hyphens
|
|
105
116
|
return pattern.test(name) && !name.includes('-') && !name.includes(' ');
|
|
106
117
|
}
|
|
118
|
+
function validateTabs(field) {
|
|
119
|
+
const duplicates = hasDuplicates(field.tabs.map((t) => t.name));
|
|
120
|
+
if (duplicates.length) {
|
|
121
|
+
errors.push(`Dupplicate tab name ${duplicates} in ${documentConfig.slug}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
107
124
|
for (const field of fields) {
|
|
125
|
+
// Recursive check first into Tabs since tabs are not Formfields
|
|
126
|
+
if (isTabsFieldRaw(field)) {
|
|
127
|
+
validateTabs(field);
|
|
128
|
+
for (const tab of field.tabs) {
|
|
129
|
+
validateFields(tab.fields);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// If field is not a Formfield eg. Separator then continue
|
|
133
|
+
if (!isFormField(field)) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
108
136
|
// Check that a field wich has field._root = true is not localized
|
|
109
137
|
if ('_root' in field && field._root && field.localized) {
|
|
110
|
-
errors.push(`Field ${field.name} of ${
|
|
138
|
+
errors.push(`Field ${field.name} of ${documentConfig.type} ${documentConfig.slug} with _root = true, can't be localized`);
|
|
111
139
|
}
|
|
112
140
|
// Check for malformed field.name
|
|
113
141
|
if (!validateFieldName(field.name)) {
|
|
114
|
-
errors.push(`Field ${field.name} of ${
|
|
142
|
+
errors.push(`Field ${field.name} of ${documentConfig.type} ${documentConfig.slug} should be camelCase`);
|
|
115
143
|
}
|
|
116
|
-
// Recursive check into Blocks
|
|
144
|
+
// Recursive check into Blocks
|
|
117
145
|
if (isBlocksFieldRaw(field)) {
|
|
118
146
|
for (const block of field.blocks) {
|
|
119
147
|
if (block.name in registeredBlocks) {
|
|
@@ -125,24 +153,25 @@ const validateDocumentFields = (config) => {
|
|
|
125
153
|
else {
|
|
126
154
|
registeredBlocks[block.name] = block;
|
|
127
155
|
}
|
|
128
|
-
|
|
156
|
+
validateFields(block.fields.filter(isFormField));
|
|
129
157
|
validateBlockField(block.fields.filter(isFormField), block.name);
|
|
130
158
|
}
|
|
159
|
+
// Recursive check into Tree
|
|
131
160
|
}
|
|
132
161
|
else if (isTreeFieldRaw(field)) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
else if (isTabsFieldRaw(field)) {
|
|
136
|
-
for (const tab of field.tabs) {
|
|
137
|
-
validateFormFields(tab.fields.filter(isFormField));
|
|
138
|
-
}
|
|
162
|
+
validateFields(field.fields.filter(isFormField));
|
|
163
|
+
// Recursive check into Tabs
|
|
139
164
|
}
|
|
140
165
|
else if (isGroupFieldRaw(field)) {
|
|
141
|
-
|
|
166
|
+
validateFields(field.fields.filter(isFormField));
|
|
167
|
+
// Check relation field
|
|
168
|
+
}
|
|
169
|
+
else if (isRelationField(field)) {
|
|
170
|
+
validateRelationField(field);
|
|
142
171
|
}
|
|
143
172
|
}
|
|
144
173
|
};
|
|
145
|
-
|
|
174
|
+
validateFields(documentConfig.fields.map((f) => f.compile()));
|
|
146
175
|
return errors;
|
|
147
176
|
};
|
|
148
177
|
const hasDatabase = (config) => {
|
|
@@ -163,6 +192,7 @@ function validateAuthCollections(config) {
|
|
|
163
192
|
return errors;
|
|
164
193
|
}
|
|
165
194
|
function validate(config) {
|
|
195
|
+
logger.debug('Validating config...');
|
|
166
196
|
const validateFunctions = [
|
|
167
197
|
hasDuplicateSlug,
|
|
168
198
|
hasUsersSlug,
|
|
@@ -174,9 +204,11 @@ function validate(config) {
|
|
|
174
204
|
const errors = isValid(config);
|
|
175
205
|
if (errors.length) {
|
|
176
206
|
cache.clear();
|
|
177
|
-
|
|
207
|
+
errors.map((err) => logger.error(err));
|
|
208
|
+
return false;
|
|
178
209
|
}
|
|
179
210
|
}
|
|
211
|
+
logger.debug('Config is valid');
|
|
180
212
|
return true;
|
|
181
213
|
}
|
|
182
214
|
export default validate;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { BuiltArea, BuiltCollection } from '../types.js';
|
|
2
2
|
import type { Dic } from '../../../util/types.js';
|
|
3
|
-
import type { IconProps } from '@lucide/svelte';
|
|
4
3
|
import type { Component } from 'svelte';
|
|
5
4
|
export declare const augmentIcons: <const T extends {
|
|
6
5
|
collections?: BuiltCollection[];
|
|
7
6
|
areas?: BuiltArea[];
|
|
8
7
|
}>(config: T) => T & {
|
|
9
|
-
readonly icons: Dic<Component<
|
|
8
|
+
readonly icons: Dic<Component<import("@lucide/svelte").LucideProps, {}, string>>;
|
|
10
9
|
};
|
|
@@ -15,7 +15,7 @@ export declare const staffCollection: {
|
|
|
15
15
|
type: string;
|
|
16
16
|
roles: string[];
|
|
17
17
|
};
|
|
18
|
-
icon: import("svelte").Component<import("@lucide/svelte").
|
|
18
|
+
icon: import("svelte").Component<import("@lucide/svelte").LucideProps, {}, "">;
|
|
19
19
|
fields: FieldBuilder<Field>[];
|
|
20
20
|
access: Access;
|
|
21
21
|
};
|
|
@@ -168,12 +168,6 @@ export type VersionsConfig = {
|
|
|
168
168
|
maxVersions?: number;
|
|
169
169
|
};
|
|
170
170
|
export type UrlDefinition<T extends BaseDoc = BaseDoc> = (document: T) => string;
|
|
171
|
-
export type PrototypePanelConfig = {
|
|
172
|
-
/** Description for the collection/area, basically displayed on the dashboard */
|
|
173
|
-
description?: string;
|
|
174
|
-
/** Sidebar navigation group */
|
|
175
|
-
group?: string;
|
|
176
|
-
};
|
|
177
171
|
type PrototypeConfig<S extends string = string> = {
|
|
178
172
|
slug: S;
|
|
179
173
|
/** Document fields definition */
|
|
@@ -185,8 +179,6 @@ type PrototypeConfig<S extends string = string> = {
|
|
|
185
179
|
access?: Access;
|
|
186
180
|
/** If the document can be edited live, if enabled the url prop must be set also. */
|
|
187
181
|
live?: boolean;
|
|
188
|
-
/** Panel configuration, set false to hide the area/collection from the panel */
|
|
189
|
-
panel?: false | PrototypePanelConfig;
|
|
190
182
|
};
|
|
191
183
|
export type UploadConfig = {
|
|
192
184
|
/**
|
|
@@ -233,6 +225,17 @@ export type CollectionAuthConfig = ({
|
|
|
233
225
|
}) & {
|
|
234
226
|
roles?: (string | Option)[];
|
|
235
227
|
};
|
|
228
|
+
export type CollectionPanelConfig = false | {
|
|
229
|
+
/** Description for the collection/area, basically displayed on the dashboard */
|
|
230
|
+
description?: string;
|
|
231
|
+
/** Sidebar navigation group */
|
|
232
|
+
group?: string;
|
|
233
|
+
/** Dashboard settings */
|
|
234
|
+
dashboard?: {
|
|
235
|
+
layout?: 'rows' | 'grid';
|
|
236
|
+
maxEntries?: number;
|
|
237
|
+
} | false;
|
|
238
|
+
};
|
|
236
239
|
export type Collection<S> = {
|
|
237
240
|
slug: S;
|
|
238
241
|
/** The collection label */
|
|
@@ -247,6 +250,8 @@ export type Collection<S> = {
|
|
|
247
250
|
nested?: boolean;
|
|
248
251
|
/** Whether the collection support file upload */
|
|
249
252
|
upload?: boolean | UploadConfig;
|
|
253
|
+
/** Panel configuration, set false to hide the collection from the panel */
|
|
254
|
+
panel?: CollectionPanelConfig;
|
|
250
255
|
} & PrototypeConfig;
|
|
251
256
|
export type Area<S> = PrototypeConfig & {
|
|
252
257
|
slug: S;
|
|
@@ -255,6 +260,13 @@ export type Area<S> = PrototypeConfig & {
|
|
|
255
260
|
$hooks?: AreaHooks<S extends keyof RegisterArea ? S : any>;
|
|
256
261
|
/** The area label */
|
|
257
262
|
label?: string;
|
|
263
|
+
/** Panel configuration, set false to hide the area from the panel */
|
|
264
|
+
panel?: false | {
|
|
265
|
+
/** Description for the collection/area, basically displayed on the dashboard */
|
|
266
|
+
description?: string;
|
|
267
|
+
/** Sidebar navigation group */
|
|
268
|
+
group?: string;
|
|
269
|
+
};
|
|
258
270
|
};
|
|
259
271
|
type NavigationConfig = {
|
|
260
272
|
groups: Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const polkaServer = "import polka from 'polka';\nimport serveStatic from 'serve-static';\nimport { handler } from './build/handler.js';\n\nconst serve = serveStatic('./static');\n\npolka()\n\t.use(serve)\n\t.use(handler)\n\t.listen(
|
|
1
|
+
export declare const polkaServer = "import polka from 'polka';\nimport serveStatic from 'serve-static';\nimport { handler } from './build/handler.js';\n\nconst serve = serveStatic('./static');\n\nconst port = process.env.PORT || 3000;\nconst host = process.env.HOST || '127.0.0.1';\n\npolka()\n\t.use(serve)\n\t.use(handler)\n\t.listen(port, host, () => {\n\t\tconsole.log(`server running on ${host}:${port}`);\n\t});\n";
|
|
@@ -4,10 +4,13 @@ import { handler } from './build/handler.js';
|
|
|
4
4
|
|
|
5
5
|
const serve = serveStatic('./static');
|
|
6
6
|
|
|
7
|
+
const port = process.env.PORT || 3000;
|
|
8
|
+
const host = process.env.HOST || '127.0.0.1';
|
|
9
|
+
|
|
7
10
|
polka()
|
|
8
11
|
.use(serve)
|
|
9
12
|
.use(handler)
|
|
10
|
-
.listen(
|
|
11
|
-
console.log(
|
|
13
|
+
.listen(port, host, () => {
|
|
14
|
+
console.log(\`server running on \${host}:\${port}\`);
|
|
12
15
|
});
|
|
13
16
|
`;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { sanitize } from '../../generate/sanitize/index.js';
|
|
1
|
+
import { sanitize } from '../../generate/sanitize/index.server.js';
|
|
3
2
|
import { ensureGeneratedConfig, ensureUserConfigExist } from '../../../ensure.server.js';
|
|
4
3
|
import { logger } from '../../../logger/index.server.js';
|
|
5
4
|
import { trycatch } from '../../../../util/function.js';
|
|
@@ -62,18 +61,23 @@ export const generate = async (args) => {
|
|
|
62
61
|
ensureUserConfigExist();
|
|
63
62
|
await sanitizeConfig();
|
|
64
63
|
const importPathJS = ensureGeneratedConfig();
|
|
65
|
-
logger.info('
|
|
64
|
+
logger.info('Starting vite server...');
|
|
66
65
|
const vite = await createServer();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
try {
|
|
67
|
+
const mod = await vite.ssrLoadModule(importPathJS);
|
|
68
|
+
// The generated config's default export is the createRime() promise;
|
|
69
|
+
// ssrLoadModule only awaits the module's synchronous evaluation, so we
|
|
70
|
+
// must await it directly to observe init failures (e.g. config validation).
|
|
71
|
+
await mod.default;
|
|
72
|
+
logger.info('[✓] Generation completed successfully');
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
await vite.close();
|
|
70
76
|
}
|
|
71
|
-
await vite.close();
|
|
72
|
-
logger.info('[✓] Generation completed successfully');
|
|
73
77
|
}
|
|
74
78
|
const [error] = await trycatch(run);
|
|
75
79
|
if (error) {
|
|
76
|
-
logger.error('Error during generation:', error);
|
|
80
|
+
logger.error('[✗] Error during generation:', error);
|
|
77
81
|
throw error;
|
|
78
82
|
}
|
|
79
83
|
};
|
|
@@ -8,7 +8,7 @@ program
|
|
|
8
8
|
.option('-f, --force', 'Force init with default package name', false)
|
|
9
9
|
.option('-s, --skip-install', 'Do not install dependencies', false)
|
|
10
10
|
.action(async (args) => {
|
|
11
|
-
const init = await import('./init/index.js').then((m) => m.init);
|
|
11
|
+
const init = await import('./init/index.server.js').then((m) => m.init);
|
|
12
12
|
init(args);
|
|
13
13
|
});
|
|
14
14
|
program
|
|
@@ -22,16 +22,21 @@ program
|
|
|
22
22
|
.command('clear')
|
|
23
23
|
.option('-f, --force', 'Force clear without prompt', false)
|
|
24
24
|
.action(async (args) => {
|
|
25
|
-
const clear = await import('./clear/index.js').then((m) => m.clear);
|
|
25
|
+
const clear = await import('./clear/index.server.js').then((m) => m.clear);
|
|
26
26
|
clear(args);
|
|
27
27
|
});
|
|
28
28
|
program
|
|
29
29
|
.command('generate')
|
|
30
30
|
.option('-f, --force', 'Force generation, ignore cache, overwrite routes', false)
|
|
31
31
|
.action(async (args) => {
|
|
32
|
-
const generate = await import('./generate/index.js').then((m) => m.generate);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const generate = await import('./generate/index.server.js').then((m) => m.generate);
|
|
33
|
+
try {
|
|
34
|
+
await generate({
|
|
35
|
+
force: args.force
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
}
|
|
36
41
|
});
|
|
37
42
|
program.parse(process.argv);
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { logger } from '../../../logger/index.server.js';
|
|
2
2
|
import { randomId } from '../../../../util/random.js';
|
|
3
3
|
import { isValidSlug, slugify } from '../../../../util/string.js';
|
|
4
|
+
import { generate as generateCode } from '@babel/generator';
|
|
5
|
+
import * as t from '@babel/types';
|
|
6
|
+
import { babelParse } from 'ast-kit';
|
|
4
7
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
5
8
|
import { cp, mkdir } from 'fs/promises';
|
|
9
|
+
import fs from 'node:fs';
|
|
6
10
|
import path from 'path';
|
|
7
11
|
import { fileURLToPath } from 'url';
|
|
8
12
|
import { INPUT_DIR } from '../../constants.js';
|
|
9
|
-
import { generate } from '../generate/index.js';
|
|
13
|
+
import { generate } from '../generate/index.server.js';
|
|
10
14
|
import { prompt } from '../util.server.js';
|
|
11
|
-
import { getPackageInfoByKey } from './
|
|
12
|
-
import { installDependencies } from './
|
|
15
|
+
import { getPackageInfoByKey } from './get-package-info.server.js';
|
|
16
|
+
import { installDependencies } from './package-manager-util.server.js';
|
|
13
17
|
import * as templates from './templates.js';
|
|
14
18
|
const PACKAGE = 'rimecms';
|
|
15
19
|
const root = process.cwd();
|
|
@@ -104,33 +108,72 @@ export const init = async ({ force, name: incomingName, skipInstall }) => {
|
|
|
104
108
|
}
|
|
105
109
|
function configureVite() {
|
|
106
110
|
const configPath = path.resolve(root, 'vite.config.ts');
|
|
107
|
-
if (!existsSync(configPath)) {
|
|
111
|
+
if (!fs.existsSync(configPath)) {
|
|
108
112
|
throw new Error("Can't find vite configuration file");
|
|
109
113
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
114
|
+
let content = fs.readFileSync(configPath, 'utf-8');
|
|
115
|
+
content = content.replace("from '@sveltejs/adapter-auto'", "from '@sveltejs/adapter-node'");
|
|
116
|
+
const program = babelParse(content, configPath); // t.Program
|
|
117
|
+
const programBody = program.body;
|
|
118
|
+
const configObject = findSvelteConfigObject(programBody);
|
|
119
|
+
if (!configObject) {
|
|
120
|
+
throw new Error("Couldn't find the Vite config object (defineConfig({...}) or export default {...})");
|
|
121
|
+
}
|
|
122
|
+
const pluginsProp = configObject.properties.find((p) => t.isObjectProperty(p) && t.isIdentifier(p.key) && p.key.name === 'plugins');
|
|
123
|
+
if (!pluginsProp || !t.isArrayExpression(pluginsProp.value)) {
|
|
124
|
+
throw new Error("Couldn't find a `plugins: [...]` array in the Vite config object");
|
|
125
|
+
}
|
|
126
|
+
const pluginsArray = pluginsProp.value;
|
|
127
|
+
const alreadyPresent = pluginsArray.elements.some((el) => t.isCallExpression(el) && t.isIdentifier(el.callee) && el.callee.name === 'rime');
|
|
128
|
+
if (alreadyPresent) {
|
|
129
|
+
logger.info('[✓] Vite plugin already present (skip)');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const hasImport = programBody.some((node) => t.isImportDeclaration(node) &&
|
|
133
|
+
node.source.value === `${PACKAGE}/vite` &&
|
|
134
|
+
node.specifiers.some((s) => t.isImportSpecifier(s) && t.isIdentifier(s.imported) && s.imported.name === 'rime'));
|
|
135
|
+
if (!hasImport) {
|
|
136
|
+
const importDecl = t.importDeclaration([t.importSpecifier(t.identifier('rime'), t.identifier('rime'))], t.stringLiteral(`${PACKAGE}/vite`));
|
|
137
|
+
programBody.unshift(importDecl);
|
|
138
|
+
}
|
|
139
|
+
const rimeCall = t.callExpression(t.identifier('rime'), []);
|
|
140
|
+
const sveltekitIndex = pluginsArray.elements.findIndex((el) => t.isCallExpression(el) && t.isIdentifier(el.callee) && el.callee.name === 'sveltekit');
|
|
141
|
+
if (sveltekitIndex !== -1) {
|
|
142
|
+
pluginsArray.elements.splice(sveltekitIndex + 1, 0, rimeCall);
|
|
130
143
|
}
|
|
131
144
|
else {
|
|
132
|
-
|
|
145
|
+
pluginsArray.elements.push(rimeCall);
|
|
146
|
+
}
|
|
147
|
+
const file = t.file(program);
|
|
148
|
+
const { code } = generateCode(file, {}, content);
|
|
149
|
+
fs.writeFileSync(configPath, code);
|
|
150
|
+
logger.info('[✓] Vite plugin added');
|
|
151
|
+
}
|
|
152
|
+
function findSvelteConfigObject(body) {
|
|
153
|
+
for (const node of body) {
|
|
154
|
+
if (t.isExpressionStatement(node) &&
|
|
155
|
+
t.isCallExpression(node.expression) &&
|
|
156
|
+
t.isIdentifier(node.expression.callee) &&
|
|
157
|
+
node.expression.callee.name === 'defineConfig') {
|
|
158
|
+
const arg = node.expression.arguments[0];
|
|
159
|
+
if (t.isObjectExpression(arg))
|
|
160
|
+
return arg;
|
|
161
|
+
}
|
|
162
|
+
if (t.isExportDefaultDeclaration(node)) {
|
|
163
|
+
const decl = node.declaration;
|
|
164
|
+
if (t.isCallExpression(decl) &&
|
|
165
|
+
t.isIdentifier(decl.callee) &&
|
|
166
|
+
decl.callee.name === 'defineConfig') {
|
|
167
|
+
const arg = decl.arguments[0];
|
|
168
|
+
if (t.isObjectExpression(arg))
|
|
169
|
+
return arg;
|
|
170
|
+
}
|
|
171
|
+
if (t.isObjectExpression(decl)) {
|
|
172
|
+
return decl;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
133
175
|
}
|
|
176
|
+
return null;
|
|
134
177
|
}
|
|
135
178
|
function setHooks() {
|
|
136
179
|
const hooksPath = path.join(root, 'src', 'hooks.server.ts');
|
|
@@ -11,23 +11,23 @@ const packageManagersMap = {
|
|
|
11
11
|
};
|
|
12
12
|
const packageManagerConfigs = {
|
|
13
13
|
yarn: {
|
|
14
|
-
command: 'yarn
|
|
14
|
+
command: 'echo "yarn is not supported, please use pnpm or npm" && exit 1'
|
|
15
15
|
},
|
|
16
16
|
pnpm: {
|
|
17
|
-
command: 'pnpm add -D drizzle-kit && pnpm add drizzle-orm @lucide/svelte sharp',
|
|
17
|
+
command: 'pnpm add -D drizzle-kit && pnpm add -D @sveltejs/adapter-node && pnpm add drizzle-orm @lucide/svelte sharp',
|
|
18
18
|
preInstall: updatePackageJsonForPnpm,
|
|
19
19
|
postInstall: () => {
|
|
20
20
|
execSync('pnpm rebuild');
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
bun: {
|
|
24
|
-
command: 'bun add -D drizzle-kit'
|
|
24
|
+
command: 'bun add -D drizzle-kit && bun add -D @sveltejs/adapter-node && bun add drizzle-orm @lucide/svelte sharp'
|
|
25
25
|
},
|
|
26
26
|
npm: {
|
|
27
|
-
command: 'npm install -D drizzle-kit'
|
|
27
|
+
command: 'npm install -D drizzle-kit && npm install -D @sveltejs/adapter-node && npm install drizzle-orm @lucide/svelte sharp'
|
|
28
28
|
},
|
|
29
29
|
deno: {
|
|
30
|
-
command: 'deno
|
|
30
|
+
command: 'echo "deno is not supported, please use pnpm or npm" && exit 1'
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
export function getPackageManager() {
|