@slicemachine/adapter-nuxt 0.3.10-dev-next-release.10 → 0.3.10-dev-next-release.11
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/hooks/project-init.cjs +26 -29
- package/dist/hooks/project-init.cjs.map +1 -1
- package/dist/hooks/project-init.js +26 -28
- package/dist/hooks/project-init.js.map +1 -1
- package/dist/hooks/slice-create.cjs +28 -46
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +28 -28
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/lib/checkHasSrcDirectory.cjs +5 -2
- package/dist/lib/checkHasSrcDirectory.cjs.map +1 -1
- package/dist/lib/checkHasSrcDirectory.js +5 -2
- package/dist/lib/checkHasSrcDirectory.js.map +1 -1
- package/dist/lib/checkIsTypeScriptProject.cjs +2 -3
- package/dist/lib/checkIsTypeScriptProject.cjs.map +1 -1
- package/dist/lib/checkIsTypeScriptProject.js +2 -3
- package/dist/lib/checkIsTypeScriptProject.js.map +1 -1
- package/dist/lib/getJSFileExtension.cjs +12 -0
- package/dist/lib/getJSFileExtension.cjs.map +1 -0
- package/dist/lib/getJSFileExtension.d.ts +5 -0
- package/dist/lib/getJSFileExtension.js +12 -0
- package/dist/lib/getJSFileExtension.js.map +1 -0
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +30 -22
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js +30 -21
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -1
- package/dist/plugin.cjs +178 -36
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +178 -36
- package/dist/plugin.js.map +1 -1
- package/dist/types.d.ts +22 -0
- package/package.json +3 -5
- package/src/hooks/project-init.ts +32 -36
- package/src/hooks/slice-create.ts +39 -34
- package/src/lib/checkHasSrcDirectory.ts +5 -2
- package/src/lib/checkIsTypeScriptProject.ts +5 -4
- package/src/lib/getJSFileExtension.ts +22 -0
- package/src/lib/upsertSliceLibraryIndexFile.ts +55 -36
- package/src/plugin.ts +247 -37
- package/src/types.ts +25 -0
- package/dist/hooks/customType-asset-delete.cjs +0 -31
- package/dist/hooks/customType-asset-delete.cjs.map +0 -1
- package/dist/hooks/customType-asset-delete.d.ts +0 -3
- package/dist/hooks/customType-asset-delete.js +0 -14
- package/dist/hooks/customType-asset-delete.js.map +0 -1
- package/dist/hooks/customType-asset-read.cjs +0 -34
- package/dist/hooks/customType-asset-read.cjs.map +0 -1
- package/dist/hooks/customType-asset-read.d.ts +0 -3
- package/dist/hooks/customType-asset-read.js +0 -17
- package/dist/hooks/customType-asset-read.js.map +0 -1
- package/dist/hooks/customType-asset-update.cjs +0 -34
- package/dist/hooks/customType-asset-update.cjs.map +0 -1
- package/dist/hooks/customType-asset-update.d.ts +0 -3
- package/dist/hooks/customType-asset-update.js +0 -16
- package/dist/hooks/customType-asset-update.js.map +0 -1
- package/dist/hooks/customType-create.cjs +0 -43
- package/dist/hooks/customType-create.cjs.map +0 -1
- package/dist/hooks/customType-create.d.ts +0 -3
- package/dist/hooks/customType-create.js +0 -25
- package/dist/hooks/customType-create.js.map +0 -1
- package/dist/hooks/customType-delete.cjs +0 -32
- package/dist/hooks/customType-delete.cjs.map +0 -1
- package/dist/hooks/customType-delete.d.ts +0 -3
- package/dist/hooks/customType-delete.js +0 -15
- package/dist/hooks/customType-delete.js.map +0 -1
- package/dist/hooks/customType-read.cjs +0 -31
- package/dist/hooks/customType-read.cjs.map +0 -1
- package/dist/hooks/customType-read.d.ts +0 -3
- package/dist/hooks/customType-read.js +0 -14
- package/dist/hooks/customType-read.js.map +0 -1
- package/dist/hooks/customType-rename.cjs +0 -6
- package/dist/hooks/customType-rename.cjs.map +0 -1
- package/dist/hooks/customType-rename.d.ts +0 -1
- package/dist/hooks/customType-rename.js +0 -6
- package/dist/hooks/customType-rename.js.map +0 -1
- package/dist/hooks/customType-update.cjs +0 -6
- package/dist/hooks/customType-update.cjs.map +0 -1
- package/dist/hooks/customType-update.d.ts +0 -1
- package/dist/hooks/customType-update.js +0 -6
- package/dist/hooks/customType-update.js.map +0 -1
- package/dist/hooks/customTypeLibrary-read.cjs +0 -55
- package/dist/hooks/customTypeLibrary-read.cjs.map +0 -1
- package/dist/hooks/customTypeLibrary-read.d.ts +0 -3
- package/dist/hooks/customTypeLibrary-read.js +0 -37
- package/dist/hooks/customTypeLibrary-read.js.map +0 -1
- package/dist/hooks/slice-asset-delete.cjs +0 -33
- package/dist/hooks/slice-asset-delete.cjs.map +0 -1
- package/dist/hooks/slice-asset-delete.d.ts +0 -3
- package/dist/hooks/slice-asset-delete.js +0 -16
- package/dist/hooks/slice-asset-delete.js.map +0 -1
- package/dist/hooks/slice-asset-read.cjs +0 -36
- package/dist/hooks/slice-asset-read.cjs.map +0 -1
- package/dist/hooks/slice-asset-read.d.ts +0 -3
- package/dist/hooks/slice-asset-read.js +0 -19
- package/dist/hooks/slice-asset-read.js.map +0 -1
- package/dist/hooks/slice-asset-update.cjs +0 -36
- package/dist/hooks/slice-asset-update.cjs.map +0 -1
- package/dist/hooks/slice-asset-update.d.ts +0 -3
- package/dist/hooks/slice-asset-update.js +0 -18
- package/dist/hooks/slice-asset-update.js.map +0 -1
- package/dist/hooks/slice-delete.cjs +0 -41
- package/dist/hooks/slice-delete.cjs.map +0 -1
- package/dist/hooks/slice-delete.d.ts +0 -3
- package/dist/hooks/slice-delete.js +0 -24
- package/dist/hooks/slice-delete.js.map +0 -1
- package/dist/hooks/slice-read.cjs +0 -62
- package/dist/hooks/slice-read.cjs.map +0 -1
- package/dist/hooks/slice-read.d.ts +0 -3
- package/dist/hooks/slice-read.js +0 -44
- package/dist/hooks/slice-read.js.map +0 -1
- package/dist/hooks/slice-rename.cjs +0 -51
- package/dist/hooks/slice-rename.cjs.map +0 -1
- package/dist/hooks/slice-rename.d.ts +0 -3
- package/dist/hooks/slice-rename.js +0 -34
- package/dist/hooks/slice-rename.js.map +0 -1
- package/dist/hooks/slice-update.cjs +0 -14
- package/dist/hooks/slice-update.cjs.map +0 -1
- package/dist/hooks/slice-update.d.ts +0 -3
- package/dist/hooks/slice-update.js +0 -14
- package/dist/hooks/slice-update.js.map +0 -1
- package/dist/hooks/sliceLibrary-read.cjs +0 -52
- package/dist/hooks/sliceLibrary-read.cjs.map +0 -1
- package/dist/hooks/sliceLibrary-read.d.ts +0 -3
- package/dist/hooks/sliceLibrary-read.js +0 -34
- package/dist/hooks/sliceLibrary-read.js.map +0 -1
- package/dist/lib/buildCustomTypeAssetPath.cjs +0 -29
- package/dist/lib/buildCustomTypeAssetPath.cjs.map +0 -1
- package/dist/lib/buildCustomTypeAssetPath.d.ts +0 -9
- package/dist/lib/buildCustomTypeAssetPath.js +0 -12
- package/dist/lib/buildCustomTypeAssetPath.js.map +0 -1
- package/dist/lib/buildCustomTypeDirectoryPath.cjs +0 -26
- package/dist/lib/buildCustomTypeDirectoryPath.cjs.map +0 -1
- package/dist/lib/buildCustomTypeDirectoryPath.d.ts +0 -8
- package/dist/lib/buildCustomTypeDirectoryPath.js +0 -9
- package/dist/lib/buildCustomTypeDirectoryPath.js.map +0 -1
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs +0 -7
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs.map +0 -1
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.d.ts +0 -7
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.js +0 -7
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.js.map +0 -1
- package/dist/lib/buildSliceAssetPath.cjs +0 -34
- package/dist/lib/buildSliceAssetPath.cjs.map +0 -1
- package/dist/lib/buildSliceAssetPath.d.ts +0 -11
- package/dist/lib/buildSliceAssetPath.js +0 -17
- package/dist/lib/buildSliceAssetPath.js.map +0 -1
- package/dist/lib/buildSliceDirectoryPath.cjs +0 -30
- package/dist/lib/buildSliceDirectoryPath.cjs.map +0 -1
- package/dist/lib/buildSliceDirectoryPath.d.ts +0 -10
- package/dist/lib/buildSliceDirectoryPath.js +0 -13
- package/dist/lib/buildSliceDirectoryPath.js.map +0 -1
- package/dist/lib/buildSliceLibraryDirectoryPath.cjs +0 -7
- package/dist/lib/buildSliceLibraryDirectoryPath.cjs.map +0 -1
- package/dist/lib/buildSliceLibraryDirectoryPath.d.ts +0 -8
- package/dist/lib/buildSliceLibraryDirectoryPath.js +0 -7
- package/dist/lib/buildSliceLibraryDirectoryPath.js.map +0 -1
- package/dist/lib/checkPathExists.cjs +0 -30
- package/dist/lib/checkPathExists.cjs.map +0 -1
- package/dist/lib/checkPathExists.d.ts +0 -2
- package/dist/lib/checkPathExists.js +0 -13
- package/dist/lib/checkPathExists.js.map +0 -1
- package/dist/lib/isSharedSliceModel.cjs +0 -7
- package/dist/lib/isSharedSliceModel.cjs.map +0 -1
- package/dist/lib/isSharedSliceModel.d.ts +0 -335
- package/dist/lib/isSharedSliceModel.js +0 -7
- package/dist/lib/isSharedSliceModel.js.map +0 -1
- package/dist/lib/readJSONFile.cjs +0 -26
- package/dist/lib/readJSONFile.cjs.map +0 -1
- package/dist/lib/readJSONFile.d.ts +0 -1
- package/dist/lib/readJSONFile.js +0 -9
- package/dist/lib/readJSONFile.js.map +0 -1
- package/dist/lib/updateSliceModelFile.cjs +0 -33
- package/dist/lib/updateSliceModelFile.cjs.map +0 -1
- package/dist/lib/updateSliceModelFile.d.ts +0 -9
- package/dist/lib/updateSliceModelFile.js +0 -15
- package/dist/lib/updateSliceModelFile.js.map +0 -1
- package/dist/lib/upsertGlobalContentTypes.cjs +0 -56
- package/dist/lib/upsertGlobalContentTypes.cjs.map +0 -1
- package/dist/lib/upsertGlobalContentTypes.d.ts +0 -12
- package/dist/lib/upsertGlobalContentTypes.js +0 -38
- package/dist/lib/upsertGlobalContentTypes.js.map +0 -1
- package/src/hooks/customType-asset-delete.ts +0 -18
- package/src/hooks/customType-asset-read.ts +0 -22
- package/src/hooks/customType-asset-update.ts +0 -20
- package/src/hooks/customType-create.ts +0 -45
- package/src/hooks/customType-delete.ts +0 -21
- package/src/hooks/customType-read.ts +0 -24
- package/src/hooks/customType-rename.ts +0 -3
- package/src/hooks/customType-update.ts +0 -3
- package/src/hooks/customTypeLibrary-read.ts +0 -58
- package/src/hooks/slice-asset-delete.ts +0 -21
- package/src/hooks/slice-asset-read.ts +0 -25
- package/src/hooks/slice-asset-update.ts +0 -23
- package/src/hooks/slice-delete.ts +0 -41
- package/src/hooks/slice-read.ts +0 -69
- package/src/hooks/slice-rename.ts +0 -46
- package/src/hooks/slice-update.ts +0 -19
- package/src/hooks/sliceLibrary-read.ts +0 -48
- package/src/lib/buildCustomTypeAssetPath.ts +0 -24
- package/src/lib/buildCustomTypeDirectoryPath.ts +0 -20
- package/src/lib/buildCustomTypeLibraryDirectoryPath.ts +0 -13
- package/src/lib/buildSliceAssetPath.ts +0 -32
- package/src/lib/buildSliceDirectoryPath.ts +0 -26
- package/src/lib/buildSliceLibraryDirectoryPath.ts +0 -14
- package/src/lib/checkPathExists.ts +0 -12
- package/src/lib/isSharedSliceModel.ts +0 -14
- package/src/lib/readJSONFile.ts +0 -7
- package/src/lib/updateSliceModelFile.ts +0 -33
- package/src/lib/upsertGlobalContentTypes.ts +0 -61
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
+
import {
|
|
3
|
+
buildSliceDirectoryPath,
|
|
4
|
+
buildSliceLibraryDirectoryPath,
|
|
5
|
+
writeProjectFile,
|
|
6
|
+
} from "@slicemachine/plugin-kit/fs";
|
|
2
7
|
import { stripIndent } from "common-tags";
|
|
3
|
-
import * as fs from "node:fs/promises";
|
|
4
8
|
import * as path from "node:path";
|
|
5
|
-
import { NON_EDITABLE_FILE_BANNER } from "../constants";
|
|
6
9
|
|
|
10
|
+
import { NON_EDITABLE_FILE_BANNER } from "../constants";
|
|
7
11
|
import { PluginOptions } from "../types";
|
|
8
12
|
|
|
9
|
-
import {
|
|
13
|
+
import { getJSFileExtension } from "./getJSFileExtension";
|
|
10
14
|
import { pascalCase } from "./pascalCase";
|
|
11
|
-
import { buildSliceLibraryDirectoryPath } from "./buildSliceLibraryDirectoryPath";
|
|
12
15
|
|
|
13
16
|
type UpsertSliceLibraryIndexFileArgs = {
|
|
14
17
|
libraryID: string;
|
|
@@ -17,19 +20,6 @@ type UpsertSliceLibraryIndexFileArgs = {
|
|
|
17
20
|
export const upsertSliceLibraryIndexFile = async (
|
|
18
21
|
args: UpsertSliceLibraryIndexFileArgs,
|
|
19
22
|
): Promise<void> => {
|
|
20
|
-
const isTypeScriptProject = await checkIsTypeScriptProject({
|
|
21
|
-
helpers: args.helpers,
|
|
22
|
-
options: args.options,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const filePath = path.join(
|
|
26
|
-
buildSliceLibraryDirectoryPath({
|
|
27
|
-
libraryID: args.libraryID,
|
|
28
|
-
helpers: args.helpers,
|
|
29
|
-
}),
|
|
30
|
-
isTypeScriptProject ? "index.ts" : "index.js",
|
|
31
|
-
);
|
|
32
|
-
|
|
33
23
|
const slices = await args.actions.readAllSliceModelsForLibrary({
|
|
34
24
|
libraryID: args.libraryID,
|
|
35
25
|
});
|
|
@@ -44,14 +34,22 @@ export const upsertSliceLibraryIndexFile = async (
|
|
|
44
34
|
import { defineSliceZoneComponents } from "@prismicio/vue";
|
|
45
35
|
|
|
46
36
|
export const components = defineSliceZoneComponents({
|
|
47
|
-
${
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
${(
|
|
38
|
+
await Promise.all(
|
|
39
|
+
slices.map(async (slice) => {
|
|
40
|
+
const id = slice.model.id;
|
|
41
|
+
const dirName = path.basename(
|
|
42
|
+
await buildSliceDirectoryPath({
|
|
43
|
+
model: slice.model,
|
|
44
|
+
helpers: args.helpers,
|
|
45
|
+
libraryID: args.libraryID,
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return `${id}: defineAsyncComponent(() => import("./${dirName}/index.vue"))`;
|
|
50
|
+
}),
|
|
51
|
+
)
|
|
52
|
+
).join(",\n")}
|
|
55
53
|
});
|
|
56
54
|
`;
|
|
57
55
|
} else {
|
|
@@ -60,14 +58,22 @@ export const upsertSliceLibraryIndexFile = async (
|
|
|
60
58
|
|
|
61
59
|
import { defineSliceZoneComponents } from "@prismicio/vue";
|
|
62
60
|
|
|
63
|
-
${
|
|
64
|
-
.
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
${(
|
|
62
|
+
await Promise.all(
|
|
63
|
+
slices.map(async (slice) => {
|
|
64
|
+
const dirName = path.basename(
|
|
65
|
+
await buildSliceDirectoryPath({
|
|
66
|
+
model: slice.model,
|
|
67
|
+
helpers: args.helpers,
|
|
68
|
+
libraryID: args.libraryID,
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
const componentName = pascalCase(slice.model.name);
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
return `import ${componentName} from "./${dirName}/index.vue";`;
|
|
74
|
+
}),
|
|
75
|
+
)
|
|
76
|
+
).join("\n")}
|
|
71
77
|
|
|
72
78
|
export const components = defineSliceZoneComponents({
|
|
73
79
|
${slices
|
|
@@ -82,9 +88,22 @@ export const upsertSliceLibraryIndexFile = async (
|
|
|
82
88
|
`;
|
|
83
89
|
}
|
|
84
90
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
const extension = await getJSFileExtension({
|
|
92
|
+
helpers: args.helpers,
|
|
93
|
+
options: args.options,
|
|
94
|
+
});
|
|
95
|
+
const filePath = path.join(
|
|
96
|
+
buildSliceLibraryDirectoryPath({
|
|
97
|
+
libraryID: args.libraryID,
|
|
98
|
+
helpers: args.helpers,
|
|
99
|
+
}),
|
|
100
|
+
`index.${extension}`,
|
|
101
|
+
);
|
|
88
102
|
|
|
89
|
-
await
|
|
103
|
+
await writeProjectFile({
|
|
104
|
+
filename: filePath,
|
|
105
|
+
contents,
|
|
106
|
+
format: args.options.format,
|
|
107
|
+
helpers: args.helpers,
|
|
108
|
+
});
|
|
90
109
|
};
|
package/src/plugin.ts
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import { defineSliceMachinePlugin } from "@slicemachine/plugin-kit";
|
|
2
|
+
import {
|
|
3
|
+
deleteCustomTypeDirectory,
|
|
4
|
+
deleteCustomTypeFile,
|
|
5
|
+
deleteSliceDirectory,
|
|
6
|
+
deleteSliceFile,
|
|
7
|
+
readCustomTypeFile,
|
|
8
|
+
readCustomTypeLibrary,
|
|
9
|
+
readCustomTypeModel,
|
|
10
|
+
readSliceFile,
|
|
11
|
+
readSliceLibrary,
|
|
12
|
+
readSliceModel,
|
|
13
|
+
renameCustomType,
|
|
14
|
+
renameSlice,
|
|
15
|
+
upsertGlobalTypeScriptTypes,
|
|
16
|
+
writeCustomTypeFile,
|
|
17
|
+
writeCustomTypeModel,
|
|
18
|
+
writeSliceFile,
|
|
19
|
+
writeSliceModel,
|
|
20
|
+
} from "@slicemachine/plugin-kit/fs";
|
|
21
|
+
|
|
22
|
+
import { rejectIfNecessary } from "./lib/rejectIfNecessary";
|
|
23
|
+
import { upsertSliceLibraryIndexFile } from "./lib/upsertSliceLibraryIndexFile";
|
|
2
24
|
|
|
3
25
|
import { name as pkgName } from "../package.json";
|
|
4
26
|
import { PluginOptions } from "./types";
|
|
5
27
|
|
|
28
|
+
import { documentationRead } from "./hooks/documentation-read";
|
|
6
29
|
import { projectInit } from "./hooks/project-init";
|
|
7
|
-
import { customTypeAssetDelete } from "./hooks/customType-asset-delete";
|
|
8
|
-
import { customTypeAssetRead } from "./hooks/customType-asset-read";
|
|
9
|
-
import { customTypeAssetUpdate } from "./hooks/customType-asset-update";
|
|
10
|
-
import { customTypeCreate } from "./hooks/customType-create";
|
|
11
|
-
import { customTypeDelete } from "./hooks/customType-delete";
|
|
12
|
-
import { customTypeLibraryRead } from "./hooks/customTypeLibrary-read";
|
|
13
|
-
import { customTypeRead } from "./hooks/customType-read";
|
|
14
|
-
import { customTypeRename } from "./hooks/customType-rename";
|
|
15
|
-
import { customTypeUpdate } from "./hooks/customType-update";
|
|
16
|
-
import { sliceAssetDelete } from "./hooks/slice-asset-delete";
|
|
17
|
-
import { sliceAssetRead } from "./hooks/slice-asset-read";
|
|
18
|
-
import { sliceAssetUpdate } from "./hooks/slice-asset-update";
|
|
19
30
|
import { sliceCreate } from "./hooks/slice-create";
|
|
20
|
-
import { sliceDelete } from "./hooks/slice-delete";
|
|
21
|
-
import { sliceLibraryRead } from "./hooks/sliceLibrary-read";
|
|
22
|
-
import { sliceRead } from "./hooks/slice-read";
|
|
23
|
-
import { sliceRename } from "./hooks/slice-rename";
|
|
24
|
-
import { sliceUpdate } from "./hooks/slice-update";
|
|
25
|
-
import { snippetRead } from "./hooks/snippet-read";
|
|
26
|
-
import { documentationRead } from "./hooks/documentation-read";
|
|
27
31
|
import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read";
|
|
32
|
+
import { snippetRead } from "./hooks/snippet-read";
|
|
28
33
|
|
|
29
34
|
export const plugin = defineSliceMachinePlugin<PluginOptions>({
|
|
30
35
|
meta: {
|
|
@@ -35,30 +40,235 @@ export const plugin = defineSliceMachinePlugin<PluginOptions>({
|
|
|
35
40
|
lazyLoadSlices: true,
|
|
36
41
|
},
|
|
37
42
|
setup({ hook }) {
|
|
43
|
+
////////////////////////////////////////////////////////////////
|
|
44
|
+
// project:*
|
|
45
|
+
////////////////////////////////////////////////////////////////
|
|
46
|
+
|
|
38
47
|
hook("project:init", projectInit);
|
|
39
48
|
|
|
49
|
+
////////////////////////////////////////////////////////////////
|
|
50
|
+
// slice:*
|
|
51
|
+
////////////////////////////////////////////////////////////////
|
|
52
|
+
|
|
40
53
|
hook("slice:create", sliceCreate);
|
|
41
|
-
hook("slice:update",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
hook("
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
hook("slice:update", async (data, context) => {
|
|
55
|
+
await writeSliceModel({
|
|
56
|
+
libraryID: data.libraryID,
|
|
57
|
+
model: data.model,
|
|
58
|
+
...context,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
await upsertGlobalTypeScriptTypes({
|
|
62
|
+
filename: context.options.generatedTypesFilePath,
|
|
63
|
+
format: context.options.format,
|
|
64
|
+
...context,
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
hook("slice:rename", async (data, context) => {
|
|
68
|
+
await renameSlice({
|
|
69
|
+
libraryID: data.libraryID,
|
|
70
|
+
model: data.model,
|
|
71
|
+
format: context.options.format,
|
|
72
|
+
...context,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
rejectIfNecessary(
|
|
76
|
+
await Promise.allSettled([
|
|
77
|
+
upsertSliceLibraryIndexFile({
|
|
78
|
+
libraryID: data.libraryID,
|
|
79
|
+
...context,
|
|
80
|
+
}),
|
|
81
|
+
upsertGlobalTypeScriptTypes({
|
|
82
|
+
filename: context.options.generatedTypesFilePath,
|
|
83
|
+
format: context.options.format,
|
|
84
|
+
...context,
|
|
85
|
+
}),
|
|
86
|
+
]),
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
hook("slice:delete", async (data, context) => {
|
|
90
|
+
await deleteSliceDirectory({
|
|
91
|
+
libraryID: data.libraryID,
|
|
92
|
+
model: data.model,
|
|
93
|
+
...context,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
rejectIfNecessary(
|
|
97
|
+
await Promise.allSettled([
|
|
98
|
+
upsertSliceLibraryIndexFile({
|
|
99
|
+
libraryID: data.libraryID,
|
|
100
|
+
...context,
|
|
101
|
+
}),
|
|
102
|
+
upsertGlobalTypeScriptTypes({
|
|
103
|
+
filename: context.options.generatedTypesFilePath,
|
|
104
|
+
format: context.options.format,
|
|
105
|
+
...context,
|
|
106
|
+
}),
|
|
107
|
+
]),
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
hook("slice:read", async (data, context) => {
|
|
111
|
+
return await readSliceModel({
|
|
112
|
+
libraryID: data.libraryID,
|
|
113
|
+
sliceID: data.sliceID,
|
|
114
|
+
...context,
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
hook("slice:asset:update", async (data, context) => {
|
|
118
|
+
await writeSliceFile({
|
|
119
|
+
libraryID: data.libraryID,
|
|
120
|
+
sliceID: data.sliceID,
|
|
121
|
+
filename: data.asset.id,
|
|
122
|
+
contents: data.asset.data,
|
|
123
|
+
...context,
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
hook("slice:asset:delete", async (data, context) => {
|
|
127
|
+
await deleteSliceFile({
|
|
128
|
+
libraryID: data.libraryID,
|
|
129
|
+
sliceID: data.sliceID,
|
|
130
|
+
filename: data.assetID,
|
|
131
|
+
...context,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
hook("slice:asset:read", async (data, context) => {
|
|
135
|
+
const file = await readSliceFile({
|
|
136
|
+
libraryID: data.libraryID,
|
|
137
|
+
sliceID: data.sliceID,
|
|
138
|
+
filename: data.assetID,
|
|
139
|
+
...context,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
data: file,
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
////////////////////////////////////////////////////////////////
|
|
148
|
+
// slice-library:*
|
|
149
|
+
////////////////////////////////////////////////////////////////
|
|
150
|
+
|
|
151
|
+
hook("slice-library:read", async (data, context) => {
|
|
152
|
+
return await readSliceLibrary({
|
|
153
|
+
libraryID: data.libraryID,
|
|
154
|
+
...context,
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
////////////////////////////////////////////////////////////////
|
|
159
|
+
// custom-type:*
|
|
160
|
+
////////////////////////////////////////////////////////////////
|
|
161
|
+
|
|
162
|
+
hook("custom-type:create", async (data, context) => {
|
|
163
|
+
await writeCustomTypeModel({
|
|
164
|
+
model: data.model,
|
|
165
|
+
format: context.options.format,
|
|
166
|
+
...context,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
await upsertGlobalTypeScriptTypes({
|
|
170
|
+
filename: context.options.generatedTypesFilePath,
|
|
171
|
+
format: context.options.format,
|
|
172
|
+
...context,
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
hook("custom-type:update", async (data, context) => {
|
|
176
|
+
await writeCustomTypeModel({
|
|
177
|
+
model: data.model,
|
|
178
|
+
format: context.options.format,
|
|
179
|
+
...context,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
await upsertGlobalTypeScriptTypes({
|
|
183
|
+
filename: context.options.generatedTypesFilePath,
|
|
184
|
+
format: context.options.format,
|
|
185
|
+
...context,
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
hook("custom-type:rename", async (data, context) => {
|
|
189
|
+
await renameCustomType({
|
|
190
|
+
model: data.model,
|
|
191
|
+
format: context.options.format,
|
|
192
|
+
...context,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
await upsertGlobalTypeScriptTypes({
|
|
196
|
+
filename: context.options.generatedTypesFilePath,
|
|
197
|
+
format: context.options.format,
|
|
198
|
+
...context,
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
hook("custom-type:delete", async (data, context) => {
|
|
202
|
+
await deleteCustomTypeDirectory({
|
|
203
|
+
customTypeID: data.model.id,
|
|
204
|
+
...context,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
await upsertGlobalTypeScriptTypes({
|
|
208
|
+
filename: context.options.generatedTypesFilePath,
|
|
209
|
+
format: context.options.format,
|
|
210
|
+
...context,
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
hook("custom-type:read", async (data, context) => {
|
|
214
|
+
return await readCustomTypeModel({
|
|
215
|
+
customTypeID: data.id,
|
|
216
|
+
...context,
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
hook("custom-type:asset:update", async (data, context) => {
|
|
220
|
+
await writeCustomTypeFile({
|
|
221
|
+
customTypeID: data.customTypeID,
|
|
222
|
+
filename: data.asset.id,
|
|
223
|
+
contents: data.asset.data,
|
|
224
|
+
...context,
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
hook("custom-type:asset:delete", async (data, context) => {
|
|
228
|
+
await deleteCustomTypeFile({
|
|
229
|
+
customTypeID: data.customTypeID,
|
|
230
|
+
filename: data.assetID,
|
|
231
|
+
...context,
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
hook("custom-type:asset:read", async (data, context) => {
|
|
235
|
+
const file = await readCustomTypeFile({
|
|
236
|
+
customTypeID: data.customTypeID,
|
|
237
|
+
filename: data.assetID,
|
|
238
|
+
...context,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
data: file,
|
|
243
|
+
};
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
////////////////////////////////////////////////////////////////
|
|
247
|
+
// custom-type-library:*
|
|
248
|
+
////////////////////////////////////////////////////////////////
|
|
249
|
+
|
|
250
|
+
hook("custom-type-library:read", async (_data, context) => {
|
|
251
|
+
return await readCustomTypeLibrary({
|
|
252
|
+
helpers: context.helpers,
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
////////////////////////////////////////////////////////////////
|
|
257
|
+
// snippet:*
|
|
258
|
+
////////////////////////////////////////////////////////////////
|
|
59
259
|
|
|
60
260
|
hook("snippet:read", snippetRead);
|
|
261
|
+
|
|
262
|
+
////////////////////////////////////////////////////////////////
|
|
263
|
+
// documentation:*
|
|
264
|
+
////////////////////////////////////////////////////////////////
|
|
265
|
+
|
|
61
266
|
hook("documentation:read", documentationRead);
|
|
267
|
+
|
|
268
|
+
////////////////////////////////////////////////////////////////
|
|
269
|
+
// slice-simulator:*
|
|
270
|
+
////////////////////////////////////////////////////////////////
|
|
271
|
+
|
|
62
272
|
hook("slice-simulator:setup:read", sliceSimulatorSetupRead);
|
|
63
273
|
},
|
|
64
274
|
});
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
export type PluginOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Determines if generated files should be formatted using Prettier.
|
|
4
|
+
*
|
|
5
|
+
* @defaultValue `true`
|
|
6
|
+
*/
|
|
2
7
|
format?: boolean;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Determines if Slice components should be lazy loaded when rendered.
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue `true`
|
|
13
|
+
*/
|
|
3
14
|
lazyLoadSlices?: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Determines if generated files should be written in TypeScript or
|
|
18
|
+
* JavaScript.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue `true` if the project contains a `tsconfig.json`, `false` otherwise.
|
|
21
|
+
*/
|
|
4
22
|
typescript?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The filepath at which generated TypeScript types will be saved.
|
|
26
|
+
*
|
|
27
|
+
* @defaultValue `prismicio-types.d.ts`
|
|
28
|
+
*/
|
|
29
|
+
generatedTypesFilePath?: string;
|
|
5
30
|
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const fs = require("node:fs/promises");
|
|
4
|
-
const buildCustomTypeAssetPath = require("../lib/buildCustomTypeAssetPath.cjs");
|
|
5
|
-
function _interopNamespaceDefault(e) {
|
|
6
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
-
if (e) {
|
|
8
|
-
for (const k in e) {
|
|
9
|
-
if (k !== "default") {
|
|
10
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: () => e[k]
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
n.default = e;
|
|
19
|
-
return Object.freeze(n);
|
|
20
|
-
}
|
|
21
|
-
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
22
|
-
const customTypeAssetDelete = async (data, context) => {
|
|
23
|
-
const filePath = buildCustomTypeAssetPath.buildCustomTypeAssetPath({
|
|
24
|
-
customTypeID: data.customTypeID,
|
|
25
|
-
assetID: data.assetID,
|
|
26
|
-
helpers: context.helpers
|
|
27
|
-
});
|
|
28
|
-
await fs__namespace.rm(filePath);
|
|
29
|
-
};
|
|
30
|
-
exports.customTypeAssetDelete = customTypeAssetDelete;
|
|
31
|
-
//# sourceMappingURL=customType-asset-delete.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customType-asset-delete.cjs","sources":["../../../src/hooks/customType-asset-delete.ts"],"sourcesContent":["import type { CustomTypeAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetDelete: CustomTypeAssetDeleteHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.rm(filePath);\n};\n"],"names":["buildCustomTypeAssetPath","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOa,MAAA,wBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAWA,yBAAAA,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAAC,cAAG,GAAG,QAAQ;AACrB;;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs/promises";
|
|
2
|
-
import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath.js";
|
|
3
|
-
const customTypeAssetDelete = async (data, context) => {
|
|
4
|
-
const filePath = buildCustomTypeAssetPath({
|
|
5
|
-
customTypeID: data.customTypeID,
|
|
6
|
-
assetID: data.assetID,
|
|
7
|
-
helpers: context.helpers
|
|
8
|
-
});
|
|
9
|
-
await fs.rm(filePath);
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
customTypeAssetDelete
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=customType-asset-delete.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customType-asset-delete.js","sources":["../../../src/hooks/customType-asset-delete.ts"],"sourcesContent":["import type { CustomTypeAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetDelete: CustomTypeAssetDeleteHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.rm(filePath);\n};\n"],"names":[],"mappings":";;AAOa,MAAA,wBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAW,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAA,GAAG,GAAG,QAAQ;AACrB;"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const fs = require("node:fs/promises");
|
|
4
|
-
const buildCustomTypeAssetPath = require("../lib/buildCustomTypeAssetPath.cjs");
|
|
5
|
-
function _interopNamespaceDefault(e) {
|
|
6
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
-
if (e) {
|
|
8
|
-
for (const k in e) {
|
|
9
|
-
if (k !== "default") {
|
|
10
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: () => e[k]
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
n.default = e;
|
|
19
|
-
return Object.freeze(n);
|
|
20
|
-
}
|
|
21
|
-
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
22
|
-
const customTypeAssetRead = async (data, context) => {
|
|
23
|
-
const filePath = buildCustomTypeAssetPath.buildCustomTypeAssetPath({
|
|
24
|
-
customTypeID: data.customTypeID,
|
|
25
|
-
assetID: data.assetID,
|
|
26
|
-
helpers: context.helpers
|
|
27
|
-
});
|
|
28
|
-
const assetData = await fs__namespace.readFile(filePath);
|
|
29
|
-
return {
|
|
30
|
-
data: assetData
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
exports.customTypeAssetRead = customTypeAssetRead;
|
|
34
|
-
//# sourceMappingURL=customType-asset-read.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customType-asset-read.cjs","sources":["../../../src/hooks/customType-asset-read.ts"],"sourcesContent":["import type { CustomTypeAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetRead: CustomTypeAssetReadHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t});\n\n\tconst assetData = await fs.readFile(filePath);\n\n\treturn {\n\t\tdata: assetData,\n\t};\n};\n"],"names":["buildCustomTypeAssetPath","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOa,MAAA,sBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAWA,yBAAAA,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAM,YAAY,MAAMC,cAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs/promises";
|
|
2
|
-
import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath.js";
|
|
3
|
-
const customTypeAssetRead = async (data, context) => {
|
|
4
|
-
const filePath = buildCustomTypeAssetPath({
|
|
5
|
-
customTypeID: data.customTypeID,
|
|
6
|
-
assetID: data.assetID,
|
|
7
|
-
helpers: context.helpers
|
|
8
|
-
});
|
|
9
|
-
const assetData = await fs.readFile(filePath);
|
|
10
|
-
return {
|
|
11
|
-
data: assetData
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
customTypeAssetRead
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=customType-asset-read.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customType-asset-read.js","sources":["../../../src/hooks/customType-asset-read.ts"],"sourcesContent":["import type { CustomTypeAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetRead: CustomTypeAssetReadHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t});\n\n\tconst assetData = await fs.readFile(filePath);\n\n\treturn {\n\t\tdata: assetData,\n\t};\n};\n"],"names":[],"mappings":";;AAOa,MAAA,sBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAW,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAM,YAAY,MAAM,GAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const fs = require("node:fs/promises");
|
|
4
|
-
const path = require("node:path");
|
|
5
|
-
const buildCustomTypeAssetPath = require("../lib/buildCustomTypeAssetPath.cjs");
|
|
6
|
-
function _interopNamespaceDefault(e) {
|
|
7
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
-
if (e) {
|
|
9
|
-
for (const k in e) {
|
|
10
|
-
if (k !== "default") {
|
|
11
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: () => e[k]
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
n.default = e;
|
|
20
|
-
return Object.freeze(n);
|
|
21
|
-
}
|
|
22
|
-
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
23
|
-
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
24
|
-
const customTypeAssetUpdate = async (data, context) => {
|
|
25
|
-
const filePath = buildCustomTypeAssetPath.buildCustomTypeAssetPath({
|
|
26
|
-
customTypeID: data.customTypeID,
|
|
27
|
-
assetID: data.asset.id,
|
|
28
|
-
helpers: context.helpers
|
|
29
|
-
});
|
|
30
|
-
await fs__namespace.mkdir(path__namespace.dirname(filePath), { recursive: true });
|
|
31
|
-
await fs__namespace.writeFile(filePath, data.asset.data);
|
|
32
|
-
};
|
|
33
|
-
exports.customTypeAssetUpdate = customTypeAssetUpdate;
|
|
34
|
-
//# sourceMappingURL=customType-asset-update.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customType-asset-update.cjs","sources":["../../../src/hooks/customType-asset-update.ts"],"sourcesContent":["import type { CustomTypeAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeAssetPath } from \"../lib/buildCustomTypeAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const customTypeAssetUpdate: CustomTypeAssetUpdateHook<\n\tPluginOptions\n> = async (data, context) => {\n\tconst filePath = buildCustomTypeAssetPath({\n\t\tcustomTypeID: data.customTypeID,\n\t\tassetID: data.asset.id,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(path.dirname(filePath), { recursive: true });\n\tawait fs.writeFile(filePath, data.asset.data);\n};\n"],"names":["buildCustomTypeAssetPath","fs","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQa,MAAA,wBAET,OAAO,MAAM,YAAW;AAC3B,QAAM,WAAWA,yBAAAA,yBAAyB;AAAA,IACzC,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK,MAAM;AAAA,IACpB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAAC,cAAG,MAAMC,gBAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAA,CAAM;AAC1D,QAAMD,cAAG,UAAU,UAAU,KAAK,MAAM,IAAI;AAC7C;;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs/promises";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { buildCustomTypeAssetPath } from "../lib/buildCustomTypeAssetPath.js";
|
|
4
|
-
const customTypeAssetUpdate = async (data, context) => {
|
|
5
|
-
const filePath = buildCustomTypeAssetPath({
|
|
6
|
-
customTypeID: data.customTypeID,
|
|
7
|
-
assetID: data.asset.id,
|
|
8
|
-
helpers: context.helpers
|
|
9
|
-
});
|
|
10
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
11
|
-
await fs.writeFile(filePath, data.asset.data);
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
customTypeAssetUpdate
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=customType-asset-update.js.map
|