Skip to content

haywire-launcher ​

npm · Source · Changelog

Run a Haywire-built entry script in one line. The container is only built when the script runs, not when it's imported.

ts
// bin.ts
import { 
launch
} from 'haywire-launcher';
import {
Cli
} from './cli.js';
import {
container
} from './container.js';
export default
launch
(
container
,
Cli
);

node bin.js gets Cli from the container, with all its dependencies, and calls its main(). Importing bin.js does nothing, so tests can build their own container instead.

Get started →

Features ​

  • No container on import: container.getAsync() at a module's top level builds every dependency (and opens every connection) as soon as anything imports it. launch() waits until the script runs.
  • Checked at compile time: a container that can't provide the id, or an id whose type has no main(argv), is a type error.
  • Any Main: the script can be any class with a main(argv) method, not only an EntryScript subclass.
  • Testable: getOriginal() returns the instance the container builds, for testing the wiring itself.

Every CLI in this repository (barrelify, genever, nx-lifecycle, …) starts this way.

Packages

  • Haywire

    Compile-time checked dependency injection for TypeScript — no decorators, no reflect-metadata, no global state.

  • entry-script

    Node.js scripts whose main() only runs when they are the entry point, so tests can import them without side effects.

Used in demos

  • CLI for agents

    Making the notes API easy for AI agents with a shell: one short command per task, logging in once from the API’s URL, with tokens, refresh and errors handled inside.