@slicemachine/adapter-nuxt 0.0.2-dev-plugins-m3.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 +202 -0
- package/README.md +98 -0
- 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 +61 -0
- package/dist/_node_modules/fetch-blob/file.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/file.js +61 -0
- package/dist/_node_modules/fetch-blob/file.js.map +1 -0
- package/dist/_node_modules/fetch-blob/index.cjs +223 -0
- package/dist/_node_modules/fetch-blob/index.cjs.map +1 -0
- package/dist/_node_modules/fetch-blob/index.js +223 -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 +262 -0
- package/dist/_node_modules/node-fetch/src/body.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/body.js +262 -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 +19 -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 +19 -0
- package/dist/_node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/headers.cjs +190 -0
- package/dist/_node_modules/node-fetch/src/headers.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/headers.js +190 -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 +206 -0
- package/dist/_node_modules/node-fetch/src/request.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/request.js +206 -0
- package/dist/_node_modules/node-fetch/src/request.js.map +1 -0
- package/dist/_node_modules/node-fetch/src/response.cjs +122 -0
- package/dist/_node_modules/node-fetch/src/response.cjs.map +1 -0
- package/dist/_node_modules/node-fetch/src/response.js +123 -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 +356 -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 +356 -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 +3822 -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 +3822 -0
- package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
- 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 +31 -0
- package/dist/hooks/customType-asset-delete.cjs.map +1 -0
- package/dist/hooks/customType-asset-delete.d.ts +3 -0
- package/dist/hooks/customType-asset-delete.js +14 -0
- package/dist/hooks/customType-asset-delete.js.map +1 -0
- package/dist/hooks/customType-asset-read.cjs +34 -0
- package/dist/hooks/customType-asset-read.cjs.map +1 -0
- package/dist/hooks/customType-asset-read.d.ts +3 -0
- package/dist/hooks/customType-asset-read.js +17 -0
- package/dist/hooks/customType-asset-read.js.map +1 -0
- package/dist/hooks/customType-asset-update.cjs +34 -0
- package/dist/hooks/customType-asset-update.cjs.map +1 -0
- package/dist/hooks/customType-asset-update.d.ts +3 -0
- package/dist/hooks/customType-asset-update.js +16 -0
- package/dist/hooks/customType-asset-update.js.map +1 -0
- package/dist/hooks/customType-create.cjs +43 -0
- package/dist/hooks/customType-create.cjs.map +1 -0
- package/dist/hooks/customType-create.d.ts +3 -0
- package/dist/hooks/customType-create.js +25 -0
- package/dist/hooks/customType-create.js.map +1 -0
- package/dist/hooks/customType-delete.cjs +32 -0
- package/dist/hooks/customType-delete.cjs.map +1 -0
- package/dist/hooks/customType-delete.d.ts +3 -0
- package/dist/hooks/customType-delete.js +15 -0
- package/dist/hooks/customType-delete.js.map +1 -0
- package/dist/hooks/customType-read.cjs +31 -0
- package/dist/hooks/customType-read.cjs.map +1 -0
- package/dist/hooks/customType-read.d.ts +3 -0
- package/dist/hooks/customType-read.js +14 -0
- package/dist/hooks/customType-read.js.map +1 -0
- package/dist/hooks/customType-rename.cjs +6 -0
- package/dist/hooks/customType-rename.cjs.map +1 -0
- package/dist/hooks/customType-rename.d.ts +1 -0
- package/dist/hooks/customType-rename.js +6 -0
- package/dist/hooks/customType-rename.js.map +1 -0
- package/dist/hooks/customType-update.cjs +6 -0
- package/dist/hooks/customType-update.cjs.map +1 -0
- package/dist/hooks/customType-update.d.ts +1 -0
- package/dist/hooks/customType-update.js +6 -0
- package/dist/hooks/customType-update.js.map +1 -0
- package/dist/hooks/customTypeLibrary-read.cjs +53 -0
- package/dist/hooks/customTypeLibrary-read.cjs.map +1 -0
- package/dist/hooks/customTypeLibrary-read.d.ts +3 -0
- package/dist/hooks/customTypeLibrary-read.js +35 -0
- package/dist/hooks/customTypeLibrary-read.js.map +1 -0
- package/dist/hooks/project-init.cjs +112 -0
- package/dist/hooks/project-init.cjs.map +1 -0
- package/dist/hooks/project-init.d.ts +3 -0
- package/dist/hooks/project-init.js +94 -0
- package/dist/hooks/project-init.js.map +1 -0
- package/dist/hooks/slice-asset-delete.cjs +33 -0
- package/dist/hooks/slice-asset-delete.cjs.map +1 -0
- package/dist/hooks/slice-asset-delete.d.ts +3 -0
- package/dist/hooks/slice-asset-delete.js +16 -0
- package/dist/hooks/slice-asset-delete.js.map +1 -0
- package/dist/hooks/slice-asset-read.cjs +36 -0
- package/dist/hooks/slice-asset-read.cjs.map +1 -0
- package/dist/hooks/slice-asset-read.d.ts +3 -0
- package/dist/hooks/slice-asset-read.js +19 -0
- package/dist/hooks/slice-asset-read.js.map +1 -0
- package/dist/hooks/slice-asset-update.cjs +36 -0
- package/dist/hooks/slice-asset-update.cjs.map +1 -0
- package/dist/hooks/slice-asset-update.d.ts +3 -0
- package/dist/hooks/slice-asset-update.js +18 -0
- package/dist/hooks/slice-asset-update.js.map +1 -0
- package/dist/hooks/slice-create.cjs +77 -0
- package/dist/hooks/slice-create.cjs.map +1 -0
- package/dist/hooks/slice-create.d.ts +3 -0
- package/dist/hooks/slice-create.js +59 -0
- package/dist/hooks/slice-create.js.map +1 -0
- package/dist/hooks/slice-delete.cjs +41 -0
- package/dist/hooks/slice-delete.cjs.map +1 -0
- package/dist/hooks/slice-delete.d.ts +3 -0
- package/dist/hooks/slice-delete.js +24 -0
- package/dist/hooks/slice-delete.js.map +1 -0
- package/dist/hooks/slice-read.cjs +62 -0
- package/dist/hooks/slice-read.cjs.map +1 -0
- package/dist/hooks/slice-read.d.ts +3 -0
- package/dist/hooks/slice-read.js +44 -0
- package/dist/hooks/slice-read.js.map +1 -0
- package/dist/hooks/slice-rename.cjs +51 -0
- package/dist/hooks/slice-rename.cjs.map +1 -0
- package/dist/hooks/slice-rename.d.ts +3 -0
- package/dist/hooks/slice-rename.js +34 -0
- package/dist/hooks/slice-rename.js.map +1 -0
- package/dist/hooks/slice-update.cjs +14 -0
- package/dist/hooks/slice-update.cjs.map +1 -0
- package/dist/hooks/slice-update.d.ts +3 -0
- package/dist/hooks/slice-update.js +14 -0
- package/dist/hooks/slice-update.js.map +1 -0
- package/dist/hooks/sliceLibrary-read.cjs +52 -0
- package/dist/hooks/sliceLibrary-read.cjs.map +1 -0
- package/dist/hooks/sliceLibrary-read.d.ts +3 -0
- package/dist/hooks/sliceLibrary-read.js +34 -0
- package/dist/hooks/sliceLibrary-read.js.map +1 -0
- package/dist/hooks/sliceSimulator-setup-read.cjs +150 -0
- package/dist/hooks/sliceSimulator-setup-read.cjs.map +1 -0
- package/dist/hooks/sliceSimulator-setup-read.d.ts +3 -0
- package/dist/hooks/sliceSimulator-setup-read.js +150 -0
- package/dist/hooks/sliceSimulator-setup-read.js.map +1 -0
- package/dist/hooks/snippet-read.cjs +101 -0
- package/dist/hooks/snippet-read.cjs.map +1 -0
- package/dist/hooks/snippet-read.d.ts +3 -0
- package/dist/hooks/snippet-read.js +101 -0
- package/dist/hooks/snippet-read.js.map +1 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- 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/checkIsTypeScriptProject.cjs +9 -0
- package/dist/lib/checkIsTypeScriptProject.cjs.map +1 -0
- package/dist/lib/checkIsTypeScriptProject.d.ts +8 -0
- package/dist/lib/checkIsTypeScriptProject.js +9 -0
- package/dist/lib/checkIsTypeScriptProject.js.map +1 -0
- package/dist/lib/checkPathExists.cjs +30 -0
- package/dist/lib/checkPathExists.cjs.map +1 -0
- package/dist/lib/checkPathExists.d.ts +2 -0
- package/dist/lib/checkPathExists.js +13 -0
- package/dist/lib/checkPathExists.js.map +1 -0
- package/dist/lib/isSharedSliceModel.cjs +7 -0
- package/dist/lib/isSharedSliceModel.cjs.map +1 -0
- package/dist/lib/isSharedSliceModel.d.ts +335 -0
- package/dist/lib/isSharedSliceModel.js +7 -0
- package/dist/lib/isSharedSliceModel.js.map +1 -0
- package/dist/lib/pascalCase.cjs +8 -0
- package/dist/lib/pascalCase.cjs.map +1 -0
- package/dist/lib/pascalCase.d.ts +8 -0
- package/dist/lib/pascalCase.js +8 -0
- package/dist/lib/pascalCase.js.map +1 -0
- package/dist/lib/readJSONFile.cjs +26 -0
- package/dist/lib/readJSONFile.cjs.map +1 -0
- package/dist/lib/readJSONFile.d.ts +1 -0
- package/dist/lib/readJSONFile.js +9 -0
- package/dist/lib/readJSONFile.js.map +1 -0
- package/dist/lib/rejectIfNecessary.cjs +10 -0
- package/dist/lib/rejectIfNecessary.cjs.map +1 -0
- package/dist/lib/rejectIfNecessary.d.ts +1 -0
- package/dist/lib/rejectIfNecessary.js +10 -0
- package/dist/lib/rejectIfNecessary.js.map +1 -0
- package/dist/lib/updateSliceModelFile.cjs +33 -0
- package/dist/lib/updateSliceModelFile.cjs.map +1 -0
- package/dist/lib/updateSliceModelFile.d.ts +9 -0
- package/dist/lib/updateSliceModelFile.js +15 -0
- package/dist/lib/updateSliceModelFile.js.map +1 -0
- package/dist/lib/upsertGlobalContentTypes.cjs +55 -0
- package/dist/lib/upsertGlobalContentTypes.cjs.map +1 -0
- package/dist/lib/upsertGlobalContentTypes.d.ts +12 -0
- package/dist/lib/upsertGlobalContentTypes.js +37 -0
- package/dist/lib/upsertGlobalContentTypes.js.map +1 -0
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +83 -0
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -0
- package/dist/lib/upsertSliceLibraryIndexFile.d.ts +7 -0
- package/dist/lib/upsertSliceLibraryIndexFile.js +65 -0
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -0
- package/dist/packages/adapter-nuxt/package.json.cjs +5 -0
- package/dist/packages/adapter-nuxt/package.json.cjs.map +1 -0
- package/dist/packages/adapter-nuxt/package.json.js +5 -0
- package/dist/packages/adapter-nuxt/package.json.js.map +1 -0
- package/dist/plugin.cjs +59 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +59 -0
- package/dist/plugin.js.map +1 -0
- package/dist/simulator/SliceSimulator.cjs +79 -0
- package/dist/simulator/SliceSimulator.cjs.map +1 -0
- package/dist/simulator/SliceSimulator.d.ts +34 -0
- package/dist/simulator/SliceSimulator.js +79 -0
- package/dist/simulator/SliceSimulator.js.map +1 -0
- package/dist/simulator/index.d.ts +2 -0
- package/dist/simulator.cjs +5 -0
- package/dist/simulator.cjs.map +1 -0
- package/dist/simulator.js +5 -0
- package/dist/simulator.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/package.json +107 -0
- package/src/constants.ts +5 -0
- package/src/hooks/customType-asset-delete.ts +18 -0
- package/src/hooks/customType-asset-read.ts +22 -0
- package/src/hooks/customType-asset-update.ts +20 -0
- package/src/hooks/customType-create.ts +45 -0
- package/src/hooks/customType-delete.ts +21 -0
- package/src/hooks/customType-read.ts +24 -0
- package/src/hooks/customType-rename.ts +3 -0
- package/src/hooks/customType-update.ts +3 -0
- package/src/hooks/customTypeLibrary-read.ts +53 -0
- package/src/hooks/project-init.ts +163 -0
- package/src/hooks/slice-asset-delete.ts +21 -0
- package/src/hooks/slice-asset-read.ts +25 -0
- package/src/hooks/slice-asset-update.ts +23 -0
- package/src/hooks/slice-create.ts +115 -0
- package/src/hooks/slice-delete.ts +41 -0
- package/src/hooks/slice-read.ts +69 -0
- package/src/hooks/slice-rename.ts +46 -0
- package/src/hooks/slice-update.ts +19 -0
- package/src/hooks/sliceLibrary-read.ts +48 -0
- package/src/hooks/sliceSimulator-setup-read.ts +209 -0
- package/src/hooks/snippet-read.ts +145 -0
- package/src/index.ts +4 -0
- 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/checkIsTypeScriptProject.ts +17 -0
- package/src/lib/checkPathExists.ts +12 -0
- package/src/lib/isSharedSliceModel.ts +14 -0
- package/src/lib/pascalCase.ts +12 -0
- package/src/lib/readJSONFile.ts +7 -0
- package/src/lib/rejectIfNecessary.ts +16 -0
- package/src/lib/updateSliceModelFile.ts +33 -0
- package/src/lib/upsertGlobalContentTypes.ts +62 -0
- package/src/lib/upsertSliceLibraryIndexFile.ts +90 -0
- package/src/plugin.ts +63 -0
- package/src/simulator/SliceSimulator.ts +157 -0
- package/src/simulator/index.ts +2 -0
- package/src/types.ts +5 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { stripIndent } from "common-tags";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath.js";
|
|
5
|
+
import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
|
|
6
|
+
import { updateSliceModelFile } from "../lib/updateSliceModelFile.js";
|
|
7
|
+
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
|
|
8
|
+
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile.js";
|
|
9
|
+
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
|
|
10
|
+
import { pascalCase } from "../lib/pascalCase.js";
|
|
11
|
+
var __freeze = Object.freeze;
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const createComponentFile = async ({ dir, data, helpers, options }) => {
|
|
16
|
+
const filePath = path.join(dir, "index.vue");
|
|
17
|
+
const model = data.model;
|
|
18
|
+
const pascalName = pascalCase(model.name);
|
|
19
|
+
let contents;
|
|
20
|
+
const isTypeScriptProject = await checkIsTypeScriptProject({
|
|
21
|
+
helpers,
|
|
22
|
+
options
|
|
23
|
+
});
|
|
24
|
+
if (isTypeScriptProject) {
|
|
25
|
+
contents = stripIndent(_a || (_a = __template(['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', ' (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup lang="ts">\n import { Content } from "@prismicio/client";\n\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n '], ['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for ', ' (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup lang="ts">\n import { Content } from "@prismicio/client";\n\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps<Content.', 'Slice>(\n ["slice", "index", "slices", "context"]\n ));\n <\/script>\n '])), model.id, pascalName);
|
|
26
|
+
} else {
|
|
27
|
+
contents = stripIndent(_b || (_b = __template(['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup>\n // The array passed to `getSliceComponentProps` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n '], ['\n <template>\n <section\n :data-slice-type="slice.slice_type"\n :data-slice-variation="slice.variation"\n >\n Placeholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n </section>\n </template>\n\n <script setup>\n // The array passed to \\`getSliceComponentProps\\` is purely optional.\n // Consider it as a visual hint for you when templating your slice.\n defineProps(getSliceComponentProps(["slice", "index", "slices", "context"]));\n <\/script>\n '])));
|
|
28
|
+
}
|
|
29
|
+
if (options.format) {
|
|
30
|
+
contents = await helpers.format(contents, filePath, {
|
|
31
|
+
prettier: { parser: "vue" }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
await fs.writeFile(filePath, contents);
|
|
35
|
+
};
|
|
36
|
+
const sliceCreate = async (data, context) => {
|
|
37
|
+
const dir = buildSliceDirectoryPath({
|
|
38
|
+
libraryID: data.libraryID,
|
|
39
|
+
model: data.model,
|
|
40
|
+
helpers: context.helpers
|
|
41
|
+
});
|
|
42
|
+
await fs.mkdir(dir, { recursive: true });
|
|
43
|
+
rejectIfNecessary(await Promise.allSettled([
|
|
44
|
+
updateSliceModelFile({
|
|
45
|
+
libraryID: data.libraryID,
|
|
46
|
+
model: data.model,
|
|
47
|
+
...context
|
|
48
|
+
}),
|
|
49
|
+
createComponentFile({ dir, data, ...context })
|
|
50
|
+
]));
|
|
51
|
+
rejectIfNecessary(await Promise.allSettled([
|
|
52
|
+
upsertGlobalContentTypes(context),
|
|
53
|
+
upsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context })
|
|
54
|
+
]));
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
sliceCreate
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=slice-create.js.map
|
|
@@ -0,0 +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 { buildSliceDirectoryPath } from \"../lib/buildSliceDirectoryPath\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { updateSliceModelFile } from \"../lib/updateSliceModelFile\";\nimport { upsertGlobalContentTypes } from \"../lib/upsertGlobalContentTypes\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { pascalCase } from \"../lib/pascalCase\";\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(dir, \"index.vue\");\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\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for ${model.id} (variation: {{ slice.variation }}) Slices\n\t\t\t\t</section>\n\t\t\t</template>\n\n\t\t\t<script setup lang=\"ts\">\n\t\t\timport { Content } from \"@prismicio/client\";\n\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps<Content.${pascalName}Slice>(\n\t\t\t\t[\"slice\", \"index\", \"slices\", \"context\"]\n\t\t\t));\n\t\t\t</script>\n\t\t`;\n\t} else {\n\t\tcontents = stripIndent`\n\t\t\t<template>\n\t\t\t\t<section\n\t\t\t\t\t:data-slice-type=\"slice.slice_type\"\n\t\t\t\t\t:data-slice-variation=\"slice.variation\"\n\t\t\t\t>\n\t\t\t\t\tPlaceholder component for {{ model.id }} (variation: {{ slice.variation }}) Slices\n\t\t\t\t</section>\n\t\t\t</template>\n\n\t\t\t<script setup>\n\t\t\t// The array passed to \\`getSliceComponentProps\\` is purely optional.\n\t\t\t// Consider it as a visual hint for you when templating your slice.\n\t\t\tdefineProps(getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]));\n\t\t\t</script>\n\t\t`;\n\t}\n\n\tif (options.format) {\n\t\tcontents = await helpers.format(contents, filePath, {\n\t\t\tprettier: { parser: \"vue\" },\n\t\t});\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":";;;;;;;;;;;;;AAKA,IAAA,IAAA;AAmBA,MAAM,sBAAsB,OAAO,EAAE,KAAK,MAAM,SAAS,cAAmB;AAC3E,QAAM,WAAW,KAAK,KAAK,KAAK,WAAW;AAC3C,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,YAAA,OAAA,KAAW,6KAMiB,gWASiB,iFAAA,GAflC,kKAMiB,oWASiB,iFAAA,CAAA,IATzB,MAAM,IASS,UAAA;AAAA,EAAA,OAKxC;AACN,eAAW,YAAW,OAAA,KAAA,WAAA,CAAA,igBAAA,GAAA,CAAA,qgBAAA,CAAA,EAAA;AAAA,EAgBtB;AAED,MAAI,QAAQ,QAAQ;AACnB,eAAW,MAAM,QAAQ,OAAO,UAAU,UAAU;AAAA,MACnD,UAAU,EAAE,QAAQ,MAAO;AAAA,IAAA,CAC3B;AAAA,EACD;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;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
const buildSliceDirectoryPath = require("../lib/buildSliceDirectoryPath.cjs");
|
|
5
|
+
const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
|
|
6
|
+
const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
|
|
7
|
+
const upsertSliceLibraryIndexFile = require("../lib/upsertSliceLibraryIndexFile.cjs");
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
25
|
+
const deleteSliceDir = async ({ data, helpers }) => {
|
|
26
|
+
const dir = buildSliceDirectoryPath.buildSliceDirectoryPath({
|
|
27
|
+
libraryID: data.libraryID,
|
|
28
|
+
model: data.model,
|
|
29
|
+
helpers
|
|
30
|
+
});
|
|
31
|
+
await fs__namespace.rm(dir, { recursive: true });
|
|
32
|
+
};
|
|
33
|
+
const sliceDelete = async (data, context) => {
|
|
34
|
+
await deleteSliceDir({ data, ...context });
|
|
35
|
+
rejectIfNecessary.rejectIfNecessary(await Promise.allSettled([
|
|
36
|
+
upsertGlobalContentTypes.upsertGlobalContentTypes(context),
|
|
37
|
+
upsertSliceLibraryIndexFile.upsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context })
|
|
38
|
+
]));
|
|
39
|
+
};
|
|
40
|
+
exports.sliceDelete = sliceDelete;
|
|
41
|
+
//# sourceMappingURL=slice-delete.cjs.map
|
|
@@ -0,0 +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 { 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;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath.js";
|
|
3
|
+
import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
|
|
4
|
+
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
|
|
5
|
+
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile.js";
|
|
6
|
+
const deleteSliceDir = async ({ data, helpers }) => {
|
|
7
|
+
const dir = buildSliceDirectoryPath({
|
|
8
|
+
libraryID: data.libraryID,
|
|
9
|
+
model: data.model,
|
|
10
|
+
helpers
|
|
11
|
+
});
|
|
12
|
+
await fs.rm(dir, { recursive: true });
|
|
13
|
+
};
|
|
14
|
+
const sliceDelete = async (data, context) => {
|
|
15
|
+
await deleteSliceDir({ data, ...context });
|
|
16
|
+
rejectIfNecessary(await Promise.allSettled([
|
|
17
|
+
upsertGlobalContentTypes(context),
|
|
18
|
+
upsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context })
|
|
19
|
+
]));
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
sliceDelete
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=slice-delete.js.map
|
|
@@ -0,0 +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 { 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;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const buildSliceLibraryDirectoryPath = require("../lib/buildSliceLibraryDirectoryPath.cjs");
|
|
6
|
+
const isSharedSliceModel = require("../lib/isSharedSliceModel.cjs");
|
|
7
|
+
const readJSONFile = require("../lib/readJSONFile.cjs");
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
25
|
+
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
26
|
+
const sliceRead = async (data, { helpers }) => {
|
|
27
|
+
const libraryDir = buildSliceLibraryDirectoryPath.buildSliceLibraryDirectoryPath({
|
|
28
|
+
libraryID: data.libraryID,
|
|
29
|
+
helpers
|
|
30
|
+
});
|
|
31
|
+
await fs__namespace.mkdir(libraryDir, { recursive: true });
|
|
32
|
+
const childDirs = await fs__namespace.readdir(libraryDir, { withFileTypes: true });
|
|
33
|
+
const modelReadErrors = [];
|
|
34
|
+
const [model] = (await Promise.all(childDirs.map(async (childDir) => {
|
|
35
|
+
if (childDir.isDirectory()) {
|
|
36
|
+
const modelPath = path__namespace.join(libraryDir, childDir.name, "model.json");
|
|
37
|
+
try {
|
|
38
|
+
const modelContents = await readJSONFile.readJSONFile(modelPath);
|
|
39
|
+
if (isSharedSliceModel.isSharedSliceModel(modelContents) && modelContents.id === data.sliceID) {
|
|
40
|
+
return modelContents;
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
modelReadErrors.push(modelPath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}))).filter((model2) => Boolean(model2));
|
|
47
|
+
if (model) {
|
|
48
|
+
return {
|
|
49
|
+
model
|
|
50
|
+
};
|
|
51
|
+
} else {
|
|
52
|
+
if (modelReadErrors.length) {
|
|
53
|
+
throw new Error(`Did not find a Slice model with ID "${data.sliceID}" in the "${data.libraryID}" Slice Library.
|
|
54
|
+
|
|
55
|
+
Those Slice models could not be read:
|
|
56
|
+
- ${modelReadErrors.join("\n - ")}`);
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`Did not find a Slice model with ID "${data.sliceID}" in the "${data.libraryID}" Slice Library.`);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.sliceRead = sliceRead;
|
|
62
|
+
//# sourceMappingURL=slice-read.cjs.map
|
|
@@ -0,0 +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 { 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\tconst modelReadErrors: string[] = [];\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\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisSharedSliceModel(modelContents) &&\n\t\t\t\t\t\t\tmodelContents.id === data.sliceID\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn modelContents;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tmodelReadErrors.push(modelPath);\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\tif (modelReadErrors.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Did not find a Slice model with ID \"${data.sliceID}\" in the \"${\n\t\t\t\t\tdata.libraryID\n\t\t\t\t}\" Slice Library.\\n\\nThose Slice models could not be read:\\n - ${modelReadErrors.join(\n\t\t\t\t\t\"\\n - \",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\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;AAEtE,QAAM,kBAA4B,CAAA;AAG5B,QAAA,CAAC,KAAK,KACX,MAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AAC3B,YAAM,YAAYC,gBAAK,KAAK,YAAY,SAAS,MAAM,YAAY;AAC/D,UAAA;AACG,cAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAElD,YACCC,mBAAAA,mBAAmB,aAAa,KAChC,cAAc,OAAO,KAAK,SACzB;AACM,iBAAA;AAAA,QACP;AAAA,eACO;AACR,wBAAgB,KAAK,SAAS;AAAA,MAC9B;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,QAAI,gBAAgB,QAAQ;AAC3B,YAAM,IAAI,MACT,uCAAuC,KAAK,oBAC3C,KAAK;AAAA;AAAA;AAAA,MAC4D,gBAAgB,KACjF,QAAQ,GACN;AAAA,IAEJ;AAED,UAAM,IAAI,MACT,uCAAuC,KAAK,oBAAoB,KAAK,2BAA2B;AAAA,EAEjG;AACF;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { buildSliceLibraryDirectoryPath } from "../lib/buildSliceLibraryDirectoryPath.js";
|
|
4
|
+
import { isSharedSliceModel } from "../lib/isSharedSliceModel.js";
|
|
5
|
+
import { readJSONFile } from "../lib/readJSONFile.js";
|
|
6
|
+
const sliceRead = async (data, { helpers }) => {
|
|
7
|
+
const libraryDir = buildSliceLibraryDirectoryPath({
|
|
8
|
+
libraryID: data.libraryID,
|
|
9
|
+
helpers
|
|
10
|
+
});
|
|
11
|
+
await fs.mkdir(libraryDir, { recursive: true });
|
|
12
|
+
const childDirs = await fs.readdir(libraryDir, { withFileTypes: true });
|
|
13
|
+
const modelReadErrors = [];
|
|
14
|
+
const [model] = (await Promise.all(childDirs.map(async (childDir) => {
|
|
15
|
+
if (childDir.isDirectory()) {
|
|
16
|
+
const modelPath = path.join(libraryDir, childDir.name, "model.json");
|
|
17
|
+
try {
|
|
18
|
+
const modelContents = await readJSONFile(modelPath);
|
|
19
|
+
if (isSharedSliceModel(modelContents) && modelContents.id === data.sliceID) {
|
|
20
|
+
return modelContents;
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
modelReadErrors.push(modelPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}))).filter((model2) => Boolean(model2));
|
|
27
|
+
if (model) {
|
|
28
|
+
return {
|
|
29
|
+
model
|
|
30
|
+
};
|
|
31
|
+
} else {
|
|
32
|
+
if (modelReadErrors.length) {
|
|
33
|
+
throw new Error(`Did not find a Slice model with ID "${data.sliceID}" in the "${data.libraryID}" Slice Library.
|
|
34
|
+
|
|
35
|
+
Those Slice models could not be read:
|
|
36
|
+
- ${modelReadErrors.join("\n - ")}`);
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Did not find a Slice model with ID "${data.sliceID}" in the "${data.libraryID}" Slice Library.`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
sliceRead
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=slice-read.js.map
|
|
@@ -0,0 +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 { 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\tconst modelReadErrors: string[] = [];\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\t\t\t\t\ttry {\n\t\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisSharedSliceModel(modelContents) &&\n\t\t\t\t\t\t\tmodelContents.id === data.sliceID\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn modelContents;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tmodelReadErrors.push(modelPath);\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\tif (modelReadErrors.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Did not find a Slice model with ID \"${data.sliceID}\" in the \"${\n\t\t\t\t\tdata.libraryID\n\t\t\t\t}\" Slice Library.\\n\\nThose Slice models could not be read:\\n - ${modelReadErrors.join(\n\t\t\t\t\t\"\\n - \",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\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;AAEtE,QAAM,kBAA4B,CAAA;AAG5B,QAAA,CAAC,KAAK,KACX,MAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AAC3B,YAAM,YAAY,KAAK,KAAK,YAAY,SAAS,MAAM,YAAY;AAC/D,UAAA;AACG,cAAA,gBAAgB,MAAM,aAAa,SAAS;AAElD,YACC,mBAAmB,aAAa,KAChC,cAAc,OAAO,KAAK,SACzB;AACM,iBAAA;AAAA,QACP;AAAA,eACO;AACR,wBAAgB,KAAK,SAAS;AAAA,MAC9B;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,QAAI,gBAAgB,QAAQ;AAC3B,YAAM,IAAI,MACT,uCAAuC,KAAK,oBAC3C,KAAK;AAAA;AAAA;AAAA,MAC4D,gBAAgB,KACjF,QAAQ,GACN;AAAA,IAEJ;AAED,UAAM,IAAI,MACT,uCAAuC,KAAK,oBAAoB,KAAK,2BAA2B;AAAA,EAEjG;AACF;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const fse = require("fs-extra");
|
|
4
|
+
const buildSliceDirectoryPath = require("../lib/buildSliceDirectoryPath.cjs");
|
|
5
|
+
const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
|
|
6
|
+
const updateSliceModelFile = require("../lib/updateSliceModelFile.cjs");
|
|
7
|
+
const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
|
|
8
|
+
const upsertSliceLibraryIndexFile = require("../lib/upsertSliceLibraryIndexFile.cjs");
|
|
9
|
+
function _interopNamespaceDefault(e) {
|
|
10
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
11
|
+
if (e) {
|
|
12
|
+
for (const k in e) {
|
|
13
|
+
if (k !== "default") {
|
|
14
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: () => e[k]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
const fse__namespace = /* @__PURE__ */ _interopNamespaceDefault(fse);
|
|
26
|
+
const sliceRename = async (data, context) => {
|
|
27
|
+
const { model: currentModel } = await context.actions.readSliceModel({
|
|
28
|
+
libraryID: data.libraryID,
|
|
29
|
+
sliceID: data.model.id
|
|
30
|
+
});
|
|
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
|
+
}));
|
|
40
|
+
await updateSliceModelFile.updateSliceModelFile({
|
|
41
|
+
libraryID: data.libraryID,
|
|
42
|
+
model: data.model,
|
|
43
|
+
...context
|
|
44
|
+
});
|
|
45
|
+
rejectIfNecessary.rejectIfNecessary(await Promise.allSettled([
|
|
46
|
+
upsertGlobalContentTypes.upsertGlobalContentTypes(context),
|
|
47
|
+
upsertSliceLibraryIndexFile.upsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context })
|
|
48
|
+
]));
|
|
49
|
+
};
|
|
50
|
+
exports.sliceRename = sliceRename;
|
|
51
|
+
//# sourceMappingURL=slice-rename.cjs.map
|
|
@@ -0,0 +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 { 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;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as fse from "fs-extra";
|
|
2
|
+
import { buildSliceDirectoryPath } from "../lib/buildSliceDirectoryPath.js";
|
|
3
|
+
import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
|
|
4
|
+
import { updateSliceModelFile } from "../lib/updateSliceModelFile.js";
|
|
5
|
+
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
|
|
6
|
+
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile.js";
|
|
7
|
+
const sliceRename = async (data, context) => {
|
|
8
|
+
const { model: currentModel } = await context.actions.readSliceModel({
|
|
9
|
+
libraryID: data.libraryID,
|
|
10
|
+
sliceID: data.model.id
|
|
11
|
+
});
|
|
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
|
+
}));
|
|
21
|
+
await updateSliceModelFile({
|
|
22
|
+
libraryID: data.libraryID,
|
|
23
|
+
model: data.model,
|
|
24
|
+
...context
|
|
25
|
+
});
|
|
26
|
+
rejectIfNecessary(await Promise.allSettled([
|
|
27
|
+
upsertGlobalContentTypes(context),
|
|
28
|
+
upsertSliceLibraryIndexFile({ libraryID: data.libraryID, ...context })
|
|
29
|
+
]));
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
sliceRename
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=slice-rename.js.map
|
|
@@ -0,0 +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 { 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;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const updateSliceModelFile = require("../lib/updateSliceModelFile.cjs");
|
|
4
|
+
const upsertGlobalContentTypes = require("../lib/upsertGlobalContentTypes.cjs");
|
|
5
|
+
const sliceUpdate = async (data, context) => {
|
|
6
|
+
await updateSliceModelFile.updateSliceModelFile({
|
|
7
|
+
libraryID: data.libraryID,
|
|
8
|
+
model: data.model,
|
|
9
|
+
...context
|
|
10
|
+
});
|
|
11
|
+
await upsertGlobalContentTypes.upsertGlobalContentTypes(context);
|
|
12
|
+
};
|
|
13
|
+
exports.sliceUpdate = sliceUpdate;
|
|
14
|
+
//# sourceMappingURL=slice-update.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { updateSliceModelFile } from "../lib/updateSliceModelFile.js";
|
|
2
|
+
import { upsertGlobalContentTypes } from "../lib/upsertGlobalContentTypes.js";
|
|
3
|
+
const sliceUpdate = async (data, context) => {
|
|
4
|
+
await updateSliceModelFile({
|
|
5
|
+
libraryID: data.libraryID,
|
|
6
|
+
model: data.model,
|
|
7
|
+
...context
|
|
8
|
+
});
|
|
9
|
+
await upsertGlobalContentTypes(context);
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
sliceUpdate
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=slice-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const fs = require("node:fs/promises");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const buildSliceLibraryDirectoryPath = require("../lib/buildSliceLibraryDirectoryPath.cjs");
|
|
6
|
+
const isSharedSliceModel = require("../lib/isSharedSliceModel.cjs");
|
|
7
|
+
const readJSONFile = require("../lib/readJSONFile.cjs");
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
25
|
+
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
26
|
+
const sliceLibraryRead = async (data, { helpers }) => {
|
|
27
|
+
const dir = buildSliceLibraryDirectoryPath.buildSliceLibraryDirectoryPath({
|
|
28
|
+
libraryID: data.libraryID,
|
|
29
|
+
helpers
|
|
30
|
+
});
|
|
31
|
+
await fs__namespace.mkdir(dir, { recursive: true });
|
|
32
|
+
const childDirs = await fs__namespace.readdir(dir, { withFileTypes: true });
|
|
33
|
+
const sliceIDs = [];
|
|
34
|
+
await Promise.all(childDirs.map(async (childDir) => {
|
|
35
|
+
if (childDir.isDirectory()) {
|
|
36
|
+
const modelPath = path__namespace.join(dir, childDir.name, "model.json");
|
|
37
|
+
try {
|
|
38
|
+
const modelContents = await readJSONFile.readJSONFile(modelPath);
|
|
39
|
+
if (isSharedSliceModel.isSharedSliceModel(modelContents)) {
|
|
40
|
+
sliceIDs.push(modelContents.id);
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
return {
|
|
47
|
+
id: data.libraryID,
|
|
48
|
+
sliceIDs: sliceIDs.sort()
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
exports.sliceLibraryRead = sliceLibraryRead;
|
|
52
|
+
//# sourceMappingURL=sliceLibrary-read.cjs.map
|
|
@@ -0,0 +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 { 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;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { buildSliceLibraryDirectoryPath } from "../lib/buildSliceLibraryDirectoryPath.js";
|
|
4
|
+
import { isSharedSliceModel } from "../lib/isSharedSliceModel.js";
|
|
5
|
+
import { readJSONFile } from "../lib/readJSONFile.js";
|
|
6
|
+
const sliceLibraryRead = async (data, { helpers }) => {
|
|
7
|
+
const dir = buildSliceLibraryDirectoryPath({
|
|
8
|
+
libraryID: data.libraryID,
|
|
9
|
+
helpers
|
|
10
|
+
});
|
|
11
|
+
await fs.mkdir(dir, { recursive: true });
|
|
12
|
+
const childDirs = await fs.readdir(dir, { withFileTypes: true });
|
|
13
|
+
const sliceIDs = [];
|
|
14
|
+
await Promise.all(childDirs.map(async (childDir) => {
|
|
15
|
+
if (childDir.isDirectory()) {
|
|
16
|
+
const modelPath = path.join(dir, childDir.name, "model.json");
|
|
17
|
+
try {
|
|
18
|
+
const modelContents = await readJSONFile(modelPath);
|
|
19
|
+
if (isSharedSliceModel(modelContents)) {
|
|
20
|
+
sliceIDs.push(modelContents.id);
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
return {
|
|
27
|
+
id: data.libraryID,
|
|
28
|
+
sliceIDs: sliceIDs.sort()
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
sliceLibraryRead
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=sliceLibrary-read.js.map
|
|
@@ -0,0 +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 { 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;"}
|