From 2d530aea33a638f1b105ae09ad3ec7e48fa26c6a Mon Sep 17 00:00:00 2001 From: Oleksii Zaichko Date: Wed, 19 Aug 2020 11:24:19 +0300 Subject: [PATCH 1/4] chore: github npm auto publish. --- .github/workflows/auto-npm-publish.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/auto-npm-publish.yml diff --git a/.github/workflows/auto-npm-publish.yml b/.github/workflows/auto-npm-publish.yml new file mode 100644 index 0000000..204c6d9 --- /dev/null +++ b/.github/workflows/auto-npm-publish.yml @@ -0,0 +1,24 @@ +name: auto-npm-publish +on: + push: + branches: + - master +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 10 + - run: npm install + - run: npm test + - run: npm run build:prod + - name: NPM Publish + uses: JS-DevTools/npm-publish@v1 + with: + package: ./dist/package.json + check-version: true + token: ${{ secrets.NPM_TOKEN }} + dry-run: true + From d86b641757bc7731e855f0156d280dd6b32eb453 Mon Sep 17 00:00:00 2001 From: Oleksii Zaichko Date: Wed, 19 Aug 2020 13:36:25 +0300 Subject: [PATCH 2/4] fix: github npm auto publish postinstall inside dev dir issue. --- projects/ngx-mqtt/.no-postinstall | 0 projects/ngx-mqtt/postinstall.js | 15 +++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 projects/ngx-mqtt/.no-postinstall diff --git a/projects/ngx-mqtt/.no-postinstall b/projects/ngx-mqtt/.no-postinstall new file mode 100644 index 0000000..e69de29 diff --git a/projects/ngx-mqtt/postinstall.js b/projects/ngx-mqtt/postinstall.js index d93a106..fdc334c 100644 --- a/projects/ngx-mqtt/postinstall.js +++ b/projects/ngx-mqtt/postinstall.js @@ -3,6 +3,21 @@ if (process.env['mqtt-disable-hook']) { } const fs = require('fs'); + +// to check if it's development directory +// the .no-postinstall file is used +// it doesn't exist in built library +const noPostInstallPath = './.no-postinstall'; +try { + if (fs.existsSync(noPostInstallPath)) { + // don't run postinstall in the dev directory + return 0; + } +} catch(err) { + console.error(err); + return 1; +} + const f = '../../node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js'; fs.readFile(f, 'utf8', function (err,data) { From b49c872942c9281db32ede299d411446f9cecf28 Mon Sep 17 00:00:00 2001 From: Oleksii Zaichko Date: Wed, 19 Aug 2020 13:56:52 +0300 Subject: [PATCH 3/4] fix: incorrect path to package.json. --- .github/workflows/auto-npm-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-npm-publish.yml b/.github/workflows/auto-npm-publish.yml index 204c6d9..0fe1826 100644 --- a/.github/workflows/auto-npm-publish.yml +++ b/.github/workflows/auto-npm-publish.yml @@ -17,7 +17,7 @@ jobs: - name: NPM Publish uses: JS-DevTools/npm-publish@v1 with: - package: ./dist/package.json + package: ./dist/ngx-mqtt/package.json check-version: true token: ${{ secrets.NPM_TOKEN }} dry-run: true From 4625894e05ed7b65837d9708703dbfe9fbbe9d9f Mon Sep 17 00:00:00 2001 From: Oleksii Zaichko Date: Wed, 19 Aug 2020 14:01:44 +0300 Subject: [PATCH 4/4] chore: remove dry run. --- .github/workflows/auto-npm-publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/auto-npm-publish.yml b/.github/workflows/auto-npm-publish.yml index 0fe1826..718f4aa 100644 --- a/.github/workflows/auto-npm-publish.yml +++ b/.github/workflows/auto-npm-publish.yml @@ -20,5 +20,4 @@ jobs: package: ./dist/ngx-mqtt/package.json check-version: true token: ${{ secrets.NPM_TOKEN }} - dry-run: true