1.0.2 • Published 1 year ago
ts-scribe-test v1.0.2
Template for TypeScript Package
Features
- TypeScript: The template is preconfigured with TypeScript, enabling you to write type-safe code and take advantage of the rich ecosystem of TypeScript tooling.
- Bundler: The template uses Tsup for building. Tsup is powered by esbuild, which means it's really fast.
- Linting: The template incorporates a linter (typescript-eslint) with predefined rules to enforce best practices.
- Code Formatting: The template includes Prettier, a code formatting tool, to automatically format your TypeScript code and ensure consistent formatting across the project.
- Git Hooks: The template includes two pre-configured git hooks using Husky to automate tasks. One for formatting, linting and testing before each commit (with lint-staged). And another for checking coverage before each push.
- dotenv: The template includes dotenv-cli, which allows you to load environment variables from a
.env
file during development or deployment (see npm scriptrelease
). This enables you to securely store sensitive data like API keys, database credentials, and configuration settings outside your codebase. - Test Framework: The template is integrated with a fast test framework (Vitest) to facilitate unit testing of your package.
- Code Coverage: It includes a code coverage tool (Vitest/C8) to help you monitor and maintain a high level of test coverage.
- Documentation: The template provides a basic structure for documentation, including a README file where you can describe the package and provide instructions for installation, usage, and contribution. In the folder
.github
, there is a template for pull requests (PR). This template will be used automatically by GitHub whenever you are creating a PR for your package. - npm Scripts: The template includes a set of npm scripts for common development tasks such as building, testing, linting, and releasing your package.
- CI/CD Configuration: The template can be easily integrated with popular CI/CD services (such as GitHub Actions or Travis CI) to automate the build, test, and release processes. It uses semantic-release to control versioning, publishing and releasing.
- License: It includes a license file where you can specify the license under which you want to release your package. You can see more about licenses here.
Installation
- Create a new repository from this template.
- Install the dependencies by running
npm install
. - Open package.json and review the package's name, description, keywords, author's info, publish config's info, homepage's url, repository's info, and bug's url.
- Create a
.env
file (see.env.example
) and add your GITHUB_TOKEN and other environment-specific configuration settings, ensuring not to commit this file to version control (this template is already configured to ignore.env
files). - Open LICENSE and complete the fields year and name.
- Edit this README for the package's purpose.
- Delete the demo source code and have fun.
Usage
- Read the commit message conventions outlined in conventional commit spec.
- Implement your package logic by writing TypeScript code in the provided source files.
- Write unit tests to ensure the correctness of your code and maintain a high level of code coverage.
- Use the npm scripts provided to build, test, and lint your package (in fact, the template uses a git hook to format, lint and test before each commit).
- Update the README file to describe your package, its installation process, usage examples, and contribution guidelines.
- Publish your package to npm by running
npm run release
. This will automatically identify a new package's version based on the commit messages, create a new git tag, publish to npm (according to the property publishConfig inpackage.json
), push to the remote repository and create a new GitHub release with the changelog (it considers the property repository inpackage.json
).
NOTE: This template uses Verdaccio as a local npm proxy registry. You can configure CI/CD (e.g., GitHub actions) for your repository to automate the build, test, and release processes.
1.0.2
1 year ago