@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,72 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
|
|
3
|
+
import pLimit from "p-limit";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The parsed number value of the SM_FS_LIMIT environment variable.
|
|
7
|
+
*/
|
|
8
|
+
const SM_FS_LIMIT = Number.isNaN(Number(process.env.SM_FS_LIMIT))
|
|
9
|
+
? undefined
|
|
10
|
+
: Number(process.env.SM_FS_LIMIT);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The maximum number of concurrent file descriptors allowed to adapters to
|
|
14
|
+
* minimize issues like `EMFILE: too many open files`.
|
|
15
|
+
*
|
|
16
|
+
* - MacOS default limit: 2560 (recent), 256 (old)
|
|
17
|
+
* - Windows limit (per process): 2048
|
|
18
|
+
*/
|
|
19
|
+
const CONCURRENT_FILE_DESCRIPTORS_LIMIT = SM_FS_LIMIT ?? 1024;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Limit concurrent file descriptors for adapters.
|
|
23
|
+
*/
|
|
24
|
+
const fsLimit = pLimit(CONCURRENT_FILE_DESCRIPTORS_LIMIT);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Wrap a function with `fsLimit()` to limit concurrent calls. All functions
|
|
28
|
+
* called with `wrapWithFSLimit()` share the same queue.
|
|
29
|
+
*
|
|
30
|
+
* @param fn - The function to wrap.
|
|
31
|
+
*
|
|
32
|
+
* @returns The wrapped function.
|
|
33
|
+
*/
|
|
34
|
+
const wrapWithFSLimit = <
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
TFn extends (...args: any[]) => any,
|
|
37
|
+
>(
|
|
38
|
+
fn: TFn,
|
|
39
|
+
): TFn => {
|
|
40
|
+
return ((...args) => fsLimit(() => fn(...args))) as TFn;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const access = wrapWithFSLimit(fs.access);
|
|
44
|
+
export const appendFile = wrapWithFSLimit(fs.appendFile);
|
|
45
|
+
export const chmod = wrapWithFSLimit(fs.chmod);
|
|
46
|
+
export const chown = wrapWithFSLimit(fs.chown);
|
|
47
|
+
export const copyFile = wrapWithFSLimit(fs.copyFile);
|
|
48
|
+
export const cp = wrapWithFSLimit(fs.cp);
|
|
49
|
+
export const lchmod = wrapWithFSLimit(fs.lchmod);
|
|
50
|
+
export const lchown = wrapWithFSLimit(fs.lchown);
|
|
51
|
+
export const link = wrapWithFSLimit(fs.link);
|
|
52
|
+
export const lstat = wrapWithFSLimit(fs.lstat);
|
|
53
|
+
export const lutimes = wrapWithFSLimit(fs.lutimes);
|
|
54
|
+
export const mkdir = wrapWithFSLimit(fs.mkdir);
|
|
55
|
+
export const mkdtemp = wrapWithFSLimit(fs.mkdtemp);
|
|
56
|
+
export const open = wrapWithFSLimit(fs.open);
|
|
57
|
+
export const opendir = wrapWithFSLimit(fs.opendir);
|
|
58
|
+
export const readFile = wrapWithFSLimit(fs.readFile);
|
|
59
|
+
export const readdir = wrapWithFSLimit(fs.readdir);
|
|
60
|
+
export const readlink = wrapWithFSLimit(fs.readlink);
|
|
61
|
+
export const realpath = wrapWithFSLimit(fs.realpath);
|
|
62
|
+
export const rename = wrapWithFSLimit(fs.rename);
|
|
63
|
+
export const rm = wrapWithFSLimit(fs.rm);
|
|
64
|
+
export const rmdir = wrapWithFSLimit(fs.rmdir);
|
|
65
|
+
export const stat = wrapWithFSLimit(fs.stat);
|
|
66
|
+
export const statfs = wrapWithFSLimit(fs.statfs);
|
|
67
|
+
export const symlink = wrapWithFSLimit(fs.symlink);
|
|
68
|
+
export const truncate = wrapWithFSLimit(fs.truncate);
|
|
69
|
+
export const unlink = wrapWithFSLimit(fs.unlink);
|
|
70
|
+
export const utimes = wrapWithFSLimit(fs.utimes);
|
|
71
|
+
export const watch = wrapWithFSLimit(fs.watch);
|
|
72
|
+
export const writeFile = wrapWithFSLimit(fs.writeFile);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
export function isSharedSliceModel(
|
|
4
|
+
input: unknown,
|
|
5
|
+
): input is TypesInternal.SharedSlice {
|
|
6
|
+
return (
|
|
7
|
+
typeof input === "object" &&
|
|
8
|
+
input !== null &&
|
|
9
|
+
"type" in input &&
|
|
10
|
+
input.type === "SharedSlice" &&
|
|
11
|
+
"id" in input &&
|
|
12
|
+
typeof input.id === "string"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pascalCase as basePascalCase,
|
|
3
|
+
pascalCaseTransformMerge,
|
|
4
|
+
} from "pascal-case";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts a string to a Pascal cased string.
|
|
8
|
+
*
|
|
9
|
+
* @param input - String to convert into a Pascal cased string.
|
|
10
|
+
*
|
|
11
|
+
* @returns Pascal cased string version of `input`.
|
|
12
|
+
*/
|
|
13
|
+
export const pascalCase = (...input: (string | undefined)[]): string => {
|
|
14
|
+
return basePascalCase(input.filter(Boolean).join(" "), {
|
|
15
|
+
transform: pascalCaseTransformMerge,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import { PluginSystemActions } from "../../createPluginSystemActions";
|
|
4
|
+
|
|
5
|
+
export type ResolveSliceModelArgs =
|
|
6
|
+
| {
|
|
7
|
+
sliceID: string;
|
|
8
|
+
libraryID: string;
|
|
9
|
+
actions: PluginSystemActions;
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
model: TypesInternal.SharedSlice;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export async function resolveSliceModel(
|
|
16
|
+
args: ResolveSliceModelArgs,
|
|
17
|
+
): Promise<TypesInternal.SharedSlice> {
|
|
18
|
+
if ("model" in args) {
|
|
19
|
+
return args.model;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { model } = await args.actions.readSliceModel({
|
|
23
|
+
libraryID: args.libraryID,
|
|
24
|
+
sliceID: args.sliceID,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return model;
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildCustomTypeFilePath,
|
|
3
|
+
BuildCustomTypeFilePathArgs,
|
|
4
|
+
} from "./buildCustomTypeFilePath";
|
|
5
|
+
import { readProjectFile, ReadProjectFileArgs } from "./readProjectFile";
|
|
6
|
+
import { BufferEncoding } from "./types";
|
|
7
|
+
|
|
8
|
+
export type ReadCustomTypeFileArgs = BuildCustomTypeFilePathArgs &
|
|
9
|
+
ReadProjectFileArgs;
|
|
10
|
+
|
|
11
|
+
export async function readCustomTypeFile(
|
|
12
|
+
args: ReadCustomTypeFileArgs,
|
|
13
|
+
): Promise<Buffer>;
|
|
14
|
+
export async function readCustomTypeFile(
|
|
15
|
+
args: ReadCustomTypeFileArgs & { encoding: BufferEncoding },
|
|
16
|
+
): Promise<string>;
|
|
17
|
+
export async function readCustomTypeFile(
|
|
18
|
+
args: ReadCustomTypeFileArgs & { encoding?: BufferEncoding },
|
|
19
|
+
): Promise<Buffer | string> {
|
|
20
|
+
const filePath = buildCustomTypeFilePath(args);
|
|
21
|
+
|
|
22
|
+
return await readProjectFile({
|
|
23
|
+
filename: filePath,
|
|
24
|
+
encoding: args.encoding as BufferEncoding,
|
|
25
|
+
helpers: args.helpers,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
buildCustomTypeLibraryDirectoryPath,
|
|
5
|
+
BuildCustomTypeLibraryDirectoryPathArgs,
|
|
6
|
+
} from "./buildCustomTypeLibraryDirectoryPath";
|
|
7
|
+
import { CUSTOM_TYPE_MODEL_FILENAME } from "./constants";
|
|
8
|
+
import { checkPathExists } from "./lib/checkPathExists";
|
|
9
|
+
import * as fs from "./lib/fsLimit";
|
|
10
|
+
import { isCustomTypeModel } from "./lib/isCustomTypeModel";
|
|
11
|
+
import { readJSONFile } from "./lib/readJSONFile";
|
|
12
|
+
|
|
13
|
+
export type ReadCustomTypeLibraryArgs = BuildCustomTypeLibraryDirectoryPathArgs;
|
|
14
|
+
|
|
15
|
+
export type ReadCustomTypeLibraryReturnType = {
|
|
16
|
+
ids: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const readCustomTypeLibrary = async (
|
|
20
|
+
args: ReadCustomTypeLibraryArgs,
|
|
21
|
+
): Promise<ReadCustomTypeLibraryReturnType> => {
|
|
22
|
+
const libraryDir = buildCustomTypeLibraryDirectoryPath({
|
|
23
|
+
absolute: true,
|
|
24
|
+
helpers: args.helpers,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (!(await checkPathExists(libraryDir))) {
|
|
28
|
+
return {
|
|
29
|
+
ids: [],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const childDirs = await fs.readdir(libraryDir, { withFileTypes: true });
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Paths to models that could not be read due to invalid JSON.
|
|
37
|
+
*/
|
|
38
|
+
const unreadableModelPaths: string[] = [];
|
|
39
|
+
|
|
40
|
+
const ids: string[] = [];
|
|
41
|
+
await Promise.all(
|
|
42
|
+
childDirs.map(async (childDir) => {
|
|
43
|
+
if (childDir.isDirectory()) {
|
|
44
|
+
const childDirContents = await fs.readdir(
|
|
45
|
+
path.join(libraryDir, childDir.name),
|
|
46
|
+
{
|
|
47
|
+
withFileTypes: true,
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
const isCustomTypeDir = childDirContents.some((entry) => {
|
|
51
|
+
return entry.isFile() && entry.name === CUSTOM_TYPE_MODEL_FILENAME;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (isCustomTypeDir) {
|
|
55
|
+
const modelPath = path.join(
|
|
56
|
+
libraryDir,
|
|
57
|
+
childDir.name,
|
|
58
|
+
CUSTOM_TYPE_MODEL_FILENAME,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
const modelContents = await readJSONFile(modelPath);
|
|
63
|
+
|
|
64
|
+
if (isCustomTypeModel(modelContents)) {
|
|
65
|
+
ids.push(modelContents.id);
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
unreadableModelPaths.push(modelPath);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (unreadableModelPaths.length > 0) {
|
|
76
|
+
const formattedPaths = unreadableModelPaths.join(", ");
|
|
77
|
+
|
|
78
|
+
throw new Error(
|
|
79
|
+
`The following custom type models could not be read: [${formattedPaths}]`,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
ids: ids.sort(),
|
|
85
|
+
};
|
|
86
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import { CUSTOM_TYPE_MODEL_FILENAME } from "./constants";
|
|
4
|
+
import {
|
|
5
|
+
readCustomTypeFile,
|
|
6
|
+
ReadCustomTypeFileArgs,
|
|
7
|
+
} from "./readCustomTypeFile";
|
|
8
|
+
|
|
9
|
+
export type ReadCustomTypeModelArgs = Omit<ReadCustomTypeFileArgs, "filename">;
|
|
10
|
+
|
|
11
|
+
export type ReadCustomTypeModelReturnType = {
|
|
12
|
+
model: TypesInternal.CustomType;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const readCustomTypeModel = async (
|
|
16
|
+
args: ReadCustomTypeModelArgs,
|
|
17
|
+
): Promise<ReadCustomTypeModelReturnType> => {
|
|
18
|
+
const model = await readCustomTypeFile({
|
|
19
|
+
...args,
|
|
20
|
+
filename: CUSTOM_TYPE_MODEL_FILENAME,
|
|
21
|
+
encoding: "utf8",
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
model: JSON.parse(model),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PluginSystemHelpers } from "../createPluginSystemHelpers";
|
|
2
|
+
|
|
3
|
+
import * as fs from "./lib/fsLimit";
|
|
4
|
+
|
|
5
|
+
type BufferEncoding = Extract<Parameters<typeof fs.readFile>[1], string>;
|
|
6
|
+
|
|
7
|
+
export type ReadProjectFileArgs = {
|
|
8
|
+
filename: string;
|
|
9
|
+
helpers: PluginSystemHelpers;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export async function readProjectFile(
|
|
13
|
+
args: ReadProjectFileArgs,
|
|
14
|
+
): Promise<Buffer>;
|
|
15
|
+
export async function readProjectFile(
|
|
16
|
+
args: ReadProjectFileArgs & { encoding: BufferEncoding },
|
|
17
|
+
): Promise<string>;
|
|
18
|
+
export async function readProjectFile(
|
|
19
|
+
args: ReadProjectFileArgs & { encoding?: BufferEncoding },
|
|
20
|
+
): Promise<Buffer | string> {
|
|
21
|
+
const filePath = args.helpers.joinPathFromRoot(args.filename);
|
|
22
|
+
|
|
23
|
+
return await fs.readFile(filePath, args.encoding);
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildSliceFilePath,
|
|
3
|
+
BuildSliceFilePathArgs,
|
|
4
|
+
} from "./buildSliceFilePath";
|
|
5
|
+
import { readProjectFile, ReadProjectFileArgs } from "./readProjectFile";
|
|
6
|
+
import { BufferEncoding } from "./types";
|
|
7
|
+
|
|
8
|
+
export type ReadSliceFileArgs = BuildSliceFilePathArgs & ReadProjectFileArgs;
|
|
9
|
+
|
|
10
|
+
export async function readSliceFile(args: ReadSliceFileArgs): Promise<Buffer>;
|
|
11
|
+
export async function readSliceFile(
|
|
12
|
+
args: ReadSliceFileArgs & { encoding: BufferEncoding },
|
|
13
|
+
): Promise<string>;
|
|
14
|
+
export async function readSliceFile(
|
|
15
|
+
args: ReadSliceFileArgs & { encoding?: BufferEncoding },
|
|
16
|
+
): Promise<Buffer | string> {
|
|
17
|
+
const filePath = await buildSliceFilePath({
|
|
18
|
+
...args,
|
|
19
|
+
absolute: false,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return await readProjectFile({
|
|
23
|
+
filename: filePath,
|
|
24
|
+
encoding: args.encoding as BufferEncoding,
|
|
25
|
+
helpers: args.helpers,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
buildSliceLibraryDirectoryPath,
|
|
5
|
+
BuildSliceLibraryDirectoryPathArgs,
|
|
6
|
+
} from "./buildSliceLibraryDirectoryPath";
|
|
7
|
+
import { SHARED_SLICE_MODEL_FILENAME } from "./constants";
|
|
8
|
+
import { checkPathExists } from "./lib/checkPathExists";
|
|
9
|
+
import * as fs from "./lib/fsLimit";
|
|
10
|
+
import { isSharedSliceModel } from "./lib/isSharedSliceModel";
|
|
11
|
+
import { readJSONFile } from "./lib/readJSONFile";
|
|
12
|
+
|
|
13
|
+
export type ReadSliceLibraryArgs = BuildSliceLibraryDirectoryPathArgs;
|
|
14
|
+
|
|
15
|
+
export type ReadSliceLibraryReturnType = {
|
|
16
|
+
id: string;
|
|
17
|
+
sliceIDs: string[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const readSliceLibrary = async (
|
|
21
|
+
args: ReadSliceLibraryArgs,
|
|
22
|
+
): Promise<ReadSliceLibraryReturnType> => {
|
|
23
|
+
const libraryDir = buildSliceLibraryDirectoryPath({
|
|
24
|
+
libraryID: args.libraryID,
|
|
25
|
+
absolute: true,
|
|
26
|
+
helpers: args.helpers,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (!(await checkPathExists(libraryDir))) {
|
|
30
|
+
return {
|
|
31
|
+
id: args.libraryID,
|
|
32
|
+
sliceIDs: [],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const childDirs = await fs.readdir(libraryDir, { withFileTypes: true });
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Paths to models that could not be read due to invalid JSON.
|
|
40
|
+
*/
|
|
41
|
+
const unreadableModelPaths: string[] = [];
|
|
42
|
+
|
|
43
|
+
const sliceIDs: string[] = [];
|
|
44
|
+
await Promise.all(
|
|
45
|
+
childDirs.map(async (childDir) => {
|
|
46
|
+
if (childDir.isDirectory()) {
|
|
47
|
+
const childDirContents = await fs.readdir(
|
|
48
|
+
path.join(libraryDir, childDir.name),
|
|
49
|
+
{
|
|
50
|
+
withFileTypes: true,
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
const isSliceDir = childDirContents.some((entry) => {
|
|
54
|
+
return entry.isFile() && entry.name === SHARED_SLICE_MODEL_FILENAME;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (isSliceDir) {
|
|
58
|
+
const modelPath = path.join(
|
|
59
|
+
libraryDir,
|
|
60
|
+
childDir.name,
|
|
61
|
+
SHARED_SLICE_MODEL_FILENAME,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const modelContents = await readJSONFile(modelPath);
|
|
66
|
+
|
|
67
|
+
if (isSharedSliceModel(modelContents)) {
|
|
68
|
+
sliceIDs.push(modelContents.id);
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
// JSON could not be read or parsed
|
|
72
|
+
unreadableModelPaths.push(modelPath);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
if (unreadableModelPaths.length > 0) {
|
|
80
|
+
const formattedPaths = unreadableModelPaths.join(", ");
|
|
81
|
+
|
|
82
|
+
throw new Error(
|
|
83
|
+
`The following Slice models could not be read: [${formattedPaths}]`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
id: args.libraryID,
|
|
89
|
+
sliceIDs: sliceIDs.sort(),
|
|
90
|
+
};
|
|
91
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
|
|
3
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
4
|
+
|
|
5
|
+
import { PluginSystemHelpers } from "../createPluginSystemHelpers";
|
|
6
|
+
|
|
7
|
+
import { buildSliceLibraryDirectoryPath } from "./buildSliceLibraryDirectoryPath";
|
|
8
|
+
import { SHARED_SLICE_MODEL_FILENAME } from "./constants";
|
|
9
|
+
import { checkPathExists } from "./lib/checkPathExists";
|
|
10
|
+
import * as fs from "./lib/fsLimit";
|
|
11
|
+
import { isSharedSliceModel } from "./lib/isSharedSliceModel";
|
|
12
|
+
import { readJSONFile } from "./lib/readJSONFile";
|
|
13
|
+
|
|
14
|
+
export type ReadSliceModelArgs = {
|
|
15
|
+
libraryID: string;
|
|
16
|
+
sliceID: string;
|
|
17
|
+
helpers: PluginSystemHelpers;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type ReadSliceModelReturnType = {
|
|
21
|
+
model: TypesInternal.SharedSlice;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const readSliceModel = async (
|
|
25
|
+
args: ReadSliceModelArgs,
|
|
26
|
+
): Promise<ReadSliceModelReturnType> => {
|
|
27
|
+
const libraryDir = buildSliceLibraryDirectoryPath({
|
|
28
|
+
libraryID: args.libraryID,
|
|
29
|
+
absolute: true,
|
|
30
|
+
helpers: args.helpers,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (await checkPathExists(libraryDir)) {
|
|
34
|
+
const childDirs = await fs.readdir(libraryDir, { withFileTypes: true });
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Paths to models that could not be read due to invalid JSON.
|
|
38
|
+
*/
|
|
39
|
+
const unreadableModelPaths: string[] = [];
|
|
40
|
+
|
|
41
|
+
// Find the first matching model.
|
|
42
|
+
const models: (TypesInternal.SharedSlice | undefined)[] = await Promise.all(
|
|
43
|
+
childDirs.map(async (childDir) => {
|
|
44
|
+
if (childDir.isDirectory()) {
|
|
45
|
+
const modelPath = path.join(
|
|
46
|
+
libraryDir,
|
|
47
|
+
childDir.name,
|
|
48
|
+
SHARED_SLICE_MODEL_FILENAME,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const modelContents = await readJSONFile(modelPath);
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
isSharedSliceModel(modelContents) &&
|
|
56
|
+
modelContents.id === args.sliceID
|
|
57
|
+
) {
|
|
58
|
+
return modelContents;
|
|
59
|
+
}
|
|
60
|
+
} catch {
|
|
61
|
+
unreadableModelPaths.push(modelPath);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
const [model] = models.filter((model): model is TypesInternal.SharedSlice =>
|
|
67
|
+
isSharedSliceModel(model),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if (model) {
|
|
71
|
+
return {
|
|
72
|
+
model,
|
|
73
|
+
};
|
|
74
|
+
} else {
|
|
75
|
+
if (unreadableModelPaths.length > 0) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Did not find a Slice model with ID "${args.sliceID}" in the "${
|
|
78
|
+
args.libraryID
|
|
79
|
+
}" Slice Library. The following Slice models could not be read: [${unreadableModelPaths.join(
|
|
80
|
+
", ",
|
|
81
|
+
)}]`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
throw new Error(
|
|
88
|
+
`Did not find a Slice model with ID "${args.sliceID}" in the "${args.libraryID}" Slice Library.`,
|
|
89
|
+
);
|
|
90
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeCustomTypeModel,
|
|
3
|
+
WriteCustomTypeModelArgs,
|
|
4
|
+
} from "./writeCustomTypeModel";
|
|
5
|
+
|
|
6
|
+
export type RenameCustomTypeArgs = WriteCustomTypeModelArgs;
|
|
7
|
+
|
|
8
|
+
export const renameCustomType = async (
|
|
9
|
+
args: RenameCustomTypeArgs,
|
|
10
|
+
): Promise<void> => {
|
|
11
|
+
await writeCustomTypeModel(args);
|
|
12
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as fse from "fs-extra";
|
|
2
|
+
|
|
3
|
+
import { PluginSystemActions } from "../createPluginSystemActions";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
buildSliceDirectoryPath,
|
|
7
|
+
BuildSliceDirectoryPathArgs,
|
|
8
|
+
} from "./buildSliceDirectoryPath";
|
|
9
|
+
import { writeSliceModel, WriteSliceModelArgs } from "./writeSliceModel";
|
|
10
|
+
|
|
11
|
+
export type RenameSliceArgs = {
|
|
12
|
+
actions: PluginSystemActions;
|
|
13
|
+
} & Omit<BuildSliceDirectoryPathArgs, "sliceID"> &
|
|
14
|
+
WriteSliceModelArgs;
|
|
15
|
+
|
|
16
|
+
export const renameSlice = async (args: RenameSliceArgs): Promise<void> => {
|
|
17
|
+
const { model: existingModel } = await args.actions.readSliceModel({
|
|
18
|
+
libraryID: args.libraryID,
|
|
19
|
+
sliceID: args.model.id,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
await fse.move(
|
|
23
|
+
await buildSliceDirectoryPath({
|
|
24
|
+
...args,
|
|
25
|
+
model: existingModel,
|
|
26
|
+
absolute: true,
|
|
27
|
+
}),
|
|
28
|
+
await buildSliceDirectoryPath({
|
|
29
|
+
...args,
|
|
30
|
+
absolute: true,
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
await writeSliceModel(args);
|
|
35
|
+
};
|
package/src/fs/types.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { detectTypesProvider, generateTypes } from "prismic-ts-codegen";
|
|
2
|
+
|
|
3
|
+
import { PluginSystemActions } from "../createPluginSystemActions";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
GLOBAL_TYPESCRIPT_TYPES_FILENAME,
|
|
7
|
+
NON_EDITABLE_FILE_BANNER,
|
|
8
|
+
} from "./constants";
|
|
9
|
+
import { writeProjectFile, WriteProjectFileArgs } from "./writeProjectFile";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Arguments for `upsertGlobalContentTypes()`.
|
|
13
|
+
*/
|
|
14
|
+
export type UpsertGlobalTypeScriptTypesArgs = {
|
|
15
|
+
filename?: string;
|
|
16
|
+
actions: PluginSystemActions;
|
|
17
|
+
} & Omit<WriteProjectFileArgs, "filename" | "contents">;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates a globally accessible TypeScript file containing types representing
|
|
21
|
+
* the Prismic repository's content.
|
|
22
|
+
*
|
|
23
|
+
* @returns The file path to the written file.
|
|
24
|
+
*/
|
|
25
|
+
export const upsertGlobalTypeScriptTypes = async (
|
|
26
|
+
args: UpsertGlobalTypeScriptTypesArgs,
|
|
27
|
+
): Promise<string> => {
|
|
28
|
+
const project = await args.helpers.getProject();
|
|
29
|
+
|
|
30
|
+
const [customTypeModelDescriptors, sharedSliceModelDescriptors] =
|
|
31
|
+
await Promise.all([
|
|
32
|
+
args.actions.readAllCustomTypeModels(),
|
|
33
|
+
args.actions.readAllSliceModels(),
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
const customTypeModels = customTypeModelDescriptors.map(
|
|
37
|
+
(customTypeModelDescriptors) => {
|
|
38
|
+
return customTypeModelDescriptors.model;
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
const sharedSliceModels = sharedSliceModelDescriptors.map(
|
|
42
|
+
(sharedSliceModelDescriptors) => {
|
|
43
|
+
return sharedSliceModelDescriptors.model;
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
let contents = generateTypes({
|
|
48
|
+
customTypeModels,
|
|
49
|
+
sharedSliceModels,
|
|
50
|
+
clientIntegration: {
|
|
51
|
+
includeCreateClientInterface: true,
|
|
52
|
+
includeContentNamespace: true,
|
|
53
|
+
},
|
|
54
|
+
typesProvider: await detectTypesProvider({ cwd: project.root }),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
contents = `${NON_EDITABLE_FILE_BANNER}\n\n${contents}`;
|
|
58
|
+
|
|
59
|
+
return await writeProjectFile({
|
|
60
|
+
...args,
|
|
61
|
+
filename: args.filename || GLOBAL_TYPESCRIPT_TYPES_FILENAME,
|
|
62
|
+
contents,
|
|
63
|
+
});
|
|
64
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildCustomTypeFilePath,
|
|
3
|
+
BuildCustomTypeFilePathArgs,
|
|
4
|
+
} from "./buildCustomTypeFilePath";
|
|
5
|
+
import { writeProjectFile, WriteProjectFileArgs } from "./writeProjectFile";
|
|
6
|
+
|
|
7
|
+
export type WriteCustomTypeFileArgs = Omit<WriteProjectFileArgs, "filePath"> &
|
|
8
|
+
BuildCustomTypeFilePathArgs;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Writes a custom type model to the file system.
|
|
12
|
+
*
|
|
13
|
+
* @returns The file path to the written file.
|
|
14
|
+
*/
|
|
15
|
+
export const writeCustomTypeFile = async (
|
|
16
|
+
args: WriteCustomTypeFileArgs,
|
|
17
|
+
): Promise<string> => {
|
|
18
|
+
const filePath = buildCustomTypeFilePath(args);
|
|
19
|
+
const relativeFilePath = buildCustomTypeFilePath({
|
|
20
|
+
...args,
|
|
21
|
+
absolute: false,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
await writeProjectFile({
|
|
25
|
+
...args,
|
|
26
|
+
filename: relativeFilePath,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return filePath;
|
|
30
|
+
};
|