Skip to content

Create Package

In a monorepo, you may need to create new packages from templates to streamline the development process. By using the monopkg create command, you can quickly generate new packages with predefined configurations and structures. This not only saves time but also ensures consistency across your packages, making it easier to maintain and scale your monorepo.

Usage

This command allows you to create a new package from a template.

bash
monopkg create <template-name> [options]
bash
bun x monopkg create <template-name> [options]
bash
npx monopkg create <template-name> [options]
bash
yarn dlx monopkg create <template-name> [options]

Options

  • -n, --name - Package name.
  • -o, --out-path - Path to the package directory.
  • -c, --cwd-path - Create new directory and cd to it.
  • -w, --workspace - Workspace of the new package (default: ./packages).

NOTE

In case you are creating a package using a non-builtin template, you may encounter a situation where you need to cd to a specific directory before running the template command. In such cases, you can use the --cwd-path instead of --out-path option to create a new directory and cd to it before running the template command.

Examples

Basic Usage

The simplest way to create a new package is by using the interactive mode. This will allow you to select the workspace, template, and package name from a list of available options.

bash
monopkg create
bash
bun x monopkg create
bash
npx monopkg create
bash
yarn dlx monopkg create

The command will prompt you to select the workspace, template, location, and package name.

Create Package

Non-Built-in Templates

In case you want to use a non-built-in template, you can specify the template name as an argument. For example, to create a new package using the create-next-app template, you can run the following command:

bash
monopkg create create-next-app
bash
bun x monopkg create create-next-app
bash
npx monopkg create create-next-app
bash
yarn dlx monopkg create create-next-app

NOTE

Non-builtin template should follow the npx {create-name} format. If you need to add an argument to the template command, you need to quote the template command and arguments.

Released under the MIT License.