Skip to content

@plinthjs/cli ​

The plinth command line tool. It runs your application's console commands from any folder, scaffolds new applications, and reports project details. It has no dependencies.

Install ​

Inside an application (the scaffold already adds it):

bash
pnpm add -D @plinthjs/cli tsx

Or install it globally to use plinth anywhere:

bash
npm install -g @plinthjs/cli

Usage ​

bash
plinth new blog --api          # create an application (runs create-plinthjs-app)
plinth about                   # project, Node and package details
plinth list                    # list the application's console commands
plinth migrate                 # run an application command
plinth make:controller PostController --resource

Inside a project, plinth with no arguments is the same as plinth list.

How it finds your application ​

plinth walks up from the current folder until it finds a package.json next to a console entry. It looks for src/console.ts, src/console.mts, src/console.js, src/console.mjs, console.ts or console.js, in that order. This means it works from any subfolder.

Every command other than the built-in ones (new, about, help) is handed to that entry with the remaining arguments, in the project root, and the exit code is passed back.

TypeScript entries run through tsx, which must be installed in the project. JavaScript entries run directly on Node.

Programmatic use ​

ts
import { findProject, runCli, processSpawner } from '@plinthjs/cli'

findProject(process.cwd()) // => { root, entry } or null

Released under the MIT License.