Skip to content

Commit

Permalink
Release v1.0.7 (#21)
Browse files Browse the repository at this point in the history
- update lint dep
- populate [files] in package.json.
- dep: eslint-plugin-haraka -> @haraka/eslint-config
- doc(CONTRIBUTORS): added
- prettier
  • Loading branch information
msimerson authored May 8, 2024
1 parent 6e05646 commit 4cd8191
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 168 deletions.
13 changes: 9 additions & 4 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
engines:
eslint:
enabled: true
channel: "eslint-8"
channel: 'eslint-8'
config:
config: ".eslintrc.yaml"
config: '.eslintrc.yaml'

ratings:
paths:
- "**.js"
paths:
- '**.js'

checks:
method-complexity:
config:
threshold: 10
8 changes: 2 additions & 6 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ env:
node: true
es6: true
mocha: true
es2020: true
es2022: true


plugins:
- haraka

extends: [ "eslint:recommended", "plugin:haraka/recommended" ]
extends: ['@haraka']
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'
allow:
- dependency-type: production
31 changes: 6 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: CI

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

env:
CI: true

jobs:

lint:
uses: haraka/.github/.github/workflows/lint.yml@master

Expand All @@ -15,27 +14,9 @@ jobs:
secrets: inherit

test:
needs: [ lint, get-lts ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
node-version: ${{ fromJson(needs.get-lts.outputs.active) }}
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
needs: [lint]
uses: haraka/.github/.github/workflows/ubuntu.yml@master

get-lts:
runs-on: ubuntu-latest
steps:
- id: get
uses: msimerson/node-lts-versions@v1
outputs:
active: ${{ steps.get.outputs.active }}
lts: ${{ steps.get.outputs.lts }}
windows:
needs: [lint]
uses: haraka/.github/.github/workflows/windows.yml@master
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: CodeQL

on:
push:
branches: [ master ]
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [master]
schedule:
- cron: '18 7 * * 4'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ env:
jobs:
publish:
uses: haraka/.github/.github/workflows/publish.yml@master
secrets: inherit
secrets: inherit
2 changes: 2 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
singleQuote: true
semi: false
2 changes: 1 addition & 1 deletion .release
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

The format is based on [Keep a Changelog](https://keepachangelog.com/).

### [1.0.7] 2024-05-08

- populate [files] in package.json.
- dep: eslint-plugin-haraka -> @haraka/eslint-config

[1.0.6]: https://github.com/haraka/haraka-constants/releases/tag/v1.0.6
[1.0.7]: https://github.com/haraka/haraka-constants/releases/tag/v1.0.7
8 changes: 8 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Contributors

This handcrafted artisinal software is brought to you by:

| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/haraka-constants/commits?author=msimerson">21</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/42121756?v=4"><br><a href="https://github.com/PSSGCSim">PSSGCSim</a> (<a href="https://github.com/haraka/haraka-constants/commits?author=PSSGCSim">1</a>) |
| :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ Haraka constants. Exports the following constants used throughout Haraka:
Populates an object with the constants.

```js
const constants = require('haraka-constants');
const myObj = {};
constants.import(myObj);
const constants = require('haraka-constants')
const myObj = {}
constants.import(myObj)

// myObj.cont === 900
```
Expand All @@ -38,11 +38,10 @@ constants.import(myObj);
Converts a numeric constant to its string representation.

```js
const constants = require('haraka-constants');
const constants = require('haraka-constants')
// 'CONT' === constants.translate(900);
```


[ci-img]: https://github.com/haraka/haraka-constants/actions/workflows/ci.yml/badge.svg
[ci-url]: https://github.com/haraka/haraka-constants/actions/workflows/ci.yml
[cov-img]: https://codecov.io/github/haraka/haraka-constants/coverage.svg
Expand All @@ -51,4 +50,3 @@ const constants = require('haraka-constants');
[clim-url]: https://codeclimate.com/github/haraka/haraka-constants
[npm-img]: https://nodei.co/npm/haraka-constants.png
[npm-url]: https://www.npmjs.com/package/haraka-constants

98 changes: 49 additions & 49 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
'use strict';
'use strict'

// node.js class
const node_const = require('constants');

const translationTable = {};

exports.cont = 900;
exports.stop = 901;
exports.deny = 902;
exports.denysoft = 903;
exports.denydisconnect = 904;
exports.disconnect = 905;
exports.ok = 906;
exports.next_hook = 907;
exports.delay = 908;
exports.denysoftdisconnect = 909;
exports.write_excl = node_const.O_CREAT | node_const.O_TRUNC | node_const.O_WRONLY | node_const.O_EXCL;
const node_const = require('node:constants')

const translationTable = {}

exports.cont = 900
exports.stop = 901
exports.deny = 902
exports.denysoft = 903
exports.denydisconnect = 904
exports.disconnect = 905
exports.ok = 906
exports.next_hook = 907
exports.delay = 908
exports.denysoftdisconnect = 909
exports.write_excl =
node_const.O_CREAT |
node_const.O_TRUNC |
node_const.O_WRONLY |
node_const.O_EXCL

exports.import = function (object) {
for (const k in exports) {
if (k === 'import') continue;
if (k === 'translate') continue;
if (k === 'connection') continue;
if (Object.prototype.hasOwnProperty.call(exports, k)) {
object[k.toUpperCase()] = exports[k];
}
for (const k in exports) {
if (['import', 'translate', 'connection'].includes(k)) continue
if (Object.prototype.hasOwnProperty.call(exports, k)) {
object[k.toUpperCase()] = exports[k]
}
};
}
}

exports.translate = function (value) {

// cache the translationTable object
if (Object.keys(translationTable).length === 0) {
for (const k in exports) {
if (typeof exports[k] === 'number') {
translationTable[exports[k]] = k.toUpperCase();
}
}
// cache the translationTable object
if (Object.keys(translationTable).length === 0) {
for (const k in exports) {
if (typeof exports[k] === 'number') {
translationTable[exports[k]] = k.toUpperCase()
}
}
}

if (translationTable[value]) return translationTable[value];
return 'UNKNOWN';
};
return translationTable[value] || 'UNKNOWN'
}

exports.import(exports);
exports.import(exports)

exports.connection = {
state: {
CMD: 1,
LOOP: 2,
DATA: 3,
PAUSE: 4,
PAUSE_SMTP: 5,
PAUSE_DATA: 6,
DISCONNECTING: 99,
DISCONNECTED: 100,
}
state: {
CMD: 1,
LOOP: 2,
DATA: 3,
PAUSE: 4,
PAUSE_SMTP: 5,
PAUSE_DATA: 6,
DISCONNECTING: 99,
DISCONNECTED: 100,
},
}

Object.keys(exports.connection.state).forEach((state) => {
exports.connection.state[`STATE_${state}`] = exports.connection.state[state];
})
for (const state of Object.keys(exports.connection.state)) {
exports.connection.state[`STATE_${state}`] = exports.connection.state[state]
}
20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,36 @@
"name": "haraka-constants",
"license": "MIT",
"description": "Haraka constants",
"version": "1.0.6",
"version": "1.0.7",
"homepage": "http://haraka.github.io",
"repository": {
"type": "git",
"url": "[email protected]:haraka/haraka-constants.git"
},
"main": "index.js",
"files": [
"CHANGELOG.md"
],
"engines": {
"node": ">= 6"
},
"dependencies": {},
"optionalDependencies": {},
"devDependencies": {
"eslint": ">=8",
"eslint-plugin-haraka": ">=1.0.10",
"mocha": "*"
"@haraka/eslint-config": "^1.1.5"
},
"bugs": {
"mail": "[email protected]",
"url": "https://github.com/haraka/haraka-constants/issues"
},
"scripts": {
"lint": "npx eslint *.js test",
"lintfix": "npx eslint --fix *.js test",
"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 dependency-version-checker check",
"versions:fix": "npx dependency-version-checker update && npm run prettier:fix"
}
}
Loading

0 comments on commit 4cd8191

Please sign in to comment.