From d84ac0310ce9f503c9ec05be742f73e2764a1651 Mon Sep 17 00:00:00 2001 From: dmytroPust Date: Wed, 1 Apr 2020 20:24:40 +0300 Subject: [PATCH 01/18] Chore: change extention of test files to .test.js --- package.json | 4 ++-- tests/package/{configurations.js => configurations.test.js} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename tests/package/{configurations.js => configurations.test.js} (100%) diff --git a/package.json b/package.json index 85aabdb..2496ad5 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "coveralls": "cat ./coverage/lcov.info | coveralls", "test:security": "npm audit", "test:lint": "eslint src", - "test:mocha": "mocha --config .mocharc.json tests/**/*.js", - "test:coverage": "MODE=test nyc mocha --config .mocharc.json tests/**/*.js", + "test:mocha": "mocha --config .mocharc.json tests/**/*test.js", + "test:coverage": "MODE=test nyc mocha --config .mocharc.json tests/**/*test.js", "coverage-check": "MODE=test nyc check-coverage", "test": "npm run test:lint && npm run test:security && npm run test:coverage", "semantic-release": "semantic-release" diff --git a/tests/package/configurations.js b/tests/package/configurations.test.js similarity index 100% rename from tests/package/configurations.js rename to tests/package/configurations.test.js From fc1491119302e2f22ba6bc497d69812dcdd21493 Mon Sep 17 00:00:00 2001 From: dmytroPust Date: Wed, 1 Apr 2020 20:41:32 +0300 Subject: [PATCH 02/18] Fix: adds missing modules --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2496ad5..94919a7 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "@babel/plugin-proposal-decorators": "^7.3.0", "@babel/plugin-proposal-object-rest-spread": "^7.3.4", "@babel/plugin-proposal-optional-chaining": "^7.2.0", + "@babel/polyfill": "^7.8.7", "@babel/preset-env": "^7.3.4", "@babel/runtime": "^7.3.4", "@semantic-release/changelog": "^3.0.4", @@ -55,7 +56,7 @@ "eslint-plugin-prefer-spread": "^1.0.3", "eslint-plugin-react": "^7.12.4", "fs-extra": "^8.1.0", - "mocha": "^6.1.4", + "mocha": "^6.2.3", "nyc": "^14.1.1", "semantic-release": "^15.13.19", "uuid": "^3.3.2" From a075dabcdd82773ce2d2170e03a3a847f6551c02 Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Thu, 8 Apr 2021 01:39:14 +0300 Subject: [PATCH 03/18] Chore: update semantic release rules --- .releaserc.json | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.releaserc.json b/.releaserc.json index e44f96d..c3de75d 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -1,5 +1,5 @@ { - "branch": "master", + "branches": "master", "ci": false, "plugins": [ "@semantic-release/commit-analyzer", @@ -12,18 +12,19 @@ "@semantic-release/npm", [ "@semantic-release/git", { - "message": "Chore: (release) add version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + "assets": ["README.md", "CHANGELOG.md", "package.json"], + "message": "Chore(release): add version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" } ] ], "preset": "eslint", "releaseRules": [ - { "type": "Fix", "release": "patch" }, - { "type": "Update", "release": "minor" }, - { "type": "New", "release": "minor" }, - { "type": "Breaking", "release": "major" }, - { "type": "Docs", "release": "patch" }, - { "type": "Upgrade", "release": "patch" } + { "tag": "Fix", "release": "patch" }, + { "tag": "Update", "release": "minor" }, + { "tag": "New", "release": "minor" }, + { "tag": "Breaking", "release": "minor" }, + { "tag": "Docs", "release": "patch" }, + { "tag": "Upgrade", "release": "patch" } ], "parserOpts": { "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"] From 38ded63eb2a1a8e71b9a437d8b784a88dac47543 Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Thu, 8 Apr 2021 20:05:11 +0300 Subject: [PATCH 04/18] Chore: adds commitlint --- .commitlintrc.json | 19 +++++++++++++++++++ .husky/.gitignore | 1 + .husky/commit-msg | 4 ++++ package.json | 4 +++- 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .commitlintrc.json create mode 100644 .husky/.gitignore create mode 100755 .husky/commit-msg diff --git a/.commitlintrc.json b/.commitlintrc.json new file mode 100644 index 0000000..a99f4fd --- /dev/null +++ b/.commitlintrc.json @@ -0,0 +1,19 @@ +{ + "rules": { + "subject-empty": [2, "never"], + "type-empty": [2, "never"], + "type-enum": [ + 2, + "always", + [ + "Chore", + "Fix", + "New", + "Update", + "Breaking", + "Docs", + "Upgrade" + ] + ] + } +} \ No newline at end of file diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 0000000..31354ec --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 0000000..e8511ea --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx --no-install commitlint --edit $1 diff --git a/package.json b/package.json index 94919a7..9754937 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "./lib", "scripts": { "build": "babel src --out-dir ./lib", - "prepare": "npm run build", + "prepare": "npm run build && husky install", "coveralls": "cat ./coverage/lcov.info | coveralls", "test:security": "npm audit", "test:lint": "eslint src", @@ -36,6 +36,7 @@ "@babel/polyfill": "^7.8.7", "@babel/preset-env": "^7.3.4", "@babel/runtime": "^7.3.4", + "@commitlint/cli": "^12.1.1", "@semantic-release/changelog": "^3.0.4", "@semantic-release/commit-analyzer": "^6.1.0", "@semantic-release/git": "^7.0.8", @@ -56,6 +57,7 @@ "eslint-plugin-prefer-spread": "^1.0.3", "eslint-plugin-react": "^7.12.4", "fs-extra": "^8.1.0", + "husky": "^6.0.0", "mocha": "^6.2.3", "nyc": "^14.1.1", "semantic-release": "^15.13.19", From c4fb3f1b9ec25425f49b3fd0a17cf68f64429fb4 Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Thu, 8 Apr 2021 21:01:54 +0300 Subject: [PATCH 05/18] Chore: adds target branch to semantic release --- .releaserc.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.releaserc.json b/.releaserc.json index c3de75d..99ad1a5 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -1,5 +1,6 @@ { - "branches": "master", + "branches": ["master"], + "branch": "master", "ci": false, "plugins": [ "@semantic-release/commit-analyzer", From 0b6e9847587f281e0b350bb4f9b6d0d498b4ac82 Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Thu, 8 Apr 2021 23:10:33 +0300 Subject: [PATCH 06/18] Chore: disable build for coverage check --- package.json | 2 +- tests/entry.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9754937..3022ce0 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "test:security": "npm audit", "test:lint": "eslint src", "test:mocha": "mocha --config .mocharc.json tests/**/*test.js", - "test:coverage": "MODE=test nyc mocha --config .mocharc.json tests/**/*test.js", + "test:coverage": "BUILD=0 MODE=test nyc mocha --config .mocharc.json tests/**/*test.js", "coverage-check": "MODE=test nyc check-coverage", "test": "npm run test:lint && npm run test:security && npm run test:coverage", "semantic-release": "semantic-release" diff --git a/tests/entry.js b/tests/entry.js index ca144c3..3d74c01 100644 --- a/tests/entry.js +++ b/tests/entry.js @@ -1,4 +1,4 @@ -module.exports = process.env.BUILD +module.exports = process.env.BUILD !== '0' ? require('../lib') : require('../src'); From 9b9602d2d5e9d869a6555437355325c703ccfb5b Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Fri, 16 Apr 2021 00:21:29 +0300 Subject: [PATCH 07/18] Chore: adds tests for packing process --- .gitignore | 3 ++- .npmignore | 9 ++++++++- .releaserc.json | 7 +++++++ .travis.yml | 3 +++ bin/pack.sh | 5 +++++ package.json | 4 +++- tests/entry.js | 9 ++++++--- tests/package/configurations.test.js | 4 ++-- 8 files changed, 36 insertions(+), 8 deletions(-) create mode 100755 bin/pack.sh diff --git a/.gitignore b/.gitignore index fc89a07..4fac487 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ lib/* coverage/* tmp/* logs/* -*.log \ No newline at end of file +*.log +*.tgz \ No newline at end of file diff --git a/.npmignore b/.npmignore index 0470bf8..7e910f2 100644 --- a/.npmignore +++ b/.npmignore @@ -4,4 +4,11 @@ tests .eslintrc .eslintignore .babelrc -tmp \ No newline at end of file +tmp +.husky +bin +*.tgz +.commitlintrc.json +.mocharc.json +.nycrc.json +.releaserc.json diff --git a/.releaserc.json b/.releaserc.json index 99ad1a5..c036d02 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -16,6 +16,13 @@ "assets": ["README.md", "CHANGELOG.md", "package.json"], "message": "Chore(release): add version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" } + ], + [ + "@semantic-release/github", { + "assets": [ + { "path": "*.tgz" } + ] + } ] ], "preset": "eslint", diff --git a/.travis.yml b/.travis.yml index 32e7892..99dad4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,12 +12,15 @@ jobs: script: "npm run test:coverage" - stage: test script: "npm run test:security" + - stage: test + script: "npm run test:package" - stage: release node_js: lts/* deploy: provider: script skip_cleanup: true script: + - ./bin/pack.sh - npx semantic-release notifications: email: diff --git a/bin/pack.sh b/bin/pack.sh new file mode 100755 index 0000000..195f770 --- /dev/null +++ b/bin/pack.sh @@ -0,0 +1,5 @@ +#!/bin/bash +rm -rf tmp/package +PACKAGE="$(npm pack 2>&1 | tail -1)" +mkdir -p tmp +tar -xvzf $PACKAGE -C tmp \ No newline at end of file diff --git a/package.json b/package.json index 3022ce0..d0b1694 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,10 @@ "test:security": "npm audit", "test:lint": "eslint src", "test:mocha": "mocha --config .mocharc.json tests/**/*test.js", + "test:package": "./bin/pack.sh && ENTRY=./tmp/package/lib npm run test:mocha", "test:coverage": "BUILD=0 MODE=test nyc mocha --config .mocharc.json tests/**/*test.js", "coverage-check": "MODE=test nyc check-coverage", - "test": "npm run test:lint && npm run test:security && npm run test:coverage", + "test": "npm run test:lint && npm run test:security && BUILD=1 npm run test:mocha", "semantic-release": "semantic-release" }, "repository": { @@ -40,6 +41,7 @@ "@semantic-release/changelog": "^3.0.4", "@semantic-release/commit-analyzer": "^6.1.0", "@semantic-release/git": "^7.0.8", + "@semantic-release/github": "^7.2.1", "@semantic-release/npm": "^5.1.7", "@semantic-release/release-notes-generator": "^7.1.4", "babel-eslint": "^10.0.1", diff --git a/tests/entry.js b/tests/entry.js index 3d74c01..2eec7b4 100644 --- a/tests/entry.js +++ b/tests/entry.js @@ -1,4 +1,7 @@ -module.exports = process.env.BUILD !== '0' - ? require('../lib') - : require('../src'); +import path from 'path'; + +const isBuild = process.env.BUILD && [ '1', 'true' ].includes(process.env.BUILD); +const entry = process.env.ENTRY && path.resolve(process.env.ENTRY); + +module.exports = entry && require(entry) || isBuild && require('../lib') || require('../src'); diff --git a/tests/package/configurations.test.js b/tests/package/configurations.test.js index 7c7f94c..ec94708 100644 --- a/tests/package/configurations.test.js +++ b/tests/package/configurations.test.js @@ -1,8 +1,8 @@ import { assert } from 'chai'; -import logger from '../entry'; -import { verifyStdout } from '../utils'; +import entry from '../entry'; suite('Configurations'); test('Default configuration', function () { + assert.exists(entry); }); From 364e26b379e6cd94b89776aa0a41abd10a5dc43a Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Fri, 16 Apr 2021 00:57:28 +0300 Subject: [PATCH 08/18] Chore: fixes package process --- .releaserc.json | 2 +- .travis.yml | 4 +--- bin/pack.sh | 3 ++- package.json | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.releaserc.json b/.releaserc.json index c036d02..52c6d8c 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -20,7 +20,7 @@ [ "@semantic-release/github", { "assets": [ - { "path": "*.tgz" } + { "path": "*.tgz", "label": "version, uploaded to npm" } ] } ] diff --git a/.travis.yml b/.travis.yml index 99dad4a..80d0e46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,9 +19,7 @@ jobs: deploy: provider: script skip_cleanup: true - script: - - ./bin/pack.sh - - npx semantic-release + script: npm run semantic-release notifications: email: recipients: dipustovit@gmail.com diff --git a/bin/pack.sh b/bin/pack.sh index 195f770..e134338 100755 --- a/bin/pack.sh +++ b/bin/pack.sh @@ -2,4 +2,5 @@ rm -rf tmp/package PACKAGE="$(npm pack 2>&1 | tail -1)" mkdir -p tmp -tar -xvzf $PACKAGE -C tmp \ No newline at end of file +tar -xvzf $PACKAGE -C tmp +mv $PACKAGE ${PACKAGE/-0.0.1/} \ No newline at end of file diff --git a/package.json b/package.json index d0b1694..d6f1a04 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test:coverage": "BUILD=0 MODE=test nyc mocha --config .mocharc.json tests/**/*test.js", "coverage-check": "MODE=test nyc check-coverage", "test": "npm run test:lint && npm run test:security && BUILD=1 npm run test:mocha", - "semantic-release": "semantic-release" + "semantic-release": "./bin/pack.sh && npx semantic-release" }, "repository": { "type": "git", @@ -62,7 +62,7 @@ "husky": "^6.0.0", "mocha": "^6.2.3", "nyc": "^14.1.1", - "semantic-release": "^15.13.19", + "semantic-release": "^17.4.2", "uuid": "^3.3.2" } } From 273497a050e075200512db9033ee2fe9d973a5f4 Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Fri, 16 Apr 2021 01:07:46 +0300 Subject: [PATCH 09/18] Chore: corrected pack pattern --- bin/pack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pack.sh b/bin/pack.sh index e134338..023f850 100755 --- a/bin/pack.sh +++ b/bin/pack.sh @@ -3,4 +3,4 @@ rm -rf tmp/package PACKAGE="$(npm pack 2>&1 | tail -1)" mkdir -p tmp tar -xvzf $PACKAGE -C tmp -mv $PACKAGE ${PACKAGE/-0.0.1/} \ No newline at end of file +mv $PACKAGE ${PACKAGE/-[0-9\.]+\.tgz/.tgz} \ No newline at end of file From 72a22018f8e9875de4194821361602cc432a32b1 Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Fri, 16 Apr 2021 01:38:18 +0300 Subject: [PATCH 10/18] Chore: corrected extglob matching --- .npmignore | 1 + bin/pack.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.npmignore b/.npmignore index 7e910f2..f0bcc2c 100644 --- a/.npmignore +++ b/.npmignore @@ -12,3 +12,4 @@ bin .mocharc.json .nycrc.json .releaserc.json +coverage/* \ No newline at end of file diff --git a/bin/pack.sh b/bin/pack.sh index 023f850..767a5ee 100755 --- a/bin/pack.sh +++ b/bin/pack.sh @@ -3,4 +3,4 @@ rm -rf tmp/package PACKAGE="$(npm pack 2>&1 | tail -1)" mkdir -p tmp tar -xvzf $PACKAGE -C tmp -mv $PACKAGE ${PACKAGE/-[0-9\.]+\.tgz/.tgz} \ No newline at end of file +mv $PACKAGE ${PACKAGE/-[0-9.]*.tgz/.tgz} \ No newline at end of file From 5e0e51223c0069915e559de8a55a18696254f8fd Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Fri, 16 Apr 2021 01:49:53 +0300 Subject: [PATCH 11/18] Chore: change tgz label --- .releaserc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.releaserc.json b/.releaserc.json index 52c6d8c..33f3f14 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -20,7 +20,7 @@ [ "@semantic-release/github", { "assets": [ - { "path": "*.tgz", "label": "version, uploaded to npm" } + { "path": "*.tgz", "label": "npm" } ] } ] From eeefda5daa30eedd1af621c4a0c0efa32f0c9645 Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Fri, 16 Apr 2021 21:42:12 +0300 Subject: [PATCH 12/18] Chore: use native tarball generation --- .releaserc.json | 8 ++++++-- bin/pack.sh | 2 +- package.json | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.releaserc.json b/.releaserc.json index 33f3f14..25fb0e3 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -10,7 +10,11 @@ "changelogFile": "CHANGELOG.md" } ], - "@semantic-release/npm", + [ + "@semantic-release/npm",{ + "tarballDir": "./" + } + ], [ "@semantic-release/git", { "assets": ["README.md", "CHANGELOG.md", "package.json"], @@ -20,7 +24,7 @@ [ "@semantic-release/github", { "assets": [ - { "path": "*.tgz", "label": "npm" } + { "path": "*.tgz", "label": "npm tarblall" } ] } ] diff --git a/bin/pack.sh b/bin/pack.sh index 767a5ee..de3476a 100755 --- a/bin/pack.sh +++ b/bin/pack.sh @@ -3,4 +3,4 @@ rm -rf tmp/package PACKAGE="$(npm pack 2>&1 | tail -1)" mkdir -p tmp tar -xvzf $PACKAGE -C tmp -mv $PACKAGE ${PACKAGE/-[0-9.]*.tgz/.tgz} \ No newline at end of file +#mv $PACKAGE ${PACKAGE/-[0-9.]*.tgz/.tgz} \ No newline at end of file diff --git a/package.json b/package.json index d6f1a04..85dd01c 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test:coverage": "BUILD=0 MODE=test nyc mocha --config .mocharc.json tests/**/*test.js", "coverage-check": "MODE=test nyc check-coverage", "test": "npm run test:lint && npm run test:security && BUILD=1 npm run test:mocha", - "semantic-release": "./bin/pack.sh && npx semantic-release" + "semantic-release": "npx semantic-release" }, "repository": { "type": "git", From 4f8ced4f6a9ba7559b68c94d0bcfcf30faa57e45 Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Fri, 16 Apr 2021 22:19:44 +0300 Subject: [PATCH 13/18] Fix: fixes typo --- .releaserc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.releaserc.json b/.releaserc.json index 25fb0e3..1f3b058 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -24,7 +24,7 @@ [ "@semantic-release/github", { "assets": [ - { "path": "*.tgz", "label": "npm tarblall" } + { "path": "*.tgz", "label": "npm tarball" } ] } ] From f5a467979d6cbb3fa21797fe063deb99c2e6e6d0 Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Sun, 18 Apr 2021 01:33:25 +0300 Subject: [PATCH 14/18] Chore: adds lock file lint --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 85dd01c..be28028 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,13 @@ "build": "babel src --out-dir ./lib", "prepare": "npm run build && husky install", "coveralls": "cat ./coverage/lcov.info | coveralls", - "test:security": "npm audit", + "test:security": "npm audit && npm run test:lock", "test:lint": "eslint src", "test:mocha": "mocha --config .mocharc.json tests/**/*test.js", "test:package": "./bin/pack.sh && ENTRY=./tmp/package/lib npm run test:mocha", "test:coverage": "BUILD=0 MODE=test nyc mocha --config .mocharc.json tests/**/*test.js", + "test:debt": "jscpd src --config .jscpd.json", + "test:lock": "lockfile-lint --path package-lock.json --validate-https --allowed-hosts npm", "coverage-check": "MODE=test nyc check-coverage", "test": "npm run test:lint && npm run test:security && BUILD=1 npm run test:mocha", "semantic-release": "npx semantic-release" @@ -60,6 +62,8 @@ "eslint-plugin-react": "^7.12.4", "fs-extra": "^8.1.0", "husky": "^6.0.0", + "jscpd": "^3.3.25", + "lockfile-lint": "^4.6.2", "mocha": "^6.2.3", "nyc": "^14.1.1", "semantic-release": "^17.4.2", From e16a8e2880d894ed0ca6f6125b7be61a90a15768 Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Sun, 18 Apr 2021 01:33:46 +0300 Subject: [PATCH 15/18] Chore: adds technical dept check --- .jscpd.json | 9 +++++++++ .travis.yml | 2 ++ 2 files changed, 11 insertions(+) create mode 100644 .jscpd.json diff --git a/.jscpd.json b/.jscpd.json new file mode 100644 index 0000000..5f520d1 --- /dev/null +++ b/.jscpd.json @@ -0,0 +1,9 @@ +{ + "threshold": 5, + "reporters": ["html", "console"], + "ignore": [], + "output": "./reports/jscpd", + "minLines": 3, + "minTokens": 30, + "ignoreCase": true +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 80d0e46..1937126 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,8 @@ jobs: script: "npm run test:security" - stage: test script: "npm run test:package" + - stage: test + script: "npm run test:dept" - stage: release node_js: lts/* deploy: From e1591042eba97c4b87c923a3a84053eca1e2da4d Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Sun, 18 Apr 2021 01:38:43 +0300 Subject: [PATCH 16/18] Chore: update travis badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9aad75..5e0b35d 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ The message summary should be a one-sentence description of the change. The issu [travis]: https://travis-ci.org/pustovitDmytro/npm-boilerplate [coveralls]: https://coveralls.io/github/pustovitDmytro/npm-boilerplate?branch=master [badge-deps]: https://img.shields.io/david/pustovitDmytro/npm-boilerplate.svg -[badge-tests]: https://img.shields.io/travis/pustovitDmytro/npm-boilerplate.svg +[badge-tests]: https://travis-ci.com/pustovitDmytro/npm-boilerplate.svg?branch=master [badge-vuln]: https://img.shields.io/snyk/vulnerabilities/npm/npm-boilerplate.svg?style=popout [badge-vers]: https://img.shields.io/npm/v/npm-boilerplate.svg [badge-lic]: https://img.shields.io/github/license/pustovitDmytro/npm-boilerplate.svg From 7fb7040e3b4daa8fc1b419aa88e08118fb43497d Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Sun, 18 Apr 2021 15:18:34 +0300 Subject: [PATCH 17/18] Chore: adds danger to validate pr --- .dangerfile.js | 36 ++++++++++++++++++++++++++++++++++++ .eslintignore | 1 + .husky/commit-msg | 2 +- .travis.yml | 7 +++++++ package.json | 2 ++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .dangerfile.js create mode 100644 .eslintignore diff --git a/.dangerfile.js b/.dangerfile.js new file mode 100644 index 0000000..37def22 --- /dev/null +++ b/.dangerfile.js @@ -0,0 +1,36 @@ +import { message, danger, warn, fail } from 'danger'; +import lint from '@commitlint/lint'; +import commitLintConfig from './.commitlintrc'; + +const src = danger.git.fileMatch('src/*'); +const tests = danger.git.fileMatch('tests/*'); +const system = danger.git.fileMatch('.*', '.*/**', 'LICENSE.md', 'package-lock.json', 'package.json'); +const isOwner = danger.github.pr.user.login === danger.github.thisPR.owner; +const modifiedList = danger.git.modified_files.join('- '); + +export default async function () { + message(`Changed Files in this PR: \n - ${modifiedList}`); + + if (system.modified && !isOwner) { + const files = system.getKeyedPaths().modified; + + fail(`Only owner can change system files [${files.join(', ')}], please provide issue instead`, files[0]); + } + + if (!src.modified && !tests.modified) { + warn('Source files were changed without tests'); + } + + const promises = danger.github.commits.map(async commit => { + const msg = commit.commit.message; + const comitLintReport = await lint(msg, commitLintConfig.rules); + + if (!comitLintReport.valid) { + const errors = comitLintReport.errors.map(e => e.message); + + fail(`Commit [${commit.sha}]:\n${msg} not mathing convention:\n${errors.join('\n')}`); + } + }); + + await Promise.all(promises); +} diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..ad6f0a7 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +!.dangerfile.js \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg index e8511ea..5426a93 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npx --no-install commitlint --edit $1 +npx commitlint --edit $1 diff --git a/.travis.yml b/.travis.yml index 1937126..d719937 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,15 @@ before_script: - "npm run build" after_success: - "npm run coveralls" +stages: + - analyze + - test + - name: deploy + if: branch = master jobs: include: + - stage: analyze + script: "npx danger ci -d .dangerfile.js" - stage: test script: "npm run test:lint" - stage: test diff --git a/package.json b/package.json index be28028..746084e 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "@babel/preset-env": "^7.3.4", "@babel/runtime": "^7.3.4", "@commitlint/cli": "^12.1.1", + "@commitlint/lint": "^12.1.1", "@semantic-release/changelog": "^3.0.4", "@semantic-release/commit-analyzer": "^6.1.0", "@semantic-release/git": "^7.0.8", @@ -52,6 +53,7 @@ "chance": "^1.0.18", "conventional-changelog-eslint": "^3.0.1", "coveralls": "^3.0.3", + "danger": "^10.6.4", "eslint": "^5.16.0", "eslint-config-webbylab": "^4.0.0", "eslint-plugin-fetch": "0.0.1", From f9fd4631aa300e16128a4d7107d45f9317f70c9b Mon Sep 17 00:00:00 2001 From: Dmytro Pustovit Date: Sun, 18 Apr 2021 15:25:06 +0300 Subject: [PATCH 18/18] Chore: fixes debt typo in travis job --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d719937..c63ba4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ jobs: - stage: test script: "npm run test:package" - stage: test - script: "npm run test:dept" + script: "npm run test:debt" - stage: release node_js: lts/* deploy: