https://github.com/nice-winter/template-ts
A Template for Node.js using TypeScript and ES Module.
https://github.com/nice-winter/template-ts
nodejs nodejs-template rollup-example template ts-template typescript typescript-example typescript-template
Last synced: 2 months ago
JSON representation
A Template for Node.js using TypeScript and ES Module.
- Host: GitHub
- URL: https://github.com/nice-winter/template-ts
- Owner: nice-winter
- License: mit
- Created: 2023-10-12T08:18:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-10T13:33:50.000Z (2 months ago)
- Last Synced: 2025-04-10T23:48:32.093Z (2 months ago)
- Topics: nodejs, nodejs-template, rollup-example, template, ts-template, typescript, typescript-example, typescript-template
- Language: TypeScript
- Homepage:
- Size: 186 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# template-ts [](https://github.com/nice-winter/template-ts/actions/workflows/ci.yml)
A Node.js template with TypeScript and ES Module support. It is designed for quickly initializing an empty TypeScript project, with pre-configured support for [oxlint](https://oxc.rs/docs/guide/usage/linter.html) for code linting, [tsup](https://tsup.egoist.dev) for JavaScript bundling, and VSCode debugging.
It also comes with pre-configured CI/CD workflows based on GitHub Actions, making it suitable for rapid library development or quick prototyping, without the need to set everything up from scratch.
Projects initialized with this template are recommended to be developed in [VS Code](https://code.visualstudio.com).
## Features
- ✅ ES Module support.
- 🩹 Linting and formatting with Git hooks.
- 📝 Automatically watches for file changes and restarts.
- 🐞 VS Code debugging support.
- 📦 Bundles JavaScript using [tsup](https://tsup.egoist.dev).
- 🚀 CI/CD integration.## Environment Requirements
- **Node.js**: Requires version **22.0.0** or higher.
## Usage
### Initialization
Click the `Use this template` button at the top-right and set a name for the new repository,
or directly clone this repository to your local machine:
```bash
# Use the `degit` command to clone the template repository to your local machine.
npx degit nice-winter/template-ts my-project# Enter the project directory and install dependencies.
cd my-project
npm i# Start and watch for file changes.
npm run dev
```### Develop and build
Start and watch for file changes:
```bash
npm run dev
```Linting & Formatting:
```bash
# lint
npm run lint# format
npm run format
```Bundling to JavaScript:
```bash
# build for production
npm run build
```The JavaScript files will output to `dist` .
### CI/CD
This template comes with the following pre-configured workflows:
- **ci**: Triggered on any push or when a PR is opened to the `main` branch.
It runs a series of unit tests and builds the project.- **release**: Triggered when a tag is pushed with the format `v*`.
It automatically creates a release in the repository and applies the corresponding tag.- **publish**: Triggered when a tag is pushed with the format `v*`.
It runs unit tests and builds the project before publishing it to NPM.**However, you need to adjust the following configurations for publish to work properly.**
1.You need to add your `NPM_TOKEN` to the secrets in the repository settings.
2.To prevent accidental publishing, the template project's package.json has private set to true by default. To publish your package, you must change `private` from true to `false` in package.json:
```diff
{
"name": "@nice-winter/template-ts",
"description": "...",
"version": "1.0.0",
- "private": true,
+ "private": false,
// ...Other keys...
}
```3.Update the `repository.url` field in package.json to **your repository URL**:
⚠️ **Note:** The publish workflow enables [Generating provenance statements](https://docs.npmjs.com/generating-provenance-statements) by default when publishing to NPM. You need to update the `repository.url` field in package.json to your own repository URL, otherwise, it will cause an error.
```diff
{
"author": "...",
"repository": {
- "url": "git+https://github.com/nice-winter/template-ts.git"
+ "url": "git+https://github.com/yourname/your-repository.git"
},
"license": "MIT",
"dependencies": {},
// ...Other keys...
}
```Only then will the "Publish package" workflow be triggered. Otherwise, it will not be published to NPM.
## License
[MIT License](LICENSE)