From 48af73f30b5264a602c26919bfb8481e73db2b73 Mon Sep 17 00:00:00 2001 From: selfisekai Date: Thu, 20 Aug 2020 17:08:27 +0200 Subject: [PATCH] build and lint setup with gitlab ci --- .eslintignore | 8 ++++++ .eslintrc.js | 43 +++++++++++++++--------------- .gitlab-ci.yml | 11 ++++++++ .prettierignore | 8 ++++++ package.json | 22 ++++++++++++--- yarn.lock | 71 +++++++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 135 insertions(+), 28 deletions(-) create mode 100644 .eslintignore create mode 100644 .gitlab-ci.yml create mode 100644 .prettierignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..39fd7cf --- /dev/null +++ b/.eslintignore @@ -0,0 +1,8 @@ +build +node_modules + +# fetched automatically with scripts/download-gql-schema.ts +schema.graphql +schema.json +# autogenerated from schema with graphql-codegen +api-types.ts diff --git a/.eslintrc.js b/.eslintrc.js index e71f70e..0eb2ae2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,23 +1,22 @@ module.exports = { - env: { - es6: true, - node: true, - }, - extends: ['airbnb-base', 'prettier'], - globals: { - Atomics: 'readonly', - SharedArrayBuffer: 'readonly', - }, - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - plugins: ['@typescript-eslint', 'prettier'], - rules: { - 'no-unused-vars': 'off', // broken with typescript - 'import/no-unresolved': 'off', // conflicting with typescript - 'import/extensions': 'off', // conflicting with typescript - }, - }; - \ No newline at end of file + env: { + es6: true, + node: true, + }, + extends: ['airbnb-base', 'prettier'], + globals: { + Atomics: 'readonly', + SharedArrayBuffer: 'readonly', + }, + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + plugins: ['@typescript-eslint', 'prettier'], + rules: { + 'no-unused-vars': 'off', // broken with typescript + 'import/no-unresolved': 'off', // conflicting with typescript + 'import/extensions': 'off', // conflicting with typescript + }, +}; diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..ae93bc6 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,11 @@ +default: + image: node:14-alpine + +build: + script: + - yarn + - yarn build + +lint: + script: + - yarn lint diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..39fd7cf --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +build +node_modules + +# fetched automatically with scripts/download-gql-schema.ts +schema.graphql +schema.json +# autogenerated from schema with graphql-codegen +api-types.ts diff --git a/package.json b/package.json index 1ac77aa..c1e4f95 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,22 @@ "author": "selfisekai ", "license": "GPL-3.0", "scripts": { - "gql-codegen": "yarn gql-codegen:download && yarn gql-codegen:generate", - "gql-codegen:download": "ts-node scripts/download-gql-schema.ts", - "gql-codegen:generate": "ts-node scripts/generate-gql-types.ts" + "build": "yarn build:gql-codegen && yarn build:ts", + "build:ts": "yarn tsc", + "build:gql-codegen": "yarn gql-codegen:download && yarn gql-codegen:generate", + "build:gql-codegen:download": "yarn ts-node scripts/download-gql-schema.ts", + "build:gql-codegen:generate": "yarn ts-node scripts/generate-gql-types.ts", + "lint": "yarn lint:prettier && yarn lint:eslint", + "lint:fix": "yarn lint:prettier:fix && yarn lint:eslint:fix", + "lint:eslint": "yarn eslint", + "lint:eslint:fix": "yarn eslint --fix", + "lint:prettier": "yarn prettier --check src", + "lint:prettier:fix": "yarn prettier --check --write src" + }, + "husky": { + "hooks": { + "pre-commit": "yarn lint:fix" + } }, "dependencies": { "@iarna/toml": "^2.2.5", @@ -15,7 +28,6 @@ "fs-extra": "^9.0.1", "got": "^11.5.1", "graphql": "^15.3.0", - "js-yaml": "^3.14.0", "simple-git": "^2.15.0" }, "devDependencies": { @@ -31,6 +43,8 @@ "eslint-config-prettier": "^6.11.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-prettier": "^3.1.4", + "husky": "^4.2.5", + "js-yaml": "^3.14.0", "prettier": "^2.0.5", "ts-node": "^8.10.2", "typescript": "^3.9.7" diff --git a/yarn.lock b/yarn.lock index f778934..c4040fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1309,6 +1309,11 @@ chokidar@3.4.1: optionalDependencies: fsevents "~2.1.2" +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + clean-stack@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" @@ -1403,6 +1408,11 @@ common-tags@1.8.0: resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.8.0.tgz#8e3153e542d4a39e9b10554434afaaf98956a937" integrity sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw== +compare-versions@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.6.0.tgz#1a5689913685e5a87637b8d3ffca75514ec41d62" + integrity sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA== + concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" @@ -1444,7 +1454,7 @@ core-util-is@1.0.2: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -cosmiconfig@6.0.0: +cosmiconfig@6.0.0, cosmiconfig@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-6.0.0.tgz#da4fee853c52f6b1e6935f41c1a2fc50bd4a9982" integrity sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg== @@ -2060,7 +2070,7 @@ find-up@^2.0.0, find-up@^2.1.0: dependencies: locate-path "^2.0.0" -find-up@^4.1.0: +find-up@^4.0.0, find-up@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== @@ -2068,6 +2078,13 @@ find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" +find-versions@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/find-versions/-/find-versions-3.2.0.tgz#10297f98030a786829681690545ef659ed1d254e" + integrity sha512-P8WRou2S+oe222TOCHitLy8zj+SIsVJh52VP4lvXkaFVnOFFdoWv1H1Jjvel1aI6NCFOAaeAVm8qrI0odiLcww== + dependencies: + semver-regex "^2.0.0" + flat-cache@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" @@ -2352,6 +2369,22 @@ https-proxy-agent@^2.2.1: agent-base "^4.3.0" debug "^3.1.0" +husky@^4.2.5: + version "4.2.5" + resolved "https://registry.yarnpkg.com/husky/-/husky-4.2.5.tgz#2b4f7622673a71579f901d9885ed448394b5fa36" + integrity sha512-SYZ95AjKcX7goYVZtVZF2i6XiZcHknw50iXvY7b0MiGoj5RwdgRQNEHdb+gPDPCXKlzwrybjFjkL6FOj8uRhZQ== + dependencies: + chalk "^4.0.0" + ci-info "^2.0.0" + compare-versions "^3.6.0" + cosmiconfig "^6.0.0" + find-versions "^3.2.0" + opencollective-postinstall "^2.0.2" + pkg-dir "^4.2.0" + please-upgrade-node "^3.2.0" + slash "^3.0.0" + which-pm-runs "^1.0.0" + iconv-lite@^0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" @@ -3164,6 +3197,11 @@ onetime@^5.1.0: dependencies: mimic-fn "^2.1.0" +opencollective-postinstall@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259" + integrity sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q== + optionator@^0.9.1: version "0.9.1" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" @@ -3356,6 +3394,20 @@ pkg-dir@^2.0.0: dependencies: find-up "^2.1.0" +pkg-dir@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" + integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== + dependencies: + find-up "^4.0.0" + +please-upgrade-node@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942" + integrity sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg== + dependencies: + semver-compare "^1.0.0" + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" @@ -3656,6 +3708,16 @@ scuid@^1.0.2: resolved "https://registry.yarnpkg.com/scuid/-/scuid-1.1.0.tgz#d3f9f920956e737a60f72d0e4ad280bf324d5dab" integrity sha512-MuCAyrGZcTLfQoH2XoBlQ8C6bzwN88XT/0slOGz0pn8+gIP85BOAfYa44ZXQUTOwRwPU0QvgU+V+OSajl/59Xg== +semver-compare@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" + integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w= + +semver-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-2.0.0.tgz#a93c2c5844539a770233379107b38c7b4ac9d338" + integrity sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw== + "semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" @@ -4160,6 +4222,11 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= +which-pm-runs@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb" + integrity sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs= + which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"