Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Apr 8, 2024
1 parent e51c565 commit 900fab2
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 74 deletions.
4 changes: 2 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ engines:
config: ".eslintrc.yaml"

ratings:
paths:
- "**.js"
paths:
- "**.js"
2 changes: 1 addition & 1 deletion .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ env:
mocha: true
es2022: true

extends: ['@haraka']
extends: ["@haraka"]
5 changes: 3 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
Changes proposed in this pull request:

-
-
-
-

Fixes #

Checklist:

- [ ] docs updated
- [ ] tests updated
- [ ] Changes.md updated
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [ push, pull_request ]
on: [push, pull_request]

env:
CI: true
Expand All @@ -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
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ jobs:
publish:
uses: haraka/.github/.github/workflows/publish.yml@master
secrets: inherit

11 changes: 4 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,45 @@

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

- ci: replace hard coded vers with node-lts-versions
- 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
- ci(publish): add secrets: inherit
- 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
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -67,8 +66,8 @@ $EDITOR config/template.ini

## USAGE


<!-- leave these buried at the bottom of the document -->

[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
Expand Down
33 changes: 17 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -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();
},
);
};
73 changes: 36 additions & 37 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -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)
})
})
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);
});
});

0 comments on commit 900fab2

Please sign in to comment.