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/cli
to create a project - Familiarize with
lint
,lint:fix
, andtest
Change the directory to a place where you like to keep projects. Then, run these commands:
# Create project
npx @codemod-utils/cli ember-codemod-rename-test-modules --addon ast-javascript
# Install dependencies
cd ember-codemod-rename-test-modules
pnpm install
Afterwards, 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 [email protected]:<your-github-handle>/<your-repo-name>.git
git branch -M main
git push -u origin main
As you write code, you will want to lint and test files.
# Lint files
pnpm lint
pnpm lint:fix
# Test files
pnpm test
Try running these scripts now. They should pass out of the box.
(The scripts for local development are documented in your project's CONTRIBUTING.md
.)
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/format-changelogs.cjs
- link to the GitHub repoCONTRIBUTING.md
- link to the GitHub repoLICENSE.md
- copyright informationpackage.json
-author
,description
,repository
(removeprivate
to publish the codemod)README.md
- link to the GitHub repo, codemod description, codemod options