This repository has been archived by the owner on May 29, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
170 lines (158 loc) · 4.18 KB
/
types.d.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/**
* @description The root element of a dictatable configuration file.
*/
export interface DictatableConfig {
/**
* @type string
* @description Optional message. Can be used to explain this dictatable.
*/
message?: string;
/**
* @description Conditions that, if met, makes this dictatable run. Empty triggers means it will always run.
*/
triggers?: DictatableConfigTrigger[];
/**
* @description Actions to perform if triggered.
*/
actions?: DictatableConfigAction[];
}
export interface DictatableConfigTrigger {
/**
* @type string
* @description The file to trigger on.
*/
target?: string;
haveJsonPathValue?: DictatableConfigActionExpression;
/**
* @items.type string
* @items.minimum 1
* @description can be regular expression.
*/
haveLineContaining?: string;
/**
* @type string
* @description A path that should EXIST or NOT_EXIST.
*/
itShould?: DictatableConfigTriggerItShould;
haveEnvironmentVariable?: DictatableConfigActionEnvironmentVariable;
/**
* @items.type string
* @items.minimum 1
* @description Trigger when running on platform. process.platform. https://nodejs.org/api/process.html#process_process_platform
*/
runningOnPlatform?: PLATFORM_TYPE;
/**
* @description Negate the following triggers.
*/
not?: DictatableConfigTrigger[];
/**
* @description Or any of these triggers.
*/
or?: DictatableConfigTrigger[];
/**
* @description And all these triggers.
*/
and?: DictatableConfigTrigger[];
}
export type DictatableConfigTriggerItShould = 'NOT_EXIST' | 'EXIST';
export type PLATFORM_TYPE =
| 'aix'
| 'darwin'
| 'freebsd'
| 'linux'
| 'openbsd'
| 'sunos'
| 'win32';
export interface DictatableConfigAction {
/**
* @type string
* @description Optional message. Can be used to explain this requirement.
*/
message?: string;
/**
* @type string Can be a file or folder, if it does not exists it will be treated as a folder.
*/
target: string;
/**
* @type string
* @description Can be a glob pattern to match many files or folders. Target will always be
* considered a folder preserving original filenames.
*/
copyFrom?: string;
notHaveJsonPathNodes?: string[];
haveJsonPathValues?: DictatableConfigActionExpression[];
/**
* @type string
* @description A file that should contain a superset of the target file.
*/
beSupersetOfJsonFile?: string;
/**
* @items.type string
* @items.minimum 1
* @description Will be added to the end of the file if not found.
*/
haveLineContaining?: string[];
/**
* @items.type string
* @items.minimum 1
* @description Will be added to the end of the file if not found. This works just like haveLineContaining
* but will respect the .dictatorConfig.json ignore.
*/
haveLineContainingFile?: string[];
/**
* @description The target should have this chmod.
*/
chmod?: string;
/**
* @type string
* @description A path that should EXIST or NOT_EXIST.
*/
itShould?: DictatableConfigActionItShould;
}
export type DictatableConfigActionItShould = 'NOT_EXIST' | 'NOT_BE_IN_GIT';
/**
* @description These may be used to make the tool behave differently, perhaps
* copy or patch different files, depending on operating system.
*/
export interface DictatableConfigActionEnvironmentVariable {
/**
* @type string
* @description Name of environment variable
*/
name: string;
/**
* @type string
* @description Optional value of variable
*/
value?: string;
}
export interface DictatableConfigActionExpression {
/**
* @type string
* @description Expression
*/
expression: string;
/**
* @type string
* @description A value that should match.
*/
value?: string;
}
/**
* @description This describes the .dictatorconfig that can be placed in the dictated folder.
*/
export interface DictatorConfig {
/**
* @description List of glob patterns in the folder to ignore.
* @items.type string
* @items.minimum 1
*/
ignore?: string[];
options?: DictatorConfigOptions;
}
export interface DictatorConfigOptions {
/**
* @description This indentation will be used when/if manipulating json files.
*/
jsonIndentation?: number;
}