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:
monopkg move [packages...] [options]
bun x monopkg move [packages...] [options]
npx monopkg move [packages...] [options]
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:
monopkg move users posts galleries --workspace services
bun x monopkg move users posts galleries --workspace services
npx monopkg move users posts galleries --workspace services
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.
monopkg move @test/ui --name @test/ui-kit --path ui-kit
bun x monopkg move @test/ui --name @test/ui-kit --path ui-kit
npx monopkg move @test/ui --name @test/ui-kit --path ui-kit
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