Skip to content

Latest commit

 

History

History
132 lines (84 loc) · 7.12 KB

create.md

File metadata and controls

132 lines (84 loc) · 7.12 KB

benmvp create Documentation

Creates a new library or updates an existing library, to be set up with infrastructure using the latest version of @benmvp/cli.

It will:

NOTE: benmvp create can be called multiple times on a repo. It's a good idea to call benmvp create every time you bump the version of @benmvp/cli so you can get the latest configuration for package.json, prettier, Github workflows, Github PR/Issue templates, and other miscellaneous config files.

Looking for Node API docs? View companion create() documentation.

Examples

@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-fun

Add lint verification to an existing library:

npx @benmvp/cli create --modes lint

Create a new library named my-lib that only outputs ESM format:

npx @benmvp/cli create my-lib --formats esm

Add custom setup to an existing library:

npx @benmvp/cli create --modes type spec --out ./built --formats esm cjs

Arguments

[name]

(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.json does not already exist, it creates a new package.json with the name matching the directory it's within.
  • If a package.json does exist, it does nothing to the existing package.json.

When name is specified, it will create a directory of name within the current working directory. Also:

  • If a package.json does not already exist, it creates a new package.json with the specified name.
  • If a package.json does exist, it updates the "name" property of the package.json with specified name.

--formats

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-typed
  • esm - ECMAScript module format (everything transpiled to ES5 except for ES2015 import/export statements 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.

--out

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.

--modes

A space-separated list of the types or modes of tests to run. Aliased as -m. Available modes:

  • type - Runs Typescript type-checking
  • lint - Runs ESLint
  • spec - 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.

Manual installation

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/cli

Install via Yarn:

yarn add --dev @benmvp/cli

You will want to create scripts to call benmvp test, benmvp start, and benmvp build for ease of use.


More help

Looking for Node API docs? View companion create() documentation.

Still unsure of how to use @benmvp/cli? Ask for help!