@slicemachine/adapter-next 0.0.3 → 0.0.5
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/SliceSimulator.cjs +14 -41
- package/dist/SliceSimulator.cjs.map +1 -1
- package/dist/SliceSimulator.js +11 -36
- package/dist/SliceSimulator.js.map +1 -1
- package/dist/_virtual/_commonjsHelpers.cjs +5 -0
- package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
- package/dist/_virtual/_commonjsHelpers.js +5 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/ponyfill.es2018.cjs +13 -0
- package/dist/_virtual/ponyfill.es2018.cjs.map +1 -0
- package/dist/_virtual/ponyfill.es2018.js +14 -0
- package/dist/_virtual/ponyfill.es2018.js.map +1 -0
- package/dist/constants.cjs +5 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/hooks/customType-asset-delete.cjs +3 -5
- package/dist/hooks/customType-asset-delete.cjs.map +1 -1
- package/dist/hooks/customType-asset-delete.js.map +1 -1
- package/dist/hooks/customType-asset-read.cjs +3 -5
- package/dist/hooks/customType-asset-read.cjs.map +1 -1
- package/dist/hooks/customType-asset-read.js.map +1 -1
- package/dist/hooks/customType-asset-update.cjs +4 -6
- package/dist/hooks/customType-asset-update.cjs.map +1 -1
- package/dist/hooks/customType-asset-update.js.map +1 -1
- package/dist/hooks/customType-create.cjs +4 -6
- package/dist/hooks/customType-create.cjs.map +1 -1
- package/dist/hooks/customType-create.js.map +1 -1
- package/dist/hooks/customType-delete.cjs +3 -5
- package/dist/hooks/customType-delete.cjs.map +1 -1
- package/dist/hooks/customType-delete.js.map +1 -1
- package/dist/hooks/customType-read.cjs +1 -1
- package/dist/hooks/customType-read.cjs.map +1 -1
- package/dist/hooks/customType-read.js.map +1 -1
- package/dist/hooks/customType-rename.cjs +1 -1
- package/dist/hooks/customType-rename.cjs.map +1 -1
- package/dist/hooks/customType-rename.js.map +1 -1
- package/dist/hooks/customType-update.cjs +1 -1
- package/dist/hooks/customType-update.cjs.map +1 -1
- package/dist/hooks/customType-update.js.map +1 -1
- package/dist/hooks/customTypeLibrary-read.cjs +4 -6
- package/dist/hooks/customTypeLibrary-read.cjs.map +1 -1
- package/dist/hooks/customTypeLibrary-read.js.map +1 -1
- package/dist/hooks/slice-asset-delete.cjs +3 -5
- package/dist/hooks/slice-asset-delete.cjs.map +1 -1
- package/dist/hooks/slice-asset-delete.js.map +1 -1
- package/dist/hooks/slice-asset-read.cjs +3 -5
- package/dist/hooks/slice-asset-read.cjs.map +1 -1
- package/dist/hooks/slice-asset-read.js.map +1 -1
- package/dist/hooks/slice-asset-update.cjs +4 -6
- package/dist/hooks/slice-asset-update.cjs.map +1 -1
- package/dist/hooks/slice-asset-update.js.map +1 -1
- package/dist/hooks/slice-create.cjs +7 -9
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +3 -3
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/hooks/slice-delete.cjs +3 -5
- package/dist/hooks/slice-delete.cjs.map +1 -1
- package/dist/hooks/slice-delete.js.map +1 -1
- package/dist/hooks/slice-read.cjs +4 -6
- package/dist/hooks/slice-read.cjs.map +1 -1
- package/dist/hooks/slice-read.js.map +1 -1
- package/dist/hooks/slice-rename.cjs +3 -5
- package/dist/hooks/slice-rename.cjs.map +1 -1
- package/dist/hooks/slice-rename.js.map +1 -1
- package/dist/hooks/slice-update.cjs +1 -1
- package/dist/hooks/slice-update.cjs.map +1 -1
- package/dist/hooks/slice-update.js.map +1 -1
- package/dist/hooks/sliceLibrary-read.cjs +4 -6
- package/dist/hooks/sliceLibrary-read.cjs.map +1 -1
- package/dist/hooks/sliceLibrary-read.js.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.cjs +32 -98
- package/dist/hooks/sliceSimulator-setup-read.cjs.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.js +32 -79
- package/dist/hooks/sliceSimulator-setup-read.js.map +1 -1
- package/dist/hooks/snippet-read.cjs +33 -18
- package/dist/hooks/snippet-read.cjs.map +1 -1
- package/dist/hooks/snippet-read.js +30 -13
- package/dist/hooks/snippet-read.js.map +1 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/getJSOrTSXFileExtension.cjs +1 -1
- package/dist/lib/getJSOrTSXFileExtension.cjs.map +1 -1
- package/dist/lib/getJSOrTSXFileExtension.js.map +1 -1
- package/dist/lib/isSharedSliceModel.cjs +3 -5
- package/dist/lib/isSharedSliceModel.cjs.map +1 -1
- package/dist/lib/isSharedSliceModel.js.map +1 -1
- package/dist/lib/pascalCase.cjs +1 -1
- package/dist/lib/pascalCase.cjs.map +1 -1
- package/dist/lib/pascalCase.js.map +1 -1
- package/dist/lib/readJSONFile.cjs +3 -5
- package/dist/lib/readJSONFile.cjs.map +1 -1
- package/dist/lib/readJSONFile.js.map +1 -1
- package/dist/lib/rejectIfNecessary.cjs +1 -1
- package/dist/lib/rejectIfNecessary.cjs.map +1 -1
- package/dist/lib/rejectIfNecessary.js.map +1 -1
- package/dist/lib/updateSliceModelFile.cjs +3 -5
- package/dist/lib/updateSliceModelFile.cjs.map +1 -1
- package/dist/lib/updateSliceModelFile.js.map +1 -1
- package/dist/lib/upsertGlobalContentTypes.cjs +8 -6
- package/dist/lib/upsertGlobalContentTypes.cjs.map +1 -1
- package/dist/lib/upsertGlobalContentTypes.js +4 -0
- package/dist/lib/upsertGlobalContentTypes.js.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +9 -8
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js +6 -3
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -1
- package/dist/node_modules/data-uri-to-buffer/dist/index.cjs +41 -0
- package/dist/node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -0
- package/dist/node_modules/data-uri-to-buffer/dist/index.js +41 -0
- package/dist/node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
- package/dist/node_modules/fetch-blob/file.cjs +55 -0
- package/dist/node_modules/fetch-blob/file.cjs.map +1 -0
- package/dist/node_modules/fetch-blob/file.js +55 -0
- package/dist/node_modules/fetch-blob/file.js.map +1 -0
- package/dist/node_modules/fetch-blob/index.cjs +177 -0
- package/dist/node_modules/fetch-blob/index.cjs.map +1 -0
- package/dist/node_modules/fetch-blob/index.js +177 -0
- package/dist/node_modules/fetch-blob/index.js.map +1 -0
- package/dist/node_modules/fetch-blob/streams.cjs +43 -0
- package/dist/node_modules/fetch-blob/streams.cjs.map +1 -0
- package/dist/node_modules/fetch-blob/streams.js +42 -0
- package/dist/node_modules/fetch-blob/streams.js.map +1 -0
- package/dist/node_modules/formdata-polyfill/esm.min.cjs +116 -0
- package/dist/node_modules/formdata-polyfill/esm.min.cjs.map +1 -0
- package/dist/node_modules/formdata-polyfill/esm.min.js +116 -0
- package/dist/node_modules/formdata-polyfill/esm.min.js.map +1 -0
- package/dist/node_modules/node-domexception/index.cjs +11 -0
- package/dist/node_modules/node-domexception/index.cjs.map +1 -0
- package/dist/node_modules/node-domexception/index.js +10 -0
- package/dist/node_modules/node-domexception/index.js.map +1 -0
- package/dist/node_modules/node-fetch/src/body.cjs +237 -0
- package/dist/node_modules/node-fetch/src/body.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/body.js +237 -0
- package/dist/node_modules/node-fetch/src/body.js.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/abort-error.cjs +10 -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 +10 -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 +17 -0
- package/dist/node_modules/node-fetch/src/errors/base.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/base.js +17 -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 +14 -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 +14 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
- package/dist/node_modules/node-fetch/src/headers.cjs +173 -0
- package/dist/node_modules/node-fetch/src/headers.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/headers.js +173 -0
- package/dist/node_modules/node-fetch/src/headers.js.map +1 -0
- package/dist/node_modules/node-fetch/src/index.cjs +292 -0
- package/dist/node_modules/node-fetch/src/index.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/index.js +292 -0
- package/dist/node_modules/node-fetch/src/index.js.map +1 -0
- package/dist/node_modules/node-fetch/src/request.cjs +193 -0
- package/dist/node_modules/node-fetch/src/request.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/request.js +193 -0
- package/dist/node_modules/node-fetch/src/request.js.map +1 -0
- package/dist/node_modules/node-fetch/src/response.cjs +110 -0
- package/dist/node_modules/node-fetch/src/response.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/response.js +110 -0
- package/dist/node_modules/node-fetch/src/response.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/get-search.cjs +12 -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 +12 -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 +8 -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 +8 -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 +28 -0
- package/dist/node_modules/node-fetch/src/utils/is.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/is.js +28 -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 +350 -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 +350 -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 +149 -0
- package/dist/node_modules/node-fetch/src/utils/referrer.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/referrer.js +149 -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 +3599 -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 +3599 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
- package/dist/package.json.cjs +5 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/{package.js → package.json.js} +1 -1
- package/dist/package.json.js.map +1 -0
- package/dist/plugin.cjs +2 -2
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/package.json +32 -17
- package/src/constants.ts +5 -0
- package/src/hooks/slice-create.ts +3 -3
- package/src/hooks/sliceSimulator-setup-read.ts +38 -80
- package/src/hooks/snippet-read.ts +42 -22
- package/src/index.ts +0 -6
- package/src/lib/upsertGlobalContentTypes.ts +3 -0
- package/src/lib/upsertSliceLibraryIndexFile.ts +11 -6
- package/dist/package.cjs +0 -5
- package/dist/package.cjs.map +0 -1
- package/dist/package.js.map +0 -1
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
const readJSONFile = require("../lib/readJSONFile.cjs");
|
|
6
|
-
function
|
|
7
|
-
if (e && e.__esModule)
|
|
8
|
-
return e;
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
9
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
8
|
if (e) {
|
|
11
9
|
for (const k in e) {
|
|
@@ -21,8 +19,8 @@ function _interopNamespace(e) {
|
|
|
21
19
|
n.default = e;
|
|
22
20
|
return Object.freeze(n);
|
|
23
21
|
}
|
|
24
|
-
const fs__namespace = /* @__PURE__ */
|
|
25
|
-
const path__namespace = /* @__PURE__ */
|
|
22
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
23
|
+
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
26
24
|
const isCustomTypeModel = (input) => {
|
|
27
25
|
return typeof input === "object" && input !== null && "json" in input;
|
|
28
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypeLibrary-read.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"customTypeLibrary-read.cjs","sources":["../../../src/hooks/customTypeLibrary-read.ts"],"sourcesContent":["import type { CustomTypeLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport * as prismicT from \"@prismicio/types\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst isCustomTypeModel = (\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinput: any,\n): input is prismicT.CustomTypeModel => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nexport const customTypeLibraryRead: CustomTypeLibraryReadHook<\n\tPluginOptions\n> = async (_data, { helpers }) => {\n\tconst dirPath = helpers.joinPathFromRoot(\"customtypes\");\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(dirPath, { recursive: true });\n\n\tconst childDirs = await fs.readdir(dirPath);\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tconst childDirContents = await fs.readdir(path.join(dirPath, childDir), {\n\t\t\t\twithFileTypes: true,\n\t\t\t});\n\t\t\tconst isCustomTypeDir = childDirContents.some((entry) => {\n\t\t\t\treturn entry.isFile() && entry.name === \"index.json\";\n\t\t\t});\n\n\t\t\tif (isCustomTypeDir) {\n\t\t\t\tconst modelPath = path.join(dirPath, childDir, \"index.json\");\n\n\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\t\tids.push(modelContents.id);\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n"],"names":["fs","path","readJSONFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,oBAAoB,CAEzB,UACsC;AACtC,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AACjE;AAEO,MAAM,wBAET,OAAO,OAAO,EAAE,cAAa;AAC1B,QAAA,UAAU,QAAQ,iBAAiB,aAAa;AAGtD,QAAMA,cAAG,MAAM,SAAS,EAAE,WAAW,MAAM;AAE3C,QAAM,YAAY,MAAMA,cAAG,QAAQ,OAAO;AAE1C,QAAM,MAAgB,CAAA;AACtB,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC1B,UAAA,mBAAmB,MAAMA,cAAG,QAAQC,gBAAK,KAAK,SAAS,QAAQ,GAAG;AAAA,MACvE,eAAe;AAAA,IAAA,CACf;AACD,UAAM,kBAAkB,iBAAiB,KAAK,CAAC,UAAS;AACvD,aAAO,MAAM,OAAA,KAAY,MAAM,SAAS;AAAA,IAAA,CACxC;AAED,QAAI,iBAAiB;AACpB,YAAM,YAAYA,gBAAK,KAAK,SAAS,UAAU,YAAY;AAErD,YAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAE9C,UAAA,kBAAkB,aAAa,GAAG;AACjC,YAAA,KAAK,cAAc,EAAE;AAAA,MACzB;AAAA,IACD;AAAA,EACD,CAAA,CAAC;AAGI,SAAA;AAAA,IACN,KAAK,IAAI,KAAM;AAAA,EAAA;AAEjB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypeLibrary-read.js","sources":["
|
|
1
|
+
{"version":3,"file":"customTypeLibrary-read.js","sources":["../../../src/hooks/customTypeLibrary-read.ts"],"sourcesContent":["import type { CustomTypeLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport * as prismicT from \"@prismicio/types\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst isCustomTypeModel = (\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinput: any,\n): input is prismicT.CustomTypeModel => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nexport const customTypeLibraryRead: CustomTypeLibraryReadHook<\n\tPluginOptions\n> = async (_data, { helpers }) => {\n\tconst dirPath = helpers.joinPathFromRoot(\"customtypes\");\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(dirPath, { recursive: true });\n\n\tconst childDirs = await fs.readdir(dirPath);\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tconst childDirContents = await fs.readdir(path.join(dirPath, childDir), {\n\t\t\t\twithFileTypes: true,\n\t\t\t});\n\t\t\tconst isCustomTypeDir = childDirContents.some((entry) => {\n\t\t\t\treturn entry.isFile() && entry.name === \"index.json\";\n\t\t\t});\n\n\t\t\tif (isCustomTypeDir) {\n\t\t\t\tconst modelPath = path.join(dirPath, childDir, \"index.json\");\n\n\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\t\tids.push(modelContents.id);\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n"],"names":[],"mappings":";;;AASA,MAAM,oBAAoB,CAEzB,UACsC;AACtC,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AACjE;AAEO,MAAM,wBAET,OAAO,OAAO,EAAE,cAAa;AAC1B,QAAA,UAAU,QAAQ,iBAAiB,aAAa;AAGtD,QAAM,GAAG,MAAM,SAAS,EAAE,WAAW,MAAM;AAE3C,QAAM,YAAY,MAAM,GAAG,QAAQ,OAAO;AAE1C,QAAM,MAAgB,CAAA;AACtB,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC1B,UAAA,mBAAmB,MAAM,GAAG,QAAQ,KAAK,KAAK,SAAS,QAAQ,GAAG;AAAA,MACvE,eAAe;AAAA,IAAA,CACf;AACD,UAAM,kBAAkB,iBAAiB,KAAK,CAAC,UAAS;AACvD,aAAO,MAAM,OAAA,KAAY,MAAM,SAAS;AAAA,IAAA,CACxC;AAED,QAAI,iBAAiB;AACpB,YAAM,YAAY,KAAK,KAAK,SAAS,UAAU,YAAY;AAErD,YAAA,gBAAgB,MAAM,aAAa,SAAS;AAE9C,UAAA,kBAAkB,aAAa,GAAG;AACjC,YAAA,KAAK,cAAc,EAAE;AAAA,MACzB;AAAA,IACD;AAAA,EACD,CAAA,CAAC;AAGI,SAAA;AAAA,IACN,KAAK,IAAI,KAAM;AAAA,EAAA;AAEjB;"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const pascalCase = require("../lib/pascalCase.cjs");
|
|
5
|
-
function
|
|
6
|
-
if (e && e.__esModule)
|
|
7
|
-
return e;
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
8
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
7
|
if (e) {
|
|
10
8
|
for (const k in e) {
|
|
@@ -20,7 +18,7 @@ function _interopNamespace(e) {
|
|
|
20
18
|
n.default = e;
|
|
21
19
|
return Object.freeze(n);
|
|
22
20
|
}
|
|
23
|
-
const fs__namespace = /* @__PURE__ */
|
|
21
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
24
22
|
const sliceAssetDelete = async (data, context) => {
|
|
25
23
|
const filePath = context.helpers.joinPathFromRoot(data.libraryID, pascalCase.pascalCase(data.sliceID), data.assetID);
|
|
26
24
|
await fs__namespace.rm(filePath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-delete.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"slice-asset-delete.cjs","sources":["../../../src/hooks/slice-asset-delete.ts"],"sourcesContent":["import type { SliceAssetDeleteHook } from \"@slicemachine/plugin-kit\";\nimport * as fs from \"node:fs/promises\";\n\nimport { pascalCase } from \"../lib/pascalCase\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetDelete: SliceAssetDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.sliceID),\n\t\tdata.assetID,\n\t);\n\n\tawait fs.rm(filePath);\n};\n"],"names":["pascalCase","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOa,MAAA,mBAAwD,OACpE,MACA,YACG;AACG,QAAA,WAAW,QAAQ,QAAQ,iBAChC,KAAK,WACLA,WAAA,WAAW,KAAK,OAAO,GACvB,KAAK,OAAO;AAGP,QAAAC,cAAG,GAAG,QAAQ;AACrB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-delete.js","sources":["
|
|
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 { pascalCase } from \"../lib/pascalCase\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetDelete: SliceAssetDeleteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.sliceID),\n\t\tdata.assetID,\n\t);\n\n\tawait fs.rm(filePath);\n};\n"],"names":[],"mappings":";;AAOa,MAAA,mBAAwD,OACpE,MACA,YACG;AACG,QAAA,WAAW,QAAQ,QAAQ,iBAChC,KAAK,WACL,WAAW,KAAK,OAAO,GACvB,KAAK,OAAO;AAGP,QAAA,GAAG,GAAG,QAAQ;AACrB;"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const pascalCase = require("../lib/pascalCase.cjs");
|
|
5
|
-
function
|
|
6
|
-
if (e && e.__esModule)
|
|
7
|
-
return e;
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
8
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
7
|
if (e) {
|
|
10
8
|
for (const k in e) {
|
|
@@ -20,7 +18,7 @@ function _interopNamespace(e) {
|
|
|
20
18
|
n.default = e;
|
|
21
19
|
return Object.freeze(n);
|
|
22
20
|
}
|
|
23
|
-
const fs__namespace = /* @__PURE__ */
|
|
21
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
24
22
|
const sliceAssetRead = async (data, context) => {
|
|
25
23
|
const filePath = context.helpers.joinPathFromRoot(data.libraryID, pascalCase.pascalCase(data.sliceID), data.assetID);
|
|
26
24
|
const assetData = await fs__namespace.readFile(filePath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-read.cjs","sources":["
|
|
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 { pascalCase } from \"../lib/pascalCase\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetRead: SliceAssetReadHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.sliceID),\n\t\tdata.assetID,\n\t);\n\n\tconst assetData = await fs.readFile(filePath);\n\n\treturn {\n\t\tdata: assetData,\n\t};\n};\n"],"names":["pascalCase","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOa,MAAA,iBAAoD,OAChE,MACA,YACG;AACG,QAAA,WAAW,QAAQ,QAAQ,iBAChC,KAAK,WACLA,WAAA,WAAW,KAAK,OAAO,GACvB,KAAK,OAAO;AAGb,QAAM,YAAY,MAAMC,cAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-read.js","sources":["
|
|
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 { pascalCase } from \"../lib/pascalCase\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetRead: SliceAssetReadHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.sliceID),\n\t\tdata.assetID,\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,QAAQ,QAAQ,iBAChC,KAAK,WACL,WAAW,KAAK,OAAO,GACvB,KAAK,OAAO;AAGb,QAAM,YAAY,MAAM,GAAG,SAAS,QAAQ;AAErC,SAAA;AAAA,IACN,MAAM;AAAA,EAAA;AAER;"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
const pascalCase = require("../lib/pascalCase.cjs");
|
|
6
|
-
function
|
|
7
|
-
if (e && e.__esModule)
|
|
8
|
-
return e;
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
9
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
8
|
if (e) {
|
|
11
9
|
for (const k in e) {
|
|
@@ -21,8 +19,8 @@ function _interopNamespace(e) {
|
|
|
21
19
|
n.default = e;
|
|
22
20
|
return Object.freeze(n);
|
|
23
21
|
}
|
|
24
|
-
const fs__namespace = /* @__PURE__ */
|
|
25
|
-
const path__namespace = /* @__PURE__ */
|
|
22
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
23
|
+
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
26
24
|
const sliceAssetUpdate = async (data, context) => {
|
|
27
25
|
const filePath = context.helpers.joinPathFromRoot(data.libraryID, pascalCase.pascalCase(data.sliceID), data.asset.id);
|
|
28
26
|
await fs__namespace.mkdir(path__namespace.dirname(filePath), { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-update.cjs","sources":["
|
|
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 { pascalCase } from \"../lib/pascalCase\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetUpdate: SliceAssetUpdateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.sliceID),\n\t\tdata.asset.id,\n\t);\n\n\tawait fs.mkdir(path.dirname(filePath), { recursive: true });\n\tawait fs.writeFile(filePath, data.asset.data);\n};\n"],"names":["pascalCase","fs","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQa,MAAA,mBAAwD,OACpE,MACA,YACG;AACH,QAAM,WAAW,QAAQ,QAAQ,iBAChC,KAAK,WACLA,sBAAW,KAAK,OAAO,GACvB,KAAK,MAAM,EAAE;AAGR,QAAAC,cAAG,MAAMC,gBAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAA,CAAM;AAC1D,QAAMD,cAAG,UAAU,UAAU,KAAK,MAAM,IAAI;AAC7C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-asset-update.js","sources":["
|
|
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 { pascalCase } from \"../lib/pascalCase\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceAssetUpdate: SliceAssetUpdateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tconst filePath = context.helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.sliceID),\n\t\tdata.asset.id,\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;AACH,QAAM,WAAW,QAAQ,QAAQ,iBAChC,KAAK,WACL,WAAW,KAAK,OAAO,GACvB,KAAK,MAAM,EAAE;AAGR,QAAA,GAAG,MAAM,KAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAA,CAAM;AAC1D,QAAM,GAAG,UAAU,UAAU,KAAK,MAAM,IAAI;AAC7C;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
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");
|
|
@@ -8,9 +8,7 @@ const getJSOrTSXFileExtension = require("../lib/getJSOrTSXFileExtension.cjs");
|
|
|
8
8
|
const pascalCase = require("../lib/pascalCase.cjs");
|
|
9
9
|
const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
|
|
10
10
|
const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
|
|
11
|
-
function
|
|
12
|
-
if (e && e.__esModule)
|
|
13
|
-
return e;
|
|
11
|
+
function _interopNamespaceDefault(e) {
|
|
14
12
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
15
13
|
if (e) {
|
|
16
14
|
for (const k in e) {
|
|
@@ -26,8 +24,8 @@ function _interopNamespace(e) {
|
|
|
26
24
|
n.default = e;
|
|
27
25
|
return Object.freeze(n);
|
|
28
26
|
}
|
|
29
|
-
const fs__namespace = /* @__PURE__ */
|
|
30
|
-
const path__namespace = /* @__PURE__ */
|
|
27
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
28
|
+
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
31
29
|
const createModelFile = async ({ dir, data, helpers, options }) => {
|
|
32
30
|
const filePath = path__namespace.join(dir, "model.json");
|
|
33
31
|
let contents = JSON.stringify(data.model);
|
|
@@ -43,13 +41,13 @@ const createComponentFile = async ({ dir, data, helpers, options }) => {
|
|
|
43
41
|
let contents;
|
|
44
42
|
if (options.typescript) {
|
|
45
43
|
contents = commonTags.stripIndent`
|
|
44
|
+
import { Content } from "@prismicio/client";
|
|
46
45
|
import { SliceComponentProps } from "@prismicio/react";
|
|
47
|
-
import { ${pascalName}Slice } from "./types";
|
|
48
46
|
|
|
49
47
|
/**
|
|
50
48
|
* Props for \`${pascalName}\`.
|
|
51
49
|
*/
|
|
52
|
-
export type ${pascalName}Props = SliceComponentProps
|
|
50
|
+
export type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;
|
|
53
51
|
|
|
54
52
|
/**
|
|
55
53
|
* Component for "${model.name}" Slices.
|
|
@@ -70,7 +68,7 @@ const createComponentFile = async ({ dir, data, helpers, options }) => {
|
|
|
70
68
|
} else {
|
|
71
69
|
contents = commonTags.stripIndent`
|
|
72
70
|
/**
|
|
73
|
-
* @typedef {import("
|
|
71
|
+
* @typedef {import("@prismicio/client").Content.${pascalName}Slice} ${pascalName}Slice
|
|
74
72
|
* @typedef {import("@prismicio/react").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props
|
|
75
73
|
* @param {${pascalName}Props}
|
|
76
74
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-create.cjs","sources":["
|
|
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 { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\nimport { getJSOrTSXFileExtension } from \"../lib/getJSOrTSXFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createModelFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"model.json\");\n\n\tlet contents = JSON.stringify(data.model);\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nconst createComponentFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, `index.${getJSOrTSXFileExtension(options)}`);\n\tconst model = data.model;\n\tconst pascalName = pascalCase(model.name);\n\n\tlet contents: string;\n\n\tif (options.typescript) {\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): React.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 = context.helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.model.name),\n\t);\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tcreateModelFile({ dir, data, ...context }),\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","fs","getJSOrTSXFileExtension","pascalCase","stripIndent","rejectIfNecessary","upsertGlobalContentTypes","upsertSliceLibraryIndexFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,kBAAkB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AACvE,QAAM,WAAWA,gBAAK,KAAK,KAAK,YAAY;AAE5C,MAAI,WAAW,KAAK,UAAU,KAAK,KAAK;AAExC,MAAI,QAAQ,QAAQ;AACnB,eAAW,MAAM,QAAQ,OAAO,UAAU,QAAQ;AAAA,EAClD;AAEK,QAAAC,cAAG,UAAU,UAAU,QAAQ;AACtC;AAEA,MAAM,sBAAsB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AAC3E,QAAM,WAAWD,gBAAK,KAAK,KAAK,SAASE,gDAAwB,OAAO,GAAG;AAC3E,QAAM,QAAQ,KAAK;AACb,QAAA,aAAaC,WAAAA,WAAW,MAAM,IAAI;AAEpC,MAAA;AAEJ,MAAI,QAAQ,YAAY;AACZ,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,QAAAH,cAAG,UAAU,UAAU,QAAQ;AACtC;AAEa,MAAA,cAA8C,OAC1D,MACA,YACG;AACG,QAAA,MAAM,QAAQ,QAAQ,iBAC3B,KAAK,WACLE,WAAAA,WAAW,KAAK,MAAM,IAAI,CAAC;AAG5B,QAAMF,cAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAGtCI,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,gBAAgB,EAAE,KAAK,MAAM,GAAG,SAAS;AAAA,IACzC,oBAAoB,EAAE,KAAK,MAAM,GAAG,SAAS;AAAA,EAC7C,CAAA,CAAC;AAIFA,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxBC,yBAAAA,yBAAyB,OAAO;AAAA,IAChCC,wDAA4B,EAAE,WAAW,KAAK,WAAW,GAAG,SAAS;AAAA,EACrE,CAAA,CAAC;AAEJ;;"}
|
|
@@ -21,13 +21,13 @@ const createComponentFile = async ({ dir, data, helpers, options }) => {
|
|
|
21
21
|
let contents;
|
|
22
22
|
if (options.typescript) {
|
|
23
23
|
contents = stripIndent`
|
|
24
|
+
import { Content } from "@prismicio/client";
|
|
24
25
|
import { SliceComponentProps } from "@prismicio/react";
|
|
25
|
-
import { ${pascalName}Slice } from "./types";
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Props for \`${pascalName}\`.
|
|
29
29
|
*/
|
|
30
|
-
export type ${pascalName}Props = SliceComponentProps
|
|
30
|
+
export type ${pascalName}Props = SliceComponentProps<Content.${pascalName}Slice>;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Component for "${model.name}" Slices.
|
|
@@ -48,7 +48,7 @@ const createComponentFile = async ({ dir, data, helpers, options }) => {
|
|
|
48
48
|
} else {
|
|
49
49
|
contents = stripIndent`
|
|
50
50
|
/**
|
|
51
|
-
* @typedef {import("
|
|
51
|
+
* @typedef {import("@prismicio/client").Content.${pascalName}Slice} ${pascalName}Slice
|
|
52
52
|
* @typedef {import("@prismicio/react").SliceComponentProps<${pascalName}Slice>} ${pascalName}Props
|
|
53
53
|
* @param {${pascalName}Props}
|
|
54
54
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-create.js","sources":["
|
|
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 { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\nimport { getJSOrTSXFileExtension } from \"../lib/getJSOrTSXFileExtension\";\nimport { pascalCase } from \"../lib/pascalCase\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\ntype Args = {\n\tdir: string;\n\tdata: SliceCreateHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createModelFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, \"model.json\");\n\n\tlet contents = JSON.stringify(data.model);\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath);\n\t}\n\n\tawait fs.writeFile(filePath, contents);\n};\n\nconst createComponentFile = async ({ dir, data, helpers, options }: Args) => {\n\tconst filePath = path.join(dir, `index.${getJSOrTSXFileExtension(options)}`);\n\tconst model = data.model;\n\tconst pascalName = pascalCase(model.name);\n\n\tlet contents: string;\n\n\tif (options.typescript) {\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): React.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 = context.helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.model.name),\n\t);\n\n\tawait fs.mkdir(dir, { recursive: true });\n\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tcreateModelFile({ dir, data, ...context }),\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":";;;;;;;;AAsBA,MAAM,kBAAkB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AACvE,QAAM,WAAW,KAAK,KAAK,KAAK,YAAY;AAE5C,MAAI,WAAW,KAAK,UAAU,KAAK,KAAK;AAExC,MAAI,QAAQ,QAAQ;AACnB,eAAW,MAAM,QAAQ,OAAO,UAAU,QAAQ;AAAA,EAClD;AAEK,QAAA,GAAG,UAAU,UAAU,QAAQ;AACtC;AAEA,MAAM,sBAAsB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AAC3E,QAAM,WAAW,KAAK,KAAK,KAAK,SAAS,wBAAwB,OAAO,GAAG;AAC3E,QAAM,QAAQ,KAAK;AACb,QAAA,aAAa,WAAW,MAAM,IAAI;AAEpC,MAAA;AAEJ,MAAI,QAAQ,YAAY;AACZ,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;AACG,QAAA,MAAM,QAAQ,QAAQ,iBAC3B,KAAK,WACL,WAAW,KAAK,MAAM,IAAI,CAAC;AAG5B,QAAM,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAGtC,oBAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,gBAAgB,EAAE,KAAK,MAAM,GAAG,SAAS;AAAA,IACzC,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,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const pascalCase = require("../lib/pascalCase.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");
|
|
8
|
-
function
|
|
9
|
-
if (e && e.__esModule)
|
|
10
|
-
return e;
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
11
9
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
12
10
|
if (e) {
|
|
13
11
|
for (const k in e) {
|
|
@@ -23,7 +21,7 @@ function _interopNamespace(e) {
|
|
|
23
21
|
n.default = e;
|
|
24
22
|
return Object.freeze(n);
|
|
25
23
|
}
|
|
26
|
-
const fs__namespace = /* @__PURE__ */
|
|
24
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
27
25
|
const deleteSliceDir = async ({ data, helpers }) => {
|
|
28
26
|
const dir = helpers.joinPathFromRoot(data.libraryID, pascalCase.pascalCase(data.model.name));
|
|
29
27
|
await fs__namespace.rm(dir, { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-delete.cjs","sources":["
|
|
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 { 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\tdata: SliceDeleteHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst deleteSliceDir = async ({ data, helpers }: Args) => {\n\tconst dir = helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.model.name),\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":["pascalCase","fs","rejectIfNecessary","upsertGlobalContentTypes","upsertSliceLibraryIndexFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,iBAAiB,OAAO,EAAE,MAAM,cAAmB;AAClD,QAAA,MAAM,QAAQ,iBACnB,KAAK,WACLA,WAAW,WAAA,KAAK,MAAM,IAAI,CAAC;AAG5B,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-delete.js","sources":["
|
|
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 { 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\tdata: SliceDeleteHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst deleteSliceDir = async ({ data, helpers }: Args) => {\n\tconst dir = helpers.joinPathFromRoot(\n\t\tdata.libraryID,\n\t\tpascalCase(data.model.name),\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;AAClD,QAAA,MAAM,QAAQ,iBACnB,KAAK,WACL,WAAW,KAAK,MAAM,IAAI,CAAC;AAG5B,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;"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
const isSharedSliceModel = require("../lib/isSharedSliceModel.cjs");
|
|
6
6
|
const readJSONFile = require("../lib/readJSONFile.cjs");
|
|
7
|
-
function
|
|
8
|
-
if (e && e.__esModule)
|
|
9
|
-
return e;
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
10
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
11
9
|
if (e) {
|
|
12
10
|
for (const k in e) {
|
|
@@ -22,8 +20,8 @@ function _interopNamespace(e) {
|
|
|
22
20
|
n.default = e;
|
|
23
21
|
return Object.freeze(n);
|
|
24
22
|
}
|
|
25
|
-
const fs__namespace = /* @__PURE__ */
|
|
26
|
-
const path__namespace = /* @__PURE__ */
|
|
23
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
24
|
+
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
27
25
|
const sliceRead = async (data, { helpers }) => {
|
|
28
26
|
const libraryDir = helpers.joinPathFromRoot(data.libraryID);
|
|
29
27
|
await fs__namespace.mkdir(libraryDir, { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-read.cjs","sources":["
|
|
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 = helpers.joinPathFromRoot(data.libraryID);\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":["fs","path","readJSONFile","isSharedSliceModel","model"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AASO,MAAM,YAA0C,OACtD,MACA,EAAE,cACC;AACH,QAAM,aAAa,QAAQ,iBAAiB,KAAK,SAAS;AAG1D,QAAMA,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;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-read.js","sources":["
|
|
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 = helpers.joinPathFromRoot(data.libraryID);\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":";;;;AASO,MAAM,YAA0C,OACtD,MACA,EAAE,cACC;AACH,QAAM,aAAa,QAAQ,iBAAiB,KAAK,SAAS;AAG1D,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,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fse = require("fs-extra");
|
|
4
4
|
const pascalCase = require("../lib/pascalCase.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");
|
|
8
8
|
const upsertSliceLibraryIndexFile = require("../lib/upsertSliceLibraryIndexFile.cjs");
|
|
9
|
-
function
|
|
10
|
-
if (e && e.__esModule)
|
|
11
|
-
return e;
|
|
9
|
+
function _interopNamespaceDefault(e) {
|
|
12
10
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
13
11
|
if (e) {
|
|
14
12
|
for (const k in e) {
|
|
@@ -24,7 +22,7 @@ function _interopNamespace(e) {
|
|
|
24
22
|
n.default = e;
|
|
25
23
|
return Object.freeze(n);
|
|
26
24
|
}
|
|
27
|
-
const fse__namespace = /* @__PURE__ */
|
|
25
|
+
const fse__namespace = /* @__PURE__ */ _interopNamespaceDefault(fse);
|
|
28
26
|
const sliceRename = async (data, context) => {
|
|
29
27
|
const { model: currentModel } = await context.actions.readSliceModel({
|
|
30
28
|
libraryID: data.libraryID,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-rename.cjs","sources":["
|
|
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 { 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\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\tcontext.helpers.joinPathFromRoot(\n\t\t\tdata.libraryID,\n\t\t\tpascalCase(currentModel.name),\n\t\t),\n\t\tcontext.helpers.joinPathFromRoot(\n\t\t\tdata.libraryID,\n\t\t\tpascalCase(data.model.name),\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","pascalCase","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,KACT,QAAQ,QAAQ,iBACf,KAAK,WACLC,sBAAW,aAAa,IAAI,CAAC,GAE9B,QAAQ,QAAQ,iBACf,KAAK,WACLA,sBAAW,KAAK,MAAM,IAAI,CAAC,CAC3B;AAGF,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-rename.js","sources":["
|
|
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 { 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\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\tcontext.helpers.joinPathFromRoot(\n\t\t\tdata.libraryID,\n\t\t\tpascalCase(currentModel.name),\n\t\t),\n\t\tcontext.helpers.joinPathFromRoot(\n\t\t\tdata.libraryID,\n\t\t\tpascalCase(data.model.name),\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,QAAQ,QAAQ,iBACf,KAAK,WACL,WAAW,aAAa,IAAI,CAAC,GAE9B,QAAQ,QAAQ,iBACf,KAAK,WACL,WAAW,KAAK,MAAM,IAAI,CAAC,CAC3B;AAGF,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;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const updateSliceModelFile = require("../lib/updateSliceModelFile.cjs");
|
|
4
4
|
const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
|
|
5
5
|
const sliceUpdate = async (data, context) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-update.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"slice-update.cjs","sources":["../../../src/hooks/slice-update.ts"],"sourcesContent":["import type { SliceUpdateHook } from \"@slicemachine/plugin-kit\";\n\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceUpdate: SliceUpdateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tawait updateSliceModelFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\t...context,\n\t});\n\n\tawait upsertGlobalContentTypes(context);\n};\n"],"names":["updateSliceModelFile","upsertGlobalContentTypes"],"mappings":";;;;AAOa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAMA,0CAAqB;AAAA,IAC1B,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,GAAG;AAAA,EAAA,CACH;AAED,QAAMC,yBAAAA,yBAAyB,OAAO;AACvC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice-update.js","sources":["
|
|
1
|
+
{"version":3,"file":"slice-update.js","sources":["../../../src/hooks/slice-update.ts"],"sourcesContent":["import type { SliceUpdateHook } from \"@slicemachine/plugin-kit\";\n\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\n\nimport type { PluginOptions } from \"../types\";\n\nexport const sliceUpdate: SliceUpdateHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tawait updateSliceModelFile({\n\t\tlibraryID: data.libraryID,\n\t\tmodel: data.model,\n\t\t...context,\n\t});\n\n\tawait upsertGlobalContentTypes(context);\n};\n"],"names":[],"mappings":";;AAOa,MAAA,cAA8C,OAC1D,MACA,YACG;AACH,QAAM,qBAAqB;AAAA,IAC1B,WAAW,KAAK;AAAA,IAChB,OAAO,KAAK;AAAA,IACZ,GAAG;AAAA,EAAA,CACH;AAED,QAAM,yBAAyB,OAAO;AACvC;"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("node:fs/promises");
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
const isSharedSliceModel = require("../lib/isSharedSliceModel.cjs");
|
|
6
6
|
const readJSONFile = require("../lib/readJSONFile.cjs");
|
|
7
|
-
function
|
|
8
|
-
if (e && e.__esModule)
|
|
9
|
-
return e;
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
10
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
11
9
|
if (e) {
|
|
12
10
|
for (const k in e) {
|
|
@@ -22,8 +20,8 @@ function _interopNamespace(e) {
|
|
|
22
20
|
n.default = e;
|
|
23
21
|
return Object.freeze(n);
|
|
24
22
|
}
|
|
25
|
-
const fs__namespace = /* @__PURE__ */
|
|
26
|
-
const path__namespace = /* @__PURE__ */
|
|
23
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
24
|
+
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
27
25
|
const sliceLibraryRead = async (data, { helpers }) => {
|
|
28
26
|
const dir = helpers.joinPathFromRoot(data.libraryID);
|
|
29
27
|
await fs__namespace.mkdir(dir, { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliceLibrary-read.cjs","sources":["
|
|
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 = helpers.joinPathFromRoot(data.libraryID);\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":["fs","path","readJSONFile","isSharedSliceModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AASO,MAAM,mBAAwD,OACpE,MACA,EAAE,cACC;AACH,QAAM,MAAM,QAAQ,iBAAiB,KAAK,SAAS;AAGnD,QAAMA,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliceLibrary-read.js","sources":["
|
|
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 = helpers.joinPathFromRoot(data.libraryID);\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":";;;;AASO,MAAM,mBAAwD,OACpE,MACA,EAAE,cACC;AACH,QAAM,MAAM,QAAQ,iBAAiB,KAAK,SAAS;AAGnD,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;"}
|