@savvy-web/github-action-builder 1.1.2 → 2.0.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/bin/github-action-builder.js +13 -18
- package/cli/commands/build.js +5 -5
- package/cli/commands/init.js +4 -4
- package/cli/commands/validate.js +1 -1
- package/github-action.js +3 -3
- package/index.d.ts +248 -272
- package/package.json +7 -14
- package/schemas/action-yml.js +272 -10
- package/schemas/config.js +13 -19
- package/schemas/path.js +7 -4
- package/services/build-live.js +5 -5
- package/services/build.js +22 -2
- package/services/config.js +21 -3
- package/services/persist-local-live.js +3 -2
- package/services/persist-local.js +2 -2
- package/services/validation-live.js +18 -17
- package/services/validation.js +22 -2
- package/tsdoc-metadata.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/github-action-builder",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A zero-config build tool for creating GitHub Actions from TypeScript. Bundles with rsbuild, validates action.yml against GitHub's schema, and outputs production-ready Node.js 24 actions.",
|
|
6
6
|
"keywords": [
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|
|
39
39
|
"types": "./index.d.ts",
|
|
40
|
-
"import": "./index.js"
|
|
40
|
+
"import": "./index.js",
|
|
41
|
+
"default": "./index.js"
|
|
41
42
|
},
|
|
42
43
|
"./tsconfig/action.json": "./tsconfig/action.json",
|
|
43
44
|
"./loaders/webpack-ignore-dynamic-imports.cjs": "./loaders/webpack-ignore-dynamic-imports.cjs",
|
|
@@ -47,20 +48,12 @@
|
|
|
47
48
|
"github-action-builder": "bin/github-action-builder.js"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"@effect/
|
|
51
|
-
"@
|
|
52
|
-
"@effect/platform": "^0.96.2",
|
|
53
|
-
"@effect/platform-node": "^0.107.0",
|
|
54
|
-
"@effect/printer": "^0.49.0",
|
|
55
|
-
"@effect/printer-ansi": "^0.49.0",
|
|
56
|
-
"@effect/rpc": "^0.75.1",
|
|
57
|
-
"@effect/sql": "^0.51.1",
|
|
58
|
-
"@effect/typeclass": "^0.40.0",
|
|
51
|
+
"@effect/platform-node": "4.0.0-beta.98",
|
|
52
|
+
"@effected/yaml": "^0.2.0",
|
|
59
53
|
"@rsbuild/core": "^2.1.5",
|
|
60
|
-
"effect": "
|
|
54
|
+
"effect": "4.0.0-beta.98",
|
|
61
55
|
"jiti": "^2.7.0",
|
|
62
|
-
"picocolors": "^1.1.1"
|
|
63
|
-
"yaml-effect": "^0.7.2"
|
|
56
|
+
"picocolors": "^1.1.1"
|
|
64
57
|
},
|
|
65
58
|
"peerDependencies": {
|
|
66
59
|
"@types/node": "^26.1.0",
|
package/schemas/action-yml.js
CHANGED
|
@@ -21,7 +21,265 @@ import { Schema } from "effect";
|
|
|
21
21
|
*
|
|
22
22
|
* @internal
|
|
23
23
|
*/
|
|
24
|
-
const BrandingIcon = Schema.
|
|
24
|
+
const BrandingIcon = Schema.Literals([
|
|
25
|
+
"activity",
|
|
26
|
+
"airplay",
|
|
27
|
+
"alert-circle",
|
|
28
|
+
"alert-octagon",
|
|
29
|
+
"alert-triangle",
|
|
30
|
+
"align-center",
|
|
31
|
+
"align-justify",
|
|
32
|
+
"align-left",
|
|
33
|
+
"align-right",
|
|
34
|
+
"anchor",
|
|
35
|
+
"aperture",
|
|
36
|
+
"archive",
|
|
37
|
+
"arrow-down-circle",
|
|
38
|
+
"arrow-down-left",
|
|
39
|
+
"arrow-down-right",
|
|
40
|
+
"arrow-down",
|
|
41
|
+
"arrow-left-circle",
|
|
42
|
+
"arrow-left",
|
|
43
|
+
"arrow-right-circle",
|
|
44
|
+
"arrow-right",
|
|
45
|
+
"arrow-up-circle",
|
|
46
|
+
"arrow-up-left",
|
|
47
|
+
"arrow-up-right",
|
|
48
|
+
"arrow-up",
|
|
49
|
+
"at-sign",
|
|
50
|
+
"award",
|
|
51
|
+
"bar-chart-2",
|
|
52
|
+
"bar-chart",
|
|
53
|
+
"battery-charging",
|
|
54
|
+
"battery",
|
|
55
|
+
"bell-off",
|
|
56
|
+
"bell",
|
|
57
|
+
"bluetooth",
|
|
58
|
+
"bold",
|
|
59
|
+
"book-open",
|
|
60
|
+
"book",
|
|
61
|
+
"bookmark",
|
|
62
|
+
"box",
|
|
63
|
+
"briefcase",
|
|
64
|
+
"calendar",
|
|
65
|
+
"camera-off",
|
|
66
|
+
"camera",
|
|
67
|
+
"cast",
|
|
68
|
+
"check-circle",
|
|
69
|
+
"check-square",
|
|
70
|
+
"check",
|
|
71
|
+
"chevron-down",
|
|
72
|
+
"chevron-left",
|
|
73
|
+
"chevron-right",
|
|
74
|
+
"chevron-up",
|
|
75
|
+
"chevrons-down",
|
|
76
|
+
"chevrons-left",
|
|
77
|
+
"chevrons-right",
|
|
78
|
+
"chevrons-up",
|
|
79
|
+
"circle",
|
|
80
|
+
"clipboard",
|
|
81
|
+
"clock",
|
|
82
|
+
"cloud-drizzle",
|
|
83
|
+
"cloud-lightning",
|
|
84
|
+
"cloud-off",
|
|
85
|
+
"cloud-rain",
|
|
86
|
+
"cloud-snow",
|
|
87
|
+
"cloud",
|
|
88
|
+
"code",
|
|
89
|
+
"command",
|
|
90
|
+
"compass",
|
|
91
|
+
"copy",
|
|
92
|
+
"corner-down-left",
|
|
93
|
+
"corner-down-right",
|
|
94
|
+
"corner-left-down",
|
|
95
|
+
"corner-left-up",
|
|
96
|
+
"corner-right-down",
|
|
97
|
+
"corner-right-up",
|
|
98
|
+
"corner-up-left",
|
|
99
|
+
"corner-up-right",
|
|
100
|
+
"cpu",
|
|
101
|
+
"credit-card",
|
|
102
|
+
"crop",
|
|
103
|
+
"crosshair",
|
|
104
|
+
"database",
|
|
105
|
+
"delete",
|
|
106
|
+
"disc",
|
|
107
|
+
"dollar-sign",
|
|
108
|
+
"download-cloud",
|
|
109
|
+
"download",
|
|
110
|
+
"droplet",
|
|
111
|
+
"edit-2",
|
|
112
|
+
"edit-3",
|
|
113
|
+
"edit",
|
|
114
|
+
"external-link",
|
|
115
|
+
"eye-off",
|
|
116
|
+
"eye",
|
|
117
|
+
"fast-forward",
|
|
118
|
+
"feather",
|
|
119
|
+
"file-minus",
|
|
120
|
+
"file-plus",
|
|
121
|
+
"file-text",
|
|
122
|
+
"file",
|
|
123
|
+
"film",
|
|
124
|
+
"filter",
|
|
125
|
+
"flag",
|
|
126
|
+
"folder-minus",
|
|
127
|
+
"folder-plus",
|
|
128
|
+
"folder",
|
|
129
|
+
"gift",
|
|
130
|
+
"git-branch",
|
|
131
|
+
"git-commit",
|
|
132
|
+
"git-merge",
|
|
133
|
+
"git-pull-request",
|
|
134
|
+
"globe",
|
|
135
|
+
"grid",
|
|
136
|
+
"hard-drive",
|
|
137
|
+
"hash",
|
|
138
|
+
"headphones",
|
|
139
|
+
"heart",
|
|
140
|
+
"help-circle",
|
|
141
|
+
"home",
|
|
142
|
+
"image",
|
|
143
|
+
"inbox",
|
|
144
|
+
"info",
|
|
145
|
+
"italic",
|
|
146
|
+
"layers",
|
|
147
|
+
"layout",
|
|
148
|
+
"life-buoy",
|
|
149
|
+
"link-2",
|
|
150
|
+
"link",
|
|
151
|
+
"list",
|
|
152
|
+
"loader",
|
|
153
|
+
"lock",
|
|
154
|
+
"log-in",
|
|
155
|
+
"log-out",
|
|
156
|
+
"mail",
|
|
157
|
+
"map-pin",
|
|
158
|
+
"map",
|
|
159
|
+
"maximize-2",
|
|
160
|
+
"maximize",
|
|
161
|
+
"menu",
|
|
162
|
+
"message-circle",
|
|
163
|
+
"message-square",
|
|
164
|
+
"mic-off",
|
|
165
|
+
"mic",
|
|
166
|
+
"minimize-2",
|
|
167
|
+
"minimize",
|
|
168
|
+
"minus-circle",
|
|
169
|
+
"minus-square",
|
|
170
|
+
"minus",
|
|
171
|
+
"monitor",
|
|
172
|
+
"moon",
|
|
173
|
+
"more-horizontal",
|
|
174
|
+
"more-vertical",
|
|
175
|
+
"move",
|
|
176
|
+
"music",
|
|
177
|
+
"navigation-2",
|
|
178
|
+
"navigation",
|
|
179
|
+
"octagon",
|
|
180
|
+
"package",
|
|
181
|
+
"paperclip",
|
|
182
|
+
"pause-circle",
|
|
183
|
+
"pause",
|
|
184
|
+
"percent",
|
|
185
|
+
"phone-call",
|
|
186
|
+
"phone-forwarded",
|
|
187
|
+
"phone-incoming",
|
|
188
|
+
"phone-missed",
|
|
189
|
+
"phone-off",
|
|
190
|
+
"phone-outgoing",
|
|
191
|
+
"phone",
|
|
192
|
+
"pie-chart",
|
|
193
|
+
"play-circle",
|
|
194
|
+
"play",
|
|
195
|
+
"plus-circle",
|
|
196
|
+
"plus-square",
|
|
197
|
+
"plus",
|
|
198
|
+
"pocket",
|
|
199
|
+
"power",
|
|
200
|
+
"printer",
|
|
201
|
+
"radio",
|
|
202
|
+
"refresh-ccw",
|
|
203
|
+
"refresh-cw",
|
|
204
|
+
"repeat",
|
|
205
|
+
"rewind",
|
|
206
|
+
"rotate-ccw",
|
|
207
|
+
"rotate-cw",
|
|
208
|
+
"rss",
|
|
209
|
+
"save",
|
|
210
|
+
"scissors",
|
|
211
|
+
"search",
|
|
212
|
+
"send",
|
|
213
|
+
"server",
|
|
214
|
+
"settings",
|
|
215
|
+
"share-2",
|
|
216
|
+
"share",
|
|
217
|
+
"shield-off",
|
|
218
|
+
"shield",
|
|
219
|
+
"shopping-bag",
|
|
220
|
+
"shopping-cart",
|
|
221
|
+
"shuffle",
|
|
222
|
+
"sidebar",
|
|
223
|
+
"skip-back",
|
|
224
|
+
"skip-forward",
|
|
225
|
+
"slash",
|
|
226
|
+
"sliders",
|
|
227
|
+
"smartphone",
|
|
228
|
+
"speaker",
|
|
229
|
+
"square",
|
|
230
|
+
"star",
|
|
231
|
+
"stop-circle",
|
|
232
|
+
"sun",
|
|
233
|
+
"sunrise",
|
|
234
|
+
"sunset",
|
|
235
|
+
"table",
|
|
236
|
+
"tablet",
|
|
237
|
+
"tag",
|
|
238
|
+
"target",
|
|
239
|
+
"terminal",
|
|
240
|
+
"thermometer",
|
|
241
|
+
"thumbs-down",
|
|
242
|
+
"thumbs-up",
|
|
243
|
+
"toggle-left",
|
|
244
|
+
"toggle-right",
|
|
245
|
+
"trash-2",
|
|
246
|
+
"trash",
|
|
247
|
+
"trending-down",
|
|
248
|
+
"trending-up",
|
|
249
|
+
"triangle",
|
|
250
|
+
"truck",
|
|
251
|
+
"tv",
|
|
252
|
+
"type",
|
|
253
|
+
"umbrella",
|
|
254
|
+
"underline",
|
|
255
|
+
"unlock",
|
|
256
|
+
"upload-cloud",
|
|
257
|
+
"upload",
|
|
258
|
+
"user-check",
|
|
259
|
+
"user-minus",
|
|
260
|
+
"user-plus",
|
|
261
|
+
"user-x",
|
|
262
|
+
"user",
|
|
263
|
+
"users",
|
|
264
|
+
"video-off",
|
|
265
|
+
"video",
|
|
266
|
+
"voicemail",
|
|
267
|
+
"volume-1",
|
|
268
|
+
"volume-2",
|
|
269
|
+
"volume-x",
|
|
270
|
+
"volume",
|
|
271
|
+
"watch",
|
|
272
|
+
"wifi-off",
|
|
273
|
+
"wifi",
|
|
274
|
+
"wind",
|
|
275
|
+
"x-circle",
|
|
276
|
+
"x-square",
|
|
277
|
+
"x",
|
|
278
|
+
"zap-off",
|
|
279
|
+
"zap",
|
|
280
|
+
"zoom-in",
|
|
281
|
+
"zoom-out"
|
|
282
|
+
]);
|
|
25
283
|
/**
|
|
26
284
|
* Schema for action input definition.
|
|
27
285
|
*
|
|
@@ -70,7 +328,17 @@ const Runs = Schema.Struct({
|
|
|
70
328
|
*
|
|
71
329
|
* @internal
|
|
72
330
|
*/
|
|
73
|
-
const BrandingColor = Schema.
|
|
331
|
+
const BrandingColor = Schema.Literals([
|
|
332
|
+
"white",
|
|
333
|
+
"black",
|
|
334
|
+
"yellow",
|
|
335
|
+
"blue",
|
|
336
|
+
"green",
|
|
337
|
+
"orange",
|
|
338
|
+
"red",
|
|
339
|
+
"purple",
|
|
340
|
+
"gray-dark"
|
|
341
|
+
]);
|
|
74
342
|
/**
|
|
75
343
|
* Schema for branding configuration.
|
|
76
344
|
* @internal
|
|
@@ -94,14 +362,8 @@ const ActionYml = Schema.Struct({
|
|
|
94
362
|
name: Schema.String,
|
|
95
363
|
description: Schema.String,
|
|
96
364
|
author: Schema.optional(Schema.String),
|
|
97
|
-
inputs: Schema.optional(Schema.Record(
|
|
98
|
-
|
|
99
|
-
value: ActionInput
|
|
100
|
-
})),
|
|
101
|
-
outputs: Schema.optional(Schema.Record({
|
|
102
|
-
key: Schema.String,
|
|
103
|
-
value: ActionOutput
|
|
104
|
-
})),
|
|
365
|
+
inputs: Schema.optional(Schema.Record(Schema.String, ActionInput)),
|
|
366
|
+
outputs: Schema.optional(Schema.Record(Schema.String, ActionOutput)),
|
|
105
367
|
runs: Runs,
|
|
106
368
|
branding: Schema.optional(Branding)
|
|
107
369
|
});
|
package/schemas/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
2
|
|
|
3
3
|
//#region src/schemas/config.ts
|
|
4
4
|
/**
|
|
@@ -26,16 +26,13 @@ import { Schema } from "effect";
|
|
|
26
26
|
*/
|
|
27
27
|
const EntriesSchema = Schema.Struct({
|
|
28
28
|
/** Path to the main action entry point. Defaults to "src/main.ts". */
|
|
29
|
-
main: Schema.
|
|
29
|
+
main: Schema.String.pipe(Schema.withDecodingDefaultType(Effect.succeed("src/main.ts"))),
|
|
30
30
|
/** Path to the pre-action hook entry point. */
|
|
31
31
|
pre: Schema.optional(Schema.String),
|
|
32
32
|
/** Path to the post-action hook entry point. */
|
|
33
33
|
post: Schema.optional(Schema.String),
|
|
34
34
|
/** Extra non-lifecycle worker bundles (name -\> source path), each emitted as dist/\{name\}.js. */
|
|
35
|
-
workers: Schema.optional(Schema.Record(
|
|
36
|
-
key: Schema.String,
|
|
37
|
-
value: Schema.String
|
|
38
|
-
}))
|
|
35
|
+
workers: Schema.optional(Schema.Record(Schema.String, Schema.String))
|
|
39
36
|
});
|
|
40
37
|
/**
|
|
41
38
|
* Schema for build options.
|
|
@@ -48,13 +45,13 @@ const EntriesSchema = Schema.Struct({
|
|
|
48
45
|
*/
|
|
49
46
|
const BuildOptionsSchema = Schema.Struct({
|
|
50
47
|
/** Enable minification to reduce bundle size. Defaults to true. */
|
|
51
|
-
minify: Schema.
|
|
48
|
+
minify: Schema.Boolean.pipe(Schema.withDecodingDefaultType(Effect.succeed(true))),
|
|
52
49
|
/** Generate source maps for debugging. Defaults to false. */
|
|
53
|
-
sourceMap: Schema.
|
|
50
|
+
sourceMap: Schema.Boolean.pipe(Schema.withDecodingDefaultType(Effect.succeed(false))),
|
|
54
51
|
/** Packages to exclude from the bundle (in addition to node: builtins). Defaults to []. */
|
|
55
|
-
externals: Schema.
|
|
52
|
+
externals: Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultType(Effect.succeed([]))),
|
|
56
53
|
/** Packages to exclude from the bundle and replace with a stub that throws if loaded at runtime. Use for optional transitive dependencies the action never exercises (e.g. native modules). Defaults to []. */
|
|
57
|
-
ignore: Schema.
|
|
54
|
+
ignore: Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultType(Effect.succeed([]))),
|
|
58
55
|
/**
|
|
59
56
|
* Packages whose dynamic `import(...)` calls must stay native `import()` at runtime instead of
|
|
60
57
|
* being compiled into an rspack context module. Use this for packages that resolve a module path
|
|
@@ -64,7 +61,7 @@ const BuildOptionsSchema = Schema.Struct({
|
|
|
64
61
|
* the package here injects a `webpackIgnore` comment into its dynamic imports so rspack leaves
|
|
65
62
|
* them alone. Defaults to [].
|
|
66
63
|
*/
|
|
67
|
-
nativeDynamicImports: Schema.
|
|
64
|
+
nativeDynamicImports: Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultType(Effect.succeed([])))
|
|
68
65
|
});
|
|
69
66
|
/**
|
|
70
67
|
* Schema for validation options.
|
|
@@ -77,7 +74,7 @@ const BuildOptionsSchema = Schema.Struct({
|
|
|
77
74
|
*/
|
|
78
75
|
const ValidationOptionsSchema = Schema.Struct({
|
|
79
76
|
/** Require action.yml to exist and be valid. Defaults to true. */
|
|
80
|
-
requireActionYml: Schema.
|
|
77
|
+
requireActionYml: Schema.Boolean.pipe(Schema.withDecodingDefaultType(Effect.succeed(true))),
|
|
81
78
|
/** Maximum bundle size before warning/error (e.g., "5mb", "500kb"). */
|
|
82
79
|
maxBundleSize: Schema.optional(Schema.String),
|
|
83
80
|
/** Treat warnings as errors. Auto-detects from CI when undefined. */
|
|
@@ -94,11 +91,11 @@ const ValidationOptionsSchema = Schema.Struct({
|
|
|
94
91
|
*/
|
|
95
92
|
const PersistLocalOptionsSchema = Schema.Struct({
|
|
96
93
|
/** Enable persisting build output locally. Defaults to true. */
|
|
97
|
-
enabled: Schema.
|
|
94
|
+
enabled: Schema.Boolean.pipe(Schema.withDecodingDefaultType(Effect.succeed(true))),
|
|
98
95
|
/** Path for the local action directory, relative to cwd. Defaults to ".github/actions/local". */
|
|
99
|
-
path: Schema.
|
|
96
|
+
path: Schema.String.pipe(Schema.withDecodingDefaultType(Effect.succeed(".github/actions/local"))),
|
|
100
97
|
/** Generate act boilerplate files (.actrc, act-test.yml) if they don't exist. Defaults to true. */
|
|
101
|
-
actTemplate: Schema.
|
|
98
|
+
actTemplate: Schema.Boolean.pipe(Schema.withDecodingDefaultType(Effect.succeed(true)))
|
|
102
99
|
});
|
|
103
100
|
/**
|
|
104
101
|
* User-provided configuration input (all fields optional).
|
|
@@ -114,10 +111,7 @@ const ConfigInputSchema = Schema.Struct({
|
|
|
114
111
|
main: Schema.optional(Schema.String),
|
|
115
112
|
pre: Schema.optional(Schema.String),
|
|
116
113
|
post: Schema.optional(Schema.String),
|
|
117
|
-
workers: Schema.optional(Schema.Record(
|
|
118
|
-
key: Schema.String,
|
|
119
|
-
value: Schema.String
|
|
120
|
-
}))
|
|
114
|
+
workers: Schema.optional(Schema.Record(Schema.String, Schema.String))
|
|
121
115
|
})),
|
|
122
116
|
build: Schema.optional(Schema.Struct({
|
|
123
117
|
minify: Schema.optional(Schema.Boolean),
|
package/schemas/path.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { Schema, SchemaTransformation } from "effect";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
|
|
4
4
|
//#region src/schemas/path.ts
|
|
@@ -27,12 +27,15 @@ function pathLikeToString(pathLike) {
|
|
|
27
27
|
*
|
|
28
28
|
* @internal
|
|
29
29
|
*/
|
|
30
|
-
const PathLikeSchema = Schema.
|
|
31
|
-
|
|
30
|
+
const PathLikeSchema = Schema.Union([
|
|
31
|
+
Schema.String,
|
|
32
|
+
Schema.instanceOf(Buffer),
|
|
33
|
+
Schema.instanceOf(URL)
|
|
34
|
+
]).pipe(Schema.decodeTo(Schema.String, SchemaTransformation.transform({
|
|
32
35
|
decode: (pathLike) => pathLikeToString(pathLike),
|
|
33
36
|
/* v8 ignore next */
|
|
34
37
|
encode: (s) => s
|
|
35
|
-
});
|
|
38
|
+
})));
|
|
36
39
|
/**
|
|
37
40
|
* Optional PathLike schema.
|
|
38
41
|
* @internal
|
package/services/build-live.js
CHANGED
|
@@ -2,7 +2,7 @@ import { BundleFailed, CleanError, WriteError } from "../errors.js";
|
|
|
2
2
|
import { BuildService } from "./build.js";
|
|
3
3
|
import { ConfigService } from "./config.js";
|
|
4
4
|
import { buildNativeDynamicImportRules } from "./native-dynamic-imports.js";
|
|
5
|
-
import { Effect, Layer } from "effect";
|
|
5
|
+
import { Effect, Layer, Result } from "effect";
|
|
6
6
|
import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { resolve } from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
@@ -213,14 +213,14 @@ const BuildServiceLive = Layer.effect(BuildService, Effect.gen(function* () {
|
|
|
213
213
|
if (shouldClean) yield* cleanDirectory(resolve(cwd, "dist"));
|
|
214
214
|
const entryResults = [];
|
|
215
215
|
for (const entry of entriesResult.entries) {
|
|
216
|
-
const result = yield* Effect.
|
|
217
|
-
if (result
|
|
218
|
-
const err = result.
|
|
216
|
+
const result = yield* Effect.result(bundleEntry(entry, config, cwd));
|
|
217
|
+
if (Result.isFailure(result)) {
|
|
218
|
+
const err = result.failure;
|
|
219
219
|
entryResults.push({
|
|
220
220
|
success: false,
|
|
221
221
|
error: err.cause instanceof Error ? err.cause.message : String(err.cause)
|
|
222
222
|
});
|
|
223
|
-
} else entryResults.push(result.
|
|
223
|
+
} else entryResults.push(result.success);
|
|
224
224
|
}
|
|
225
225
|
yield* writeFile(resolve(cwd, "dist/package.json"), "{ \"type\": \"module\" }");
|
|
226
226
|
const duration = Date.now() - startTime;
|
package/services/build.js
CHANGED
|
@@ -53,11 +53,31 @@ const BuildResultSchema = Schema.Struct({
|
|
|
53
53
|
error: Schema.optional(Schema.String)
|
|
54
54
|
});
|
|
55
55
|
/**
|
|
56
|
-
* BuildService
|
|
56
|
+
* BuildService key for dependency injection.
|
|
57
|
+
*
|
|
58
|
+
* @example Using BuildService with Effect
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { Effect } from "effect";
|
|
61
|
+
* import { AppLayer, BuildService, ConfigService } from "@savvy-web/github-action-builder";
|
|
62
|
+
*
|
|
63
|
+
* const program = Effect.gen(function* () {
|
|
64
|
+
* const configService = yield* ConfigService;
|
|
65
|
+
* const buildService = yield* BuildService;
|
|
66
|
+
*
|
|
67
|
+
* const { config } = yield* configService.load();
|
|
68
|
+
* const result = yield* buildService.build(config);
|
|
69
|
+
*
|
|
70
|
+
* if (result.success) {
|
|
71
|
+
* console.log("Build complete:", result.entries.length, "entries");
|
|
72
|
+
* }
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* Effect.runPromise(program.pipe(Effect.provide(AppLayer)));
|
|
76
|
+
* ```
|
|
57
77
|
*
|
|
58
78
|
* @public
|
|
59
79
|
*/
|
|
60
|
-
|
|
80
|
+
var BuildService = class extends Context.Service()("BuildService") {};
|
|
61
81
|
|
|
62
82
|
//#endregion
|
|
63
83
|
export { BuildResultSchema, BuildRunnerOptionsSchema, BuildService, BundleResultSchema, BundleStatsSchema };
|
package/services/config.js
CHANGED
|
@@ -17,7 +17,11 @@ const LoadConfigOptionsSchema = Schema.Struct({
|
|
|
17
17
|
* Entry point type.
|
|
18
18
|
* @internal
|
|
19
19
|
*/
|
|
20
|
-
const EntryTypeSchema = Schema.
|
|
20
|
+
const EntryTypeSchema = Schema.Literals([
|
|
21
|
+
"main",
|
|
22
|
+
"pre",
|
|
23
|
+
"post"
|
|
24
|
+
]);
|
|
21
25
|
/**
|
|
22
26
|
* Detected entry point information.
|
|
23
27
|
* @public
|
|
@@ -53,11 +57,25 @@ const LoadConfigResultSchema = Schema.Struct({
|
|
|
53
57
|
usingDefaults: Schema.Boolean
|
|
54
58
|
});
|
|
55
59
|
/**
|
|
56
|
-
* ConfigService
|
|
60
|
+
* ConfigService key for dependency injection.
|
|
61
|
+
*
|
|
62
|
+
* @example Using ConfigService with Effect
|
|
63
|
+
* ```typescript
|
|
64
|
+
* import { Effect } from "effect";
|
|
65
|
+
* import { AppLayer, ConfigService } from "@savvy-web/github-action-builder";
|
|
66
|
+
*
|
|
67
|
+
* const program = Effect.gen(function* () {
|
|
68
|
+
* const configService = yield* ConfigService;
|
|
69
|
+
* const result = yield* configService.load({ cwd: process.cwd() });
|
|
70
|
+
* console.log("Loaded config:", result.config);
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* Effect.runPromise(program.pipe(Effect.provide(AppLayer)));
|
|
74
|
+
* ```
|
|
57
75
|
*
|
|
58
76
|
* @public
|
|
59
77
|
*/
|
|
60
|
-
|
|
78
|
+
var ConfigService = class extends Context.Service()("ConfigService") {};
|
|
61
79
|
|
|
62
80
|
//#endregion
|
|
63
81
|
export { ConfigService, DetectEntriesResultSchema, DetectedEntrySchema, LoadConfigOptionsSchema };
|
|
@@ -4,7 +4,7 @@ import { Effect, Layer } from "effect";
|
|
|
4
4
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join, relative, resolve } from "node:path";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
|
-
import {
|
|
7
|
+
import { Yaml } from "@effected/yaml";
|
|
8
8
|
|
|
9
9
|
//#region src/services/persist-local-live.ts
|
|
10
10
|
/**
|
|
@@ -72,7 +72,8 @@ function syncDirectory(srcDir, destDir) {
|
|
|
72
72
|
function validateActionYmlPaths(actionYmlPath, destDir) {
|
|
73
73
|
return Effect.gen(function* () {
|
|
74
74
|
if (!existsSync(actionYmlPath)) return;
|
|
75
|
-
const
|
|
75
|
+
const content = readFileSync(actionYmlPath, "utf8");
|
|
76
|
+
const parsed = yield* Yaml.parse(content).pipe(Effect.catch(() => Effect.succeed(null)));
|
|
76
77
|
if (!parsed?.runs) return;
|
|
77
78
|
for (const entryType of [
|
|
78
79
|
"main",
|
|
@@ -27,11 +27,11 @@ const PersistLocalResultSchema = Schema.Struct({
|
|
|
27
27
|
error: Schema.optional(Schema.String)
|
|
28
28
|
});
|
|
29
29
|
/**
|
|
30
|
-
* PersistLocalService
|
|
30
|
+
* PersistLocalService key for dependency injection.
|
|
31
31
|
*
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
var PersistLocalService = class extends Context.Service()("PersistLocalService") {};
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
37
|
export { PersistLocalResultSchema, PersistLocalRunnerOptionsSchema, PersistLocalService };
|