Schema
Command convention
Each xPart that provides CLI commands places Command classes under src/commands/.
One file = one Command class. No cli.js, no registration.
| 1 | @xpulse/my-package/ |
| 2 | src/ |
| 3 | commands/ |
| 4 | FetchCommand.js β extends Command |
| 5 | ChangelogCommand.js β extends Command |
Minimal example
| 1 | |
| 2 | import { Command } from '@xpulse/cli/command'; |
| 3 | |
| 4 | export class HelloCommand extends Command { |
| 5 | configure() { |
| 6 | this |
| 7 | .setName('tapp:hello') |
| 8 | .setDescription('Say hello') |
| 9 | .addArgument('name', 'Anon', 'Recipient name'); |
| 10 | } |
| 11 | |
| 12 | async run(input, output) { |
| 13 | output.success(`Hello ${input.getArgument('name')}!`); |
| 14 | return 0; |
| 15 | } |
| 16 | } |
Required
| Field |
Description |
setName() |
Command name β namespace:area:command |
setDescription() |
Short description for --help and --list |
run() |
Execution logic β returns exit code |
Autodiscovery order
| 1 | 1. node_modules/@xpulse/*/src/commands/*.js β installed xParts |
| 2 | 2. src/commands/*.js β local project |
The local project behaves like an implicit xPart β no npm link needed.
Namespace convention
| Command |
Namespace |
xPart |
doc:fetch |
doc |
@xpulse/doc |
project:config:show |
project |
@xpulse/config |
repo:changelog:generate |
repo |
@xpulse/repo |
release:prepare |
release |
@xpulse/release |
Package structure
| 1 | @xpulse/cli/ |
| 2 | bin/ |
| 3 | xpulse.js β entry point: autodiscovery, parser, Input/Output, timeout |
| 4 | src/ |
| 5 | command.js β Command base class with configure(), keepAlive(), run() |
| 6 | input.js β Input class: getArgument, getOption, getFlag, isVerbose ... |
| 7 | output.js β Output class + internal helpers (--help, --list, --version) |
| 8 | loader.js β find + import node_modules/@xpulse |
| 9 | parser.js β CLI input β { name, args, rawArguments, verbose, quiet, ansi } |
| 10 | docs/ |
| 11 | index.md |
| 12 | de/ index, guide, api, schema |
| 13 | en/ index, guide, api, schema |
| 14 | test/ |
| 15 | command.test.js |
| 16 | input.test.js |
| 17 | parser.test.js |
| 18 | loader.test.js |
| 19 | README.md |
| 20 | package.json |
| 21 | xpulse.json |
Exports
| 1 | import { Command } from '@xpulse/cli/command'; |
| 2 | import { Input } from '@xpulse/cli/input'; |
| 3 | import { Output } from '@xpulse/cli/output'; |
project `package.json` requirements
"type": "module" is required because the entire xPulse ecosystem uses ESM.
Without it, Node.js will fail to load Command files with import statements.