Skip to content

Commit 8ac122e

Browse files
committed
refactor: change code base to TypeScript, better workflow
1 parent 7d89fd3 commit 8ac122e

34 files changed

+6245
-1784
lines changed

.commitlintrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"@commitlint/config-conventional"
4+
]
5+
}

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
tab_width = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib

.eslintrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const { md, mdx } = require('@1stg/eslint-config/overrides')
2+
3+
module.exports = {
4+
extends: ['plugin:prettier/recommended'],
5+
overrides: [md, mdx],
6+
rules: {
7+
'prettier/prettier': 2,
8+
},
9+
}

.github/workflows/nodejs.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Node CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
node: [8.x, 10.x, 12.x]
10+
os: [macOS-latest, ubuntu-latest]
11+
runs-on: ${{ matrix.os }}
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Use Node.js ${{ matrix.node }}
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: ${{ matrix.node }}
18+
- name: setup yarn
19+
run: |
20+
curl -o- -L https://yarnpkg.com/install.sh | bash
21+
export PATH="$HOME/.yarn/bin:$PATH"
22+
- name: build, lint, test
23+
run: |
24+
yarn --frozen-lockfile
25+
yarn lint
26+
yarn build
27+
yarn test
28+
env:
29+
CI: true
30+
31+
# codecov:
32+
# runs-on: macOS-latest
33+
# needs: build
34+
# steps:
35+
# - name: Report Test Code Coverage
36+
# if: matrix.node == '12.x'
37+
# run: |
38+
# yarn global add codecov codacy-coverage
39+
# codecov
40+
# cat ./coverage/lcov.info | codacy-coverage
41+
# env:
42+
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
43+
44+
deploy:
45+
runs-on: macOS-latest
46+
needs: build
47+
steps:
48+
- name: Publish Release and npm Package
49+
if: github.event_name == 'push' && github.ref == 'master' && matrix.node == '12.x'
50+
run: bash deploy.sh
51+
env:
52+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
GH_BRANCH: ${{ github.ref }}
55+
GH_REPO: ${{ github.repository }}
56+
57+
codecheck:
58+
runs-on: macOS-latest
59+
needs: [build, deploy]
60+
steps:
61+
- name: Code Check
62+
if: matrix.node == '12.x'
63+
run: |
64+
yarn add -D @codechecks/client @codechecks/build-size-watcher
65+
yarn codechecks
66+
env:
67+
CC_SECRET: ${{ secrets.CC_SECRET }}

.gitignore

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1+
lib
12
node_modules
2-
yarn-error.log
3-
yarn.lock
4-
.idea
5-
.vscode
3+
*.log

.huskyrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@1stg/husky-config')

.lintstagedrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"tests/**/*.{js,json,ts,tsx}": [
3+
"prettier --write",
4+
"git add"
5+
],
6+
"src/*.{js,ts}": [
7+
"eslint --fix",
8+
"git add"
9+
],
10+
"*.md": [
11+
"eslint --fix",
12+
"git add"
13+
]
14+
}

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"@1stg/prettier-config"

.remarkrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"plugins": [
3+
"@1stg/remark-config"
4+
]
5+
}

.travis.yml

+32-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
1-
dist: trusty
21
language: node_js
3-
node_js:
4-
- '10'
5-
- '8'
6-
install: npm i
2+
3+
node_js: --lts
4+
5+
cache: yarn
6+
7+
before_install:
8+
- curl -o- -L https://yarnpkg.com/install.sh | bash
9+
- export PATH="$HOME/.yarn/bin:$PATH"
10+
- git config --global user.name 'JounQin'
11+
- git config --global user.email 'admin@1stg.me'
12+
13+
install: yarn --frozen-lockfile
14+
715
script:
8-
- npm run check-format
9-
- npm run test
16+
- yarn lint
17+
- yarn build
18+
- yarn test
19+
20+
# after_success:
21+
# - yarn global add codecov codacy-coverage
22+
# - codecov
23+
# - cat ./coverage/lcov.info | codacy-coverage
24+
25+
deploy:
26+
provider: script
27+
skip_cleanup: true
28+
script: bash deploy.sh
29+
on:
30+
branch: master
31+
32+
after_script:
33+
- yarn add -D @codechecks/client @codechecks/build-size-watcher @codechecks/type-coverage-watcher
34+
- yarn codechecks

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ Add the following to your `.eslintrc` config:
7272
}
7373
```
7474

75-
7675
## Contributing
7776

7877
- Make sure your change is covered by a test import.

deploy.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
GH_BRANCH=${GH_BRANCH:-$TRAVIS_BRANCH}
6+
GH_REPO=${GH_REPO:-$TRAVIS_REPO_SLUG}
7+
8+
git remote set-url origin "https://user:$GH_TOKEN@github.com/$GH_REPO.git"
9+
npm set //registry.npmjs.org/:_authToken "$NPM_TOKEN"
10+
11+
git fetch origin "$GH_BRANCH":"$GH_BRANCH"
12+
git checkout "$GH_BRANCH"
13+
14+
PKG_VERSION=$(jq -r '.version' package.json)
15+
16+
git fetch origin v"$PKG_VERSION" || {
17+
yarn global add standard-version
18+
standard-version -a --release-as "$PKG_VERSION"
19+
git push --follow-tags origin "$GH_BRANCH"
20+
npm publish
21+
}

dummy.js/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = 'dummy';
1+
module.exports = 'dummy'

index.js

-179
This file was deleted.

0 commit comments

Comments
 (0)