This is a template for a Node.js TypeScript app.
The following tools and conventions have been configured:
- "Conventional Commits" for commit messages;
- "Dev Containers" for development Docker containers;
- "Docker" for containerization;
- "ESLint" for linting;
- "eslint-plugin-import" for linting import/export;
- "eslint-plugin-sort-destructure-keys"" for sorting destructuring keys;
- "eslint-plugin-svelte" for linting Svelte;
- "typescript-eslint" for linting TypeScript;
- "GitHub Actions" for CI/CD;
- "Hadolint" for linting Dockerfiles;
- "npm" for package management and Node.js scripts;
- "Prettier" for code formatting;
- "prettier-plugin-svelte" for formatting Svelte;
- "release-it" for releasing;
- "@release-it/conventional-changelog" for generating changelogs automatically;
- "Testcontainers" for testing with Docker containers;
- "tsx" for running TypeScript code;
- "TypeScript" for TypeScript support;
npm ci
You can edit the code in the "src
" directory.
The entry point of the application is "src/main.ts
".
npm run dev
Note: The project uses "tsx" to run TypeScript code on the fly.
npm run compile
This will create a "dist
" directory with the compiled code.
Note: The "dist
" directory will mimic the main directory structure. All directories with TypeScript files will be recreated in the "dist
" directory. In the default configuration those are "src
" and "test
".
node ./dist/main.js
Note: This will command will fail if the application has not been compiled (no "dist
" directory)!
Native Node.js test runner is used to run the tests. Native "node:assert" and "node:test" modules are used to write the tests.
Source code-related tests are kept alongside the source code they test in the "src
" directory. Other tests and test utilities are kept in the "test
" directory.
To run the unit tests:
npm run test
The coverage report can be generated in the "lcov" format by running:
npm run test:experimental-coverage
After running the command, the coverage report will be available in the "lcov.info
" file.
Note that the coverage report is experimental as it only works on compiled code.
"ESLint" is used to lint the code.
npm run eslint:check
Note: The linter will return a non-zero exit code if there are any linting errors or warnings.
You can also try to automatically fix some of the errors and warnings by running:
npm run eslint:fix
"Prettier" is used to format the code.
npm run prettier:check
Formatting errors can be automatically fixed by running:
npm run prettier:fix
"Conventional Commits" are used to format the commit messages.
The following types are supported:
- "
feat
": A new feature; - "
fix
": A bug fix; - "
chore
": Other changes;
Use {type}!: {description}
as the commit message for breaking changes.
Thanks to the "@release-it/conventional-changelog" plugin for "release-it", the changelog will be automatically generated when releasing. Also, the version number will be automatically incremented based on the commit messages.
There is one CI pipeline configured in the ".github/workflows
" directory:
- "Continuous integration": This pipeline will check the integrity of the code by running formatting, linting, and testing.
There is one CD pipeline configured in the ".github/workflows
" directory:
- "Release": This pipeline will create a GitHub release, build a Docker image, and push it to a Docker registry and also push the compiled code to npm.