@contextjs/commands
v25.1.0
Published
ContextJS - Commands
Maintainers
Readme
@contextjs/commands
Core command implementations for building, restoring, running, and watching ContextJS projects.
Features
- Build, restore, run, and watch ContextJS projects via CLI commands
- Full support for TypeScript compiler flags and project selection
- Custom transformers and extensions support
- Consistent project discovery and error handling
- Seamless integration with all ContextJS tools
Installation
Usually installed as a dependency and used internally.
For advanced or direct usage:
npm install --save-dev @contextjs/commandsCommands
build
Compiles the project TypeScript sources and prepares templates for deployment.
ctx build- Description: Compiles the ContextJS project(s) using the project file and
tsconfig.json. - Options: Accepts any TypeScript compiler flag, project selectors, and custom extensions.
restore
Restores all NPM dependencies for each detected ContextJS project.
ctx restore- Description: Installs or updates dependencies based on each project’s
package.json. - Behavior: Fails if either
context.ctxportsconfig.jsonare missing.
run
Executes the main entry point of a built ContextJS project.
ctx run- Description: Finds and runs the compiled output specified in the project manifest.
- Options: Can be chained with build (default) or use
--no-buildto skip rebuilding.
watch
Starts a file watcher for each ContextJS project and automatically recompiles on changes.
ctx watch- Description: Watches sources and rebuilds on changes, using TypeScript's watch API.
- Options: All TypeScript CLI flags, transformer support, and project filtering.
Usage Examples
ctx build # Build all projects
ctx restore # Restore dependencies
ctx run # Build and run (default), or use --no-build
ctx watch # Watch files and auto-buildWith project selection:
ctx build myApi myWeb # Only build specific projectsWith TypeScript options:
ctx build --noEmitOnError --target ES2022
ctx watch --strict trueWith custom extensions:
ctx build --extensions=./src/my-extension.js
ctx watch --extensions=./src/my-extension.js