@hyperfrontend/workspace/generators/rename

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).

npx hf generate rename my-utils shared-utils
npx hf generate rename my-utils shared-utils --packageName=@acme/shared
OptionWhat it sets
--projectThe current project name (also the first positional argument)
--newNameThe new project name
--packageNameThe new package name; defaults to the new name under the package's current scope
--skipFormatLeave 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

§function

planRename(tree: Tree, options: RenameGeneratorOptions): RenamePlan

Settles the options: the project's root and its package's names.
Parameters
NameTypeDescription
§tree
TreeThe tree the project lives in
§options
RenameGeneratorOptionsThe options as given
Returns
RenamePlan
The 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',
// }
§function

renameGenerator(tree: Tree, options: RenameGeneratorOptions): Promise<void>

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
NameTypeDescription
§tree
TreeThe tree, rooted at the workspace
§options
RenameGeneratorOptionsWhich 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-utils

Choosing 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

§interface

RenameGeneratorOptions

What the rename generator takes.
Properties
§project:stringThe project renamed
§newName:stringThe project's new name
§packageName?:stringThe package's new name; the new name under the package's current scope when unset
§skipFormat?:booleanSkip formatting the generated files
§interface

RenamePlan

The options settled.
Properties
§currentProjectName:stringThe project's current name
§projectRoot:stringThe project's directory, relative to the root
§newProjectName:stringThe project's new name
§currentPackageName:stringThe package's current name, or undefined for a project with no package
§newPackageName:stringThe package's new name, or undefined for a project with no package