@savvy-web/github-action-builder 0.2.0 → 0.3.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/123.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Console, Context, Data, Effect, Layer, ManagedRuntime, Option, ParseResult, Schema } from "effect";
1
+ import { Cause, Console, Context, Data, Effect, Layer, ManagedRuntime, Option, ParseResult, Schema } from "effect";
2
2
  import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
3
3
  import { createRequire } from "node:module";
4
4
  import { dirname, join, relative, resolve } from "node:path";
@@ -230,7 +230,7 @@ function cleanDirectory(dir) {
230
230
  },
231
231
  catch: (error)=>new CleanError({
232
232
  directory: dir,
233
- cause: error instanceof Error ? error.message : String(error)
233
+ cause: error
234
234
  })
235
235
  });
236
236
  }
@@ -245,7 +245,7 @@ function writeFile(path, content) {
245
245
  },
246
246
  catch: (error)=>new WriteError({
247
247
  path,
248
- cause: error instanceof Error ? error.message : String(error)
248
+ cause: error
249
249
  })
250
250
  });
251
251
  }
@@ -264,7 +264,7 @@ function bundleEntry(entry, config, cwd) {
264
264
  }),
265
265
  catch: (error)=>new BundleFailed({
266
266
  entry: entry.path,
267
- cause: error instanceof Error ? error.message : String(error)
267
+ cause: error
268
268
  })
269
269
  });
270
270
  const outputPath = resolve(cwd, entry.output);
@@ -308,11 +308,13 @@ const BuildServiceLive = Layer.effect(BuildService, Effect.gen(function*() {
308
308
  const entryResults = [];
309
309
  for (const entry of entriesResult.entries){
310
310
  const result = yield* Effect.either(bundleEntry(entry, config, cwd));
311
- if ("Left" === result._tag) entryResults.push({
312
- success: false,
313
- error: result.left.cause
314
- });
315
- else entryResults.push(result.right);
311
+ if ("Left" === result._tag) {
312
+ const err = result.left;
313
+ entryResults.push({
314
+ success: false,
315
+ error: err.cause instanceof Error ? err.cause.message : String(err.cause)
316
+ });
317
+ } else entryResults.push(result.right);
316
318
  }
317
319
  yield* writeFile(resolve(cwd, "dist/package.json"), '{ "type": "module" }');
318
320
  const duration = Date.now() - startTime;
@@ -378,7 +380,7 @@ const ConfigServiceLive = Layer.succeed(ConfigService, {
378
380
  try: async ()=>import(absolutePath),
379
381
  catch: (error)=>new ConfigLoadFailed({
380
382
  path: configPath,
381
- cause: error instanceof Error ? error.message : String(error)
383
+ cause: error
382
384
  })
383
385
  });
384
386
  const configInput = configModule.default;
@@ -552,7 +554,7 @@ const PersistLocalServiceLive = Layer.succeed(PersistLocalService, {
552
554
  }),
553
555
  catch: (error)=>new PersistLocalError({
554
556
  path: outputPath,
555
- cause: error instanceof Error ? error.message : String(error)
557
+ cause: error
556
558
  })
557
559
  });
558
560
  let totalCopied = 0;
@@ -564,7 +566,7 @@ const PersistLocalServiceLive = Layer.succeed(PersistLocalService, {
564
566
  try: ()=>syncFile(actionYmlSrc, actionYmlDest),
565
567
  catch: (error)=>new PersistLocalError({
566
568
  path: actionYmlSrc,
567
- cause: error instanceof Error ? error.message : String(error)
569
+ cause: error
568
570
  })
569
571
  });
570
572
  if (copied) totalCopied++;
@@ -578,7 +580,7 @@ const PersistLocalServiceLive = Layer.succeed(PersistLocalService, {
578
580
  try: ()=>syncDirectory(distSrc, resolve(outputPath, "dist")),
579
581
  catch: (error)=>new PersistLocalError({
580
582
  path: distSrc,
581
- cause: error instanceof Error ? error.message : String(error)
583
+ cause: error
582
584
  })
583
585
  });
584
586
  totalCopied += distStats.copied;
@@ -595,7 +597,7 @@ const PersistLocalServiceLive = Layer.succeed(PersistLocalService, {
595
597
  try: ()=>writeFileSync(actrcPath, ACTRC_CONTENT, "utf8"),
596
598
  catch: (error)=>new PersistLocalError({
597
599
  path: actrcPath,
598
- cause: error instanceof Error ? error.message : String(error)
600
+ cause: error
599
601
  })
600
602
  });
601
603
  actTemplateGenerated = true;
@@ -610,7 +612,7 @@ const PersistLocalServiceLive = Layer.succeed(PersistLocalService, {
610
612
  },
611
613
  catch: (error)=>new PersistLocalError({
612
614
  path: actWorkflowPath,
613
- cause: error instanceof Error ? error.message : String(error)
615
+ cause: error
614
616
  })
615
617
  });
616
618
  actTemplateGenerated = true;
@@ -876,4 +878,4 @@ const ValidationLayer = ValidationServiceLive.pipe(Layer.provide(ConfigServiceLi
876
878
  const BuildLayer = BuildServiceLive.pipe(Layer.provide(ConfigServiceLive));
877
879
  const PersistLocalLayer = PersistLocalServiceLive;
878
880
  const AppLayer = Layer.mergeAll(ConfigServiceLive, ValidationLayer, BuildLayer, PersistLocalLayer);
879
- export { ActionYmlMissing, ActionYmlMissingBase, ActionYmlPathError, ActionYmlPathErrorBase, ActionYmlResultSchema, ActionYmlSchemaError, ActionYmlSchemaErrorBase, ActionYmlSyntaxError, ActionYmlSyntaxErrorBase, AppLayer, BuildFailed, BuildFailedBase, BuildLayer, BuildOptionsSchema, BuildResultSchema, BuildRunnerOptionsSchema, BuildService, BundleFailed, BundleFailedBase, BundleResultSchema, BundleStatsSchema, CleanError, CleanErrorBase, ConfigInputSchema, ConfigInvalid, ConfigInvalidBase, ConfigLayer, ConfigLoadFailed, ConfigLoadFailedBase, ConfigNotFound, ConfigNotFoundBase, ConfigSchema, ConfigService, Console, DetectEntriesResultSchema, DetectedEntrySchema, Effect, EntriesSchema, EntryFileMissing, EntryFileMissingBase, Layer, LoadConfigOptionsSchema, MainEntryMissing, MainEntryMissingBase, ManagedRuntime, Option, PersistLocalError, PersistLocalErrorBase, PersistLocalLayer, PersistLocalOptionsSchema, PersistLocalResultSchema, PersistLocalRunnerOptionsSchema, PersistLocalService, Schema, ValidateOptionsSchema, ValidationErrorSchema, ValidationFailed, ValidationFailedBase, ValidationLayer, ValidationOptionsSchema, ValidationResultSchema, ValidationService, ValidationWarningSchema, WriteError, WriteErrorBase, defineConfig, existsSync, mkdirSync, resolve, writeFileSync };
881
+ export { ActionYmlMissing, ActionYmlMissingBase, ActionYmlPathError, ActionYmlPathErrorBase, ActionYmlResultSchema, ActionYmlSchemaError, ActionYmlSchemaErrorBase, ActionYmlSyntaxError, ActionYmlSyntaxErrorBase, AppLayer, BuildFailed, BuildFailedBase, BuildLayer, BuildOptionsSchema, BuildResultSchema, BuildRunnerOptionsSchema, BuildService, BundleFailed, BundleFailedBase, BundleResultSchema, BundleStatsSchema, Cause, CleanError, CleanErrorBase, ConfigInputSchema, ConfigInvalid, ConfigInvalidBase, ConfigLayer, ConfigLoadFailed, ConfigLoadFailedBase, ConfigNotFound, ConfigNotFoundBase, ConfigSchema, ConfigService, Console, DetectEntriesResultSchema, DetectedEntrySchema, Effect, EntriesSchema, EntryFileMissing, EntryFileMissingBase, Layer, LoadConfigOptionsSchema, MainEntryMissing, MainEntryMissingBase, ManagedRuntime, Option, PersistLocalError, PersistLocalErrorBase, PersistLocalLayer, PersistLocalOptionsSchema, PersistLocalResultSchema, PersistLocalRunnerOptionsSchema, PersistLocalService, Schema, ValidateOptionsSchema, ValidationErrorSchema, ValidationFailed, ValidationFailedBase, ValidationLayer, ValidationOptionsSchema, ValidationResultSchema, ValidationService, ValidationWarningSchema, WriteError, WriteErrorBase, defineConfig, existsSync, mkdirSync, resolve, writeFileSync };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { Args, Command, Options } from "@effect/cli";
3
3
  import { NodeContext, NodeRuntime } from "@effect/platform-node";
4
- import { Layer, writeFileSync, AppLayer, BuildService, ConfigService, ValidationService, Effect, existsSync, resolve, mkdirSync, PersistLocalService, Console, Option } from "../123.js";
4
+ import { AppLayer, BuildService, BuildFailed, existsSync, resolve, mkdirSync, writeFileSync, Console, Option, Layer, ConfigService, Cause, Effect, ValidationService, PersistLocalService, ValidationFailed } from "../123.js";
5
5
  const configOption = Options.file("config").pipe(Options.withAlias("c"), Options.withDescription("Path to configuration file"), Options.optional);
6
6
  const quietOption = Options.boolean("quiet").pipe(Options.withAlias("q"), Options.withDescription("Suppress non-error output"), Options.withDefault(false));
7
7
  const noValidateOption = Options.boolean("no-validate").pipe(Options.withDescription("Skip validation step"), Options.withDefault(false));
@@ -29,7 +29,11 @@ const buildHandler = ({ config, quiet, noValidate, noPersist })=>Effect.gen(func
29
29
  });
30
30
  if (!validationResult.valid) {
31
31
  yield* Console.error(`\n${validationService.formatResult(validationResult)}`);
32
- return yield* Effect.fail(new Error("Validation failed"));
32
+ return yield* new ValidationFailed({
33
+ errorCount: validationResult.errors.length,
34
+ warningCount: validationResult.warnings.length,
35
+ message: "Validation failed"
36
+ });
33
37
  }
34
38
  if (!quiet && validationResult.warnings.length > 0) yield* Console.log(validationService.formatResult(validationResult));
35
39
  else if (!quiet) yield* Console.log(" All checks passed");
@@ -40,7 +44,10 @@ const buildHandler = ({ config, quiet, noValidate, noPersist })=>Effect.gen(func
40
44
  });
41
45
  if (!buildResult.success) {
42
46
  yield* Console.error(`\nBuild failed: ${buildResult.error}`);
43
- return yield* Effect.fail(new Error("Build failed"));
47
+ return yield* new BuildFailed({
48
+ message: buildResult.error ?? "One or more entries failed to build",
49
+ failedEntries: buildResult.entries.filter((e)=>!e.success).length
50
+ });
44
51
  }
45
52
  if (!quiet) {
46
53
  yield* Console.log(`\n${buildService.formatResult(buildResult)}`);
@@ -64,7 +71,7 @@ const actionNameArg = Args.text({
64
71
  name: "action-name"
65
72
  }).pipe(Args.withDescription("Name of the GitHub Action (also the output directory)"));
66
73
  const forceOption = Options.boolean("force").pipe(Options.withAlias("f"), Options.withDescription("Overwrite existing files"), Options.withDefault(false));
67
- const getPackageVersion = ()=>"0.2.0";
74
+ const getPackageVersion = ()=>"0.3.0";
68
75
  const generatePackageJson = (name)=>{
69
76
  const version = getPackageVersion();
70
77
  const pkg = {
@@ -297,8 +304,12 @@ const rootCommand = Command.make("github-action-builder").pipe(Command.withSubco
297
304
  ]));
298
305
  const cli = Command.run(rootCommand, {
299
306
  name: "github-action-builder",
300
- version: "0.2.0"
307
+ version: "0.3.0"
301
308
  });
302
309
  const CliLayer = Layer.merge(AppLayer, NodeContext.layer);
303
- const main = Effect.suspend(()=>cli(process.argv)).pipe(Effect.provide(CliLayer));
310
+ const main = Effect.suspend(()=>cli(process.argv)).pipe(Effect.provide(CliLayer), Effect.catchAllCause((cause)=>{
311
+ const defects = Cause.defects(cause);
312
+ if (defects.length > 0) return Console.error(Cause.pretty(cause)).pipe(Effect.andThen(Effect.failCause(cause)));
313
+ return Effect.failCause(cause);
314
+ }));
304
315
  NodeRuntime.runMain(main);
package/index.d.ts CHANGED
@@ -498,9 +498,9 @@ export declare class BundleFailed extends BundleFailedBase<{
498
498
  */
499
499
  readonly entry: string;
500
500
  /**
501
- * The underlying error message.
501
+ * The underlying error or error message.
502
502
  */
503
- readonly cause: string;
503
+ readonly cause: unknown;
504
504
  }> {
505
505
  }
506
506
 
@@ -578,9 +578,9 @@ export declare class CleanError extends CleanErrorBase<{
578
578
  */
579
579
  readonly directory: string;
580
580
  /**
581
- * The underlying error message.
581
+ * The underlying error or error message.
582
582
  */
583
- readonly cause: string;
583
+ readonly cause: unknown;
584
584
  }> {
585
585
  }
586
586
 
@@ -713,9 +713,9 @@ export declare class ConfigLoadFailed extends ConfigLoadFailedBase<{
713
713
  */
714
714
  readonly path: string;
715
715
  /**
716
- * The underlying error message.
716
+ * The underlying error or error message.
717
717
  */
718
- readonly cause: string;
718
+ readonly cause: unknown;
719
719
  }> {
720
720
  }
721
721
 
@@ -1287,6 +1287,8 @@ export declare const GitHubActionBuildResultSchema: Schema.Struct<{
1287
1287
  }>>;
1288
1288
  /** Error message if the build or validation failed. */
1289
1289
  error: Schema.optional<typeof Schema.String>;
1290
+ /** Raw error object for programmatic inspection. */
1291
+ cause: Schema.optional<typeof Schema.Unknown>;
1290
1292
  }>;
1291
1293
 
1292
1294
  /**
@@ -1417,9 +1419,9 @@ export declare class PersistLocalError extends PersistLocalErrorBase<{
1417
1419
  */
1418
1420
  readonly path: string;
1419
1421
  /**
1420
- * The underlying error message.
1422
+ * The underlying error or error message.
1421
1423
  */
1422
- readonly cause: string;
1424
+ readonly cause: unknown;
1423
1425
  }> {
1424
1426
  }
1425
1427
 
@@ -1819,9 +1821,9 @@ export declare class WriteError extends WriteErrorBase<{
1819
1821
  */
1820
1822
  readonly path: string;
1821
1823
  /**
1822
- * The underlying error message.
1824
+ * The underlying error or error message.
1823
1825
  */
1824
- readonly cause: string;
1826
+ readonly cause: unknown;
1825
1827
  }> {
1826
1828
  }
1827
1829
 
package/index.js CHANGED
@@ -4,7 +4,8 @@ const GitHubActionBuildResultSchema = Schema.Struct({
4
4
  build: Schema.optional(BuildResultSchema),
5
5
  validation: Schema.optional(ValidationResultSchema),
6
6
  persistLocal: Schema.optional(PersistLocalResultSchema),
7
- error: Schema.optional(Schema.String)
7
+ error: Schema.optional(Schema.String),
8
+ cause: Schema.optional(Schema.Unknown)
8
9
  });
9
10
  class GitHubAction {
10
11
  runtime;
@@ -119,7 +120,8 @@ class GitHubAction {
119
120
  } catch (error) {
120
121
  return {
121
122
  success: false,
122
- error: error instanceof Error ? error.message : "Unknown error"
123
+ error: error instanceof Error ? error.message : "Unknown error",
124
+ cause: error
123
125
  };
124
126
  }
125
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/github-action-builder",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "description": "A zero-config build tool for creating GitHub Actions from TypeScript. Bundles with @vercel/ncc, validates action.yml against GitHub's schema, and outputs production-ready Node.js 24 actions.",
6
6
  "keywords": [
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.56.3"
8
+ "packageVersion": "7.57.6"
9
9
  }
10
10
  ]
11
11
  }