Skip to content

Add standalone executable packaging and test infrastructure#4

Merged
rjrodger merged 3 commits intomainfrom
claude/package-standalone-executable-IHajI
Mar 5, 2026
Merged

Add standalone executable packaging and test infrastructure#4
rjrodger merged 3 commits intomainfrom
claude/package-standalone-executable-IHajI

Conversation

@rjrodger
Copy link
Contributor

@rjrodger rjrodger commented Mar 5, 2026

Summary

This PR adds comprehensive infrastructure for packaging the @voxgig/apidef CLI as standalone executables across multiple platforms and runtimes, along with a complete test suite to validate the packaging approaches.

Key Changes

Standalone Executable Packaging

  • Node.js SEA (Single Executable Application): Added cmd/node-sea/build.sh that bundles the CLI with esbuild and injects it into the Node.js binary using postject, producing a 121 MB executable
  • Bun Compile: Added cmd/bun/build.sh and cmd/bun/entry.js for building standalone executables with Bun's --compile flag, supporting cross-compilation to 6 platform targets
  • Deno Compile: Added cmd/deno/build.sh and cmd/deno/entry.ts for Deno-compatible packaging with built-in cross-compilation support

Test Infrastructure

  • Master test script (cmd/test/build-and-test.sh): Orchestrates building and testing all three executable approaches, comparing output against a Node.js reference implementation
  • Shared test runner (cmd/test/run-test.js): Programmatically exercises the ApiDef pipeline using the Solar System API test fixture, handling require.main.paths resolution for standalone executables
  • Test fixtures: Added complete Solar System API OpenAPI 3.0.0 specification in both YAML and JSON formats (cmd/test/def/)

Test Data & Expected Output

  • Solar test project: Complete fixture with entity models (planet, moon), flows (BasicPlanetFlow, BasicMoonFlow), and API guide definitions in jsonic format
  • Reference outputs: Pre-generated expected outputs for manifest.json, guide.json, apimodel.json, and all entity/flow jsonic files

Documentation

  • RESULTS.md: Comprehensive analysis of all three packaging approaches, including build steps, results, pros/cons, and cross-compilation notes

Notable Implementation Details

  • Standalone executables properly handle require.main.paths resolution, which may be undefined or incorrect in bundled contexts, enabling aontu to resolve @"@voxgig/apidef/model/*.jsonic" includes
  • Test infrastructure copies model files into a node_modules-like structure for consistent resolution across all executable types
  • Build scripts include version and help output validation to ensure CLI functionality is preserved through packaging
  • Cross-compilation support varies: Node.js SEA requires manual binary downloads per platform, while Bun and Deno have built-in --target support

https://claude.ai/code/session_01SYcmojUbs1ef1UgkFeSZyE

claude added 3 commits March 4, 2026 19:49
… and Deno

Created cmd/ folder with build scripts and results for three approaches:
- cmd/node-sea/: Node.js Single Executable Application (PASS - 121MB, version works)
- cmd/bun/: Bun compile with cross-compilation (PASS - all 5 OS/arch targets, 60-112MB)
- cmd/deno/: Deno compile (NOT TESTED - Deno unavailable in env, scripts prepared)
- cmd/RESULTS.md: Detailed comparison and recommendation

https://claude.ai/code/session_01SYcmojUbs1ef1UgkFeSZyE
- cmd/test/run-test.js: Programmatic test runner using ApiDef.makeBuild()
  that exercises the full pipeline (parse, guide, transformers, builders,
  generate) with solar test data
- cmd/test/build-and-test.sh: Master script that generates Node.js reference
  output, then builds and tests Bun and Node SEA executables, comparing all
  output files (jsonic, json, manifest) for exact match
- cmd/test/solar/ and cmd/test/def/: Independent copy of test fixtures
- Polyfills require.main.paths for Bun (missing) and Node SEA (wrong location)
- Copies model/*.jsonic to work dir node_modules for SEA require.resolve compat

Results: Bun 5/5 PASS, Node SEA 5/5 PASS, Deno SKIP (not installed)
All 11 .jsonic files, guide.json, and apimodel.json match exactly between
Node.js reference, Bun executable, and Node SEA executable.

https://claude.ai/code/session_01SYcmojUbs1ef1UgkFeSZyE
@rjrodger rjrodger merged commit 2930f05 into main Mar 5, 2026
3 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants