Write a brief description of your project and what it aims to achieve.
- Project Title
To use this project/template, follow the steps below:
Update the name and description in package.json
and README.md
to match your project.
Clone the repository to your local machine:
git clone https://github.com/benjaminrae/node-ts-jest-starter.git
Alternatively, you can click on the Use this template button to create a new repository using this template.
Navigate to the project directory:
cd your-repo
Install the dependencies using pnpm:
pnpm install
Customize the project according to your needs. Update the source code, configuration files, and other relevant files to match your requirements.
Start the development server:
pnpm start:dev
This command will run the application in development mode using Nodemon, allowing the server to automatically restart whenever changes are detected.
Write tests for your application and place them in the appropriate directories.
Run tests using the following command:
pnpm test
This command will execute the test runner (Jest) and display the test results.
Customize the linting rules and configurations as per your project requirements. Run the linting scripts to ensure code quality and consistency:
pnpm lint
This command will execute ESLint, Prettier, and Markdownlint scripts to check the code and documentation for linting errors.
Customize the provided CI workflows according to your needs. Configure the commitlint, build and test workflows, and add or modify other workflows as required.
When you're ready to commit your changes, use the following command to create a commit using Commitizen:
pnpm commit
This command will launch the Commitizen CLI, guiding you through the commit message creation process and ensuring a consistent commit message format.
Push your changes to the remote repository:
git push origin main
This template includes linting tools to maintain code quality and consistency:
- ESLint: Lints JavaScript and TypeScript files.
- Prettier: Enforces code formatting rules.
- Markdownlint: Checks Markdown (*.md`) files for linting errors.
Feel free to customize the linting rules or configurations in .eslintrc.cjs
, .editorconfig
, .prettierrc.json
and .markdownlint.json
as per your project requirements.
See: ESLint | Editor Config | Prettier | Markdownlint
Your template uses Jest as the test runner.
Once you have written your first test, it's advisable to remove the --passWithNoTests
flag from the test
scripts in package.json
.
Customize the testing setup in jest.config.cjs
and write your tests according to your project needs.
See: Jest
Your template comes with 4 CI workflows that can be configured:
- Commitlint: Checks commit messages against defined rules in
commitlint.config.cjs
. Commit messages must follow the Conventional Commits specification. - Build: Builds the project.
- Test: Executes tests.
- Audit: Linting and similar jobs.
Feel free to configure these workflows as needed or add additional workflows based on your project requirements.
Your template uses Husky to set up the following Git hooks:
- Pre-commit: Executes lint-staged and other checks before allowing commits.
- Commit-msg: Validates commit messages using Commitlint.
- Pre-push: Checks branch name and runs testing. Update the allowed branch names in
.husky/pre-push
as needed. - Post-merge: Installs dependencies if there are changes in
pnpm-lock.yaml
.
Feel free to customize the Git hooks based on your project requirements.
If using a Mac, you may need to give the hooks executable permissions using the steps here.
See: Husky | lint-staged | Commitlint
The template uses Commitizen to enforce a consistent commit message format. Use the following script to create commits:
pnpm commit
: Launches the Commitizen CLI to guide you through the commit message creation process.
Ensure that you follow the commit guidelines and maintain a clean commit history.
See: Commitizen | Conventional Commits | Commitlint
The template uses pnpm
as the package manager. Make sure you have pnpm
installed globally or use it with npx
when running the scripts.
See: pnpm
Explain how others can contribute to your project/template. You can include guidelines for submitting bug reports, feature requests, or pull requests. It's also helpful to mention the coding standards or guidelines you expect contributors to follow. Check out Contributor Covenant for help creating a code of conduct for your project.
Mention the license under which your project/template is released. If you're unsure about which license to choose, you can visit choosealicense.com for guidance. Make sure to include any additional terms or conditions specific to your project.
In the project directory, you can run the following scripts:
Runs the application in production mode. It starts the Node.js server.
Runs the application in development mode using Nodemon. Nodemon automatically restarts the server whenever changes are detected, making the development process more efficient.
Launches the test runner (Jest) to execute the tests. By default, it only shows test results for files that have changed since the last commit.
Generates test coverage reports using Jest. It provides detailed information about the code coverage of your tests.
Runs the test runner in watch mode. It re-runs the tests whenever changes are detected, making it convenient for continuous testing during development.
Builds the TypeScript code into JavaScript, generating the compiled files in the dist
directory.
Builds the TypeScript code into JavaScript in watch mode. It automatically recompiles the code whenever changes are made.
Deletes the dist
directory, removing the previously built files.
Combines the clean
and build
commands. It removes the dist
directory and then builds the TypeScript code into JavaScript.
Formats the JavaScript, TypeScript, JSON, Markdown, and other supported files using Prettier.
Checks if the files need to be formatted according to Prettier's rules. It lists the files that differ from the expected formatting.
Formats the files according to Prettier's rules and automatically fixes any formatting issues.