docker-parser 0.1.0

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/types.d.ts ADDED
@@ -0,0 +1,284 @@
1
+ /**
2
+ * Position in source code
3
+ */
4
+ export interface Position {
5
+ line: number;
6
+ column: number;
7
+ offset: number;
8
+ }
9
+ /**
10
+ * Range in source code
11
+ */
12
+ export interface Range {
13
+ start: Position;
14
+ end: Position;
15
+ }
16
+ /**
17
+ * Base node interface
18
+ */
19
+ export interface BaseNode {
20
+ type: string;
21
+ range?: Range;
22
+ }
23
+ /**
24
+ * Dockerfile AST root node
25
+ */
26
+ export interface Dockerfile extends BaseNode {
27
+ type: 'Dockerfile';
28
+ directives: ParserDirective[];
29
+ stages: Stage[];
30
+ comments: Comment[];
31
+ }
32
+ /**
33
+ * Parser directive (e.g., # escape=\ or # syntax=docker/dockerfile:1)
34
+ */
35
+ export interface ParserDirective extends BaseNode {
36
+ type: 'ParserDirective';
37
+ directive: string;
38
+ value: string;
39
+ }
40
+ /**
41
+ * Build stage (starts with FROM)
42
+ */
43
+ export interface Stage extends BaseNode {
44
+ type: 'Stage';
45
+ from: FromInstruction;
46
+ instructions: Instruction[];
47
+ name?: string;
48
+ }
49
+ /**
50
+ * Comment node
51
+ */
52
+ export interface Comment extends BaseNode {
53
+ type: 'Comment';
54
+ value: string;
55
+ }
56
+ /**
57
+ * Base instruction interface
58
+ */
59
+ export interface BaseInstruction extends BaseNode {
60
+ instruction: string;
61
+ }
62
+ /**
63
+ * FROM instruction
64
+ */
65
+ export interface FromInstruction extends BaseInstruction {
66
+ type: 'FromInstruction';
67
+ instruction: 'FROM';
68
+ image: string;
69
+ tag?: string;
70
+ digest?: string;
71
+ name?: string;
72
+ platform?: string;
73
+ }
74
+ /**
75
+ * RUN instruction
76
+ * When isExec is false (shell form), bashAst contains the parsed bash AST
77
+ */
78
+ export interface RunInstruction extends BaseInstruction {
79
+ type: 'RunInstruction';
80
+ instruction: 'RUN';
81
+ command: string | string[];
82
+ isExec: boolean;
83
+ mount?: MountFlag[];
84
+ network?: string;
85
+ security?: string;
86
+ bashAst?: unknown;
87
+ }
88
+ /**
89
+ * Mount flag for RUN instruction
90
+ */
91
+ export interface MountFlag {
92
+ type: string;
93
+ target?: string;
94
+ source?: string;
95
+ from?: string;
96
+ id?: string;
97
+ sharing?: string;
98
+ readonly?: boolean;
99
+ required?: boolean;
100
+ mode?: string;
101
+ uid?: string;
102
+ gid?: string;
103
+ }
104
+ /**
105
+ * CMD instruction
106
+ */
107
+ export interface CmdInstruction extends BaseInstruction {
108
+ type: 'CmdInstruction';
109
+ instruction: 'CMD';
110
+ command: string | string[];
111
+ isExec: boolean;
112
+ }
113
+ /**
114
+ * ENTRYPOINT instruction
115
+ */
116
+ export interface EntrypointInstruction extends BaseInstruction {
117
+ type: 'EntrypointInstruction';
118
+ instruction: 'ENTRYPOINT';
119
+ command: string | string[];
120
+ isExec: boolean;
121
+ }
122
+ /**
123
+ * COPY instruction
124
+ */
125
+ export interface CopyInstruction extends BaseInstruction {
126
+ type: 'CopyInstruction';
127
+ instruction: 'COPY';
128
+ sources: string[];
129
+ destination: string;
130
+ from?: string;
131
+ chown?: string;
132
+ chmod?: string;
133
+ link?: boolean;
134
+ parents?: boolean;
135
+ exclude?: string[];
136
+ }
137
+ /**
138
+ * ADD instruction
139
+ */
140
+ export interface AddInstruction extends BaseInstruction {
141
+ type: 'AddInstruction';
142
+ instruction: 'ADD';
143
+ sources: string[];
144
+ destination: string;
145
+ chown?: string;
146
+ chmod?: string;
147
+ link?: boolean;
148
+ checksum?: string;
149
+ keepGitDir?: boolean;
150
+ exclude?: string[];
151
+ }
152
+ /**
153
+ * ENV instruction
154
+ */
155
+ export interface EnvInstruction extends BaseInstruction {
156
+ type: 'EnvInstruction';
157
+ instruction: 'ENV';
158
+ variables: EnvVariable[];
159
+ }
160
+ /**
161
+ * Environment variable
162
+ */
163
+ export interface EnvVariable {
164
+ key: string;
165
+ value: string;
166
+ }
167
+ /**
168
+ * ARG instruction
169
+ */
170
+ export interface ArgInstruction extends BaseInstruction {
171
+ type: 'ArgInstruction';
172
+ instruction: 'ARG';
173
+ name: string;
174
+ defaultValue?: string;
175
+ }
176
+ /**
177
+ * WORKDIR instruction
178
+ */
179
+ export interface WorkdirInstruction extends BaseInstruction {
180
+ type: 'WorkdirInstruction';
181
+ instruction: 'WORKDIR';
182
+ path: string;
183
+ }
184
+ /**
185
+ * USER instruction
186
+ */
187
+ export interface UserInstruction extends BaseInstruction {
188
+ type: 'UserInstruction';
189
+ instruction: 'USER';
190
+ user: string;
191
+ group?: string;
192
+ }
193
+ /**
194
+ * EXPOSE instruction
195
+ */
196
+ export interface ExposeInstruction extends BaseInstruction {
197
+ type: 'ExposeInstruction';
198
+ instruction: 'EXPOSE';
199
+ ports: PortSpec[];
200
+ }
201
+ /**
202
+ * Port specification
203
+ */
204
+ export interface PortSpec {
205
+ port: number | string;
206
+ protocol?: 'tcp' | 'udp';
207
+ }
208
+ /**
209
+ * VOLUME instruction
210
+ */
211
+ export interface VolumeInstruction extends BaseInstruction {
212
+ type: 'VolumeInstruction';
213
+ instruction: 'VOLUME';
214
+ paths: string[];
215
+ }
216
+ /**
217
+ * LABEL instruction
218
+ */
219
+ export interface LabelInstruction extends BaseInstruction {
220
+ type: 'LabelInstruction';
221
+ instruction: 'LABEL';
222
+ labels: LabelEntry[];
223
+ }
224
+ /**
225
+ * Label entry
226
+ */
227
+ export interface LabelEntry {
228
+ key: string;
229
+ value: string;
230
+ }
231
+ /**
232
+ * SHELL instruction
233
+ */
234
+ export interface ShellInstruction extends BaseInstruction {
235
+ type: 'ShellInstruction';
236
+ instruction: 'SHELL';
237
+ shell: string[];
238
+ }
239
+ /**
240
+ * HEALTHCHECK instruction
241
+ */
242
+ export interface HealthcheckInstruction extends BaseInstruction {
243
+ type: 'HealthcheckInstruction';
244
+ instruction: 'HEALTHCHECK';
245
+ none?: boolean;
246
+ interval?: string;
247
+ timeout?: string;
248
+ startPeriod?: string;
249
+ startInterval?: string;
250
+ retries?: number;
251
+ command?: CmdInstruction;
252
+ }
253
+ /**
254
+ * STOPSIGNAL instruction
255
+ */
256
+ export interface StopsignalInstruction extends BaseInstruction {
257
+ type: 'StopsignalInstruction';
258
+ instruction: 'STOPSIGNAL';
259
+ signal: string;
260
+ }
261
+ /**
262
+ * ONBUILD instruction
263
+ */
264
+ export interface OnbuildInstruction extends BaseInstruction {
265
+ type: 'OnbuildInstruction';
266
+ instruction: 'ONBUILD';
267
+ trigger: Instruction;
268
+ }
269
+ /**
270
+ * MAINTAINER instruction (deprecated)
271
+ */
272
+ export interface MaintainerInstruction extends BaseInstruction {
273
+ type: 'MaintainerInstruction';
274
+ instruction: 'MAINTAINER';
275
+ maintainer: string;
276
+ }
277
+ /**
278
+ * Union type for all instructions
279
+ */
280
+ export type Instruction = FromInstruction | RunInstruction | CmdInstruction | EntrypointInstruction | CopyInstruction | AddInstruction | EnvInstruction | ArgInstruction | WorkdirInstruction | UserInstruction | ExposeInstruction | VolumeInstruction | LabelInstruction | ShellInstruction | HealthcheckInstruction | StopsignalInstruction | OnbuildInstruction | MaintainerInstruction;
281
+ /**
282
+ * Union type for all AST nodes
283
+ */
284
+ export type Node = Dockerfile | ParserDirective | Stage | Comment | Instruction;
package/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });