Skip to content

Commit

Permalink
feat: use yargs (#9)
Browse files Browse the repository at this point in the history
* feat: use yargs

Co-authored-by: MickVanDuijn <m.vanduijn@zefiros.eu>
  • Loading branch information
pevisscher and MickVanDuijn committed Jun 16, 2020
1 parent 9534be3 commit 2db32de
Show file tree
Hide file tree
Showing 80 changed files with 2,315 additions and 3,730 deletions.
43 changes: 37 additions & 6 deletions .eslintrc.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,53 @@ module.exports = {
sourceType: 'module',
project: 'tsconfig.json',
},
plugins: ['@typescript-eslint', 'extra-rules'],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', 'prettier/@typescript-eslint'],
plugins: ['@typescript-eslint', 'import'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'prettier/@typescript-eslint',
],
rules: {
'max-classes-per-file': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unused-vars-experimental': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'explicit',
},
],
'extra-rules/no-commented-out-code': 'warn',
'import/default': 'off',
'import/order': [
'error',
{
groups: ['index', 'sibling', 'parent', 'internal', 'external', 'builtin'],
'newlines-between': 'always',
pathGroups: [
{
pattern: '~/**',
group: 'internal',
},
],
},
],
},
settings: {
'import/resolver': {
typescript: {
directory: './',
},
},
'import/external-module-folders': ['node_modules', 'typings'],
},
}
9 changes: 1 addition & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
module.exports = {
...require('./.eslintrc.base.js'),
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
project: 'tsconfig.lint.json',
},
}
module.exports = require('./.eslintrc.base.js')
13 changes: 6 additions & 7 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand All @@ -27,8 +27,7 @@ jobs:
- name: yarn link
run: |
export PATH="$(yarn global bin):$PATH"
npm config set scripts-prepend-node-path true
yarn install
# initialize environment
Expand All @@ -38,20 +37,20 @@ jobs:
yarn link
yarn link @zefiros/npm-defaults
./bin/run ci
npm-defaults ci
yalc publish
- name: library - yarn install, build, and test
working-directory: ./examples/library
run: |
yalc add @zefiros/npm-defaults
../../bin/run ci
- name: oclif-cli - yarn install, build, and test
working-directory: ./examples/oclif-cli
- name: yargs-cli - yarn install, build, and test
working-directory: ./examples/yargs-cli
run: |
yalc add @zefiros/npm-defaults
../../bin/run ci
- name: coverage
run: codecov
run: nyc report --reporter=text-lcov | codecov --pipe
env:
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
- name: release
Expand Down
2 changes: 1 addition & 1 deletion .huskyrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module.exports = {
hooks: {
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
'pre-commit': 'lint-staged',
'pre-push': 'yarn test --collectCoverage=false',
'pre-push': 'yarn test',
},
}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts-prepend-node-path=true
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"javascript.validate.enable": true,
"prettier.disableLanguages": ["yaml"],
"prettier.disableLanguages": ["yaml", "js", "typescript"],
"typescript.referencesCodeLens.enabled": true,
"typescript.implementationsCodeLens.enabled": true,
"eslint.validate": ["javascript", { "language": "typescript", "autoFix": true }],
"eslint.validate": ["javascript", "typescript"],
"yaml.format.enable": false,
"editor.formatOnSave": true,
"[json]": {
"editor.tabSize": 2
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"files.eol": "\n",
"files.exclude": {
"**/.git": true,
Expand All @@ -17,7 +20,7 @@
"**/CVS": true,
"**/.DS_Store": true,
"**/node_modules": true,
//"**/dist": true,
"**/dist": true,
"**/.yalc": true,
"**/.webpack": true,
"**/coverage": true
Expand Down
5 changes: 5 additions & 0 deletions ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
files: ['test/**/*'],
extensions: ['ts'],
nodeArguments: ['-r', 'ts-node/register/transpile-only', '-r', 'tsconfig-paths/register'],
}
10 changes: 4 additions & 6 deletions bin/run
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env node
require('source-map-support').install()
const fs = require('fs')
const path = require('path')
const project = path.join(__dirname, '../tsconfig.json')
const dev = fs.existsSync(project)
const dev = fs.existsSync(project) && process.env.DEBUG != 'false'

if (dev) {
const root = path.join(__dirname, '../')
Expand All @@ -13,9 +12,8 @@ if (dev) {
baseUrl: root,
})
require('ts-node').register({ project, pretty: true, files: true, transpileOnly: true })
} else {
process.env.OCLIF_TS_NODE = 0
}
require(`../${dev ? 'src' : 'dist'}`)

require(`../${dev ? 'src' : 'dist/main'}`)
.run()
.catch(require('@oclif/errors/handle'))
.catch(console.error)
1 change: 1 addition & 0 deletions examples/library/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts-prepend-node-path=true
5 changes: 5 additions & 0 deletions examples/library/ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
files: ['test/**/*'],
extensions: ['ts'],
nodeArguments: ['-r', 'ts-node/register/transpile-only', '-r', 'tsconfig-paths/register'],
}
1 change: 0 additions & 1 deletion examples/library/jest.config.js

This file was deleted.

14 changes: 8 additions & 6 deletions examples/library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,28 @@
"engines": {
"node": ">=12"
},
"files": ["dist/**"],
"files": ["dist", "package.json"],
"scripts": {
"build": "yarn ttsc -p tsconfig.dist.json",
"test": "concurrently \"yarn check:types\" \"jest test --maxWorkers=1 --collectCoverage=false\"",
"test": "concurrently \"yarn check:types\" \"yarn ava\"",
"fix": "yarn lint --fix",
"lint": "yarn eslint \"{src,test,typing}/**/*.{ts,js}\" --ignore-pattern **/node_modules/* --resolve-plugins-relative-to .",
"format": "prettier \"{src/*,test/*,typing/*,templates/*,examples/*,}*/*.{ts,js,json}\" --write",
"release": "semantic-release",
"release:dry": "yarn release --dry-run",
"check:types": "yarn ttsc -p tsconfig.json",
"check:project": "yarn npm-defaults lint",
"package": "rm -rf dist && yarn build"
"package": "rm -rf dist && yarn build",
"check:cost": "npx cost-of-modules --yarn --no-install --include-dev",
"coverage": "nyc --reporter=text-summary ava"
},
"dependencies": {
"tslib": "^1.11.2"
},
"devDependencies": {
"@zefiros/npm-defaults": "^0.2.0-beta.47",
"@zerollup/ts-transform-paths": "^1.7.17",
"@zefiros/npm-defaults": "^0.2.0-beta.51",
"@zerollup/ts-transform-paths": "^1.7.18",
"ttypescript": "^1.5.10",
"typescript": "^3.8.3"
"typescript": "^3.9.5"
}
}
6 changes: 4 additions & 2 deletions examples/library/test/main.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { main } from '~/main'

test('main', () => {
expect(main()).toEqual('yay')
import test from 'ava'

test('main', t => {
t.deepEqual(main(),'yay')
})
8 changes: 0 additions & 8 deletions examples/oclif-cli/.eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion examples/oclif-cli/jest.config.js

This file was deleted.

53 changes: 0 additions & 53 deletions examples/oclif-cli/package.json

This file was deleted.

25 changes: 0 additions & 25 deletions examples/oclif-cli/src/commands/goodbye.ts

This file was deleted.

31 changes: 0 additions & 31 deletions examples/oclif-cli/src/commands/hello.ts

This file was deleted.

1 change: 0 additions & 1 deletion examples/oclif-cli/src/index.ts

This file was deleted.

5 changes: 0 additions & 5 deletions examples/oclif-cli/test/index.spec.ts

This file was deleted.

8 changes: 0 additions & 8 deletions examples/oclif-cli/tsconfig.lint.json

This file was deleted.

3 changes: 0 additions & 3 deletions examples/oclif-cli/webpack.config.js

This file was deleted.

1 change: 1 addition & 0 deletions examples/yargs-cli/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@zefiros/npm-defaults/.eslintrc.base.js')
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions examples/yargs-cli/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts-prepend-node-path=true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions examples/yargs-cli/ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
files: ['test/**/*'],
extensions: ['ts'],
nodeArguments: ['-r', 'ts-node/register/transpile-only', '-r', 'tsconfig-paths/register'],
}
Loading

0 comments on commit 2db32de

Please sign in to comment.