@xtaskjs/cli
v0.1.2
Published
Commander-based CLI for creating and scaffolding XTaskJS projects.
Downloads
144
Maintainers
Readme
xtask-cli
Console client for bootstrapping XTaskJS applications from the official TypeScript starter and generating common source artifacts such as controllers, services, repositories, DTOs, guards, middleware, feature modules, and full resources.
Features
create: downloadsxtaskjs/typescript-starterinto a target directorygenerate controller: creates an XTaskJS controller skeletongenerate service: creates an XTaskJS service skeletongenerate repository: creates an XTaskJS repository skeletongenerate dto: creates a validation DTO skeletongenerate guard: creates an XTaskJS guard skeletongenerate middleware: creates an XTaskJS middleware skeletongenerate module: creates a feature scaffold with controller, service, repository, DTO, and barrel exportsgenerate resource: creates controller, service, and repository files as a feature scaffoldcache: talks to an app's XTaskJS cache management endpoints for inspection and clearing
Install
npm installUsage
Run from source while developing:
npm run start -- --helpBuild the CLI:
npm run buildRun the automated generator tests:
npm testInstall globally from npm:
npm install -g @xtaskjs/cli
xtask --helpCreate a new XTaskJS project:
npm run start -- create my-apiSkip dependency installation during project creation:
npm run start -- create my-api --skip-installGenerate a controller inside an existing XTaskJS app:
npm run start -- generate controller usersGenerate a resource trio:
npm run start -- generate resource billingGenerate a resource scaffold with a DTO file:
npm run start -- generate resource billing --with-dtoGenerate a CRUD-oriented resource scaffold:
npm run start -- generate resource billing --crudWrite a resource scaffold directly into the target directory:
npm run start -- generate resource billing --path src/modules --flatGenerate a DTO for request validation:
npm run start -- generate dto create-userGenerate a guard or middleware:
npm run start -- generate guard admin-auth
npm run start -- generate middleware request-metricsGenerate a feature module folder:
npm run start -- generate module billing --path src/modulesGenerate a module and wire a guard into its controller:
npm run start -- generate module billing --path src/modules --with-guardKeep a module scaffold flat in the current target path:
npm run start -- generate module billing --path src/modules/billing --flatGenerate files in a different source directory:
npm run start -- generate service auth --path src/modules/authList registered cache models from a running XTaskJS app:
npm run start -- cache modelsInspect one cache model:
npm run start -- cache model productsInspect a single cache entry:
npm run start -- cache entry products 42Clear one model or all registered models:
npm run start -- cache clear products
npm run start -- cache clear-allInspect HTTP/browser cache metadata exposed by createCacheManagementController():
npm run start -- cache http-routes
npm run start -- cache http-route --method GET --path /articles/landingTarget a different server or management controller path:
npm run start -- cache models --server http://127.0.0.1:4000 --management-path /internal/cacheTroubleshooting
If you installed the package globally but xtask is not found, or the command does not appear to work, check the active Node environment first.
Useful commands:
node -v
npm prefix -g
npm list -g --depth=0 @xtaskjs/cli
type -a xtaskIf you use nvm, global packages are installed separately for each Node version. That means xtask may be installed in one version but unavailable in the shell if another version is active.
Reinstall in the active Node version:
npm install -g @xtaskjs/cli
hash -r
xtask --helpIf you want to verify the published package without relying on the global install, run:
npx @xtaskjs/cli --helpNotes
- The
createcommand downloads the starter fromhttps://github.com/xtaskjs/typescript-starter. - Generated controller templates follow the decorator patterns used by XTaskJS samples and the official starter.
resourceandmodulescaffolds create a dedicated feature directory by default; pass--flatto write files directly into the chosen path.--with-guardadds a*.guard.tsfile and applies@UseGuards(...)to generated module/resource controllers.--with-dtoadds a*.dto.tsfile to a resource scaffold.--crudupgrades a resource scaffold to CRUD-style controller, service, and repository methods and also generates the DTO file.- The
cachecommand expects your app to opt into the XTaskJS management controller, typically withcreateCacheManagementController({ path: "/ops/cache" }). - Generated DTOs assume the target app installs
class-validatorand, when needed,class-transformer, matching XTaskJS validation guidance.
