Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
qq15725 authored Dec 1, 2023
0 parents commit 4a05229
Show file tree
Hide file tree
Showing 23 changed files with 4,328 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@qq15725"
}
25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- Thank you for contributing! -->

### Description

<!-- Please insert your description here and provide especially info about the "what" this PR is solving -->

### Additional context

<!-- e.g. is there anything you'd like reviewers to focus on? -->

---

### What is the purpose of this pull request? <!-- (put an "X" next to an item) -->

- [ ] Bug fix
- [ ] New Feature
- [ ] Documentation update
- [ ] Other

### Before submitting the PR, please make sure you do the following

- [ ] Read the [Pull Request Guidelines](https://github.com/qq15725/starter-ts/blob/main/.github/pull-request-guidelines.md) and follow the [PR Title Convention](https://github.com/qq15725/starter-ts/blob/main/.github/commit-convention.md).
- [ ] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
- [ ] Provide a description in this PR that addresses **what** the PR is solving, or reference the issue that it solves (e.g. `fixes #123`).
- [ ] Ideally, include relevant tests that fail without this PR but pass with it.
37 changes: 37 additions & 0 deletions .github/commit-convention.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Git Commit Message Convention

> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular).
#### TL;DR:

Messages must be matched by the following regex:

<!-- prettier-ignore -->
```js
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?!?: .{1,50}/
```

#### Examples

```
feat(dev): add 'comments' option
fix(dev): fix dev error
perf(build)!: remove 'foo' option
revert: feat(compiler): add 'comments' option
```

### Revert

If the PR reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit

### Scope

The scope could be anything specifying the place of the commit change. For example `dev`, `build`, `workflow`, `cli` etc...

### Subject

The subject contains a succinct description of the change:

- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize the first letter
- no dot (.) at the end
20 changes: 20 additions & 0 deletions .github/pull-request-guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Pull Request Guidelines

- Checkout a topic branch from a base branch (e.g. `main`), and merge back against that branch.

- If adding a new feature:

- Add accompanying test case.
- Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first, and have it approved before working on it.

- If fixing a bug:

- If you are resolving a special issue, add `(fix #xxxx[,#xxxx])` (#xxxx is the issue id) in your PR title for a better release log (e.g. `fix: update entities encoding/decoding (fix #3899)`).
- Provide a detailed description of the bug in the PR. Live demo preferred.
- Add appropriate test coverage if applicable.

- It's OK to have multiple small commits as you work on the PR. GitHub can automatically squash them before merging.

- Make sure tests pass!

- PR title must follow the [commit message convention](./commit-convention.md) so that changelogs can be automatically generated.
100 changes: 100 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: 👷 CI

env:
# 7 GiB by default on GitHub, setting to 6 GiB
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
NODE_OPTIONS: --max-old-space-size=6144
# Vitest auto retry on flaky segfault
VITEST_SEGFAULT_RETRY: 3

# Remove default permissions of GITHUB_TOKEN for security
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
permissions: {}

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

jobs:
test:
timeout-minutes: 10
runs-on: ubuntu-latest
name: "Build&Test: node-18, ubuntu-latest"
steps:
- name: ⤵️ Checkout
uses: actions/checkout@v3
with:
# Assume PRs are less than 50 commits
fetch-depth: 50

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@57d9664f8e2aa45f26bcb59095f99aa47ae8e90d # v35.4.4
with:
files: |
docs/**
.github/**
!.github/workflows/ci.yml
**.md
- name: 🎉 Install pnpm
if: steps.changed-files.outputs.only_changed != 'true'
uses: pnpm/[email protected]

- name: 🎉 Set node version to 18
if: steps.changed-files.outputs.only_changed != 'true'
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"

- name: 🚧 Install deps
if: steps.changed-files.outputs.only_changed != 'true'
run: pnpm install

- name: 📦 Build
if: steps.changed-files.outputs.only_changed != 'true'
run: pnpm run build

- name: 🔀 Test unit
if: steps.changed-files.outputs.only_changed != 'true'
run: pnpm run test

lint:
timeout-minutes: 10
runs-on: ubuntu-latest
name: "Lint: node-18, ubuntu-latest"
steps:
- name: ⤵️ Checkout
uses: actions/checkout@v3

- name: 🎉 Install pnpm
uses: pnpm/[email protected]

- name: 🎉 Set node version to 18
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"

- name: 🚧 Install deps
run: pnpm install

- name: 📦 Build
run: pnpm run build

- name: 🔀 Lint
run: pnpm run lint

# From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions
- name: 🔀 Check workflow files
run: |
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
./actionlint -color -shellcheck=""
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 🚀 Publish Package

on:
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
publish:
runs-on: ubuntu-latest
environment: Release
steps:
- name: ⤵️ Checkout
uses: actions/checkout@v3

- name: 🎉 Install pnpm
uses: pnpm/[email protected]

- name: 🎉 Set node version to 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://registry.npmjs.org/
cache: "pnpm"

- name: 🚧 Install deps
run: pnpm install

- name: 📦 Build
run: pnpm run build

- name: 🔀 Publish package
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 🚀 Add GitHub Release Tag

on:
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10

# $GITHUB_REF_NAME - https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 🔀 Create Release for Tag
id: release_tag
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
body: |
Please refer to [CHANGELOG.md](https://github.com/qq15725/starter-ts/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.DS_Store
.env
node_modules/
dist/
types/

# Lock
package-lock.json

# IDE user config
.vscode/
.idea/
.vs/

# Logs
yarn-error.log
npm-debug.log
lerna-debug.log
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-workspace-root-check=true
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## [0.0.3](https://github.com/qq15725/starter-ts/compare/v0.0.2...v0.0.3) (2023-02-18)


### Bug Fixes

* release script ([4139591](https://github.com/qq15725/starter-ts/commit/4139591f2209f5740b5de5ca36f8c5d9b8af0e33))



## [0.0.2](https://github.com/qq15725/starter-ts/compare/v0.0.1...v0.0.2) (2023-02-18)



21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021-PRESENT wxm

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<h1 align="center">starter-ts</h1>

<p align="center">
<a href="https://unpkg.com/starter-ts">
<img src="https://img.shields.io/bundlephobia/minzip/starter-ts" alt="Minzip">
</a>
<a href="https://www.npmjs.com/package/starter-ts">
<img src="https://img.shields.io/npm/v/starter-ts.svg" alt="Version">
</a>
<a href="https://www.npmjs.com/package/starter-ts">
<img src="https://img.shields.io/npm/dm/starter-ts" alt="Downloads">
</a>
<a href="https://github.com/qq15725/starter-ts/issues">
<img src="https://img.shields.io/github/issues/qq15725/starter-ts" alt="Issues">
</a>
<a href="https://github.com/qq15725/starter-ts/blob/main/LICENSE">
<img src="https://img.shields.io/npm/l/starter-ts.svg" alt="License">
</a>
</p>

## Try it now!

### GitHub Template

[Create a repo from this template on GitHub](https://github.com/qq15725/starter-ts/generate).

### Clone to local

If you prefer to do it manually with the cleaner git history

```bash
npx degit qq15725/starter-ts my-ts-lib
cd my-ts-lib
pnpm i # If you don't have pnpm installed, run: npm install -g pnpm
```
9 changes: 9 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Docs</title>
</head>
<body>
</body>
</html>
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Playground</title>
</head>
<body>
<div>Playground</div>

<script type="module">
import { one } from './src'

console.log(one)
</script>
</body>
</html>
Loading

0 comments on commit 4a05229

Please sign in to comment.