Creates a new library or updates an existing library, to be set up with infrastructure using the latest version of @benmvp/cli.
It will:
- Set up git (i.e.
git init) in the directory - Add
"test","start","build"and"integrate"scripts in thepackage.jsonto callbenmvp test,benmvp start,benmvp build, andbenmvp integrate, respectively - After the
package.jsonis created (or updated), it will install@benmvp/clias a dev dependency, using npm - Add a dummy
src/index.tsfile which is the entry-point to the lib and from where all top-level API functions will be exported - Add (or overwrite)
.prettierrc.json,.prettierignore&.vscode/settings.jsonfiles to format all code - Add (or overwrite) Github workflows:
.github/workflows/ci.ymlfor testing your code when a branch is pushed to or a PR is updated..github/workflows/format.ymlfor formatting your files when a non-masterbranch is pushed to. Formatted code will be pushed as a new commit to the branch..github/workflows/validate-pr.ymlfor validating that each PR title follows the Conventional Commits specification..github/workflows/release.ymlfor releasing a new version of your package upon new commits tomaster.
- Add (or overwrite)
.github/pull_request_template.md&.github/ISSUE_TEMPLATEfor more organized pull request and issue creation. - Add (or overwrite) other miscellaneous config files:
NOTE:
benmvp createcan be called multiple times on a repo. It's a good idea to callbenmvp createevery time you bump the version of@benmvp/cliso you can get the latest configuration forpackage.json, prettier, Github workflows, Github PR/Issue templates, and other miscellaneous config files.
Looking for Node API docs? View companion create() documentation.
@benmvp/cli works best with npx so that you don't have to globally install it and can always use the latest and greatest version.
Create a new lib named lib-of-fun with the default settings (simplest setup):
npx @benmvp/cli create lib-of-funAdd lint verification to an existing library:
npx @benmvp/cli create --modes lintCreate a new library named my-lib that only outputs ESM format:
npx @benmvp/cli create my-lib --formats esmAdd custom setup to an existing library:
npx @benmvp/cli create --modes type spec --out ./built --formats esm cjs(Optional) The name of the library to create or update.
When name is unspecified, it assumes the current working directory is the root of the library. Also:
- If a
package.jsondoes not already exist, it creates a newpackage.jsonwith the name matching the directory it's within. - If a
package.jsondoes exist, it does nothing to the existingpackage.json.
When name is specified, it will create a directory of name within the current working directory. Also:
- If a
package.jsondoes not already exist, it creates a newpackage.jsonwith the specified name. - If a
package.jsondoes exist, it updates the"name"property of thepackage.jsonwith specified name.
A space-separated list of the module formats to build. Aliased as -f. Available formats:
type- Typescript definition files (.d.ts) so that clients of your library can use your library fully-typedesm- ECMAScript module format (everything transpiled to ES5 except for ES2015import/exportstatements enabling tree shaking)cjs- CommonJS format (fully transpiled)
Optional. Defaults to all formats.
This will include the appropriate "types", "main" (cjs), "module" (esm), and "jsnext:main" (esm) properties in the package.json. It will also update the "build" script to pass the matching argument.
A path (relative or absolute) to the output directory for where the module formats should be built. Aliased as -o.
If you chose 'esm' as one of the formats and choose './built' as the output directory, the ESM files will live at ./built/esm.
Optional. Defaults to ./lib.
This will update the appropriate "types", "main" (cjs), "module" (esm), "jsnext:main" (esm), "types" (Typescript), "files" (NPM release) properties in the package.json. It will also update the "build" script to pass the matching argument.
A space-separated list of the types or modes of tests to run. Aliased as -m. Available modes:
type- Runs Typescript type-checkinglint- Runs ESLintspec- Runs Jest-based tests
Optional. Defaults to all modes.
This will initialize the "start", "test" and "integrate" scripts in the package.json to pass the matching argument.
benmvp create will automatically add the latest version of @benmvp/cli as a dev dependency to your library, even if a package.json exists. However, you can manually install it.
Install via npm:
npm install --save-dev @benmvp/cliInstall via Yarn:
yarn add --dev @benmvp/cliYou will want to create scripts to call benmvp test, benmvp start, and benmvp build for ease of use.
Looking for Node API docs? View companion create() documentation.
Still unsure of how to use @benmvp/cli? Ask for help!