Skip to content

Move Packages

Moving packages is a common task when working with monorepos. MonoPKG simplifies this process by providing a command to move packages to a new workspace.

IMPORTANT

Before moving packages, make sure to commit your changes to avoid losing any work. MonoPKG only moves the packages without tracking changes in the repository.

Command

To move packages, you can run the following command:

bash
monopkg move [packages...] [options]
bash
bun x monopkg move [packages...] [options]
bash
npx monopkg move [packages...] [options]
bash
yarn dlx monopkg move [packages...] [options]

Options

  • --name - Set the new package name.
  • --path - Set the new package location (relative to a workspace).
  • --rename - Rename package in interactive mode.
  • -w, --workspace - Workspace to move the packages to.
  • -y, --yes - Skip interactive prompts and use default options.
  • --dry - Run in dry mode without writing any changes.

IMPORTANT

Renaming a package will apply the name change to the packages that depend on it. Make sure to commit your work before renaming a package to prevent losing any work.

Examples

Moving Packages

Move multiple packages to a new workspace:

bash
monopkg move users posts galleries --workspace services
bash
bun x monopkg move users posts galleries --workspace services
bash
npx monopkg move users posts galleries --workspace services
bash
yarn dlx monopkg move users posts galleries --workspace services

INFO

The above command will move the users, posts, and galleries packages to the services workspace, assuming the packages are located in the packages workspace before.

Renaming a Package

Rename a package and its folder location.

bash
monopkg move @test/ui --name @test/ui-kit --path ui-kit
bash
bun x monopkg move @test/ui --name @test/ui-kit --path ui-kit
bash
npx monopkg move @test/ui --name @test/ui-kit --path ui-kit
bash
yarn dlx monopkg move @test/ui --name @test/ui-kit --path ui-kit

INFO

The above command will change the package name from @test/ui to @test/ui-kit, and move the folder location from packages/ui to packages/ui-kit. If the @test/ui package has a dependents, it will also apply the name change to the packages that depend on it.

Sample Output

List Packages

Released under the MIT License.