Skip to content

Latest commit

 

History

History
79 lines (54 loc) · 2.38 KB

01-create-a-project.md

File metadata and controls

79 lines (54 loc) · 2.38 KB

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/cli to create a project
  • Familiarize with lint, lint:fix, and test

Use the CLI

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

Local development

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

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/format-changelogs.cjs - link to the GitHub repo
  • CONTRIBUTING.md - link to the GitHub repo
  • LICENSE.md - copyright information
  • package.json - author, description, repository (remove private to publish the codemod)
  • README.md - link to the GitHub repo, codemod description, codemod options