New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@factory/cli

Package Overview
Dependencies
Maintainers
2
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@factory/cli

A hybrid command-line interface that runs **either**:

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
1.7K
45.47%
Maintainers
2
Weekly downloads
 
Created
Source

Factory CLI - Demo Edit

A hybrid command-line interface that runs either:

  • Interactive TUI – a full-screen React/Ink terminal app
  • Headless commands – traditional factory headless <command> sub-commands powered by Commander

The entry-point (src/index.ts) detects how it was invoked and chooses the right mode automatically.

1. Overview of the Hybrid Architecture

src/
├── index.ts          # Hybrid entry – mode detection
│
├── app.tsx           # React/Ink TUI (interactive mode)
│
└── commands/         # Commander commands (headless mode)
    ├── droid.ts
    └── login.ts

No positional args ➜ Interactive TUI
headless subcommand ➜ Headless mode

2 · Local Development

All dev tasks are exposed as npm scripts – never run compiled .js files directly.

PurposeCommand
Start CLI (auto mode)npm start
Start with Node inspectornpm run debug
Lint sourcenpm run lint
Type-checknpm run typecheck
Run testsnpm test
Build JS into dist/npm run build
Produce executable bundlenpm run bundle
Clean build artifactsnpm run clean

The start/debug scripts use tsx so you can edit TypeScript and restart instantly.

3 · Testing Both Modes Locally

Interactive TUI

# Launch interactive UI
npm start

You’ll see a colourful Ink interface; quit with Ctrl-C.

Headless Commands

# Show global help
npm start -- --help

# Show headless subcommands
npm start -- headless --help

# Run login interactively (headless)
npm start -- headless login

# Send message to a droid
npm start -- headless droid "Hello, Droid!" --session-id <sessionId>

The extra -- after npm start passes subsequent flags to the CLI.

4 · Development vs Production

PhaseCommand(s)Result
Devnpm start / npm run debugRuns from TS sources with tsx, fast reload.
Buildnpm run buildCompiles TS → dist/.
Bundlenpm run bundle (calls build)Generates single executable bundle/factory.js.
Publishnpm publish (bundled in prepare)Users install factory binary from npm.

During CI the prepare script produces the bundle automatically.

5 · Examples

Headless examples

# Show authentication status
factory headless status

# Authenticate (opens browser)
factory headless login

# Talk to Droid
factory headless droid "Hello" --session-id dOLpXUI8ux6YdZrg3kCs

Interactive example

# Simply run with no args
factory

6 · Testing the Production factory Command

Sometimes you need to test the exact binary users will get from npm install -g factory-cli.
Follow this workflow:

# 1. Build optimised bundle (also compiles TS → JS)
npm run bundle

# 2. Link globally so `factory` is on your PATH
npm link

# 3. Use it anywhere
factory --help
factory headless status
factory headless droid "Hello" --session-id <sessionId>

# 4. (Optional) Un-link when finished
npm unlink -g factory-cli
SituationCommand to use
Fast iteration / TypeScriptnpm start -- <args>
Debug with inspectornpm run debug -- <args>
Validate production bundlenpm run bundle && npm link then factory headless <args>

ℹ️ Tip: The extra -- after npm start or npm run debug passes the remaining flags directly to the CLI.

7 · ESM & Imports

The package is "type": "module"; all runtime imports use .js extensions even though the source is TypeScript. The build pipeline rewrites them automatically.

8 · Troubleshooting

ProblemFix
EACCES when running factoryEnsure the bundle is executable (chmod +x bundle/factory.js). npm run bundle handles this automatically.
module not found after renameRun npm run clean && npm run bundle to rebuild from scratch.
Global command still points to old codeRun npm unlink -g factory-cli && npm link to refresh the symlink.

9 · Contributing

  • pnpm install (or npm install) at repo root
  • cd apps/factory-cli
  • Implement feature / fix
  • Ensure npm run lint && npm run typecheck && npm test pass
  • Commit & open PR 🚀

FAQs

Package last updated on 07 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts