Skip to content

Commit 8e35712

Browse files
Initial commit
0 parents  commit 8e35712

20 files changed

+3915
-0
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Main
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
permissions:
8+
pull-requests: write
9+
contents: read
10+
11+
on:
12+
push:
13+
branches:
14+
- main
15+
16+
pull_request:
17+
branches:
18+
- main
19+
20+
jobs:
21+
build-test:
22+
name: 📚 Main
23+
runs-on: ${{ matrix.os }}
24+
25+
strategy:
26+
matrix:
27+
os: [ubuntu-latest]
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- run: corepack enable
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: '20'
36+
cache: pnpm
37+
38+
- name: 📦 Install dependencies
39+
run: pnpm install --frozen-lockfile
40+
41+
- name: 🚀 Build
42+
run: pnpm build
43+
44+
- name: 👀 Lint
45+
run: pnpm lint
46+
47+
# - name: 🧪 Test
48+
# run: pnpm test
49+
# env:
50+
# VITE_TEST_DB_URL: ${{ secrets.VITE_TEST_DB_URL }}
51+
52+
- name: 🧪 Test with coverage
53+
run: pnpm coverage
54+
55+
- name: 📝 Upload coverage
56+
if: always()
57+
uses: davelosert/vitest-coverage-report-action@v2

.github/workflows/release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
pull-requests: write
10+
contents: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: 20.x
23+
24+
- run: npx changelogithub
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.log
2+
.DS_Store
3+
node_modules
4+
dist
5+
package-lock.json

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
shamefully-hoist=true
2+
git-checks=false

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// Enable the ESlint flat config support
3+
"eslint.experimental.useFlatConfig": true
4+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 productdevbook - Open Source
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Typescript Bundle Template
2+
3+
![Typescript Bundle Template](https://github.com/productdevbookcom/assets/blob/main/ts-bundle-template.jpg?raw=true)
4+
5+
6+
This is a template for creating a Typescript bundle. It is based on the [Typescript](https://www.typescriptlang.org/) compiler with the [Tsup](https://github.com/egoist/tsup) bundler.
7+
8+
## Features
9+
10+
- [x] [Typescript](https://www.typescriptlang.org/)
11+
- [x] [Tsup](https://github.com/egoist/tsup)
12+
- [x] [ESLint](https://eslint.org/) with [Antfu's ESLint Config](https://github.com/antfu/eslint-config)
13+
- [x] [Bumpp](https://github.com/antfu/bumpp) github changelog generator
14+
- [x] [Vitest](https://vitest.dev/)
15+
- [x] [Pnpm](https://pnpm.io/)
16+
- [x] [GitHub Actions]()
17+
- [x] [NPM Local Registry]()
18+
- [x] [Renovate]()
19+
20+
21+
## Usage
22+
23+
1. To use this template, click the "Use this template" button above.
24+
2. Clone the repository to your local machine.
25+
3. Run `pnpm install` to install the dependencies.
26+
4. Run `pnpm build` to build the bundle.
27+
5. Run `pnpm start` to start the bundle.
28+
6. Run `pnpm lint` to lint the code. (You can also run `pnpm lint:fix` to fix the linting errors.)
29+
7. Run `pnpm test` to run the tests. (You can also run `pnpm test:watch` to run the tests in watch mode.)
30+
8. Run `pnpm release` to bump the version. Terminal will ask you to select the version type. And then it will automatically commit and push the changes. GitHub Actions will automatically publish git tags. NPM local registry will automatically publish the package.
31+
32+
## Configuration
33+
34+
### Renovate
35+
36+
[Setup Github App](https://github.com/apps/renovate) for Renovate.
37+
38+
### TS Config Base
39+
40+
(tsconfig.json)[https://github.com/tsconfig/bases/tree/main/bases] is used as the base config for the Typescript compiler.
41+
42+
## Sponsors
43+
44+
<p align="center">
45+
<a href="https://cdn.jsdelivr.net/gh/oku-ui/static/sponsors/sponsors.svg">
46+
<img alt="sponsors" src='https://cdn.jsdelivr.net/gh/oku-ui/static/sponsors/sponsors.svg'/>
47+
</a>
48+
</p>
49+
50+
51+
## License
52+
53+
This project is licensed under the [MIT License](LICENSE).

eslint.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import antfu from '@antfu/eslint-config'
2+
3+
export default antfu(
4+
{},
5+
{
6+
ignores: [
7+
'dist',
8+
'.github',
9+
],
10+
},
11+
)

package.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "ts-bundle-template",
3+
"type": "module",
4+
"version": "0.0.0",
5+
"packageManager": "[email protected]",
6+
"description": "add description",
7+
"author": "add author",
8+
"license": "MIT",
9+
"funding": "https://github.com/sponsors/productdevbook",
10+
"homepage": "https://github.com/productdevbookcom/ts-bundle-template",
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/productdevbookcom/ts-bundle-template.git"
14+
},
15+
"bugs": "https://github.com/productdevbookcom/ts-bundle-template/issues",
16+
"keywords": [
17+
"add keywords"
18+
],
19+
"exports": {
20+
".": {
21+
"import": "./dist/index.js",
22+
"require": "./dist/index.cjs"
23+
}
24+
},
25+
"main": "./dist/index.js",
26+
"module": "./dist/index.js",
27+
"types": "./dist/index.d.ts",
28+
"files": [
29+
"dist"
30+
],
31+
"engines": {
32+
"node": ">=20"
33+
},
34+
"scripts": {
35+
"build": "tsup",
36+
"dev": "tsup --watch",
37+
"prepublishOnly": "pnpm run build",
38+
"release": "pnpm build && bumpp --commit --push --tag && pnpm publish",
39+
"lint": "eslint . && pnpm typecheck",
40+
"lint:fix": "eslint . --fix",
41+
"typecheck": "tsc --noEmit",
42+
"test": "vitest",
43+
"test:watch": "vitest --watch",
44+
"coverage": "vitest run --coverage"
45+
},
46+
"devDependencies": {
47+
"@antfu/eslint-config": "1.1.1",
48+
"@vitest/coverage-v8": "^0.34.6",
49+
"bumpp": "^9.2.0",
50+
"eslint": "^8.53.0",
51+
"lint-staged": "^15.1.0",
52+
"simple-git-hooks": "^2.9.0",
53+
"tsup": "^7.2.0",
54+
"typescript": "^5.2.2",
55+
"vitest": "^0.34.6"
56+
},
57+
"simple-git-hooks": {
58+
"pre-commit": "pnpm lint-staged"
59+
},
60+
"lint-staged": {
61+
"*": "pnpm eslint . --fix"
62+
},
63+
"publishConfig": {
64+
"access": "public"
65+
}
66+
}

playground/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { handler } from 'ts-bundle-template'
2+
3+
handler('test', 'test', (err: any, result: any) => {
4+
// eslint-disable-next-line no-console
5+
console.log(err, result)
6+
})

playground/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "playground",
3+
"version": "1.0.0",
4+
"description": "",
5+
"author": "",
6+
"license": "ISC",
7+
"keywords": [],
8+
"main": "index.js",
9+
"scripts": {
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"devDependencies": {
13+
"ts-bundle-template": "workspace:^"
14+
}
15+
}

0 commit comments

Comments
 (0)