@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
package/dist/plugin.js
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import { defineSliceMachinePlugin } from "@slicemachine/plugin-kit";
|
|
2
|
+
import { writeSliceModel, upsertGlobalTypeScriptTypes, renameSlice, deleteSliceDirectory, readSliceModel, writeSliceFile, deleteSliceFile, readSliceFile, readSliceLibrary, writeCustomTypeModel, renameCustomType, deleteCustomTypeDirectory, readCustomTypeModel, writeCustomTypeFile, deleteCustomTypeFile, readCustomTypeFile, readCustomTypeLibrary } from "@slicemachine/plugin-kit/fs";
|
|
3
|
+
import { rejectIfNecessary } from "./lib/rejectIfNecessary.js";
|
|
4
|
+
import { upsertSliceLibraryIndexFile } from "./lib/upsertSliceLibraryIndexFile.js";
|
|
2
5
|
import { name } from "./packages/adapter-nuxt/package.json.js";
|
|
6
|
+
import { documentationRead } from "./hooks/documentation-read.js";
|
|
3
7
|
import { projectInit } from "./hooks/project-init.js";
|
|
4
|
-
import { customTypeAssetDelete } from "./hooks/customType-asset-delete.js";
|
|
5
|
-
import { customTypeAssetRead } from "./hooks/customType-asset-read.js";
|
|
6
|
-
import { customTypeAssetUpdate } from "./hooks/customType-asset-update.js";
|
|
7
|
-
import { customTypeCreate } from "./hooks/customType-create.js";
|
|
8
|
-
import { customTypeDelete } from "./hooks/customType-delete.js";
|
|
9
|
-
import { customTypeLibraryRead } from "./hooks/customTypeLibrary-read.js";
|
|
10
|
-
import { customTypeRead } from "./hooks/customType-read.js";
|
|
11
|
-
import { customTypeRename } from "./hooks/customType-rename.js";
|
|
12
|
-
import { customTypeUpdate } from "./hooks/customType-update.js";
|
|
13
|
-
import { sliceAssetDelete } from "./hooks/slice-asset-delete.js";
|
|
14
|
-
import { sliceAssetRead } from "./hooks/slice-asset-read.js";
|
|
15
|
-
import { sliceAssetUpdate } from "./hooks/slice-asset-update.js";
|
|
16
8
|
import { sliceCreate } from "./hooks/slice-create.js";
|
|
17
|
-
import { sliceDelete } from "./hooks/slice-delete.js";
|
|
18
|
-
import { sliceLibraryRead } from "./hooks/sliceLibrary-read.js";
|
|
19
|
-
import { sliceRead } from "./hooks/slice-read.js";
|
|
20
|
-
import { sliceRename } from "./hooks/slice-rename.js";
|
|
21
|
-
import { sliceUpdate } from "./hooks/slice-update.js";
|
|
22
|
-
import { snippetRead } from "./hooks/snippet-read.js";
|
|
23
|
-
import { documentationRead } from "./hooks/documentation-read.js";
|
|
24
9
|
import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read.js";
|
|
10
|
+
import { snippetRead } from "./hooks/snippet-read.js";
|
|
25
11
|
const plugin = defineSliceMachinePlugin({
|
|
26
12
|
meta: {
|
|
27
13
|
name
|
|
@@ -33,23 +19,179 @@ const plugin = defineSliceMachinePlugin({
|
|
|
33
19
|
setup({ hook }) {
|
|
34
20
|
hook("project:init", projectInit);
|
|
35
21
|
hook("slice:create", sliceCreate);
|
|
36
|
-
hook("slice:update",
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
hook("
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
22
|
+
hook("slice:update", async (data, context) => {
|
|
23
|
+
await writeSliceModel({
|
|
24
|
+
libraryID: data.libraryID,
|
|
25
|
+
model: data.model,
|
|
26
|
+
...context
|
|
27
|
+
});
|
|
28
|
+
await upsertGlobalTypeScriptTypes({
|
|
29
|
+
filename: context.options.generatedTypesFilePath,
|
|
30
|
+
format: context.options.format,
|
|
31
|
+
...context
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
hook("slice:rename", async (data, context) => {
|
|
35
|
+
await renameSlice({
|
|
36
|
+
libraryID: data.libraryID,
|
|
37
|
+
model: data.model,
|
|
38
|
+
format: context.options.format,
|
|
39
|
+
...context
|
|
40
|
+
});
|
|
41
|
+
rejectIfNecessary(await Promise.allSettled([
|
|
42
|
+
upsertSliceLibraryIndexFile({
|
|
43
|
+
libraryID: data.libraryID,
|
|
44
|
+
...context
|
|
45
|
+
}),
|
|
46
|
+
upsertGlobalTypeScriptTypes({
|
|
47
|
+
filename: context.options.generatedTypesFilePath,
|
|
48
|
+
format: context.options.format,
|
|
49
|
+
...context
|
|
50
|
+
})
|
|
51
|
+
]));
|
|
52
|
+
});
|
|
53
|
+
hook("slice:delete", async (data, context) => {
|
|
54
|
+
await deleteSliceDirectory({
|
|
55
|
+
libraryID: data.libraryID,
|
|
56
|
+
model: data.model,
|
|
57
|
+
...context
|
|
58
|
+
});
|
|
59
|
+
rejectIfNecessary(await Promise.allSettled([
|
|
60
|
+
upsertSliceLibraryIndexFile({
|
|
61
|
+
libraryID: data.libraryID,
|
|
62
|
+
...context
|
|
63
|
+
}),
|
|
64
|
+
upsertGlobalTypeScriptTypes({
|
|
65
|
+
filename: context.options.generatedTypesFilePath,
|
|
66
|
+
format: context.options.format,
|
|
67
|
+
...context
|
|
68
|
+
})
|
|
69
|
+
]));
|
|
70
|
+
});
|
|
71
|
+
hook("slice:read", async (data, context) => {
|
|
72
|
+
return await readSliceModel({
|
|
73
|
+
libraryID: data.libraryID,
|
|
74
|
+
sliceID: data.sliceID,
|
|
75
|
+
...context
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
hook("slice:asset:update", async (data, context) => {
|
|
79
|
+
await writeSliceFile({
|
|
80
|
+
libraryID: data.libraryID,
|
|
81
|
+
sliceID: data.sliceID,
|
|
82
|
+
filename: data.asset.id,
|
|
83
|
+
contents: data.asset.data,
|
|
84
|
+
...context
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
hook("slice:asset:delete", async (data, context) => {
|
|
88
|
+
await deleteSliceFile({
|
|
89
|
+
libraryID: data.libraryID,
|
|
90
|
+
sliceID: data.sliceID,
|
|
91
|
+
filename: data.assetID,
|
|
92
|
+
...context
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
hook("slice:asset:read", async (data, context) => {
|
|
96
|
+
const file = await readSliceFile({
|
|
97
|
+
libraryID: data.libraryID,
|
|
98
|
+
sliceID: data.sliceID,
|
|
99
|
+
filename: data.assetID,
|
|
100
|
+
...context
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
data: file
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
hook("slice-library:read", async (data, context) => {
|
|
107
|
+
return await readSliceLibrary({
|
|
108
|
+
libraryID: data.libraryID,
|
|
109
|
+
...context
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
hook("custom-type:create", async (data, context) => {
|
|
113
|
+
await writeCustomTypeModel({
|
|
114
|
+
model: data.model,
|
|
115
|
+
format: context.options.format,
|
|
116
|
+
...context
|
|
117
|
+
});
|
|
118
|
+
await upsertGlobalTypeScriptTypes({
|
|
119
|
+
filename: context.options.generatedTypesFilePath,
|
|
120
|
+
format: context.options.format,
|
|
121
|
+
...context
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
hook("custom-type:update", async (data, context) => {
|
|
125
|
+
await writeCustomTypeModel({
|
|
126
|
+
model: data.model,
|
|
127
|
+
format: context.options.format,
|
|
128
|
+
...context
|
|
129
|
+
});
|
|
130
|
+
await upsertGlobalTypeScriptTypes({
|
|
131
|
+
filename: context.options.generatedTypesFilePath,
|
|
132
|
+
format: context.options.format,
|
|
133
|
+
...context
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
hook("custom-type:rename", async (data, context) => {
|
|
137
|
+
await renameCustomType({
|
|
138
|
+
model: data.model,
|
|
139
|
+
format: context.options.format,
|
|
140
|
+
...context
|
|
141
|
+
});
|
|
142
|
+
await upsertGlobalTypeScriptTypes({
|
|
143
|
+
filename: context.options.generatedTypesFilePath,
|
|
144
|
+
format: context.options.format,
|
|
145
|
+
...context
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
hook("custom-type:delete", async (data, context) => {
|
|
149
|
+
await deleteCustomTypeDirectory({
|
|
150
|
+
customTypeID: data.model.id,
|
|
151
|
+
...context
|
|
152
|
+
});
|
|
153
|
+
await upsertGlobalTypeScriptTypes({
|
|
154
|
+
filename: context.options.generatedTypesFilePath,
|
|
155
|
+
format: context.options.format,
|
|
156
|
+
...context
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
hook("custom-type:read", async (data, context) => {
|
|
160
|
+
return await readCustomTypeModel({
|
|
161
|
+
customTypeID: data.id,
|
|
162
|
+
...context
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
hook("custom-type:asset:update", async (data, context) => {
|
|
166
|
+
await writeCustomTypeFile({
|
|
167
|
+
customTypeID: data.customTypeID,
|
|
168
|
+
filename: data.asset.id,
|
|
169
|
+
contents: data.asset.data,
|
|
170
|
+
...context
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
hook("custom-type:asset:delete", async (data, context) => {
|
|
174
|
+
await deleteCustomTypeFile({
|
|
175
|
+
customTypeID: data.customTypeID,
|
|
176
|
+
filename: data.assetID,
|
|
177
|
+
...context
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
hook("custom-type:asset:read", async (data, context) => {
|
|
181
|
+
const file = await readCustomTypeFile({
|
|
182
|
+
customTypeID: data.customTypeID,
|
|
183
|
+
filename: data.assetID,
|
|
184
|
+
...context
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
data: file
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
hook("custom-type-library:read", async (_data, context) => {
|
|
191
|
+
return await readCustomTypeLibrary({
|
|
192
|
+
helpers: context.helpers
|
|
193
|
+
});
|
|
194
|
+
});
|
|
53
195
|
hook("snippet:read", snippetRead);
|
|
54
196
|
hook("documentation:read", documentationRead);
|
|
55
197
|
hook("slice-simulator:setup:read", sliceSimulatorSetupRead);
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { projectInit } from \"./hooks/project-init\";\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\nimport { documentationRead } from \"./hooks/documentation-read\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"project:init\", projectInit);\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\n\t\thook(\"slice-library:read\", sliceLibraryRead);\n\n\t\thook(\"custom-type:create\", customTypeCreate);\n\t\thook(\"custom-type:update\", customTypeUpdate);\n\t\thook(\"custom-type:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\n\t\thook(\"custom-type-library:read\", customTypeLibraryRead);\n\n\t\thook(\"snippet:read\", snippetRead);\n\t\thook(\"documentation:read\", documentationRead);\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,SAAS,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL;AAAA,EACA;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAChB;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgB,WAAW;AAEhC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,cAAc,SAAS;AAC5B,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,sBAAsB,gBAAgB;AAE3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,0BAA0B,mBAAmB;AAClD,SAAK,4BAA4B,qBAAqB;AAEtD,SAAK,gBAAgB,WAAW;AAChC,SAAK,sBAAsB,iBAAiB;AAC5C,SAAK,8BAA8B,uBAAuB;AAAA,EAC3D;AACA,CAAA;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\nimport {\n\tdeleteCustomTypeDirectory,\n\tdeleteCustomTypeFile,\n\tdeleteSliceDirectory,\n\tdeleteSliceFile,\n\treadCustomTypeFile,\n\treadCustomTypeLibrary,\n\treadCustomTypeModel,\n\treadSliceFile,\n\treadSliceLibrary,\n\treadSliceModel,\n\trenameCustomType,\n\trenameSlice,\n\tupsertGlobalTypeScriptTypes,\n\twriteCustomTypeFile,\n\twriteCustomTypeModel,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { rejectIfNecessary } from \"./lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"./lib/upsertSliceLibraryIndexFile\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { documentationRead } from \"./hooks/documentation-read\";\nimport { projectInit } from \"./hooks/project-init\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\t////////////////////////////////////////////////////////////////\n\t\t// project:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"project:init\", projectInit);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", async (data, context) => {\n\t\t\tawait writeSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:rename\", async (data, context) => {\n\t\t\tawait renameSlice({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:delete\", async (data, context) => {\n\t\t\tawait deleteSliceDirectory({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:read\", async (data, context) => {\n\t\t\treturn await readSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:update\", async (data, context) => {\n\t\t\tawait writeSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:delete\", async (data, context) => {\n\t\t\tawait deleteSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:read\", async (data, context) => {\n\t\t\tconst file = await readSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-library:read\", async (data, context) => {\n\t\t\treturn await readSliceLibrary({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type:create\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:rename\", async (data, context) => {\n\t\t\tawait renameCustomType({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeDirectory({\n\t\t\t\tcustomTypeID: data.model.id,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:read\", async (data, context) => {\n\t\t\treturn await readCustomTypeModel({\n\t\t\t\tcustomTypeID: data.id,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:read\", async (data, context) => {\n\t\t\tconst file = await readCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type-library:read\", async (_data, context) => {\n\t\t\treturn await readCustomTypeLibrary({\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// snippet:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// documentation:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"documentation:read\", documentationRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-simulator:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":[],"mappings":"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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
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
|
+
* Determines if Slice components should be lazy loaded when rendered.
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue `true`
|
|
12
|
+
*/
|
|
3
13
|
lazyLoadSlices?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Determines if generated files should be written in TypeScript or
|
|
16
|
+
* JavaScript.
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue `true` if the project contains a `tsconfig.json`, `false` otherwise.
|
|
19
|
+
*/
|
|
4
20
|
typescript?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The filepath at which generated TypeScript types will be saved.
|
|
23
|
+
*
|
|
24
|
+
* @defaultValue `prismicio-types.d.ts`
|
|
25
|
+
*/
|
|
26
|
+
generatedTypesFilePath?: string;
|
|
5
27
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slicemachine/adapter-nuxt",
|
|
3
|
-
"version": "0.3.10-dev-next-release.
|
|
3
|
+
"version": "0.3.10-dev-next-release.11",
|
|
4
4
|
"description": "Slice Machine adapter for Nuxt 3.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -61,10 +61,9 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@prismicio/simulator": "^0.1.4",
|
|
63
63
|
"@prismicio/types-internal": "^2.0.0",
|
|
64
|
-
"@slicemachine/plugin-kit": "^0.4.10-dev-next-release.
|
|
64
|
+
"@slicemachine/plugin-kit": "^0.4.10-dev-next-release.11",
|
|
65
65
|
"common-tags": "^1.8.2",
|
|
66
66
|
"fp-ts": "^2.13.1",
|
|
67
|
-
"fs-extra": "^11.1.0",
|
|
68
67
|
"io-ts": "^2.2.20",
|
|
69
68
|
"io-ts-types": "^0.5.19",
|
|
70
69
|
"magicast": "^0.2.1",
|
|
@@ -78,7 +77,6 @@
|
|
|
78
77
|
"@prismicio/mock": "0.2.0",
|
|
79
78
|
"@size-limit/preset-small-lib": "8.2.4",
|
|
80
79
|
"@types/common-tags": "1.8.1",
|
|
81
|
-
"@types/fs-extra": "11.0.1",
|
|
82
80
|
"@types/prettier": "2.7.2",
|
|
83
81
|
"@typescript-eslint/eslint-plugin": "5.55.0",
|
|
84
82
|
"@typescript-eslint/parser": "5.55.0",
|
|
@@ -105,5 +103,5 @@
|
|
|
105
103
|
"engines": {
|
|
106
104
|
"node": ">=14.15.0"
|
|
107
105
|
},
|
|
108
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "c37766e0280275919f992e52b149643db059952c"
|
|
109
107
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import * as fs from "node:fs/promises";
|
|
2
1
|
import * as path from "node:path";
|
|
3
2
|
import type {
|
|
4
3
|
ProjectInitHook,
|
|
5
4
|
ProjectInitHookData,
|
|
6
5
|
SliceMachineContext,
|
|
7
6
|
} from "@slicemachine/plugin-kit";
|
|
7
|
+
import {
|
|
8
|
+
checkHasProjectFile,
|
|
9
|
+
writeProjectFile,
|
|
10
|
+
} from "@slicemachine/plugin-kit/fs";
|
|
8
11
|
import { stripIndent } from "common-tags";
|
|
9
12
|
import { loadFile, writeFile, type ASTNode } from "magicast";
|
|
10
13
|
|
|
11
|
-
import { checkPathExists } from "../lib/checkPathExists";
|
|
12
14
|
import { rejectIfNecessary } from "../lib/rejectIfNecessary";
|
|
13
15
|
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
|
|
14
16
|
import { checkHasSrcDirectory } from "../lib/checkHasSrcDirectory";
|
|
@@ -49,17 +51,21 @@ const configurePrismicModule = async ({
|
|
|
49
51
|
helpers,
|
|
50
52
|
project,
|
|
51
53
|
}: ConfigurePrismicModuleArgs) => {
|
|
52
|
-
let
|
|
54
|
+
let nuxtConfigFilename = "nuxt.config.js";
|
|
53
55
|
|
|
54
|
-
if (!(await
|
|
55
|
-
|
|
56
|
+
if (!(await checkHasProjectFile({ filename: nuxtConfigFilename, helpers }))) {
|
|
57
|
+
nuxtConfigFilename = "nuxt.config.ts";
|
|
56
58
|
|
|
57
59
|
// nuxt.config.* not found
|
|
58
|
-
if (
|
|
60
|
+
if (
|
|
61
|
+
!(await checkHasProjectFile({ filename: nuxtConfigFilename, helpers }))
|
|
62
|
+
) {
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
const nuxtConfigPath = helpers.joinPathFromRoot(nuxtConfigFilename);
|
|
68
|
+
|
|
63
69
|
const mod = await loadFile(nuxtConfigPath);
|
|
64
70
|
const config =
|
|
65
71
|
mod.exports.default.$type === "function-call"
|
|
@@ -108,27 +114,26 @@ const createSliceSimulatorPage = async ({
|
|
|
108
114
|
options,
|
|
109
115
|
});
|
|
110
116
|
|
|
111
|
-
const srcPagesDirectoryExists = await
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
const srcPagesDirectoryExists = await checkHasProjectFile({
|
|
118
|
+
filename: "src/pages",
|
|
119
|
+
helpers,
|
|
120
|
+
});
|
|
114
121
|
|
|
115
|
-
const
|
|
122
|
+
const filename = path.join(
|
|
116
123
|
srcPagesDirectoryExists ? "src/pages" : "pages",
|
|
117
124
|
"slice-simulator.vue",
|
|
118
125
|
);
|
|
119
126
|
|
|
120
|
-
if (await
|
|
127
|
+
if (await checkHasProjectFile({ filename, helpers })) {
|
|
121
128
|
return;
|
|
122
129
|
}
|
|
123
130
|
|
|
124
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
125
|
-
|
|
126
131
|
const scriptAttributes = ["setup"];
|
|
127
132
|
if (isTypeScriptProject) {
|
|
128
133
|
scriptAttributes.push('lang="ts"');
|
|
129
134
|
}
|
|
130
135
|
|
|
131
|
-
|
|
136
|
+
const contents = stripIndent`
|
|
132
137
|
<template>
|
|
133
138
|
<SliceSimulator #default="{ slices }">
|
|
134
139
|
<SliceZone :slices="slices" :components="components" />
|
|
@@ -141,18 +146,18 @@ const createSliceSimulatorPage = async ({
|
|
|
141
146
|
</script>
|
|
142
147
|
`;
|
|
143
148
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
await fs.writeFile(filePath, contents);
|
|
149
|
+
await writeProjectFile({
|
|
150
|
+
filename,
|
|
151
|
+
contents,
|
|
152
|
+
format: options.format,
|
|
153
|
+
helpers,
|
|
154
|
+
});
|
|
151
155
|
};
|
|
152
156
|
|
|
153
157
|
const modifySliceMachineConfig = async ({
|
|
154
158
|
helpers,
|
|
155
159
|
options,
|
|
160
|
+
actions,
|
|
156
161
|
}: SliceMachineContext<PluginOptions>) => {
|
|
157
162
|
const hasSrcDirectory = await checkHasSrcDirectory({ helpers });
|
|
158
163
|
const project = await helpers.getProject();
|
|
@@ -165,24 +170,15 @@ const modifySliceMachineConfig = async ({
|
|
|
165
170
|
// is empty.
|
|
166
171
|
if (
|
|
167
172
|
hasSrcDirectory &&
|
|
173
|
+
project.config.libraries &&
|
|
168
174
|
JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])
|
|
169
175
|
) {
|
|
170
|
-
|
|
171
|
-
|
|
176
|
+
const sliceLibrary = await actions.readSliceLibrary({
|
|
177
|
+
libraryID: project.config.libraries[0],
|
|
178
|
+
});
|
|
172
179
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
} catch (error) {
|
|
177
|
-
if (
|
|
178
|
-
error instanceof Error &&
|
|
179
|
-
"code" in error &&
|
|
180
|
-
error.code === "ENOENT"
|
|
181
|
-
) {
|
|
182
|
-
// The directory does not exist, which means we
|
|
183
|
-
// can safely nest the library.
|
|
184
|
-
project.config.libraries = ["./src/slices"];
|
|
185
|
-
}
|
|
180
|
+
if (sliceLibrary.sliceIDs.length < 1) {
|
|
181
|
+
project.config.libraries = ["./src/slices"];
|
|
186
182
|
}
|
|
187
183
|
}
|
|
188
184
|
|
|
@@ -3,29 +3,31 @@ import type {
|
|
|
3
3
|
SliceCreateHookData,
|
|
4
4
|
SliceMachineContext,
|
|
5
5
|
} from "@slicemachine/plugin-kit";
|
|
6
|
+
import {
|
|
7
|
+
upsertGlobalTypeScriptTypes,
|
|
8
|
+
writeSliceFile,
|
|
9
|
+
writeSliceModel,
|
|
10
|
+
} from "@slicemachine/plugin-kit/fs";
|
|
6
11
|
import { stripIndent } from "common-tags";
|
|
7
|
-
import * as fs from "node:fs/promises";
|
|
8
|
-
import * as path from "node:path";
|
|
9
12
|
|
|
10
|
-
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath";
|
|
11
|
-
import { rejectIfNecessary } from "../lib/rejectIfNecessary";
|
|
12
|
-
import { updateSliceModelFile } from "../lib/updateSliceModelFile";
|
|
13
|
-
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes";
|
|
14
|
-
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile";
|
|
15
13
|
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
|
|
16
14
|
import { pascalCase } from "../lib/pascalCase";
|
|
15
|
+
import { rejectIfNecessary } from "../lib/rejectIfNecessary";
|
|
16
|
+
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile";
|
|
17
17
|
|
|
18
18
|
import type { PluginOptions } from "../types";
|
|
19
19
|
|
|
20
|
-
type
|
|
21
|
-
dir: string;
|
|
20
|
+
type CreateComponentFileArgs = {
|
|
22
21
|
data: SliceCreateHookData;
|
|
23
22
|
} & SliceMachineContext<PluginOptions>;
|
|
24
23
|
|
|
25
|
-
const createComponentFile = async ({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const createComponentFile = async ({
|
|
25
|
+
data,
|
|
26
|
+
helpers,
|
|
27
|
+
actions,
|
|
28
|
+
options,
|
|
29
|
+
}: CreateComponentFileArgs) => {
|
|
30
|
+
const pascalName = pascalCase(data.model.name);
|
|
29
31
|
|
|
30
32
|
let contents: string;
|
|
31
33
|
|
|
@@ -51,7 +53,7 @@ const createComponentFile = async ({ dir, data, helpers, options }: Args) => {
|
|
|
51
53
|
:data-slice-type="slice.slice_type"
|
|
52
54
|
:data-slice-variation="slice.variation"
|
|
53
55
|
>
|
|
54
|
-
Placeholder component for ${model.id} (variation: {{ slice.variation }}) Slices
|
|
56
|
+
Placeholder component for ${data.model.id} (variation: {{ slice.variation }}) Slices
|
|
55
57
|
</section>
|
|
56
58
|
</template>
|
|
57
59
|
`;
|
|
@@ -74,42 +76,45 @@ const createComponentFile = async ({ dir, data, helpers, options }: Args) => {
|
|
|
74
76
|
`;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
await writeSliceFile({
|
|
80
|
+
libraryID: data.libraryID,
|
|
81
|
+
model: data.model,
|
|
82
|
+
filename: "index.vue",
|
|
83
|
+
contents,
|
|
84
|
+
format: options.format,
|
|
85
|
+
actions,
|
|
86
|
+
helpers,
|
|
87
|
+
});
|
|
84
88
|
};
|
|
85
89
|
|
|
86
90
|
export const sliceCreate: SliceCreateHook<PluginOptions> = async (
|
|
87
91
|
data,
|
|
88
92
|
context,
|
|
89
93
|
) => {
|
|
90
|
-
const dir = buildSliceDirectoryPath({
|
|
91
|
-
libraryID: data.libraryID,
|
|
92
|
-
model: data.model,
|
|
93
|
-
helpers: context.helpers,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
await fs.mkdir(dir, { recursive: true });
|
|
97
|
-
|
|
98
94
|
rejectIfNecessary(
|
|
99
95
|
await Promise.allSettled([
|
|
100
|
-
|
|
96
|
+
writeSliceModel({
|
|
101
97
|
libraryID: data.libraryID,
|
|
102
98
|
model: data.model,
|
|
103
|
-
|
|
99
|
+
format: context.options.format,
|
|
100
|
+
helpers: context.helpers,
|
|
104
101
|
}),
|
|
105
|
-
createComponentFile({
|
|
102
|
+
createComponentFile({ data, ...context }),
|
|
106
103
|
]),
|
|
107
104
|
);
|
|
108
105
|
|
|
109
106
|
rejectIfNecessary(
|
|
110
107
|
await Promise.allSettled([
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
upsertSliceLibraryIndexFile({
|
|
109
|
+
libraryID: data.libraryID,
|
|
110
|
+
...context,
|
|
111
|
+
}),
|
|
112
|
+
upsertGlobalTypeScriptTypes({
|
|
113
|
+
filename: context.options.generatedTypesFilePath,
|
|
114
|
+
format: context.options.format,
|
|
115
|
+
helpers: context.helpers,
|
|
116
|
+
actions: context.actions,
|
|
117
|
+
}),
|
|
113
118
|
]),
|
|
114
119
|
);
|
|
115
120
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
+
import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs";
|
|
2
3
|
|
|
3
4
|
import { PluginOptions } from "../types";
|
|
4
|
-
import { checkPathExists } from "./checkPathExists";
|
|
5
5
|
|
|
6
6
|
type CheckHasSrcDirectoryArgs = Pick<
|
|
7
7
|
SliceMachineContext<PluginOptions>,
|
|
@@ -11,5 +11,8 @@ type CheckHasSrcDirectoryArgs = Pick<
|
|
|
11
11
|
export async function checkHasSrcDirectory(
|
|
12
12
|
args: CheckHasSrcDirectoryArgs,
|
|
13
13
|
): Promise<boolean> {
|
|
14
|
-
return await
|
|
14
|
+
return await checkHasProjectFile({
|
|
15
|
+
filename: "src",
|
|
16
|
+
helpers: args.helpers,
|
|
17
|
+
});
|
|
15
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
+
import { checkIsTypeScriptProject as baseCheckIsTypeScriptProject } from "@slicemachine/plugin-kit/fs";
|
|
2
3
|
|
|
3
4
|
import { PluginOptions } from "../types";
|
|
4
|
-
import { checkPathExists } from "./checkPathExists";
|
|
5
5
|
|
|
6
6
|
type CheckIsTypeScriptProjectArgs = {
|
|
7
7
|
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
@@ -11,7 +11,8 @@ type CheckIsTypeScriptProjectArgs = {
|
|
|
11
11
|
export const checkIsTypeScriptProject = async (
|
|
12
12
|
args: CheckIsTypeScriptProjectArgs,
|
|
13
13
|
): Promise<boolean> => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
return (
|
|
15
|
+
args.options.typescript ??
|
|
16
|
+
baseCheckIsTypeScriptProject({ helpers: args.helpers })
|
|
17
|
+
);
|
|
17
18
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
+
|
|
3
|
+
import { PluginOptions } from "../types";
|
|
4
|
+
|
|
5
|
+
import { checkIsTypeScriptProject } from "./checkIsTypeScriptProject";
|
|
6
|
+
|
|
7
|
+
type GetJSFileExtensionArgs = Pick<
|
|
8
|
+
SliceMachineContext<PluginOptions>,
|
|
9
|
+
"helpers" | "options"
|
|
10
|
+
>;
|
|
11
|
+
|
|
12
|
+
export const getJSFileExtension = async ({
|
|
13
|
+
helpers,
|
|
14
|
+
options,
|
|
15
|
+
}: GetJSFileExtensionArgs): Promise<string> => {
|
|
16
|
+
const isTypeScriptProject = await checkIsTypeScriptProject({
|
|
17
|
+
helpers,
|
|
18
|
+
options,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return isTypeScriptProject ? "ts" : "js";
|
|
22
|
+
};
|