Refactoring
These commands change many files at once. Each takes --dry-run to print what would change and write nothing.
package:rename
pnpx @frigear-nu/cli package:rename <package> <new-name> [--dir] [--dry-run]
| Argument | Default | Purpose |
|---|---|---|
package | required | The package: its current name, or its folder (relative to --cwd or the workspace root). |
new-name | required | The new name. A bare name keeps the old scope: forms renames @acme/old to @acme/forms. |
--dir | false | Also rename the folder to the new unscoped name, and fix paths that point into it. |
--dry-run | Print what would change; write nothing. |
It changes, across the workspace (skipping node_modules, .nuxt, .output, .data, dist, hidden folders and
changelogs):
- the package's own
name; - the key in the
dependencies,devDependencies,peerDependencies,optionalDependenciesandpeerDependenciesMetaof everypackage.json, keeping the spec (workspace:*staysworkspace:*); - keys and list items of
pnpm-workspace.yaml(catalog,overrides,minimumReleaseAgeExclude), edited as text so comments stay; - string literals equal to the name or starting with
<name>/in.ts,.mts,.js,.mjs,.vueand.jsonfiles: imports,import('…'),nuxt.configmodulesentries, tsconfigpaths; and mentions in Markdown.
An unscoped name is too common a word to replace in every string, so for one only manifests and import, export and
require specifiers change, and the command says so. Lockfiles are never edited: run pnpm install afterwards, then
nuxi prepare in the apps that use the package.
module folder
pnpx @frigear-nu/cli module folder <module> [--app <app>] [--runtime] [--dry-run]
| Argument | Default | Purpose |
|---|---|---|
module | required | A path to modules/<name>.ts in an app or layer, or a bare name looked up in the app's modules/. |
--app | as for module add | The app a bare name is looked up in: a path, or a folder under apps/. |
--runtime | false | Also create runtime/plugin.ts, a plugin stub. |
--dry-run | Print what would change; write nothing. |
Nuxt registers both modules/*.ts and modules/*/index.ts, so modules/foo.ts can become modules/foo/index.ts
with a runtime/ folder next to it. The command moves the file, rewrites its relative imports (./x becomes ../x)
and updates imports of it that name the file with its extension; an extensionless ../modules/foo still resolves, so it
stays. It refuses when modules/foo/ exists. When the module has no createResolver(import.meta.url), it prints how
to add one and register runtime files with resolve('./runtime/…').
module move
pnpx @frigear-nu/cli module move <module> <destination> [--name <name>] [--app <app>] [--dry-run]
| Argument | Default | Purpose |
|---|---|---|
module | required | A module file (modules/foo.ts), a folder module (modules/foo/), a package folder, or a bare name in the app's modules/. |
destination | required | The directory to move it into. For a local module, an app or layer folder (one with a nuxt.config) means its modules/. |
--name | the current name | New file or folder name. A package keeps its name: use package:rename for that. |
--app | as for module add | The app a bare module name is looked up in. |
--dry-run | Print what would change; write nothing. |
It refuses to overwrite. Relative paths inside the moved files that point outside them are made relative to the new
place, and relative or ~~/ paths elsewhere in the workspace that point into it (imports, nuxt.config extends and
modules entries, tsconfig extends, Markdown links) follow it. Paths that do not resolve to an existing file are left
alone. It warns when:
- a moved file uses a Nuxt alias (
~/,~~/) that now resolves against another app; - the module imports a package the source app depends on and the destination does not;
- a package folder lands outside the
packages:globs ofpnpm-workspace.yaml, where pnpm will not link it.
Restart nuxi dev in both apps after moving a local module, and run pnpm install after moving a package.