Skip to content
This repository was archived by the owner on Jun 29, 2022. It is now read-only.

refactor: change code base to TypeScript, better workflow #10

Merged
merged 2 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .commitlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"@commitlint/config-conventional"
]
}
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { md, mdx } = require('@1stg/eslint-config/overrides')

module.exports = {
extends: ['plugin:prettier/recommended'],
overrides: [md, mdx],
rules: {
'prettier/prettier': 2,
},
}
67 changes: 67 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Node CI

on: [push, pull_request]

jobs:
build:
strategy:
matrix:
node: [8.x, 10.x, 12.x]
os: [macOS-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: setup yarn
run: |
curl -o- -L https://yarnpkg.com/install.sh | bash
export PATH="$HOME/.yarn/bin:$PATH"
- name: build, lint, test
run: |
yarn --frozen-lockfile
yarn lint
yarn build
yarn test
env:
CI: true

# codecov:
# runs-on: macOS-latest
# needs: build
# steps:
# - name: Report Test Code Coverage
# if: matrix.node == '12.x'
# run: |
# yarn global add codecov codacy-coverage
# codecov
# cat ./coverage/lcov.info | codacy-coverage
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

deploy:
runs-on: macOS-latest
needs: build
steps:
- name: Publish Release and npm Package
if: github.event_name == 'push' && github.ref == 'master' && matrix.node == '12.x'
run: bash deploy.sh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_BRANCH: ${{ github.ref }}
GH_REPO: ${{ github.repository }}

codecheck:
runs-on: macOS-latest
needs: [build, deploy]
steps:
- name: Code Check
if: matrix.node == '12.x'
run: |
yarn add -D @codechecks/client @codechecks/build-size-watcher
yarn codechecks
env:
CC_SECRET: ${{ secrets.CC_SECRET }}
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
lib
node_modules
yarn-error.log
yarn.lock
.idea
.vscode
*.log
1 change: 1 addition & 0 deletions .huskyrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@1stg/husky-config')
14 changes: 14 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"tests/**/*.{js,json,ts,tsx}": [
"prettier --write",
"git add"
],
"src/*.{js,ts}": [
"eslint --fix",
"git add"
],
"*.md": [
"eslint --fix",
"git add"
]
}
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@1stg/prettier-config"
5 changes: 5 additions & 0 deletions .remarkrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": [
"@1stg/remark-config"
]
}
3 changes: 3 additions & 0 deletions .renovaterc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@1stg"
}
39 changes: 32 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
dist: trusty
language: node_js
node_js:
- '10'
- '8'
install: npm i

node_js: --lts

cache: yarn

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- git config --global user.name 'JounQin'
- git config --global user.email '[email protected]'

install: yarn --frozen-lockfile

script:
- npm run check-format
- npm run test
- yarn lint
- yarn build
- yarn test

# after_success:
# - yarn global add codecov codacy-coverage
# - codecov
# - cat ./coverage/lcov.info | codacy-coverage

deploy:
provider: script
skip_cleanup: true
script: bash deploy.sh
on:
branch: master

after_script:
- yarn add -D @codechecks/client @codechecks/build-size-watcher @codechecks/type-coverage-watcher
- yarn codechecks
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Add the following to your `.eslintrc` config:
}
```


## Contributing

- Make sure your change is covered by a test import.
Expand Down
9 changes: 9 additions & 0 deletions codechecks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
checks:
- name: build-size-watcher
options:
files:
- path: 'lib/**/*.*'
- name: type-coverage-watcher
options:
ignoreCatch: true
strict: true
21 changes: 21 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -e

GH_BRANCH=${GH_BRANCH:-$TRAVIS_BRANCH}
GH_REPO=${GH_REPO:-$TRAVIS_REPO_SLUG}

git remote set-url origin "https://user:[email protected]/$GH_REPO.git"
npm set //registry.npmjs.org/:_authToken "$NPM_TOKEN"

git fetch origin "$GH_BRANCH":"$GH_BRANCH"
git checkout "$GH_BRANCH"

PKG_VERSION=$(jq -r '.version' package.json)

git fetch origin v"$PKG_VERSION" || {
yarn global add standard-version
standard-version -a --release-as "$PKG_VERSION"
git push --follow-tags origin "$GH_BRANCH"
npm publish
}
2 changes: 1 addition & 1 deletion dummy.js/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = 'dummy';
module.exports = 'dummy'
179 changes: 0 additions & 179 deletions index.js

This file was deleted.

Loading