An open API service indexing awesome lists of open source software.

https://github.com/ijlee2/ember-codemod-add-component-signatures

Codemod to add component signatures
https://github.com/ijlee2/ember-codemod-add-component-signatures

codemod ember-codemod emberjs embroider glint typescript

Last synced: 3 months ago
JSON representation

Codemod to add component signatures

Awesome Lists containing this project

README

          

[![This project uses GitHub Actions for continuous integration.](https://github.com/ijlee2/ember-codemod-add-component-signatures/actions/workflows/ci.yml/badge.svg)](https://github.com/ijlee2/ember-codemod-add-component-signatures/actions/workflows/ci.yml)

# ember-codemod-add-component-signatures

_Codemod to add component signatures_

## What is it?

To introduce Glint, you will need to write the [signature](https://typed-ember.gitbook.io/glint/environments/ember/component-signatures) and [template registry](https://typed-ember.gitbook.io/glint/environments/ember/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 `` tag (Glint v2)



A code diff to show what template-only components can look like before and after running ember-codemod-add-component-signatures


Template-only components





A code diff to show what Glimmer components can look like before and after running ember-codemod-add-component-signatures
Another code diff for a Glimmer component


Glimmer components

## Usage

Step 1. Quickly migrate.1

```sh
cd
pnpx ember-codemod-add-component-signatures
```

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](#frequently-asked-questions).

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](https://github.com/ember-codemods/ember-component-template-colocation-migrator) and [pod](https://github.com/ijlee2/ember-codemod-pod-to-octane).

### Arguments

Optional: Limit entity to consider

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.

```sh
# `ui/form` only
pnpx ember-codemod-add-component-signatures --entity ui/form
```

Optional: Specify the component structure

By default, an Octane project has the flat component structure. Pass `--component-structure` to indicate otherwise.

```sh
pnpx ember-codemod-add-component-signatures --component-structure nested
```

Optional: Convert *.{js,gjs} files

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

```sh
pnpx ember-codemod-add-component-signatures --convert-javascript
```

Optional: Create registries

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

```sh
pnpx ember-codemod-add-component-signatures --create-registries
```

Optional: Specify the project root

Pass `--root` to run the codemod on a project somewhere else (i.e. not in the current directory).

```sh
pnpx ember-codemod-add-component-signatures --root
```

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

```sh
cd

# Compile TypeScript
pnpm build

# Run codemod
./dist/bin/ember-codemod-add-component-signatures.js --root
```

## Compatibility

- Node.js v22 or above

## Contributing

See the [Contributing](CONTRIBUTING.md) guide for details.

## License

This project is licensed under the [MIT License](LICENSE.md).