@smthrs/plan 1.0.0-rc.7 → 1.0.0-rc.9
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/README.md +3 -1
- package/dist/cjs/Effects.d.ts +29 -11
- package/dist/cjs/Effects.d.ts.map +1 -1
- package/dist/cjs/Effects.js.map +2 -2
- package/dist/cjs/FileSet.d.ts +121 -51
- package/dist/cjs/FileSet.d.ts.map +1 -1
- package/dist/cjs/FileSet.js.map +2 -2
- package/dist/cjs/GraphBuildError.d.ts +2 -4
- package/dist/cjs/GraphBuildError.d.ts.map +1 -1
- package/dist/cjs/GraphBuildError.js.map +2 -2
- package/dist/cjs/KeyMaterial.d.ts +13 -8
- package/dist/cjs/KeyMaterial.d.ts.map +1 -1
- package/dist/cjs/KeyMaterial.js.map +2 -2
- package/dist/cjs/Plan.d.ts +72 -23
- package/dist/cjs/Plan.d.ts.map +1 -1
- package/dist/cjs/Plan.js +3 -0
- package/dist/cjs/Plan.js.map +2 -2
- package/dist/cjs/PlanDiff.d.ts +26 -7
- package/dist/cjs/PlanDiff.d.ts.map +1 -1
- package/dist/cjs/PlanDiff.js +29 -4
- package/dist/cjs/PlanDiff.js.map +2 -2
- package/dist/cjs/StepKey.d.ts +38 -17
- package/dist/cjs/StepKey.d.ts.map +1 -1
- package/dist/cjs/StepKey.js +24 -22
- package/dist/cjs/StepKey.js.map +2 -2
- package/dist/cjs/internal/node.d.ts.map +1 -1
- package/dist/esm/Effects.d.ts +29 -11
- package/dist/esm/Effects.d.ts.map +1 -1
- package/dist/esm/Effects.js +18 -7
- package/dist/esm/Effects.js.map +1 -1
- package/dist/esm/FileSet.d.ts +121 -51
- package/dist/esm/FileSet.d.ts.map +1 -1
- package/dist/esm/FileSet.js +97 -35
- package/dist/esm/FileSet.js.map +1 -1
- package/dist/esm/GraphBuildError.d.ts +2 -4
- package/dist/esm/GraphBuildError.d.ts.map +1 -1
- package/dist/esm/GraphBuildError.js +2 -3
- package/dist/esm/GraphBuildError.js.map +1 -1
- package/dist/esm/KeyMaterial.d.ts +13 -8
- package/dist/esm/KeyMaterial.d.ts.map +1 -1
- package/dist/esm/KeyMaterial.js +11 -4
- package/dist/esm/KeyMaterial.js.map +1 -1
- package/dist/esm/Plan.d.ts +72 -23
- package/dist/esm/Plan.d.ts.map +1 -1
- package/dist/esm/Plan.js +61 -16
- package/dist/esm/Plan.js.map +1 -1
- package/dist/esm/PlanDiff.d.ts +26 -7
- package/dist/esm/PlanDiff.d.ts.map +1 -1
- package/dist/esm/PlanDiff.js +55 -9
- package/dist/esm/PlanDiff.js.map +1 -1
- package/dist/esm/StepKey.d.ts +38 -17
- package/dist/esm/StepKey.d.ts.map +1 -1
- package/dist/esm/StepKey.js +41 -16
- package/dist/esm/StepKey.js.map +1 -1
- package/dist/esm/internal/node.d.ts.map +1 -1
- package/docs/README.md +3 -1
- package/docs/api.md +1 -1
- package/docs/guides/diff-two-plans.md +138 -74
- package/docs/installation.md +5 -1
- package/docs/quickstart.md +1 -1
- package/package.json +4 -4
- package/src/Effects.ts +29 -11
- package/src/FileSet.ts +121 -51
- package/src/GraphBuildError.ts +2 -4
- package/src/KeyMaterial.ts +13 -8
- package/src/Plan.ts +66 -23
- package/src/PlanDiff.ts +56 -11
- package/src/StepKey.ts +66 -40
package/dist/esm/FileSet.d.ts
CHANGED
|
@@ -43,7 +43,6 @@ export type BoundaryMode = typeof BoundaryMode.Type;
|
|
|
43
43
|
*
|
|
44
44
|
* @category accessors
|
|
45
45
|
* @since 0.1.0
|
|
46
|
-
* @slop
|
|
47
46
|
*/
|
|
48
47
|
export declare const canonical: (path: string) => string;
|
|
49
48
|
/**
|
|
@@ -59,10 +58,15 @@ export declare const canonical: (path: string) => string;
|
|
|
59
58
|
* @since 1.0.0-rc.0
|
|
60
59
|
*/
|
|
61
60
|
export declare const folded: (path: string) => string;
|
|
62
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* A non-empty workspace-relative path or pattern.
|
|
63
|
+
*
|
|
64
|
+
* Decoding fails with a `SchemaError` when {@link workspaceRelative} refuses
|
|
65
|
+
* the string. A bare `Pattern` in a declaration names one literal path; only a
|
|
66
|
+
* {@link Glob} gives `*` and `**` wildcard meaning.
|
|
67
|
+
*
|
|
63
68
|
* @category schemas
|
|
64
69
|
* @since 0.1.0
|
|
65
|
-
* @slop
|
|
66
70
|
*/
|
|
67
71
|
export declare const Pattern: Schema.NonEmptyString;
|
|
68
72
|
/**
|
|
@@ -71,44 +75,59 @@ export declare const Pattern: Schema.NonEmptyString;
|
|
|
71
75
|
* traversal, and the aliasing forms — `.` segments, empty segments — that
|
|
72
76
|
* would let two spellings of one file defeat exact-string overlap detection.
|
|
73
77
|
*
|
|
78
|
+
* C0 controls and DEL are refused as well.
|
|
79
|
+
*
|
|
74
80
|
* @category predicates
|
|
75
81
|
* @since 0.1.0
|
|
76
|
-
* @slop
|
|
77
82
|
*/
|
|
78
83
|
export declare const workspaceRelative: (pattern: string) => boolean;
|
|
79
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* A Bazel-style file glob: the paths matching any `include` pattern and no
|
|
86
|
+
* `exclude` pattern.
|
|
87
|
+
*
|
|
88
|
+
* In a pattern, `*` matches within one path segment and a `**` segment
|
|
89
|
+
* matches zero or more whole segments. A trailing `**` needs its separator,
|
|
90
|
+
* so `src/**` does not match `src` itself.
|
|
91
|
+
*
|
|
80
92
|
* @category schemas
|
|
81
93
|
* @since 0.1.0
|
|
82
|
-
* @slop
|
|
83
94
|
*/
|
|
84
95
|
export declare const Glob: Schema.TaggedStruct<"Glob", {
|
|
85
96
|
readonly include: Schema.NonEmptyArray<Schema.NonEmptyString>;
|
|
86
97
|
readonly exclude: Schema.optional<Schema.$Array<Schema.NonEmptyString>>;
|
|
87
98
|
}>;
|
|
88
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* The value form of {@link Glob}.
|
|
101
|
+
*
|
|
89
102
|
* @category models
|
|
90
103
|
* @since 0.1.0
|
|
91
|
-
* @slop
|
|
92
104
|
*/
|
|
93
105
|
export type Glob = typeof Glob.Type;
|
|
94
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* A directory output captured and replayed as one tree artifact.
|
|
108
|
+
*
|
|
109
|
+
* It covers `path` and every path beneath it, compared in {@link folded}
|
|
110
|
+
* form.
|
|
111
|
+
*
|
|
95
112
|
* @category schemas
|
|
96
113
|
* @since 0.1.0
|
|
97
|
-
* @slop
|
|
98
114
|
*/
|
|
99
115
|
export declare const TreeArtifact: Schema.TaggedStruct<"TreeArtifact", {
|
|
100
116
|
readonly path: Schema.NonEmptyString;
|
|
101
117
|
}>;
|
|
102
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* The value form of {@link TreeArtifact}.
|
|
120
|
+
*
|
|
103
121
|
* @category models
|
|
104
122
|
* @since 0.1.0
|
|
105
|
-
* @slop
|
|
106
123
|
*/
|
|
107
124
|
export type TreeArtifact = typeof TreeArtifact.Type;
|
|
108
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* One leaf declaration: a literal path, a {@link Glob}, or a
|
|
127
|
+
* {@link TreeArtifact}. Write sets and filegroups hold entries.
|
|
128
|
+
*
|
|
109
129
|
* @category schemas
|
|
110
130
|
* @since 0.1.0
|
|
111
|
-
* @slop
|
|
112
131
|
*/
|
|
113
132
|
export declare const Entry: Schema.Union<readonly [Schema.NonEmptyString, Schema.TaggedStruct<"Glob", {
|
|
114
133
|
readonly include: Schema.NonEmptyArray<Schema.NonEmptyString>;
|
|
@@ -116,31 +135,40 @@ export declare const Entry: Schema.Union<readonly [Schema.NonEmptyString, Schema
|
|
|
116
135
|
}>, Schema.TaggedStruct<"TreeArtifact", {
|
|
117
136
|
readonly path: Schema.NonEmptyString;
|
|
118
137
|
}>]>;
|
|
119
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* The value form of {@link Entry}.
|
|
140
|
+
*
|
|
120
141
|
* @category models
|
|
121
142
|
* @since 0.1.0
|
|
122
|
-
* @slop
|
|
123
143
|
*/
|
|
124
144
|
export type Entry = typeof Entry.Type;
|
|
125
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* One leaf declaration valid in a read set: a literal path or a {@link Glob}.
|
|
147
|
+
* A read set cannot name a {@link TreeArtifact}, which is an output form.
|
|
148
|
+
*
|
|
126
149
|
* @category schemas
|
|
127
150
|
* @since 0.1.0
|
|
128
|
-
* @slop
|
|
129
151
|
*/
|
|
130
152
|
export declare const ReadEntry: Schema.Union<readonly [Schema.NonEmptyString, Schema.TaggedStruct<"Glob", {
|
|
131
153
|
readonly include: Schema.NonEmptyArray<Schema.NonEmptyString>;
|
|
132
154
|
readonly exclude: Schema.optional<Schema.$Array<Schema.NonEmptyString>>;
|
|
133
155
|
}>]>;
|
|
134
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* The value form of {@link ReadEntry}.
|
|
158
|
+
*
|
|
135
159
|
* @category models
|
|
136
160
|
* @since 0.1.0
|
|
137
|
-
* @slop
|
|
138
161
|
*/
|
|
139
162
|
export type ReadEntry = typeof ReadEntry.Type;
|
|
140
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* A named, reusable list of {@link Entry} declarations.
|
|
165
|
+
*
|
|
166
|
+
* {@link expand} replaces a filegroup with its entries in place before any
|
|
167
|
+
* overlap check or measurement, so the name never reaches the boundary.
|
|
168
|
+
* Filegroups do not nest.
|
|
169
|
+
*
|
|
141
170
|
* @category schemas
|
|
142
171
|
* @since 0.1.0
|
|
143
|
-
* @slop
|
|
144
172
|
*/
|
|
145
173
|
export declare const Filegroup: Schema.TaggedStruct<"Filegroup", {
|
|
146
174
|
readonly name: Schema.NonEmptyString;
|
|
@@ -151,16 +179,19 @@ export declare const Filegroup: Schema.TaggedStruct<"Filegroup", {
|
|
|
151
179
|
readonly path: Schema.NonEmptyString;
|
|
152
180
|
}>]>>;
|
|
153
181
|
}>;
|
|
154
|
-
/**
|
|
182
|
+
/**
|
|
183
|
+
* The value form of {@link Filegroup}.
|
|
184
|
+
*
|
|
155
185
|
* @category models
|
|
156
186
|
* @since 0.1.0
|
|
157
|
-
* @slop
|
|
158
187
|
*/
|
|
159
188
|
export type Filegroup = typeof Filegroup.Type;
|
|
160
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* A {@link Filegroup} restricted to {@link ReadEntry} declarations, for use
|
|
191
|
+
* in a read set. It shares the `"Filegroup"` tag.
|
|
192
|
+
*
|
|
161
193
|
* @category schemas
|
|
162
194
|
* @since 0.1.0
|
|
163
|
-
* @slop
|
|
164
195
|
*/
|
|
165
196
|
export declare const ReadFilegroup: Schema.TaggedStruct<"Filegroup", {
|
|
166
197
|
readonly name: Schema.NonEmptyString;
|
|
@@ -169,16 +200,19 @@ export declare const ReadFilegroup: Schema.TaggedStruct<"Filegroup", {
|
|
|
169
200
|
readonly exclude: Schema.optional<Schema.$Array<Schema.NonEmptyString>>;
|
|
170
201
|
}>]>>;
|
|
171
202
|
}>;
|
|
172
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* The value form of {@link ReadFilegroup}.
|
|
205
|
+
*
|
|
173
206
|
* @category models
|
|
174
207
|
* @since 0.1.0
|
|
175
|
-
* @slop
|
|
176
208
|
*/
|
|
177
209
|
export type ReadFilegroup = typeof ReadFilegroup.Type;
|
|
178
|
-
/**
|
|
210
|
+
/**
|
|
211
|
+
* Any declaration accepted in a write set: an {@link Entry} or a
|
|
212
|
+
* {@link Filegroup}.
|
|
213
|
+
*
|
|
179
214
|
* @category schemas
|
|
180
215
|
* @since 0.1.0
|
|
181
|
-
* @slop
|
|
182
216
|
*/
|
|
183
217
|
export declare const Declaration: Schema.Union<readonly [Schema.Union<readonly [Schema.NonEmptyString, Schema.TaggedStruct<"Glob", {
|
|
184
218
|
readonly include: Schema.NonEmptyArray<Schema.NonEmptyString>;
|
|
@@ -194,16 +228,19 @@ export declare const Declaration: Schema.Union<readonly [Schema.Union<readonly [
|
|
|
194
228
|
readonly path: Schema.NonEmptyString;
|
|
195
229
|
}>]>>;
|
|
196
230
|
}>]>;
|
|
197
|
-
/**
|
|
231
|
+
/**
|
|
232
|
+
* The value form of {@link Declaration}.
|
|
233
|
+
*
|
|
198
234
|
* @category models
|
|
199
235
|
* @since 0.1.0
|
|
200
|
-
* @slop
|
|
201
236
|
*/
|
|
202
237
|
export type Declaration = typeof Declaration.Type;
|
|
203
|
-
/**
|
|
238
|
+
/**
|
|
239
|
+
* Any declaration accepted in a read set: a {@link ReadEntry} or a
|
|
240
|
+
* {@link ReadFilegroup}.
|
|
241
|
+
*
|
|
204
242
|
* @category schemas
|
|
205
243
|
* @since 0.1.0
|
|
206
|
-
* @slop
|
|
207
244
|
*/
|
|
208
245
|
export declare const ReadDeclaration: Schema.Union<readonly [Schema.Union<readonly [Schema.NonEmptyString, Schema.TaggedStruct<"Glob", {
|
|
209
246
|
readonly include: Schema.NonEmptyArray<Schema.NonEmptyString>;
|
|
@@ -215,52 +252,86 @@ export declare const ReadDeclaration: Schema.Union<readonly [Schema.Union<readon
|
|
|
215
252
|
readonly exclude: Schema.optional<Schema.$Array<Schema.NonEmptyString>>;
|
|
216
253
|
}>]>>;
|
|
217
254
|
}>]>;
|
|
218
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* The value form of {@link ReadDeclaration}.
|
|
257
|
+
*
|
|
219
258
|
* @category models
|
|
220
259
|
* @since 0.1.0
|
|
221
|
-
* @slop
|
|
222
260
|
*/
|
|
223
261
|
export type ReadDeclaration = typeof ReadDeclaration.Type;
|
|
224
|
-
/**
|
|
262
|
+
/**
|
|
263
|
+
* Creates a {@link Filegroup}. It does not validate `name` or `entries`;
|
|
264
|
+
* decode through {@link Filegroup} when the input is untrusted.
|
|
265
|
+
*
|
|
266
|
+
* @param name - The filegroup name.
|
|
267
|
+
* @param entries - The entries the filegroup expands to, in order.
|
|
268
|
+
* @returns The filegroup value.
|
|
225
269
|
* @category constructors
|
|
226
270
|
* @since 0.1.0
|
|
227
|
-
* @slop
|
|
228
271
|
*/
|
|
229
272
|
export declare const makeFilegroup: (name: string, entries: ReadonlyArray<Entry>) => Filegroup;
|
|
230
|
-
/**
|
|
273
|
+
/**
|
|
274
|
+
* Replaces each {@link Filegroup} with its entries, in place, and keeps every
|
|
275
|
+
* other declaration as it is. Order is preserved and duplicates are kept.
|
|
276
|
+
*
|
|
277
|
+
* @param declarations - Write-set declarations, possibly holding filegroups.
|
|
278
|
+
* @returns The flat list of entries.
|
|
231
279
|
* @category accessors
|
|
232
280
|
* @since 0.1.0
|
|
233
|
-
* @slop
|
|
234
281
|
*/
|
|
235
282
|
export declare const expand: (declarations: ReadonlyArray<Declaration>) => ReadonlyArray<Entry>;
|
|
236
|
-
/**
|
|
283
|
+
/**
|
|
284
|
+
* {@link expand} for read sets: replaces each {@link ReadFilegroup} with its
|
|
285
|
+
* entries, in place, preserving order and duplicates.
|
|
286
|
+
*
|
|
287
|
+
* @param declarations - Read-set declarations, possibly holding filegroups.
|
|
288
|
+
* @returns The flat list of read entries.
|
|
237
289
|
* @category accessors
|
|
238
290
|
* @since 0.1.0
|
|
239
|
-
* @slop
|
|
240
291
|
*/
|
|
241
292
|
export declare const expandReads: (declarations: ReadonlyArray<ReadDeclaration>) => ReadonlyArray<ReadEntry>;
|
|
242
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* Whether a value carries the `"Glob"` tag. It checks only the tag, not the
|
|
295
|
+
* patterns.
|
|
296
|
+
*
|
|
297
|
+
* @param value - Any value.
|
|
298
|
+
* @returns `true` for an object whose `_tag` is `"Glob"`.
|
|
243
299
|
* @category guards
|
|
244
300
|
* @since 0.1.0
|
|
245
|
-
* @slop
|
|
246
301
|
*/
|
|
247
302
|
export declare const isGlob: (value: unknown) => value is Glob;
|
|
248
|
-
/**
|
|
303
|
+
/**
|
|
304
|
+
* Whether a value carries the `"TreeArtifact"` tag. It checks only the tag,
|
|
305
|
+
* not the path.
|
|
306
|
+
*
|
|
307
|
+
* @param value - Any value.
|
|
308
|
+
* @returns `true` for an object whose `_tag` is `"TreeArtifact"`.
|
|
249
309
|
* @category guards
|
|
250
310
|
* @since 0.1.0
|
|
251
|
-
* @slop
|
|
252
311
|
*/
|
|
253
312
|
export declare const isTreeArtifact: (value: unknown) => value is TreeArtifact;
|
|
254
|
-
/**
|
|
313
|
+
/**
|
|
314
|
+
* Whether `path` matches `pattern` under {@link Glob} wildcard rules.
|
|
315
|
+
*
|
|
316
|
+
* The pattern is read in its {@link canonical} spelling; the path is matched
|
|
317
|
+
* as given, case-sensitively, with `/` as its only separator.
|
|
318
|
+
*
|
|
319
|
+
* @param pattern - A Bazel-style pattern such as `src/*.ts` or `docs/**`.
|
|
320
|
+
* @param path - A workspace-relative path.
|
|
321
|
+
* @returns `true` when the path matches.
|
|
255
322
|
* @category predicates
|
|
256
323
|
* @since 0.1.0
|
|
257
|
-
* @slop
|
|
258
324
|
*/
|
|
259
325
|
export declare const matchesPattern: (pattern: string, path: string) => boolean;
|
|
260
|
-
/**
|
|
326
|
+
/**
|
|
327
|
+
* Whether `path` matches some `include` pattern of `glob` and no `exclude`
|
|
328
|
+
* pattern, each tested with {@link matchesPattern}. Case-sensitive.
|
|
329
|
+
*
|
|
330
|
+
* @param glob - The glob to test.
|
|
331
|
+
* @param path - A workspace-relative path.
|
|
332
|
+
* @returns `true` when the glob selects the path.
|
|
261
333
|
* @category predicates
|
|
262
334
|
* @since 0.1.0
|
|
263
|
-
* @slop
|
|
264
335
|
*/
|
|
265
336
|
export declare const matchesGlob: (glob: Glob, path: string) => boolean;
|
|
266
337
|
/**
|
|
@@ -282,7 +353,6 @@ export declare const matchesGlob: (glob: Glob, path: string) => boolean;
|
|
|
282
353
|
*
|
|
283
354
|
* @category predicates
|
|
284
355
|
* @since 0.1.0
|
|
285
|
-
* @slop
|
|
286
356
|
*/
|
|
287
357
|
export declare const overlaps: (left: Entry, right: Entry) => boolean;
|
|
288
358
|
//# sourceMappingURL=FileSet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSet.d.ts","sourceRoot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KAAG,KAAK,IAAI,YACwC,CAAA;AA4EjG;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,MAAM,MAAM,KAAG,OAAwC,CAAA;AAEvG;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,IAAI,EAAE,MAAM,MAAM,KAAG,OAEiB,CAAA;AAexE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,KAAK,EAAE,OAAO,KAAK,KAAG,OAepD,CAAA"}
|
package/dist/esm/FileSet.js
CHANGED
|
@@ -36,7 +36,6 @@ export const BoundaryMode = Schema.Literals(["hard", "expected"]);
|
|
|
36
36
|
*
|
|
37
37
|
* @category accessors
|
|
38
38
|
* @since 0.1.0
|
|
39
|
-
* @slop
|
|
40
39
|
*/
|
|
41
40
|
export const canonical = (path) => path.replaceAll("\\", "/").normalize("NFC");
|
|
42
41
|
/**
|
|
@@ -52,10 +51,15 @@ export const canonical = (path) => path.replaceAll("\\", "/").normalize("NFC");
|
|
|
52
51
|
* @since 1.0.0-rc.0
|
|
53
52
|
*/
|
|
54
53
|
export const folded = (path) => canonical(path).toUpperCase().normalize("NFC");
|
|
55
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* A non-empty workspace-relative path or pattern.
|
|
56
|
+
*
|
|
57
|
+
* Decoding fails with a `SchemaError` when {@link workspaceRelative} refuses
|
|
58
|
+
* the string. A bare `Pattern` in a declaration names one literal path; only a
|
|
59
|
+
* {@link Glob} gives `*` and `**` wildcard meaning.
|
|
60
|
+
*
|
|
56
61
|
* @category schemas
|
|
57
62
|
* @since 0.1.0
|
|
58
|
-
* @slop
|
|
59
63
|
*/
|
|
60
64
|
export const Pattern = Schema.NonEmptyString.check(Schema.makeFilter((pattern) => workspaceRelative(pattern) || "file patterns must be workspace-relative and cannot traverse upward", { title: "workspaceRelativePattern" }));
|
|
61
65
|
/**
|
|
@@ -64,9 +68,10 @@ export const Pattern = Schema.NonEmptyString.check(Schema.makeFilter((pattern) =
|
|
|
64
68
|
* traversal, and the aliasing forms — `.` segments, empty segments — that
|
|
65
69
|
* would let two spellings of one file defeat exact-string overlap detection.
|
|
66
70
|
*
|
|
71
|
+
* C0 controls and DEL are refused as well.
|
|
72
|
+
*
|
|
67
73
|
* @category predicates
|
|
68
74
|
* @since 0.1.0
|
|
69
|
-
* @slop
|
|
70
75
|
*/
|
|
71
76
|
export const workspaceRelative = (pattern) => {
|
|
72
77
|
for (let index = 0; index < pattern.length; index++) {
|
|
@@ -82,97 +87,143 @@ export const workspaceRelative = (pattern) => {
|
|
|
82
87
|
return false;
|
|
83
88
|
return segments.every((segment) => segment !== ".." && segment !== "." && segment !== "");
|
|
84
89
|
};
|
|
85
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* A Bazel-style file glob: the paths matching any `include` pattern and no
|
|
92
|
+
* `exclude` pattern.
|
|
93
|
+
*
|
|
94
|
+
* In a pattern, `*` matches within one path segment and a `**` segment
|
|
95
|
+
* matches zero or more whole segments. A trailing `**` needs its separator,
|
|
96
|
+
* so `src/**` does not match `src` itself.
|
|
97
|
+
*
|
|
86
98
|
* @category schemas
|
|
87
99
|
* @since 0.1.0
|
|
88
|
-
* @slop
|
|
89
100
|
*/
|
|
90
101
|
export const Glob = Schema.TaggedStruct("Glob", {
|
|
91
102
|
include: Schema.NonEmptyArray(Pattern),
|
|
92
103
|
exclude: Schema.optional(Schema.Array(Pattern))
|
|
93
104
|
});
|
|
94
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* A directory output captured and replayed as one tree artifact.
|
|
107
|
+
*
|
|
108
|
+
* It covers `path` and every path beneath it, compared in {@link folded}
|
|
109
|
+
* form.
|
|
110
|
+
*
|
|
95
111
|
* @category schemas
|
|
96
112
|
* @since 0.1.0
|
|
97
|
-
* @slop
|
|
98
113
|
*/
|
|
99
114
|
export const TreeArtifact = Schema.TaggedStruct("TreeArtifact", {
|
|
100
115
|
path: Pattern
|
|
101
116
|
});
|
|
102
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* One leaf declaration: a literal path, a {@link Glob}, or a
|
|
119
|
+
* {@link TreeArtifact}. Write sets and filegroups hold entries.
|
|
120
|
+
*
|
|
103
121
|
* @category schemas
|
|
104
122
|
* @since 0.1.0
|
|
105
|
-
* @slop
|
|
106
123
|
*/
|
|
107
124
|
export const Entry = Schema.Union([Pattern, Glob, TreeArtifact]);
|
|
108
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* One leaf declaration valid in a read set: a literal path or a {@link Glob}.
|
|
127
|
+
* A read set cannot name a {@link TreeArtifact}, which is an output form.
|
|
128
|
+
*
|
|
109
129
|
* @category schemas
|
|
110
130
|
* @since 0.1.0
|
|
111
|
-
* @slop
|
|
112
131
|
*/
|
|
113
132
|
export const ReadEntry = Schema.Union([Pattern, Glob]);
|
|
114
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* A named, reusable list of {@link Entry} declarations.
|
|
135
|
+
*
|
|
136
|
+
* {@link expand} replaces a filegroup with its entries in place before any
|
|
137
|
+
* overlap check or measurement, so the name never reaches the boundary.
|
|
138
|
+
* Filegroups do not nest.
|
|
139
|
+
*
|
|
115
140
|
* @category schemas
|
|
116
141
|
* @since 0.1.0
|
|
117
|
-
* @slop
|
|
118
142
|
*/
|
|
119
143
|
export const Filegroup = Schema.TaggedStruct("Filegroup", {
|
|
120
144
|
name: Schema.NonEmptyString,
|
|
121
145
|
entries: Schema.Array(Entry)
|
|
122
146
|
});
|
|
123
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* A {@link Filegroup} restricted to {@link ReadEntry} declarations, for use
|
|
149
|
+
* in a read set. It shares the `"Filegroup"` tag.
|
|
150
|
+
*
|
|
124
151
|
* @category schemas
|
|
125
152
|
* @since 0.1.0
|
|
126
|
-
* @slop
|
|
127
153
|
*/
|
|
128
154
|
export const ReadFilegroup = Schema.TaggedStruct("Filegroup", {
|
|
129
155
|
name: Schema.NonEmptyString,
|
|
130
156
|
entries: Schema.Array(ReadEntry)
|
|
131
157
|
});
|
|
132
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Any declaration accepted in a write set: an {@link Entry} or a
|
|
160
|
+
* {@link Filegroup}.
|
|
161
|
+
*
|
|
133
162
|
* @category schemas
|
|
134
163
|
* @since 0.1.0
|
|
135
|
-
* @slop
|
|
136
164
|
*/
|
|
137
165
|
export const Declaration = Schema.Union([Entry, Filegroup]);
|
|
138
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Any declaration accepted in a read set: a {@link ReadEntry} or a
|
|
168
|
+
* {@link ReadFilegroup}.
|
|
169
|
+
*
|
|
139
170
|
* @category schemas
|
|
140
171
|
* @since 0.1.0
|
|
141
|
-
* @slop
|
|
142
172
|
*/
|
|
143
173
|
export const ReadDeclaration = Schema.Union([ReadEntry, ReadFilegroup]);
|
|
144
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* Creates a {@link Filegroup}. It does not validate `name` or `entries`;
|
|
176
|
+
* decode through {@link Filegroup} when the input is untrusted.
|
|
177
|
+
*
|
|
178
|
+
* @param name - The filegroup name.
|
|
179
|
+
* @param entries - The entries the filegroup expands to, in order.
|
|
180
|
+
* @returns The filegroup value.
|
|
145
181
|
* @category constructors
|
|
146
182
|
* @since 0.1.0
|
|
147
|
-
* @slop
|
|
148
183
|
*/
|
|
149
184
|
export const makeFilegroup = (name, entries) => ({
|
|
150
185
|
_tag: "Filegroup",
|
|
151
186
|
name,
|
|
152
187
|
entries
|
|
153
188
|
});
|
|
154
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* Replaces each {@link Filegroup} with its entries, in place, and keeps every
|
|
191
|
+
* other declaration as it is. Order is preserved and duplicates are kept.
|
|
192
|
+
*
|
|
193
|
+
* @param declarations - Write-set declarations, possibly holding filegroups.
|
|
194
|
+
* @returns The flat list of entries.
|
|
155
195
|
* @category accessors
|
|
156
196
|
* @since 0.1.0
|
|
157
|
-
* @slop
|
|
158
197
|
*/
|
|
159
198
|
export const expand = (declarations) => declarations.flatMap((declaration) => typeof declaration !== "string" && declaration._tag === "Filegroup" ? declaration.entries : [declaration]);
|
|
160
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* {@link expand} for read sets: replaces each {@link ReadFilegroup} with its
|
|
201
|
+
* entries, in place, preserving order and duplicates.
|
|
202
|
+
*
|
|
203
|
+
* @param declarations - Read-set declarations, possibly holding filegroups.
|
|
204
|
+
* @returns The flat list of read entries.
|
|
161
205
|
* @category accessors
|
|
162
206
|
* @since 0.1.0
|
|
163
|
-
* @slop
|
|
164
207
|
*/
|
|
165
208
|
export const expandReads = (declarations) => declarations.flatMap((declaration) => typeof declaration !== "string" && declaration._tag === "Filegroup" ? declaration.entries : [declaration]);
|
|
166
|
-
/**
|
|
209
|
+
/**
|
|
210
|
+
* Whether a value carries the `"Glob"` tag. It checks only the tag, not the
|
|
211
|
+
* patterns.
|
|
212
|
+
*
|
|
213
|
+
* @param value - Any value.
|
|
214
|
+
* @returns `true` for an object whose `_tag` is `"Glob"`.
|
|
167
215
|
* @category guards
|
|
168
216
|
* @since 0.1.0
|
|
169
|
-
* @slop
|
|
170
217
|
*/
|
|
171
218
|
export const isGlob = (value) => typeof value === "object" && value !== null && "_tag" in value && value._tag === "Glob";
|
|
172
|
-
/**
|
|
219
|
+
/**
|
|
220
|
+
* Whether a value carries the `"TreeArtifact"` tag. It checks only the tag,
|
|
221
|
+
* not the path.
|
|
222
|
+
*
|
|
223
|
+
* @param value - Any value.
|
|
224
|
+
* @returns `true` for an object whose `_tag` is `"TreeArtifact"`.
|
|
173
225
|
* @category guards
|
|
174
226
|
* @since 0.1.0
|
|
175
|
-
* @slop
|
|
176
227
|
*/
|
|
177
228
|
export const isTreeArtifact = (value) => typeof value === "object" && value !== null && "_tag" in value && value._tag === "TreeArtifact";
|
|
178
229
|
/** KMP searches a literal without rescanning a long near-matching prefix. */
|
|
@@ -252,16 +303,28 @@ const patternMatcher = (pattern) => {
|
|
|
252
303
|
patternMatchers.set(key, matcher);
|
|
253
304
|
return matcher;
|
|
254
305
|
};
|
|
255
|
-
/**
|
|
306
|
+
/**
|
|
307
|
+
* Whether `path` matches `pattern` under {@link Glob} wildcard rules.
|
|
308
|
+
*
|
|
309
|
+
* The pattern is read in its {@link canonical} spelling; the path is matched
|
|
310
|
+
* as given, case-sensitively, with `/` as its only separator.
|
|
311
|
+
*
|
|
312
|
+
* @param pattern - A Bazel-style pattern such as `src/*.ts` or `docs/**`.
|
|
313
|
+
* @param path - A workspace-relative path.
|
|
314
|
+
* @returns `true` when the path matches.
|
|
256
315
|
* @category predicates
|
|
257
316
|
* @since 0.1.0
|
|
258
|
-
* @slop
|
|
259
317
|
*/
|
|
260
318
|
export const matchesPattern = (pattern, path) => patternMatcher(pattern)(path);
|
|
261
|
-
/**
|
|
319
|
+
/**
|
|
320
|
+
* Whether `path` matches some `include` pattern of `glob` and no `exclude`
|
|
321
|
+
* pattern, each tested with {@link matchesPattern}. Case-sensitive.
|
|
322
|
+
*
|
|
323
|
+
* @param glob - The glob to test.
|
|
324
|
+
* @param path - A workspace-relative path.
|
|
325
|
+
* @returns `true` when the glob selects the path.
|
|
262
326
|
* @category predicates
|
|
263
327
|
* @since 0.1.0
|
|
264
|
-
* @slop
|
|
265
328
|
*/
|
|
266
329
|
export const matchesGlob = (glob, path) => glob.include.some((pattern) => matchesPattern(pattern, path)) &&
|
|
267
330
|
!(glob.exclude ?? []).some((pattern) => matchesPattern(pattern, path));
|
|
@@ -295,7 +358,6 @@ const matchesGlobFolded = (glob, path) => {
|
|
|
295
358
|
*
|
|
296
359
|
* @category predicates
|
|
297
360
|
* @since 0.1.0
|
|
298
|
-
* @slop
|
|
299
361
|
*/
|
|
300
362
|
export const overlaps = (left, right) => {
|
|
301
363
|
if (typeof left === "string" && typeof right === "string")
|