@slicemachine/adapter-next 0.3.10 → 0.3.11-dev-next-release.2
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/documentation-read.cjs +7 -6
- package/dist/hooks/documentation-read.cjs.map +1 -1
- package/dist/hooks/documentation-read.js +7 -6
- package/dist/hooks/documentation-read.js.map +1 -1
- package/dist/hooks/project-init.cjs +51 -58
- package/dist/hooks/project-init.cjs.map +1 -1
- package/dist/hooks/project-init.js +51 -57
- package/dist/hooks/project-init.js.map +1 -1
- package/dist/hooks/slice-create.cjs +29 -44
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +29 -26
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/lib/checkHasAppRouter.cjs +23 -2
- package/dist/lib/checkHasAppRouter.cjs.map +1 -1
- package/dist/lib/checkHasAppRouter.js +6 -2
- package/dist/lib/checkHasAppRouter.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/upsertSliceLibraryIndexFile.cjs +29 -21
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js +29 -20
- 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/package.json +5 -7
- package/src/hooks/documentation-read.ts +9 -7
- package/src/hooks/project-init.ts +58 -69
- package/src/hooks/slice-create.ts +39 -31
- package/src/lib/checkHasAppRouter.ts +6 -6
- package/src/lib/checkHasSrcDirectory.ts +5 -2
- package/src/lib/checkIsTypeScriptProject.ts +5 -4
- package/src/lib/upsertSliceLibraryIndexFile.ts +53 -33
- package/src/plugin.ts +245 -37
- 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 -63
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const fs = require("@slicemachine/plugin-kit/fs");
|
|
4
|
+
const path = require("node:path");
|
|
3
5
|
const checkHasSrcDirectory = require("./checkHasSrcDirectory.cjs");
|
|
4
|
-
|
|
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 path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
5
23
|
async function checkHasAppRouter(args) {
|
|
6
24
|
const hasSrcDirectory = await checkHasSrcDirectory.checkHasSrcDirectory({ helpers: args.helpers });
|
|
7
|
-
return await
|
|
25
|
+
return await fs.checkHasProjectFile({
|
|
26
|
+
filename: hasSrcDirectory ? path__namespace.join("src", "app") : "app",
|
|
27
|
+
helpers: args.helpers
|
|
28
|
+
});
|
|
8
29
|
}
|
|
9
30
|
exports.checkHasAppRouter = checkHasAppRouter;
|
|
10
31
|
//# sourceMappingURL=checkHasAppRouter.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkHasAppRouter.cjs","sources":["../../../src/lib/checkHasAppRouter.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\
|
|
1
|
+
{"version":3,"file":"checkHasAppRouter.cjs","sources":["../../../src/lib/checkHasAppRouter.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { checkHasProjectFile } from \"@slicemachine/plugin-kit/fs\";\nimport * as path from \"node:path\";\n\nimport { PluginOptions } from \"../types\";\nimport { checkHasSrcDirectory } from \"./checkHasSrcDirectory\";\n\ntype CheckHasAppRouterArgs = Pick<\n\tSliceMachineContext<PluginOptions>,\n\t\"helpers\"\n>;\n\nexport async function checkHasAppRouter(\n\targs: CheckHasAppRouterArgs,\n): Promise<boolean> {\n\tconst hasSrcDirectory = await checkHasSrcDirectory({ helpers: args.helpers });\n\n\treturn await checkHasProjectFile({\n\t\tfilename: hasSrcDirectory ? path.join(\"src\", \"app\") : \"app\",\n\t\thelpers: args.helpers,\n\t});\n}\n"],"names":["checkHasSrcDirectory","checkHasProjectFile","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA,eAAsB,kBACrB,MAA2B;AAE3B,QAAM,kBAAkB,MAAMA,0CAAqB,EAAE,SAAS,KAAK,SAAS;AAE5E,SAAO,MAAMC,GAAAA,oBAAoB;AAAA,IAChC,UAAU,kBAAkBC,gBAAK,KAAK,OAAO,KAAK,IAAI;AAAA,IACtD,SAAS,KAAK;AAAA,EAAA,CACd;AACF;;"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs";
|
|
2
|
+
import * as path from "node:path";
|
|
1
3
|
import { checkHasSrcDirectory } from "./checkHasSrcDirectory.js";
|
|
2
|
-
import { checkPathExists } from "./checkPathExists.js";
|
|
3
4
|
async function checkHasAppRouter(args) {
|
|
4
5
|
const hasSrcDirectory = await checkHasSrcDirectory({ helpers: args.helpers });
|
|
5
|
-
return await
|
|
6
|
+
return await checkHasProjectFile({
|
|
7
|
+
filename: hasSrcDirectory ? path.join("src", "app") : "app",
|
|
8
|
+
helpers: args.helpers
|
|
9
|
+
});
|
|
6
10
|
}
|
|
7
11
|
export {
|
|
8
12
|
checkHasAppRouter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkHasAppRouter.js","sources":["../../../src/lib/checkHasAppRouter.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\
|
|
1
|
+
{"version":3,"file":"checkHasAppRouter.js","sources":["../../../src/lib/checkHasAppRouter.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { checkHasProjectFile } from \"@slicemachine/plugin-kit/fs\";\nimport * as path from \"node:path\";\n\nimport { PluginOptions } from \"../types\";\nimport { checkHasSrcDirectory } from \"./checkHasSrcDirectory\";\n\ntype CheckHasAppRouterArgs = Pick<\n\tSliceMachineContext<PluginOptions>,\n\t\"helpers\"\n>;\n\nexport async function checkHasAppRouter(\n\targs: CheckHasAppRouterArgs,\n): Promise<boolean> {\n\tconst hasSrcDirectory = await checkHasSrcDirectory({ helpers: args.helpers });\n\n\treturn await checkHasProjectFile({\n\t\tfilename: hasSrcDirectory ? path.join(\"src\", \"app\") : \"app\",\n\t\thelpers: args.helpers,\n\t});\n}\n"],"names":[],"mappings":";;;AAYA,eAAsB,kBACrB,MAA2B;AAE3B,QAAM,kBAAkB,MAAM,qBAAqB,EAAE,SAAS,KAAK,SAAS;AAE5E,SAAO,MAAM,oBAAoB;AAAA,IAChC,UAAU,kBAAkB,KAAK,KAAK,OAAO,KAAK,IAAI;AAAA,IACtD,SAAS,KAAK;AAAA,EAAA,CACd;AACF;"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const fs = require("@slicemachine/plugin-kit/fs");
|
|
4
4
|
async function checkHasSrcDirectory(args) {
|
|
5
|
-
return await
|
|
5
|
+
return await fs.checkHasProjectFile({
|
|
6
|
+
filename: "src",
|
|
7
|
+
helpers: args.helpers
|
|
8
|
+
});
|
|
6
9
|
}
|
|
7
10
|
exports.checkHasSrcDirectory = checkHasSrcDirectory;
|
|
8
11
|
//# sourceMappingURL=checkHasSrcDirectory.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkHasSrcDirectory.cjs","sources":["../../../src/lib/checkHasSrcDirectory.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\
|
|
1
|
+
{"version":3,"file":"checkHasSrcDirectory.cjs","sources":["../../../src/lib/checkHasSrcDirectory.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { checkHasProjectFile } from \"@slicemachine/plugin-kit/fs\";\n\nimport { PluginOptions } from \"../types\";\n\ntype CheckHasSrcDirectoryArgs = Pick<\n\tSliceMachineContext<PluginOptions>,\n\t\"helpers\"\n>;\n\nexport async function checkHasSrcDirectory(\n\targs: CheckHasSrcDirectoryArgs,\n): Promise<boolean> {\n\treturn await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers: args.helpers,\n\t});\n}\n"],"names":["checkHasProjectFile"],"mappings":";;;AAUA,eAAsB,qBACrB,MAA8B;AAE9B,SAAO,MAAMA,GAAAA,oBAAoB;AAAA,IAChC,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AACF;;"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs";
|
|
2
2
|
async function checkHasSrcDirectory(args) {
|
|
3
|
-
return await
|
|
3
|
+
return await checkHasProjectFile({
|
|
4
|
+
filename: "src",
|
|
5
|
+
helpers: args.helpers
|
|
6
|
+
});
|
|
4
7
|
}
|
|
5
8
|
export {
|
|
6
9
|
checkHasSrcDirectory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkHasSrcDirectory.js","sources":["../../../src/lib/checkHasSrcDirectory.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\
|
|
1
|
+
{"version":3,"file":"checkHasSrcDirectory.js","sources":["../../../src/lib/checkHasSrcDirectory.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { checkHasProjectFile } from \"@slicemachine/plugin-kit/fs\";\n\nimport { PluginOptions } from \"../types\";\n\ntype CheckHasSrcDirectoryArgs = Pick<\n\tSliceMachineContext<PluginOptions>,\n\t\"helpers\"\n>;\n\nexport async function checkHasSrcDirectory(\n\targs: CheckHasSrcDirectoryArgs,\n): Promise<boolean> {\n\treturn await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers: args.helpers,\n\t});\n}\n"],"names":[],"mappings":";AAUA,eAAsB,qBACrB,MAA8B;AAE9B,SAAO,MAAM,oBAAoB;AAAA,IAChC,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AACF;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const fs = require("@slicemachine/plugin-kit/fs");
|
|
4
4
|
const checkIsTypeScriptProject = async (args) => {
|
|
5
|
-
|
|
6
|
-
return args.options.typescript ?? await checkPathExists.checkPathExists(tsConfigPath);
|
|
5
|
+
return args.options.typescript ?? fs.checkIsTypeScriptProject({ helpers: args.helpers });
|
|
7
6
|
};
|
|
8
7
|
exports.checkIsTypeScriptProject = checkIsTypeScriptProject;
|
|
9
8
|
//# sourceMappingURL=checkIsTypeScriptProject.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkIsTypeScriptProject.cjs","sources":["../../../src/lib/checkIsTypeScriptProject.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\
|
|
1
|
+
{"version":3,"file":"checkIsTypeScriptProject.cjs","sources":["../../../src/lib/checkIsTypeScriptProject.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { checkIsTypeScriptProject as baseCheckIsTypeScriptProject } from \"@slicemachine/plugin-kit/fs\";\n\nimport { PluginOptions } from \"../types\";\n\ntype CheckIsTypeScriptProjectArgs = {\n\thelpers: SliceMachineContext<PluginOptions>[\"helpers\"];\n\toptions: SliceMachineContext<PluginOptions>[\"options\"];\n};\n\nexport const checkIsTypeScriptProject = async (\n\targs: CheckIsTypeScriptProjectArgs,\n): Promise<boolean> => {\n\treturn (\n\t\targs.options.typescript ??\n\t\tbaseCheckIsTypeScriptProject({ helpers: args.helpers })\n\t);\n};\n"],"names":["baseCheckIsTypeScriptProject"],"mappings":";;;AAUa,MAAA,2BAA2B,OACvC,SACqB;AAEpB,SAAA,KAAK,QAAQ,cACbA,GAAAA,yBAA6B,EAAE,SAAS,KAAK,SAAS;AAExD;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { checkIsTypeScriptProject as checkIsTypeScriptProject$1 } from "@slicemachine/plugin-kit/fs";
|
|
2
2
|
const checkIsTypeScriptProject = async (args) => {
|
|
3
|
-
|
|
4
|
-
return args.options.typescript ?? await checkPathExists(tsConfigPath);
|
|
3
|
+
return args.options.typescript ?? checkIsTypeScriptProject$1({ helpers: args.helpers });
|
|
5
4
|
};
|
|
6
5
|
export {
|
|
7
6
|
checkIsTypeScriptProject
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkIsTypeScriptProject.js","sources":["../../../src/lib/checkIsTypeScriptProject.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\
|
|
1
|
+
{"version":3,"file":"checkIsTypeScriptProject.js","sources":["../../../src/lib/checkIsTypeScriptProject.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport { checkIsTypeScriptProject as baseCheckIsTypeScriptProject } from \"@slicemachine/plugin-kit/fs\";\n\nimport { PluginOptions } from \"../types\";\n\ntype CheckIsTypeScriptProjectArgs = {\n\thelpers: SliceMachineContext<PluginOptions>[\"helpers\"];\n\toptions: SliceMachineContext<PluginOptions>[\"options\"];\n};\n\nexport const checkIsTypeScriptProject = async (\n\targs: CheckIsTypeScriptProjectArgs,\n): Promise<boolean> => {\n\treturn (\n\t\targs.options.typescript ??\n\t\tbaseCheckIsTypeScriptProject({ helpers: args.helpers })\n\t);\n};\n"],"names":["baseCheckIsTypeScriptProject"],"mappings":";AAUa,MAAA,2BAA2B,OACvC,SACqB;AAEpB,SAAA,KAAK,QAAQ,cACbA,2BAA6B,EAAE,SAAS,KAAK,SAAS;AAExD;"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const fs = require("@slicemachine/plugin-kit/fs");
|
|
3
4
|
const commonTags = require("common-tags");
|
|
4
|
-
const fs = require("node:fs/promises");
|
|
5
5
|
const path = require("node:path");
|
|
6
6
|
const constants = require("../constants.cjs");
|
|
7
7
|
const pascalCase = require("./pascalCase.cjs");
|
|
8
|
-
const buildSliceLibraryDirectoryPath = require("./buildSliceLibraryDirectoryPath.cjs");
|
|
9
8
|
const getJSFileExtension = require("./getJSFileExtension.cjs");
|
|
10
9
|
function _interopNamespaceDefault(e) {
|
|
11
10
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -23,17 +22,8 @@ function _interopNamespaceDefault(e) {
|
|
|
23
22
|
n.default = e;
|
|
24
23
|
return Object.freeze(n);
|
|
25
24
|
}
|
|
26
|
-
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
27
25
|
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
28
26
|
const upsertSliceLibraryIndexFile = async (args) => {
|
|
29
|
-
const extension = await getJSFileExtension.getJSFileExtension({
|
|
30
|
-
helpers: args.helpers,
|
|
31
|
-
options: args.options
|
|
32
|
-
});
|
|
33
|
-
const filePath = path__namespace.join(buildSliceLibraryDirectoryPath.buildSliceLibraryDirectoryPath({
|
|
34
|
-
libraryID: args.libraryID,
|
|
35
|
-
helpers: args.helpers
|
|
36
|
-
}), `index.${extension}`);
|
|
37
27
|
const slices = await args.actions.readAllSliceModelsForLibrary({
|
|
38
28
|
libraryID: args.libraryID
|
|
39
29
|
});
|
|
@@ -45,22 +35,30 @@ const upsertSliceLibraryIndexFile = async (args) => {
|
|
|
45
35
|
import dynamic from 'next/dynamic'
|
|
46
36
|
|
|
47
37
|
export const components = {
|
|
48
|
-
${slices.map((slice) => {
|
|
38
|
+
${(await Promise.all(slices.map(async (slice) => {
|
|
49
39
|
const id = slice.model.id;
|
|
50
|
-
const dirName =
|
|
40
|
+
const dirName = path__namespace.basename(await fs.buildSliceDirectoryPath({
|
|
41
|
+
model: slice.model,
|
|
42
|
+
helpers: args.helpers,
|
|
43
|
+
libraryID: args.libraryID
|
|
44
|
+
}));
|
|
51
45
|
return `${id}: dynamic(() => import('./${dirName}'))`;
|
|
52
|
-
}).join(",\n")}
|
|
46
|
+
}))).join(",\n")}
|
|
53
47
|
}
|
|
54
48
|
`;
|
|
55
49
|
} else {
|
|
56
50
|
contents = commonTags.stripIndent`
|
|
57
51
|
${constants.NON_EDITABLE_FILE_BANNER}
|
|
58
52
|
|
|
59
|
-
${slices.map((slice) => {
|
|
53
|
+
${(await Promise.all(slices.map(async (slice) => {
|
|
54
|
+
const dirName = path__namespace.basename(await fs.buildSliceDirectoryPath({
|
|
55
|
+
model: slice.model,
|
|
56
|
+
helpers: args.helpers,
|
|
57
|
+
libraryID: args.libraryID
|
|
58
|
+
}));
|
|
60
59
|
const componentName = pascalCase.pascalCase(slice.model.name);
|
|
61
|
-
const dirName = pascalCase.pascalCase(slice.model.name);
|
|
62
60
|
return `import ${componentName} from "./${dirName}";`;
|
|
63
|
-
}).join("\n")}
|
|
61
|
+
}))).join("\n")}
|
|
64
62
|
|
|
65
63
|
export const components = {
|
|
66
64
|
${slices.map((slice) => {
|
|
@@ -71,10 +69,20 @@ const upsertSliceLibraryIndexFile = async (args) => {
|
|
|
71
69
|
}
|
|
72
70
|
`;
|
|
73
71
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
const extension = await getJSFileExtension.getJSFileExtension({
|
|
73
|
+
helpers: args.helpers,
|
|
74
|
+
options: args.options
|
|
75
|
+
});
|
|
76
|
+
const filePath = path__namespace.join(fs.buildSliceLibraryDirectoryPath({
|
|
77
|
+
libraryID: args.libraryID,
|
|
78
|
+
helpers: args.helpers
|
|
79
|
+
}), `index.${extension}`);
|
|
80
|
+
await fs.writeProjectFile({
|
|
81
|
+
filename: filePath,
|
|
82
|
+
contents,
|
|
83
|
+
format: args.options.format,
|
|
84
|
+
helpers: args.helpers
|
|
85
|
+
});
|
|
78
86
|
};
|
|
79
87
|
exports.upsertSliceLibraryIndexFile = upsertSliceLibraryIndexFile;
|
|
80
88
|
//# sourceMappingURL=upsertSliceLibraryIndexFile.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertSliceLibraryIndexFile.cjs","sources":["../../../src/lib/upsertSliceLibraryIndexFile.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport {
|
|
1
|
+
{"version":3,"file":"upsertSliceLibraryIndexFile.cjs","sources":["../../../src/lib/upsertSliceLibraryIndexFile.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport {\n\tbuildSliceDirectoryPath,\n\tbuildSliceLibraryDirectoryPath,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\nimport * as path from \"node:path\";\nimport { NON_EDITABLE_FILE_BANNER } from \"../constants\";\n\nimport { PluginOptions } from \"../types\";\n\nimport { pascalCase } from \"./pascalCase\";\nimport { getJSFileExtension } from \"./getJSFileExtension\";\n\ntype UpsertSliceLibraryIndexFileArgs = {\n\tlibraryID: string;\n} & SliceMachineContext<PluginOptions>;\n\nexport const upsertSliceLibraryIndexFile = async (\n\targs: UpsertSliceLibraryIndexFileArgs,\n): Promise<void> => {\n\tconst slices = await args.actions.readAllSliceModelsForLibrary({\n\t\tlibraryID: args.libraryID,\n\t});\n\n\tlet contents: string;\n\n\tif (args.options.lazyLoadSlices) {\n\t\tcontents = stripIndent`\n\t\t\t${NON_EDITABLE_FILE_BANNER}\n\n\t\t\timport dynamic from 'next/dynamic'\n\n\t\t\texport const components = {\n\t\t\t\t${(\n\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\tslices.map(async (slice) => {\n\t\t\t\t\t\t\tconst id = slice.model.id;\n\t\t\t\t\t\t\tconst dirName = path.basename(\n\t\t\t\t\t\t\t\tawait buildSliceDirectoryPath({\n\t\t\t\t\t\t\t\t\tmodel: slice.model,\n\t\t\t\t\t\t\t\t\thelpers: args.helpers,\n\t\t\t\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\treturn `${id}: dynamic(() => import('./${dirName}'))`;\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t).join(\",\\n\")}\n\t\t\t}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t${NON_EDITABLE_FILE_BANNER}\n\n\t\t\t${(\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tslices.map(async (slice) => {\n\t\t\t\t\t\tconst dirName = path.basename(\n\t\t\t\t\t\t\tawait buildSliceDirectoryPath({\n\t\t\t\t\t\t\t\tmodel: slice.model,\n\t\t\t\t\t\t\t\thelpers: args.helpers,\n\t\t\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst componentName = pascalCase(slice.model.name);\n\n\t\t\t\t\t\treturn `import ${componentName} from \"./${dirName}\";`;\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t).join(\"\\n\")}\n\n\t\t\texport const components = {\n\t\t\t\t${slices\n\t\t\t\t\t.map((slice) => {\n\t\t\t\t\t\tconst id = slice.model.id;\n\t\t\t\t\t\tconst componentName = pascalCase(slice.model.name);\n\n\t\t\t\t\t\treturn `${id}: ${componentName},`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\")}\n\t\t\t}\n\t\t`;\n\t}\n\n\tconst extension = await getJSFileExtension({\n\t\thelpers: args.helpers,\n\t\toptions: args.options,\n\t});\n\tconst filePath = path.join(\n\t\tbuildSliceLibraryDirectoryPath({\n\t\t\tlibraryID: args.libraryID,\n\t\t\thelpers: args.helpers,\n\t\t}),\n\t\t`index.${extension}`,\n\t);\n\n\tawait writeProjectFile({\n\t\tfilename: filePath,\n\t\tcontents,\n\t\tformat: args.options.format,\n\t\thelpers: args.helpers,\n\t});\n};\n"],"names":["stripIndent","NON_EDITABLE_FILE_BANNER","path","buildSliceDirectoryPath","pascalCase","getJSFileExtension","buildSliceLibraryDirectoryPath","writeProjectFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmBa,MAAA,8BAA8B,OAC1C,SACkB;AAClB,QAAM,SAAS,MAAM,KAAK,QAAQ,6BAA6B;AAAA,IAC9D,WAAW,KAAK;AAAA,EAAA,CAChB;AAEG,MAAA;AAEA,MAAA,KAAK,QAAQ,gBAAgB;AACrB,eAAAA,WAAAA;AAAAA,KACRC;;;;;OAMA,MAAM,QAAQ,IACb,OAAO,IAAI,OAAO,UAAS;AACpB,YAAA,KAAK,MAAM,MAAM;AACvB,YAAM,UAAUC,gBAAK,SACpB,MAAMC,GAAAA,wBAAwB;AAAA,QAC7B,OAAO,MAAM;AAAA,QACb,SAAS,KAAK;AAAA,QACd,WAAW,KAAK;AAAA,MAChB,CAAA,CAAC;AAGH,aAAO,GAAG,+BAA+B;AAAA,IAAA,CACzC,CAAC,GAEF,KAAK,KAAK;AAAA;AAAA;AAAA,EAAA,OAGR;AACK,eAAAH,WAAAA;AAAAA,KACRC;;MAGD,MAAM,QAAQ,IACb,OAAO,IAAI,OAAO,UAAS;AAC1B,YAAM,UAAUC,gBAAK,SACpB,MAAMC,GAAAA,wBAAwB;AAAA,QAC7B,OAAO,MAAM;AAAA,QACb,SAAS,KAAK;AAAA,QACd,WAAW,KAAK;AAAA,MAChB,CAAA,CAAC;AAEH,YAAM,gBAAgBC,WAAA,WAAW,MAAM,MAAM,IAAI;AAEjD,aAAO,UAAU,yBAAyB;AAAA,IAAA,CAC1C,CAAC,GAEF,KAAK,IAAI;AAAA;AAAA;AAAA,MAGR,OACA,IAAI,CAAC,UAAS;AACR,YAAA,KAAK,MAAM,MAAM;AACvB,YAAM,gBAAgBA,WAAA,WAAW,MAAM,MAAM,IAAI;AAEjD,aAAO,GAAG,OAAO;AAAA,IAAA,CACjB,EACA,KAAK,IAAI;AAAA;AAAA;AAAA,EAGb;AAEK,QAAA,YAAY,MAAMC,sCAAmB;AAAA,IAC1C,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,EAAA,CACd;AACK,QAAA,WAAWH,gBAAK,KACrBI,kCAA+B;AAAA,IAC9B,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,EACd,CAAA,GACD,SAAS,WAAW;AAGrB,QAAMC,oBAAiB;AAAA,IACtB,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,KAAK,QAAQ;AAAA,IACrB,SAAS,KAAK;AAAA,EAAA,CACd;AACF;;"}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
+
import { buildSliceDirectoryPath, buildSliceLibraryDirectoryPath, writeProjectFile } from "@slicemachine/plugin-kit/fs";
|
|
1
2
|
import { stripIndent } from "common-tags";
|
|
2
|
-
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { NON_EDITABLE_FILE_BANNER } from "../constants.js";
|
|
5
5
|
import { pascalCase } from "./pascalCase.js";
|
|
6
|
-
import { buildSliceLibraryDirectoryPath } from "./buildSliceLibraryDirectoryPath.js";
|
|
7
6
|
import { getJSFileExtension } from "./getJSFileExtension.js";
|
|
8
7
|
const upsertSliceLibraryIndexFile = async (args) => {
|
|
9
|
-
const extension = await getJSFileExtension({
|
|
10
|
-
helpers: args.helpers,
|
|
11
|
-
options: args.options
|
|
12
|
-
});
|
|
13
|
-
const filePath = path.join(buildSliceLibraryDirectoryPath({
|
|
14
|
-
libraryID: args.libraryID,
|
|
15
|
-
helpers: args.helpers
|
|
16
|
-
}), `index.${extension}`);
|
|
17
8
|
const slices = await args.actions.readAllSliceModelsForLibrary({
|
|
18
9
|
libraryID: args.libraryID
|
|
19
10
|
});
|
|
@@ -25,22 +16,30 @@ const upsertSliceLibraryIndexFile = async (args) => {
|
|
|
25
16
|
import dynamic from 'next/dynamic'
|
|
26
17
|
|
|
27
18
|
export const components = {
|
|
28
|
-
${slices.map((slice) => {
|
|
19
|
+
${(await Promise.all(slices.map(async (slice) => {
|
|
29
20
|
const id = slice.model.id;
|
|
30
|
-
const dirName =
|
|
21
|
+
const dirName = path.basename(await buildSliceDirectoryPath({
|
|
22
|
+
model: slice.model,
|
|
23
|
+
helpers: args.helpers,
|
|
24
|
+
libraryID: args.libraryID
|
|
25
|
+
}));
|
|
31
26
|
return `${id}: dynamic(() => import('./${dirName}'))`;
|
|
32
|
-
}).join(",\n")}
|
|
27
|
+
}))).join(",\n")}
|
|
33
28
|
}
|
|
34
29
|
`;
|
|
35
30
|
} else {
|
|
36
31
|
contents = stripIndent`
|
|
37
32
|
${NON_EDITABLE_FILE_BANNER}
|
|
38
33
|
|
|
39
|
-
${slices.map((slice) => {
|
|
34
|
+
${(await Promise.all(slices.map(async (slice) => {
|
|
35
|
+
const dirName = path.basename(await buildSliceDirectoryPath({
|
|
36
|
+
model: slice.model,
|
|
37
|
+
helpers: args.helpers,
|
|
38
|
+
libraryID: args.libraryID
|
|
39
|
+
}));
|
|
40
40
|
const componentName = pascalCase(slice.model.name);
|
|
41
|
-
const dirName = pascalCase(slice.model.name);
|
|
42
41
|
return `import ${componentName} from "./${dirName}";`;
|
|
43
|
-
}).join("\n")}
|
|
42
|
+
}))).join("\n")}
|
|
44
43
|
|
|
45
44
|
export const components = {
|
|
46
45
|
${slices.map((slice) => {
|
|
@@ -51,10 +50,20 @@ const upsertSliceLibraryIndexFile = async (args) => {
|
|
|
51
50
|
}
|
|
52
51
|
`;
|
|
53
52
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
const extension = await getJSFileExtension({
|
|
54
|
+
helpers: args.helpers,
|
|
55
|
+
options: args.options
|
|
56
|
+
});
|
|
57
|
+
const filePath = path.join(buildSliceLibraryDirectoryPath({
|
|
58
|
+
libraryID: args.libraryID,
|
|
59
|
+
helpers: args.helpers
|
|
60
|
+
}), `index.${extension}`);
|
|
61
|
+
await writeProjectFile({
|
|
62
|
+
filename: filePath,
|
|
63
|
+
contents,
|
|
64
|
+
format: args.options.format,
|
|
65
|
+
helpers: args.helpers
|
|
66
|
+
});
|
|
58
67
|
};
|
|
59
68
|
export {
|
|
60
69
|
upsertSliceLibraryIndexFile
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertSliceLibraryIndexFile.js","sources":["../../../src/lib/upsertSliceLibraryIndexFile.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport {
|
|
1
|
+
{"version":3,"file":"upsertSliceLibraryIndexFile.js","sources":["../../../src/lib/upsertSliceLibraryIndexFile.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\nimport {\n\tbuildSliceDirectoryPath,\n\tbuildSliceLibraryDirectoryPath,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { stripIndent } from \"common-tags\";\nimport * as path from \"node:path\";\nimport { NON_EDITABLE_FILE_BANNER } from \"../constants\";\n\nimport { PluginOptions } from \"../types\";\n\nimport { pascalCase } from \"./pascalCase\";\nimport { getJSFileExtension } from \"./getJSFileExtension\";\n\ntype UpsertSliceLibraryIndexFileArgs = {\n\tlibraryID: string;\n} & SliceMachineContext<PluginOptions>;\n\nexport const upsertSliceLibraryIndexFile = async (\n\targs: UpsertSliceLibraryIndexFileArgs,\n): Promise<void> => {\n\tconst slices = await args.actions.readAllSliceModelsForLibrary({\n\t\tlibraryID: args.libraryID,\n\t});\n\n\tlet contents: string;\n\n\tif (args.options.lazyLoadSlices) {\n\t\tcontents = stripIndent`\n\t\t\t${NON_EDITABLE_FILE_BANNER}\n\n\t\t\timport dynamic from 'next/dynamic'\n\n\t\t\texport const components = {\n\t\t\t\t${(\n\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\tslices.map(async (slice) => {\n\t\t\t\t\t\t\tconst id = slice.model.id;\n\t\t\t\t\t\t\tconst dirName = path.basename(\n\t\t\t\t\t\t\t\tawait buildSliceDirectoryPath({\n\t\t\t\t\t\t\t\t\tmodel: slice.model,\n\t\t\t\t\t\t\t\t\thelpers: args.helpers,\n\t\t\t\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\treturn `${id}: dynamic(() => import('./${dirName}'))`;\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t).join(\",\\n\")}\n\t\t\t}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t${NON_EDITABLE_FILE_BANNER}\n\n\t\t\t${(\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tslices.map(async (slice) => {\n\t\t\t\t\t\tconst dirName = path.basename(\n\t\t\t\t\t\t\tawait buildSliceDirectoryPath({\n\t\t\t\t\t\t\t\tmodel: slice.model,\n\t\t\t\t\t\t\t\thelpers: args.helpers,\n\t\t\t\t\t\t\t\tlibraryID: args.libraryID,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst componentName = pascalCase(slice.model.name);\n\n\t\t\t\t\t\treturn `import ${componentName} from \"./${dirName}\";`;\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t).join(\"\\n\")}\n\n\t\t\texport const components = {\n\t\t\t\t${slices\n\t\t\t\t\t.map((slice) => {\n\t\t\t\t\t\tconst id = slice.model.id;\n\t\t\t\t\t\tconst componentName = pascalCase(slice.model.name);\n\n\t\t\t\t\t\treturn `${id}: ${componentName},`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\")}\n\t\t\t}\n\t\t`;\n\t}\n\n\tconst extension = await getJSFileExtension({\n\t\thelpers: args.helpers,\n\t\toptions: args.options,\n\t});\n\tconst filePath = path.join(\n\t\tbuildSliceLibraryDirectoryPath({\n\t\t\tlibraryID: args.libraryID,\n\t\t\thelpers: args.helpers,\n\t\t}),\n\t\t`index.${extension}`,\n\t);\n\n\tawait writeProjectFile({\n\t\tfilename: filePath,\n\t\tcontents,\n\t\tformat: args.options.format,\n\t\thelpers: args.helpers,\n\t});\n};\n"],"names":[],"mappings":";;;;;;AAmBa,MAAA,8BAA8B,OAC1C,SACkB;AAClB,QAAM,SAAS,MAAM,KAAK,QAAQ,6BAA6B;AAAA,IAC9D,WAAW,KAAK;AAAA,EAAA,CAChB;AAEG,MAAA;AAEA,MAAA,KAAK,QAAQ,gBAAgB;AACrB,eAAA;AAAA,KACR;AAAA;AAAA;AAAA;AAAA;AAAA,OAMA,MAAM,QAAQ,IACb,OAAO,IAAI,OAAO,UAAS;AACpB,YAAA,KAAK,MAAM,MAAM;AACvB,YAAM,UAAU,KAAK,SACpB,MAAM,wBAAwB;AAAA,QAC7B,OAAO,MAAM;AAAA,QACb,SAAS,KAAK;AAAA,QACd,WAAW,KAAK;AAAA,MAChB,CAAA,CAAC;AAGH,aAAO,GAAG,+BAA+B;AAAA,IAAA,CACzC,CAAC,GAEF,KAAK,KAAK;AAAA;AAAA;AAAA,EAAA,OAGR;AACK,eAAA;AAAA,KACR;AAAA;AAAA,MAGD,MAAM,QAAQ,IACb,OAAO,IAAI,OAAO,UAAS;AAC1B,YAAM,UAAU,KAAK,SACpB,MAAM,wBAAwB;AAAA,QAC7B,OAAO,MAAM;AAAA,QACb,SAAS,KAAK;AAAA,QACd,WAAW,KAAK;AAAA,MAChB,CAAA,CAAC;AAEH,YAAM,gBAAgB,WAAW,MAAM,MAAM,IAAI;AAEjD,aAAO,UAAU,yBAAyB;AAAA,IAAA,CAC1C,CAAC,GAEF,KAAK,IAAI;AAAA;AAAA;AAAA,MAGR,OACA,IAAI,CAAC,UAAS;AACR,YAAA,KAAK,MAAM,MAAM;AACvB,YAAM,gBAAgB,WAAW,MAAM,MAAM,IAAI;AAEjD,aAAO,GAAG,OAAO;AAAA,IAAA,CACjB,EACA,KAAK,IAAI;AAAA;AAAA;AAAA,EAGb;AAEK,QAAA,YAAY,MAAM,mBAAmB;AAAA,IAC1C,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,EAAA,CACd;AACK,QAAA,WAAW,KAAK,KACrB,+BAA+B;AAAA,IAC9B,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,EACd,CAAA,GACD,SAAS,WAAW;AAGrB,QAAM,iBAAiB;AAAA,IACtB,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,KAAK,QAAQ;AAAA,IACrB,SAAS,KAAK;AAAA,EAAA,CACd;AACF;"}
|
package/dist/plugin.cjs
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const pluginKit = require("@slicemachine/plugin-kit");
|
|
4
|
+
const fs = require("@slicemachine/plugin-kit/fs");
|
|
5
|
+
const rejectIfNecessary = require("./lib/rejectIfNecessary.cjs");
|
|
6
|
+
const upsertSliceLibraryIndexFile = require("./lib/upsertSliceLibraryIndexFile.cjs");
|
|
4
7
|
const _package = require("./packages/adapter-next/package.json.cjs");
|
|
8
|
+
const documentationRead = require("./hooks/documentation-read.cjs");
|
|
5
9
|
const projectInit = require("./hooks/project-init.cjs");
|
|
6
|
-
const customTypeAssetDelete = require("./hooks/customType-asset-delete.cjs");
|
|
7
|
-
const customTypeAssetRead = require("./hooks/customType-asset-read.cjs");
|
|
8
|
-
const customTypeAssetUpdate = require("./hooks/customType-asset-update.cjs");
|
|
9
|
-
const customTypeCreate = require("./hooks/customType-create.cjs");
|
|
10
|
-
const customTypeDelete = require("./hooks/customType-delete.cjs");
|
|
11
|
-
const customTypeLibraryRead = require("./hooks/customTypeLibrary-read.cjs");
|
|
12
|
-
const customTypeRead = require("./hooks/customType-read.cjs");
|
|
13
|
-
const customTypeRename = require("./hooks/customType-rename.cjs");
|
|
14
|
-
const customTypeUpdate = require("./hooks/customType-update.cjs");
|
|
15
|
-
const sliceAssetDelete = require("./hooks/slice-asset-delete.cjs");
|
|
16
|
-
const sliceAssetRead = require("./hooks/slice-asset-read.cjs");
|
|
17
|
-
const sliceAssetUpdate = require("./hooks/slice-asset-update.cjs");
|
|
18
10
|
const sliceCreate = require("./hooks/slice-create.cjs");
|
|
19
|
-
const sliceDelete = require("./hooks/slice-delete.cjs");
|
|
20
|
-
const sliceLibraryRead = require("./hooks/sliceLibrary-read.cjs");
|
|
21
|
-
const sliceRead = require("./hooks/slice-read.cjs");
|
|
22
|
-
const sliceRename = require("./hooks/slice-rename.cjs");
|
|
23
|
-
const sliceUpdate = require("./hooks/slice-update.cjs");
|
|
24
|
-
const snippetRead = require("./hooks/snippet-read.cjs");
|
|
25
|
-
const documentationRead = require("./hooks/documentation-read.cjs");
|
|
26
11
|
const sliceSimulatorSetupRead = require("./hooks/sliceSimulator-setup-read.cjs");
|
|
12
|
+
const snippetRead = require("./hooks/snippet-read.cjs");
|
|
27
13
|
const plugin = pluginKit.defineSliceMachinePlugin({
|
|
28
14
|
meta: {
|
|
29
15
|
name: _package.name
|
|
@@ -35,23 +21,179 @@ const plugin = pluginKit.defineSliceMachinePlugin({
|
|
|
35
21
|
setup({ hook }) {
|
|
36
22
|
hook("project:init", projectInit.projectInit);
|
|
37
23
|
hook("slice:create", sliceCreate.sliceCreate);
|
|
38
|
-
hook("slice:update",
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
hook("
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
24
|
+
hook("slice:update", async (data, context) => {
|
|
25
|
+
await fs.writeSliceModel({
|
|
26
|
+
libraryID: data.libraryID,
|
|
27
|
+
model: data.model,
|
|
28
|
+
...context
|
|
29
|
+
});
|
|
30
|
+
await fs.upsertGlobalTypeScriptTypes({
|
|
31
|
+
filename: context.options.generatedTypesFilePath,
|
|
32
|
+
format: context.options.format,
|
|
33
|
+
...context
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
hook("slice:rename", async (data, context) => {
|
|
37
|
+
await fs.renameSlice({
|
|
38
|
+
libraryID: data.libraryID,
|
|
39
|
+
model: data.model,
|
|
40
|
+
format: context.options.format,
|
|
41
|
+
...context
|
|
42
|
+
});
|
|
43
|
+
rejectIfNecessary.rejectIfNecessary(await Promise.allSettled([
|
|
44
|
+
upsertSliceLibraryIndexFile.upsertSliceLibraryIndexFile({
|
|
45
|
+
libraryID: data.libraryID,
|
|
46
|
+
...context
|
|
47
|
+
}),
|
|
48
|
+
fs.upsertGlobalTypeScriptTypes({
|
|
49
|
+
filename: context.options.generatedTypesFilePath,
|
|
50
|
+
format: context.options.format,
|
|
51
|
+
...context
|
|
52
|
+
})
|
|
53
|
+
]));
|
|
54
|
+
});
|
|
55
|
+
hook("slice:delete", async (data, context) => {
|
|
56
|
+
await fs.deleteSliceDirectory({
|
|
57
|
+
libraryID: data.libraryID,
|
|
58
|
+
model: data.model,
|
|
59
|
+
...context
|
|
60
|
+
});
|
|
61
|
+
rejectIfNecessary.rejectIfNecessary(await Promise.allSettled([
|
|
62
|
+
upsertSliceLibraryIndexFile.upsertSliceLibraryIndexFile({
|
|
63
|
+
libraryID: data.libraryID,
|
|
64
|
+
...context
|
|
65
|
+
}),
|
|
66
|
+
fs.upsertGlobalTypeScriptTypes({
|
|
67
|
+
filename: context.options.generatedTypesFilePath,
|
|
68
|
+
format: context.options.format,
|
|
69
|
+
...context
|
|
70
|
+
})
|
|
71
|
+
]));
|
|
72
|
+
});
|
|
73
|
+
hook("slice:read", async (data, context) => {
|
|
74
|
+
return await fs.readSliceModel({
|
|
75
|
+
libraryID: data.libraryID,
|
|
76
|
+
sliceID: data.sliceID,
|
|
77
|
+
...context
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
hook("slice:asset:update", async (data, context) => {
|
|
81
|
+
await fs.writeSliceFile({
|
|
82
|
+
libraryID: data.libraryID,
|
|
83
|
+
sliceID: data.sliceID,
|
|
84
|
+
filename: data.asset.id,
|
|
85
|
+
contents: data.asset.data,
|
|
86
|
+
...context
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
hook("slice:asset:delete", async (data, context) => {
|
|
90
|
+
await fs.deleteSliceFile({
|
|
91
|
+
libraryID: data.libraryID,
|
|
92
|
+
sliceID: data.sliceID,
|
|
93
|
+
filename: data.assetID,
|
|
94
|
+
...context
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
hook("slice:asset:read", async (data, context) => {
|
|
98
|
+
const file = await fs.readSliceFile({
|
|
99
|
+
libraryID: data.libraryID,
|
|
100
|
+
sliceID: data.sliceID,
|
|
101
|
+
filename: data.assetID,
|
|
102
|
+
...context
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
data: file
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
hook("slice-library:read", async (data, context) => {
|
|
109
|
+
return await fs.readSliceLibrary({
|
|
110
|
+
libraryID: data.libraryID,
|
|
111
|
+
...context
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
hook("custom-type:create", async (data, context) => {
|
|
115
|
+
await fs.writeCustomTypeModel({
|
|
116
|
+
model: data.model,
|
|
117
|
+
format: context.options.format,
|
|
118
|
+
...context
|
|
119
|
+
});
|
|
120
|
+
await fs.upsertGlobalTypeScriptTypes({
|
|
121
|
+
filename: context.options.generatedTypesFilePath,
|
|
122
|
+
format: context.options.format,
|
|
123
|
+
...context
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
hook("custom-type:update", async (data, context) => {
|
|
127
|
+
await fs.writeCustomTypeModel({
|
|
128
|
+
model: data.model,
|
|
129
|
+
format: context.options.format,
|
|
130
|
+
...context
|
|
131
|
+
});
|
|
132
|
+
await fs.upsertGlobalTypeScriptTypes({
|
|
133
|
+
filename: context.options.generatedTypesFilePath,
|
|
134
|
+
format: context.options.format,
|
|
135
|
+
...context
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
hook("custom-type:rename", async (data, context) => {
|
|
139
|
+
await fs.renameCustomType({
|
|
140
|
+
model: data.model,
|
|
141
|
+
format: context.options.format,
|
|
142
|
+
...context
|
|
143
|
+
});
|
|
144
|
+
await fs.upsertGlobalTypeScriptTypes({
|
|
145
|
+
filename: context.options.generatedTypesFilePath,
|
|
146
|
+
format: context.options.format,
|
|
147
|
+
...context
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
hook("custom-type:delete", async (data, context) => {
|
|
151
|
+
await fs.deleteCustomTypeDirectory({
|
|
152
|
+
customTypeID: data.model.id,
|
|
153
|
+
...context
|
|
154
|
+
});
|
|
155
|
+
await fs.upsertGlobalTypeScriptTypes({
|
|
156
|
+
filename: context.options.generatedTypesFilePath,
|
|
157
|
+
format: context.options.format,
|
|
158
|
+
...context
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
hook("custom-type:read", async (data, context) => {
|
|
162
|
+
return await fs.readCustomTypeModel({
|
|
163
|
+
customTypeID: data.id,
|
|
164
|
+
...context
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
hook("custom-type:asset:update", async (data, context) => {
|
|
168
|
+
await fs.writeCustomTypeFile({
|
|
169
|
+
customTypeID: data.customTypeID,
|
|
170
|
+
filename: data.asset.id,
|
|
171
|
+
contents: data.asset.data,
|
|
172
|
+
...context
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
hook("custom-type:asset:delete", async (data, context) => {
|
|
176
|
+
await fs.deleteCustomTypeFile({
|
|
177
|
+
customTypeID: data.customTypeID,
|
|
178
|
+
filename: data.assetID,
|
|
179
|
+
...context
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
hook("custom-type:asset:read", async (data, context) => {
|
|
183
|
+
const file = await fs.readCustomTypeFile({
|
|
184
|
+
customTypeID: data.customTypeID,
|
|
185
|
+
filename: data.assetID,
|
|
186
|
+
...context
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
data: file
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
hook("custom-type-library:read", async (_data, context) => {
|
|
193
|
+
return await fs.readCustomTypeLibrary({
|
|
194
|
+
helpers: context.helpers
|
|
195
|
+
});
|
|
196
|
+
});
|
|
55
197
|
hook("snippet:read", snippetRead.snippetRead);
|
|
56
198
|
hook("documentation:read", documentationRead.documentationRead);
|
|
57
199
|
hook("slice-simulator:setup:read", sliceSimulatorSetupRead.sliceSimulatorSetupRead);
|