@slicemachine/adapter-nuxt 0.0.2-dev-plugins-m3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +98 -0
- package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs +41 -0
- package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -0
- package/dist/_node_modules/data-uri-to-buffer/dist/index.js +41 -0
- package/dist/_node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
- package/dist/_node_modules/fetch-blob/file.cjs +61 -0
- package/dist/_node_modules/fetch-blob/file.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/file.js +61 -0
- package/dist/_node_modules/fetch-blob/file.js.map +1 -0
- package/dist/_node_modules/fetch-blob/index.cjs +223 -0
- package/dist/_node_modules/fetch-blob/index.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/index.js +223 -0
- package/dist/_node_modules/fetch-blob/index.js.map +1 -0
- package/dist/_node_modules/fetch-blob/streams.cjs +43 -0
- package/dist/_node_modules/fetch-blob/streams.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/streams.js +42 -0
- package/dist/_node_modules/fetch-blob/streams.js.map +1 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.cjs +116 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.cjs.map +1 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.js +116 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.js.map +1 -0
- package/dist/_node_modules/node-domexception/index.cjs +11 -0
- package/dist/_node_modules/node-domexception/index.cjs.map +1 -0
- package/dist/_node_modules/node-domexception/index.js +10 -0
- package/dist/_node_modules/node-domexception/index.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/body.cjs +262 -0
- package/dist/_node_modules/node-fetch/src/body.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/body.js +262 -0
- package/dist/_node_modules/node-fetch/src/body.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/abort-error.cjs +10 -0
- package/dist/_node_modules/node-fetch/src/errors/abort-error.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/abort-error.js +10 -0
- package/dist/_node_modules/node-fetch/src/errors/abort-error.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/base.cjs +17 -0
- package/dist/_node_modules/node-fetch/src/errors/base.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/base.js +17 -0
- package/dist/_node_modules/node-fetch/src/errors/base.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/fetch-error.cjs +19 -0
- package/dist/_node_modules/node-fetch/src/errors/fetch-error.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/fetch-error.js +19 -0
- package/dist/_node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/headers.cjs +190 -0
- package/dist/_node_modules/node-fetch/src/headers.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/headers.js +190 -0
- package/dist/_node_modules/node-fetch/src/headers.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/index.cjs +292 -0
- package/dist/_node_modules/node-fetch/src/index.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/index.js +292 -0
- package/dist/_node_modules/node-fetch/src/index.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/request.cjs +206 -0
- package/dist/_node_modules/node-fetch/src/request.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/request.js +206 -0
- package/dist/_node_modules/node-fetch/src/request.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/response.cjs +122 -0
- package/dist/_node_modules/node-fetch/src/response.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/response.js +123 -0
- package/dist/_node_modules/node-fetch/src/response.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/get-search.cjs +12 -0
- package/dist/_node_modules/node-fetch/src/utils/get-search.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/get-search.js +12 -0
- package/dist/_node_modules/node-fetch/src/utils/get-search.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/is-redirect.cjs +8 -0
- package/dist/_node_modules/node-fetch/src/utils/is-redirect.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/is-redirect.js +8 -0
- package/dist/_node_modules/node-fetch/src/utils/is-redirect.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/is.cjs +28 -0
- package/dist/_node_modules/node-fetch/src/utils/is.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/is.js +28 -0
- package/dist/_node_modules/node-fetch/src/utils/is.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/multipart-parser.cjs +356 -0
- package/dist/_node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/multipart-parser.js +356 -0
- package/dist/_node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/referrer.cjs +149 -0
- package/dist/_node_modules/node-fetch/src/utils/referrer.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/referrer.js +149 -0
- package/dist/_node_modules/node-fetch/src/utils/referrer.js.map +1 -0
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs +3822 -0
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -0
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js +3822 -0
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
- package/dist/_virtual/_commonjsHelpers.cjs +5 -0
- package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
- package/dist/_virtual/_commonjsHelpers.js +5 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/ponyfill.es2018.cjs +13 -0
- package/dist/_virtual/ponyfill.es2018.cjs.map +1 -0
- package/dist/_virtual/ponyfill.es2018.js +14 -0
- package/dist/_virtual/ponyfill.es2018.js.map +1 -0
- package/dist/constants.cjs +5 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/hooks/customType-asset-delete.cjs +31 -0
- package/dist/hooks/customType-asset-delete.cjs.map +1 -0
- package/dist/hooks/customType-asset-delete.d.ts +3 -0
- package/dist/hooks/customType-asset-delete.js +14 -0
- package/dist/hooks/customType-asset-delete.js.map +1 -0
- package/dist/hooks/customType-asset-read.cjs +34 -0
- package/dist/hooks/customType-asset-read.cjs.map +1 -0
- package/dist/hooks/customType-asset-read.d.ts +3 -0
- package/dist/hooks/customType-asset-read.js +17 -0
- package/dist/hooks/customType-asset-read.js.map +1 -0
- package/dist/hooks/customType-asset-update.cjs +34 -0
- package/dist/hooks/customType-asset-update.cjs.map +1 -0
- package/dist/hooks/customType-asset-update.d.ts +3 -0
- package/dist/hooks/customType-asset-update.js +16 -0
- package/dist/hooks/customType-asset-update.js.map +1 -0
- package/dist/hooks/customType-create.cjs +43 -0
- package/dist/hooks/customType-create.cjs.map +1 -0
- package/dist/hooks/customType-create.d.ts +3 -0
- package/dist/hooks/customType-create.js +25 -0
- package/dist/hooks/customType-create.js.map +1 -0
- package/dist/hooks/customType-delete.cjs +32 -0
- package/dist/hooks/customType-delete.cjs.map +1 -0
- package/dist/hooks/customType-delete.d.ts +3 -0
- package/dist/hooks/customType-delete.js +15 -0
- package/dist/hooks/customType-delete.js.map +1 -0
- package/dist/hooks/customType-read.cjs +31 -0
- package/dist/hooks/customType-read.cjs.map +1 -0
- package/dist/hooks/customType-read.d.ts +3 -0
- package/dist/hooks/customType-read.js +14 -0
- package/dist/hooks/customType-read.js.map +1 -0
- package/dist/hooks/customType-rename.cjs +6 -0
- package/dist/hooks/customType-rename.cjs.map +1 -0
- package/dist/hooks/customType-rename.d.ts +1 -0
- package/dist/hooks/customType-rename.js +6 -0
- package/dist/hooks/customType-rename.js.map +1 -0
- package/dist/hooks/customType-update.cjs +6 -0
- package/dist/hooks/customType-update.cjs.map +1 -0
- package/dist/hooks/customType-update.d.ts +1 -0
- package/dist/hooks/customType-update.js +6 -0
- package/dist/hooks/customType-update.js.map +1 -0
- package/dist/hooks/customTypeLibrary-read.cjs +53 -0
- package/dist/hooks/customTypeLibrary-read.cjs.map +1 -0
- package/dist/hooks/customTypeLibrary-read.d.ts +3 -0
- package/dist/hooks/customTypeLibrary-read.js +35 -0
- package/dist/hooks/customTypeLibrary-read.js.map +1 -0
- package/dist/hooks/project-init.cjs +112 -0
- package/dist/hooks/project-init.cjs.map +1 -0
- package/dist/hooks/project-init.d.ts +3 -0
- package/dist/hooks/project-init.js +94 -0
- package/dist/hooks/project-init.js.map +1 -0
- package/dist/hooks/slice-asset-delete.cjs +33 -0
- package/dist/hooks/slice-asset-delete.cjs.map +1 -0
- package/dist/hooks/slice-asset-delete.d.ts +3 -0
- package/dist/hooks/slice-asset-delete.js +16 -0
- package/dist/hooks/slice-asset-delete.js.map +1 -0
- package/dist/hooks/slice-asset-read.cjs +36 -0
- package/dist/hooks/slice-asset-read.cjs.map +1 -0
- package/dist/hooks/slice-asset-read.d.ts +3 -0
- package/dist/hooks/slice-asset-read.js +19 -0
- package/dist/hooks/slice-asset-read.js.map +1 -0
- package/dist/hooks/slice-asset-update.cjs +36 -0
- package/dist/hooks/slice-asset-update.cjs.map +1 -0
- package/dist/hooks/slice-asset-update.d.ts +3 -0
- package/dist/hooks/slice-asset-update.js +18 -0
- package/dist/hooks/slice-asset-update.js.map +1 -0
- package/dist/hooks/slice-create.cjs +77 -0
- package/dist/hooks/slice-create.cjs.map +1 -0
- package/dist/hooks/slice-create.d.ts +3 -0
- package/dist/hooks/slice-create.js +59 -0
- package/dist/hooks/slice-create.js.map +1 -0
- package/dist/hooks/slice-delete.cjs +41 -0
- package/dist/hooks/slice-delete.cjs.map +1 -0
- package/dist/hooks/slice-delete.d.ts +3 -0
- package/dist/hooks/slice-delete.js +24 -0
- package/dist/hooks/slice-delete.js.map +1 -0
- package/dist/hooks/slice-read.cjs +62 -0
- package/dist/hooks/slice-read.cjs.map +1 -0
- package/dist/hooks/slice-read.d.ts +3 -0
- package/dist/hooks/slice-read.js +44 -0
- package/dist/hooks/slice-read.js.map +1 -0
- package/dist/hooks/slice-rename.cjs +51 -0
- package/dist/hooks/slice-rename.cjs.map +1 -0
- package/dist/hooks/slice-rename.d.ts +3 -0
- package/dist/hooks/slice-rename.js +34 -0
- package/dist/hooks/slice-rename.js.map +1 -0
- package/dist/hooks/slice-update.cjs +14 -0
- package/dist/hooks/slice-update.cjs.map +1 -0
- package/dist/hooks/slice-update.d.ts +3 -0
- package/dist/hooks/slice-update.js +14 -0
- package/dist/hooks/slice-update.js.map +1 -0
- package/dist/hooks/sliceLibrary-read.cjs +52 -0
- package/dist/hooks/sliceLibrary-read.cjs.map +1 -0
- package/dist/hooks/sliceLibrary-read.d.ts +3 -0
- package/dist/hooks/sliceLibrary-read.js +34 -0
- package/dist/hooks/sliceLibrary-read.js.map +1 -0
- package/dist/hooks/sliceSimulator-setup-read.cjs +150 -0
- package/dist/hooks/sliceSimulator-setup-read.cjs.map +1 -0
- package/dist/hooks/sliceSimulator-setup-read.d.ts +3 -0
- package/dist/hooks/sliceSimulator-setup-read.js +150 -0
- package/dist/hooks/sliceSimulator-setup-read.js.map +1 -0
- package/dist/hooks/snippet-read.cjs +101 -0
- package/dist/hooks/snippet-read.cjs.map +1 -0
- package/dist/hooks/snippet-read.d.ts +3 -0
- package/dist/hooks/snippet-read.js +101 -0
- package/dist/hooks/snippet-read.js.map +1 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/buildCustomTypeAssetPath.cjs +29 -0
- package/dist/lib/buildCustomTypeAssetPath.cjs.map +1 -0
- package/dist/lib/buildCustomTypeAssetPath.d.ts +9 -0
- package/dist/lib/buildCustomTypeAssetPath.js +12 -0
- package/dist/lib/buildCustomTypeAssetPath.js.map +1 -0
- package/dist/lib/buildCustomTypeDirectoryPath.cjs +26 -0
- package/dist/lib/buildCustomTypeDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildCustomTypeDirectoryPath.d.ts +8 -0
- package/dist/lib/buildCustomTypeDirectoryPath.js +9 -0
- package/dist/lib/buildCustomTypeDirectoryPath.js.map +1 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs +7 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.d.ts +7 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.js +7 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.js.map +1 -0
- package/dist/lib/buildSliceAssetPath.cjs +34 -0
- package/dist/lib/buildSliceAssetPath.cjs.map +1 -0
- package/dist/lib/buildSliceAssetPath.d.ts +11 -0
- package/dist/lib/buildSliceAssetPath.js +17 -0
- package/dist/lib/buildSliceAssetPath.js.map +1 -0
- package/dist/lib/buildSliceDirectoryPath.cjs +30 -0
- package/dist/lib/buildSliceDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildSliceDirectoryPath.d.ts +10 -0
- package/dist/lib/buildSliceDirectoryPath.js +13 -0
- package/dist/lib/buildSliceDirectoryPath.js.map +1 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.cjs +7 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.d.ts +8 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.js +7 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.js.map +1 -0
- package/dist/lib/checkIsTypeScriptProject.cjs +9 -0
- package/dist/lib/checkIsTypeScriptProject.cjs.map +1 -0
- package/dist/lib/checkIsTypeScriptProject.d.ts +8 -0
- package/dist/lib/checkIsTypeScriptProject.js +9 -0
- package/dist/lib/checkIsTypeScriptProject.js.map +1 -0
- package/dist/lib/checkPathExists.cjs +30 -0
- package/dist/lib/checkPathExists.cjs.map +1 -0
- package/dist/lib/checkPathExists.d.ts +2 -0
- package/dist/lib/checkPathExists.js +13 -0
- package/dist/lib/checkPathExists.js.map +1 -0
- package/dist/lib/isSharedSliceModel.cjs +7 -0
- package/dist/lib/isSharedSliceModel.cjs.map +1 -0
- package/dist/lib/isSharedSliceModel.d.ts +335 -0
- package/dist/lib/isSharedSliceModel.js +7 -0
- package/dist/lib/isSharedSliceModel.js.map +1 -0
- package/dist/lib/pascalCase.cjs +8 -0
- package/dist/lib/pascalCase.cjs.map +1 -0
- package/dist/lib/pascalCase.d.ts +8 -0
- package/dist/lib/pascalCase.js +8 -0
- package/dist/lib/pascalCase.js.map +1 -0
- package/dist/lib/readJSONFile.cjs +26 -0
- package/dist/lib/readJSONFile.cjs.map +1 -0
- package/dist/lib/readJSONFile.d.ts +1 -0
- package/dist/lib/readJSONFile.js +9 -0
- package/dist/lib/readJSONFile.js.map +1 -0
- package/dist/lib/rejectIfNecessary.cjs +10 -0
- package/dist/lib/rejectIfNecessary.cjs.map +1 -0
- package/dist/lib/rejectIfNecessary.d.ts +1 -0
- package/dist/lib/rejectIfNecessary.js +10 -0
- package/dist/lib/rejectIfNecessary.js.map +1 -0
- package/dist/lib/updateSliceModelFile.cjs +33 -0
- package/dist/lib/updateSliceModelFile.cjs.map +1 -0
- package/dist/lib/updateSliceModelFile.d.ts +9 -0
- package/dist/lib/updateSliceModelFile.js +15 -0
- package/dist/lib/updateSliceModelFile.js.map +1 -0
- package/dist/lib/upsertGlobalContentTypes.cjs +55 -0
- package/dist/lib/upsertGlobalContentTypes.cjs.map +1 -0
- package/dist/lib/upsertGlobalContentTypes.d.ts +12 -0
- package/dist/lib/upsertGlobalContentTypes.js +37 -0
- package/dist/lib/upsertGlobalContentTypes.js.map +1 -0
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +83 -0
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -0
- package/dist/lib/upsertSliceLibraryIndexFile.d.ts +7 -0
- package/dist/lib/upsertSliceLibraryIndexFile.js +65 -0
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -0
- package/dist/packages/adapter-nuxt/package.json.cjs +5 -0
- package/dist/packages/adapter-nuxt/package.json.cjs.map +1 -0
- package/dist/packages/adapter-nuxt/package.json.js +5 -0
- package/dist/packages/adapter-nuxt/package.json.js.map +1 -0
- package/dist/plugin.cjs +59 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +59 -0
- package/dist/plugin.js.map +1 -0
- package/dist/simulator/SliceSimulator.cjs +79 -0
- package/dist/simulator/SliceSimulator.cjs.map +1 -0
- package/dist/simulator/SliceSimulator.d.ts +34 -0
- package/dist/simulator/SliceSimulator.js +79 -0
- package/dist/simulator/SliceSimulator.js.map +1 -0
- package/dist/simulator/index.d.ts +2 -0
- package/dist/simulator.cjs +5 -0
- package/dist/simulator.cjs.map +1 -0
- package/dist/simulator.js +5 -0
- package/dist/simulator.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/package.json +107 -0
- package/src/constants.ts +5 -0
- package/src/hooks/customType-asset-delete.ts +18 -0
- package/src/hooks/customType-asset-read.ts +22 -0
- package/src/hooks/customType-asset-update.ts +20 -0
- package/src/hooks/customType-create.ts +45 -0
- package/src/hooks/customType-delete.ts +21 -0
- package/src/hooks/customType-read.ts +24 -0
- package/src/hooks/customType-rename.ts +3 -0
- package/src/hooks/customType-update.ts +3 -0
- package/src/hooks/customTypeLibrary-read.ts +53 -0
- package/src/hooks/project-init.ts +163 -0
- package/src/hooks/slice-asset-delete.ts +21 -0
- package/src/hooks/slice-asset-read.ts +25 -0
- package/src/hooks/slice-asset-update.ts +23 -0
- package/src/hooks/slice-create.ts +115 -0
- package/src/hooks/slice-delete.ts +41 -0
- package/src/hooks/slice-read.ts +69 -0
- package/src/hooks/slice-rename.ts +46 -0
- package/src/hooks/slice-update.ts +19 -0
- package/src/hooks/sliceLibrary-read.ts +48 -0
- package/src/hooks/sliceSimulator-setup-read.ts +209 -0
- package/src/hooks/snippet-read.ts +145 -0
- package/src/index.ts +4 -0
- package/src/lib/buildCustomTypeAssetPath.ts +24 -0
- package/src/lib/buildCustomTypeDirectoryPath.ts +20 -0
- package/src/lib/buildCustomTypeLibraryDirectoryPath.ts +13 -0
- package/src/lib/buildSliceAssetPath.ts +32 -0
- package/src/lib/buildSliceDirectoryPath.ts +26 -0
- package/src/lib/buildSliceLibraryDirectoryPath.ts +14 -0
- package/src/lib/checkIsTypeScriptProject.ts +17 -0
- package/src/lib/checkPathExists.ts +12 -0
- package/src/lib/isSharedSliceModel.ts +14 -0
- package/src/lib/pascalCase.ts +12 -0
- package/src/lib/readJSONFile.ts +7 -0
- package/src/lib/rejectIfNecessary.ts +16 -0
- package/src/lib/updateSliceModelFile.ts +33 -0
- package/src/lib/upsertGlobalContentTypes.ts +62 -0
- package/src/lib/upsertSliceLibraryIndexFile.ts +90 -0
- package/src/plugin.ts +63 -0
- package/src/simulator/SliceSimulator.ts +157 -0
- package/src/simulator/index.ts +2 -0
- package/src/types.ts +5 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SliceDeleteHook,
|
|
3
|
+
SliceDeleteHookData,
|
|
4
|
+
SliceMachineContext,
|
|
5
|
+
} from "@slicemachine/plugin-kit";
|
|
6
|
+
import * as fs from "node:fs/promises";
|
|
7
|
+
|
|
8
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath";
|
|
9
|
+
import { rejectIfNecessary } from "../lib/rejectIfNecessary";
|
|
10
|
+
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
|
|
11
|
+
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile";
|
|
12
|
+
|
|
13
|
+
import type { PluginOptions } from "../types";
|
|
14
|
+
|
|
15
|
+
type Args = {
|
|
16
|
+
data: SliceDeleteHookData;
|
|
17
|
+
} & SliceMachineContext<PluginOptions>;
|
|
18
|
+
|
|
19
|
+
const deleteSliceDir = async ({ data, helpers }: Args) => {
|
|
20
|
+
const dir = buildSliceDirectoryPath({
|
|
21
|
+
libraryID: data.libraryID,
|
|
22
|
+
model: data.model,
|
|
23
|
+
helpers,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await fs.rm(dir, { recursive: true });
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const sliceDelete: SliceDeleteHook<PluginOptions> = async (
|
|
30
|
+
data,
|
|
31
|
+
context,
|
|
32
|
+
) => {
|
|
33
|
+
await deleteSliceDir({ data, ...context });
|
|
34
|
+
|
|
35
|
+
rejectIfNecessary(
|
|
36
|
+
await Promise.allSettled([
|
|
37
|
+
upsertGlobalContentTypes(context),
|
|
38
|
+
upsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),
|
|
39
|
+
]),
|
|
40
|
+
);
|
|
41
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { SliceReadHook } from "@slicemachine/plugin-kit";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { buildSliceLibraryDirectoryPath } from "../lib/buildSliceLibraryDirectoryPath";
|
|
6
|
+
import { isSharedSliceModel } from "../lib/isSharedSliceModel";
|
|
7
|
+
import { readJSONFile } from "../lib/readJSONFile";
|
|
8
|
+
|
|
9
|
+
import type { PluginOptions } from "../types";
|
|
10
|
+
|
|
11
|
+
export const sliceRead: SliceReadHook<PluginOptions> = async (
|
|
12
|
+
data,
|
|
13
|
+
{ helpers },
|
|
14
|
+
) => {
|
|
15
|
+
const libraryDir = buildSliceLibraryDirectoryPath({
|
|
16
|
+
libraryID: data.libraryID,
|
|
17
|
+
helpers,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Ensure the directory exists.
|
|
21
|
+
await fs.mkdir(libraryDir, { recursive: true });
|
|
22
|
+
|
|
23
|
+
const childDirs = await fs.readdir(libraryDir, { withFileTypes: true });
|
|
24
|
+
|
|
25
|
+
const modelReadErrors: string[] = [];
|
|
26
|
+
|
|
27
|
+
// Find the first matching model.
|
|
28
|
+
const [model] = (
|
|
29
|
+
await Promise.all(
|
|
30
|
+
childDirs.map(async (childDir) => {
|
|
31
|
+
if (childDir.isDirectory()) {
|
|
32
|
+
const modelPath = path.join(libraryDir, childDir.name, "model.json");
|
|
33
|
+
try {
|
|
34
|
+
const modelContents = await readJSONFile(modelPath);
|
|
35
|
+
|
|
36
|
+
if (
|
|
37
|
+
isSharedSliceModel(modelContents) &&
|
|
38
|
+
modelContents.id === data.sliceID
|
|
39
|
+
) {
|
|
40
|
+
return modelContents;
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
modelReadErrors.push(modelPath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
)
|
|
48
|
+
).filter((model): model is NonNullable<typeof model> => Boolean(model));
|
|
49
|
+
|
|
50
|
+
if (model) {
|
|
51
|
+
return {
|
|
52
|
+
model,
|
|
53
|
+
};
|
|
54
|
+
} else {
|
|
55
|
+
if (modelReadErrors.length) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Did not find a Slice model with ID "${data.sliceID}" in the "${
|
|
58
|
+
data.libraryID
|
|
59
|
+
}" Slice Library.\n\nThose Slice models could not be read:\n - ${modelReadErrors.join(
|
|
60
|
+
"\n - ",
|
|
61
|
+
)}`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Did not find a Slice model with ID "${data.sliceID}" in the "${data.libraryID}" Slice Library.`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { SliceRenameHook } from "@slicemachine/plugin-kit";
|
|
2
|
+
import * as fse from "fs-extra";
|
|
3
|
+
|
|
4
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath";
|
|
5
|
+
import { rejectIfNecessary } from "../lib/rejectIfNecessary";
|
|
6
|
+
import { updateSliceModelFile } from "../lib/updateSliceModelFile";
|
|
7
|
+
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
|
|
8
|
+
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile";
|
|
9
|
+
|
|
10
|
+
import type { PluginOptions } from "../types";
|
|
11
|
+
|
|
12
|
+
export const sliceRename: SliceRenameHook<PluginOptions> = async (
|
|
13
|
+
data,
|
|
14
|
+
context,
|
|
15
|
+
) => {
|
|
16
|
+
const { model: currentModel } = await context.actions.readSliceModel({
|
|
17
|
+
libraryID: data.libraryID,
|
|
18
|
+
sliceID: data.model.id,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await fse.move(
|
|
22
|
+
buildSliceDirectoryPath({
|
|
23
|
+
libraryID: data.libraryID,
|
|
24
|
+
model: currentModel,
|
|
25
|
+
helpers: context.helpers,
|
|
26
|
+
}),
|
|
27
|
+
buildSliceDirectoryPath({
|
|
28
|
+
libraryID: data.libraryID,
|
|
29
|
+
model: data.model,
|
|
30
|
+
helpers: context.helpers,
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
await updateSliceModelFile({
|
|
35
|
+
libraryID: data.libraryID,
|
|
36
|
+
model: data.model,
|
|
37
|
+
...context,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
rejectIfNecessary(
|
|
41
|
+
await Promise.allSettled([
|
|
42
|
+
upsertGlobalContentTypes(context),
|
|
43
|
+
upsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),
|
|
44
|
+
]),
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SliceUpdateHook } from "@slicemachine/plugin-kit";
|
|
2
|
+
|
|
3
|
+
import { updateSliceModelFile } from "../lib/updateSliceModelFile";
|
|
4
|
+
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
|
|
5
|
+
|
|
6
|
+
import type { PluginOptions } from "../types";
|
|
7
|
+
|
|
8
|
+
export const sliceUpdate: SliceUpdateHook<PluginOptions> = async (
|
|
9
|
+
data,
|
|
10
|
+
context,
|
|
11
|
+
) => {
|
|
12
|
+
await updateSliceModelFile({
|
|
13
|
+
libraryID: data.libraryID,
|
|
14
|
+
model: data.model,
|
|
15
|
+
...context,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
await upsertGlobalContentTypes(context);
|
|
19
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { SliceLibraryReadHook } from "@slicemachine/plugin-kit";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { buildSliceLibraryDirectoryPath } from "../lib/buildSliceLibraryDirectoryPath";
|
|
6
|
+
import { isSharedSliceModel } from "../lib/isSharedSliceModel";
|
|
7
|
+
import { readJSONFile } from "../lib/readJSONFile";
|
|
8
|
+
|
|
9
|
+
import type { PluginOptions } from "../types";
|
|
10
|
+
|
|
11
|
+
export const sliceLibraryRead: SliceLibraryReadHook<PluginOptions> = async (
|
|
12
|
+
data,
|
|
13
|
+
{ helpers },
|
|
14
|
+
) => {
|
|
15
|
+
const dir = buildSliceLibraryDirectoryPath({
|
|
16
|
+
libraryID: data.libraryID,
|
|
17
|
+
helpers,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Ensure the directory exists.
|
|
21
|
+
await fs.mkdir(dir, { recursive: true });
|
|
22
|
+
|
|
23
|
+
const childDirs = await fs.readdir(dir, { withFileTypes: true });
|
|
24
|
+
|
|
25
|
+
const sliceIDs: string[] = [];
|
|
26
|
+
await Promise.all(
|
|
27
|
+
childDirs.map(async (childDir) => {
|
|
28
|
+
if (childDir.isDirectory()) {
|
|
29
|
+
const modelPath = path.join(dir, childDir.name, "model.json");
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const modelContents = await readJSONFile(modelPath);
|
|
33
|
+
|
|
34
|
+
if (isSharedSliceModel(modelContents)) {
|
|
35
|
+
sliceIDs.push(modelContents.id);
|
|
36
|
+
}
|
|
37
|
+
} catch {
|
|
38
|
+
// noop
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
id: data.libraryID,
|
|
46
|
+
sliceIDs: sliceIDs.sort(),
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SliceMachineContext,
|
|
3
|
+
SliceSimulatorSetupReadHook,
|
|
4
|
+
SliceSimulatorSetupStep,
|
|
5
|
+
} from "@slicemachine/plugin-kit";
|
|
6
|
+
import { source } from "common-tags";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import fetch, { Response } from "node-fetch";
|
|
9
|
+
|
|
10
|
+
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
|
|
11
|
+
|
|
12
|
+
import type { PluginOptions } from "../types";
|
|
13
|
+
|
|
14
|
+
const REQUIRED_DEPENDENCIES = ["@nuxtjs/prismic"];
|
|
15
|
+
|
|
16
|
+
type Args = SliceMachineContext<PluginOptions>;
|
|
17
|
+
|
|
18
|
+
const createStep1 = async ({
|
|
19
|
+
project,
|
|
20
|
+
helpers,
|
|
21
|
+
}: Args): Promise<SliceSimulatorSetupStep> => {
|
|
22
|
+
const require = createRequire(project.root);
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
title: "Install packages",
|
|
26
|
+
description: "The simulator requires some dependencies.",
|
|
27
|
+
// TODO: Create a plugin runner helper to provide the correct
|
|
28
|
+
// package manager
|
|
29
|
+
body: source`
|
|
30
|
+
The simulator requires extra dependencies. Run the following command to install them.
|
|
31
|
+
|
|
32
|
+
~~~sh
|
|
33
|
+
npm install --save ${REQUIRED_DEPENDENCIES.join(" ")}
|
|
34
|
+
~~~
|
|
35
|
+
`,
|
|
36
|
+
validate: async () => {
|
|
37
|
+
const missingDependencies: string[] = [];
|
|
38
|
+
|
|
39
|
+
for (const dependency of REQUIRED_DEPENDENCIES) {
|
|
40
|
+
try {
|
|
41
|
+
// `require.resolve()` is preferred
|
|
42
|
+
// over `import()` because we don't
|
|
43
|
+
// want to load the module. Loading a
|
|
44
|
+
// module could introduce side-effects.
|
|
45
|
+
require.resolve(dependency, {
|
|
46
|
+
paths: [helpers.joinPathFromRoot("node_modules")],
|
|
47
|
+
});
|
|
48
|
+
} catch {
|
|
49
|
+
missingDependencies.push(dependency);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (missingDependencies.length >= REQUIRED_DEPENDENCIES.length) {
|
|
54
|
+
return {
|
|
55
|
+
title: "Missing all dependencies",
|
|
56
|
+
message: source`
|
|
57
|
+
Install the required dependencies to continue.
|
|
58
|
+
`,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (missingDependencies.length > 0) {
|
|
63
|
+
const formattedMissingDependencies = missingDependencies
|
|
64
|
+
.map((missingDependency) => `\`${missingDependency}\``)
|
|
65
|
+
.join(", ");
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
title: "Missing some dependencies",
|
|
69
|
+
message: source`
|
|
70
|
+
The following dependencies are missing: ${formattedMissingDependencies}
|
|
71
|
+
`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const createStep2 = async ({
|
|
79
|
+
helpers,
|
|
80
|
+
options,
|
|
81
|
+
}: Args): Promise<SliceSimulatorSetupStep> => {
|
|
82
|
+
const isTypeScriptProject = await checkIsTypeScriptProject({
|
|
83
|
+
helpers,
|
|
84
|
+
options,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const fileName = "slice-simulator.vue";
|
|
88
|
+
const filePath = helpers.joinPathFromRoot("pages", fileName);
|
|
89
|
+
|
|
90
|
+
const scriptAttributes = ["setup"];
|
|
91
|
+
if (isTypeScriptProject) {
|
|
92
|
+
scriptAttributes.push('lang="ts"');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const fileContents = await helpers.format(
|
|
96
|
+
source`
|
|
97
|
+
<template>
|
|
98
|
+
<SliceSimulator #default="{ slices }">
|
|
99
|
+
<SliceZone :slices="slices" :components="components" />
|
|
100
|
+
</SliceSimulator>
|
|
101
|
+
</template>
|
|
102
|
+
|
|
103
|
+
<script ${scriptAttributes.join(" ")}>
|
|
104
|
+
import { SliceSimulator } from "@slicemachine/adapter-nuxt/simulator";
|
|
105
|
+
import { components } from "~/slices";
|
|
106
|
+
</script>
|
|
107
|
+
`,
|
|
108
|
+
filePath,
|
|
109
|
+
{
|
|
110
|
+
includeNewlineAtEnd: false,
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
title: "Create a page for the simulator",
|
|
116
|
+
description: `In your \`pages\` directory, create a file called \`${fileName}\` containing this code.`,
|
|
117
|
+
body: source`
|
|
118
|
+
In your \`pages\` directory, create a file called \`${fileName}\` and add the following code. This route will be used to simulate and develop your components.
|
|
119
|
+
|
|
120
|
+
~~~vue
|
|
121
|
+
${fileContents}
|
|
122
|
+
~~~
|
|
123
|
+
`,
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const createStep3 = async ({
|
|
128
|
+
helpers,
|
|
129
|
+
}: Args): Promise<SliceSimulatorSetupStep> => {
|
|
130
|
+
const filePath = helpers.joinPathFromRoot("slicemachine.config.json");
|
|
131
|
+
const fileContents = await helpers.format(
|
|
132
|
+
source`
|
|
133
|
+
{
|
|
134
|
+
"localSliceSimulatorURL": "http://localhost:3000/slice-simulator"
|
|
135
|
+
}
|
|
136
|
+
`,
|
|
137
|
+
filePath,
|
|
138
|
+
{
|
|
139
|
+
includeNewlineAtEnd: false,
|
|
140
|
+
},
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
title: "Update `slicemachine.config.json`",
|
|
145
|
+
description: `Update your \`slicemachine.config.json\` file with a \`localSliceSimulatorURL\` property pointing to your \`/slice-simulator\` page.`,
|
|
146
|
+
body: source`
|
|
147
|
+
Update your \`slicemachine.config.json\` file with a \`localSliceSimulatorURL\` property pointing to your \`/slice-simulator\` page.
|
|
148
|
+
|
|
149
|
+
~~~json
|
|
150
|
+
${fileContents}
|
|
151
|
+
~~~
|
|
152
|
+
`,
|
|
153
|
+
validate: async () => {
|
|
154
|
+
const project = await helpers.getProject();
|
|
155
|
+
|
|
156
|
+
if (!("localSliceSimulatorURL" in project.config)) {
|
|
157
|
+
return {
|
|
158
|
+
title: "Missing `localSliceSimulatorURL` property",
|
|
159
|
+
message: source`
|
|
160
|
+
A \`localSliceSimulatorURL\` property was not found in your \`slicemachine.config.json\` file.
|
|
161
|
+
`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Test if the URL is valid.
|
|
166
|
+
try {
|
|
167
|
+
if (project.config.localSliceSimulatorURL) {
|
|
168
|
+
new URL(project.config.localSliceSimulatorURL);
|
|
169
|
+
} else {
|
|
170
|
+
throw new Error("Undefined Slice Simulator URL");
|
|
171
|
+
}
|
|
172
|
+
} catch {
|
|
173
|
+
return {
|
|
174
|
+
title: "An invalid URL was provided",
|
|
175
|
+
message: source`
|
|
176
|
+
The \`localSliceSimulatorURL\` property should be of the shape \`http://localhost:PORT/PATH\`. See the codeblock for an example.
|
|
177
|
+
`,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Check if the URL is accessible.
|
|
182
|
+
let res: Response | undefined = undefined;
|
|
183
|
+
try {
|
|
184
|
+
res = await fetch(project.config.localSliceSimulatorURL);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
// Noop, we return if `res` is not defined
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (!res || !res.ok) {
|
|
190
|
+
return {
|
|
191
|
+
title: "Unable to connect to simulator page",
|
|
192
|
+
message: source`
|
|
193
|
+
Check that the \`localSliceSimulatorURL\` property in \`slicemachine.config.json\` is correct and try again. See the [troubleshooting page](https://prismic.io/docs/nuxt-setup) for more details.
|
|
194
|
+
`,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const sliceSimulatorSetupRead: SliceSimulatorSetupReadHook<
|
|
202
|
+
PluginOptions
|
|
203
|
+
> = async (_data, context) => {
|
|
204
|
+
return Promise.all([
|
|
205
|
+
createStep1(context),
|
|
206
|
+
createStep2(context),
|
|
207
|
+
createStep3(context),
|
|
208
|
+
]);
|
|
209
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SliceMachineHelpers,
|
|
3
|
+
SnippetReadHook,
|
|
4
|
+
} from "@slicemachine/plugin-kit";
|
|
5
|
+
import { stripIndent } from "common-tags";
|
|
6
|
+
|
|
7
|
+
import type { PluginOptions } from "../types";
|
|
8
|
+
|
|
9
|
+
const dotPath = (segments: string[]): string => {
|
|
10
|
+
return segments.join(".");
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const format = async (input: string, helpers: SliceMachineHelpers) => {
|
|
14
|
+
const formattedInput = await helpers.format(input, undefined, {
|
|
15
|
+
includeNewlineAtEnd: false,
|
|
16
|
+
prettier: {
|
|
17
|
+
parser: "vue",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return formattedInput.endsWith(";")
|
|
22
|
+
? formattedInput.substring(0, formattedInput.length - 1)
|
|
23
|
+
: formattedInput;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const snippetRead: SnippetReadHook<PluginOptions> = async (
|
|
27
|
+
data,
|
|
28
|
+
{ helpers },
|
|
29
|
+
) => {
|
|
30
|
+
const { fieldPath } = data;
|
|
31
|
+
|
|
32
|
+
const label = "Vue";
|
|
33
|
+
|
|
34
|
+
switch (data.model.type) {
|
|
35
|
+
case "StructuredText": {
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
label: `${label} (rich)`,
|
|
39
|
+
language: "vue",
|
|
40
|
+
code: await format(
|
|
41
|
+
stripIndent`
|
|
42
|
+
<PrismicRichText :field="${dotPath(fieldPath)}" />
|
|
43
|
+
`,
|
|
44
|
+
helpers,
|
|
45
|
+
),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: `${label} (plain)`,
|
|
49
|
+
language: "vue",
|
|
50
|
+
code: await format(
|
|
51
|
+
stripIndent`
|
|
52
|
+
<PrismicText :field="${dotPath(fieldPath)}" />
|
|
53
|
+
`,
|
|
54
|
+
helpers,
|
|
55
|
+
),
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
case "Link": {
|
|
61
|
+
return {
|
|
62
|
+
label,
|
|
63
|
+
language: "vue",
|
|
64
|
+
code: await format(
|
|
65
|
+
stripIndent`
|
|
66
|
+
<PrismicLink :field="${dotPath(fieldPath)}">Link</PrismicLink>
|
|
67
|
+
`,
|
|
68
|
+
helpers,
|
|
69
|
+
),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
case "Image": {
|
|
74
|
+
return {
|
|
75
|
+
label,
|
|
76
|
+
language: "vue",
|
|
77
|
+
code: await format(
|
|
78
|
+
stripIndent`
|
|
79
|
+
<PrismicImage :field="${dotPath(fieldPath)}" />
|
|
80
|
+
`,
|
|
81
|
+
helpers,
|
|
82
|
+
),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
case "Embed": {
|
|
87
|
+
return {
|
|
88
|
+
label,
|
|
89
|
+
language: "vue",
|
|
90
|
+
code: await format(
|
|
91
|
+
stripIndent`
|
|
92
|
+
<PrismicEmbed :field="${dotPath(fieldPath)}" />
|
|
93
|
+
`,
|
|
94
|
+
helpers,
|
|
95
|
+
),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
case "Group": {
|
|
100
|
+
return {
|
|
101
|
+
label,
|
|
102
|
+
language: "vue",
|
|
103
|
+
code: await format(
|
|
104
|
+
stripIndent`
|
|
105
|
+
<template v-for="item in ${dotPath(fieldPath)}">
|
|
106
|
+
{{ item }}
|
|
107
|
+
</template>
|
|
108
|
+
`,
|
|
109
|
+
helpers,
|
|
110
|
+
),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
case "Slices": {
|
|
115
|
+
const code = await format(
|
|
116
|
+
stripIndent`
|
|
117
|
+
<SliceZone
|
|
118
|
+
:slices="${dotPath(fieldPath)}"
|
|
119
|
+
:components="components"
|
|
120
|
+
/>
|
|
121
|
+
`,
|
|
122
|
+
helpers,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
label,
|
|
127
|
+
language: "vue",
|
|
128
|
+
code,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
default: {
|
|
133
|
+
return {
|
|
134
|
+
label,
|
|
135
|
+
language: "vue",
|
|
136
|
+
code: await format(
|
|
137
|
+
stripIndent`
|
|
138
|
+
{{${dotPath(fieldPath)}}}
|
|
139
|
+
`,
|
|
140
|
+
helpers,
|
|
141
|
+
),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { PluginOptions } from "../types";
|
|
5
|
+
|
|
6
|
+
import { buildCustomTypeDirectoryPath } from "./buildCustomTypeDirectoryPath";
|
|
7
|
+
|
|
8
|
+
type BuildCustomTypeAssetPathArgs = {
|
|
9
|
+
customTypeID: string;
|
|
10
|
+
assetID: string;
|
|
11
|
+
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const buildCustomTypeAssetPath = (
|
|
15
|
+
args: BuildCustomTypeAssetPathArgs,
|
|
16
|
+
): string => {
|
|
17
|
+
return path.join(
|
|
18
|
+
buildCustomTypeDirectoryPath({
|
|
19
|
+
customTypeID: args.customTypeID,
|
|
20
|
+
helpers: args.helpers,
|
|
21
|
+
}),
|
|
22
|
+
args.assetID,
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { PluginOptions } from "../types";
|
|
5
|
+
|
|
6
|
+
import { buildCustomTypeLibraryDirectoryPath } from "./buildCustomTypeLibraryDirectoryPath";
|
|
7
|
+
|
|
8
|
+
type BuildCustomTypeDirectoryPathArgs = {
|
|
9
|
+
customTypeID: string;
|
|
10
|
+
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const buildCustomTypeDirectoryPath = (
|
|
14
|
+
args: BuildCustomTypeDirectoryPathArgs,
|
|
15
|
+
): string => {
|
|
16
|
+
return path.join(
|
|
17
|
+
buildCustomTypeLibraryDirectoryPath({ helpers: args.helpers }),
|
|
18
|
+
args.customTypeID,
|
|
19
|
+
);
|
|
20
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
+
|
|
3
|
+
import { PluginOptions } from "../types";
|
|
4
|
+
|
|
5
|
+
type BuildCustomTypeLibraryDirectoryPathArgs = {
|
|
6
|
+
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const buildCustomTypeLibraryDirectoryPath = (
|
|
10
|
+
args: BuildCustomTypeLibraryDirectoryPathArgs,
|
|
11
|
+
): string => {
|
|
12
|
+
return args.helpers.joinPathFromRoot("customtypes");
|
|
13
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { PluginOptions } from "../types";
|
|
5
|
+
|
|
6
|
+
import { buildSliceDirectoryPath } from "./buildSliceDirectoryPath";
|
|
7
|
+
|
|
8
|
+
type BuildSliceAssetPathArgs = {
|
|
9
|
+
libraryID: string;
|
|
10
|
+
sliceID: string;
|
|
11
|
+
assetID: string;
|
|
12
|
+
actions: SliceMachineContext<PluginOptions>["actions"];
|
|
13
|
+
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const buildSliceAssetPath = async (
|
|
17
|
+
args: BuildSliceAssetPathArgs,
|
|
18
|
+
): Promise<string> => {
|
|
19
|
+
const { model } = await args.actions.readSliceModel({
|
|
20
|
+
libraryID: args.libraryID,
|
|
21
|
+
sliceID: args.sliceID,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return path.join(
|
|
25
|
+
buildSliceDirectoryPath({
|
|
26
|
+
libraryID: args.libraryID,
|
|
27
|
+
model,
|
|
28
|
+
helpers: args.helpers,
|
|
29
|
+
}),
|
|
30
|
+
args.assetID,
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
|
|
2
|
+
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { PluginOptions } from "../types";
|
|
6
|
+
|
|
7
|
+
import { buildSliceLibraryDirectoryPath } from "./buildSliceLibraryDirectoryPath";
|
|
8
|
+
import { pascalCase } from "./pascalCase";
|
|
9
|
+
|
|
10
|
+
type BuildSliceDirectoryPathArgs = {
|
|
11
|
+
libraryID: string;
|
|
12
|
+
model: SharedSlice;
|
|
13
|
+
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const buildSliceDirectoryPath = (
|
|
17
|
+
args: BuildSliceDirectoryPathArgs,
|
|
18
|
+
): string => {
|
|
19
|
+
return path.join(
|
|
20
|
+
buildSliceLibraryDirectoryPath({
|
|
21
|
+
libraryID: args.libraryID,
|
|
22
|
+
helpers: args.helpers,
|
|
23
|
+
}),
|
|
24
|
+
pascalCase(args.model.name),
|
|
25
|
+
);
|
|
26
|
+
};
|