@contextjs/context
Official CLI for building and managing ContextJS projects.
Features
- Unified command-line interface for managing ContextJS-based projects
- Support for creating new projects from templates
- Project-wide or selective build and watch support
- Supports all TypeScript compiler flags via
ctx buildandctx watch - Supports custom and external transformers via
--transformersorcontext.ctxp - Works seamlessly with all ContextJS packages
Installation
Install globally via npm:
npm i -g @contextjs/contextThis exposes the ctx command globally in your terminal.
Usage
Display available options
ctxDisplay version
ctx versionNew project
These commands are equivalent:
ctx new api my-api
ctx new api -n my-api
ctx new api --name my-apiIf no argument is passed for the API name, the current folder name will be used:
ctx new apiIf no arguments are passed at all, the help message will be shown:
ctx newBuild
Build all detected projects:
ctx buildBuild specific projects:
ctx build -p myApi1 myApi2 ...You can pass TypeScript compiler options directly:
ctx build --noEmitOnError --target ES2022Use a custom transformer:
ctx build --transformers=./src/my-transformer.tsOr define transformers in context.ctxp:
{
"compilerOptions": {
"transformers": ["./src/my-transformer.ts"]
}
}Watch
Watch and rebuild all projects on file changes:
ctx watchWatch specific projects:
ctx watch -p myApi1 myApi2 ...You can also include TypeScript flags with watch:
ctx watch --moduleResolution NodeNext --strict trueExternal transformers are also supported in watch mode:
ctx watch --transformers=./src/my-transformer.tsProject types
ContextJS is in active development, and the CLI is designed to support various project types. For a complete list of available project types, refer to the Projects Section.
