From 3e8109f19bc7b9fb313467f61177ab08459ecf21 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Fri, 23 Feb 2024 13:51:42 +0200 Subject: [PATCH] feat(deploy): added autopublish --- .github/workflows/release.yaml | 37 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 6 +++--- .ncurc.js | 7 +++++++ lib/charset.js | 1 + lib/libmime.js | 1 + package.json | 17 ++++++++-------- test/libmime-test.js | 34 +++++++++++++++++++++++++++++++ 7 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 .ncurc.js diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..a91a109 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,37 @@ +on: + push: + branches: + - master + +permissions: + contents: write + pull-requests: write + id-token: write + +name: release +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: node + package-name: ${{vars.NPM_MODULE_NAME}} + pull-request-title-pattern: 'chore${scope}: release ${version} [skip-ci]' + # The logic below handles the npm publication: + - uses: actions/checkout@v4 + # these if statements ensure that a publication only occurs when + # a new release is created: + if: ${{ steps.release.outputs.release_created }} + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: 'https://registry.npmjs.org' + if: ${{ steps.release.outputs.release_created }} + - run: npm ci + if: ${{ steps.release.outputs.release_created }} + - run: npm publish --provenance --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + if: ${{ steps.release.outputs.release_created }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e7be683..e56a4c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,13 +8,13 @@ jobs: test: strategy: matrix: - node: [12.x, 14.x, 16.x, 18.x] - os: [ubuntu-latest, macos-latest, windows-latest] + node: [16.x, 18.x, 20.x, 21.x] + os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - run: npm install diff --git a/.ncurc.js b/.ncurc.js new file mode 100644 index 0000000..8380f9b --- /dev/null +++ b/.ncurc.js @@ -0,0 +1,7 @@ +module.exports = { + upgrade: true, + reject: [ + // 5x is esm only + 'chai' + ] +}; diff --git a/lib/charset.js b/lib/charset.js index f5ab60b..2f5686d 100644 --- a/lib/charset.js +++ b/lib/charset.js @@ -1,5 +1,6 @@ 'use strict'; +const { Buffer } = require('node:buffer'); const iconv = require('iconv-lite'); const encodingJapanese = require('encoding-japanese'); const charsets = require('./charsets'); diff --git a/lib/libmime.js b/lib/libmime.js index 740868a..cfd5cb0 100644 --- a/lib/libmime.js +++ b/lib/libmime.js @@ -1,6 +1,7 @@ /* eslint no-control-regex: 0, no-div-regex: 0, quotes: 0 */ 'use strict'; +const { Buffer } = require('node:buffer'); const libcharset = require('./charset'); const libbase64 = require('libbase64'); const libqp = require('libqp'); diff --git a/package.json b/package.json index 43ef8ab..f591266 100644 --- a/package.json +++ b/package.json @@ -16,22 +16,23 @@ ], "author": "Andris Reinman ", "scripts": { - "test": "grunt" + "test": "grunt", + "update": "rm -rf node_modules package-lock.json && ncu -u && npm install" }, "dependencies": { "encoding-japanese": "2.0.0", "iconv-lite": "0.6.3", - "libbase64": "1.2.1", - "libqp": "2.0.1" + "libbase64": "1.3.0", + "libqp": "2.1.0" }, "devDependencies": { - "chai": "4.3.7", + "chai": "4.4.1", "eslint-config-nodemailer": "1.2.0", - "eslint-config-prettier": "8.6.0", - "grunt": "1.5.3", + "eslint-config-prettier": "9.1.0", + "grunt": "1.6.1", "grunt-cli": "1.4.3", - "grunt-eslint": "24.0.1", + "grunt-eslint": "24.3.0", "grunt-mocha-test": "0.13.3", - "mocha": "10.2.0" + "mocha": "10.3.0" } } diff --git a/test/libmime-test.js b/test/libmime-test.js index c1386dd..14b313c 100644 --- a/test/libmime-test.js +++ b/test/libmime-test.js @@ -2,6 +2,7 @@ 'use strict'; +const { Buffer } = require('node:buffer'); const libmime = require('../lib/libmime'); const charset = require('../lib/charset'); @@ -307,6 +308,39 @@ describe('libmime', () => { expect(libmime.parseHeaderValue(str)).to.deep.equal(obj); }); + it('should handle multi line ascii values', () => { + let str = + 'text/plain;\n' + + '\tname*0=emailengine_uuendamise_kasud_ja_muud_asjad_ja_veelgi_pikem_pealk;\n' + + '\tname*1=iri.txt;\n' + + '\tx-apple-part-url=99AFDE83-8953-43B4-BE59-F59D6160AFAB', + obj = { + value: 'text/plain', + params: { + name: 'emailengine_uuendamise_kasud_ja_muud_asjad_ja_veelgi_pikem_pealkiri.txt', + 'x-apple-part-url': '99AFDE83-8953-43B4-BE59-F59D6160AFAB' + } + }; + + expect(libmime.parseHeaderValue(str)).to.deep.equal(obj); + }); + + it.only('should handle ARC header from MS', () => { + let str = + 'i=1; mx.microsoft.com 1; spf=fail (sender ip is 52.138.216.130) smtp.rcpttodomain=recipient.com smtp.mailfrom=sender.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=sender.com; dkim=none (message not signed); arc=none (0)', + obj = { + value: 'i=1', + params: { + 'mx.microsoft.com 1; spf': 'fail (sender ip is 52.138.216.130) smtp.rcpttodomain=recipient.com smtp.mailfrom=sender.com', + dmarc: 'fail (p=reject sp=reject pct=100) action=oreject header.from=sender.com', + dkim: 'none (message not signed)', + arc: 'none (0)' + } + }; + + expect(libmime.parseHeaderValue(str)).to.deep.equal(obj); + }); + it('should handle params only', () => { let str = '; CHARSET= UTF-8; format=flowed;', obj = {