-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
110 lines (100 loc) · 3.1 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// =============================================================================
// File : types.ts
// Author : yukimemi
// Last Change : 2024/09/29 21:19:19.
// =============================================================================
import type { Denops } from "jsr:@denops/[email protected]";
import { z } from "npm:[email protected]";
export type Bool =
| boolean
| (({ denops, info }: { denops: Denops; info: PlugInfo }) => Promise<boolean>);
export const BoolSchema: z.ZodType<Bool> = z.union([
z.boolean(),
z.function().args(z.object({
denops: z.any().transform((v) => v as Denops),
info: z.lazy(() => PlugInfoSchema),
})).returns(z.promise(z.boolean())),
]);
export type Config = ({ denops, info }: { denops: Denops; info: PlugInfo }) => Promise<void>;
export const ConfigSchema: z.ZodType<Config> = z.function().args(z.object({
denops: z.any().transform((v) => v as Denops),
info: z.lazy(() => PlugInfoSchema),
})).returns(z.promise(z.void()));
export type Plug = {
url: string;
dst?: string;
rev?: string;
enabled?: Bool;
before?: Config;
after?: Config;
beforeFile?: string;
afterFile?: string;
build?: Config;
clone?: Bool;
depth?: number;
dependencies?: string[];
cache?: {
enabled?: Bool;
before?: string;
after?: string;
beforeFile?: string;
afterFile?: string;
};
isLoad?: boolean;
isUpdate?: boolean;
isCache?: boolean;
elaps?: number;
};
export const PlugSchema = z.object({
url: z.string(),
dst: z.string().optional(),
rev: z.string().optional(),
enabled: BoolSchema.default(true),
before: ConfigSchema.optional(),
after: ConfigSchema.optional(),
beforeFile: z.string().optional(),
afterFile: z.string().optional(),
build: ConfigSchema.optional(),
clone: BoolSchema.default(true),
depth: z.number().default(0),
dependencies: z.array(z.string()).default([]),
cache: z.object({
enabled: BoolSchema.default(false),
before: z.string().optional(),
after: z.string().optional(),
beforeFile: z.string().optional(),
afterFile: z.string().optional(),
}).default({ enabled: false }),
isLoad: z.boolean().default(false),
isUpdate: z.boolean().default(false),
isCache: z.boolean().default(false),
elaps: z.number().default(0),
});
export const PlugInfoSchema = PlugSchema.merge(z.object({
dst: z.string(),
}));
export type PlugInfo = z.infer<typeof PlugInfoSchema>;
export const PlugOptionSchema = z.object({
base: z.string(),
debug: z.boolean().default(false),
profile: z.boolean().default(false),
logarg: z.array(z.string()).default([]),
});
export type PlugOption = z.infer<typeof PlugOptionSchema>;
export const DvpmOptionSchema = z.object({
base: z.string(),
cache: z.string().optional(),
debug: z.boolean().default(false),
concurrency: z.number().default(8),
profile: z.boolean().default(false),
notify: z.boolean().default(false),
logarg: z.array(z.string()).default([]),
});
const DvpmOptionPartialSchema = DvpmOptionSchema.partial({
debug: true,
concurrency: true,
profile: true,
notify: true,
logarg: true,
});
export type DvpmOption = z.infer<typeof DvpmOptionPartialSchema>;