@slicemachine/adapter-next 0.3.10-dev-next-release.10 → 0.3.10-dev-next-release.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/documentation-read.cjs.map +1 -1
- package/dist/hooks/documentation-read.js.map +1 -1
- package/dist/hooks/project-init.cjs +51 -52
- package/dist/hooks/project-init.cjs.map +1 -1
- package/dist/hooks/project-init.js +51 -51
- package/dist/hooks/project-init.js.map +1 -1
- package/dist/hooks/slice-create.cjs +29 -44
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +29 -26
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/lib/checkHasAppRouter.cjs +23 -2
- package/dist/lib/checkHasAppRouter.cjs.map +1 -1
- package/dist/lib/checkHasAppRouter.js +6 -2
- package/dist/lib/checkHasAppRouter.js.map +1 -1
- package/dist/lib/checkHasSrcDirectory.cjs +5 -2
- package/dist/lib/checkHasSrcDirectory.cjs.map +1 -1
- package/dist/lib/checkHasSrcDirectory.js +5 -2
- package/dist/lib/checkHasSrcDirectory.js.map +1 -1
- package/dist/lib/checkIsTypeScriptProject.cjs +2 -3
- package/dist/lib/checkIsTypeScriptProject.cjs.map +1 -1
- package/dist/lib/checkIsTypeScriptProject.js +2 -3
- package/dist/lib/checkIsTypeScriptProject.js.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +29 -21
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js +29 -20
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -1
- package/dist/plugin.cjs +178 -36
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +178 -36
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -6
- package/src/hooks/documentation-read.ts +2 -1
- package/src/hooks/project-init.ts +58 -63
- package/src/hooks/slice-create.ts +39 -31
- package/src/lib/checkHasAppRouter.ts +6 -6
- package/src/lib/checkHasSrcDirectory.ts +5 -2
- package/src/lib/checkIsTypeScriptProject.ts +5 -4
- package/src/lib/upsertSliceLibraryIndexFile.ts +53 -33
- package/src/plugin.ts +245 -37
- package/dist/hooks/customType-asset-delete.cjs +0 -31
- package/dist/hooks/customType-asset-delete.cjs.map +0 -1
- package/dist/hooks/customType-asset-delete.d.ts +0 -3
- package/dist/hooks/customType-asset-delete.js +0 -14
- package/dist/hooks/customType-asset-delete.js.map +0 -1
- package/dist/hooks/customType-asset-read.cjs +0 -34
- package/dist/hooks/customType-asset-read.cjs.map +0 -1
- package/dist/hooks/customType-asset-read.d.ts +0 -3
- package/dist/hooks/customType-asset-read.js +0 -17
- package/dist/hooks/customType-asset-read.js.map +0 -1
- package/dist/hooks/customType-asset-update.cjs +0 -34
- package/dist/hooks/customType-asset-update.cjs.map +0 -1
- package/dist/hooks/customType-asset-update.d.ts +0 -3
- package/dist/hooks/customType-asset-update.js +0 -16
- package/dist/hooks/customType-asset-update.js.map +0 -1
- package/dist/hooks/customType-create.cjs +0 -43
- package/dist/hooks/customType-create.cjs.map +0 -1
- package/dist/hooks/customType-create.d.ts +0 -3
- package/dist/hooks/customType-create.js +0 -25
- package/dist/hooks/customType-create.js.map +0 -1
- package/dist/hooks/customType-delete.cjs +0 -32
- package/dist/hooks/customType-delete.cjs.map +0 -1
- package/dist/hooks/customType-delete.d.ts +0 -3
- package/dist/hooks/customType-delete.js +0 -15
- package/dist/hooks/customType-delete.js.map +0 -1
- package/dist/hooks/customType-read.cjs +0 -31
- package/dist/hooks/customType-read.cjs.map +0 -1
- package/dist/hooks/customType-read.d.ts +0 -3
- package/dist/hooks/customType-read.js +0 -14
- package/dist/hooks/customType-read.js.map +0 -1
- package/dist/hooks/customType-rename.cjs +0 -6
- package/dist/hooks/customType-rename.cjs.map +0 -1
- package/dist/hooks/customType-rename.d.ts +0 -1
- package/dist/hooks/customType-rename.js +0 -6
- package/dist/hooks/customType-rename.js.map +0 -1
- package/dist/hooks/customType-update.cjs +0 -6
- package/dist/hooks/customType-update.cjs.map +0 -1
- package/dist/hooks/customType-update.d.ts +0 -1
- package/dist/hooks/customType-update.js +0 -6
- package/dist/hooks/customType-update.js.map +0 -1
- package/dist/hooks/customTypeLibrary-read.cjs +0 -55
- package/dist/hooks/customTypeLibrary-read.cjs.map +0 -1
- package/dist/hooks/customTypeLibrary-read.d.ts +0 -3
- package/dist/hooks/customTypeLibrary-read.js +0 -37
- package/dist/hooks/customTypeLibrary-read.js.map +0 -1
- package/dist/hooks/slice-asset-delete.cjs +0 -33
- package/dist/hooks/slice-asset-delete.cjs.map +0 -1
- package/dist/hooks/slice-asset-delete.d.ts +0 -3
- package/dist/hooks/slice-asset-delete.js +0 -16
- package/dist/hooks/slice-asset-delete.js.map +0 -1
- package/dist/hooks/slice-asset-read.cjs +0 -36
- package/dist/hooks/slice-asset-read.cjs.map +0 -1
- package/dist/hooks/slice-asset-read.d.ts +0 -3
- package/dist/hooks/slice-asset-read.js +0 -19
- package/dist/hooks/slice-asset-read.js.map +0 -1
- package/dist/hooks/slice-asset-update.cjs +0 -36
- package/dist/hooks/slice-asset-update.cjs.map +0 -1
- package/dist/hooks/slice-asset-update.d.ts +0 -3
- package/dist/hooks/slice-asset-update.js +0 -18
- package/dist/hooks/slice-asset-update.js.map +0 -1
- package/dist/hooks/slice-delete.cjs +0 -41
- package/dist/hooks/slice-delete.cjs.map +0 -1
- package/dist/hooks/slice-delete.d.ts +0 -3
- package/dist/hooks/slice-delete.js +0 -24
- package/dist/hooks/slice-delete.js.map +0 -1
- package/dist/hooks/slice-read.cjs +0 -62
- package/dist/hooks/slice-read.cjs.map +0 -1
- package/dist/hooks/slice-read.d.ts +0 -3
- package/dist/hooks/slice-read.js +0 -44
- package/dist/hooks/slice-read.js.map +0 -1
- package/dist/hooks/slice-rename.cjs +0 -51
- package/dist/hooks/slice-rename.cjs.map +0 -1
- package/dist/hooks/slice-rename.d.ts +0 -3
- package/dist/hooks/slice-rename.js +0 -34
- package/dist/hooks/slice-rename.js.map +0 -1
- package/dist/hooks/slice-update.cjs +0 -14
- package/dist/hooks/slice-update.cjs.map +0 -1
- package/dist/hooks/slice-update.d.ts +0 -3
- package/dist/hooks/slice-update.js +0 -14
- package/dist/hooks/slice-update.js.map +0 -1
- package/dist/hooks/sliceLibrary-read.cjs +0 -52
- package/dist/hooks/sliceLibrary-read.cjs.map +0 -1
- package/dist/hooks/sliceLibrary-read.d.ts +0 -3
- package/dist/hooks/sliceLibrary-read.js +0 -34
- package/dist/hooks/sliceLibrary-read.js.map +0 -1
- package/dist/lib/buildCustomTypeAssetPath.cjs +0 -29
- package/dist/lib/buildCustomTypeAssetPath.cjs.map +0 -1
- package/dist/lib/buildCustomTypeAssetPath.d.ts +0 -9
- package/dist/lib/buildCustomTypeAssetPath.js +0 -12
- package/dist/lib/buildCustomTypeAssetPath.js.map +0 -1
- package/dist/lib/buildCustomTypeDirectoryPath.cjs +0 -26
- package/dist/lib/buildCustomTypeDirectoryPath.cjs.map +0 -1
- package/dist/lib/buildCustomTypeDirectoryPath.d.ts +0 -8
- package/dist/lib/buildCustomTypeDirectoryPath.js +0 -9
- package/dist/lib/buildCustomTypeDirectoryPath.js.map +0 -1
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs +0 -7
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.cjs.map +0 -1
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.d.ts +0 -7
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.js +0 -7
- package/dist/lib/buildCustomTypeLibraryDirectoryPath.js.map +0 -1
- package/dist/lib/buildSliceAssetPath.cjs +0 -34
- package/dist/lib/buildSliceAssetPath.cjs.map +0 -1
- package/dist/lib/buildSliceAssetPath.d.ts +0 -11
- package/dist/lib/buildSliceAssetPath.js +0 -17
- package/dist/lib/buildSliceAssetPath.js.map +0 -1
- package/dist/lib/buildSliceDirectoryPath.cjs +0 -30
- package/dist/lib/buildSliceDirectoryPath.cjs.map +0 -1
- package/dist/lib/buildSliceDirectoryPath.d.ts +0 -10
- package/dist/lib/buildSliceDirectoryPath.js +0 -13
- package/dist/lib/buildSliceDirectoryPath.js.map +0 -1
- package/dist/lib/buildSliceLibraryDirectoryPath.cjs +0 -7
- package/dist/lib/buildSliceLibraryDirectoryPath.cjs.map +0 -1
- package/dist/lib/buildSliceLibraryDirectoryPath.d.ts +0 -8
- package/dist/lib/buildSliceLibraryDirectoryPath.js +0 -7
- package/dist/lib/buildSliceLibraryDirectoryPath.js.map +0 -1
- package/dist/lib/checkPathExists.cjs +0 -30
- package/dist/lib/checkPathExists.cjs.map +0 -1
- package/dist/lib/checkPathExists.d.ts +0 -2
- package/dist/lib/checkPathExists.js +0 -13
- package/dist/lib/checkPathExists.js.map +0 -1
- package/dist/lib/isSharedSliceModel.cjs +0 -7
- package/dist/lib/isSharedSliceModel.cjs.map +0 -1
- package/dist/lib/isSharedSliceModel.d.ts +0 -335
- package/dist/lib/isSharedSliceModel.js +0 -7
- package/dist/lib/isSharedSliceModel.js.map +0 -1
- package/dist/lib/readJSONFile.cjs +0 -26
- package/dist/lib/readJSONFile.cjs.map +0 -1
- package/dist/lib/readJSONFile.d.ts +0 -1
- package/dist/lib/readJSONFile.js +0 -9
- package/dist/lib/readJSONFile.js.map +0 -1
- package/dist/lib/updateSliceModelFile.cjs +0 -33
- package/dist/lib/updateSliceModelFile.cjs.map +0 -1
- package/dist/lib/updateSliceModelFile.d.ts +0 -9
- package/dist/lib/updateSliceModelFile.js +0 -15
- package/dist/lib/updateSliceModelFile.js.map +0 -1
- package/dist/lib/upsertGlobalContentTypes.cjs +0 -56
- package/dist/lib/upsertGlobalContentTypes.cjs.map +0 -1
- package/dist/lib/upsertGlobalContentTypes.d.ts +0 -12
- package/dist/lib/upsertGlobalContentTypes.js +0 -38
- package/dist/lib/upsertGlobalContentTypes.js.map +0 -1
- package/src/hooks/customType-asset-delete.ts +0 -18
- package/src/hooks/customType-asset-read.ts +0 -22
- package/src/hooks/customType-asset-update.ts +0 -20
- package/src/hooks/customType-create.ts +0 -45
- package/src/hooks/customType-delete.ts +0 -21
- package/src/hooks/customType-read.ts +0 -24
- package/src/hooks/customType-rename.ts +0 -3
- package/src/hooks/customType-update.ts +0 -3
- package/src/hooks/customTypeLibrary-read.ts +0 -58
- package/src/hooks/slice-asset-delete.ts +0 -21
- package/src/hooks/slice-asset-read.ts +0 -25
- package/src/hooks/slice-asset-update.ts +0 -23
- package/src/hooks/slice-delete.ts +0 -41
- package/src/hooks/slice-read.ts +0 -69
- package/src/hooks/slice-rename.ts +0 -46
- package/src/hooks/slice-update.ts +0 -19
- package/src/hooks/sliceLibrary-read.ts +0 -48
- package/src/lib/buildCustomTypeAssetPath.ts +0 -24
- package/src/lib/buildCustomTypeDirectoryPath.ts +0 -20
- package/src/lib/buildCustomTypeLibraryDirectoryPath.ts +0 -13
- package/src/lib/buildSliceAssetPath.ts +0 -32
- package/src/lib/buildSliceDirectoryPath.ts +0 -26
- package/src/lib/buildSliceLibraryDirectoryPath.ts +0 -14
- package/src/lib/checkPathExists.ts +0 -12
- package/src/lib/isSharedSliceModel.ts +0 -14
- package/src/lib/readJSONFile.ts +0 -7
- package/src/lib/updateSliceModelFile.ts +0 -33
- package/src/lib/upsertGlobalContentTypes.ts +0 -63
package/dist/plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { projectInit } from \"./hooks/project-init\";\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\nimport { documentationRead } from \"./hooks/documentation-read\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"project:init\", projectInit);\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\n\t\thook(\"slice-library:read\", sliceLibraryRead);\n\n\t\thook(\"custom-type:create\", customTypeCreate);\n\t\thook(\"custom-type:update\", customTypeUpdate);\n\t\thook(\"custom-type:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\n\t\thook(\"custom-type-library:read\", customTypeLibraryRead);\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\thook(\"documentation:read\", documentationRead);\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":["defineSliceMachinePlugin","pkgName","projectInit","sliceCreate","sliceUpdate","sliceRename","sliceDelete","sliceRead","sliceAssetUpdate","sliceAssetDelete","sliceAssetRead","sliceLibraryRead","customTypeCreate","customTypeUpdate","customTypeRename","customTypeDelete","customTypeRead","customTypeAssetUpdate","customTypeAssetDelete","customTypeAssetRead","customTypeLibraryRead","snippetRead","documentationRead","sliceSimulatorSetupRead"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,SAASA,UAAAA,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL,MAAMC,SAAA;AAAA,EACN;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAChB;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgBC,YAAAA,WAAW;AAEhC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,gBAAgBC,YAAAA,WAAW;AAChC,SAAK,cAAcC,UAAAA,SAAS;AAC5B,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,oBAAoBC,eAAAA,cAAc;AACvC,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAE3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,sBAAsBC,iBAAAA,gBAAgB;AAC3C,SAAK,oBAAoBC,eAAAA,cAAc;AACvC,SAAK,4BAA4BC,sBAAAA,qBAAqB;AACtD,SAAK,4BAA4BC,sBAAAA,qBAAqB;AACtD,SAAK,0BAA0BC,oBAAAA,mBAAmB;AAClD,SAAK,4BAA4BC,sBAAAA,qBAAqB;AAEtD,SAAK,gBAAgBC,YAAAA,WAAW;AAEhC,SAAK,sBAAsBC,kBAAAA,iBAAiB;AAE5C,SAAK,8BAA8BC,wBAAAA,uBAAuB;AAAA,EAC3D;AACA,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\nimport {\n\tdeleteCustomTypeDirectory,\n\tdeleteCustomTypeFile,\n\tdeleteSliceDirectory,\n\tdeleteSliceFile,\n\treadCustomTypeFile,\n\treadCustomTypeLibrary,\n\treadCustomTypeModel,\n\treadSliceFile,\n\treadSliceLibrary,\n\treadSliceModel,\n\trenameCustomType,\n\trenameSlice,\n\tupsertGlobalTypeScriptTypes,\n\twriteCustomTypeFile,\n\twriteCustomTypeModel,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { rejectIfNecessary } from \"./lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"./lib/upsertSliceLibraryIndexFile\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { documentationRead } from \"./hooks/documentation-read\";\nimport { projectInit } from \"./hooks/project-init\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\t////////////////////////////////////////////////////////////////\n\t\t// project:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"project:init\", projectInit);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", async (data, context) => {\n\t\t\tawait writeSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:rename\", async (data, context) => {\n\t\t\tawait renameSlice({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:delete\", async (data, context) => {\n\t\t\tawait deleteSliceDirectory({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:read\", async (data, context) => {\n\t\t\treturn await readSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:update\", async (data, context) => {\n\t\t\tawait writeSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:delete\", async (data, context) => {\n\t\t\tawait deleteSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:read\", async (data, context) => {\n\t\t\tconst file = await readSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-library:read\", async (data, context) => {\n\t\t\treturn await readSliceLibrary({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type:create\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:rename\", async (data, context) => {\n\t\t\tawait renameCustomType({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeDirectory({\n\t\t\t\tcustomTypeID: data.model.id,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:read\", async (data, context) => {\n\t\t\treturn await readCustomTypeModel({\n\t\t\t\tcustomTypeID: data.id,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:read\", async (data, context) => {\n\t\t\tconst file = await readCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type-library:read\", async (_data, context) => {\n\t\t\treturn await readCustomTypeLibrary({\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// snippet:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// documentation:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"documentation:read\", documentationRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-simulator:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":["defineSliceMachinePlugin","pkgName","projectInit","sliceCreate","writeSliceModel","upsertGlobalTypeScriptTypes","renameSlice","rejectIfNecessary","upsertSliceLibraryIndexFile","deleteSliceDirectory","readSliceModel","writeSliceFile","deleteSliceFile","readSliceFile","readSliceLibrary","writeCustomTypeModel","renameCustomType","deleteCustomTypeDirectory","readCustomTypeModel","writeCustomTypeFile","deleteCustomTypeFile","readCustomTypeFile","readCustomTypeLibrary","snippetRead","documentationRead","sliceSimulatorSetupRead"],"mappings":";;;;;;;;;;;;AAiCO,MAAM,SAASA,UAAAA,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL,MAAMC,SAAA;AAAA,EACN;AAAA,EACD,gBAAgB;AAAA,IACf,QA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;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,4BAA4B,OAAO,MAAM,YAAW;AACxD,YAAMC,wBAAqB;AAAA,QAC1B,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,0BAA0B,OAAO,MAAM,YAAW;AAChD,YAAA,OAAO,MAAMC,sBAAmB;AAAA,QACrC,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAEM,aAAA;AAAA,QACN,MAAM;AAAA,MAAA;AAAA,KAEP;AAMI,SAAA,4BAA4B,OAAO,OAAO,YAAW;AACzD,aAAO,MAAMC,GAAAA,sBAAsB;AAAA,QAClC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAAA,IAAA,CACD;AAMD,SAAK,gBAAgBC,YAAAA,WAAW;AAMhC,SAAK,sBAAsBC,kBAAAA,iBAAiB;AAM5C,SAAK,8BAA8BC,wBAAAA,uBAAuB;AAAA,EAC3D;AACA,CAAA;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import { defineSliceMachinePlugin } from "@slicemachine/plugin-kit";
|
|
2
|
+
import { writeSliceModel, upsertGlobalTypeScriptTypes, renameSlice, deleteSliceDirectory, readSliceModel, writeSliceFile, deleteSliceFile, readSliceFile, readSliceLibrary, writeCustomTypeModel, renameCustomType, deleteCustomTypeDirectory, readCustomTypeModel, writeCustomTypeFile, deleteCustomTypeFile, readCustomTypeFile, readCustomTypeLibrary } from "@slicemachine/plugin-kit/fs";
|
|
3
|
+
import { rejectIfNecessary } from "./lib/rejectIfNecessary.js";
|
|
4
|
+
import { upsertSliceLibraryIndexFile } from "./lib/upsertSliceLibraryIndexFile.js";
|
|
2
5
|
import { name } from "./packages/adapter-next/package.json.js";
|
|
6
|
+
import { documentationRead } from "./hooks/documentation-read.js";
|
|
3
7
|
import { projectInit } from "./hooks/project-init.js";
|
|
4
|
-
import { customTypeAssetDelete } from "./hooks/customType-asset-delete.js";
|
|
5
|
-
import { customTypeAssetRead } from "./hooks/customType-asset-read.js";
|
|
6
|
-
import { customTypeAssetUpdate } from "./hooks/customType-asset-update.js";
|
|
7
|
-
import { customTypeCreate } from "./hooks/customType-create.js";
|
|
8
|
-
import { customTypeDelete } from "./hooks/customType-delete.js";
|
|
9
|
-
import { customTypeLibraryRead } from "./hooks/customTypeLibrary-read.js";
|
|
10
|
-
import { customTypeRead } from "./hooks/customType-read.js";
|
|
11
|
-
import { customTypeRename } from "./hooks/customType-rename.js";
|
|
12
|
-
import { customTypeUpdate } from "./hooks/customType-update.js";
|
|
13
|
-
import { sliceAssetDelete } from "./hooks/slice-asset-delete.js";
|
|
14
|
-
import { sliceAssetRead } from "./hooks/slice-asset-read.js";
|
|
15
|
-
import { sliceAssetUpdate } from "./hooks/slice-asset-update.js";
|
|
16
8
|
import { sliceCreate } from "./hooks/slice-create.js";
|
|
17
|
-
import { sliceDelete } from "./hooks/slice-delete.js";
|
|
18
|
-
import { sliceLibraryRead } from "./hooks/sliceLibrary-read.js";
|
|
19
|
-
import { sliceRead } from "./hooks/slice-read.js";
|
|
20
|
-
import { sliceRename } from "./hooks/slice-rename.js";
|
|
21
|
-
import { sliceUpdate } from "./hooks/slice-update.js";
|
|
22
|
-
import { snippetRead } from "./hooks/snippet-read.js";
|
|
23
|
-
import { documentationRead } from "./hooks/documentation-read.js";
|
|
24
9
|
import { sliceSimulatorSetupRead } from "./hooks/sliceSimulator-setup-read.js";
|
|
10
|
+
import { snippetRead } from "./hooks/snippet-read.js";
|
|
25
11
|
const plugin = defineSliceMachinePlugin({
|
|
26
12
|
meta: {
|
|
27
13
|
name
|
|
@@ -33,23 +19,179 @@ const plugin = defineSliceMachinePlugin({
|
|
|
33
19
|
setup({ hook }) {
|
|
34
20
|
hook("project:init", projectInit);
|
|
35
21
|
hook("slice:create", sliceCreate);
|
|
36
|
-
hook("slice:update",
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
hook("
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
22
|
+
hook("slice:update", async (data, context) => {
|
|
23
|
+
await writeSliceModel({
|
|
24
|
+
libraryID: data.libraryID,
|
|
25
|
+
model: data.model,
|
|
26
|
+
...context
|
|
27
|
+
});
|
|
28
|
+
await upsertGlobalTypeScriptTypes({
|
|
29
|
+
filename: context.options.generatedTypesFilePath,
|
|
30
|
+
format: context.options.format,
|
|
31
|
+
...context
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
hook("slice:rename", async (data, context) => {
|
|
35
|
+
await renameSlice({
|
|
36
|
+
libraryID: data.libraryID,
|
|
37
|
+
model: data.model,
|
|
38
|
+
format: context.options.format,
|
|
39
|
+
...context
|
|
40
|
+
});
|
|
41
|
+
rejectIfNecessary(await Promise.allSettled([
|
|
42
|
+
upsertSliceLibraryIndexFile({
|
|
43
|
+
libraryID: data.libraryID,
|
|
44
|
+
...context
|
|
45
|
+
}),
|
|
46
|
+
upsertGlobalTypeScriptTypes({
|
|
47
|
+
filename: context.options.generatedTypesFilePath,
|
|
48
|
+
format: context.options.format,
|
|
49
|
+
...context
|
|
50
|
+
})
|
|
51
|
+
]));
|
|
52
|
+
});
|
|
53
|
+
hook("slice:delete", async (data, context) => {
|
|
54
|
+
await deleteSliceDirectory({
|
|
55
|
+
libraryID: data.libraryID,
|
|
56
|
+
model: data.model,
|
|
57
|
+
...context
|
|
58
|
+
});
|
|
59
|
+
rejectIfNecessary(await Promise.allSettled([
|
|
60
|
+
upsertSliceLibraryIndexFile({
|
|
61
|
+
libraryID: data.libraryID,
|
|
62
|
+
...context
|
|
63
|
+
}),
|
|
64
|
+
upsertGlobalTypeScriptTypes({
|
|
65
|
+
filename: context.options.generatedTypesFilePath,
|
|
66
|
+
format: context.options.format,
|
|
67
|
+
...context
|
|
68
|
+
})
|
|
69
|
+
]));
|
|
70
|
+
});
|
|
71
|
+
hook("slice:read", async (data, context) => {
|
|
72
|
+
return await readSliceModel({
|
|
73
|
+
libraryID: data.libraryID,
|
|
74
|
+
sliceID: data.sliceID,
|
|
75
|
+
...context
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
hook("slice:asset:update", async (data, context) => {
|
|
79
|
+
await writeSliceFile({
|
|
80
|
+
libraryID: data.libraryID,
|
|
81
|
+
sliceID: data.sliceID,
|
|
82
|
+
filename: data.asset.id,
|
|
83
|
+
contents: data.asset.data,
|
|
84
|
+
...context
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
hook("slice:asset:delete", async (data, context) => {
|
|
88
|
+
await deleteSliceFile({
|
|
89
|
+
libraryID: data.libraryID,
|
|
90
|
+
sliceID: data.sliceID,
|
|
91
|
+
filename: data.assetID,
|
|
92
|
+
...context
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
hook("slice:asset:read", async (data, context) => {
|
|
96
|
+
const file = await readSliceFile({
|
|
97
|
+
libraryID: data.libraryID,
|
|
98
|
+
sliceID: data.sliceID,
|
|
99
|
+
filename: data.assetID,
|
|
100
|
+
...context
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
data: file
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
hook("slice-library:read", async (data, context) => {
|
|
107
|
+
return await readSliceLibrary({
|
|
108
|
+
libraryID: data.libraryID,
|
|
109
|
+
...context
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
hook("custom-type:create", async (data, context) => {
|
|
113
|
+
await writeCustomTypeModel({
|
|
114
|
+
model: data.model,
|
|
115
|
+
format: context.options.format,
|
|
116
|
+
...context
|
|
117
|
+
});
|
|
118
|
+
await upsertGlobalTypeScriptTypes({
|
|
119
|
+
filename: context.options.generatedTypesFilePath,
|
|
120
|
+
format: context.options.format,
|
|
121
|
+
...context
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
hook("custom-type:update", async (data, context) => {
|
|
125
|
+
await writeCustomTypeModel({
|
|
126
|
+
model: data.model,
|
|
127
|
+
format: context.options.format,
|
|
128
|
+
...context
|
|
129
|
+
});
|
|
130
|
+
await upsertGlobalTypeScriptTypes({
|
|
131
|
+
filename: context.options.generatedTypesFilePath,
|
|
132
|
+
format: context.options.format,
|
|
133
|
+
...context
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
hook("custom-type:rename", async (data, context) => {
|
|
137
|
+
await renameCustomType({
|
|
138
|
+
model: data.model,
|
|
139
|
+
format: context.options.format,
|
|
140
|
+
...context
|
|
141
|
+
});
|
|
142
|
+
await upsertGlobalTypeScriptTypes({
|
|
143
|
+
filename: context.options.generatedTypesFilePath,
|
|
144
|
+
format: context.options.format,
|
|
145
|
+
...context
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
hook("custom-type:delete", async (data, context) => {
|
|
149
|
+
await deleteCustomTypeDirectory({
|
|
150
|
+
customTypeID: data.model.id,
|
|
151
|
+
...context
|
|
152
|
+
});
|
|
153
|
+
await upsertGlobalTypeScriptTypes({
|
|
154
|
+
filename: context.options.generatedTypesFilePath,
|
|
155
|
+
format: context.options.format,
|
|
156
|
+
...context
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
hook("custom-type:read", async (data, context) => {
|
|
160
|
+
return await readCustomTypeModel({
|
|
161
|
+
customTypeID: data.id,
|
|
162
|
+
...context
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
hook("custom-type:asset:update", async (data, context) => {
|
|
166
|
+
await writeCustomTypeFile({
|
|
167
|
+
customTypeID: data.customTypeID,
|
|
168
|
+
filename: data.asset.id,
|
|
169
|
+
contents: data.asset.data,
|
|
170
|
+
...context
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
hook("custom-type:asset:delete", async (data, context) => {
|
|
174
|
+
await deleteCustomTypeFile({
|
|
175
|
+
customTypeID: data.customTypeID,
|
|
176
|
+
filename: data.assetID,
|
|
177
|
+
...context
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
hook("custom-type:asset:read", async (data, context) => {
|
|
181
|
+
const file = await readCustomTypeFile({
|
|
182
|
+
customTypeID: data.customTypeID,
|
|
183
|
+
filename: data.assetID,
|
|
184
|
+
...context
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
data: file
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
hook("custom-type-library:read", async (_data, context) => {
|
|
191
|
+
return await readCustomTypeLibrary({
|
|
192
|
+
helpers: context.helpers
|
|
193
|
+
});
|
|
194
|
+
});
|
|
53
195
|
hook("snippet:read", snippetRead);
|
|
54
196
|
hook("documentation:read", documentationRead);
|
|
55
197
|
hook("slice-simulator:setup:read", sliceSimulatorSetupRead);
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { projectInit } from \"./hooks/project-init\";\nimport { customTypeAssetDelete } from \"./hooks/customType-asset-delete\";\nimport { customTypeAssetRead } from \"./hooks/customType-asset-read\";\nimport { customTypeAssetUpdate } from \"./hooks/customType-asset-update\";\nimport { customTypeCreate } from \"./hooks/customType-create\";\nimport { customTypeDelete } from \"./hooks/customType-delete\";\nimport { customTypeLibraryRead } from \"./hooks/customTypeLibrary-read\";\nimport { customTypeRead } from \"./hooks/customType-read\";\nimport { customTypeRename } from \"./hooks/customType-rename\";\nimport { customTypeUpdate } from \"./hooks/customType-update\";\nimport { sliceAssetDelete } from \"./hooks/slice-asset-delete\";\nimport { sliceAssetRead } from \"./hooks/slice-asset-read\";\nimport { sliceAssetUpdate } from \"./hooks/slice-asset-update\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceDelete } from \"./hooks/slice-delete\";\nimport { sliceLibraryRead } from \"./hooks/sliceLibrary-read\";\nimport { sliceRead } from \"./hooks/slice-read\";\nimport { sliceRename } from \"./hooks/slice-rename\";\nimport { sliceUpdate } from \"./hooks/slice-update\";\nimport { snippetRead } from \"./hooks/snippet-read\";\nimport { documentationRead } from \"./hooks/documentation-read\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\thook(\"project:init\", projectInit);\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", sliceUpdate);\n\t\thook(\"slice:rename\", sliceRename);\n\t\thook(\"slice:delete\", sliceDelete);\n\t\thook(\"slice:read\", sliceRead);\n\t\thook(\"slice:asset:update\", sliceAssetUpdate);\n\t\thook(\"slice:asset:delete\", sliceAssetDelete);\n\t\thook(\"slice:asset:read\", sliceAssetRead);\n\t\thook(\"slice-library:read\", sliceLibraryRead);\n\n\t\thook(\"custom-type:create\", customTypeCreate);\n\t\thook(\"custom-type:update\", customTypeUpdate);\n\t\thook(\"custom-type:rename\", customTypeRename);\n\t\thook(\"custom-type:delete\", customTypeDelete);\n\t\thook(\"custom-type:read\", customTypeRead);\n\t\thook(\"custom-type:asset:update\", customTypeAssetUpdate);\n\t\thook(\"custom-type:asset:delete\", customTypeAssetDelete);\n\t\thook(\"custom-type:asset:read\", customTypeAssetRead);\n\t\thook(\"custom-type-library:read\", customTypeLibraryRead);\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\thook(\"documentation:read\", documentationRead);\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,SAAS,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL;AAAA,EACA;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAChB;AAAA,EACD,MAAM,EAAE,QAAM;AACb,SAAK,gBAAgB,WAAW;AAEhC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,gBAAgB,WAAW;AAChC,SAAK,cAAc,SAAS;AAC5B,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,sBAAsB,gBAAgB;AAE3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,sBAAsB,gBAAgB;AAC3C,SAAK,oBAAoB,cAAc;AACvC,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,4BAA4B,qBAAqB;AACtD,SAAK,0BAA0B,mBAAmB;AAClD,SAAK,4BAA4B,qBAAqB;AAEtD,SAAK,gBAAgB,WAAW;AAEhC,SAAK,sBAAsB,iBAAiB;AAE5C,SAAK,8BAA8B,uBAAuB;AAAA,EAC3D;AACA,CAAA;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../src/plugin.ts"],"sourcesContent":["import { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\nimport {\n\tdeleteCustomTypeDirectory,\n\tdeleteCustomTypeFile,\n\tdeleteSliceDirectory,\n\tdeleteSliceFile,\n\treadCustomTypeFile,\n\treadCustomTypeLibrary,\n\treadCustomTypeModel,\n\treadSliceFile,\n\treadSliceLibrary,\n\treadSliceModel,\n\trenameCustomType,\n\trenameSlice,\n\tupsertGlobalTypeScriptTypes,\n\twriteCustomTypeFile,\n\twriteCustomTypeModel,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { rejectIfNecessary } from \"./lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"./lib/upsertSliceLibraryIndexFile\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\n\nimport { documentationRead } from \"./hooks/documentation-read\";\nimport { projectInit } from \"./hooks/project-init\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { sliceSimulatorSetupRead } from \"./hooks/sliceSimulator-setup-read\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\t////////////////////////////////////////////////////////////////\n\t\t// project:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"project:init\", projectInit);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", async (data, context) => {\n\t\t\tawait writeSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:rename\", async (data, context) => {\n\t\t\tawait renameSlice({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:delete\", async (data, context) => {\n\t\t\tawait deleteSliceDirectory({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:read\", async (data, context) => {\n\t\t\treturn await readSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:update\", async (data, context) => {\n\t\t\tawait writeSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:delete\", async (data, context) => {\n\t\t\tawait deleteSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:read\", async (data, context) => {\n\t\t\tconst file = await readSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-library:read\", async (data, context) => {\n\t\t\treturn await readSliceLibrary({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type:create\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:rename\", async (data, context) => {\n\t\t\tawait renameCustomType({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeDirectory({\n\t\t\t\tcustomTypeID: data.model.id,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:read\", async (data, context) => {\n\t\t\treturn await readCustomTypeModel({\n\t\t\t\tcustomTypeID: data.id,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:read\", async (data, context) => {\n\t\t\tconst file = await readCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type-library:read\", async (_data, context) => {\n\t\t\treturn await readCustomTypeLibrary({\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// snippet:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// documentation:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"documentation:read\", documentationRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-simulator:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-simulator:setup:read\", sliceSimulatorSetupRead);\n\t},\n});\n"],"names":[],"mappings":";;;;;;;;;;AAiCO,MAAM,SAAS,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL;AAAA,EACA;AAAA,EACD,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAChB;AAAA,EACD,MAAM,EAAE,QAAM;AAKb,SAAK,gBAAgB,WAAW;AAMhC,SAAK,gBAAgB,WAAW;AAC3B,SAAA,gBAAgB,OAAO,MAAM,YAAW;AAC5C,YAAM,gBAAgB;AAAA,QACrB,WAAW,KAAK;AAAA,QAChB,OAAO,KAAK;AAAA,QACZ,GAAG;AAAA,MAAA,CACH;AAED,YAAM,4BAA4B;AAAA,QACjC,UAAU,QAAQ,QAAQ;AAAA,QAC1B,QAAQ,QAAQ,QAAQ;AAAA,QACxB,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,gBAAgB,OAAO,MAAM,YAAW;AAC5C,YAAM,YAAY;AAAA,QACjB,WAAW,KAAK;AAAA,QAChB,OAAO,KAAK;AAAA,QACZ,QAAQ,QAAQ,QAAQ;AAAA,QACxB,GAAG;AAAA,MAAA,CACH;AAGA,wBAAA,MAAM,QAAQ,WAAW;AAAA,QACxB,4BAA4B;AAAA,UAC3B,WAAW,KAAK;AAAA,UAChB,GAAG;AAAA,QAAA,CACH;AAAA,QACD,4BAA4B;AAAA,UAC3B,UAAU,QAAQ,QAAQ;AAAA,UAC1B,QAAQ,QAAQ,QAAQ;AAAA,UACxB,GAAG;AAAA,QAAA,CACH;AAAA,MACD,CAAA,CAAC;AAAA,IAAA,CAEH;AACI,SAAA,gBAAgB,OAAO,MAAM,YAAW;AAC5C,YAAM,qBAAqB;AAAA,QAC1B,WAAW,KAAK;AAAA,QAChB,OAAO,KAAK;AAAA,QACZ,GAAG;AAAA,MAAA,CACH;AAGA,wBAAA,MAAM,QAAQ,WAAW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MAAM,YAAW;AACxD,YAAM,oBAAoB;AAAA,QACzB,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK,MAAM;AAAA,QACrB,UAAU,KAAK,MAAM;AAAA,QACrB,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,4BAA4B,OAAO,MAAM,YAAW;AACxD,YAAM,qBAAqB;AAAA,QAC1B,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAAA,IAAA,CACD;AACI,SAAA,0BAA0B,OAAO,MAAM,YAAW;AAChD,YAAA,OAAO,MAAM,mBAAmB;AAAA,QACrC,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAEM,aAAA;AAAA,QACN,MAAM;AAAA,MAAA;AAAA,KAEP;AAMI,SAAA,4BAA4B,OAAO,OAAO,YAAW;AACzD,aAAO,MAAM,sBAAsB;AAAA,QAClC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAAA,IAAA,CACD;AAMD,SAAK,gBAAgB,WAAW;AAMhC,SAAK,sBAAsB,iBAAiB;AAM5C,SAAK,8BAA8B,uBAAuB;AAAA,EAC3D;AACA,CAAA;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slicemachine/adapter-next",
|
|
3
|
-
"version": "0.3.10-dev-next-release.
|
|
3
|
+
"version": "0.3.10-dev-next-release.11",
|
|
4
4
|
"description": "Slice Machine adapter for Next.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -61,23 +61,21 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@prismicio/simulator": "^0.1.4",
|
|
63
63
|
"@prismicio/types-internal": "^2.0.0",
|
|
64
|
-
"@slicemachine/plugin-kit": "^0.4.10-dev-next-release.
|
|
64
|
+
"@slicemachine/plugin-kit": "^0.4.10-dev-next-release.11",
|
|
65
65
|
"common-tags": "^1.8.2",
|
|
66
66
|
"fp-ts": "^2.13.1",
|
|
67
|
-
"fs-extra": "^11.1.0",
|
|
68
67
|
"io-ts": "^2.2.20",
|
|
69
68
|
"io-ts-types": "^0.5.19",
|
|
70
69
|
"monocle-ts": "^2.3.13",
|
|
71
70
|
"newtype-ts": "^0.3.5",
|
|
72
71
|
"node-fetch": "^3.3.1",
|
|
73
72
|
"pascal-case": "^3.1.2",
|
|
74
|
-
"prismic-ts-codegen": "^0.1.
|
|
73
|
+
"prismic-ts-codegen": "^0.1.16"
|
|
75
74
|
},
|
|
76
75
|
"devDependencies": {
|
|
77
76
|
"@prismicio/mock": "0.2.0",
|
|
78
77
|
"@size-limit/preset-small-lib": "8.2.4",
|
|
79
78
|
"@types/common-tags": "1.8.1",
|
|
80
|
-
"@types/fs-extra": "11.0.1",
|
|
81
79
|
"@types/prettier": "2.7.2",
|
|
82
80
|
"@types/react": "18.0.28",
|
|
83
81
|
"@typescript-eslint/eslint-plugin": "5.55.0",
|
|
@@ -106,5 +104,5 @@
|
|
|
106
104
|
"engines": {
|
|
107
105
|
"node": ">=14.15.0"
|
|
108
106
|
},
|
|
109
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "c37766e0280275919f992e52b149643db059952c"
|
|
110
108
|
}
|
|
@@ -2,10 +2,11 @@ import { stripIndent, source } from "common-tags";
|
|
|
2
2
|
|
|
3
3
|
import type { DocumentationReadHook } from "@slicemachine/plugin-kit";
|
|
4
4
|
|
|
5
|
-
import type { PluginOptions } from "../types";
|
|
6
5
|
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
|
|
7
6
|
import { getJSFileExtension } from "../lib/getJSFileExtension";
|
|
8
7
|
|
|
8
|
+
import type { PluginOptions } from "../types";
|
|
9
|
+
|
|
9
10
|
export const documentationRead: DocumentationReadHook<PluginOptions> = async (
|
|
10
11
|
data,
|
|
11
12
|
{ options, helpers },
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import * as fs from "node:fs/promises";
|
|
2
1
|
import * as path from "node:path";
|
|
3
2
|
import type {
|
|
4
3
|
ProjectInitHook,
|
|
5
4
|
ProjectInitHookData,
|
|
6
5
|
SliceMachineContext,
|
|
7
6
|
} from "@slicemachine/plugin-kit";
|
|
7
|
+
import {
|
|
8
|
+
checkHasProjectFile,
|
|
9
|
+
writeProjectFile,
|
|
10
|
+
} from "@slicemachine/plugin-kit/fs";
|
|
8
11
|
import { source } from "common-tags";
|
|
9
12
|
|
|
10
13
|
import { checkHasAppRouter } from "../lib/checkHasAppRouter";
|
|
11
14
|
import { checkHasSrcDirectory } from "../lib/checkHasSrcDirectory";
|
|
12
15
|
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject";
|
|
13
|
-
import { checkPathExists } from "../lib/checkPathExists";
|
|
14
16
|
import { getJSFileExtension } from "../lib/getJSFileExtension";
|
|
15
17
|
import { rejectIfNecessary } from "../lib/rejectIfNecessary";
|
|
16
18
|
|
|
@@ -46,12 +48,13 @@ const createPrismicIOFile = async ({
|
|
|
46
48
|
const hasAppRouter = await checkHasAppRouter({ helpers });
|
|
47
49
|
|
|
48
50
|
const extension = await getJSFileExtension({ helpers, options });
|
|
49
|
-
const filename =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const filename = path.join(
|
|
52
|
+
...[hasSrcDirectory ? "src" : undefined, `prismicio.${extension}`].filter(
|
|
53
|
+
(segment): segment is NonNullable<typeof segment> => Boolean(segment),
|
|
54
|
+
),
|
|
55
|
+
);
|
|
53
56
|
|
|
54
|
-
if (await
|
|
57
|
+
if (await checkHasProjectFile({ filename, helpers })) {
|
|
55
58
|
return;
|
|
56
59
|
}
|
|
57
60
|
|
|
@@ -229,11 +232,12 @@ const createPrismicIOFile = async ({
|
|
|
229
232
|
`;
|
|
230
233
|
}
|
|
231
234
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
await writeProjectFile({
|
|
236
|
+
filename,
|
|
237
|
+
contents,
|
|
238
|
+
format: options.format,
|
|
239
|
+
helpers,
|
|
240
|
+
});
|
|
237
241
|
};
|
|
238
242
|
|
|
239
243
|
type CreateSliceSimulatorPageArgs = SliceMachineContext<PluginOptions>;
|
|
@@ -246,7 +250,7 @@ const createSliceSimulatorPage = async ({
|
|
|
246
250
|
const hasAppRouter = await checkHasAppRouter({ helpers });
|
|
247
251
|
|
|
248
252
|
const extension = await getJSFileExtension({ helpers, options, jsx: true });
|
|
249
|
-
const
|
|
253
|
+
const filename = path.join(
|
|
250
254
|
...[
|
|
251
255
|
hasSrcDirectory ? "src" : undefined,
|
|
252
256
|
hasAppRouter
|
|
@@ -257,13 +261,11 @@ const createSliceSimulatorPage = async ({
|
|
|
257
261
|
),
|
|
258
262
|
);
|
|
259
263
|
|
|
260
|
-
if (await
|
|
264
|
+
if (await checkHasProjectFile({ filename, helpers })) {
|
|
261
265
|
return;
|
|
262
266
|
}
|
|
263
267
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
let contents = source`
|
|
268
|
+
const contents = source`
|
|
267
269
|
"use client"
|
|
268
270
|
|
|
269
271
|
import { SliceSimulator } from "@slicemachine/adapter-next/simulator";
|
|
@@ -280,11 +282,12 @@ const createSliceSimulatorPage = async ({
|
|
|
280
282
|
}
|
|
281
283
|
`;
|
|
282
284
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
285
|
+
await writeProjectFile({
|
|
286
|
+
filename,
|
|
287
|
+
contents,
|
|
288
|
+
format: options.format,
|
|
289
|
+
helpers,
|
|
290
|
+
});
|
|
288
291
|
};
|
|
289
292
|
|
|
290
293
|
const createPreviewRoute = async ({
|
|
@@ -299,7 +302,7 @@ const createPreviewRoute = async ({
|
|
|
299
302
|
});
|
|
300
303
|
|
|
301
304
|
const extension = await getJSFileExtension({ helpers, options });
|
|
302
|
-
const
|
|
305
|
+
const filename = path.join(
|
|
303
306
|
...[
|
|
304
307
|
hasSrcDirectory ? "src" : undefined,
|
|
305
308
|
hasAppRouter
|
|
@@ -310,7 +313,7 @@ const createPreviewRoute = async ({
|
|
|
310
313
|
),
|
|
311
314
|
);
|
|
312
315
|
|
|
313
|
-
if (await
|
|
316
|
+
if (await checkHasProjectFile({ filename, helpers })) {
|
|
314
317
|
return;
|
|
315
318
|
}
|
|
316
319
|
|
|
@@ -376,12 +379,12 @@ const createPreviewRoute = async ({
|
|
|
376
379
|
}
|
|
377
380
|
}
|
|
378
381
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
382
|
+
await writeProjectFile({
|
|
383
|
+
filename,
|
|
384
|
+
contents,
|
|
385
|
+
format: options.format,
|
|
386
|
+
helpers,
|
|
387
|
+
});
|
|
385
388
|
};
|
|
386
389
|
|
|
387
390
|
const createExitPreviewRoute = async ({
|
|
@@ -396,7 +399,7 @@ const createExitPreviewRoute = async ({
|
|
|
396
399
|
});
|
|
397
400
|
|
|
398
401
|
const extension = await getJSFileExtension({ helpers, options });
|
|
399
|
-
const
|
|
402
|
+
const filename = path.join(
|
|
400
403
|
...[
|
|
401
404
|
hasSrcDirectory ? "src" : undefined,
|
|
402
405
|
hasAppRouter
|
|
@@ -407,14 +410,14 @@ const createExitPreviewRoute = async ({
|
|
|
407
410
|
),
|
|
408
411
|
);
|
|
409
412
|
|
|
410
|
-
if (await
|
|
413
|
+
if (await checkHasProjectFile({ filename, helpers })) {
|
|
411
414
|
return;
|
|
412
415
|
}
|
|
413
416
|
|
|
414
417
|
let contents: string;
|
|
415
418
|
|
|
416
419
|
if (hasAppRouter) {
|
|
417
|
-
contents = `
|
|
420
|
+
contents = source`
|
|
418
421
|
import { exitPreview } from "@prismicio/next";
|
|
419
422
|
|
|
420
423
|
export async function GET() {
|
|
@@ -442,17 +445,18 @@ const createExitPreviewRoute = async ({
|
|
|
442
445
|
}
|
|
443
446
|
}
|
|
444
447
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
448
|
+
await writeProjectFile({
|
|
449
|
+
filename,
|
|
450
|
+
contents,
|
|
451
|
+
format: options.format,
|
|
452
|
+
helpers,
|
|
453
|
+
});
|
|
451
454
|
};
|
|
452
455
|
|
|
453
456
|
const modifySliceMachineConfig = async ({
|
|
454
457
|
helpers,
|
|
455
458
|
options,
|
|
459
|
+
actions,
|
|
456
460
|
}: SliceMachineContext<PluginOptions>) => {
|
|
457
461
|
const hasSrcDirectory = await checkHasSrcDirectory({ helpers });
|
|
458
462
|
const project = await helpers.getProject();
|
|
@@ -465,24 +469,15 @@ const modifySliceMachineConfig = async ({
|
|
|
465
469
|
// is empty.
|
|
466
470
|
if (
|
|
467
471
|
hasSrcDirectory &&
|
|
472
|
+
project.config.libraries &&
|
|
468
473
|
JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"])
|
|
469
474
|
) {
|
|
470
|
-
|
|
471
|
-
|
|
475
|
+
const sliceLibrary = await actions.readSliceLibrary({
|
|
476
|
+
libraryID: project.config.libraries[0],
|
|
477
|
+
});
|
|
472
478
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
} catch (error) {
|
|
477
|
-
if (
|
|
478
|
-
error instanceof Error &&
|
|
479
|
-
"code" in error &&
|
|
480
|
-
error.code === "ENOENT"
|
|
481
|
-
) {
|
|
482
|
-
// The directory does not exist, which means we
|
|
483
|
-
// can safely nest the library.
|
|
484
|
-
project.config.libraries = ["./src/slices"];
|
|
485
|
-
}
|
|
479
|
+
if (sliceLibrary.sliceIDs.length < 1) {
|
|
480
|
+
project.config.libraries = ["./src/slices"];
|
|
486
481
|
}
|
|
487
482
|
}
|
|
488
483
|
|
|
@@ -504,7 +499,7 @@ const createRevalidateRoute = async ({
|
|
|
504
499
|
const hasSrcDirectory = await checkHasSrcDirectory({ helpers });
|
|
505
500
|
|
|
506
501
|
const extension = await getJSFileExtension({ helpers, options });
|
|
507
|
-
const
|
|
502
|
+
const filename = path.join(
|
|
508
503
|
...[
|
|
509
504
|
hasSrcDirectory ? "src" : undefined,
|
|
510
505
|
`app/api/revalidate/route.${extension}`,
|
|
@@ -513,11 +508,11 @@ const createRevalidateRoute = async ({
|
|
|
513
508
|
),
|
|
514
509
|
);
|
|
515
510
|
|
|
516
|
-
if (await
|
|
511
|
+
if (await checkHasProjectFile({ filename, helpers })) {
|
|
517
512
|
return;
|
|
518
513
|
}
|
|
519
514
|
|
|
520
|
-
|
|
515
|
+
const contents = source`
|
|
521
516
|
import { NextResponse } from "next/server";
|
|
522
517
|
import { revalidateTag } from "next/cache";
|
|
523
518
|
|
|
@@ -528,12 +523,12 @@ const createRevalidateRoute = async ({
|
|
|
528
523
|
}
|
|
529
524
|
`;
|
|
530
525
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
526
|
+
await writeProjectFile({
|
|
527
|
+
filename,
|
|
528
|
+
contents,
|
|
529
|
+
format: options.format,
|
|
530
|
+
helpers,
|
|
531
|
+
});
|
|
537
532
|
};
|
|
538
533
|
|
|
539
534
|
export const projectInit: ProjectInitHook<PluginOptions> = async (
|