@slicemachine/adapter-next 0.0.12 → 0.0.13-dev-plugins-validation.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/{node_modules → _node_modules}/data-uri-to-buffer/dist/index.cjs +1 -1
- package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -0
- package/dist/{node_modules → _node_modules}/data-uri-to-buffer/dist/index.js +1 -1
- package/dist/_node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
- package/dist/_node_modules/fetch-blob/file.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/file.js.map +1 -0
- package/dist/_node_modules/fetch-blob/index.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/index.js.map +1 -0
- package/dist/_node_modules/fetch-blob/streams.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/streams.js.map +1 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.cjs.map +1 -0
- package/dist/_node_modules/formdata-polyfill/esm.min.js.map +1 -0
- package/dist/_node_modules/node-domexception/index.cjs.map +1 -0
- package/dist/_node_modules/node-domexception/index.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/body.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/body.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/abort-error.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/abort-error.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/base.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/base.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/fetch-error.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/headers.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/headers.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/index.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/index.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/request.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/request.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/response.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/response.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/get-search.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/get-search.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/is-redirect.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/is-redirect.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/is.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/is.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/referrer.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/utils/referrer.js.map +1 -0
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -0
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
- package/dist/hooks/customType-asset-delete.cjs +6 -1
- package/dist/hooks/customType-asset-delete.cjs.map +1 -1
- package/dist/hooks/customType-asset-delete.js +6 -1
- package/dist/hooks/customType-asset-delete.js.map +1 -1
- package/dist/hooks/customType-asset-read.cjs +6 -1
- package/dist/hooks/customType-asset-read.cjs.map +1 -1
- package/dist/hooks/customType-asset-read.js +6 -1
- package/dist/hooks/customType-asset-read.js.map +1 -1
- package/dist/hooks/customType-asset-update.cjs +6 -1
- package/dist/hooks/customType-asset-update.cjs.map +1 -1
- package/dist/hooks/customType-asset-update.js +6 -1
- package/dist/hooks/customType-asset-update.js.map +1 -1
- package/dist/hooks/customType-create.cjs +5 -1
- package/dist/hooks/customType-create.cjs.map +1 -1
- package/dist/hooks/customType-create.js +5 -1
- package/dist/hooks/customType-create.js.map +1 -1
- package/dist/hooks/customType-delete.cjs +5 -1
- package/dist/hooks/customType-delete.cjs.map +1 -1
- package/dist/hooks/customType-delete.js +5 -1
- package/dist/hooks/customType-delete.js.map +1 -1
- package/dist/hooks/customType-read.cjs +20 -1
- package/dist/hooks/customType-read.cjs.map +1 -1
- package/dist/hooks/customType-read.js +3 -1
- package/dist/hooks/customType-read.js.map +1 -1
- package/dist/hooks/customTypeLibrary-read.cjs +2 -1
- package/dist/hooks/customTypeLibrary-read.cjs.map +1 -1
- package/dist/hooks/customTypeLibrary-read.js +2 -1
- package/dist/hooks/customTypeLibrary-read.js.map +1 -1
- package/dist/hooks/{command-init.cjs → project-init.cjs} +3 -3
- package/dist/hooks/{command-init.cjs.map → project-init.cjs.map} +1 -1
- package/dist/hooks/project-init.d.ts +3 -0
- package/dist/hooks/{command-init.js → project-init.js} +3 -3
- package/dist/hooks/{command-init.js.map → project-init.js.map} +1 -1
- package/dist/hooks/slice-asset-delete.cjs +8 -2
- package/dist/hooks/slice-asset-delete.cjs.map +1 -1
- package/dist/hooks/slice-asset-delete.js +8 -2
- package/dist/hooks/slice-asset-delete.js.map +1 -1
- package/dist/hooks/slice-asset-read.cjs +8 -2
- package/dist/hooks/slice-asset-read.cjs.map +1 -1
- package/dist/hooks/slice-asset-read.js +8 -2
- package/dist/hooks/slice-asset-read.js.map +1 -1
- package/dist/hooks/slice-asset-update.cjs +8 -2
- package/dist/hooks/slice-asset-update.cjs.map +1 -1
- package/dist/hooks/slice-asset-update.js +8 -2
- package/dist/hooks/slice-asset-update.js.map +1 -1
- package/dist/hooks/slice-create.cjs +12 -10
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +12 -10
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/hooks/slice-delete.cjs +6 -2
- package/dist/hooks/slice-delete.cjs.map +1 -1
- package/dist/hooks/slice-delete.js +6 -2
- package/dist/hooks/slice-delete.js.map +1 -1
- package/dist/hooks/slice-read.cjs +5 -1
- package/dist/hooks/slice-read.cjs.map +1 -1
- package/dist/hooks/slice-read.js +5 -1
- package/dist/hooks/slice-read.js.map +1 -1
- package/dist/hooks/slice-rename.cjs +10 -2
- package/dist/hooks/slice-rename.cjs.map +1 -1
- package/dist/hooks/slice-rename.js +10 -2
- package/dist/hooks/slice-rename.js.map +1 -1
- package/dist/hooks/sliceLibrary-read.cjs +5 -1
- package/dist/hooks/sliceLibrary-read.cjs.map +1 -1
- package/dist/hooks/sliceLibrary-read.js +5 -1
- package/dist/hooks/sliceLibrary-read.js.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.cjs +1 -1
- package/dist/hooks/sliceSimulator-setup-read.js +1 -1
- package/dist/lib/buildCustomTypeAssetPath.cjs +29 -0
- package/dist/lib/buildCustomTypeAssetPath.cjs.map +1 -0
- package/dist/lib/buildCustomTypeAssetPath.d.ts +9 -0
- package/dist/lib/buildCustomTypeAssetPath.js +12 -0
- package/dist/lib/buildCustomTypeAssetPath.js.map +1 -0
- package/dist/lib/buildCustomTypeDirectoryPath.cjs +26 -0
- package/dist/lib/buildCustomTypeDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildCustomTypeDirectoryPath.d.ts +8 -0
- package/dist/lib/buildCustomTypeDirectoryPath.js +9 -0
- package/dist/lib/buildCustomTypeDirectoryPath.js.map +1 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs +7 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.d.ts +7 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.js +7 -0
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.js.map +1 -0
- package/dist/lib/buildSliceAssetPath.cjs +34 -0
- package/dist/lib/buildSliceAssetPath.cjs.map +1 -0
- package/dist/lib/buildSliceAssetPath.d.ts +11 -0
- package/dist/lib/buildSliceAssetPath.js +17 -0
- package/dist/lib/buildSliceAssetPath.js.map +1 -0
- package/dist/lib/buildSliceDirectoryPath.cjs +30 -0
- package/dist/lib/buildSliceDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildSliceDirectoryPath.d.ts +10 -0
- package/dist/lib/buildSliceDirectoryPath.js +13 -0
- package/dist/lib/buildSliceDirectoryPath.js.map +1 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.cjs +7 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.cjs.map +1 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.d.ts +8 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.js +7 -0
- package/dist/lib/buildSliceLibraryDirectoryPath.js.map +1 -0
- package/dist/lib/updateSliceModelFile.cjs +4 -2
- package/dist/lib/updateSliceModelFile.cjs.map +1 -1
- package/dist/lib/updateSliceModelFile.js +3 -2
- package/dist/lib/updateSliceModelFile.js.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +7 -1
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js +6 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -1
- package/dist/plugin.cjs +3 -3
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +3 -3
- package/dist/plugin.js.map +1 -1
- package/package.json +18 -14
- package/src/hooks/customType-asset-delete.ts +7 -5
- package/src/hooks/customType-asset-read.ts +7 -5
- package/src/hooks/customType-asset-update.ts +7 -5
- package/src/hooks/customType-create.ts +5 -1
- package/src/hooks/customType-delete.ts +5 -1
- package/src/hooks/customType-read.ts +4 -3
- package/src/hooks/customTypeLibrary-read.ts +2 -1
- package/src/hooks/{command-init.ts → project-init.ts} +4 -4
- package/src/hooks/slice-asset-delete.ts +8 -6
- package/src/hooks/slice-asset-read.ts +8 -6
- package/src/hooks/slice-asset-update.ts +8 -6
- package/src/hooks/slice-create.ts +12 -17
- package/src/hooks/slice-delete.ts +6 -5
- package/src/hooks/slice-read.ts +5 -1
- package/src/hooks/slice-rename.ts +11 -9
- package/src/hooks/sliceLibrary-read.ts +5 -1
- package/src/lib/buildCustomTypeAssetPath.ts +24 -0
- package/src/lib/buildCustomTypeDirectoryPath.ts +20 -0
- package/src/lib/buildCustomTypeLibraryDirectoryPath.ts +13 -0
- package/src/lib/buildSliceAssetPath.ts +32 -0
- package/src/lib/buildSliceDirectoryPath.ts +26 -0
- package/src/lib/buildSliceLibraryDirectoryPath.ts +14 -0
- package/src/lib/updateSliceModelFile.ts +5 -4
- package/src/lib/upsertSliceLibraryIndexFile.ts +7 -2
- package/src/plugin.ts +2 -2
- package/dist/hooks/command-init.d.ts +0 -3
- package/dist/node_modules/data-uri-to-buffer/dist/index.cjs.map +0 -1
- package/dist/node_modules/data-uri-to-buffer/dist/index.js.map +0 -1
- package/dist/node_modules/fetch-blob/file.cjs.map +0 -1
- package/dist/node_modules/fetch-blob/file.js.map +0 -1
- package/dist/node_modules/fetch-blob/index.cjs.map +0 -1
- package/dist/node_modules/fetch-blob/index.js.map +0 -1
- package/dist/node_modules/fetch-blob/streams.cjs.map +0 -1
- package/dist/node_modules/fetch-blob/streams.js.map +0 -1
- package/dist/node_modules/formdata-polyfill/esm.min.cjs.map +0 -1
- package/dist/node_modules/formdata-polyfill/esm.min.js.map +0 -1
- package/dist/node_modules/node-domexception/index.cjs.map +0 -1
- package/dist/node_modules/node-domexception/index.js.map +0 -1
- package/dist/node_modules/node-fetch/src/body.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/body.js.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/abort-error.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/abort-error.js.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/base.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/base.js.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/fetch-error.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/errors/fetch-error.js.map +0 -1
- package/dist/node_modules/node-fetch/src/headers.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/headers.js.map +0 -1
- package/dist/node_modules/node-fetch/src/index.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/index.js.map +0 -1
- package/dist/node_modules/node-fetch/src/request.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/request.js.map +0 -1
- package/dist/node_modules/node-fetch/src/response.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/response.js.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/get-search.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/get-search.js.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/is-redirect.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/is-redirect.js.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/is.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/is.js.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.js.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/referrer.cjs.map +0 -1
- package/dist/node_modules/node-fetch/src/utils/referrer.js.map +0 -1
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +0 -1
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +0 -1
- /package/dist/{node_modules → _node_modules}/fetch-blob/file.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/fetch-blob/file.js +0 -0
- /package/dist/{node_modules → _node_modules}/fetch-blob/index.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/fetch-blob/index.js +0 -0
- /package/dist/{node_modules → _node_modules}/fetch-blob/streams.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/fetch-blob/streams.js +0 -0
- /package/dist/{node_modules → _node_modules}/formdata-polyfill/esm.min.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/formdata-polyfill/esm.min.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-domexception/index.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-domexception/index.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/body.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/body.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/abort-error.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/abort-error.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/base.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/base.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/fetch-error.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/errors/fetch-error.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/headers.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/headers.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/index.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/index.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/request.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/request.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/response.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/response.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/get-search.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/get-search.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/is-redirect.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/is-redirect.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/is.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/is.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/multipart-parser.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/multipart-parser.js +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/referrer.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/node-fetch/src/utils/referrer.js +0 -0
- /package/dist/{node_modules → _node_modules}/web-streams-polyfill/dist/ponyfill.es2018.cjs +0 -0
- /package/dist/{node_modules → _node_modules}/web-streams-polyfill/dist/ponyfill.es2018.js +0 -0
- /package/dist/{package.json.cjs → packages/adapter-next/package.json.cjs} +0 -0
- /package/dist/{package.json.cjs.map → packages/adapter-next/package.json.cjs.map} +0 -0
- /package/dist/{package.json.js → packages/adapter-next/package.json.js} +0 -0
- /package/dist/{package.json.js.map → packages/adapter-next/package.json.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-delete.js","sources":["../../../src/hooks/slice-asset-delete.ts"],"sourcesContent":["import type { SliceAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"slice-asset-delete.js","sources":["../../../src/hooks/slice-asset-delete.ts"],"sourcesContent":["import type { SliceAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetDelete: SliceAssetDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\n\t});\n\n\tawait fs.rm(filePath);\n};\n"],"names":[],"mappings":";;AAOa,MAAA,mBAAwD,OACpE,MACA,YACG;AACG,QAAA,WAAW,MAAM,oBAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAA,GAAG,GAAG,QAAQ;AACrB;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
|
-
const
|
|
4
|
+
const buildSliceAssetPath = require("../lib/buildSliceAssetPath.cjs");
|
|
5
5
|
function _interopNamespaceDefault(e) {
|
|
6
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
7
|
if (e) {
|
|
@@ -20,7 +20,13 @@ function _interopNamespaceDefault(e) {
|
|
|
20
20
|
}
|
|
21
21
|
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
22
22
|
const sliceAssetRead = async (data, context) => {
|
|
23
|
-
const filePath =
|
|
23
|
+
const filePath = await buildSliceAssetPath.buildSliceAssetPath({
|
|
24
|
+
libraryID: data.libraryID,
|
|
25
|
+
sliceID: data.sliceID,
|
|
26
|
+
assetID: data.assetID,
|
|
27
|
+
helpers: context.helpers,
|
|
28
|
+
actions: context.actions
|
|
29
|
+
});
|
|
24
30
|
const assetData = await fs__namespace.readFile(filePath);
|
|
25
31
|
return {
|
|
26
32
|
data: assetData
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-read.cjs","sources":["../../../src/hooks/slice-asset-read.ts"],"sourcesContent":["import type { SliceAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"slice-asset-read.cjs","sources":["../../../src/hooks/slice-asset-read.ts"],"sourcesContent":["import type { SliceAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetRead: SliceAssetReadHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\n\t});\n\n\tconst assetData = await fs.readFile(filePath);\n\n\treturn {\n\t\tdata: assetData,\n\t};\n};\n"],"names":["buildSliceAssetPath","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOa,MAAA,iBAAoD,OAChE,MACA,YACG;AACG,QAAA,WAAW,MAAMA,wCAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAM,YAAY,MAAMC,cAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;;"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
|
-
import {
|
|
2
|
+
import { buildSliceAssetPath } from "../lib/buildSliceAssetPath.js";
|
|
3
3
|
const sliceAssetRead = async (data, context) => {
|
|
4
|
-
const filePath =
|
|
4
|
+
const filePath = await buildSliceAssetPath({
|
|
5
|
+
libraryID: data.libraryID,
|
|
6
|
+
sliceID: data.sliceID,
|
|
7
|
+
assetID: data.assetID,
|
|
8
|
+
helpers: context.helpers,
|
|
9
|
+
actions: context.actions
|
|
10
|
+
});
|
|
5
11
|
const assetData = await fs.readFile(filePath);
|
|
6
12
|
return {
|
|
7
13
|
data: assetData
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-read.js","sources":["../../../src/hooks/slice-asset-read.ts"],"sourcesContent":["import type { SliceAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"slice-asset-read.js","sources":["../../../src/hooks/slice-asset-read.ts"],"sourcesContent":["import type { SliceAssetReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetRead: SliceAssetReadHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.assetID,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\n\t});\n\n\tconst assetData = await fs.readFile(filePath);\n\n\treturn {\n\t\tdata: assetData,\n\t};\n};\n"],"names":[],"mappings":";;AAOa,MAAA,iBAAoD,OAChE,MACA,YACG;AACG,QAAA,WAAW,MAAM,oBAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAM,YAAY,MAAM,GAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const path = require("node:path");
|
|
5
|
-
const
|
|
5
|
+
const buildSliceAssetPath = require("../lib/buildSliceAssetPath.cjs");
|
|
6
6
|
function _interopNamespaceDefault(e) {
|
|
7
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
8
|
if (e) {
|
|
@@ -22,7 +22,13 @@ function _interopNamespaceDefault(e) {
|
|
|
22
22
|
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
23
23
|
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
24
24
|
const sliceAssetUpdate = async (data, context) => {
|
|
25
|
-
const filePath =
|
|
25
|
+
const filePath = await buildSliceAssetPath.buildSliceAssetPath({
|
|
26
|
+
libraryID: data.libraryID,
|
|
27
|
+
sliceID: data.sliceID,
|
|
28
|
+
assetID: data.asset.id,
|
|
29
|
+
helpers: context.helpers,
|
|
30
|
+
actions: context.actions
|
|
31
|
+
});
|
|
26
32
|
await fs__namespace.mkdir(path__namespace.dirname(filePath), { recursive: true });
|
|
27
33
|
await fs__namespace.writeFile(filePath, data.asset.data);
|
|
28
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-update.cjs","sources":["../../../src/hooks/slice-asset-update.ts"],"sourcesContent":["import type { SliceAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"slice-asset-update.cjs","sources":["../../../src/hooks/slice-asset-update.ts"],"sourcesContent":["import type { SliceAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetUpdate: SliceAssetUpdateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.asset.id,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\n\t});\n\n\tawait fs.mkdir(path.dirname(filePath), { recursive: true });\n\tawait fs.writeFile(filePath, data.asset.data);\n};\n"],"names":["buildSliceAssetPath","fs","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQa,MAAA,mBAAwD,OACpE,MACA,YACG;AACG,QAAA,WAAW,MAAMA,wCAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK,MAAM;AAAA,IACpB,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAAC,cAAG,MAAMC,gBAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAA,CAAM;AAC1D,QAAMD,cAAG,UAAU,UAAU,KAAK,MAAM,IAAI;AAC7C;;"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { buildSliceAssetPath } from "../lib/buildSliceAssetPath.js";
|
|
4
4
|
const sliceAssetUpdate = async (data, context) => {
|
|
5
|
-
const filePath =
|
|
5
|
+
const filePath = await buildSliceAssetPath({
|
|
6
|
+
libraryID: data.libraryID,
|
|
7
|
+
sliceID: data.sliceID,
|
|
8
|
+
assetID: data.asset.id,
|
|
9
|
+
helpers: context.helpers,
|
|
10
|
+
actions: context.actions
|
|
11
|
+
});
|
|
6
12
|
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
7
13
|
await fs.writeFile(filePath, data.asset.data);
|
|
8
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-update.js","sources":["../../../src/hooks/slice-asset-update.ts"],"sourcesContent":["import type { SliceAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"slice-asset-update.js","sources":["../../../src/hooks/slice-asset-update.ts"],"sourcesContent":["import type { SliceAssetUpdateHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceAssetPath } from \"../lib/buildSliceAssetPath\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetUpdate: SliceAssetUpdateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = await buildSliceAssetPath({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.sliceID,\n\t\tassetID: data.asset.id,\n\t\thelpers: context.helpers,\n\t\tactions: context.actions,\n\t});\n\n\tawait fs.mkdir(path.dirname(filePath), { recursive: true });\n\tawait fs.writeFile(filePath, data.asset.data);\n};\n"],"names":[],"mappings":";;;AAQa,MAAA,mBAAwD,OACpE,MACA,YACG;AACG,QAAA,WAAW,MAAM,oBAAoB;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK;AAAA,IACd,SAAS,KAAK,MAAM;AAAA,IACpB,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,EAAA,CACjB;AAEK,QAAA,GAAG,MAAM,KAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAA,CAAM;AAC1D,QAAM,GAAG,UAAU,UAAU,KAAK,MAAM,IAAI;AAC7C;"}
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const commonTags = require("common-tags");
|
|
4
4
|
const fs = require("node:fs/promises");
|
|
5
5
|
const path = require("node:path");
|
|
6
|
+
const buildSliceDirectoryPath = require("../lib/buildSliceDirectoryPath.cjs");
|
|
6
7
|
const checkIsTypeScriptProject = require("../lib/checkIsTypeScriptProject.cjs");
|
|
7
8
|
const getJSOrTSXFileExtension = require("../lib/getJSOrTSXFileExtension.cjs");
|
|
8
9
|
const pascalCase = require("../lib/pascalCase.cjs");
|
|
9
10
|
const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
|
|
11
|
+
const updateSliceModelFile = require("../lib/updateSliceModelFile.cjs");
|
|
10
12
|
const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
|
|
11
13
|
const upsertSliceLibraryIndexFile = require("../lib/upsertSliceLibraryIndexFile.cjs");
|
|
12
14
|
function _interopNamespaceDefault(e) {
|
|
@@ -27,14 +29,6 @@ function _interopNamespaceDefault(e) {
|
|
|
27
29
|
}
|
|
28
30
|
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
29
31
|
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
30
|
-
const createModelFile = async ({ dir, data, helpers, options }) => {
|
|
31
|
-
const filePath = path__namespace.join(dir, "model.json");
|
|
32
|
-
let contents = JSON.stringify(data.model);
|
|
33
|
-
if (options.format) {
|
|
34
|
-
contents = await helpers.format(contents, filePath);
|
|
35
|
-
}
|
|
36
|
-
await fs__namespace.writeFile(filePath, contents);
|
|
37
|
-
};
|
|
38
32
|
const createComponentFile = async ({ dir, data, helpers, options }) => {
|
|
39
33
|
const filePath = path__namespace.join(dir, `index.${await getJSOrTSXFileExtension.getJSOrTSXFileExtension({ helpers, options })}`);
|
|
40
34
|
const model = data.model;
|
|
@@ -97,10 +91,18 @@ const createComponentFile = async ({ dir, data, helpers, options }) => {
|
|
|
97
91
|
await fs__namespace.writeFile(filePath, contents);
|
|
98
92
|
};
|
|
99
93
|
const sliceCreate = async (data, context) => {
|
|
100
|
-
const dir =
|
|
94
|
+
const dir = buildSliceDirectoryPath.buildSliceDirectoryPath({
|
|
95
|
+
libraryID: data.libraryID,
|
|
96
|
+
model: data.model,
|
|
97
|
+
helpers: context.helpers
|
|
98
|
+
});
|
|
101
99
|
await fs__namespace.mkdir(dir, { recursive: true });
|
|
102
100
|
rejectIfNecessary.rejectIfNecessary(await Promise.allSettled([
|
|
103
|
-
|
|
101
|
+
updateSliceModelFile.updateSliceModelFile({
|
|
102
|
+
libraryID: data.libraryID,
|
|
103
|
+
model: data.model,
|
|
104
|
+
...context
|
|
105
|
+
}),
|
|
104
106
|
createComponentFile({ dir, data, ...context })
|
|
105
107
|
]));
|
|
106
108
|
rejectIfNecessary.rejectIfNecessary(await Promise.allSettled([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-create.cjs","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSOrTSXFileExtension } from \"../lib/getJSOrTSXFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst
|
|
1
|
+
{"version":3,"file":"slice-create.cjs","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSOrTSXFileExtension } from \"../lib/getJSOrTSXFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(\n\t\tdir,\n\t\t`index.${await getJSOrTSXFileExtension({ helpers, options })}`,\n\t);\n\tconst model = data.model;\n\tconst pascalName = pascalCase(model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\timport { Content } from \"@prismicio/client\";\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalName}\\`.\n\t\t\t */\n\t\t\texport type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }: ${pascalName}Props): JSX.Element => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\tPlaceholder component for ${model.id} (variation: {slice.variation}) Slices\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t/**\n\t\t\t * @typedef {import(\"@prismicio/client\").Content.${pascalName}Slice} ${pascalName}Slice\n\t\t\t * @typedef {import(\"@prismicio/react\").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props\n\t\t\t * @param {${pascalName}Props}\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\tPlaceholder component for ${model.id} (variation: {slice.variation}) Slices\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName};\n\t\t`;\n\t}\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = buildSliceDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupdateSliceModelFile({\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\t\t\tcreateComponentFile({ dir, data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":["path","getJSOrTSXFileExtension","pascalCase","checkIsTypeScriptProject","stripIndent","fs","buildSliceDirectoryPath","rejectIfNecessary","updateSliceModelFile","upsertGlobalContentTypes","upsertSliceLibraryIndexFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,sBAAsB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AACrE,QAAA,WAAWA,gBAAK,KACrB,KACA,SAAS,MAAMC,wBAAA,wBAAwB,EAAE,SAAS,SAAS,GAAG;AAE/D,QAAM,QAAQ,KAAK;AACb,QAAA,aAAaC,WAAAA,WAAW,MAAM,IAAI;AAEpC,MAAA;AAEE,QAAA,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,qBAAqB;AACb,eAAAC,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,oBAKO;AAAA;AAAA,iBAEH,iDAAiD;AAAA;AAAA;AAAA,uBAG3C,MAAM;AAAA;AAAA,WAElB,4BAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAML,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKpB;AAAA;AAAA,EAAA,OAEZ;AACK,eAAAA,WAAAA;AAAAA;AAAAA,sDAEyC,oBAAoB;AAAA,iEACT,qBAAqB;AAAA,gBACtE;AAAA;AAAA,WAEL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAMuB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKpB;AAAA;AAAA,EAElB;AAED,MAAI,QAAQ,QAAQ;AACnB,eAAW,MAAM,QAAQ,OAAO,UAAU,QAAQ;AAAA,EAClD;AAEK,QAAAC,cAAG,UAAU,UAAU,QAAQ;AACtC;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAM,MAAMC,wBAAAA,wBAAwB;AAAA,IACnC,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAMD,cAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAGtCE,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBC,0CAAqB;AAAA,MACpB,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,GAAG;AAAA,IAAA,CACH;AAAA,IACD,oBAAoB,EAAE,KAAK,MAAM,GAAG,SAAS;AAAA,EAC7C,CAAA,CAAC;AAIFD,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBE,yBAAAA,yBAAyB,OAAO;AAAA,IAChCC,wDAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,CAAA,CAAC;AAEJ;;"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { stripIndent } from "common-tags";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath.js";
|
|
4
5
|
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
|
|
5
6
|
import { getJSOrTSXFileExtension } from "../lib/getJSOrTSXFileExtension.js";
|
|
6
7
|
import { pascalCase } from "../lib/pascalCase.js";
|
|
7
8
|
import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
|
|
9
|
+
import { updateSliceModelFile } from "../lib/updateSliceModelFile.js";
|
|
8
10
|
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
|
|
9
11
|
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile.js";
|
|
10
|
-
const createModelFile = async ({ dir, data, helpers, options }) => {
|
|
11
|
-
const filePath = path.join(dir, "model.json");
|
|
12
|
-
let contents = JSON.stringify(data.model);
|
|
13
|
-
if (options.format) {
|
|
14
|
-
contents = await helpers.format(contents, filePath);
|
|
15
|
-
}
|
|
16
|
-
await fs.writeFile(filePath, contents);
|
|
17
|
-
};
|
|
18
12
|
const createComponentFile = async ({ dir, data, helpers, options }) => {
|
|
19
13
|
const filePath = path.join(dir, `index.${await getJSOrTSXFileExtension({ helpers, options })}`);
|
|
20
14
|
const model = data.model;
|
|
@@ -77,10 +71,18 @@ const createComponentFile = async ({ dir, data, helpers, options }) => {
|
|
|
77
71
|
await fs.writeFile(filePath, contents);
|
|
78
72
|
};
|
|
79
73
|
const sliceCreate = async (data, context) => {
|
|
80
|
-
const dir =
|
|
74
|
+
const dir = buildSliceDirectoryPath({
|
|
75
|
+
libraryID: data.libraryID,
|
|
76
|
+
model: data.model,
|
|
77
|
+
helpers: context.helpers
|
|
78
|
+
});
|
|
81
79
|
await fs.mkdir(dir, { recursive: true });
|
|
82
80
|
rejectIfNecessary(await Promise.allSettled([
|
|
83
|
-
|
|
81
|
+
updateSliceModelFile({
|
|
82
|
+
libraryID: data.libraryID,
|
|
83
|
+
model: data.model,
|
|
84
|
+
...context
|
|
85
|
+
}),
|
|
84
86
|
createComponentFile({ dir, data, ...context })
|
|
85
87
|
]));
|
|
86
88
|
rejectIfNecessary(await Promise.allSettled([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-create.js","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSOrTSXFileExtension } from \"../lib/getJSOrTSXFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst
|
|
1
|
+
{"version":3,"file":"slice-create.js","sources":["../../../src/hooks/slice-create.ts"],"sourcesContent":["import type {\n\tSliceCreateHook,\n\tSliceCreateHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport { stripIndent } from \"common-tags\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSOrTSXFileExtension } from \"../lib/getJSOrTSXFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(\n\t\tdir,\n\t\t`index.${await getJSOrTSXFileExtension({ helpers, options })}`,\n\t);\n\tconst model = data.model;\n\tconst pascalName = pascalCase(model.name);\n\n\tlet contents: string;\n\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\tcontents = stripIndent`\n\t\t\timport { Content } from \"@prismicio/client\";\n\t\t\timport { SliceComponentProps } from \"@prismicio/react\";\n\n\t\t\t/**\n\t\t\t * Props for \\`${pascalName}\\`.\n\t\t\t */\n\t\t\texport type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;\n\n\t\t\t/**\n\t\t\t * Component for \"${model.name}\" Slices.\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }: ${pascalName}Props): JSX.Element => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\tPlaceholder component for ${model.id} (variation: {slice.variation}) Slices\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName}\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t/**\n\t\t\t * @typedef {import(\"@prismicio/client\").Content.${pascalName}Slice} ${pascalName}Slice\n\t\t\t * @typedef {import(\"@prismicio/react\").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props\n\t\t\t * @param {${pascalName}Props}\n\t\t\t */\n\t\t\tconst ${pascalName} = ({ slice }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<section\n\t\t\t\t\t\tdata-slice-type={slice.slice_type}\n\t\t\t\t\t\tdata-slice-variation={slice.variation}\n\t\t\t\t\t>\n\t\t\t\t\t\tPlaceholder component for ${model.id} (variation: {slice.variation}) Slices\n\t\t\t\t\t</section>\n\t\t\t\t);\n\t\t\t};\n\n\t\t\texport default ${pascalName};\n\t\t`;\n\t}\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nexport const sliceCreate: SliceCreateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst dir = buildSliceDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\thelpers: context.helpers,\n\t});\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupdateSliceModelFile({\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\t\t\tcreateComponentFile({ dir, data, ...context }),\n\t\t]),\n\t);\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAyBA,MAAM,sBAAsB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AACrE,QAAA,WAAW,KAAK,KACrB,KACA,SAAS,MAAM,wBAAwB,EAAE,SAAS,SAAS,GAAG;AAE/D,QAAM,QAAQ,KAAK;AACb,QAAA,aAAa,WAAW,MAAM,IAAI;AAEpC,MAAA;AAEE,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AAED,MAAI,qBAAqB;AACb,eAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AAAA;AAAA,iBAEH,iDAAiD;AAAA;AAAA;AAAA,uBAG3C,MAAM;AAAA;AAAA,WAElB,4BAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAML,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKpB;AAAA;AAAA,EAAA,OAEZ;AACK,eAAA;AAAA;AAAA,sDAEyC,oBAAoB;AAAA,iEACT,qBAAqB;AAAA,gBACtE;AAAA;AAAA,WAEL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAMuB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKpB;AAAA;AAAA,EAElB;AAED,MAAI,QAAQ,QAAQ;AACnB,eAAW,MAAM,QAAQ,OAAO,UAAU,QAAQ;AAAA,EAClD;AAEK,QAAA,GAAG,UAAU,UAAU,QAAQ;AACtC;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAM,MAAM,wBAAwB;AAAA,IACnC,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,SAAS,QAAQ;AAAA,EAAA,CACjB;AAED,QAAM,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAGtC,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,qBAAqB;AAAA,MACpB,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ,GAAG;AAAA,IAAA,CACH;AAAA,IACD,oBAAoB,EAAE,KAAK,MAAM,GAAG,SAAS;AAAA,EAC7C,CAAA,CAAC;AAIF,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,yBAAyB,OAAO;AAAA,IAChC,4BAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,CAAA,CAAC;AAEJ;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
|
-
const
|
|
4
|
+
const buildSliceDirectoryPath = require("../lib/buildSliceDirectoryPath.cjs");
|
|
5
5
|
const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
|
|
6
6
|
const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
|
|
7
7
|
const upsertSliceLibraryIndexFile = require("../lib/upsertSliceLibraryIndexFile.cjs");
|
|
@@ -23,7 +23,11 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
}
|
|
24
24
|
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
25
25
|
const deleteSliceDir = async ({ data, helpers }) => {
|
|
26
|
-
const dir =
|
|
26
|
+
const dir = buildSliceDirectoryPath.buildSliceDirectoryPath({
|
|
27
|
+
libraryID: data.libraryID,
|
|
28
|
+
model: data.model,
|
|
29
|
+
helpers
|
|
30
|
+
});
|
|
27
31
|
await fs__namespace.rm(dir, { recursive: true });
|
|
28
32
|
};
|
|
29
33
|
const sliceDelete = async (data, context) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-delete.cjs","sources":["../../../src/hooks/slice-delete.ts"],"sourcesContent":["import type {\n\tSliceDeleteHook,\n\tSliceDeleteHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"slice-delete.cjs","sources":["../../../src/hooks/slice-delete.ts"],"sourcesContent":["import type {\n\tSliceDeleteHook,\n\tSliceDeleteHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceDeleteHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst deleteSliceDir = async ({ data, helpers }: Args) => {\n\tconst dir = buildSliceDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\thelpers,\n\t});\n\n\tawait fs.rm(dir, { recursive: true });\n};\n\nexport const sliceDelete: SliceDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tawait deleteSliceDir({ data, ...context });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":["buildSliceDirectoryPath","fs","rejectIfNecessary","upsertGlobalContentTypes","upsertSliceLibraryIndexFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,iBAAiB,OAAO,EAAE,MAAM,cAAmB;AACxD,QAAM,MAAMA,wBAAAA,wBAAwB;AAAA,IACnC,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ;AAAA,EAAA,CACA;AAED,QAAMC,cAAG,GAAG,KAAK,EAAE,WAAW,MAAM;AACrC;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAM,eAAe,EAAE,MAAM,GAAG,QAAS,CAAA;AAGxCC,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBC,yBAAAA,yBAAyB,OAAO;AAAA,IAChCC,wDAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,CAAA,CAAC;AAEJ;;"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
|
-
import {
|
|
2
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath.js";
|
|
3
3
|
import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
|
|
4
4
|
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
|
|
5
5
|
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile.js";
|
|
6
6
|
const deleteSliceDir = async ({ data, helpers }) => {
|
|
7
|
-
const dir =
|
|
7
|
+
const dir = buildSliceDirectoryPath({
|
|
8
|
+
libraryID: data.libraryID,
|
|
9
|
+
model: data.model,
|
|
10
|
+
helpers
|
|
11
|
+
});
|
|
8
12
|
await fs.rm(dir, { recursive: true });
|
|
9
13
|
};
|
|
10
14
|
const sliceDelete = async (data, context) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-delete.js","sources":["../../../src/hooks/slice-delete.ts"],"sourcesContent":["import type {\n\tSliceDeleteHook,\n\tSliceDeleteHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"slice-delete.js","sources":["../../../src/hooks/slice-delete.ts"],"sourcesContent":["import type {\n\tSliceDeleteHook,\n\tSliceDeleteHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdata: SliceDeleteHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst deleteSliceDir = async ({ data, helpers }: Args) => {\n\tconst dir = buildSliceDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\thelpers,\n\t});\n\n\tawait fs.rm(dir, { recursive: true });\n};\n\nexport const sliceDelete: SliceDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tawait deleteSliceDir({ data, ...context });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;AAkBA,MAAM,iBAAiB,OAAO,EAAE,MAAM,cAAmB;AACxD,QAAM,MAAM,wBAAwB;AAAA,IACnC,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ;AAAA,EAAA,CACA;AAED,QAAM,GAAG,GAAG,KAAK,EAAE,WAAW,MAAM;AACrC;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAM,eAAe,EAAE,MAAM,GAAG,QAAS,CAAA;AAGxC,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,yBAAyB,OAAO;AAAA,IAChC,4BAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,CAAA,CAAC;AAEJ;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const path = require("node:path");
|
|
5
|
+
const buildSliceLibraryDirectoryPath = require("../lib/buildSliceLibraryDirectoryPath.cjs");
|
|
5
6
|
const isSharedSliceModel = require("../lib/isSharedSliceModel.cjs");
|
|
6
7
|
const readJSONFile = require("../lib/readJSONFile.cjs");
|
|
7
8
|
function _interopNamespaceDefault(e) {
|
|
@@ -23,7 +24,10 @@ function _interopNamespaceDefault(e) {
|
|
|
23
24
|
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
24
25
|
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
25
26
|
const sliceRead = async (data, { helpers }) => {
|
|
26
|
-
const libraryDir =
|
|
27
|
+
const libraryDir = buildSliceLibraryDirectoryPath.buildSliceLibraryDirectoryPath({
|
|
28
|
+
libraryID: data.libraryID,
|
|
29
|
+
helpers
|
|
30
|
+
});
|
|
27
31
|
await fs__namespace.mkdir(libraryDir, { recursive: true });
|
|
28
32
|
const childDirs = await fs__namespace.readdir(libraryDir, { withFileTypes: true });
|
|
29
33
|
const [model] = (await Promise.all(childDirs.map(async (childDir) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-read.cjs","sources":["../../../src/hooks/slice-read.ts"],"sourcesContent":["import type { SliceReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { isSharedSliceModel } from \"../lib/isSharedSliceModel\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceRead: SliceReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst libraryDir =
|
|
1
|
+
{"version":3,"file":"slice-read.cjs","sources":["../../../src/hooks/slice-read.ts"],"sourcesContent":["import type { SliceReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceLibraryDirectoryPath } from \"../lib/buildSliceLibraryDirectoryPath\";\nimport { isSharedSliceModel } from \"../lib/isSharedSliceModel\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceRead: SliceReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\thelpers,\n\t});\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(libraryDir, { recursive: true });\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t// Find the first matching model.\n\tconst [model] = (\n\t\tawait Promise.all(\n\t\t\tchildDirs.map(async (childDir) => {\n\t\t\t\tif (childDir.isDirectory()) {\n\t\t\t\t\tconst modelPath = path.join(libraryDir, childDir.name, \"model.json\");\n\n\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tisSharedSliceModel(modelContents) &&\n\t\t\t\t\t\tmodelContents.id === data.sliceID\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn modelContents;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t)\n\t).filter((model): model is NonNullable<typeof model> => Boolean(model));\n\n\tif (model) {\n\t\treturn {\n\t\t\tmodel,\n\t\t};\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Did not find a Slice model with ID \"${data.sliceID}\" in the \"${data.libraryID}\" Slice Library.`,\n\t\t);\n\t}\n};\n"],"names":["buildSliceLibraryDirectoryPath","fs","path","readJSONFile","isSharedSliceModel","model"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUO,MAAM,YAA0C,OACtD,MACA,EAAE,cACC;AACH,QAAM,aAAaA,+BAAAA,+BAA+B;AAAA,IACjD,WAAW,KAAK;AAAA,IAChB;AAAA,EAAA,CACA;AAGD,QAAMC,cAAG,MAAM,YAAY,EAAE,WAAW,MAAM;AAExC,QAAA,YAAY,MAAMA,cAAG,QAAQ,YAAY,EAAE,eAAe,MAAM;AAGhE,QAAA,CAAC,KAAK,KACX,MAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AAC3B,YAAM,YAAYC,gBAAK,KAAK,YAAY,SAAS,MAAM,YAAY;AAE7D,YAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAElD,UACCC,mBAAAA,mBAAmB,aAAa,KAChC,cAAc,OAAO,KAAK,SACzB;AACM,eAAA;AAAA,MACP;AAAA,IACD;AAAA,EAAA,CACD,CAAC,GAEF,OAAO,CAACC,WAA8C,QAAQA,MAAK,CAAC;AAEtE,MAAI,OAAO;AACH,WAAA;AAAA,MACN;AAAA,IAAA;AAAA,SAEK;AACN,UAAM,IAAI,MACT,uCAAuC,KAAK,oBAAoB,KAAK,2BAA2B;AAAA,EAEjG;AACF;;"}
|
package/dist/hooks/slice-read.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
+
import { buildSliceLibraryDirectoryPath } from "../lib/buildSliceLibraryDirectoryPath.js";
|
|
3
4
|
import { isSharedSliceModel } from "../lib/isSharedSliceModel.js";
|
|
4
5
|
import { readJSONFile } from "../lib/readJSONFile.js";
|
|
5
6
|
const sliceRead = async (data, { helpers }) => {
|
|
6
|
-
const libraryDir =
|
|
7
|
+
const libraryDir = buildSliceLibraryDirectoryPath({
|
|
8
|
+
libraryID: data.libraryID,
|
|
9
|
+
helpers
|
|
10
|
+
});
|
|
7
11
|
await fs.mkdir(libraryDir, { recursive: true });
|
|
8
12
|
const childDirs = await fs.readdir(libraryDir, { withFileTypes: true });
|
|
9
13
|
const [model] = (await Promise.all(childDirs.map(async (childDir) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-read.js","sources":["../../../src/hooks/slice-read.ts"],"sourcesContent":["import type { SliceReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { isSharedSliceModel } from \"../lib/isSharedSliceModel\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceRead: SliceReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst libraryDir =
|
|
1
|
+
{"version":3,"file":"slice-read.js","sources":["../../../src/hooks/slice-read.ts"],"sourcesContent":["import type { SliceReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceLibraryDirectoryPath } from \"../lib/buildSliceLibraryDirectoryPath\";\nimport { isSharedSliceModel } from \"../lib/isSharedSliceModel\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceRead: SliceReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst libraryDir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\thelpers,\n\t});\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(libraryDir, { recursive: true });\n\n\tconst childDirs = await fs.readdir(libraryDir, { withFileTypes: true });\n\n\t// Find the first matching model.\n\tconst [model] = (\n\t\tawait Promise.all(\n\t\t\tchildDirs.map(async (childDir) => {\n\t\t\t\tif (childDir.isDirectory()) {\n\t\t\t\t\tconst modelPath = path.join(libraryDir, childDir.name, \"model.json\");\n\n\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tisSharedSliceModel(modelContents) &&\n\t\t\t\t\t\tmodelContents.id === data.sliceID\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn modelContents;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t)\n\t).filter((model): model is NonNullable<typeof model> => Boolean(model));\n\n\tif (model) {\n\t\treturn {\n\t\t\tmodel,\n\t\t};\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Did not find a Slice model with ID \"${data.sliceID}\" in the \"${data.libraryID}\" Slice Library.`,\n\t\t);\n\t}\n};\n"],"names":["model"],"mappings":";;;;;AAUO,MAAM,YAA0C,OACtD,MACA,EAAE,cACC;AACH,QAAM,aAAa,+BAA+B;AAAA,IACjD,WAAW,KAAK;AAAA,IAChB;AAAA,EAAA,CACA;AAGD,QAAM,GAAG,MAAM,YAAY,EAAE,WAAW,MAAM;AAExC,QAAA,YAAY,MAAM,GAAG,QAAQ,YAAY,EAAE,eAAe,MAAM;AAGhE,QAAA,CAAC,KAAK,KACX,MAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AAC3B,YAAM,YAAY,KAAK,KAAK,YAAY,SAAS,MAAM,YAAY;AAE7D,YAAA,gBAAgB,MAAM,aAAa,SAAS;AAElD,UACC,mBAAmB,aAAa,KAChC,cAAc,OAAO,KAAK,SACzB;AACM,eAAA;AAAA,MACP;AAAA,IACD;AAAA,EAAA,CACD,CAAC,GAEF,OAAO,CAACA,WAA8C,QAAQA,MAAK,CAAC;AAEtE,MAAI,OAAO;AACH,WAAA;AAAA,MACN;AAAA,IAAA;AAAA,SAEK;AACN,UAAM,IAAI,MACT,uCAAuC,KAAK,oBAAoB,KAAK,2BAA2B;AAAA,EAEjG;AACF;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fse = require("fs-extra");
|
|
4
|
-
const
|
|
4
|
+
const buildSliceDirectoryPath = require("../lib/buildSliceDirectoryPath.cjs");
|
|
5
5
|
const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
|
|
6
6
|
const updateSliceModelFile = require("../lib/updateSliceModelFile.cjs");
|
|
7
7
|
const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
|
|
@@ -28,7 +28,15 @@ const sliceRename = async (data, context) => {
|
|
|
28
28
|
libraryID: data.libraryID,
|
|
29
29
|
sliceID: data.model.id
|
|
30
30
|
});
|
|
31
|
-
await fse__namespace.move(
|
|
31
|
+
await fse__namespace.move(buildSliceDirectoryPath.buildSliceDirectoryPath({
|
|
32
|
+
libraryID: data.libraryID,
|
|
33
|
+
model: currentModel,
|
|
34
|
+
helpers: context.helpers
|
|
35
|
+
}), buildSliceDirectoryPath.buildSliceDirectoryPath({
|
|
36
|
+
libraryID: data.libraryID,
|
|
37
|
+
model: data.model,
|
|
38
|
+
helpers: context.helpers
|
|
39
|
+
}));
|
|
32
40
|
await updateSliceModelFile.updateSliceModelFile({
|
|
33
41
|
libraryID: data.libraryID,
|
|
34
42
|
model: data.model,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-rename.cjs","sources":["../../../src/hooks/slice-rename.ts"],"sourcesContent":["import type { SliceRenameHook } from \"@slicemachine/plugin-kit\";\nimport * as fse from \"fs-extra\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"slice-rename.cjs","sources":["../../../src/hooks/slice-rename.ts"],"sourcesContent":["import type { SliceRenameHook } from \"@slicemachine/plugin-kit\";\nimport * as fse from \"fs-extra\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceRename: SliceRenameHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst { model: currentModel } = await context.actions.readSliceModel({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.model.id,\n\t});\n\n\tawait fse.move(\n\t\tbuildSliceDirectoryPath({\n\t\t\tlibraryID: data.libraryID,\n\t\t\tmodel: currentModel,\n\t\t\thelpers: context.helpers,\n\t\t}),\n\t\tbuildSliceDirectoryPath({\n\t\t\tlibraryID: data.libraryID,\n\t\t\tmodel: data.model,\n\t\t\thelpers: context.helpers,\n\t\t}),\n\t);\n\n\tawait updateSliceModelFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\t...context,\n\t});\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":["fse","buildSliceDirectoryPath","updateSliceModelFile","rejectIfNecessary","upsertGlobalContentTypes","upsertSliceLibraryIndexFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAWa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAM,EAAE,OAAO,aAAA,IAAiB,MAAM,QAAQ,QAAQ,eAAe;AAAA,IACpE,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK,MAAM;AAAA,EAAA,CACpB;AAEK,QAAAA,eAAI,KACTC,gDAAwB;AAAA,IACvB,WAAW,KAAK;AAAA,IAChB,OAAO;AAAA,IACP,SAAS,QAAQ;AAAA,EACjB,CAAA,GACDA,wBAAAA,wBAAwB;AAAA,IACvB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,SAAS,QAAQ;AAAA,EACjB,CAAA,CAAC;AAGH,QAAMC,0CAAqB;AAAA,IAC1B,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,GAAG;AAAA,EAAA,CACH;AAGAC,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBC,yBAAAA,yBAAyB,OAAO;AAAA,IAChCC,wDAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,CAAA,CAAC;AAEJ;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as fse from "fs-extra";
|
|
2
|
-
import {
|
|
2
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath.js";
|
|
3
3
|
import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
|
|
4
4
|
import { updateSliceModelFile } from "../lib/updateSliceModelFile.js";
|
|
5
5
|
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
|
|
@@ -9,7 +9,15 @@ const sliceRename = async (data, context) => {
|
|
|
9
9
|
libraryID: data.libraryID,
|
|
10
10
|
sliceID: data.model.id
|
|
11
11
|
});
|
|
12
|
-
await fse.move(
|
|
12
|
+
await fse.move(buildSliceDirectoryPath({
|
|
13
|
+
libraryID: data.libraryID,
|
|
14
|
+
model: currentModel,
|
|
15
|
+
helpers: context.helpers
|
|
16
|
+
}), buildSliceDirectoryPath({
|
|
17
|
+
libraryID: data.libraryID,
|
|
18
|
+
model: data.model,
|
|
19
|
+
helpers: context.helpers
|
|
20
|
+
}));
|
|
13
21
|
await updateSliceModelFile({
|
|
14
22
|
libraryID: data.libraryID,
|
|
15
23
|
model: data.model,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-rename.js","sources":["../../../src/hooks/slice-rename.ts"],"sourcesContent":["import type { SliceRenameHook } from \"@slicemachine/plugin-kit\";\nimport * as fse from \"fs-extra\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"slice-rename.js","sources":["../../../src/hooks/slice-rename.ts"],"sourcesContent":["import type { SliceRenameHook } from \"@slicemachine/plugin-kit\";\nimport * as fse from \"fs-extra\";\n\nimport { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceRename: SliceRenameHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst { model: currentModel } = await context.actions.readSliceModel({\n\t\tlibraryID: data.libraryID,\n\t\tsliceID: data.model.id,\n\t});\n\n\tawait fse.move(\n\t\tbuildSliceDirectoryPath({\n\t\t\tlibraryID: data.libraryID,\n\t\t\tmodel: currentModel,\n\t\t\thelpers: context.helpers,\n\t\t}),\n\t\tbuildSliceDirectoryPath({\n\t\t\tlibraryID: data.libraryID,\n\t\t\tmodel: data.model,\n\t\t\thelpers: context.helpers,\n\t\t}),\n\t);\n\n\tawait updateSliceModelFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\t...context,\n\t});\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tupsertGlobalContentTypes(context),\n\t\t\tupsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context }),\n\t\t]),\n\t);\n};\n"],"names":[],"mappings":";;;;;;AAWa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAM,EAAE,OAAO,aAAA,IAAiB,MAAM,QAAQ,QAAQ,eAAe;AAAA,IACpE,WAAW,KAAK;AAAA,IAChB,SAAS,KAAK,MAAM;AAAA,EAAA,CACpB;AAEK,QAAA,IAAI,KACT,wBAAwB;AAAA,IACvB,WAAW,KAAK;AAAA,IAChB,OAAO;AAAA,IACP,SAAS,QAAQ;AAAA,EACjB,CAAA,GACD,wBAAwB;AAAA,IACvB,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,SAAS,QAAQ;AAAA,EACjB,CAAA,CAAC;AAGH,QAAM,qBAAqB;AAAA,IAC1B,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,GAAG;AAAA,EAAA,CACH;AAGA,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,yBAAyB,OAAO;AAAA,IAChC,4BAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,CAAA,CAAC;AAEJ;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const path = require("node:path");
|
|
5
|
+
const buildSliceLibraryDirectoryPath = require("../lib/buildSliceLibraryDirectoryPath.cjs");
|
|
5
6
|
const isSharedSliceModel = require("../lib/isSharedSliceModel.cjs");
|
|
6
7
|
const readJSONFile = require("../lib/readJSONFile.cjs");
|
|
7
8
|
function _interopNamespaceDefault(e) {
|
|
@@ -23,7 +24,10 @@ function _interopNamespaceDefault(e) {
|
|
|
23
24
|
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
24
25
|
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
25
26
|
const sliceLibraryRead = async (data, { helpers }) => {
|
|
26
|
-
const dir =
|
|
27
|
+
const dir = buildSliceLibraryDirectoryPath.buildSliceLibraryDirectoryPath({
|
|
28
|
+
libraryID: data.libraryID,
|
|
29
|
+
helpers
|
|
30
|
+
});
|
|
27
31
|
await fs__namespace.mkdir(dir, { recursive: true });
|
|
28
32
|
const childDirs = await fs__namespace.readdir(dir, { withFileTypes: true });
|
|
29
33
|
const sliceIDs = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliceLibrary-read.cjs","sources":["../../../src/hooks/sliceLibrary-read.ts"],"sourcesContent":["import type { SliceLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { isSharedSliceModel } from \"../lib/isSharedSliceModel\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceLibraryRead: SliceLibraryReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst dir =
|
|
1
|
+
{"version":3,"file":"sliceLibrary-read.cjs","sources":["../../../src/hooks/sliceLibrary-read.ts"],"sourcesContent":["import type { SliceLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceLibraryDirectoryPath } from \"../lib/buildSliceLibraryDirectoryPath\";\nimport { isSharedSliceModel } from \"../lib/isSharedSliceModel\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceLibraryRead: SliceLibraryReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst dir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\thelpers,\n\t});\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tconst childDirs = await fs.readdir(dir, { withFileTypes: true });\n\n\tconst sliceIDs: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst modelPath = path.join(dir, childDir.name, \"model.json\");\n\n\t\t\t\ttry {\n\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\tif (isSharedSliceModel(modelContents)) {\n\t\t\t\t\t\tsliceIDs.push(modelContents.id);\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// noop\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn {\n\t\tid: data.libraryID,\n\t\tsliceIDs: sliceIDs.sort(),\n\t};\n};\n"],"names":["buildSliceLibraryDirectoryPath","fs","path","readJSONFile","isSharedSliceModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUO,MAAM,mBAAwD,OACpE,MACA,EAAE,cACC;AACH,QAAM,MAAMA,+BAAAA,+BAA+B;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB;AAAA,EAAA,CACA;AAGD,QAAMC,cAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAEjC,QAAA,YAAY,MAAMA,cAAG,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE/D,QAAM,WAAqB,CAAA;AAC3B,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AAC3B,YAAM,YAAYC,gBAAK,KAAK,KAAK,SAAS,MAAM,YAAY;AAExD,UAAA;AACG,cAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAE9C,YAAAC,mBAAAA,mBAAmB,aAAa,GAAG;AAC7B,mBAAA,KAAK,cAAc,EAAE;AAAA,QAC9B;AAAA,MAAA,QACA;AAAA,MAED;AAAA,IACD;AAAA,EACD,CAAA,CAAC;AAGI,SAAA;AAAA,IACN,IAAI,KAAK;AAAA,IACT,UAAU,SAAS,KAAM;AAAA,EAAA;AAE3B;;"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
+
import { buildSliceLibraryDirectoryPath } from "../lib/buildSliceLibraryDirectoryPath.js";
|
|
3
4
|
import { isSharedSliceModel } from "../lib/isSharedSliceModel.js";
|
|
4
5
|
import { readJSONFile } from "../lib/readJSONFile.js";
|
|
5
6
|
const sliceLibraryRead = async (data, { helpers }) => {
|
|
6
|
-
const dir =
|
|
7
|
+
const dir = buildSliceLibraryDirectoryPath({
|
|
8
|
+
libraryID: data.libraryID,
|
|
9
|
+
helpers
|
|
10
|
+
});
|
|
7
11
|
await fs.mkdir(dir, { recursive: true });
|
|
8
12
|
const childDirs = await fs.readdir(dir, { withFileTypes: true });
|
|
9
13
|
const sliceIDs = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliceLibrary-read.js","sources":["../../../src/hooks/sliceLibrary-read.ts"],"sourcesContent":["import type { SliceLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { isSharedSliceModel } from \"../lib/isSharedSliceModel\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceLibraryRead: SliceLibraryReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst dir =
|
|
1
|
+
{"version":3,"file":"sliceLibrary-read.js","sources":["../../../src/hooks/sliceLibrary-read.ts"],"sourcesContent":["import type { SliceLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildSliceLibraryDirectoryPath } from \"../lib/buildSliceLibraryDirectoryPath\";\nimport { isSharedSliceModel } from \"../lib/isSharedSliceModel\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceLibraryRead: SliceLibraryReadHook<PluginOptions> = async (\n\tdata,\n\t{ helpers },\n) => {\n\tconst dir = buildSliceLibraryDirectoryPath({\n\t\tlibraryID: data.libraryID,\n\t\thelpers,\n\t});\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tconst childDirs = await fs.readdir(dir, { withFileTypes: true });\n\n\tconst sliceIDs: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst modelPath = path.join(dir, childDir.name, \"model.json\");\n\n\t\t\t\ttry {\n\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\tif (isSharedSliceModel(modelContents)) {\n\t\t\t\t\t\tsliceIDs.push(modelContents.id);\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// noop\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn {\n\t\tid: data.libraryID,\n\t\tsliceIDs: sliceIDs.sort(),\n\t};\n};\n"],"names":[],"mappings":";;;;;AAUO,MAAM,mBAAwD,OACpE,MACA,EAAE,cACC;AACH,QAAM,MAAM,+BAA+B;AAAA,IAC1C,WAAW,KAAK;AAAA,IAChB;AAAA,EAAA,CACA;AAGD,QAAM,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAEjC,QAAA,YAAY,MAAM,GAAG,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE/D,QAAM,WAAqB,CAAA;AAC3B,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AAC3B,YAAM,YAAY,KAAK,KAAK,KAAK,SAAS,MAAM,YAAY;AAExD,UAAA;AACG,cAAA,gBAAgB,MAAM,aAAa,SAAS;AAE9C,YAAA,mBAAmB,aAAa,GAAG;AAC7B,mBAAA,KAAK,cAAc,EAAE;AAAA,QAC9B;AAAA,MAAA,QACA;AAAA,MAED;AAAA,IACD;AAAA,EACD,CAAA,CAAC;AAGI,SAAA;AAAA,IACN,IAAI,KAAK;AAAA,IACT,UAAU,SAAS,KAAM;AAAA,EAAA;AAE3B;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const commonTags = require("common-tags");
|
|
4
4
|
const node_module = require("node:module");
|
|
5
|
-
const index = require(
|
|
5
|
+
const index = require('./../_node_modules/node-fetch/src/index.cjs');
|
|
6
6
|
const checkIsTypeScriptProject = require("../lib/checkIsTypeScriptProject.cjs");
|
|
7
7
|
const getJSOrTSXFileExtension = require("../lib/getJSOrTSXFileExtension.cjs");
|
|
8
8
|
const REQUIRED_DEPENDENCIES = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { source } from "common-tags";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import fetch from
|
|
3
|
+
import fetch from './../_node_modules/node-fetch/src/index.js';
|
|
4
4
|
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
|
|
5
5
|
import { getJSOrTSXFileExtension } from "../lib/getJSOrTSXFileExtension.js";
|
|
6
6
|
const REQUIRED_DEPENDENCIES = [
|