Create a project
We will use @codemod-utils/cli (a command-line interface) to create a Node project. The project comes with lint, test, CI (continuous integration), and documentation out of the box.
The CLI automatically adds @codemod-utils/files and @codemod-utils/tests (these packages are "core"), because every codemod will need them. For ember-codemod-rename-test-modules, we will need to parse and update JavaScript and TypeScript files, so we will instruct the CLI to also add @codemod-utils/ast-javascript (an "addon").
Goals:
- Use
@codemod-utils/clito create a project - Familiarize with
lint,lint:fix, andtest
Use the CLI
Change the directory to a place where you like to keep projects. Then, run these commands:
# Create project
pnpx @codemod-utils/cli ember-codemod-rename-test-modules --addon ast-javascript
# Install dependencies
cd ember-codemod-rename-test-modules
pnpm installAfterwards, you may commit the changes to a GitHub repo.
# Commit changes
git init
git add .
git commit -m "Initial commit"# Push changes (to a new repo)
git remote add origin git@github.com:<your-github-handle>/<your-repo-name>.git
git branch -M main
git push -u origin mainLocal development
As you write code, you will want to lint and test files.
# Lint files
pnpm lint
pnpm lint:fix
# Test files
pnpm testTry running these scripts now. They should pass out of the box.
TIP
The scripts for local development are documented in your project's CONTRIBUTING.md.
Update configurations
The CLI added a few placeholders. At some point—before the initial commit or, at the latest, before publishing your codemod—you will want to manually update these files:
.changeset/formatter.mjs- link to the GitHub repoCONTRIBUTING.md- link to the GitHub repoLICENSE.md- copyright informationpackage.json-author,description,repository(removeprivateto publish the codemod)README.md- link to the GitHub repo, codemod description, codemod options