-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.ts
98 lines (85 loc) · 2.24 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
export type InputConfig = {
/**
* Base directory where to look for input files, typically `./src`.
*/
directory: string;
/**
* An optional glob or glob array to match input files in `directory`.
*
* @defaultValue `"**\/*.md"`
*
* @see Globby `patterns` parameter {@link https://github.com/sindresorhus/globby#patterns}
*/
glob?: string | string[];
};
export type RendererOptions = {
/**
* Output directory where to write rendered snippets.
*/
outputDirectory: string;
/**
* An optional map mapping input file paths from CWD to output file paths to
* copy after render.
*/
passthroughFileCopy?: Record<string, string>;
/**
* A map mapping input scopes to output scopes or a function receiving an
* input scope and returning an output scope.
*/
scopeResolver?: Record<string, string> | ((scope: string) => string);
};
export type VisualStudioCodeRendererOptions = {
/**
* An optional path to a `package.json` file where to write the
* `contributes.snippets` map of Visual Studio Code extensions.
*/
packageJSON?: string;
} & RendererOptions;
export type SublimeTextRendererOptions = RendererOptions;
export type IntelliJIDEARendererOptions = {
/**
* An optional path to a `plugin.xml` file where to write the `<extensions />`
* default live templates of an IntelliJ IDEA plugin.
*/
pluginXML?: string;
} & RendererOptions;
export type RendererConfig<
TName extends string,
TOptions extends RendererOptions,
> = {
/**
* Name of the renderer.
*/
name: TName;
/**
* Options to pass to the renderer.
*/
options: TOptions;
};
export type AllRendererConfig =
| RendererConfig<
"visualstudiocode" | "vscode" | "vim",
VisualStudioCodeRendererOptions
>
| RendererConfig<"sublimetext" | "sublime", SublimeTextRendererOptions>
| RendererConfig<"intellijidea" | "intellij", IntelliJIDEARendererOptions>;
/**
* Schnipsel configuration.
*/
export type SchnipselConfig = {
/**
* Configures where and how Schnipsel should look for input files.
*/
input: InputConfig;
/**
* Configures renderers that should be applied to found input files.
*/
renderers: AllRendererConfig[];
};
export type SnippetObject = {
name: string;
description: string;
scopes: string[];
prefix: string;
body: string;
};