# rename 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). ```bash 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 #### planRename ```typescript function planRename(tree: Tree, options: RenameGeneratorOptions): RenamePlan ``` 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** `RenamePlan`: The root and the names the rename writes from **Example: The package keeps its scope** ```typescript 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', // } ``` #### renameGenerator ```typescript function renameGenerator(tree: Tree, options: RenameGeneratorOptions): Promise ``` 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`: Resolves when the rename is written **Example: Renaming a project from the command line** ```bash npx hf generate rename my-utils better-utils ``` **Example: Choosing the package name rather than deriving it** ```typescript import renameGenerator from '@hyperfrontend/workspace/generators/rename' await renameGenerator(tree, { project: 'my-utils', newName: 'better-utils', packageName: '@acme/utils' }) ``` ### Interfaces #### RenameGeneratorOptions What the `rename` generator takes. **Properties** | Name | Type | Description | | --- | --- | --- | | `project` | `string` | The project renamed | | `newName` | `string` | The project's new name | | `packageName?` | `string` | The package's new name; the new name under the package's current scope when unset | | `skipFormat?` | `boolean` | Skip formatting the generated files | #### RenamePlan The options settled. **Properties** | Name | Type | Description | | --- | --- | --- | | `currentProjectName` | `string` | The project's current name | | `projectRoot` | `string` | The project's directory, relative to the root | | `newProjectName` | `string` | The project's new name | | `currentPackageName` | `string` | The package's current name, or undefined for a project with no package | | `newPackageName` | `string` | The package's new name, or undefined for a project with no package | --- Canonical page: https://www.hyperfrontend.dev/docs/libraries/workspace/generators/rename/ This file: https://www.hyperfrontend.dev/docs/libraries/workspace/generators/rename.md Documentation index: https://www.hyperfrontend.dev/llms.txt