From d3f54deb82d8256b8fa2cb8d5535ec5c512ff3a1 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Mon, 8 Apr 2024 15:12:54 -0700 Subject: [PATCH 1/6] populate [files] in package.json. Delete .npmignore. --- .npmignore | 59 ---------------------------------------------------- .release | 2 +- Changes.md | 14 +++++++++++-- package.json | 19 ++++++++++------- 4 files changed, 24 insertions(+), 70 deletions(-) delete mode 100644 .npmignore diff --git a/.npmignore b/.npmignore deleted file mode 100644 index a1802f9..0000000 --- a/.npmignore +++ /dev/null @@ -1,59 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules -jspm_packages - -# Optional npm cache directory -.npm - -# Optional REPL history -.node_repl_history - -package-lock.json -bower_components -# Optional npm cache directory -.npmrc - -.idea -.DS_Store -haraka-update.sh - -.github -.release -.codeclimate.yml -.editorconfig -.gitignore -.gitmodules -.lgtm.yml -appveyor.yml -codecov.yml -.travis.yml -.eslintrc.yaml -.eslintrc.json diff --git a/.release b/.release index 0890e94..7cd5707 160000 --- a/.release +++ b/.release @@ -1 +1 @@ -Subproject commit 0890e945e4e061c96c7b2ab45017525904c17728 +Subproject commit 7cd5707f7d69f8d4dca1ec407ada911890e59d0a diff --git a/Changes.md b/Changes.md index 401eb5f..bb6dec4 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,13 @@ +# Changelog + +The format is based on [Keep a Changelog](https://keepachangelog.com/). + ### Unreleased +### [1.0.6] - 2024-04-08 + +- populate [files] in package.json. Delete .npmignore. ### 1.0.5 - 2023-12-12 @@ -16,7 +23,7 @@ - ci: use reusable workflows (#18) -### 1.0.2 - 2022-05-23 +### [1.0.2] - 2022-05-23 - ci: replace hard coded node vers with node-lts-versions - ci(publish): add secrets: inherit @@ -24,7 +31,7 @@ - packaging updates -### 1.0.1 - 2021-02-04 +### [1.0.1] - 2021-02-04 - test: added example tests that set up conn/txn - ci: add automated package publishing @@ -36,4 +43,7 @@ - initial release +[1.0.1]: https://github.com/haraka/haraka-plugin-template/releases/tag/1.0.1 +[1.0.2]: https://github.com/haraka/haraka-plugin-template/releases/tag/1.0.2 [1.0.3]: https://github.com/haraka/haraka-plugin-template/releases/tag/1.0.3 +[1.0.6]: https://github.com/haraka/haraka-plugin-template/releases/tag/v1.0.6 diff --git a/package.json b/package.json index 2ce56a2..841307e 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,18 @@ { "name": "haraka-plugin-template", - "version": "1.0.5", + "version": "1.0.6", "description": "Haraka plugin that...CHANGE THIS", "main": "index.js", + "files": ["CHANGELOG.md", "config"], "scripts": { - "lint": "npx eslint *.js test", - "lintfix": "npx eslint --fix *.js test", - "versions": "npx dependency-version-checker check", - "test": "npx mocha" + "format": "npm run prettier:fix && npm run lint:fix", + "lint": "npx eslint@^8 *.js test", + "lint:fix": "npx eslint@^8 *.js test --fix", + "prettier": "npx prettier . --check", + "prettier:fix": "npx prettier . --write --log-level=warn", + "test": "npx mocha@^10", + "versions": "npx @msimerson/dependency-version-checker check", + "versions:fix": "npx @msimerson/dependency-version-checker update" }, "repository": { "type": "git", @@ -25,9 +30,7 @@ }, "homepage": "https://github.com/haraka/haraka-plugin-template#readme", "devDependencies": { - "eslint": "^8.55.0", "eslint-plugin-haraka": "*", - "haraka-test-fixtures": "*", - "mocha": "^10.2.0" + "haraka-test-fixtures": "*" } } From 943cb51511ddeb76e8940cf6618ae71dc2a0e390 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Mon, 8 Apr 2024 15:16:02 -0700 Subject: [PATCH 2/6] dep: eslint-plugin-haraka -> @haraka/eslint-config --- .github/workflows/ci.yml | 1 - .github/workflows/publish.yml | 3 +-- Changes.md | 1 + package.json | 9 ++++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d1cca8..325fb6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,6 @@ env: CI: true jobs: - lint: uses: haraka/.github/.github/workflows/lint.yml@master diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c33f899..9bfdec3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,8 +1,6 @@ name: publish on: - release: - types: [ published ] push: branches: - master @@ -16,3 +14,4 @@ jobs: publish: uses: haraka/.github/.github/workflows/publish.yml@master secrets: inherit + diff --git a/Changes.md b/Changes.md index bb6dec4..273ec57 100644 --- a/Changes.md +++ b/Changes.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### [1.0.6] - 2024-04-08 +- dep: eslint-plugin-haraka -> @haraka/eslint-config - populate [files] in package.json. Delete .npmignore. ### 1.0.5 - 2023-12-12 diff --git a/package.json b/package.json index 841307e..d04a0eb 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,10 @@ "version": "1.0.6", "description": "Haraka plugin that...CHANGE THIS", "main": "index.js", - "files": ["CHANGELOG.md", "config"], + "files": [ + "CHANGELOG.md", + "config" + ], "scripts": { "format": "npm run prettier:fix && npm run lint:fix", "lint": "npx eslint@^8 *.js test", @@ -30,7 +33,7 @@ }, "homepage": "https://github.com/haraka/haraka-plugin-template#readme", "devDependencies": { - "eslint-plugin-haraka": "*", - "haraka-test-fixtures": "*" + "@haraka/eslint-config": "1.1.3", + "haraka-test-fixtures": "1.3.5" } } From c8d833911eaf6ffd5b56595d83736bb0c836f050 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Mon, 8 Apr 2024 15:21:26 -0700 Subject: [PATCH 3/6] lint: remove duplicate / stale rules from .eslintrc --- .eslintrc.yaml | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index fe947ea..ddf5f86 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,24 +2,6 @@ env: node: true es6: true mocha: true - es2020: true + es2022: true -plugins: - - haraka - -extends: - - eslint:recommended - - plugin:haraka/recommended - -rules: - indent: [2, 2, {"SwitchCase": 1}] - -root: true - -globals: - OK: true - CONT: true - DENY: true - DENYSOFT: true - DENYDISCONNECT: true - DENYSOFTDISCONNECT: true +extends: ['@haraka'] \ No newline at end of file From 424b0f1b7e106c43f950eb1accf74939b9017d5b Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Mon, 8 Apr 2024 15:21:46 -0700 Subject: [PATCH 4/6] test: switch to node --test --- package.json | 2 +- test/index.js | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index d04a0eb..5721aec 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "lint:fix": "npx eslint@^8 *.js test --fix", "prettier": "npx prettier . --check", "prettier:fix": "npx prettier . --write --log-level=warn", - "test": "npx mocha@^10", + "test": "node --test", "versions": "npx @msimerson/dependency-version-checker check", "versions:fix": "npx @msimerson/dependency-version-checker update" }, diff --git a/test/index.js b/test/index.js index 14aae58..d955647 100644 --- a/test/index.js +++ b/test/index.js @@ -1,52 +1,44 @@ -// node.js built-in modules -const assert = require('assert') +const assert = require('node:assert/strict') +const { beforeEach, describe, it } = require('node:test') // npm modules const fixtures = require('haraka-test-fixtures') // start of tests // assert: https://nodejs.org/api/assert.html -// mocha: http://mochajs.org -beforeEach(function (done) { +beforeEach(function () { this.plugin = new fixtures.plugin('template') - done() // if a test hangs, assure you called done() }) describe('template', function () { - it('loads', function (done) { + it('loads', function () { assert.ok(this.plugin) - done() }) }) describe('load_template_ini', function () { - it('loads template.ini from config/template.ini', function (done) { + it('loads template.ini from config/template.ini', function () { this.plugin.load_template_ini() assert.ok(this.plugin.cfg) - done() }) - it('initializes enabled boolean', function (done) { + it('initializes enabled boolean', function () { this.plugin.load_template_ini() assert.equal(this.plugin.cfg.main.enabled, true, this.plugin.cfg) - done() }) }) describe('uses text fixtures', function () { - it('sets up a connection', function (done) { + it('sets up a connection', function () { this.connection = fixtures.connection.createConnection({}) assert.ok(this.connection.server) - done() }) - it('sets up a transaction', function (done) { + it('sets up a transaction', function () { this.connection = fixtures.connection.createConnection({}) this.connection.transaction = fixtures.transaction.createTransaction({}) - // console.log(this.connection.transaction) assert.ok(this.connection.transaction.header) - done() }) }) \ No newline at end of file From e51c565e5927097ea3f7652569003b3aa03c95c0 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Mon, 8 Apr 2024 15:23:50 -0700 Subject: [PATCH 5/6] doc: Changes.md -> CHANGELOG.md --- Changes.md => CHANGELOG.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Changes.md => CHANGELOG.md (100%) diff --git a/Changes.md b/CHANGELOG.md similarity index 100% rename from Changes.md rename to CHANGELOG.md From 900fab2f6806b4a76754cca5d12d2496471459a7 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Mon, 8 Apr 2024 15:29:13 -0700 Subject: [PATCH 6/6] prettier --- .codeclimate.yml | 4 +- .eslintrc.yaml | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 5 ++- .github/workflows/ci.yml | 6 +-- .github/workflows/codeql.yml | 6 +-- .github/workflows/publish.yml | 1 - CHANGELOG.md | 11 ++--- README.md | 3 +- index.js | 33 ++++++++------- test/index.js | 73 ++++++++++++++++---------------- 10 files changed, 70 insertions(+), 74 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index 0e443ca..96490fa 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -6,5 +6,5 @@ engines: config: ".eslintrc.yaml" ratings: - paths: - - "**.js" + paths: + - "**.js" diff --git a/.eslintrc.yaml b/.eslintrc.yaml index ddf5f86..693b320 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -4,4 +4,4 @@ env: mocha: true es2022: true -extends: ['@haraka'] \ No newline at end of file +extends: ["@haraka"] diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ba28fbb..5ccd7ed 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,11 +1,12 @@ Changes proposed in this pull request: -- -- +- +- Fixes # Checklist: + - [ ] docs updated - [ ] tests updated - [ ] Changes.md updated diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 325fb6d..3d01042 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: [ push, pull_request ] +on: [push, pull_request] env: CI: true @@ -14,9 +14,9 @@ jobs: # secrets: inherit ubuntu: - needs: [ lint ] + needs: [lint] uses: haraka/.github/.github/workflows/ubuntu.yml@master windows: - needs: [ lint ] + needs: [lint] uses: haraka/.github/.github/workflows/windows.yml@master diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 383aca2..2b614e3 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,11 +2,11 @@ name: "CodeQL" on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] schedule: - - cron: '18 7 * * 4' + - cron: "18 7 * * 4" jobs: codeql: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9bfdec3..e81c15f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,4 +14,3 @@ jobs: publish: uses: haraka/.github/.github/workflows/publish.yml@master secrets: inherit - diff --git a/CHANGELOG.md b/CHANGELOG.md index 273ec57..7c9ea33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,20 +2,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). - ### Unreleased ### [1.0.6] - 2024-04-08 - dep: eslint-plugin-haraka -> @haraka/eslint-config +- lint: remove duplicate / stale rules from .eslintrc - populate [files] in package.json. Delete .npmignore. +- doc: Changes.md -> CHANGELOG.md +- test: switch to node --test ### 1.0.5 - 2023-12-12 - ci: run tests on PR - ci(publish): add on.release trigger -- deps(dev*): pin versions - +- deps(dev\*): pin versions ### [1.0.3] - 2022-06-05 @@ -23,7 +24,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). - ci(publish): add secrets: inherit - ci: use reusable workflows (#18) - ### [1.0.2] - 2022-05-23 - ci: replace hard coded node vers with node-lts-versions @@ -31,19 +31,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). - ci: use reusable workflows (#18) - packaging updates - ### [1.0.1] - 2021-02-04 - test: added example tests that set up conn/txn - ci: add automated package publishing - ci(GHA): consolidate \*nix & win tests - ### 1.0.0 - 2017-02-02 - initial release - [1.0.1]: https://github.com/haraka/haraka-plugin-template/releases/tag/1.0.1 [1.0.2]: https://github.com/haraka/haraka-plugin-template/releases/tag/1.0.2 [1.0.3]: https://github.com/haraka/haraka-plugin-template/releases/tag/1.0.3 diff --git a/README.md b/README.md index 2e58ed7..9f4306f 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,6 @@ Replaces all uses of the word `template` with your plugin's name. You'll then be prompted to update package.json and then force push this repo onto the GitHub repo you've created earlier. - # Add your content here ## INSTALL @@ -67,8 +66,8 @@ $EDITOR config/template.ini ## USAGE - + [ci-img]: https://github.com/haraka/haraka-plugin-template/actions/workflows/ci.yml/badge.svg [ci-url]: https://github.com/haraka/haraka-plugin-template/actions/workflows/ci.yml [clim-img]: https://codeclimate.com/github/haraka/haraka-plugin-template/badges/gpa.svg diff --git a/index.js b/index.js index c9bd648..f09e7c0 100644 --- a/index.js +++ b/index.js @@ -1,23 +1,24 @@ -'use strict' +"use strict"; exports.register = function () { - this.load_template_ini() + this.load_template_ini(); // register hooks here. More info at https://haraka.github.io/core/Plugins/ // this.register_hook('data_post', 'do_stuff_with_message') -} +}; exports.load_template_ini = function () { - const plugin = this - - plugin.cfg = plugin.config.get('template.ini', { - booleans: [ - '+enabled', // plugin.cfg.main.enabled=true - '-disabled', // plugin.cfg.main.disabled=false - '+feature_section.yes' // plugin.cfg.feature_section.yes=true - ] - }, - function () { - plugin.load_example_ini() - }) -} + this.cfg = this.config.get( + "template.ini", + { + booleans: [ + "+enabled", // this.cfg.main.enabled=true + "-disabled", // this.cfg.main.disabled=false + "+feature_section.yes", // this.cfg.feature_section.yes=true + ], + }, + () => { + this.load_example_ini(); + }, + ); +}; diff --git a/test/index.js b/test/index.js index d955647..5f65df3 100644 --- a/test/index.js +++ b/test/index.js @@ -1,44 +1,43 @@ - -const assert = require('node:assert/strict') -const { beforeEach, describe, it } = require('node:test') +const assert = require("node:assert/strict"); +const { beforeEach, describe, it } = require("node:test"); // npm modules -const fixtures = require('haraka-test-fixtures') +const fixtures = require("haraka-test-fixtures"); // start of tests // assert: https://nodejs.org/api/assert.html beforeEach(function () { - this.plugin = new fixtures.plugin('template') -}) - -describe('template', function () { - it('loads', function () { - assert.ok(this.plugin) - }) -}) - -describe('load_template_ini', function () { - it('loads template.ini from config/template.ini', function () { - this.plugin.load_template_ini() - assert.ok(this.plugin.cfg) - }) - - it('initializes enabled boolean', function () { - this.plugin.load_template_ini() - assert.equal(this.plugin.cfg.main.enabled, true, this.plugin.cfg) - }) -}) - -describe('uses text fixtures', function () { - it('sets up a connection', function () { - this.connection = fixtures.connection.createConnection({}) - assert.ok(this.connection.server) - }) - - it('sets up a transaction', function () { - this.connection = fixtures.connection.createConnection({}) - this.connection.transaction = fixtures.transaction.createTransaction({}) - assert.ok(this.connection.transaction.header) - }) -}) \ No newline at end of file + this.plugin = new fixtures.plugin("template"); +}); + +describe("template", function () { + it("loads", function () { + assert.ok(this.plugin); + }); +}); + +describe("load_template_ini", function () { + it("loads template.ini from config/template.ini", function () { + this.plugin.load_template_ini(); + assert.ok(this.plugin.cfg); + }); + + it("initializes enabled boolean", function () { + this.plugin.load_template_ini(); + assert.equal(this.plugin.cfg.main.enabled, true, this.plugin.cfg); + }); +}); + +describe("uses text fixtures", function () { + it("sets up a connection", function () { + this.connection = fixtures.connection.createConnection({}); + assert.ok(this.connection.server); + }); + + it("sets up a transaction", function () { + this.connection = fixtures.connection.createConnection({}); + this.connection.transaction = fixtures.transaction.createTransaction({}); + assert.ok(this.connection.transaction.header); + }); +});