Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
yanhaijing committed Oct 2, 2023
0 parents commit 14bda2e
Show file tree
Hide file tree
Showing 36 changed files with 16,121 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 根目录的配置
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

[*.html]
indent_size = 2

[*.{css,less,scss}]
indent_size = 2

[*.{js,mjs,cjs,ts,cts,mts}]
indent_size = 2

[*.{json,yml,yaml}]
indent_size = 2

[*.{sh}]
indent_size = 2

[*.{md,makrdown}]
indent_size = 2

[*rc]
indent_size = 2
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
require.js
48 changes: 48 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
mocha: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
overrides: [
{
env: {
node: true,
},
files: ['*.{js,cjs}'],
parserOptions: {
sourceType: 'script',
},
rules: {
'@typescript-eslint/no-var-requires': 0,
},
},
],
rules: {
/**
* ts 会检查
*/
'import/no-unresolved': 'off',
/**
* ts 会检查全局变量
*/
'import/no-deprecated': 'off',
'import/named': 'off',
'import/namespace': 'off',
'import/default': 'off',
'import/no-named-as-default-member': 'off',
},
};
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

custom: ['https://yanhaijing.com/mywallet/']
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### 问题是什么

问题的具体描述,尽量详细

### 环境

- 手机: 小米6
- 系统:安卓7.1.1
- 浏览器:chrome 61
- jslib版本:0.2.0
- 其他版本信息

### 在线例子

如果有请提供在线例子

### 其他

其他信息
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: CI

on:
push:
branches: ['master']
pull_request:
branches: ['master']

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v4

lint:
needs: commitlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'
- run: npm ci
- run: npm run lint

test:
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm i
- run: npm test
# - run: npm run coveralls --if-present
- run: npm run build --if-present
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage
node_modules
dist
.eslintcache
.nyc_output
types
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
3 changes: 3 additions & 0 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'**/*.{js,mjs,cjs,ts,cts,mts}': ['prettier --write', 'eslint --cache'],
};
15 changes: 15 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"check-coverage": true,
"lines": 75,
"statements": 75,
"functions": 0,
"branches": 75,
"require": ["ts-node/register", "source-map-support/register"],
"reporter": ["lcov", "text"],
"extension": [".ts"],
"include": ["src/**.ts"],
"exclude": ["**/*.d.ts"],
"sourceMap": true,
"instrument": true,
"all": true
}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
coverage
package-lock.json
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 变更日志

## 0.2.0 / 2023-9-24

- 新增功能C
- 新增功能D

## 0.1.0 / 2023-9-23

- 新增功能A
- 新增功能B
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (C) 2017-2023

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.
111 changes: 111 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# [get-selector](https://github.com/jsmini/get-selector)
[![](https://img.shields.io/badge/Powered%20by-jslib%20base-brightgreen.svg)](https://github.com/yanhaijing/jslib-base)
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jsmini/get-selector/blob/master/LICENSE)
[![CI](https://github.com/jsmini/get-selector/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/jsmini/get-selector/actions/workflows/ci.yml)
[![npm](https://img.shields.io/badge/npm-0.1.0-orange.svg)](https://www.npmjs.com/package/@jsmini/get-selector)
[![NPM downloads](http://img.shields.io/npm/dm/get-selector.svg?style=flat-square)](http://www.npmtrends.com/@jsmini/get-selector)
[![Percentage of issues still open](http://isitmaintained.com/badge/open/jsmini/get-selector.svg)](http://isitmaintained.com/project/jsmini/get-selector "Percentage of issues still open")

最好用的 `JS|TS` 第三方库脚手架

## :star: 特性

- 支持ES6+或TypeScript编写源码,编译生成生产代码
- 多环境支持(支持浏览器原生,支持AMD,CMD,支持Webpack,Rollup,fis等,支持Node)
- 集成[jsmini](https://github.com/jsmini)

> 注意: 如果不同时使用 `export``export default` 可打开 `legacy模式``legacy模式` 下的模块系统可以兼容 `ie6-8`,见rollup配置文件
## :pill: 兼容性
单元测试保证支持如下环境:

| IE | CH | FF | SF | OP | IOS | Android | Node |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ----- |
| 11+ | 100+ | 100+ | 16+ | 100+ | 10.3+ | 4.1+ | 14+ |

**注意:编译代码依赖ES5环境,对于ie6-8需要引入[es5-shim](http://github.com/es-shims/es5-shim/)才可以兼容,可以查看[demo/demo-global.html](./demo/demo-global.html)中的例子**

## :open_file_folder: 目录介绍

```
.
├── demo 使用demo
├── dist 编译产出代码
├── doc 项目文档
├── src 源代码目录
├── test 单元测试
├── CHANGELOG.md 变更日志
└── TODO.md 计划功能
```

## :rocket: 使用者指南

通过npm下载安装代码

```bash
$ npm install --save @jsmini/get-selector
```

如果你是node环境

```js
var base = require('@jsmini/get-selector');
```

如果你是webpack等环境

```js
import base from '@jsmini/get-selector';
```

如果你是浏览器环境

```html
<script src="node_modules/@jsmini/get-selector/dist/index.aio.js"></script>
```

## :bookmark_tabs: 文档
[API](./doc/api.md)

## :kissing_heart: 贡献者指南
首次运行需要先安装依赖

```bash
$ npm install
```

一键打包生成生产代码

```bash
$ npm run build
```

运行单元测试:

```bash
$ npm test
```

> 注意:浏览器环境需要手动测试,位于`test/browser`
修改 package.json 中的版本号,修改 README.md 中的版本号,修改 CHANGELOG.md,然后发布新版

```bash
$ npm run release
```

将新版本发布到npm

```bash
$ npm publish
```

## 贡献者列表

[contributors](https://github.com/jsmini/get-selector/graphs/contributors)

## :gear: 更新日志
[CHANGELOG.md](./CHANGELOG.md)

## :airplane: 计划列表
[TODO.md](./TODO.md)
5 changes: 5 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 计划列表
这里列出会在未来添加的新功能,和已经完成的功能

- [X] 已完成
- [ ] 未完成
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
Loading

0 comments on commit 14bda2e

Please sign in to comment.