@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 build
andctx watch
- Supports custom and external transformers via
--transformers
orcontext.ctxp
- Works seamlessly with all ContextJS packages
Installation
Install globally via npm:
npm i -g @contextjs/context
This exposes the ctx
command globally in your terminal.
Usage
Display available options
ctx
Display version
ctx version
New project
These commands are equivalent:
ctx new api my-api
ctx new api -n my-api
ctx new api --name my-api
If no argument is passed for the API name, the current folder name will be used:
ctx new api
If no arguments are passed at all, the help message will be shown:
ctx new
Build
Build all detected projects:
ctx build
Build specific projects:
ctx build -p myApi1 myApi2 ...
You can pass TypeScript compiler options directly:
ctx build --noEmitOnError --target ES2022
Use a custom transformer:
ctx build --transformers=./src/my-transformer.ts
Or define transformers in context.ctxp
:
{
"compilerOptions": {
"transformers": ["./src/my-transformer.ts"]
}
}
Watch
Watch and rebuild all projects on file changes:
ctx watch
Watch specific projects:
ctx watch -p myApi1 myApi2 ...
You can also include TypeScript flags with watch
:
ctx watch --moduleResolution NodeNext --strict true
External transformers are also supported in watch mode:
ctx watch --transformers=./src/my-transformer.ts
Project 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.