@prismicio/plugin-kit 0.0.1
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/_node_modules/lower-case/dist.es2015/index.js +7 -0
- package/dist/_node_modules/lower-case/dist.es2015/index.js.map +1 -0
- package/dist/_node_modules/no-case/dist.es2015/index.js +28 -0
- package/dist/_node_modules/no-case/dist.es2015/index.js.map +1 -0
- package/dist/_node_modules/p-limit/_node_modules/yocto-queue/index.js +68 -0
- package/dist/_node_modules/p-limit/_node_modules/yocto-queue/index.js.map +1 -0
- package/dist/_node_modules/p-limit/index.js +77 -0
- package/dist/_node_modules/p-limit/index.js.map +1 -0
- package/dist/_node_modules/pascal-case/dist.es2015/index.js +25 -0
- package/dist/_node_modules/pascal-case/dist.es2015/index.js.map +1 -0
- package/dist/_node_modules/tslib/tslib.es6.js +14 -0
- package/dist/_node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/createPluginHookSystem.d.ts +6 -0
- package/dist/createPluginHookSystem.js +8 -0
- package/dist/createPluginHookSystem.js.map +1 -0
- package/dist/createPluginSystemActions.d.ts +46 -0
- package/dist/createPluginSystemActions.js +96 -0
- package/dist/createPluginSystemActions.js.map +1 -0
- package/dist/createPluginSystemContext.d.ts +31 -0
- package/dist/createPluginSystemContext.js +12 -0
- package/dist/createPluginSystemContext.js.map +1 -0
- package/dist/createPluginSystemHelpers.d.ts +37 -0
- package/dist/createPluginSystemHelpers.js +72 -0
- package/dist/createPluginSystemHelpers.js.map +1 -0
- package/dist/createPluginSystemRunner.d.ts +58 -0
- package/dist/createPluginSystemRunner.js +128 -0
- package/dist/createPluginSystemRunner.js.map +1 -0
- package/dist/definePlugin.d.ts +30 -0
- package/dist/definePlugin.js +5 -0
- package/dist/definePlugin.js.map +1 -0
- package/dist/fs/buildCustomTypeDirectoryPath.d.ts +5 -0
- package/dist/fs/buildCustomTypeDirectoryPath.js +9 -0
- package/dist/fs/buildCustomTypeDirectoryPath.js.map +1 -0
- package/dist/fs/buildCustomTypeFilePath.d.ts +5 -0
- package/dist/fs/buildCustomTypeFilePath.js +9 -0
- package/dist/fs/buildCustomTypeFilePath.js.map +1 -0
- package/dist/fs/buildCustomTypeLibraryDirectoryPath.d.ts +6 -0
- package/dist/fs/buildCustomTypeLibraryDirectoryPath.js +8 -0
- package/dist/fs/buildCustomTypeLibraryDirectoryPath.js.map +1 -0
- package/dist/fs/buildSliceDirectoryPath.d.ts +4 -0
- package/dist/fs/buildSliceDirectoryPath.js +12 -0
- package/dist/fs/buildSliceDirectoryPath.js.map +1 -0
- package/dist/fs/buildSliceFilePath.d.ts +5 -0
- package/dist/fs/buildSliceFilePath.js +9 -0
- package/dist/fs/buildSliceFilePath.js.map +1 -0
- package/dist/fs/buildSliceLibraryDirectoryPath.d.ts +7 -0
- package/dist/fs/buildSliceLibraryDirectoryPath.js +8 -0
- package/dist/fs/buildSliceLibraryDirectoryPath.js.map +1 -0
- package/dist/fs/checkHasProjectFile.d.ts +6 -0
- package/dist/fs/checkHasProjectFile.js +9 -0
- package/dist/fs/checkHasProjectFile.js.map +1 -0
- package/dist/fs/checkIsTypeScriptProject.d.ts +4 -0
- package/dist/fs/checkIsTypeScriptProject.js +12 -0
- package/dist/fs/checkIsTypeScriptProject.js.map +1 -0
- package/dist/fs/constants.d.ts +9 -0
- package/dist/fs/constants.js +15 -0
- package/dist/fs/constants.js.map +1 -0
- package/dist/fs/deleteCustomTypeDirectory.d.ts +3 -0
- package/dist/fs/deleteCustomTypeDirectory.js +18 -0
- package/dist/fs/deleteCustomTypeDirectory.js.map +1 -0
- package/dist/fs/deleteProjectFile.d.ts +6 -0
- package/dist/fs/deleteProjectFile.js +10 -0
- package/dist/fs/deleteProjectFile.js.map +1 -0
- package/dist/fs/deleteSliceDirectory.d.ts +3 -0
- package/dist/fs/deleteSliceDirectory.js +18 -0
- package/dist/fs/deleteSliceDirectory.js.map +1 -0
- package/dist/fs/deleteSliceFile.d.ts +3 -0
- package/dist/fs/deleteSliceFile.js +18 -0
- package/dist/fs/deleteSliceFile.js.map +1 -0
- package/dist/fs/index.d.ts +49 -0
- package/dist/fs/index.js +53 -0
- package/dist/fs/index.js.map +1 -0
- package/dist/fs/lib/checkPathExists.d.ts +2 -0
- package/dist/fs/lib/checkPathExists.js +13 -0
- package/dist/fs/lib/checkPathExists.js.map +1 -0
- package/dist/fs/lib/fsLimit.d.ts +31 -0
- package/dist/fs/lib/fsLimit.js +23 -0
- package/dist/fs/lib/fsLimit.js.map +1 -0
- package/dist/fs/lib/isCustomTypeModel.d.ts +2 -0
- package/dist/fs/lib/isCustomTypeModel.js +7 -0
- package/dist/fs/lib/isCustomTypeModel.js.map +1 -0
- package/dist/fs/lib/isSharedSliceModel.d.ts +2 -0
- package/dist/fs/lib/isSharedSliceModel.js +7 -0
- package/dist/fs/lib/isSharedSliceModel.js.map +1 -0
- package/dist/fs/lib/pascalCase.d.ts +8 -0
- package/dist/fs/lib/pascalCase.js +10 -0
- package/dist/fs/lib/pascalCase.js.map +1 -0
- package/dist/fs/lib/readJSONFile.d.ts +1 -0
- package/dist/fs/lib/readJSONFile.js +9 -0
- package/dist/fs/lib/readJSONFile.js.map +1 -0
- package/dist/fs/lib/resolveSliceModel.d.ts +10 -0
- package/dist/fs/lib/resolveSliceModel.js +14 -0
- package/dist/fs/lib/resolveSliceModel.js.map +1 -0
- package/dist/fs/readCustomTypeFile.d.ts +8 -0
- package/dist/fs/readCustomTypeFile.js +14 -0
- package/dist/fs/readCustomTypeFile.js.map +1 -0
- package/dist/fs/readCustomTypeLibrary.d.ts +6 -0
- package/dist/fs/readCustomTypeLibrary.js +53 -0
- package/dist/fs/readCustomTypeLibrary.js.map +1 -0
- package/dist/fs/readCustomTypeModel.d.ts +7 -0
- package/dist/fs/readCustomTypeModel.js +16 -0
- package/dist/fs/readCustomTypeModel.js.map +1 -0
- package/dist/fs/readProjectFile.d.ts +12 -0
- package/dist/fs/readProjectFile.js +9 -0
- package/dist/fs/readProjectFile.js.map +1 -0
- package/dist/fs/readSliceFile.d.ts +8 -0
- package/dist/fs/readSliceFile.js +17 -0
- package/dist/fs/readSliceFile.js.map +1 -0
- package/dist/fs/readSliceLibrary.d.ts +7 -0
- package/dist/fs/readSliceLibrary.js +56 -0
- package/dist/fs/readSliceLibrary.js.map +1 -0
- package/dist/fs/readSliceModel.d.ts +11 -0
- package/dist/fs/readSliceModel.js +46 -0
- package/dist/fs/readSliceModel.js.map +1 -0
- package/dist/fs/renameCustomType.d.ts +3 -0
- package/dist/fs/renameCustomType.js +8 -0
- package/dist/fs/renameCustomType.js.map +1 -0
- package/dist/fs/renameSlice.d.ts +7 -0
- package/dist/fs/renameSlice.js +22 -0
- package/dist/fs/renameSlice.js.map +1 -0
- package/dist/fs/types.d.ts +3 -0
- package/dist/fs/upsertGlobalTypeScriptTypes.d.ts +16 -0
- package/dist/fs/upsertGlobalTypeScriptTypes.js +37 -0
- package/dist/fs/upsertGlobalTypeScriptTypes.js.map +1 -0
- package/dist/fs/writeCustomTypeFile.d.ts +9 -0
- package/dist/fs/writeCustomTypeFile.js +18 -0
- package/dist/fs/writeCustomTypeFile.js.map +1 -0
- package/dist/fs/writeCustomTypeModel.d.ts +12 -0
- package/dist/fs/writeCustomTypeModel.js +14 -0
- package/dist/fs/writeCustomTypeModel.js.map +1 -0
- package/dist/fs/writeProjectFile.d.ts +15 -0
- package/dist/fs/writeProjectFile.js +16 -0
- package/dist/fs/writeProjectFile.js.map +1 -0
- package/dist/fs/writeSliceFile.d.ts +9 -0
- package/dist/fs/writeSliceFile.js +18 -0
- package/dist/fs/writeSliceFile.js.map +1 -0
- package/dist/fs/writeSliceModel.d.ts +11 -0
- package/dist/fs/writeSliceModel.js +13 -0
- package/dist/fs/writeSliceModel.js.map +1 -0
- package/dist/hooks/customType-create.d.ts +28 -0
- package/dist/hooks/customType-delete.d.ts +26 -0
- package/dist/hooks/customType-read.d.ts +32 -0
- package/dist/hooks/customType-rename.d.ts +29 -0
- package/dist/hooks/customType-update.d.ts +29 -0
- package/dist/hooks/customTypeLibrary-read.d.ts +25 -0
- package/dist/hooks/debug.d.ts +22 -0
- package/dist/hooks/project-init.d.ts +35 -0
- package/dist/hooks/slice-create.d.ts +30 -0
- package/dist/hooks/slice-delete.d.ts +26 -0
- package/dist/hooks/slice-read.d.ts +32 -0
- package/dist/hooks/slice-rename.d.ts +26 -0
- package/dist/hooks/slice-update.d.ts +29 -0
- package/dist/hooks/sliceLibrary-read.d.ts +27 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/DecodeError.d.ts +13 -0
- package/dist/lib/DecodeError.js +21 -0
- package/dist/lib/DecodeError.js.map +1 -0
- package/dist/lib/HookSystem.d.ts +93 -0
- package/dist/lib/HookSystem.js +121 -0
- package/dist/lib/HookSystem.js.map +1 -0
- package/dist/lib/decode.d.ts +10 -0
- package/dist/lib/decode.js +16 -0
- package/dist/lib/decode.js.map +1 -0
- package/dist/lib/decodePrismicConfig.d.ts +3 -0
- package/dist/lib/decodePrismicConfig.js +22 -0
- package/dist/lib/decodePrismicConfig.js.map +1 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -0
- package/package.json +90 -0
- package/src/createPluginHookSystem.ts +9 -0
- package/src/createPluginSystemActions.ts +188 -0
- package/src/createPluginSystemContext.ts +51 -0
- package/src/createPluginSystemHelpers.ts +129 -0
- package/src/createPluginSystemRunner.ts +216 -0
- package/src/definePlugin.ts +48 -0
- package/src/fs/buildCustomTypeDirectoryPath.ts +19 -0
- package/src/fs/buildCustomTypeFilePath.ts +16 -0
- package/src/fs/buildCustomTypeLibraryDirectoryPath.ts +16 -0
- package/src/fs/buildSliceDirectoryPath.ts +25 -0
- package/src/fs/buildSliceFilePath.ts +16 -0
- package/src/fs/buildSliceLibraryDirectoryPath.ts +17 -0
- package/src/fs/checkHasProjectFile.ts +16 -0
- package/src/fs/checkIsTypeScriptProject.ts +16 -0
- package/src/fs/constants.ts +15 -0
- package/src/fs/deleteCustomTypeDirectory.ts +24 -0
- package/src/fs/deleteProjectFile.ts +18 -0
- package/src/fs/deleteSliceDirectory.ts +24 -0
- package/src/fs/deleteSliceFile.ts +24 -0
- package/src/fs/index.ts +103 -0
- package/src/fs/lib/checkPathExists.ts +13 -0
- package/src/fs/lib/fsLimit.ts +72 -0
- package/src/fs/lib/isCustomTypeModel.ts +7 -0
- package/src/fs/lib/isSharedSliceModel.ts +14 -0
- package/src/fs/lib/pascalCase.ts +17 -0
- package/src/fs/lib/readJSONFile.ts +7 -0
- package/src/fs/lib/resolveSliceModel.ts +28 -0
- package/src/fs/readCustomTypeFile.ts +27 -0
- package/src/fs/readCustomTypeLibrary.ts +86 -0
- package/src/fs/readCustomTypeModel.ts +27 -0
- package/src/fs/readProjectFile.ts +24 -0
- package/src/fs/readSliceFile.ts +27 -0
- package/src/fs/readSliceLibrary.ts +91 -0
- package/src/fs/readSliceModel.ts +90 -0
- package/src/fs/renameCustomType.ts +12 -0
- package/src/fs/renameSlice.ts +35 -0
- package/src/fs/types.ts +5 -0
- package/src/fs/upsertGlobalTypeScriptTypes.ts +64 -0
- package/src/fs/writeCustomTypeFile.ts +30 -0
- package/src/fs/writeCustomTypeModel.ts +31 -0
- package/src/fs/writeProjectFile.ts +39 -0
- package/src/fs/writeSliceFile.ts +30 -0
- package/src/fs/writeSliceModel.ts +26 -0
- package/src/hooks/customType-create.ts +42 -0
- package/src/hooks/customType-delete.ts +40 -0
- package/src/hooks/customType-read.ts +46 -0
- package/src/hooks/customType-rename.ts +43 -0
- package/src/hooks/customType-update.ts +43 -0
- package/src/hooks/customTypeLibrary-read.ts +38 -0
- package/src/hooks/debug.ts +31 -0
- package/src/hooks/project-init.ts +48 -0
- package/src/hooks/slice-create.ts +44 -0
- package/src/hooks/slice-delete.ts +40 -0
- package/src/hooks/slice-read.ts +44 -0
- package/src/hooks/slice-rename.ts +40 -0
- package/src/hooks/slice-update.ts +43 -0
- package/src/hooks/sliceLibrary-read.ts +41 -0
- package/src/index.ts +141 -0
- package/src/lib/DecodeError.ts +31 -0
- package/src/lib/HookSystem.ts +277 -0
- package/src/lib/decode.ts +30 -0
- package/src/lib/decodePrismicConfig.ts +26 -0
- package/src/types.ts +175 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPluginSystemHelpers.js","sources":["../../src/createPluginSystemHelpers.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { stripIndent } from \"common-tags\";\nimport * as prettier from \"prettier\";\n\nimport { decodePrismicConfig } from \"./lib/decodePrismicConfig\";\nimport { PrismicConfig, PrismicProject } from \"./types\";\n\ntype UpdatePrismicConfigOptions = {\n\tformat?: boolean;\n};\n\ntype FormatOptions = {\n\tprettier?: prettier.Options;\n\t/**\n\t * Determines if a newline is included at the end of the formatted result.\n\t *\n\t * @defaultValue `true`\n\t */\n\tincludeNewlineAtEnd?: boolean;\n};\n\n/**\n * Creates Plugin System helpers.\n *\n * @internal\n */\nexport const createPluginSystemHelpers = (\n\tproject: PrismicProject,\n): PluginSystemHelpers => {\n\treturn new PluginSystemHelpers(project);\n};\n\n/**\n * Plugin System helpers shared to plugins and hooks.\n */\nexport class PluginSystemHelpers {\n\t/**\n\t * Project's metadata.\n\t *\n\t * @internal\n\t */\n\tprivate _project: PrismicProject;\n\n\tconstructor(project: PrismicProject) {\n\t\tthis._project = project;\n\t}\n\n\tgetProject = async (): Promise<PrismicProject> => {\n\t\tconst configFilePath = this.joinPathFromRoot(\"prismic.config.json\");\n\n\t\tlet rawConfig: unknown | undefined;\n\t\ttry {\n\t\t\tconst contents = await fs.readFile(configFilePath, \"utf8\");\n\t\t\trawConfig = JSON.parse(contents);\n\t\t} catch {\n\t\t\t// noop\n\t\t}\n\n\t\tif (!rawConfig) {\n\t\t\tthrow new Error(\n\t\t\t\t\"No Prismic config found, please initialize your project with first.\",\n\t\t\t);\n\t\t}\n\n\t\tconst { value: prismicConfig, error } = decodePrismicConfig(rawConfig);\n\n\t\tif (error) {\n\t\t\tthrow new Error(`Invalid Prismic config. ${error.errors.join(\", \")}`);\n\t\t}\n\n\t\treturn {\n\t\t\t...this._project,\n\t\t\tconfig: prismicConfig,\n\t\t};\n\t};\n\n\tupdatePrismicConfig = async (\n\t\tprismicConfig: PrismicConfig,\n\t\toptions?: UpdatePrismicConfigOptions,\n\t): Promise<void> => {\n\t\tconst { value: decodedPrismicConfig, error } =\n\t\t\tdecodePrismicConfig(prismicConfig);\n\n\t\tif (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid Prismic config provided. ${error.errors.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\tconst configFilePath = this.joinPathFromRoot(\"prismic.config.json\");\n\t\tlet content = JSON.stringify(decodedPrismicConfig, null, 2);\n\n\t\tif (options?.format) {\n\t\t\tcontent = await this.format(content, configFilePath);\n\t\t}\n\n\t\tawait fs.writeFile(configFilePath, content);\n\t};\n\n\tformat = async (\n\t\tsource: string,\n\t\tfilePath?: string,\n\t\toptions?: FormatOptions,\n\t): Promise<string> => {\n\t\tlet formatted = stripIndent(source);\n\n\t\tconst prettierOptions = await prettier.resolveConfig(\n\t\t\tfilePath || this._project.root,\n\t\t);\n\n\t\tformatted = await prettier.format(formatted, {\n\t\t\t...prettierOptions,\n\t\t\tfilepath: filePath,\n\t\t\t...(options?.prettier ?? {}),\n\t\t});\n\n\t\tif (options?.includeNewlineAtEnd === false) {\n\t\t\tformatted = formatted.replace(/[\\r\\n]+$/, \"\");\n\t\t}\n\n\t\treturn formatted;\n\t};\n\n\tjoinPathFromRoot = (...paths: string[]): string => {\n\t\treturn path.join(this._project.root, ...paths);\n\t};\n}\n"],"names":[],"mappings":";;;;;AA4BO,MAAM,4BAA4B,CACxC,YACwB;AACxB,SAAO,IAAI,oBAAoB,OAAO;AACvC;MAKa,oBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvB;AAAA,EAER,YAAY,SAAuB;AAClC,SAAK,WAAW;AAAA,EACjB;AAAA,EAEA,aAAa,YAAoC;AAChD,UAAM,iBAAiB,KAAK,iBAAiB,qBAAqB;AAElE,QAAI;AACJ,QAAI;AACH,YAAM,WAAW,MAAM,GAAG,SAAS,gBAAgB,MAAM;AACzD,kBAAY,KAAK,MAAM,QAAQ;AAAA,IAChC,QAAQ;AAAA,IAER;AAEA,QAAI,CAAC,WAAW;AACf,YAAM,IAAI,MACT,qEAAqE;AAAA,IAEvE;AAEA,UAAM,EAAE,OAAO,eAAe,MAAA,IAAU,oBAAoB,SAAS;AAErE,QAAI,OAAO;AACV,YAAM,IAAI,MAAM,2BAA2B,MAAM,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,IACrE;AAEA,WAAO;AAAA,MACN,GAAG,KAAK;AAAA,MACR,QAAQ;AAAA,IAAA;AAAA,EAEV;AAAA,EAEA,sBAAsB,OACrB,eACA,YACkB;AAClB,UAAM,EAAE,OAAO,sBAAsB,MAAA,IACpC,oBAAoB,aAAa;AAElC,QAAI,OAAO;AACV,YAAM,IAAI,MACT,oCAAoC,MAAM,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,IAE/D;AAEA,UAAM,iBAAiB,KAAK,iBAAiB,qBAAqB;AAClE,QAAI,UAAU,KAAK,UAAU,sBAAsB,MAAM,CAAC;AAE1D,QAAI,SAAS,QAAQ;AACpB,gBAAU,MAAM,KAAK,OAAO,SAAS,cAAc;AAAA,IACpD;AAEA,UAAM,GAAG,UAAU,gBAAgB,OAAO;AAAA,EAC3C;AAAA,EAEA,SAAS,OACR,QACA,UACA,YACoB;AACpB,QAAI,YAAY,YAAY,MAAM;AAElC,UAAM,kBAAkB,MAAM,SAAS,cACtC,YAAY,KAAK,SAAS,IAAI;AAG/B,gBAAY,MAAM,SAAS,OAAO,WAAW;AAAA,MAC5C,GAAG;AAAA,MACH,UAAU;AAAA,MACV,GAAI,SAAS,YAAY,CAAA;AAAA,KACzB;AAED,QAAI,SAAS,wBAAwB,OAAO;AAC3C,kBAAY,UAAU,QAAQ,YAAY,EAAE;AAAA,IAC7C;AAEA,WAAO;AAAA,EACR;AAAA,EAEA,mBAAmB,IAAI,UAA2B;AACjD,WAAO,KAAK,KAAK,KAAK,SAAS,MAAM,GAAG,KAAK;AAAA,EAC9C;AACA;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { PluginSystemActions } from "./createPluginSystemActions.js";
|
|
2
|
+
import { PluginSystemHelpers } from "./createPluginSystemHelpers.js";
|
|
3
|
+
import { Plugin } from "./definePlugin.js";
|
|
4
|
+
import { HookSystem } from "./lib/HookSystem.js";
|
|
5
|
+
import { PluginHookTypes, PluginHooks, PrismicProject } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare const REQUIRED_ADAPTER_HOOKS: PluginHookTypes[];
|
|
10
|
+
type PluginSystemRunnerConstructorArgs = {
|
|
11
|
+
project: PrismicProject;
|
|
12
|
+
hookSystem: HookSystem<PluginHooks>;
|
|
13
|
+
nativePlugins: Record<string, Plugin>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare class PluginSystemRunner {
|
|
19
|
+
private _project;
|
|
20
|
+
private _hookSystem;
|
|
21
|
+
private _nativePlugins;
|
|
22
|
+
/**
|
|
23
|
+
* Plugin System actions provided to hooks.
|
|
24
|
+
*
|
|
25
|
+
* IMPORTANT: Prefer creating your own abstraction over using `rawActions`
|
|
26
|
+
* directly to prevent code breakage if this internal API changes.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
rawActions: PluginSystemActions;
|
|
31
|
+
/**
|
|
32
|
+
* Plugin System helpers provided to hooks.
|
|
33
|
+
*
|
|
34
|
+
* IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`
|
|
35
|
+
* directly to prevent code breakage if this internal API changes.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
rawHelpers: PluginSystemHelpers;
|
|
40
|
+
callHook: HookSystem<PluginHooks>["callHook"];
|
|
41
|
+
hooksForOwner: HookSystem<PluginHooks>["hooksForOwner"];
|
|
42
|
+
hooksForType: HookSystem<PluginHooks>["hooksForType"];
|
|
43
|
+
createScope: HookSystem<PluginHooks>["createScope"];
|
|
44
|
+
constructor({ project, hookSystem, nativePlugins, }: PluginSystemRunnerConstructorArgs);
|
|
45
|
+
private _loadPlugin;
|
|
46
|
+
private _setupPlugin;
|
|
47
|
+
private _validateAdapter;
|
|
48
|
+
init(): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
type CreatePluginSystemRunnerArgs = {
|
|
51
|
+
project: PrismicProject;
|
|
52
|
+
nativePlugins: Record<string, Plugin>;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
export declare const createPluginSystemRunner: ({ project, nativePlugins, }: CreatePluginSystemRunnerArgs) => PluginSystemRunner;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { defu } from "defu";
|
|
2
|
+
import { createPluginHookSystem } from "./createPluginHookSystem.js";
|
|
3
|
+
import { createPluginSystemActions } from "./createPluginSystemActions.js";
|
|
4
|
+
import { createPluginSystemContext } from "./createPluginSystemContext.js";
|
|
5
|
+
import { createPluginSystemHelpers } from "./createPluginSystemHelpers.js";
|
|
6
|
+
const REQUIRED_ADAPTER_HOOKS = [
|
|
7
|
+
"slice:create",
|
|
8
|
+
"slice:read",
|
|
9
|
+
"slice:rename",
|
|
10
|
+
"slice:delete",
|
|
11
|
+
"slice:update",
|
|
12
|
+
"slice-library:read",
|
|
13
|
+
"custom-type:create",
|
|
14
|
+
"custom-type:read",
|
|
15
|
+
"custom-type:rename",
|
|
16
|
+
"custom-type:delete",
|
|
17
|
+
"custom-type:update",
|
|
18
|
+
"custom-type-library:read"
|
|
19
|
+
];
|
|
20
|
+
class PluginSystemRunner {
|
|
21
|
+
_project;
|
|
22
|
+
_hookSystem;
|
|
23
|
+
_nativePlugins;
|
|
24
|
+
/**
|
|
25
|
+
* Plugin System actions provided to hooks.
|
|
26
|
+
*
|
|
27
|
+
* IMPORTANT: Prefer creating your own abstraction over using `rawActions`
|
|
28
|
+
* directly to prevent code breakage if this internal API changes.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
rawActions;
|
|
33
|
+
/**
|
|
34
|
+
* Plugin System helpers provided to hooks.
|
|
35
|
+
*
|
|
36
|
+
* IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`
|
|
37
|
+
* directly to prevent code breakage if this internal API changes.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
rawHelpers;
|
|
42
|
+
// Methods forwarded to the plugin runner's hook system.
|
|
43
|
+
callHook;
|
|
44
|
+
hooksForOwner;
|
|
45
|
+
hooksForType;
|
|
46
|
+
createScope;
|
|
47
|
+
constructor({ project, hookSystem, nativePlugins }) {
|
|
48
|
+
this._project = project;
|
|
49
|
+
this._hookSystem = hookSystem;
|
|
50
|
+
this._nativePlugins = nativePlugins;
|
|
51
|
+
this.rawActions = createPluginSystemActions(this._project, this._hookSystem);
|
|
52
|
+
this.rawHelpers = createPluginSystemHelpers(this._project);
|
|
53
|
+
this.callHook = this._hookSystem.callHook.bind(this._hookSystem);
|
|
54
|
+
this.hooksForOwner = this._hookSystem.hooksForOwner.bind(this._hookSystem);
|
|
55
|
+
this.hooksForType = this._hookSystem.hooksForType.bind(this._hookSystem);
|
|
56
|
+
this.createScope = this._hookSystem.createScope.bind(this._hookSystem);
|
|
57
|
+
}
|
|
58
|
+
async _loadPlugin(pluginRegistration) {
|
|
59
|
+
const { resolve, options = {} } = typeof pluginRegistration === "object" && "resolve" in pluginRegistration ? pluginRegistration : { resolve: pluginRegistration };
|
|
60
|
+
let plugin = void 0;
|
|
61
|
+
if (typeof resolve === "string") {
|
|
62
|
+
plugin = this._nativePlugins[resolve];
|
|
63
|
+
if (!plugin) {
|
|
64
|
+
throw new Error(`Could not resolve plugin \`${resolve}\`. Check that it has been installed.`);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
plugin = resolve;
|
|
68
|
+
}
|
|
69
|
+
if (!plugin) {
|
|
70
|
+
throw new Error(`Could not load plugin: \`${resolve}\``);
|
|
71
|
+
}
|
|
72
|
+
const mergedOptions = defu(options, plugin.defaultOptions || {});
|
|
73
|
+
return {
|
|
74
|
+
...plugin,
|
|
75
|
+
resolve,
|
|
76
|
+
options: mergedOptions
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async _setupPlugin(plugin) {
|
|
80
|
+
const context = createPluginSystemContext({
|
|
81
|
+
actions: this.rawActions,
|
|
82
|
+
helpers: this.rawHelpers,
|
|
83
|
+
project: this._project,
|
|
84
|
+
plugin
|
|
85
|
+
});
|
|
86
|
+
const hookSystemScope = this._hookSystem.createScope(plugin.meta.name, [context]);
|
|
87
|
+
try {
|
|
88
|
+
await plugin.setup({
|
|
89
|
+
...context,
|
|
90
|
+
hook: hookSystemScope.hook,
|
|
91
|
+
unhook: hookSystemScope.unhook
|
|
92
|
+
});
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (error instanceof Error) {
|
|
95
|
+
throw new Error(`Plugin \`${plugin.meta.name}\` errored during setup: ${error.message}`, { cause: error });
|
|
96
|
+
} else {
|
|
97
|
+
throw new Error(`Plugin \`${plugin.meta.name}\` errored during setup: ${error}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
_validateAdapter(adapter) {
|
|
102
|
+
const hooks = this._hookSystem.hooksForOwner(adapter.meta.name);
|
|
103
|
+
const hookTypes = hooks.map((hook) => hook.meta.type);
|
|
104
|
+
const missingHooks = REQUIRED_ADAPTER_HOOKS.filter((requiredHookType) => !hookTypes.includes(requiredHookType));
|
|
105
|
+
if (missingHooks.length) {
|
|
106
|
+
throw new Error(`Adapter \`${adapter.meta.name}\` is missing hooks: \`${missingHooks.join("`, `")}\``);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async init() {
|
|
110
|
+
const adapter = await this._loadPlugin(this._project.config.adapter);
|
|
111
|
+
await this._setupPlugin(adapter);
|
|
112
|
+
this._validateAdapter(adapter);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const createPluginSystemRunner = ({ project, nativePlugins }) => {
|
|
116
|
+
const hookSystem = createPluginHookSystem();
|
|
117
|
+
return new PluginSystemRunner({
|
|
118
|
+
project,
|
|
119
|
+
hookSystem,
|
|
120
|
+
nativePlugins
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
export {
|
|
124
|
+
PluginSystemRunner,
|
|
125
|
+
REQUIRED_ADAPTER_HOOKS,
|
|
126
|
+
createPluginSystemRunner
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=createPluginSystemRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPluginSystemRunner.js","sources":["../../src/createPluginSystemRunner.ts"],"sourcesContent":["import _module from \"node:module\";\n\nimport { defu } from \"defu\";\n\nimport { createPluginHookSystem } from \"./createPluginHookSystem\";\nimport {\n\tcreatePluginSystemActions,\n\tPluginSystemActions,\n} from \"./createPluginSystemActions\";\nimport { createPluginSystemContext } from \"./createPluginSystemContext\";\nimport {\n\tcreatePluginSystemHelpers,\n\tPluginSystemHelpers,\n} from \"./createPluginSystemHelpers\";\nimport { LoadedPlugin, Plugin } from \"./definePlugin\";\nimport { HookSystem } from \"./lib/HookSystem\";\nimport {\n\tPrismicConfigPluginRegistration,\n\tPluginHookExtraArgs,\n\tPluginHookTypes,\n\tPluginHooks,\n\tPrismicProject,\n} from \"./types\";\n\n/**\n * @internal\n */\nexport const REQUIRED_ADAPTER_HOOKS: PluginHookTypes[] = [\n\t\"slice:create\",\n\t\"slice:read\",\n\t\"slice:rename\",\n\t\"slice:delete\",\n\t\"slice:update\",\n\t\"slice-library:read\",\n\t\"custom-type:create\",\n\t\"custom-type:read\",\n\t\"custom-type:rename\",\n\t\"custom-type:delete\",\n\t\"custom-type:update\",\n\t\"custom-type-library:read\",\n];\n\ntype PluginSystemRunnerConstructorArgs = {\n\tproject: PrismicProject;\n\thookSystem: HookSystem<PluginHooks>;\n\tnativePlugins: Record<string, Plugin>;\n};\n\n/**\n * @internal\n */\nexport class PluginSystemRunner {\n\tprivate _project: PrismicProject;\n\tprivate _hookSystem: HookSystem<PluginHooks>;\n\tprivate _nativePlugins: Record<string, Plugin>;\n\n\t/**\n\t * Plugin System actions provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawActions`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawActions: PluginSystemActions;\n\n\t/**\n\t * Plugin System helpers provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawHelpers: PluginSystemHelpers;\n\n\t// Methods forwarded to the plugin runner's hook system.\n\tcallHook: HookSystem<PluginHooks>[\"callHook\"];\n\thooksForOwner: HookSystem<PluginHooks>[\"hooksForOwner\"];\n\thooksForType: HookSystem<PluginHooks>[\"hooksForType\"];\n\tcreateScope: HookSystem<PluginHooks>[\"createScope\"];\n\n\tconstructor({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins,\n\t}: PluginSystemRunnerConstructorArgs) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t\tthis._nativePlugins = nativePlugins;\n\n\t\tthis.rawActions = createPluginSystemActions(\n\t\t\tthis._project,\n\t\t\tthis._hookSystem,\n\t\t);\n\t\tthis.rawHelpers = createPluginSystemHelpers(this._project);\n\n\t\tthis.callHook = this._hookSystem.callHook.bind(this._hookSystem);\n\t\tthis.hooksForOwner = this._hookSystem.hooksForOwner.bind(this._hookSystem);\n\t\tthis.hooksForType = this._hookSystem.hooksForType.bind(this._hookSystem);\n\t\tthis.createScope = this._hookSystem.createScope.bind(this._hookSystem);\n\t}\n\n\tprivate async _loadPlugin(\n\t\tpluginRegistration: PrismicConfigPluginRegistration,\n\t): Promise<LoadedPlugin> {\n\t\t// Sanitize registration\n\t\tconst { resolve, options = {} } =\n\t\t\ttypeof pluginRegistration === \"object\" && \"resolve\" in pluginRegistration\n\t\t\t\t? pluginRegistration\n\t\t\t\t: { resolve: pluginRegistration };\n\n\t\tlet plugin: Plugin | undefined = undefined;\n\n\t\tif (typeof resolve === \"string\") {\n\t\t\tplugin = this._nativePlugins[resolve];\n\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not resolve plugin \\`${resolve}\\`. Check that it has been installed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin = resolve;\n\t\t}\n\n\t\tif (!plugin) {\n\t\t\tthrow new Error(`Could not load plugin: \\`${resolve}\\``);\n\t\t}\n\n\t\tconst mergedOptions = defu(options, plugin.defaultOptions || {});\n\n\t\treturn {\n\t\t\t...plugin,\n\t\t\tresolve,\n\t\t\toptions: mergedOptions,\n\t\t};\n\t}\n\n\tprivate async _setupPlugin(plugin: LoadedPlugin): Promise<void> {\n\t\tconst context = createPluginSystemContext({\n\t\t\tactions: this.rawActions,\n\t\t\thelpers: this.rawHelpers,\n\t\t\tproject: this._project,\n\t\t\tplugin,\n\t\t});\n\t\tconst hookSystemScope = this._hookSystem.createScope<PluginHookExtraArgs>(\n\t\t\tplugin.meta.name,\n\t\t\t[context],\n\t\t);\n\n\t\t// Run plugin setup with actions and context\n\t\ttry {\n\t\t\tawait plugin.setup({\n\t\t\t\t...context,\n\t\t\t\thook: hookSystemScope.hook,\n\t\t\t\tunhook: hookSystemScope.unhook,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error.message}`,\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _validateAdapter(adapter: LoadedPlugin): void {\n\t\tconst hooks = this._hookSystem.hooksForOwner(adapter.meta.name);\n\t\tconst hookTypes = hooks.map((hook) => hook.meta.type);\n\n\t\tconst missingHooks = REQUIRED_ADAPTER_HOOKS.filter(\n\t\t\t(requiredHookType) => !hookTypes.includes(requiredHookType),\n\t\t);\n\n\t\tif (missingHooks.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Adapter \\`${\n\t\t\t\t\tadapter.meta.name\n\t\t\t\t}\\` is missing hooks: \\`${missingHooks.join(\"`, `\")}\\``,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync init(): Promise<void> {\n\t\tconst adapter = await this._loadPlugin(this._project.config.adapter);\n\t\tawait this._setupPlugin(adapter);\n\t\tthis._validateAdapter(adapter);\n\t}\n}\n\ntype CreatePluginSystemRunnerArgs = {\n\tproject: PrismicProject;\n\tnativePlugins: Record<string, Plugin>;\n};\n\n/**\n * @internal\n */\nexport const createPluginSystemRunner = ({\n\tproject,\n\tnativePlugins,\n}: CreatePluginSystemRunnerArgs): PluginSystemRunner => {\n\tconst hookSystem = createPluginHookSystem();\n\n\treturn new PluginSystemRunner({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins,\n\t});\n};\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PluginSystemContext } from "./createPluginSystemContext.js";
|
|
2
|
+
import { CreateScopeReturnType } from "./lib/HookSystem.js";
|
|
3
|
+
import { PluginOptions, PluginHookExtraArgs, PluginHooks } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Plugin definition.
|
|
6
|
+
*/
|
|
7
|
+
export type Plugin<TPluginOptions extends Record<string, unknown> = Record<string, unknown>> = {
|
|
8
|
+
/**
|
|
9
|
+
* Information about the plugin.
|
|
10
|
+
*/
|
|
11
|
+
meta: {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Default options.
|
|
16
|
+
*/
|
|
17
|
+
defaultOptions?: TPluginOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Plugin setup.
|
|
20
|
+
*/
|
|
21
|
+
setup: (context: Omit<PluginSystemContext<TPluginOptions>, "actions"> & Pick<CreateScopeReturnType<PluginHooks, PluginHookExtraArgs<TPluginOptions>>, "hook" | "unhook">) => void | Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export type LoadedPlugin<TPluginOptions extends PluginOptions = PluginOptions> = Plugin<TPluginOptions> & {
|
|
27
|
+
resolve: string | Plugin;
|
|
28
|
+
options: TPluginOptions;
|
|
29
|
+
};
|
|
30
|
+
export declare const definePlugin: <TPluginOptions extends PluginOptions = PluginOptions>(plugin: Plugin<TPluginOptions>) => Plugin<TPluginOptions>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definePlugin.js","sources":["../../src/definePlugin.ts"],"sourcesContent":["import { PluginSystemContext } from \"./createPluginSystemContext\";\nimport { CreateScopeReturnType } from \"./lib/HookSystem\";\nimport { PluginOptions, PluginHookExtraArgs, PluginHooks } from \"./types\";\n\n/**\n * Plugin definition.\n */\nexport type Plugin<\n\tTPluginOptions extends Record<string, unknown> = Record<string, unknown>,\n> = {\n\t/**\n\t * Information about the plugin.\n\t */\n\tmeta: {\n\t\tname: string;\n\t};\n\n\t/**\n\t * Default options.\n\t */\n\tdefaultOptions?: TPluginOptions;\n\n\t/**\n\t * Plugin setup.\n\t */\n\tsetup: (\n\t\tcontext: Omit<PluginSystemContext<TPluginOptions>, \"actions\"> &\n\t\t\tPick<\n\t\t\t\tCreateScopeReturnType<PluginHooks, PluginHookExtraArgs<TPluginOptions>>,\n\t\t\t\t\"hook\" | \"unhook\"\n\t\t\t>,\n\t) => void | Promise<void>;\n};\n\n/**\n * @internal\n */\nexport type LoadedPlugin<TPluginOptions extends PluginOptions = PluginOptions> =\n\tPlugin<TPluginOptions> & {\n\t\tresolve: string | Plugin;\n\t\toptions: TPluginOptions;\n\t};\n\nexport const definePlugin = <\n\tTPluginOptions extends PluginOptions = PluginOptions,\n>(\n\tplugin: Plugin<TPluginOptions>,\n): Plugin<TPluginOptions> => plugin;\n"],"names":[],"mappings":"AA2CO,MAAM,eAAe,CAG3B,WAC4B;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BuildCustomTypeLibraryDirectoryPathArgs } from "./buildCustomTypeLibraryDirectoryPath.js";
|
|
2
|
+
export type BuildCustomTypeDirectoryPathArgs = {
|
|
3
|
+
customTypeID: string;
|
|
4
|
+
} & BuildCustomTypeLibraryDirectoryPathArgs;
|
|
5
|
+
export declare const buildCustomTypeDirectoryPath: (args: BuildCustomTypeDirectoryPathArgs) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { buildCustomTypeLibraryDirectoryPath } from "./buildCustomTypeLibraryDirectoryPath.js";
|
|
3
|
+
const buildCustomTypeDirectoryPath = (args) => {
|
|
4
|
+
return path.join(buildCustomTypeLibraryDirectoryPath(args), args.customTypeID);
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
buildCustomTypeDirectoryPath
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=buildCustomTypeDirectoryPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildCustomTypeDirectoryPath.js","sources":["../../../src/fs/buildCustomTypeDirectoryPath.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport {\n\tbuildCustomTypeLibraryDirectoryPath,\n\tBuildCustomTypeLibraryDirectoryPathArgs,\n} from \"./buildCustomTypeLibraryDirectoryPath\";\n\nexport type BuildCustomTypeDirectoryPathArgs = {\n\tcustomTypeID: string;\n} & BuildCustomTypeLibraryDirectoryPathArgs;\n\nexport const buildCustomTypeDirectoryPath = (\n\targs: BuildCustomTypeDirectoryPathArgs,\n): string => {\n\treturn path.join(\n\t\tbuildCustomTypeLibraryDirectoryPath(args),\n\t\targs.customTypeID,\n\t);\n};\n"],"names":[],"mappings":";;AAWO,MAAM,+BAA+B,CAC3C,SACW;AACX,SAAO,KAAK,KACX,oCAAoC,IAAI,GACxC,KAAK,YAAY;AAEnB;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BuildCustomTypeDirectoryPathArgs } from "./buildCustomTypeDirectoryPath.js";
|
|
2
|
+
export type BuildCustomTypeFilePathArgs = {
|
|
3
|
+
filename: string;
|
|
4
|
+
} & BuildCustomTypeDirectoryPathArgs;
|
|
5
|
+
export declare const buildCustomTypeFilePath: (args: BuildCustomTypeFilePathArgs) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { buildCustomTypeDirectoryPath } from "./buildCustomTypeDirectoryPath.js";
|
|
3
|
+
const buildCustomTypeFilePath = (args) => {
|
|
4
|
+
return path.join(buildCustomTypeDirectoryPath(args), args.filename);
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
buildCustomTypeFilePath
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=buildCustomTypeFilePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildCustomTypeFilePath.js","sources":["../../../src/fs/buildCustomTypeFilePath.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport {\n\tbuildCustomTypeDirectoryPath,\n\tBuildCustomTypeDirectoryPathArgs,\n} from \"./buildCustomTypeDirectoryPath\";\n\nexport type BuildCustomTypeFilePathArgs = {\n\tfilename: string;\n} & BuildCustomTypeDirectoryPathArgs;\n\nexport const buildCustomTypeFilePath = (\n\targs: BuildCustomTypeFilePathArgs,\n): string => {\n\treturn path.join(buildCustomTypeDirectoryPath(args), args.filename);\n};\n"],"names":[],"mappings":";;AAWO,MAAM,0BAA0B,CACtC,SACW;AACX,SAAO,KAAK,KAAK,6BAA6B,IAAI,GAAG,KAAK,QAAQ;AACnE;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PluginSystemHelpers } from "../createPluginSystemHelpers.js";
|
|
2
|
+
export type BuildCustomTypeLibraryDirectoryPathArgs = {
|
|
3
|
+
absolute?: boolean;
|
|
4
|
+
helpers: PluginSystemHelpers;
|
|
5
|
+
};
|
|
6
|
+
export declare const buildCustomTypeLibraryDirectoryPath: (args: BuildCustomTypeLibraryDirectoryPathArgs) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CUSTOM_TYPES_LIBRARY_DIRNAME } from "./constants.js";
|
|
2
|
+
const buildCustomTypeLibraryDirectoryPath = (args) => {
|
|
3
|
+
return args.absolute ? args.helpers.joinPathFromRoot(CUSTOM_TYPES_LIBRARY_DIRNAME) : CUSTOM_TYPES_LIBRARY_DIRNAME;
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
buildCustomTypeLibraryDirectoryPath
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=buildCustomTypeLibraryDirectoryPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildCustomTypeLibraryDirectoryPath.js","sources":["../../../src/fs/buildCustomTypeLibraryDirectoryPath.ts"],"sourcesContent":["import { PluginSystemHelpers } from \"../createPluginSystemHelpers\";\n\nimport { CUSTOM_TYPES_LIBRARY_DIRNAME } from \"./constants\";\n\nexport type BuildCustomTypeLibraryDirectoryPathArgs = {\n\tabsolute?: boolean;\n\thelpers: PluginSystemHelpers;\n};\n\nexport const buildCustomTypeLibraryDirectoryPath = (\n\targs: BuildCustomTypeLibraryDirectoryPathArgs,\n): string => {\n\treturn args.absolute\n\t\t? args.helpers.joinPathFromRoot(CUSTOM_TYPES_LIBRARY_DIRNAME)\n\t\t: CUSTOM_TYPES_LIBRARY_DIRNAME;\n};\n"],"names":[],"mappings":";AASO,MAAM,sCAAsC,CAClD,SACW;AACX,SAAO,KAAK,WACT,KAAK,QAAQ,iBAAiB,4BAA4B,IAC1D;AACJ;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BuildSliceLibraryDirectoryPathArgs } from "./buildSliceLibraryDirectoryPath.js";
|
|
2
|
+
import { ResolveSliceModelArgs } from "./lib/resolveSliceModel.js";
|
|
3
|
+
export type BuildSliceDirectoryPathArgs = BuildSliceLibraryDirectoryPathArgs & ResolveSliceModelArgs;
|
|
4
|
+
export declare const buildSliceDirectoryPath: (args: BuildSliceDirectoryPathArgs) => Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { buildSliceLibraryDirectoryPath } from "./buildSliceLibraryDirectoryPath.js";
|
|
3
|
+
import { pascalCase } from "./lib/pascalCase.js";
|
|
4
|
+
import { resolveSliceModel } from "./lib/resolveSliceModel.js";
|
|
5
|
+
const buildSliceDirectoryPath = async (args) => {
|
|
6
|
+
const model = await resolveSliceModel(args);
|
|
7
|
+
return path.join(buildSliceLibraryDirectoryPath(args), pascalCase(model.name));
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
buildSliceDirectoryPath
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=buildSliceDirectoryPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSliceDirectoryPath.js","sources":["../../../src/fs/buildSliceDirectoryPath.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport {\n\tbuildSliceLibraryDirectoryPath,\n\tBuildSliceLibraryDirectoryPathArgs,\n} from \"./buildSliceLibraryDirectoryPath\";\nimport { pascalCase } from \"./lib/pascalCase\";\nimport {\n\tresolveSliceModel,\n\tResolveSliceModelArgs,\n} from \"./lib/resolveSliceModel\";\n\nexport type BuildSliceDirectoryPathArgs = BuildSliceLibraryDirectoryPathArgs &\n\tResolveSliceModelArgs;\n\nexport const buildSliceDirectoryPath = async (\n\targs: BuildSliceDirectoryPathArgs,\n): Promise<string> => {\n\tconst model = await resolveSliceModel(args);\n\n\treturn path.join(\n\t\tbuildSliceLibraryDirectoryPath(args),\n\t\tpascalCase(model.name),\n\t);\n};\n"],"names":[],"mappings":";;;;AAeO,MAAM,0BAA0B,OACtC,SACoB;AACpB,QAAM,QAAQ,MAAM,kBAAkB,IAAI;AAE1C,SAAO,KAAK,KACX,+BAA+B,IAAI,GACnC,WAAW,MAAM,IAAI,CAAC;AAExB;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { buildSliceDirectoryPath } from "./buildSliceDirectoryPath.js";
|
|
3
|
+
const buildSliceFilePath = async (args) => {
|
|
4
|
+
return path.join(await buildSliceDirectoryPath(args), args.filename);
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
buildSliceFilePath
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=buildSliceFilePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSliceFilePath.js","sources":["../../../src/fs/buildSliceFilePath.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport {\n\tbuildSliceDirectoryPath,\n\tBuildSliceDirectoryPathArgs,\n} from \"./buildSliceDirectoryPath\";\n\nexport type BuildSliceFilePathArgs = {\n\tfilename: string;\n} & BuildSliceDirectoryPathArgs;\n\nexport const buildSliceFilePath = async (\n\targs: BuildSliceFilePathArgs,\n): Promise<string> => {\n\treturn path.join(await buildSliceDirectoryPath(args), args.filename);\n};\n"],"names":[],"mappings":";;AAWO,MAAM,qBAAqB,OACjC,SACoB;AACpB,SAAO,KAAK,KAAK,MAAM,wBAAwB,IAAI,GAAG,KAAK,QAAQ;AACpE;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PluginSystemHelpers } from "../createPluginSystemHelpers.js";
|
|
2
|
+
export type BuildSliceLibraryDirectoryPathArgs = {
|
|
3
|
+
libraryID: string;
|
|
4
|
+
absolute?: boolean;
|
|
5
|
+
helpers: PluginSystemHelpers;
|
|
6
|
+
};
|
|
7
|
+
export declare const buildSliceLibraryDirectoryPath: (args: BuildSliceLibraryDirectoryPathArgs) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
const buildSliceLibraryDirectoryPath = (args) => {
|
|
3
|
+
return args.absolute ? args.helpers.joinPathFromRoot(args.libraryID) : path.join(args.libraryID);
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
buildSliceLibraryDirectoryPath
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=buildSliceLibraryDirectoryPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSliceLibraryDirectoryPath.js","sources":["../../../src/fs/buildSliceLibraryDirectoryPath.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { PluginSystemHelpers } from \"../createPluginSystemHelpers\";\n\nexport type BuildSliceLibraryDirectoryPathArgs = {\n\tlibraryID: string;\n\tabsolute?: boolean;\n\thelpers: PluginSystemHelpers;\n};\n\nexport const buildSliceLibraryDirectoryPath = (\n\targs: BuildSliceLibraryDirectoryPathArgs,\n): string => {\n\treturn args.absolute\n\t\t? args.helpers.joinPathFromRoot(args.libraryID)\n\t\t: path.join(args.libraryID);\n};\n"],"names":[],"mappings":";AAUO,MAAM,iCAAiC,CAC7C,SACW;AACX,SAAO,KAAK,WACT,KAAK,QAAQ,iBAAiB,KAAK,SAAS,IAC5C,KAAK,KAAK,KAAK,SAAS;AAC5B;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { checkPathExists } from "./lib/checkPathExists.js";
|
|
2
|
+
const checkHasProjectFile = async (args) => {
|
|
3
|
+
const filePath = args.helpers.joinPathFromRoot(args.filename);
|
|
4
|
+
return checkPathExists(filePath);
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
checkHasProjectFile
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=checkHasProjectFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkHasProjectFile.js","sources":["../../../src/fs/checkHasProjectFile.ts"],"sourcesContent":["import { PluginSystemHelpers } from \"../createPluginSystemHelpers\";\n\nimport { checkPathExists } from \"./lib/checkPathExists\";\n\nexport type CheckHasProjectFileArgs = {\n\tfilename: string;\n\thelpers: PluginSystemHelpers;\n};\n\nexport const checkHasProjectFile = async (\n\targs: CheckHasProjectFileArgs,\n): Promise<boolean> => {\n\tconst filePath = args.helpers.joinPathFromRoot(args.filename);\n\n\treturn checkPathExists(filePath);\n};\n"],"names":[],"mappings":";AASO,MAAM,sBAAsB,OAClC,SACqB;AACrB,QAAM,WAAW,KAAK,QAAQ,iBAAiB,KAAK,QAAQ;AAE5D,SAAO,gBAAgB,QAAQ;AAChC;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { checkHasProjectFile } from "./checkHasProjectFile.js";
|
|
2
|
+
import { TSCONFIG_FILENAME } from "./constants.js";
|
|
3
|
+
const checkIsTypeScriptProject = async (args) => {
|
|
4
|
+
return checkHasProjectFile({
|
|
5
|
+
...args,
|
|
6
|
+
filename: TSCONFIG_FILENAME
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
checkIsTypeScriptProject
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=checkIsTypeScriptProject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkIsTypeScriptProject.js","sources":["../../../src/fs/checkIsTypeScriptProject.ts"],"sourcesContent":["import {\n\tcheckHasProjectFile,\n\tCheckHasProjectFileArgs,\n} from \"./checkHasProjectFile\";\nimport { TSCONFIG_FILENAME } from \"./constants\";\n\ntype CheckIsTypeScriptProjectArgs = Omit<CheckHasProjectFileArgs, \"filename\">;\n\nexport const checkIsTypeScriptProject = async (\n\targs: CheckIsTypeScriptProjectArgs,\n): Promise<boolean> => {\n\treturn checkHasProjectFile({\n\t\t...args,\n\t\tfilename: TSCONFIG_FILENAME,\n\t});\n};\n"],"names":[],"mappings":";;AAQO,MAAM,2BAA2B,OACvC,SACqB;AACrB,SAAO,oBAAoB;AAAA,IAC1B,GAAG;AAAA,IACH,UAAU;AAAA,EAAA,CACV;AACF;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Banner text added to files that should not be edited by users.
|
|
3
|
+
*/
|
|
4
|
+
export declare const NON_EDITABLE_FILE_BANNER = "// Code generated by Prismic. DO NOT EDIT.";
|
|
5
|
+
export declare const CUSTOM_TYPES_LIBRARY_DIRNAME = "customtypes";
|
|
6
|
+
export declare const CUSTOM_TYPE_MODEL_FILENAME = "index.json";
|
|
7
|
+
export declare const SHARED_SLICE_MODEL_FILENAME = "model.json";
|
|
8
|
+
export declare const TSCONFIG_FILENAME = "tsconfig.json";
|
|
9
|
+
export declare const GLOBAL_TYPESCRIPT_TYPES_FILENAME = "prismicio-types.d.ts";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const NON_EDITABLE_FILE_BANNER = "// Code generated by Prismic. DO NOT EDIT.";
|
|
2
|
+
const CUSTOM_TYPES_LIBRARY_DIRNAME = "customtypes";
|
|
3
|
+
const CUSTOM_TYPE_MODEL_FILENAME = "index.json";
|
|
4
|
+
const SHARED_SLICE_MODEL_FILENAME = "model.json";
|
|
5
|
+
const TSCONFIG_FILENAME = "tsconfig.json";
|
|
6
|
+
const GLOBAL_TYPESCRIPT_TYPES_FILENAME = "prismicio-types.d.ts";
|
|
7
|
+
export {
|
|
8
|
+
CUSTOM_TYPES_LIBRARY_DIRNAME,
|
|
9
|
+
CUSTOM_TYPE_MODEL_FILENAME,
|
|
10
|
+
GLOBAL_TYPESCRIPT_TYPES_FILENAME,
|
|
11
|
+
NON_EDITABLE_FILE_BANNER,
|
|
12
|
+
SHARED_SLICE_MODEL_FILENAME,
|
|
13
|
+
TSCONFIG_FILENAME
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../src/fs/constants.ts"],"sourcesContent":["/**\n * Banner text added to files that should not be edited by users.\n */\nexport const NON_EDITABLE_FILE_BANNER =\n\t\"// Code generated by Prismic. DO NOT EDIT.\";\n\nexport const CUSTOM_TYPES_LIBRARY_DIRNAME = \"customtypes\";\n\nexport const CUSTOM_TYPE_MODEL_FILENAME = \"index.json\";\n\nexport const SHARED_SLICE_MODEL_FILENAME = \"model.json\";\n\nexport const TSCONFIG_FILENAME = \"tsconfig.json\";\n\nexport const GLOBAL_TYPESCRIPT_TYPES_FILENAME = \"prismicio-types.d.ts\";\n"],"names":[],"mappings":"AAGO,MAAM,2BACZ;AAEM,MAAM,+BAA+B;AAErC,MAAM,6BAA6B;AAEnC,MAAM,8BAA8B;AAEpC,MAAM,oBAAoB;AAE1B,MAAM,mCAAmC;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { buildCustomTypeDirectoryPath } from "./buildCustomTypeDirectoryPath.js";
|
|
2
|
+
import { deleteProjectFile } from "./deleteProjectFile.js";
|
|
3
|
+
const deleteCustomTypeDirectory = async (args) => {
|
|
4
|
+
const dir = buildCustomTypeDirectoryPath(args);
|
|
5
|
+
const relativeDir = buildCustomTypeDirectoryPath({
|
|
6
|
+
...args,
|
|
7
|
+
absolute: false
|
|
8
|
+
});
|
|
9
|
+
await deleteProjectFile({
|
|
10
|
+
filename: relativeDir,
|
|
11
|
+
helpers: args.helpers
|
|
12
|
+
});
|
|
13
|
+
return dir;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
deleteCustomTypeDirectory
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=deleteCustomTypeDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteCustomTypeDirectory.js","sources":["../../../src/fs/deleteCustomTypeDirectory.ts"],"sourcesContent":["import {\n\tbuildCustomTypeDirectoryPath,\n\tBuildCustomTypeDirectoryPathArgs,\n} from \"./buildCustomTypeDirectoryPath\";\nimport { deleteProjectFile } from \"./deleteProjectFile\";\n\nexport type DeleteCustomTypeDirectoryArgs = BuildCustomTypeDirectoryPathArgs;\n\nexport const deleteCustomTypeDirectory = async (\n\targs: DeleteCustomTypeDirectoryArgs,\n): Promise<string> => {\n\tconst dir = buildCustomTypeDirectoryPath(args);\n\tconst relativeDir = buildCustomTypeDirectoryPath({\n\t\t...args,\n\t\tabsolute: false,\n\t});\n\n\tawait deleteProjectFile({\n\t\tfilename: relativeDir,\n\t\thelpers: args.helpers,\n\t});\n\n\treturn dir;\n};\n"],"names":[],"mappings":";;AAQO,MAAM,4BAA4B,OACxC,SACoB;AACpB,QAAM,MAAM,6BAA6B,IAAI;AAC7C,QAAM,cAAc,6BAA6B;AAAA,IAChD,GAAG;AAAA,IACH,UAAU;AAAA,EAAA,CACV;AAED,QAAM,kBAAkB;AAAA,IACvB,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAED,SAAO;AACR;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { rm } from "./lib/fsLimit.js";
|
|
2
|
+
const deleteProjectFile = async (args) => {
|
|
3
|
+
const filePath = args.helpers.joinPathFromRoot(args.filename);
|
|
4
|
+
await rm(filePath, { recursive: true });
|
|
5
|
+
return filePath;
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
deleteProjectFile
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=deleteProjectFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteProjectFile.js","sources":["../../../src/fs/deleteProjectFile.ts"],"sourcesContent":["import { PluginSystemHelpers } from \"../createPluginSystemHelpers\";\n\nimport * as fs from \"./lib/fsLimit\";\n\nexport type DeleteProjectFileArgs = {\n\tfilename: string;\n\thelpers: PluginSystemHelpers;\n};\n\nexport const deleteProjectFile = async (\n\targs: DeleteProjectFileArgs,\n): Promise<string> => {\n\tconst filePath = args.helpers.joinPathFromRoot(args.filename);\n\n\tawait fs.rm(filePath, { recursive: true });\n\n\treturn filePath;\n};\n"],"names":["fs.rm"],"mappings":";AASO,MAAM,oBAAoB,OAChC,SACoB;AACpB,QAAM,WAAW,KAAK,QAAQ,iBAAiB,KAAK,QAAQ;AAE5D,QAAMA,GAAM,UAAU,EAAE,WAAW,MAAM;AAEzC,SAAO;AACR;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { buildSliceDirectoryPath } from "./buildSliceDirectoryPath.js";
|
|
2
|
+
import { deleteProjectFile } from "./deleteProjectFile.js";
|
|
3
|
+
const deleteSliceDirectory = async (args) => {
|
|
4
|
+
const dir = await buildSliceDirectoryPath(args);
|
|
5
|
+
const relativeDir = await buildSliceDirectoryPath({
|
|
6
|
+
...args,
|
|
7
|
+
absolute: false
|
|
8
|
+
});
|
|
9
|
+
await deleteProjectFile({
|
|
10
|
+
filename: relativeDir,
|
|
11
|
+
helpers: args.helpers
|
|
12
|
+
});
|
|
13
|
+
return dir;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
deleteSliceDirectory
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=deleteSliceDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteSliceDirectory.js","sources":["../../../src/fs/deleteSliceDirectory.ts"],"sourcesContent":["import {\n\tbuildSliceDirectoryPath,\n\tBuildSliceDirectoryPathArgs,\n} from \"./buildSliceDirectoryPath\";\nimport { deleteProjectFile } from \"./deleteProjectFile\";\n\nexport type DeleteSliceDirectoryArgs = BuildSliceDirectoryPathArgs;\n\nexport const deleteSliceDirectory = async (\n\targs: DeleteSliceDirectoryArgs,\n): Promise<string> => {\n\tconst dir = await buildSliceDirectoryPath(args);\n\tconst relativeDir = await buildSliceDirectoryPath({\n\t\t...args,\n\t\tabsolute: false,\n\t});\n\n\tawait deleteProjectFile({\n\t\tfilename: relativeDir,\n\t\thelpers: args.helpers,\n\t});\n\n\treturn dir;\n};\n"],"names":[],"mappings":";;AAQO,MAAM,uBAAuB,OACnC,SACoB;AACpB,QAAM,MAAM,MAAM,wBAAwB,IAAI;AAC9C,QAAM,cAAc,MAAM,wBAAwB;AAAA,IACjD,GAAG;AAAA,IACH,UAAU;AAAA,EAAA,CACV;AAED,QAAM,kBAAkB;AAAA,IACvB,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAED,SAAO;AACR;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { buildSliceFilePath } from "./buildSliceFilePath.js";
|
|
2
|
+
import { deleteProjectFile } from "./deleteProjectFile.js";
|
|
3
|
+
const deleteSliceFile = async (args) => {
|
|
4
|
+
const filePath = await buildSliceFilePath(args);
|
|
5
|
+
const relativeFilePath = await buildSliceFilePath({
|
|
6
|
+
...args,
|
|
7
|
+
absolute: false
|
|
8
|
+
});
|
|
9
|
+
await deleteProjectFile({
|
|
10
|
+
filename: relativeFilePath,
|
|
11
|
+
helpers: args.helpers
|
|
12
|
+
});
|
|
13
|
+
return filePath;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
deleteSliceFile
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=deleteSliceFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteSliceFile.js","sources":["../../../src/fs/deleteSliceFile.ts"],"sourcesContent":["import {\n\tbuildSliceFilePath,\n\tBuildSliceFilePathArgs,\n} from \"./buildSliceFilePath\";\nimport { deleteProjectFile } from \"./deleteProjectFile\";\n\nexport type DeleteSliceFileArgs = BuildSliceFilePathArgs;\n\nexport const deleteSliceFile = async (\n\targs: DeleteSliceFileArgs,\n): Promise<string> => {\n\tconst filePath = await buildSliceFilePath(args);\n\tconst relativeFilePath = await buildSliceFilePath({\n\t\t...args,\n\t\tabsolute: false,\n\t});\n\n\tawait deleteProjectFile({\n\t\tfilename: relativeFilePath,\n\t\thelpers: args.helpers,\n\t});\n\n\treturn filePath;\n};\n"],"names":[],"mappings":";;AAQO,MAAM,kBAAkB,OAC9B,SACoB;AACpB,QAAM,WAAW,MAAM,mBAAmB,IAAI;AAC9C,QAAM,mBAAmB,MAAM,mBAAmB;AAAA,IACjD,GAAG;AAAA,IACH,UAAU;AAAA,EAAA,CACV;AAED,QAAM,kBAAkB;AAAA,IACvB,UAAU;AAAA,IACV,SAAS,KAAK;AAAA,EAAA,CACd;AAED,SAAO;AACR;"}
|