@slicemachine/adapter-next 0.0.11 → 0.0.13-dev-plugins-validation.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/LICENSE +1 -1
- package/dist/{node_modules → _node_modules}/data-uri-to-buffer/dist/index.cjs +1 -1
- package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -0
- package/dist/{node_modules → _node_modules}/data-uri-to-buffer/dist/index.js +1 -1
- package/dist/_node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
- package/dist/_node_modules/fetch-blob/file.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/file.js.map +1 -0
- package/dist/_node_modules/fetch-blob/index.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/index.js.map +1 -0
- package/dist/_node_modules/fetch-blob/streams.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/streams.js.map +1 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.cjs.map +1 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.js.map +1 -0
- package/dist/_node_modules/node-domexception/index.cjs.map +1 -0
- package/dist/_node_modules/node-domexception/index.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/body.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/body.js.map +1 -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.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/base.cjs.map +1 -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.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/headers.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/headers.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/index.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/index.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/request.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/request.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/response.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/response.js.map +1 -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.map +1 -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.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/is.cjs.map +1 -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.map +1 -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.map +1 -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.map +1 -0
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
- package/dist/hooks/customType-asset-delete.cjs +6 -1
- package/dist/hooks/customType-asset-delete.cjs.map +1 -1
- package/dist/hooks/customType-asset-delete.js +6 -1
- package/dist/hooks/customType-asset-delete.js.map +1 -1
- package/dist/hooks/customType-asset-read.cjs +6 -1
- package/dist/hooks/customType-asset-read.cjs.map +1 -1
- package/dist/hooks/customType-asset-read.js +6 -1
- package/dist/hooks/customType-asset-read.js.map +1 -1
- package/dist/hooks/customType-asset-update.cjs +6 -1
- package/dist/hooks/customType-asset-update.cjs.map +1 -1
- package/dist/hooks/customType-asset-update.js +6 -1
- package/dist/hooks/customType-asset-update.js.map +1 -1
- package/dist/hooks/customType-create.cjs +5 -1
- package/dist/hooks/customType-create.cjs.map +1 -1
- package/dist/hooks/customType-create.js +5 -1
- package/dist/hooks/customType-create.js.map +1 -1
- package/dist/hooks/customType-delete.cjs +5 -1
- package/dist/hooks/customType-delete.cjs.map +1 -1
- package/dist/hooks/customType-delete.js +5 -1
- package/dist/hooks/customType-delete.js.map +1 -1
- package/dist/hooks/customType-read.cjs +20 -1
- package/dist/hooks/customType-read.cjs.map +1 -1
- package/dist/hooks/customType-read.js +3 -1
- package/dist/hooks/customType-read.js.map +1 -1
- package/dist/hooks/customTypeLibrary-read.cjs +2 -1
- package/dist/hooks/customTypeLibrary-read.cjs.map +1 -1
- package/dist/hooks/customTypeLibrary-read.js +2 -1
- package/dist/hooks/customTypeLibrary-read.js.map +1 -1
- package/dist/hooks/{command-init.cjs → project-init.cjs} +5 -3
- package/dist/hooks/project-init.cjs.map +1 -0
- package/dist/hooks/project-init.d.ts +3 -0
- package/dist/hooks/{command-init.js → project-init.js} +5 -3
- package/dist/hooks/project-init.js.map +1 -0
- package/dist/hooks/slice-asset-delete.cjs +8 -2
- package/dist/hooks/slice-asset-delete.cjs.map +1 -1
- package/dist/hooks/slice-asset-delete.js +8 -2
- package/dist/hooks/slice-asset-delete.js.map +1 -1
- package/dist/hooks/slice-asset-read.cjs +8 -2
- package/dist/hooks/slice-asset-read.cjs.map +1 -1
- package/dist/hooks/slice-asset-read.js +8 -2
- package/dist/hooks/slice-asset-read.js.map +1 -1
- package/dist/hooks/slice-asset-update.cjs +8 -2
- package/dist/hooks/slice-asset-update.cjs.map +1 -1
- package/dist/hooks/slice-asset-update.js +8 -2
- package/dist/hooks/slice-asset-update.js.map +1 -1
- package/dist/hooks/slice-create.cjs +12 -10
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +12 -10
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/hooks/slice-delete.cjs +6 -2
- package/dist/hooks/slice-delete.cjs.map +1 -1
- package/dist/hooks/slice-delete.js +6 -2
- package/dist/hooks/slice-delete.js.map +1 -1
- package/dist/hooks/slice-read.cjs +5 -1
- package/dist/hooks/slice-read.cjs.map +1 -1
- package/dist/hooks/slice-read.js +5 -1
- package/dist/hooks/slice-read.js.map +1 -1
- package/dist/hooks/slice-rename.cjs +10 -2
- package/dist/hooks/slice-rename.cjs.map +1 -1
- package/dist/hooks/slice-rename.js +10 -2
- package/dist/hooks/slice-rename.js.map +1 -1
- package/dist/hooks/sliceLibrary-read.cjs +5 -1
- package/dist/hooks/sliceLibrary-read.cjs.map +1 -1
- package/dist/hooks/sliceLibrary-read.js +5 -1
- package/dist/hooks/sliceLibrary-read.js.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.cjs +1 -1
- package/dist/hooks/sliceSimulator-setup-read.js +1 -1
- 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/updateSliceModelFile.cjs +4 -2
- package/dist/lib/updateSliceModelFile.cjs.map +1 -1
- package/dist/lib/updateSliceModelFile.js +3 -2
- package/dist/lib/updateSliceModelFile.js.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +7 -1
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js +6 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -1
- package/dist/plugin.cjs +3 -3
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +3 -3
- package/dist/plugin.js.map +1 -1
- package/package.json +18 -14
- package/src/hooks/customType-asset-delete.ts +7 -5
- package/src/hooks/customType-asset-read.ts +7 -5
- package/src/hooks/customType-asset-update.ts +7 -5
- package/src/hooks/customType-create.ts +5 -1
- package/src/hooks/customType-delete.ts +5 -1
- package/src/hooks/customType-read.ts +4 -3
- package/src/hooks/customTypeLibrary-read.ts +2 -1
- package/src/hooks/{command-init.ts → project-init.ts} +6 -4
- package/src/hooks/slice-asset-delete.ts +8 -6
- package/src/hooks/slice-asset-read.ts +8 -6
- package/src/hooks/slice-asset-update.ts +8 -6
- package/src/hooks/slice-create.ts +12 -17
- package/src/hooks/slice-delete.ts +6 -5
- package/src/hooks/slice-read.ts +5 -1
- package/src/hooks/slice-rename.ts +11 -9
- package/src/hooks/sliceLibrary-read.ts +5 -1
- 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/updateSliceModelFile.ts +5 -4
- package/src/lib/upsertSliceLibraryIndexFile.ts +7 -2
- package/src/plugin.ts +2 -2
- package/dist/hooks/command-init.cjs.map +0 -1
- package/dist/hooks/command-init.d.ts +0 -3
- package/dist/hooks/command-init.js.map +0 -1
- package/dist/node_modules/data-uri-to-buffer/dist/index.cjs.map +0 -1
- package/dist/node_modules/data-uri-to-buffer/dist/index.js.map +0 -1
- package/dist/node_modules/fetch-blob/file.cjs.map +0 -1
- package/dist/node_modules/fetch-blob/file.js.map +0 -1
- package/dist/node_modules/fetch-blob/index.cjs.map +0 -1
- package/dist/node_modules/fetch-blob/index.js.map +0 -1
- package/dist/node_modules/fetch-blob/streams.cjs.map +0 -1
- package/dist/node_modules/fetch-blob/streams.js.map +0 -1
- package/dist/node_modules/formdata-polyfill/esm.min.cjs.map +0 -1
- package/dist/node_modules/formdata-polyfill/esm.min.js.map +0 -1
- package/dist/node_modules/node-domexception/index.cjs.map +0 -1
- package/dist/node_modules/node-domexception/index.js.map +0 -1
- package/dist/node_modules/node-fetch/src/body.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/body.js.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/abort-error.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/abort-error.js.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/base.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/base.js.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/fetch-error.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/fetch-error.js.map +0 -1
- package/dist/node_modules/node-fetch/src/headers.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/headers.js.map +0 -1
- package/dist/node_modules/node-fetch/src/index.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/index.js.map +0 -1
- package/dist/node_modules/node-fetch/src/request.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/request.js.map +0 -1
- package/dist/node_modules/node-fetch/src/response.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/response.js.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/get-search.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/get-search.js.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/is-redirect.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/is-redirect.js.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/is.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/is.js.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.js.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/referrer.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/referrer.js.map +0 -1
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +0 -1
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +0 -1
- /package/dist/{node_modules → _node_modules}/fetch-blob/file.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/fetch-blob/file.js +0 -0
- /package/dist/{node_modules → _node_modules}/fetch-blob/index.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/fetch-blob/index.js +0 -0
- /package/dist/{node_modules → _node_modules}/fetch-blob/streams.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/fetch-blob/streams.js +0 -0
- /package/dist/{node_modules → _node_modules}/formdata-polyfill/esm.min.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/formdata-polyfill/esm.min.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-domexception/index.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-domexception/index.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/body.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/body.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/abort-error.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/abort-error.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/base.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/base.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/fetch-error.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/fetch-error.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/headers.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/headers.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/index.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/index.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/request.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/request.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/response.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/response.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/get-search.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/get-search.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/is-redirect.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/is-redirect.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/is.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/is.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/multipart-parser.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/multipart-parser.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/referrer.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/referrer.js +0 -0
- /package/dist/{node_modules → _node_modules}/web-streams-polyfill/dist/ponyfill.es2018.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/web-streams-polyfill/dist/ponyfill.es2018.js +0 -0
- /package/dist/{package.json.cjs → packages/adapter-next/package.json.cjs} +0 -0
- /package/dist/{package.json.cjs.map → packages/adapter-next/package.json.cjs.map} +0 -0
- /package/dist/{package.json.js → packages/adapter-next/package.json.js} +0 -0
- /package/dist/{package.json.js.map → packages/adapter-next/package.json.js.map} +0 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { CustomTypeAssetDeleteHook } from "@slicemachine/plugin-kit";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
|
|
4
|
+
import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath";
|
|
5
|
+
|
|
4
6
|
import type { PluginOptions } from "../types";
|
|
5
7
|
|
|
6
8
|
export const customTypeAssetDelete: CustomTypeAssetDeleteHook<
|
|
7
9
|
PluginOptions
|
|
8
10
|
> = async (data, context) => {
|
|
9
|
-
const filePath =
|
|
10
|
-
|
|
11
|
-
data.
|
|
12
|
-
|
|
13
|
-
);
|
|
11
|
+
const filePath = buildCustomTypeAssetPath({
|
|
12
|
+
customTypeID: data.customTypeID,
|
|
13
|
+
assetID: data.assetID,
|
|
14
|
+
helpers: context.helpers,
|
|
15
|
+
});
|
|
14
16
|
|
|
15
17
|
await fs.rm(filePath);
|
|
16
18
|
};
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { CustomTypeAssetReadHook } from "@slicemachine/plugin-kit";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
|
|
4
|
+
import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath";
|
|
5
|
+
|
|
4
6
|
import type { PluginOptions } from "../types";
|
|
5
7
|
|
|
6
8
|
export const customTypeAssetRead: CustomTypeAssetReadHook<
|
|
7
9
|
PluginOptions
|
|
8
10
|
> = async (data, context) => {
|
|
9
|
-
const filePath =
|
|
10
|
-
|
|
11
|
-
data.
|
|
12
|
-
|
|
13
|
-
);
|
|
11
|
+
const filePath = buildCustomTypeAssetPath({
|
|
12
|
+
customTypeID: data.customTypeID,
|
|
13
|
+
assetID: data.assetID,
|
|
14
|
+
helpers: context.helpers,
|
|
15
|
+
});
|
|
14
16
|
|
|
15
17
|
const assetData = await fs.readFile(filePath);
|
|
16
18
|
|
|
@@ -2,16 +2,18 @@ import type { CustomTypeAssetUpdateHook } from "@slicemachine/plugin-kit";
|
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
|
|
5
|
+
import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath";
|
|
6
|
+
|
|
5
7
|
import type { PluginOptions } from "../types";
|
|
6
8
|
|
|
7
9
|
export const customTypeAssetUpdate: CustomTypeAssetUpdateHook<
|
|
8
10
|
PluginOptions
|
|
9
11
|
> = async (data, context) => {
|
|
10
|
-
const filePath =
|
|
11
|
-
|
|
12
|
-
data.
|
|
13
|
-
|
|
14
|
-
);
|
|
12
|
+
const filePath = buildCustomTypeAssetPath({
|
|
13
|
+
customTypeID: data.customTypeID,
|
|
14
|
+
assetID: data.asset.id,
|
|
15
|
+
helpers: context.helpers,
|
|
16
|
+
});
|
|
15
17
|
|
|
16
18
|
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
17
19
|
await fs.writeFile(filePath, data.asset.data);
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
import * as fs from "node:fs/promises";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
|
|
9
|
+
import { buildCustomTypeDirectoryPath } from "../lib/buildCustomTypeDirectoryPath";
|
|
9
10
|
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
|
|
10
11
|
|
|
11
12
|
import type { PluginOptions } from "../types";
|
|
@@ -31,7 +32,10 @@ export const customTypeCreate: CustomTypeCreateHook<PluginOptions> = async (
|
|
|
31
32
|
data,
|
|
32
33
|
context,
|
|
33
34
|
) => {
|
|
34
|
-
const dir =
|
|
35
|
+
const dir = buildCustomTypeDirectoryPath({
|
|
36
|
+
customTypeID: data.model.id,
|
|
37
|
+
helpers: context.helpers,
|
|
38
|
+
});
|
|
35
39
|
|
|
36
40
|
await fs.mkdir(dir, { recursive: true });
|
|
37
41
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CustomTypeDeleteHook } from "@slicemachine/plugin-kit";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
|
|
4
|
+
import { buildCustomTypeDirectoryPath } from "../lib/buildCustomTypeDirectoryPath";
|
|
4
5
|
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
|
|
5
6
|
|
|
6
7
|
import type { PluginOptions } from "../types";
|
|
@@ -9,7 +10,10 @@ export const customTypeDelete: CustomTypeDeleteHook<PluginOptions> = async (
|
|
|
9
10
|
data,
|
|
10
11
|
context,
|
|
11
12
|
) => {
|
|
12
|
-
const dir =
|
|
13
|
+
const dir = buildCustomTypeDirectoryPath({
|
|
14
|
+
customTypeID: data.model.id,
|
|
15
|
+
helpers: context.helpers,
|
|
16
|
+
});
|
|
13
17
|
|
|
14
18
|
await fs.rm(dir, { recursive: true });
|
|
15
19
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CustomTypeReadHook } from "@slicemachine/plugin-kit";
|
|
2
2
|
import * as prismicT from "@prismicio/types";
|
|
3
|
+
import * as path from "node:path";
|
|
3
4
|
|
|
5
|
+
import { buildCustomTypeDirectoryPath } from "../lib/buildCustomTypeDirectoryPath";
|
|
4
6
|
import { readJSONFile } from "../lib/readJSONFile";
|
|
5
7
|
|
|
6
8
|
import type { PluginOptions } from "../types";
|
|
@@ -9,9 +11,8 @@ export const customTypeRead: CustomTypeReadHook<PluginOptions> = async (
|
|
|
9
11
|
data,
|
|
10
12
|
{ helpers },
|
|
11
13
|
) => {
|
|
12
|
-
const filePath =
|
|
13
|
-
|
|
14
|
-
data.id,
|
|
14
|
+
const filePath = path.join(
|
|
15
|
+
buildCustomTypeDirectoryPath({ customTypeID: data.id, helpers }),
|
|
15
16
|
"index.json",
|
|
16
17
|
);
|
|
17
18
|
|
|
@@ -3,6 +3,7 @@ import * as prismicT from "@prismicio/types";
|
|
|
3
3
|
import * as fs from "node:fs/promises";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
|
|
6
|
+
import { buildCustomTypeLibraryDirectoryPath } from "../lib/buildCustomTypeLibraryDirectoryPath";
|
|
6
7
|
import { readJSONFile } from "../lib/readJSONFile";
|
|
7
8
|
|
|
8
9
|
import type { PluginOptions } from "../types";
|
|
@@ -17,7 +18,7 @@ const isCustomTypeModel = (
|
|
|
17
18
|
export const customTypeLibraryRead: CustomTypeLibraryReadHook<
|
|
18
19
|
PluginOptions
|
|
19
20
|
> = async (_data, { helpers }) => {
|
|
20
|
-
const dirPath = helpers
|
|
21
|
+
const dirPath = buildCustomTypeLibraryDirectoryPath({ helpers });
|
|
21
22
|
|
|
22
23
|
// Ensure the directory exists.
|
|
23
24
|
await fs.mkdir(dirPath, { recursive: true });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import type {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
ProjectInitHook,
|
|
5
|
+
ProjectInitHookData,
|
|
6
6
|
SliceMachineContext,
|
|
7
7
|
} from "@slicemachine/plugin-kit";
|
|
8
8
|
import { stripIndent } from "common-tags";
|
|
@@ -15,7 +15,7 @@ import type { PluginOptions } from "../types";
|
|
|
15
15
|
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
|
|
16
16
|
|
|
17
17
|
type InstallDependenciesArgs = {
|
|
18
|
-
installDependencies:
|
|
18
|
+
installDependencies: ProjectInitHookData["installDependencies"];
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const installDependencies = async ({
|
|
@@ -24,6 +24,8 @@ const installDependencies = async ({
|
|
|
24
24
|
await installDependencies({
|
|
25
25
|
dependencies: {
|
|
26
26
|
"@prismicio/client": "latest",
|
|
27
|
+
"@prismicio/helpers": "latest",
|
|
28
|
+
"@prismicio/react": "latest",
|
|
27
29
|
"@prismicio/next": "latest",
|
|
28
30
|
},
|
|
29
31
|
});
|
|
@@ -213,7 +215,7 @@ const createSliceSimulatorPage = async ({
|
|
|
213
215
|
await fs.writeFile(filePath, contents);
|
|
214
216
|
};
|
|
215
217
|
|
|
216
|
-
export const
|
|
218
|
+
export const projectInit: ProjectInitHook<PluginOptions> = async (
|
|
217
219
|
{ installDependencies: _installDependencies },
|
|
218
220
|
context,
|
|
219
221
|
) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SliceAssetDeleteHook } from "@slicemachine/plugin-kit";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { buildSliceAssetPath } from "../lib/buildSliceAssetPath";
|
|
5
5
|
|
|
6
6
|
import type { PluginOptions } from "../types";
|
|
7
7
|
|
|
@@ -9,11 +9,13 @@ export const sliceAssetDelete: SliceAssetDeleteHook<PluginOptions> = async (
|
|
|
9
9
|
data,
|
|
10
10
|
context,
|
|
11
11
|
) => {
|
|
12
|
-
const filePath =
|
|
13
|
-
data.libraryID,
|
|
14
|
-
|
|
15
|
-
data.assetID,
|
|
16
|
-
|
|
12
|
+
const filePath = await buildSliceAssetPath({
|
|
13
|
+
libraryID: data.libraryID,
|
|
14
|
+
sliceID: data.sliceID,
|
|
15
|
+
assetID: data.assetID,
|
|
16
|
+
helpers: context.helpers,
|
|
17
|
+
actions: context.actions,
|
|
18
|
+
});
|
|
17
19
|
|
|
18
20
|
await fs.rm(filePath);
|
|
19
21
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SliceAssetReadHook } from "@slicemachine/plugin-kit";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { buildSliceAssetPath } from "../lib/buildSliceAssetPath";
|
|
5
5
|
|
|
6
6
|
import type { PluginOptions } from "../types";
|
|
7
7
|
|
|
@@ -9,11 +9,13 @@ export const sliceAssetRead: SliceAssetReadHook<PluginOptions> = async (
|
|
|
9
9
|
data,
|
|
10
10
|
context,
|
|
11
11
|
) => {
|
|
12
|
-
const filePath =
|
|
13
|
-
data.libraryID,
|
|
14
|
-
|
|
15
|
-
data.assetID,
|
|
16
|
-
|
|
12
|
+
const filePath = await buildSliceAssetPath({
|
|
13
|
+
libraryID: data.libraryID,
|
|
14
|
+
sliceID: data.sliceID,
|
|
15
|
+
assetID: data.assetID,
|
|
16
|
+
helpers: context.helpers,
|
|
17
|
+
actions: context.actions,
|
|
18
|
+
});
|
|
17
19
|
|
|
18
20
|
const assetData = await fs.readFile(filePath);
|
|
19
21
|
|
|
@@ -2,7 +2,7 @@ import type { SliceAssetUpdateHook } from "@slicemachine/plugin-kit";
|
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { buildSliceAssetPath } from "../lib/buildSliceAssetPath";
|
|
6
6
|
|
|
7
7
|
import type { PluginOptions } from "../types";
|
|
8
8
|
|
|
@@ -10,11 +10,13 @@ export const sliceAssetUpdate: SliceAssetUpdateHook<PluginOptions> = async (
|
|
|
10
10
|
data,
|
|
11
11
|
context,
|
|
12
12
|
) => {
|
|
13
|
-
const filePath =
|
|
14
|
-
data.libraryID,
|
|
15
|
-
|
|
16
|
-
data.asset.id,
|
|
17
|
-
|
|
13
|
+
const filePath = await buildSliceAssetPath({
|
|
14
|
+
libraryID: data.libraryID,
|
|
15
|
+
sliceID: data.sliceID,
|
|
16
|
+
assetID: data.asset.id,
|
|
17
|
+
helpers: context.helpers,
|
|
18
|
+
actions: context.actions,
|
|
19
|
+
});
|
|
18
20
|
|
|
19
21
|
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
20
22
|
await fs.writeFile(filePath, data.asset.data);
|
|
@@ -7,10 +7,12 @@ import { stripIndent } from "common-tags";
|
|
|
7
7
|
import * as fs from "node:fs/promises";
|
|
8
8
|
import * as path from "node:path";
|
|
9
9
|
|
|
10
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath";
|
|
10
11
|
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
|
|
11
12
|
import { getJSOrTSXFileExtension } from "../lib/getJSOrTSXFileExtension";
|
|
12
13
|
import { pascalCase } from "../lib/pascalCase";
|
|
13
14
|
import { rejectIfNecessary } from "../lib/rejectIfNecessary";
|
|
15
|
+
import { updateSliceModelFile } from "../lib/updateSliceModelFile";
|
|
14
16
|
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
|
|
15
17
|
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile";
|
|
16
18
|
|
|
@@ -21,18 +23,6 @@ type Args = {
|
|
|
21
23
|
data: SliceCreateHookData;
|
|
22
24
|
} & SliceMachineContext<PluginOptions>;
|
|
23
25
|
|
|
24
|
-
const createModelFile = async ({ dir, data, helpers, options }: Args) => {
|
|
25
|
-
const filePath = path.join(dir, "model.json");
|
|
26
|
-
|
|
27
|
-
let contents = JSON.stringify(data.model);
|
|
28
|
-
|
|
29
|
-
if (options.format) {
|
|
30
|
-
contents = await helpers.format(contents, filePath);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
await fs.writeFile(filePath, contents);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
26
|
const createComponentFile = async ({ dir, data, helpers, options }: Args) => {
|
|
37
27
|
const filePath = path.join(
|
|
38
28
|
dir,
|
|
@@ -107,16 +97,21 @@ export const sliceCreate: SliceCreateHook<PluginOptions> = async (
|
|
|
107
97
|
data,
|
|
108
98
|
context,
|
|
109
99
|
) => {
|
|
110
|
-
const dir =
|
|
111
|
-
data.libraryID,
|
|
112
|
-
|
|
113
|
-
|
|
100
|
+
const dir = buildSliceDirectoryPath({
|
|
101
|
+
libraryID: data.libraryID,
|
|
102
|
+
model: data.model,
|
|
103
|
+
helpers: context.helpers,
|
|
104
|
+
});
|
|
114
105
|
|
|
115
106
|
await fs.mkdir(dir, { recursive: true });
|
|
116
107
|
|
|
117
108
|
rejectIfNecessary(
|
|
118
109
|
await Promise.allSettled([
|
|
119
|
-
|
|
110
|
+
updateSliceModelFile({
|
|
111
|
+
libraryID: data.libraryID,
|
|
112
|
+
model: data.model,
|
|
113
|
+
...context,
|
|
114
|
+
}),
|
|
120
115
|
createComponentFile({ dir, data, ...context }),
|
|
121
116
|
]),
|
|
122
117
|
);
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
} from "@slicemachine/plugin-kit";
|
|
6
6
|
import * as fs from "node:fs/promises";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath";
|
|
9
9
|
import { rejectIfNecessary } from "../lib/rejectIfNecessary";
|
|
10
10
|
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
|
|
11
11
|
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile";
|
|
@@ -17,10 +17,11 @@ type Args = {
|
|
|
17
17
|
} & SliceMachineContext<PluginOptions>;
|
|
18
18
|
|
|
19
19
|
const deleteSliceDir = async ({ data, helpers }: Args) => {
|
|
20
|
-
const dir =
|
|
21
|
-
data.libraryID,
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const dir = buildSliceDirectoryPath({
|
|
21
|
+
libraryID: data.libraryID,
|
|
22
|
+
model: data.model,
|
|
23
|
+
helpers,
|
|
24
|
+
});
|
|
24
25
|
|
|
25
26
|
await fs.rm(dir, { recursive: true });
|
|
26
27
|
};
|
package/src/hooks/slice-read.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { SliceReadHook } from "@slicemachine/plugin-kit";
|
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
|
|
5
|
+
import { buildSliceLibraryDirectoryPath } from "../lib/buildSliceLibraryDirectoryPath";
|
|
5
6
|
import { isSharedSliceModel } from "../lib/isSharedSliceModel";
|
|
6
7
|
import { readJSONFile } from "../lib/readJSONFile";
|
|
7
8
|
|
|
@@ -11,7 +12,10 @@ export const sliceRead: SliceReadHook<PluginOptions> = async (
|
|
|
11
12
|
data,
|
|
12
13
|
{ helpers },
|
|
13
14
|
) => {
|
|
14
|
-
const libraryDir =
|
|
15
|
+
const libraryDir = buildSliceLibraryDirectoryPath({
|
|
16
|
+
libraryID: data.libraryID,
|
|
17
|
+
helpers,
|
|
18
|
+
});
|
|
15
19
|
|
|
16
20
|
// Ensure the directory exists.
|
|
17
21
|
await fs.mkdir(libraryDir, { recursive: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SliceRenameHook } from "@slicemachine/plugin-kit";
|
|
2
2
|
import * as fse from "fs-extra";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath";
|
|
5
5
|
import { rejectIfNecessary } from "../lib/rejectIfNecessary";
|
|
6
6
|
import { updateSliceModelFile } from "../lib/updateSliceModelFile";
|
|
7
7
|
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
|
|
@@ -19,14 +19,16 @@ export const sliceRename: SliceRenameHook<PluginOptions> = async (
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
await fse.move(
|
|
22
|
-
|
|
23
|
-
data.libraryID,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
+
}),
|
|
30
32
|
);
|
|
31
33
|
|
|
32
34
|
await updateSliceModelFile({
|
|
@@ -2,6 +2,7 @@ import type { SliceLibraryReadHook } from "@slicemachine/plugin-kit";
|
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
|
|
5
|
+
import { buildSliceLibraryDirectoryPath } from "../lib/buildSliceLibraryDirectoryPath";
|
|
5
6
|
import { isSharedSliceModel } from "../lib/isSharedSliceModel";
|
|
6
7
|
import { readJSONFile } from "../lib/readJSONFile";
|
|
7
8
|
|
|
@@ -11,7 +12,10 @@ export const sliceLibraryRead: SliceLibraryReadHook<PluginOptions> = async (
|
|
|
11
12
|
data,
|
|
12
13
|
{ helpers },
|
|
13
14
|
) => {
|
|
14
|
-
const dir =
|
|
15
|
+
const dir = buildSliceLibraryDirectoryPath({
|
|
16
|
+
libraryID: data.libraryID,
|
|
17
|
+
helpers,
|
|
18
|
+
});
|
|
15
19
|
|
|
16
20
|
// Ensure the directory exists.
|
|
17
21
|
await fs.mkdir(dir, { recursive: true });
|
|
@@ -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 { SharedSliceModel } from "@prismicio/types";
|
|
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: SharedSliceModel;
|
|
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
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
+
|
|
3
|
+
import { PluginOptions } from "../types";
|
|
4
|
+
|
|
5
|
+
type BuildSliceLibraryDirectoryPathArgs = {
|
|
6
|
+
libraryID: string;
|
|
7
|
+
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const buildSliceLibraryDirectoryPath = (
|
|
11
|
+
args: BuildSliceLibraryDirectoryPathArgs,
|
|
12
|
+
): string => {
|
|
13
|
+
return args.helpers.joinPathFromRoot(args.libraryID);
|
|
14
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { SharedSliceModel } from "@prismicio/types";
|
|
2
2
|
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
3
3
|
import * as fs from "node:fs/promises";
|
|
4
|
+
import * as path from "node:path";
|
|
4
5
|
|
|
5
6
|
import type { PluginOptions } from "../types";
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
import { buildSliceDirectoryPath } from "./buildSliceDirectoryPath";
|
|
7
9
|
|
|
8
10
|
type UpdateSliceModelFileArgs = {
|
|
9
11
|
libraryID: string;
|
|
@@ -16,9 +18,8 @@ export const updateSliceModelFile = async ({
|
|
|
16
18
|
helpers,
|
|
17
19
|
options,
|
|
18
20
|
}: UpdateSliceModelFileArgs): Promise<void> => {
|
|
19
|
-
const filePath =
|
|
20
|
-
libraryID,
|
|
21
|
-
pascalCase(model.name),
|
|
21
|
+
const filePath = path.join(
|
|
22
|
+
buildSliceDirectoryPath({ libraryID, model, helpers }),
|
|
22
23
|
"model.json",
|
|
23
24
|
);
|
|
24
25
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
2
|
import { stripIndent } from "common-tags";
|
|
3
3
|
import * as fs from "node:fs/promises";
|
|
4
|
+
import * as path from "node:path";
|
|
4
5
|
import { NON_EDITABLE_FILE_BANNER } from "../constants";
|
|
5
6
|
|
|
6
7
|
import { PluginOptions } from "../types";
|
|
7
8
|
|
|
8
9
|
import { checkIsTypeScriptProject } from "./checkIsTypeScriptProject";
|
|
9
10
|
import { pascalCase } from "./pascalCase";
|
|
11
|
+
import { buildSliceLibraryDirectoryPath } from "./buildSliceLibraryDirectoryPath";
|
|
10
12
|
|
|
11
13
|
type UpsertSliceLibraryIndexFileArgs = {
|
|
12
14
|
libraryID: string;
|
|
@@ -20,8 +22,11 @@ export const upsertSliceLibraryIndexFile = async (
|
|
|
20
22
|
options: args.options,
|
|
21
23
|
});
|
|
22
24
|
|
|
23
|
-
const filePath =
|
|
24
|
-
|
|
25
|
+
const filePath = path.join(
|
|
26
|
+
buildSliceLibraryDirectoryPath({
|
|
27
|
+
libraryID: args.libraryID,
|
|
28
|
+
helpers: args.helpers,
|
|
29
|
+
}),
|
|
25
30
|
isTypeScriptProject ? "index.ts" : "index.js",
|
|
26
31
|
);
|
|
27
32
|
|
package/src/plugin.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { defineSliceMachinePlugin } from "@slicemachine/plugin-kit";
|
|
|
3
3
|
import { name as pkgName } from "../package.json";
|
|
4
4
|
import { PluginOptions } from "./types";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { projectInit } from "./hooks/project-init";
|
|
7
7
|
import { customTypeAssetDelete } from "./hooks/customType-asset-delete";
|
|
8
8
|
import { customTypeAssetRead } from "./hooks/customType-asset-read";
|
|
9
9
|
import { customTypeAssetUpdate } from "./hooks/customType-asset-update";
|
|
@@ -34,7 +34,7 @@ export const plugin = defineSliceMachinePlugin<PluginOptions>({
|
|
|
34
34
|
lazyLoadSlices: true,
|
|
35
35
|
},
|
|
36
36
|
setup({ hook }) {
|
|
37
|
-
hook("
|
|
37
|
+
hook("project:init", projectInit);
|
|
38
38
|
|
|
39
39
|
hook("slice:create", sliceCreate);
|
|
40
40
|
hook("slice:update", sliceUpdate);
|