ember-codemod-add-component-signatures
v5.6.0
Published
Codemod to add component signatures
Maintainers
Readme
ember-codemod-add-component-signatures
Codemod to add component signatures
What is it?
To introduce Glint, you will need to write the signature and template registry for each component. This can be an error-prone, onerous task for large projects.
You can run this codemod to get started.
Features
- Scaffolds signature for components
- Adds template registry for components (Glint v1)
- Supports
<template>tag (Glint v2)
Usage
Step 1. Quickly migrate.1
cd <path/to/your/project>
pnpx ember-codemod-add-component-signatures <arguments>Step 2. Review the package.
- [x] Fill in missing type information.
- [x] Confirm that you can run all scripts in
package.json.
For more information, please check the FAQ.
1. The codemod assumes that your apps and addons follow the Octane layout (flat or nested). If not, you can run codemods to move away from classic and pod.
Arguments
By default, the codemod considers all files and folders for components, routes, and tests. Pass --entity to limit the search to 1 entity and its sub-entities (if any). You may use curly braces to specify multiple entities.
# `ui/form` only
pnpx ember-codemod-add-component-signatures --entity ui/formBy default, an Octane project has the flat component structure. Pass --component-structure to indicate otherwise.
pnpx ember-codemod-add-component-signatures --component-structure nestedBy default, the codemod ignores component classes written in *.{js,gjs}. Pass --convert-javascript to allow the codemod to change the file extension to *.{ts,gts} and add the component signature.
pnpx ember-codemod-add-component-signatures --convert-javascriptBy default, the codemod doesn't add registries to component classes, because these registries are unnecessary for Glint v2 (strict mode templates). Pass --create-registries if you use Glint v1 (loose mode templates).
pnpx ember-codemod-add-component-signatures --create-registriesPass --root to run the codemod on a project somewhere else (i.e. not in the current directory).
pnpx ember-codemod-add-component-signatures --root <path/to/your/project>Limitations
The codemod is designed to cover typical cases. It is not designed to cover one-off cases. (Classic components are not supported.)
To better meet your needs, consider cloning the repo and running the codemod locally.
cd <path/to/cloned/repo>
# Compile TypeScript
pnpm build
# Run codemod
./dist/bin/ember-codemod-add-component-signatures.js --root <path/to/your/project>Compatibility
- Node.js v22 or above
Contributing
See the Contributing guide for details.
License
This project is licensed under the MIT License.
