Skip to content

Commit

Permalink
feat: switch to all typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Jun 15, 2024
1 parent 2eb323d commit 1138bc4
Show file tree
Hide file tree
Showing 12 changed files with 705 additions and 388 deletions.
224 changes: 218 additions & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,218 @@
*.js eol=lf
*.jsx eol=lf
*.json eol=lf
*.vue eol=lf
*.ts eol=lf
*.tsx eol=lf
# From https://github.com/gitattributes/gitattributes/blob/master/Web.gitattributes
## GITATTRIBUTES FOR WEB PROJECTS
#
# These settings are for any web project.
#
# Details per file setting:
# text These files should be normalized (i.e. convert CRLF to LF).
# binary These files are binary and should be left untouched.
#
# Note that binary is a macro for -text -diff.
######################################################################

# Auto detect
## Handle line endings automatically for files detected as
## text and leave all files detected as binary untouched.
## This will handle all files NOT defined below.
* text=auto

# Source code
*.bash text eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.coffee text
*.css text diff=css
*.htm text diff=html
*.html text diff=html
*.inc text
*.ini text
*.js text
*.mjs text
*.cjs text
*.json text
*.jsx text
*.less text
*.ls text
*.map text -diff
*.od text
*.onlydata text
*.php text diff=php
*.pl text
*.ps1 text eol=crlf
*.py text diff=python
*.rb text diff=ruby
*.sass text
*.scm text
*.scss text diff=css
*.sh text eol=lf
.husky/* text eol=lf
*.sql text
*.styl text
*.tag text
*.ts text
*.tsx text
*.xml text
*.xhtml text diff=html

# Docker
Dockerfile text

# Documentation
*.ipynb text eol=lf
*.markdown text diff=markdown
*.md text diff=markdown
*.mdwn text diff=markdown
*.mdown text diff=markdown
*.mkd text diff=markdown
*.mkdn text diff=markdown
*.mdtxt text
*.mdtext text
*.txt text
AUTHORS text
CHANGELOG text
CHANGES text
CONTRIBUTING text
COPYING text
copyright text
*COPYRIGHT* text
INSTALL text
license text
LICENSE text
NEWS text
readme text
*README* text
TODO text

# Templates
*.dot text
*.ejs text
*.erb text
*.haml text
*.handlebars text
*.hbs text
*.hbt text
*.jade text
*.latte text
*.mustache text
*.njk text
*.phtml text
*.svelte text
*.tmpl text
*.tpl text
*.twig text
*.vue text

# Configs
*.cnf text
*.conf text
*.config text
.editorconfig text
.env text
.gitattributes text
.gitconfig text
.htaccess text
*.lock text -diff
package.json text eol=lf
package-lock.json text eol=lf -diff
pnpm-lock.yaml text eol=lf -diff
.prettierrc text
yarn.lock text -diff
*.toml text
*.yaml text
*.yml text
browserslist text
Makefile text
makefile text
# Fixes syntax highlighting on GitHub to allow comments
tsconfig.json linguist-language=JSON-with-Comments

# Heroku
Procfile text

# Graphics
*.ai binary
*.bmp binary
*.eps binary
*.gif binary
*.gifv binary
*.ico binary
*.jng binary
*.jp2 binary
*.jpg binary
*.jpeg binary
*.jpx binary
*.jxr binary
*.pdf binary
*.png binary
*.psb binary
*.psd binary
# SVG treated as an asset (binary) by default.
*.svg text
# If you want to treat it as binary,
# use the following line instead.
# *.svg binary
*.svgz binary
*.tif binary
*.tiff binary
*.wbmp binary
*.webp binary

# Audio
*.kar binary
*.m4a binary
*.mid binary
*.midi binary
*.mp3 binary
*.ogg binary
*.ra binary

# Video
*.3gpp binary
*.3gp binary
*.as binary
*.asf binary
*.asx binary
*.avi binary
*.fla binary
*.flv binary
*.m4v binary
*.mng binary
*.mov binary
*.mp4 binary
*.mpeg binary
*.mpg binary
*.ogv binary
*.swc binary
*.swf binary
*.webm binary

# Archives
*.7z binary
*.gz binary
*.jar binary
*.rar binary
*.tar binary
*.zip binary

# Fonts
*.ttf binary
*.eot binary
*.otf binary
*.woff binary
*.woff2 binary

# Executables
*.exe binary
*.pyc binary
# Prevents massive diffs caused by vendored, minified files
**/.yarn/releases/** binary
**/.yarn/plugins/** binary

# RC files (like .babelrc or .eslintrc)
*.*rc text

# Ignore files (like .npmignore or .gitignore)
*.*ignore text

# Prevents massive diffs from built files
dist/* binary
30 changes: 15 additions & 15 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand All @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
1324318532@qq.com.
<1324318532@qq.com>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand All @@ -116,13 +116,13 @@ the community.

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at
<https://www.contributor-covenant.org/translations>.
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# npm-lib-rollup-template

> BREAKING CHANGE
[![codecov](https://codecov.io/gh/sonofmagic/npm-lib-rollup-template/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/npm-lib-rollup-template)

本人用于编写的一个 `npm` 包的一个模板
[icebreaker](https://github.com/sonofmagic) 编写的一个 `npm` 包的一个模板

- 使用 ~~`rollup`~~ `tsup`(esbuild) 打包 , `rollup` 打包版本在 [rollup](https://github.com/sonofmagic/npm-lib-rollup-template/tree/rollup) 分支 (兼容 `tsc`)
- 使用 ~~`jest`~~ `vitest` 作为单元测试框架
- 使用 `tsup` 打包 , `rollup` 打包版本在 [rollup](https://github.com/sonofmagic/npm-lib-rollup-template/tree/rollup) 分支 (兼容 `tsc`)
- 使用 `vitest` 作为单元测试框架
- 使用 `eslint` 来规范代码风格
- 输出 `dist` -> `cjs`,`esm` and `.d.ts`
- 使用 `semantic-release` 来发布 `npm`/`github`

## 为什么使用 `vitest` 而不是原先的 `jest`

`vitest` 开箱即用,`jest` 在同时遇到 `cjs``esm` 依赖的时候,支持很差,经常会失败,而且配置复杂,依赖的 `preset` 多,比如 `ts-jest`..
`vitest` 开箱即用, `jest` 在同时遇到 `cjs``esm` 依赖的时候,支持差,而且配置复杂,依赖的 `preset` 多,比如 `ts-jest`..

## scripts

Expand Down
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
"build": "tsup",
"test:dev": "vitest",
"test": "vitest run",
"init:rename": "node scripts/init/rename.js",
"init:bin": "node scripts/init/bin.js",
"clean": "node scripts/clean.js",
"init:rename": "tsx scripts/init/rename.ts",
"init:bin": "tsx scripts/init/bin.ts",
"clean": "tsx scripts/clean.ts",
"ls:pack": "npm pack --dry-run",
"semantic-release": "semantic-release"
},
Expand All @@ -55,22 +55,26 @@
"registry": "https://registry.npmjs.org"
},
"devDependencies": {
"@icebreakers/eslint-config": "^0.3.5",
"@icebreakers/eslint-config": "^0.3.7",
"@tsconfig/recommended": "^1.0.6",
"@types/fs-extra": "^11.0.4",
"@types/klaw": "^3.0.6",
"@types/lodash": "^4.17.4",
"@types/lodash": "^4.17.5",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.14.2",
"@vitest/coverage-v8": "^1.6.0",
"cross-env": "^7.0.3",
"defu": "^6.1.4",
"del": "^7.1.0",
"eslint": "9.4.0",
"eslint": "9.5.0",
"fs-extra": "^11.2.0",
"klaw": "^4.1.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"pathe": "^1.1.2",
"semantic-release": "^24.0.0",
"tsup": "^8.1.0",
"tsx": "^4.15.5",
"typescript": "^5.4.5",
"vitest": "^1.6.0"
}
Expand Down
Loading

0 comments on commit 1138bc4

Please sign in to comment.