@hyperfrontend/workspace/generators/renamerename
Renames a project and carries the new name into everything that refers to it: both manifests, the alias in tsconfig.base.json, the project references, its own README and module headers, and the project that tests the library (its names, descriptions and the tarball it pins).
npx hf generate rename my-utils shared-utils
npx hf generate rename my-utils shared-utils --packageName=@acme/shared
| Option | What it sets |
|---|---|
--project | The current project name (also the first positional argument) |
--newName | The new project name |
--packageName | The new package name; defaults to the new name under the package's current scope |
--skipFormat | Leave the written files unformatted |
The sources of other projects that import the package are not rewritten; the lint rule for module boundaries reports and fixes them.
API Reference§
ƒ Functions
Settles the options: the project's root and its package's names.
Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | The tree the project lives in |
§options | RenameGeneratorOptions | The options as given |
Returns
RenamePlanThe root and the names the rename writes from
Example
The package keeps its scope
planRename(tree, { project: 'my-utils', newName: 'better-utils' })
// => {
// currentProjectName: 'my-utils',
// projectRoot: 'libs/my-utils',
// newProjectName: 'better-utils',
// currentPackageName: '@acme/my-utils',
// newPackageName: '@acme/better-utils',
// }Renames a project: its
project.json and package.json, its aliases in tsconfig.base.json, the implicitDependencies and dependsOn entries that name it, the package name its README and module header mention, and the project that tests it. The directory stays where it is; the move generator relocates it.Parameters
| Name | Type | Description |
|---|---|---|
§tree | Tree | The tree, rooted at the workspace |
§options | RenameGeneratorOptions | Which project, and its new names |
Returns
Promise< void>Resolves when the rename is written
Examples
Renaming a project from the command line
npx hf generate rename my-utils better-utilsChoosing the package name rather than deriving it
import renameGenerator from '@hyperfrontend/workspace/generators/rename'
await renameGenerator(tree, { project: 'my-utils', newName: 'better-utils', packageName: '@acme/utils' })◈ Interfaces
What the
rename generator takes.Properties
The options settled.