@effected/bundler 0.0.0-stage → 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/Bundler.js +450 -0
- package/BundlerError.js +39 -0
- package/LICENSE +21 -0
- package/README.md +84 -2
- package/action/ActionBuilder.js +108 -0
- package/action/ActionBundle.js +261 -0
- package/action/ActionErrors.js +83 -0
- package/action/ActionValidation.js +195 -0
- package/action/ActionYml.js +366 -0
- package/action/PersistLocal.js +186 -0
- package/action/entries.js +23 -0
- package/action/ignore-stub-plugin.js +25 -0
- package/action/import-check.js +134 -0
- package/assets/Inter-SemiBold.ttf +0 -0
- package/assets/LICENSE-Inter.txt +92 -0
- package/catalog/resolve-catalogs.js +32 -0
- package/changesets/next-versions.js +50 -0
- package/config/ActionConfig.js +102 -0
- package/config/BuildConfig.js +427 -0
- package/config/EffectedConfigFile.js +160 -0
- package/config/merge.js +20 -0
- package/config/plugins.js +84 -0
- package/config-validation/ConfigValidator.js +67 -0
- package/dts/bundled-siblings.js +108 -0
- package/dts/parse.js +28 -0
- package/dts/reexport-stub.js +94 -0
- package/dts/relative-imports.js +33 -0
- package/dts/resolved-tsconfig.js +238 -0
- package/entries/ambient-dts.js +108 -0
- package/entries/export-paths.js +16 -0
- package/entries/extract.js +79 -0
- package/entries/package-json-entries.js +19 -0
- package/errors.js +37 -0
- package/exe/build.js +55 -0
- package/exe/config.js +54 -0
- package/exe/filename.js +13 -0
- package/index.d.ts +3919 -0
- package/index.js +58 -0
- package/internal/causeMessage.js +57 -0
- package/journal/BuildJournal.js +108 -0
- package/jsx/config.js +51 -0
- package/manifest/emit-manifest.js +88 -0
- package/manifest/export-patterns.js +58 -0
- package/manifest/transform.js +323 -0
- package/meta/BundleManifest.js +208 -0
- package/meta/ManifestSource.js +37 -0
- package/meta/api-extractor.js +241 -0
- package/meta/config.js +24 -0
- package/meta/generate.js +246 -0
- package/meta/merge-models.js +43 -0
- package/meta/message-suppressor.js +43 -0
- package/meta/og-image.js +137 -0
- package/meta/og-satori.js +140 -0
- package/meta/optimistic.js +32 -0
- package/meta/run-pass.js +117 -0
- package/meta/scrub-declaration-maps.js +63 -0
- package/meta/tsconfig-resolver.js +55 -0
- package/meta/tsdoc-config.js +47 -0
- package/meta/tsdoctor-config.js +22 -0
- package/meta/tsdoctor-manifest.js +134 -0
- package/meta/tsdoctor-source.js +94 -0
- package/package.json +85 -5
- package/passes/build-target-groups.js +346 -0
- package/passes/cjs-default-interop.js +98 -0
- package/passes/loose-files.js +57 -0
- package/passes/node-builtin-default-interop.js +79 -0
- package/passes/strip-maps.js +39 -0
- package/passes/sync-public.js +100 -0
- package/passes/target-groups.js +112 -0
- package/report/ci-annotations.js +36 -0
- package/report/collector.js +140 -0
- package/report/issues-artifact.js +155 -0
- package/report/metrics-plugin.js +76 -0
- package/report/schema.js +77 -0
- package/report/timer.js +19 -0
- package/report/tsdown-logger.js +58 -0
- package/targets/binding.js +18 -0
- package/targets/config.js +21 -0
- package/targets/resolve-targets.js +165 -0
- package/tsconfig/sync-options.js +20 -0
- package/tsdoc-metadata.json +11 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
// src/action/ActionYml.ts
|
|
4
|
+
/**
|
|
5
|
+
* The Feather icons GitHub accepts as an action's branding icon.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
const ActionYmlBrandingIcon = Schema.Literals([
|
|
10
|
+
"activity",
|
|
11
|
+
"airplay",
|
|
12
|
+
"alert-circle",
|
|
13
|
+
"alert-octagon",
|
|
14
|
+
"alert-triangle",
|
|
15
|
+
"align-center",
|
|
16
|
+
"align-justify",
|
|
17
|
+
"align-left",
|
|
18
|
+
"align-right",
|
|
19
|
+
"anchor",
|
|
20
|
+
"aperture",
|
|
21
|
+
"archive",
|
|
22
|
+
"arrow-down-circle",
|
|
23
|
+
"arrow-down-left",
|
|
24
|
+
"arrow-down-right",
|
|
25
|
+
"arrow-down",
|
|
26
|
+
"arrow-left-circle",
|
|
27
|
+
"arrow-left",
|
|
28
|
+
"arrow-right-circle",
|
|
29
|
+
"arrow-right",
|
|
30
|
+
"arrow-up-circle",
|
|
31
|
+
"arrow-up-left",
|
|
32
|
+
"arrow-up-right",
|
|
33
|
+
"arrow-up",
|
|
34
|
+
"at-sign",
|
|
35
|
+
"award",
|
|
36
|
+
"bar-chart-2",
|
|
37
|
+
"bar-chart",
|
|
38
|
+
"battery-charging",
|
|
39
|
+
"battery",
|
|
40
|
+
"bell-off",
|
|
41
|
+
"bell",
|
|
42
|
+
"bluetooth",
|
|
43
|
+
"bold",
|
|
44
|
+
"book-open",
|
|
45
|
+
"book",
|
|
46
|
+
"bookmark",
|
|
47
|
+
"box",
|
|
48
|
+
"briefcase",
|
|
49
|
+
"calendar",
|
|
50
|
+
"camera-off",
|
|
51
|
+
"camera",
|
|
52
|
+
"cast",
|
|
53
|
+
"check-circle",
|
|
54
|
+
"check-square",
|
|
55
|
+
"check",
|
|
56
|
+
"chevron-down",
|
|
57
|
+
"chevron-left",
|
|
58
|
+
"chevron-right",
|
|
59
|
+
"chevron-up",
|
|
60
|
+
"chevrons-down",
|
|
61
|
+
"chevrons-left",
|
|
62
|
+
"chevrons-right",
|
|
63
|
+
"chevrons-up",
|
|
64
|
+
"circle",
|
|
65
|
+
"clipboard",
|
|
66
|
+
"clock",
|
|
67
|
+
"cloud-drizzle",
|
|
68
|
+
"cloud-lightning",
|
|
69
|
+
"cloud-off",
|
|
70
|
+
"cloud-rain",
|
|
71
|
+
"cloud-snow",
|
|
72
|
+
"cloud",
|
|
73
|
+
"code",
|
|
74
|
+
"command",
|
|
75
|
+
"compass",
|
|
76
|
+
"copy",
|
|
77
|
+
"corner-down-left",
|
|
78
|
+
"corner-down-right",
|
|
79
|
+
"corner-left-down",
|
|
80
|
+
"corner-left-up",
|
|
81
|
+
"corner-right-down",
|
|
82
|
+
"corner-right-up",
|
|
83
|
+
"corner-up-left",
|
|
84
|
+
"corner-up-right",
|
|
85
|
+
"cpu",
|
|
86
|
+
"credit-card",
|
|
87
|
+
"crop",
|
|
88
|
+
"crosshair",
|
|
89
|
+
"database",
|
|
90
|
+
"delete",
|
|
91
|
+
"disc",
|
|
92
|
+
"dollar-sign",
|
|
93
|
+
"download-cloud",
|
|
94
|
+
"download",
|
|
95
|
+
"droplet",
|
|
96
|
+
"edit-2",
|
|
97
|
+
"edit-3",
|
|
98
|
+
"edit",
|
|
99
|
+
"external-link",
|
|
100
|
+
"eye-off",
|
|
101
|
+
"eye",
|
|
102
|
+
"fast-forward",
|
|
103
|
+
"feather",
|
|
104
|
+
"file-minus",
|
|
105
|
+
"file-plus",
|
|
106
|
+
"file-text",
|
|
107
|
+
"file",
|
|
108
|
+
"film",
|
|
109
|
+
"filter",
|
|
110
|
+
"flag",
|
|
111
|
+
"folder-minus",
|
|
112
|
+
"folder-plus",
|
|
113
|
+
"folder",
|
|
114
|
+
"gift",
|
|
115
|
+
"git-branch",
|
|
116
|
+
"git-commit",
|
|
117
|
+
"git-merge",
|
|
118
|
+
"git-pull-request",
|
|
119
|
+
"globe",
|
|
120
|
+
"grid",
|
|
121
|
+
"hard-drive",
|
|
122
|
+
"hash",
|
|
123
|
+
"headphones",
|
|
124
|
+
"heart",
|
|
125
|
+
"help-circle",
|
|
126
|
+
"home",
|
|
127
|
+
"image",
|
|
128
|
+
"inbox",
|
|
129
|
+
"info",
|
|
130
|
+
"italic",
|
|
131
|
+
"layers",
|
|
132
|
+
"layout",
|
|
133
|
+
"life-buoy",
|
|
134
|
+
"link-2",
|
|
135
|
+
"link",
|
|
136
|
+
"list",
|
|
137
|
+
"loader",
|
|
138
|
+
"lock",
|
|
139
|
+
"log-in",
|
|
140
|
+
"log-out",
|
|
141
|
+
"mail",
|
|
142
|
+
"map-pin",
|
|
143
|
+
"map",
|
|
144
|
+
"maximize-2",
|
|
145
|
+
"maximize",
|
|
146
|
+
"menu",
|
|
147
|
+
"message-circle",
|
|
148
|
+
"message-square",
|
|
149
|
+
"mic-off",
|
|
150
|
+
"mic",
|
|
151
|
+
"minimize-2",
|
|
152
|
+
"minimize",
|
|
153
|
+
"minus-circle",
|
|
154
|
+
"minus-square",
|
|
155
|
+
"minus",
|
|
156
|
+
"monitor",
|
|
157
|
+
"moon",
|
|
158
|
+
"more-horizontal",
|
|
159
|
+
"more-vertical",
|
|
160
|
+
"move",
|
|
161
|
+
"music",
|
|
162
|
+
"navigation-2",
|
|
163
|
+
"navigation",
|
|
164
|
+
"octagon",
|
|
165
|
+
"package",
|
|
166
|
+
"paperclip",
|
|
167
|
+
"pause-circle",
|
|
168
|
+
"pause",
|
|
169
|
+
"percent",
|
|
170
|
+
"phone-call",
|
|
171
|
+
"phone-forwarded",
|
|
172
|
+
"phone-incoming",
|
|
173
|
+
"phone-missed",
|
|
174
|
+
"phone-off",
|
|
175
|
+
"phone-outgoing",
|
|
176
|
+
"phone",
|
|
177
|
+
"pie-chart",
|
|
178
|
+
"play-circle",
|
|
179
|
+
"play",
|
|
180
|
+
"plus-circle",
|
|
181
|
+
"plus-square",
|
|
182
|
+
"plus",
|
|
183
|
+
"pocket",
|
|
184
|
+
"power",
|
|
185
|
+
"printer",
|
|
186
|
+
"radio",
|
|
187
|
+
"refresh-ccw",
|
|
188
|
+
"refresh-cw",
|
|
189
|
+
"repeat",
|
|
190
|
+
"rewind",
|
|
191
|
+
"rotate-ccw",
|
|
192
|
+
"rotate-cw",
|
|
193
|
+
"rss",
|
|
194
|
+
"save",
|
|
195
|
+
"scissors",
|
|
196
|
+
"search",
|
|
197
|
+
"send",
|
|
198
|
+
"server",
|
|
199
|
+
"settings",
|
|
200
|
+
"share-2",
|
|
201
|
+
"share",
|
|
202
|
+
"shield-off",
|
|
203
|
+
"shield",
|
|
204
|
+
"shopping-bag",
|
|
205
|
+
"shopping-cart",
|
|
206
|
+
"shuffle",
|
|
207
|
+
"sidebar",
|
|
208
|
+
"skip-back",
|
|
209
|
+
"skip-forward",
|
|
210
|
+
"slash",
|
|
211
|
+
"sliders",
|
|
212
|
+
"smartphone",
|
|
213
|
+
"speaker",
|
|
214
|
+
"square",
|
|
215
|
+
"star",
|
|
216
|
+
"stop-circle",
|
|
217
|
+
"sun",
|
|
218
|
+
"sunrise",
|
|
219
|
+
"sunset",
|
|
220
|
+
"table",
|
|
221
|
+
"tablet",
|
|
222
|
+
"tag",
|
|
223
|
+
"target",
|
|
224
|
+
"terminal",
|
|
225
|
+
"thermometer",
|
|
226
|
+
"thumbs-down",
|
|
227
|
+
"thumbs-up",
|
|
228
|
+
"toggle-left",
|
|
229
|
+
"toggle-right",
|
|
230
|
+
"trash-2",
|
|
231
|
+
"trash",
|
|
232
|
+
"trending-down",
|
|
233
|
+
"trending-up",
|
|
234
|
+
"triangle",
|
|
235
|
+
"truck",
|
|
236
|
+
"tv",
|
|
237
|
+
"type",
|
|
238
|
+
"umbrella",
|
|
239
|
+
"underline",
|
|
240
|
+
"unlock",
|
|
241
|
+
"upload-cloud",
|
|
242
|
+
"upload",
|
|
243
|
+
"user-check",
|
|
244
|
+
"user-minus",
|
|
245
|
+
"user-plus",
|
|
246
|
+
"user-x",
|
|
247
|
+
"user",
|
|
248
|
+
"users",
|
|
249
|
+
"video-off",
|
|
250
|
+
"video",
|
|
251
|
+
"voicemail",
|
|
252
|
+
"volume-1",
|
|
253
|
+
"volume-2",
|
|
254
|
+
"volume-x",
|
|
255
|
+
"volume",
|
|
256
|
+
"watch",
|
|
257
|
+
"wifi-off",
|
|
258
|
+
"wifi",
|
|
259
|
+
"wind",
|
|
260
|
+
"x-circle",
|
|
261
|
+
"x-square",
|
|
262
|
+
"x",
|
|
263
|
+
"zap-off",
|
|
264
|
+
"zap",
|
|
265
|
+
"zoom-in",
|
|
266
|
+
"zoom-out"
|
|
267
|
+
]);
|
|
268
|
+
/**
|
|
269
|
+
* The colors GitHub accepts as an action's branding color.
|
|
270
|
+
*
|
|
271
|
+
* @public
|
|
272
|
+
*/
|
|
273
|
+
const ActionYmlBrandingColor = Schema.Literals([
|
|
274
|
+
"white",
|
|
275
|
+
"black",
|
|
276
|
+
"yellow",
|
|
277
|
+
"blue",
|
|
278
|
+
"green",
|
|
279
|
+
"orange",
|
|
280
|
+
"red",
|
|
281
|
+
"purple",
|
|
282
|
+
"gray-dark"
|
|
283
|
+
]);
|
|
284
|
+
/**
|
|
285
|
+
* One input an action declares.
|
|
286
|
+
*
|
|
287
|
+
* @public
|
|
288
|
+
*/
|
|
289
|
+
var ActionYmlInput = class extends Schema.Class("ActionYmlInput")({
|
|
290
|
+
/** What the input is for. */
|
|
291
|
+
description: Schema.String,
|
|
292
|
+
/** Whether a workflow must supply the input. */
|
|
293
|
+
required: Schema.optionalKey(Schema.Boolean),
|
|
294
|
+
/** The value used when a workflow supplies none. A string only, so a YAML `default: true` is a schema error: quote it. */
|
|
295
|
+
default: Schema.optionalKey(Schema.String),
|
|
296
|
+
/** The warning shown when a workflow supplies the input. */
|
|
297
|
+
deprecationMessage: Schema.optionalKey(Schema.String)
|
|
298
|
+
}) {};
|
|
299
|
+
/**
|
|
300
|
+
* One output an action declares.
|
|
301
|
+
*
|
|
302
|
+
* @public
|
|
303
|
+
*/
|
|
304
|
+
var ActionYmlOutput = class extends Schema.Class("ActionYmlOutput")({
|
|
305
|
+
/** What the output holds. */
|
|
306
|
+
description: Schema.String }) {};
|
|
307
|
+
/**
|
|
308
|
+
* How an action runs, the `runs` key.
|
|
309
|
+
*
|
|
310
|
+
* @remarks
|
|
311
|
+
* The action builder emits Node 24 actions only, so `using` takes `node24` and nothing else.
|
|
312
|
+
*
|
|
313
|
+
* @public
|
|
314
|
+
*/
|
|
315
|
+
var ActionYmlRuns = class extends Schema.Class("ActionYmlRuns")({
|
|
316
|
+
/** The runtime. */
|
|
317
|
+
using: Schema.Literal("node24"),
|
|
318
|
+
/** The file that runs as the main step. */
|
|
319
|
+
main: Schema.String,
|
|
320
|
+
/** The file that runs before `main`. */
|
|
321
|
+
pre: Schema.optionalKey(Schema.String),
|
|
322
|
+
/** The condition for running `pre`. */
|
|
323
|
+
"pre-if": Schema.optionalKey(Schema.String),
|
|
324
|
+
/** The file that runs after `main`. */
|
|
325
|
+
post: Schema.optionalKey(Schema.String),
|
|
326
|
+
/** The condition for running `post`. */
|
|
327
|
+
"post-if": Schema.optionalKey(Schema.String)
|
|
328
|
+
}) {};
|
|
329
|
+
/**
|
|
330
|
+
* An action's Marketplace branding.
|
|
331
|
+
*
|
|
332
|
+
* @public
|
|
333
|
+
*/
|
|
334
|
+
var ActionYmlBranding = class extends Schema.Class("ActionYmlBranding")({
|
|
335
|
+
/** The icon. */
|
|
336
|
+
icon: Schema.optionalKey(ActionYmlBrandingIcon),
|
|
337
|
+
/** The background color. */
|
|
338
|
+
color: Schema.optionalKey(ActionYmlBrandingColor)
|
|
339
|
+
}) {};
|
|
340
|
+
/**
|
|
341
|
+
* A decoded `action.yml`, per GitHub's metadata syntax for actions.
|
|
342
|
+
*
|
|
343
|
+
* @remarks
|
|
344
|
+
* Keys it does not model are dropped rather than rejected. Parse the file with `Yaml.parse` from `@effected/yaml`,
|
|
345
|
+
* then decode the document with this schema.
|
|
346
|
+
*
|
|
347
|
+
* @public
|
|
348
|
+
*/
|
|
349
|
+
var ActionYml = class extends Schema.Class("ActionYml")({
|
|
350
|
+
/** The action's name. */
|
|
351
|
+
name: Schema.String,
|
|
352
|
+
/** What the action does. */
|
|
353
|
+
description: Schema.String,
|
|
354
|
+
/** The action's author. */
|
|
355
|
+
author: Schema.optionalKey(Schema.String),
|
|
356
|
+
/** The inputs, by name. */
|
|
357
|
+
inputs: Schema.optionalKey(Schema.Record(Schema.String, ActionYmlInput)),
|
|
358
|
+
/** The outputs, by name. */
|
|
359
|
+
outputs: Schema.optionalKey(Schema.Record(Schema.String, ActionYmlOutput)),
|
|
360
|
+
/** How the action runs. */
|
|
361
|
+
runs: ActionYmlRuns,
|
|
362
|
+
/** The Marketplace branding. */
|
|
363
|
+
branding: Schema.optionalKey(ActionYmlBranding)
|
|
364
|
+
}) {};
|
|
365
|
+
|
|
366
|
+
export { ActionYml, ActionYmlBranding, ActionYmlBrandingColor, ActionYmlBrandingIcon, ActionYmlInput, ActionYmlOutput, ActionYmlRuns };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { ActionYmlPathError, PersistLocalError } from "./ActionErrors.js";
|
|
2
|
+
import { Effect, FileSystem, Path, Result, Schema } from "effect";
|
|
3
|
+
import { Yaml } from "@effected/yaml";
|
|
4
|
+
|
|
5
|
+
// src/action/PersistLocal.ts
|
|
6
|
+
/**
|
|
7
|
+
* What a persist did.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
var PersistLocalResult = class extends Schema.Class("PersistLocalResult")({
|
|
12
|
+
/** Files copied because they were new or changed. */
|
|
13
|
+
filesCopied: Schema.Number,
|
|
14
|
+
/** Files left alone because they matched. */
|
|
15
|
+
filesSkipped: Schema.Number,
|
|
16
|
+
/** Whether an act template file was generated. */
|
|
17
|
+
actTemplateGenerated: Schema.Boolean,
|
|
18
|
+
/** The local action directory. */
|
|
19
|
+
outputPath: Schema.String
|
|
20
|
+
}) {};
|
|
21
|
+
const ACTRC_CONTENT = `--container-architecture linux/amd64
|
|
22
|
+
-W .github/workflows/act-test.yml
|
|
23
|
+
`;
|
|
24
|
+
const ACT_WORKFLOW_CONTENT = `name: Local Test
|
|
25
|
+
on:
|
|
26
|
+
workflow_dispatch:
|
|
27
|
+
|
|
28
|
+
jobs:
|
|
29
|
+
test:
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v7
|
|
33
|
+
- uses: ./.github/actions/local
|
|
34
|
+
`;
|
|
35
|
+
const sameBytes = (a, b) => a.length === b.length && a.every((byte, index) => byte === b[index]);
|
|
36
|
+
/** Copies `from` over `to` unless they already match, and says whether it copied. */
|
|
37
|
+
const syncFile = Effect.fnUntraced(function* (from, to) {
|
|
38
|
+
const fs = yield* FileSystem.FileSystem;
|
|
39
|
+
const path = yield* Path.Path;
|
|
40
|
+
if ((yield* fs.exists(to)) && sameBytes(yield* fs.readFile(from), yield* fs.readFile(to))) return false;
|
|
41
|
+
yield* fs.makeDirectory(path.dirname(to), { recursive: true });
|
|
42
|
+
yield* fs.copyFile(from, to);
|
|
43
|
+
return true;
|
|
44
|
+
});
|
|
45
|
+
/** Every file under `directory`, relative to `base`. */
|
|
46
|
+
const walk = (directory, base) => Effect.gen(function* () {
|
|
47
|
+
const fs = yield* FileSystem.FileSystem;
|
|
48
|
+
const path = yield* Path.Path;
|
|
49
|
+
if (!(yield* fs.exists(directory))) return [];
|
|
50
|
+
const files = [];
|
|
51
|
+
for (const name of yield* fs.readDirectory(directory)) {
|
|
52
|
+
const full = path.join(directory, name);
|
|
53
|
+
if ((yield* fs.stat(full)).type === "Directory") files.push(...yield* walk(full, base));
|
|
54
|
+
else files.push(path.relative(base, full));
|
|
55
|
+
}
|
|
56
|
+
return files;
|
|
57
|
+
});
|
|
58
|
+
/** Removes a file and each parent up to `root` that it leaves empty. */
|
|
59
|
+
const removeStale = Effect.fnUntraced(function* (file, root) {
|
|
60
|
+
const fs = yield* FileSystem.FileSystem;
|
|
61
|
+
const path = yield* Path.Path;
|
|
62
|
+
yield* fs.remove(file, { force: true });
|
|
63
|
+
let parent = path.dirname(file);
|
|
64
|
+
while (parent !== root && (yield* fs.exists(parent)) && (yield* fs.readDirectory(parent)).length === 0) {
|
|
65
|
+
yield* fs.remove(parent, { recursive: true });
|
|
66
|
+
parent = path.dirname(parent);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
/** Makes `to` match `from`: copies what is new or changed, and removes what `from` no longer has. */
|
|
70
|
+
const syncDirectory = Effect.fnUntraced(function* (from, to) {
|
|
71
|
+
const path = yield* Path.Path;
|
|
72
|
+
const sourceFiles = yield* walk(from, from);
|
|
73
|
+
let copied = 0;
|
|
74
|
+
let skipped = 0;
|
|
75
|
+
for (const file of sourceFiles) if (yield* syncFile(path.join(from, file), path.join(to, file))) copied++;
|
|
76
|
+
else skipped++;
|
|
77
|
+
const sources = new Set(sourceFiles);
|
|
78
|
+
for (const file of yield* walk(to, to)) if (!sources.has(file)) yield* removeStale(path.join(to, file), to);
|
|
79
|
+
return {
|
|
80
|
+
copied,
|
|
81
|
+
skipped
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
/** Fails when a `runs` path in the persisted `action.yml` names no persisted file. */
|
|
85
|
+
const checkRunsPaths = Effect.fnUntraced(function* (actionYml, outputPath) {
|
|
86
|
+
const fs = yield* FileSystem.FileSystem;
|
|
87
|
+
const path = yield* Path.Path;
|
|
88
|
+
if (!(yield* fs.exists(actionYml))) return;
|
|
89
|
+
const parsed = Yaml.parseResult(yield* fs.readFileString(actionYml));
|
|
90
|
+
if (Result.isFailure(parsed)) return;
|
|
91
|
+
const runs = parsed.success?.runs;
|
|
92
|
+
if (runs === void 0 || runs === null) return;
|
|
93
|
+
for (const entryType of [
|
|
94
|
+
"main",
|
|
95
|
+
"pre",
|
|
96
|
+
"post"
|
|
97
|
+
]) {
|
|
98
|
+
const specifiedPath = runs[entryType];
|
|
99
|
+
if (typeof specifiedPath !== "string" || specifiedPath.length === 0) continue;
|
|
100
|
+
const expectedPath = path.resolve(outputPath, specifiedPath);
|
|
101
|
+
if (!(yield* fs.exists(expectedPath))) return yield* new ActionYmlPathError({
|
|
102
|
+
entryType,
|
|
103
|
+
specifiedPath,
|
|
104
|
+
expectedPath
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
/** Writes `content` at `file` unless the file exists, and says whether it wrote. */
|
|
109
|
+
const writeIfAbsent = Effect.fnUntraced(function* (file, content) {
|
|
110
|
+
const fs = yield* FileSystem.FileSystem;
|
|
111
|
+
const path = yield* Path.Path;
|
|
112
|
+
if (yield* fs.exists(file)) return false;
|
|
113
|
+
yield* fs.makeDirectory(path.dirname(file), { recursive: true });
|
|
114
|
+
yield* fs.writeFileString(file, content);
|
|
115
|
+
return true;
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* Copies an action's build to a local action directory, for testing with nektos/act.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
var PersistLocal = class {
|
|
123
|
+
constructor() {}
|
|
124
|
+
/**
|
|
125
|
+
* Makes `persistLocal.path` hold the action's `action.yml` and `dist/`, and generates the act template.
|
|
126
|
+
*
|
|
127
|
+
* @remarks
|
|
128
|
+
* It writes nothing when `persistLocal.enabled` is false. Files that match are left alone, and files the source no
|
|
129
|
+
* longer has are removed. A `.actrc` and `.github/workflows/act-test.yml` that already exist are kept. A `runs` path
|
|
130
|
+
* in `action.yml` that names no persisted file fails {@link ActionYmlPathError}.
|
|
131
|
+
*
|
|
132
|
+
* @param options - `cwd` is the action's directory.
|
|
133
|
+
*/
|
|
134
|
+
static persist = Effect.fn("PersistLocal.persist")(function* (config, options) {
|
|
135
|
+
const fs = yield* FileSystem.FileSystem;
|
|
136
|
+
const path = yield* Path.Path;
|
|
137
|
+
const { enabled, actTemplate } = config.persistLocal;
|
|
138
|
+
const outputPath = path.resolve(options.cwd, config.persistLocal.path);
|
|
139
|
+
if (!enabled) return PersistLocalResult.make({
|
|
140
|
+
filesCopied: 0,
|
|
141
|
+
filesSkipped: 0,
|
|
142
|
+
actTemplateGenerated: false,
|
|
143
|
+
outputPath
|
|
144
|
+
});
|
|
145
|
+
const failingAt = (at) => Effect.mapError((cause) => new PersistLocalError({
|
|
146
|
+
path: at,
|
|
147
|
+
cause
|
|
148
|
+
}));
|
|
149
|
+
yield* fs.makeDirectory(outputPath, { recursive: true }).pipe(failingAt(outputPath));
|
|
150
|
+
let filesCopied = 0;
|
|
151
|
+
let filesSkipped = 0;
|
|
152
|
+
const actionYml = path.resolve(options.cwd, "action.yml");
|
|
153
|
+
const persistedActionYml = path.resolve(outputPath, "action.yml");
|
|
154
|
+
if (yield* fs.exists(actionYml).pipe(failingAt(actionYml))) {
|
|
155
|
+
if (yield* syncFile(actionYml, persistedActionYml).pipe(failingAt(actionYml))) filesCopied++;
|
|
156
|
+
else filesSkipped++;
|
|
157
|
+
} else yield* fs.remove(persistedActionYml, { force: true }).pipe(failingAt(persistedActionYml));
|
|
158
|
+
const dist = path.resolve(options.cwd, "dist");
|
|
159
|
+
if (yield* Effect.gen(function* () {
|
|
160
|
+
return (yield* fs.exists(dist)) && (yield* fs.stat(dist)).type === "Directory";
|
|
161
|
+
}).pipe(failingAt(dist))) {
|
|
162
|
+
const synced = yield* syncDirectory(dist, path.resolve(outputPath, "dist")).pipe(failingAt(dist));
|
|
163
|
+
filesCopied += synced.copied;
|
|
164
|
+
filesSkipped += synced.skipped;
|
|
165
|
+
}
|
|
166
|
+
yield* checkRunsPaths(persistedActionYml, outputPath).pipe(Effect.catchTag("PlatformError", (cause) => Effect.fail(new PersistLocalError({
|
|
167
|
+
path: persistedActionYml,
|
|
168
|
+
cause
|
|
169
|
+
}))));
|
|
170
|
+
let actTemplateGenerated = false;
|
|
171
|
+
if (actTemplate) {
|
|
172
|
+
const actrc = path.resolve(options.cwd, ".actrc");
|
|
173
|
+
const workflow = path.resolve(options.cwd, ".github/workflows/act-test.yml");
|
|
174
|
+
if (yield* writeIfAbsent(actrc, ACTRC_CONTENT).pipe(failingAt(actrc))) actTemplateGenerated = true;
|
|
175
|
+
if (yield* writeIfAbsent(workflow, ACT_WORKFLOW_CONTENT).pipe(failingAt(workflow))) actTemplateGenerated = true;
|
|
176
|
+
}
|
|
177
|
+
return PersistLocalResult.make({
|
|
178
|
+
filesCopied,
|
|
179
|
+
filesSkipped,
|
|
180
|
+
actTemplateGenerated,
|
|
181
|
+
outputPath
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export { PersistLocal, PersistLocalResult };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/action/entries.ts
|
|
2
|
+
/** The bundle names the action lifecycle owns, which a worker must not take. */
|
|
3
|
+
const RESERVED_ENTRY_NAMES = /* @__PURE__ */ new Set([
|
|
4
|
+
"main",
|
|
5
|
+
"pre",
|
|
6
|
+
"post"
|
|
7
|
+
]);
|
|
8
|
+
/**
|
|
9
|
+
* Why a worker name cannot be used, if it cannot.
|
|
10
|
+
*
|
|
11
|
+
* A worker's name becomes the emitted filename, so it must not collide with a lifecycle bundle or escape `dist/`.
|
|
12
|
+
*/
|
|
13
|
+
const invalidWorkerName = (name) => {
|
|
14
|
+
if (RESERVED_ENTRY_NAMES.has(name)) return `"${name}" is a reserved lifecycle bundle name (main/pre/post)`;
|
|
15
|
+
return name.length === 0 || name.includes("/") || name.includes("\\") || name.includes("..") ? "worker names must be non-empty and free of path separators" : void 0;
|
|
16
|
+
};
|
|
17
|
+
/** Where `pre` and `post` are looked for when the config names neither. */
|
|
18
|
+
const DEFAULT_LIFECYCLE_ENTRIES = {
|
|
19
|
+
pre: "src/pre.ts",
|
|
20
|
+
post: "src/post.ts"
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { DEFAULT_LIFECYCLE_ENTRIES, invalidWorkerName };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/action/ignore-stub-plugin.ts
|
|
2
|
+
const STUB_PREFIX = "\0effected-action-ignore:";
|
|
3
|
+
/**
|
|
4
|
+
* Replaces each ignored package with a virtual module that throws when it is loaded.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* A guarded `require` or `import()` of the package then sees it as unavailable. The module is virtual and its id names
|
|
8
|
+
* only the package, so no path reaches the bundle and the output does not depend on where it is built.
|
|
9
|
+
*/
|
|
10
|
+
const ignoreStubPlugin = (ignored) => ({
|
|
11
|
+
name: "effected-action-ignore",
|
|
12
|
+
resolveId(source) {
|
|
13
|
+
return ignored.includes(source) ? {
|
|
14
|
+
id: `${STUB_PREFIX}${source}`,
|
|
15
|
+
moduleSideEffects: true
|
|
16
|
+
} : null;
|
|
17
|
+
},
|
|
18
|
+
load(id) {
|
|
19
|
+
if (!id.startsWith(STUB_PREFIX)) return null;
|
|
20
|
+
const message = `${id.slice(24)} is excluded via the build 'ignore' option and was loaded at runtime.`;
|
|
21
|
+
return `throw new Error(${JSON.stringify(message)});\n`;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { ignoreStubPlugin };
|