@savvy-web/github-action-builder 0.4.0 → 0.5.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/677.js +58 -47
- package/README.md +5 -4
- package/bin/github-action-builder.js +2 -3
- package/index.d.ts +8 -42
- package/package.json +5 -5
package/677.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, Data, Effect, Layer, ParseResult, Schema } from "effect";
|
|
2
2
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
3
|
import { dirname, join, relative, resolve } from "node:path";
|
|
4
|
+
import { createRsbuild } from "@rsbuild/core";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { parse } from "yaml-effect";
|
|
@@ -91,22 +91,15 @@ const EntriesSchema = Schema.Struct({
|
|
|
91
91
|
pre: Schema.optional(Schema.String),
|
|
92
92
|
post: Schema.optional(Schema.String)
|
|
93
93
|
});
|
|
94
|
-
const EsTarget = Schema.Literal("es2020", "es2021", "es2022", "es2023", "es2024");
|
|
95
94
|
const BuildOptionsSchema = Schema.Struct({
|
|
96
95
|
minify: Schema.optionalWith(Schema.Boolean, {
|
|
97
96
|
default: ()=>true
|
|
98
97
|
}),
|
|
99
|
-
target: Schema.optionalWith(EsTarget, {
|
|
100
|
-
default: ()=>"es2022"
|
|
101
|
-
}),
|
|
102
98
|
sourceMap: Schema.optionalWith(Schema.Boolean, {
|
|
103
99
|
default: ()=>false
|
|
104
100
|
}),
|
|
105
101
|
externals: Schema.optionalWith(Schema.Array(Schema.String), {
|
|
106
102
|
default: ()=>[]
|
|
107
|
-
}),
|
|
108
|
-
quiet: Schema.optionalWith(Schema.Boolean, {
|
|
109
|
-
default: ()=>false
|
|
110
103
|
})
|
|
111
104
|
});
|
|
112
105
|
const ValidationOptionsSchema = Schema.Struct({
|
|
@@ -135,10 +128,8 @@ const ConfigInputSchema = Schema.Struct({
|
|
|
135
128
|
})),
|
|
136
129
|
build: Schema.optional(Schema.Struct({
|
|
137
130
|
minify: Schema.optional(Schema.Boolean),
|
|
138
|
-
target: Schema.optional(EsTarget),
|
|
139
131
|
sourceMap: Schema.optional(Schema.Boolean),
|
|
140
|
-
externals: Schema.optional(Schema.Array(Schema.String))
|
|
141
|
-
quiet: Schema.optional(Schema.Boolean)
|
|
132
|
+
externals: Schema.optional(Schema.Array(Schema.String))
|
|
142
133
|
})),
|
|
143
134
|
validation: Schema.optional(Schema.Struct({
|
|
144
135
|
requireActionYml: Schema.optional(Schema.Boolean),
|
|
@@ -185,21 +176,6 @@ Schema.Struct({
|
|
|
185
176
|
usingDefaults: Schema.Boolean
|
|
186
177
|
});
|
|
187
178
|
const ConfigService = Context.GenericTag("ConfigService");
|
|
188
|
-
const build_live_require = createRequire(import.meta.url);
|
|
189
|
-
const ncc = build_live_require("@vercel/ncc");
|
|
190
|
-
async function bundle(entryPath, options = {}) {
|
|
191
|
-
return ncc(entryPath, {
|
|
192
|
-
minify: options.minify ?? true,
|
|
193
|
-
sourceMap: options.sourceMap ?? false,
|
|
194
|
-
target: options.target ?? "es2022",
|
|
195
|
-
quiet: options.quiet ?? true,
|
|
196
|
-
externals: options.externals ?? [],
|
|
197
|
-
...options
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
function getBundleSize(code) {
|
|
201
|
-
return Buffer.byteLength(code, "utf8");
|
|
202
|
-
}
|
|
203
179
|
function formatBytes(bytes) {
|
|
204
180
|
if (bytes < 1024) return `${bytes} B`;
|
|
205
181
|
if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
@@ -252,34 +228,69 @@ function writeFile(path, content) {
|
|
|
252
228
|
function bundleEntry(entry, config, cwd) {
|
|
253
229
|
return Effect.gen(function*() {
|
|
254
230
|
const startTime = Date.now();
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
231
|
+
const outputDir = resolve(cwd, "dist");
|
|
232
|
+
const rsbuild = yield* Effect.tryPromise({
|
|
233
|
+
try: ()=>createRsbuild({
|
|
234
|
+
rsbuildConfig: {
|
|
235
|
+
source: {
|
|
236
|
+
entry: {
|
|
237
|
+
[entry.type]: entry.path
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
output: {
|
|
241
|
+
target: "node",
|
|
242
|
+
module: true,
|
|
243
|
+
distPath: {
|
|
244
|
+
root: outputDir
|
|
245
|
+
},
|
|
246
|
+
filename: {
|
|
247
|
+
js: "[name].js"
|
|
248
|
+
},
|
|
249
|
+
externals: [
|
|
250
|
+
/^node:/,
|
|
251
|
+
...config.build.externals
|
|
252
|
+
],
|
|
253
|
+
cleanDistPath: false,
|
|
254
|
+
minify: config.build.minify,
|
|
255
|
+
sourceMap: config.build.sourceMap ? {
|
|
256
|
+
js: "source-map"
|
|
257
|
+
} : false
|
|
258
|
+
},
|
|
259
|
+
performance: {
|
|
260
|
+
chunkSplit: {
|
|
261
|
+
strategy: "all-in-one"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
264
265
|
}),
|
|
265
266
|
catch: (error)=>new BundleFailed({
|
|
266
267
|
entry: entry.path,
|
|
267
268
|
cause: error
|
|
268
269
|
})
|
|
269
270
|
});
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
271
|
+
const buildResult = yield* Effect.tryPromise({
|
|
272
|
+
try: ()=>rsbuild.build(),
|
|
273
|
+
catch: (error)=>new BundleFailed({
|
|
274
|
+
entry: entry.path,
|
|
275
|
+
cause: error
|
|
276
|
+
})
|
|
277
|
+
});
|
|
278
|
+
yield* Effect.tryPromise({
|
|
279
|
+
try: ()=>buildResult.close(),
|
|
280
|
+
catch: (error)=>new BundleFailed({
|
|
281
|
+
entry: entry.path,
|
|
282
|
+
cause: new Error(`rsbuild close() failed: ${error}`)
|
|
283
|
+
})
|
|
284
|
+
});
|
|
285
|
+
const outputPath = resolve(outputDir, `${entry.type}.js`);
|
|
286
|
+
const size = yield* Effect["try"]({
|
|
287
|
+
try: ()=>statSync(outputPath).size,
|
|
288
|
+
catch: (error)=>new BundleFailed({
|
|
289
|
+
entry: entry.path,
|
|
290
|
+
cause: error
|
|
291
|
+
})
|
|
292
|
+
});
|
|
281
293
|
const duration = Date.now() - startTime;
|
|
282
|
-
const size = getBundleSize(nccResult.code);
|
|
283
294
|
return {
|
|
284
295
|
success: true,
|
|
285
296
|
stats: {
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# @savvy-web/github-action-builder
|
|
2
2
|
|
|
3
3
|
A zero-config build tool for creating GitHub Actions from TypeScript source
|
|
4
|
-
code. Bundles your action with [@
|
|
5
|
-
validates `action.yml` against GitHub's official schema, and
|
|
6
|
-
production-ready Node.js 24 actions.
|
|
4
|
+
code. Bundles your action with [@rsbuild/core](https://github.com/web-infra-dev/rsbuild)
|
|
5
|
+
(rspack-based), validates `action.yml` against GitHub's official schema, and
|
|
6
|
+
outputs production-ready Node.js 24 actions.
|
|
7
7
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
@@ -13,7 +13,8 @@ production-ready Node.js 24 actions.
|
|
|
13
13
|
runtime
|
|
14
14
|
- **Schema validation** - Validates `action.yml` against GitHub's official
|
|
15
15
|
metadata specification
|
|
16
|
-
- **Single-file bundles** - All dependencies inlined
|
|
16
|
+
- **Single-file bundles** - All npm dependencies inlined via rsbuild, `node:`
|
|
17
|
+
builtins externalized, with tree-shaking support
|
|
17
18
|
- **Local testing** - Auto-persists build output for testing with
|
|
18
19
|
[nektos/act](https://github.com/nektos/act)
|
|
19
20
|
- **CI-aware** - Strict validation in CI, warnings-only locally
|
|
@@ -74,7 +74,7 @@ const actionNameArg = Args.text({
|
|
|
74
74
|
name: "action-name"
|
|
75
75
|
}).pipe(Args.withDescription("Name of the GitHub Action (also the output directory)"));
|
|
76
76
|
const forceOption = Options.boolean("force").pipe(Options.withAlias("f"), Options.withDescription("Overwrite existing files"), Options.withDefault(false));
|
|
77
|
-
const getPackageVersion = ()=>"0.
|
|
77
|
+
const getPackageVersion = ()=>"0.5.0";
|
|
78
78
|
const generatePackageJson = (name)=>{
|
|
79
79
|
const version = getPackageVersion();
|
|
80
80
|
const pkg = {
|
|
@@ -162,7 +162,6 @@ export default GitHubAction.create({
|
|
|
162
162
|
// build: {
|
|
163
163
|
// minify: true,
|
|
164
164
|
// sourceMap: false,
|
|
165
|
-
// target: "es2022",
|
|
166
165
|
// },
|
|
167
166
|
|
|
168
167
|
// Validation options
|
|
@@ -307,7 +306,7 @@ const rootCommand = Command.make("github-action-builder").pipe(Command.withSubco
|
|
|
307
306
|
]));
|
|
308
307
|
const cli = Command.run(rootCommand, {
|
|
309
308
|
name: "github-action-builder",
|
|
310
|
-
version: "0.
|
|
309
|
+
version: "0.5.0"
|
|
311
310
|
});
|
|
312
311
|
const CliLayer = Layer.merge(AppLayer, NodeContext.layer);
|
|
313
312
|
const main = Effect.suspend(()=>cli(process.argv)).pipe(Effect.provide(CliLayer), Effect.catchAllCause((cause)=>{
|
package/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* GitHub Actions into production-ready JavaScript bundles.
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
|
-
* The package uses
|
|
9
|
+
* The package uses rsbuild under the hood to create single-file bundles
|
|
10
10
|
* that include all dependencies. It automatically detects entry points
|
|
11
11
|
* (`main.ts`, `pre.ts`, `post.ts`) and validates `action.yml` configuration.
|
|
12
12
|
*
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
* },
|
|
41
41
|
* build: {
|
|
42
42
|
* minify: true,
|
|
43
|
-
* target: "es2022",
|
|
44
43
|
* },
|
|
45
44
|
* });
|
|
46
45
|
* ```
|
|
@@ -326,7 +325,7 @@ export declare type BuildOptions = typeof BuildOptionsSchema.Type;
|
|
|
326
325
|
* Schema for build options.
|
|
327
326
|
*
|
|
328
327
|
* @remarks
|
|
329
|
-
* Build options control how the TypeScript source is bundled using
|
|
328
|
+
* Build options control how the TypeScript source is bundled using rsbuild.
|
|
330
329
|
* The bundler creates a single JavaScript file with all dependencies inlined.
|
|
331
330
|
*
|
|
332
331
|
* @internal
|
|
@@ -336,22 +335,14 @@ export declare const BuildOptionsSchema: Schema.Struct<{
|
|
|
336
335
|
minify: Schema.optionalWith<typeof Schema.Boolean, {
|
|
337
336
|
default: () => true;
|
|
338
337
|
}>;
|
|
339
|
-
/** ECMAScript target version for the output. Defaults to "es2022". */
|
|
340
|
-
target: Schema.optionalWith<Schema.Literal<["es2020", "es2021", "es2022", "es2023", "es2024"]>, {
|
|
341
|
-
default: () => "es2022";
|
|
342
|
-
}>;
|
|
343
338
|
/** Generate source maps for debugging. Defaults to false. */
|
|
344
339
|
sourceMap: Schema.optionalWith<typeof Schema.Boolean, {
|
|
345
340
|
default: () => false;
|
|
346
341
|
}>;
|
|
347
|
-
/** Packages to exclude from the bundle. Defaults to []. */
|
|
342
|
+
/** Packages to exclude from the bundle (in addition to node: builtins). Defaults to []. */
|
|
348
343
|
externals: Schema.optionalWith<Schema.Array$<typeof Schema.String>, {
|
|
349
344
|
default: () => never[];
|
|
350
345
|
}>;
|
|
351
|
-
/** Suppress build output. Defaults to false. */
|
|
352
|
-
quiet: Schema.optionalWith<typeof Schema.Boolean, {
|
|
353
|
-
default: () => false;
|
|
354
|
-
}>;
|
|
355
346
|
}>;
|
|
356
347
|
|
|
357
348
|
/**
|
|
@@ -413,7 +404,7 @@ export declare const BuildRunnerOptionsSchema: Schema.Struct<{
|
|
|
413
404
|
*
|
|
414
405
|
* @remarks
|
|
415
406
|
* This service handles:
|
|
416
|
-
* - Bundling TypeScript entries with
|
|
407
|
+
* - Bundling TypeScript entries with rsbuild
|
|
417
408
|
* - Managing output directory
|
|
418
409
|
* - Collecting build statistics
|
|
419
410
|
* - Formatting build results
|
|
@@ -488,7 +479,7 @@ export declare interface BuildService {
|
|
|
488
479
|
export declare const BuildService: Context.Tag<BuildService, BuildService>;
|
|
489
480
|
|
|
490
481
|
/**
|
|
491
|
-
* Error when bundling with
|
|
482
|
+
* Error when bundling with rsbuild fails.
|
|
492
483
|
*
|
|
493
484
|
* @public
|
|
494
485
|
*/
|
|
@@ -644,10 +635,8 @@ export declare const ConfigInputSchema: Schema.Struct<{
|
|
|
644
635
|
}>>;
|
|
645
636
|
build: Schema.optional<Schema.Struct<{
|
|
646
637
|
minify: Schema.optional<typeof Schema.Boolean>;
|
|
647
|
-
target: Schema.optional<Schema.Literal<["es2020", "es2021", "es2022", "es2023", "es2024"]>>;
|
|
648
638
|
sourceMap: Schema.optional<typeof Schema.Boolean>;
|
|
649
639
|
externals: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
650
|
-
quiet: Schema.optional<typeof Schema.Boolean>;
|
|
651
640
|
}>>;
|
|
652
641
|
validation: Schema.optional<Schema.Struct<{
|
|
653
642
|
requireActionYml: Schema.optional<typeof Schema.Boolean>;
|
|
@@ -785,22 +774,14 @@ export declare const ConfigSchema: Schema.Struct<{
|
|
|
785
774
|
minify: Schema.optionalWith<typeof Schema.Boolean, {
|
|
786
775
|
default: () => true;
|
|
787
776
|
}>;
|
|
788
|
-
/** ECMAScript target version for the output. Defaults to "es2022". */
|
|
789
|
-
target: Schema.optionalWith<Schema.Literal<["es2020", "es2021", "es2022", "es2023", "es2024"]>, {
|
|
790
|
-
default: () => "es2022";
|
|
791
|
-
}>;
|
|
792
777
|
/** Generate source maps for debugging. Defaults to false. */
|
|
793
778
|
sourceMap: Schema.optionalWith<typeof Schema.Boolean, {
|
|
794
779
|
default: () => false;
|
|
795
780
|
}>;
|
|
796
|
-
/** Packages to exclude from the bundle. Defaults to []. */
|
|
781
|
+
/** Packages to exclude from the bundle (in addition to node: builtins). Defaults to []. */
|
|
797
782
|
externals: Schema.optionalWith<Schema.Array$<typeof Schema.String>, {
|
|
798
783
|
default: () => never[];
|
|
799
784
|
}>;
|
|
800
|
-
/** Suppress build output. Defaults to false. */
|
|
801
|
-
quiet: Schema.optionalWith<typeof Schema.Boolean, {
|
|
802
|
-
default: () => false;
|
|
803
|
-
}>;
|
|
804
785
|
}>;
|
|
805
786
|
validation: Schema.Struct<{
|
|
806
787
|
/** Require action.yml to exist and be valid. Defaults to true. */
|
|
@@ -927,7 +908,6 @@ export declare const ConfigService: Context.Tag<ConfigService, ConfigService>;
|
|
|
927
908
|
* },
|
|
928
909
|
* build: {
|
|
929
910
|
* minify: true,
|
|
930
|
-
* target: "es2022",
|
|
931
911
|
* sourceMap: true,
|
|
932
912
|
* externals: ["@aws-sdk/client-s3"],
|
|
933
913
|
* },
|
|
@@ -1046,20 +1026,6 @@ export declare const EntryFileMissingBase: new <A extends Record<string, any> =
|
|
|
1046
1026
|
readonly _tag: "EntryFileMissing";
|
|
1047
1027
|
} & Readonly<A>;
|
|
1048
1028
|
|
|
1049
|
-
/**
|
|
1050
|
-
* ECMAScript target versions supported by the bundler.
|
|
1051
|
-
*
|
|
1052
|
-
* @internal
|
|
1053
|
-
*/
|
|
1054
|
-
export declare const EsTarget: Schema.Literal<["es2020", "es2021", "es2022", "es2023", "es2024"]>;
|
|
1055
|
-
|
|
1056
|
-
/**
|
|
1057
|
-
* Type for ECMAScript target.
|
|
1058
|
-
*
|
|
1059
|
-
* @public
|
|
1060
|
-
*/
|
|
1061
|
-
export declare type EsTarget = typeof EsTarget.Type;
|
|
1062
|
-
|
|
1063
1029
|
/**
|
|
1064
1030
|
* Main API class for building GitHub Actions.
|
|
1065
1031
|
*
|
|
@@ -1099,7 +1065,7 @@ export declare type EsTarget = typeof EsTarget.Type;
|
|
|
1099
1065
|
* const action = GitHubAction.create({
|
|
1100
1066
|
* config: {
|
|
1101
1067
|
* entries: { main: "src/action.ts" },
|
|
1102
|
-
* build: { minify: true
|
|
1068
|
+
* build: { minify: true },
|
|
1103
1069
|
* },
|
|
1104
1070
|
* cwd: "/path/to/project",
|
|
1105
1071
|
* });
|
|
@@ -1191,7 +1157,7 @@ export declare class GitHubAction {
|
|
|
1191
1157
|
* The build process:
|
|
1192
1158
|
* 1. Loads configuration (if not already loaded)
|
|
1193
1159
|
* 2. Validates the project (unless `skipValidation` is set)
|
|
1194
|
-
* 3. Bundles each entry point with
|
|
1160
|
+
* 3. Bundles each entry point with rsbuild
|
|
1195
1161
|
* 4. Writes output to the `dist/` directory
|
|
1196
1162
|
*
|
|
1197
1163
|
* @returns Build result with success status and details
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/github-action-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "A zero-config build tool for creating GitHub Actions from TypeScript. Bundles with
|
|
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": [
|
|
7
7
|
"github-actions",
|
|
8
8
|
"github",
|
|
9
9
|
"actions",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"rsbuild",
|
|
11
|
+
"rspack",
|
|
12
12
|
"bundler",
|
|
13
13
|
"typescript",
|
|
14
14
|
"node24",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@effect/printer": "^0.48.0",
|
|
50
50
|
"@effect/printer-ansi": "^0.48.0",
|
|
51
51
|
"@effect/typeclass": "^0.39.0",
|
|
52
|
-
"@
|
|
52
|
+
"@rsbuild/core": "^1.7.3",
|
|
53
53
|
"effect": "^3.20.0",
|
|
54
54
|
"picocolors": "^1.1.1",
|
|
55
55
|
"yaml-effect": "^0.1.5"
|