Skip to content

Latest commit

 

History

History
99 lines (66 loc) · 3.44 KB

DEVELOPMENT.md

File metadata and controls

99 lines (66 loc) · 3.44 KB

Development

After forking the repo from GitHub and installing pnpm:

git clone https://github.com/<your-name-here>/all-contributors-auto-action
cd all-contributors-auto-action
pnpm install

This repository includes a list of suggested VS Code extensions. It's a good idea to use VS Code and accept its suggestion to install them, as they'll help with development.

Building

Run TypeScript locally to type check and build source files from src/ into output files in lib/:

pnpm build --watch

You should also see suggestions from TypeScript in your editor.

Building for Release

We use @vercel/ncc to create an output dist/ to be used in production.

pnpm build:release

Formatting

Prettier is used to format code. It should be applied automatically when you save files in VS Code or make a Git commit.

To manually reformat all files, you can run:

pnpm format:write

Linting

This package includes several forms of linting to enforce consistent code quality and styling. Each should be shown in VS Code, and can be run manually on the command-line:

  • pnpm lint:knip (knip): Detects unused files, dependencies, and code exports
  • pnpm lint:md (Markdownlint): Checks Markdown source files
  • pnpm lint:package (npm-package-json-lint): Lints the package.json file
  • pnpm lint:packages (pnpm-deduplicate): Deduplicates packages in the pnpm-lock.yml file
  • pnpm lint:spelling (cspell): Spell checks across all source files
  • pnpm lint (ESLint with typescript-eslint): Lints JavaScript and TypeScript source files

Testing Locally

You can run this locally by running lib/index.js. Be sure to pnpm build before running.

In one (background/secondary) terminal:

pnpm build -w

In your primary terminal, run lib/index.js with the following environment variables:

  • GITHUB_REPOSITORY: Locator for the repository to run against, in a format like Owner/repository.
  • GITHUB_TOKEN: Your GitHub auth token, to avoid API throttling
  • LOCAL_TESTING: Indicates to log comments that would be creating to the console, instead of actually POSTing them to GitHub

For example:

GITHUB_REPOSITORY=YourUsername/your-repository-name GITHUB_TOKEN=$(gh auth token) LOCAL_TESTING=true node lib/index.js

Unit Tests

Vitest is used for some small tests. You can run it locally on the command-line:

pnpm run test

Add the --coverage flag to compute test coverage and place reports in the coverage/ directory:

pnpm run test --coverage

Note that console-fail-test is enabled for all test runs. Calls to console.log, console.warn, and other console methods will cause a test to fail.

Debugging Tests

This repository includes a VS Code launch configuration for debugging unit tests. To launch it, open a test file, then run Debug Current Test File from the VS Code Debug panel (or press F5).