mirror of
https://github.com/Mintplex-Labs/bree.git
synced 2026-07-01 20:04:39 -04:00
chore: updated conf and linting, fixed tests, bump deps
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
module.exports = {
|
||||
"extends": [
|
||||
"@commitlint/config-conventional"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ jobs:
|
||||
- 12
|
||||
- 14
|
||||
- 16
|
||||
- 18
|
||||
|
||||
name: Node ${{ matrix.node_version }} on ${{ matrix.os }}
|
||||
|
||||
@@ -26,15 +27,5 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node_version }}
|
||||
|
||||
- name: Install yarn
|
||||
run: npm install -g yarn
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn --frozen-lockfile
|
||||
|
||||
- name: Run tests
|
||||
run: yarn test-coverage
|
||||
|
||||
- name: Uninstall yarn
|
||||
if: always()
|
||||
run: npm uninstall -g yarn
|
||||
run: npm run test-coverage
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn commitlint --edit $1
|
||||
npx --no-install commitlint --edit $1
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn lint-staged
|
||||
npx --no-install lint-staged && npm test
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"extension": [
|
||||
".js"
|
||||
],
|
||||
"report-dir": "./coverage",
|
||||
"temp-dir": "./.nyc_output",
|
||||
"reporter": ["lcov", "html", "text"],
|
||||
"check-coverage": true,
|
||||
"lines": 100,
|
||||
"functions": 100,
|
||||
"branches": 100
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
module.exports = {
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": true,
|
||||
"trailingComma": "none"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
plugins: ['preset-github']
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
module.exports = {
|
||||
prettier: true,
|
||||
space: true,
|
||||
extends: ['xo-lass'],
|
||||
ignore: ['config.js'],
|
||||
rules: {
|
||||
'capitalized-comments': 'off',
|
||||
'unicorn/catch-error-name': 'off',
|
||||
'unicorn/require-post-message-target-origin': 'off',
|
||||
'node/no-unsupported-features/node-builtins': [
|
||||
'error',
|
||||
{
|
||||
ignores: ['events.once']
|
||||
}
|
||||
]
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: 'test/jobs/*.js',
|
||||
rules: {
|
||||
'unicorn/no-process-exit': 'off'
|
||||
}
|
||||
},
|
||||
{
|
||||
files: [ '*.ts', '**/*.ts' ],
|
||||
parserOptions: {
|
||||
project: 'types/tsconfig.json'
|
||||
},
|
||||
rules: {
|
||||
'no-redeclare': 'warn',
|
||||
'no-unused-vars': 'warn',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
||||
'@typescript-eslint/no-unsafe-call': 'warn',
|
||||
'@typescript-eslint/no-unused-vars': 'warn',
|
||||
'@typescript-eslint/no-empty-function': 'warn'
|
||||
}
|
||||
}
|
||||
],
|
||||
parser: '@typescript-eslint/parser'
|
||||
};
|
||||
@@ -3,7 +3,6 @@
|
||||
</h1>
|
||||
<div align="center">
|
||||
<a href="https://github.com/breejs/bree/actions/workflows/ci.yml"><img src="https://github.com/breejs/later/actions/workflows/ci.yml/badge.svg" alt="build status" /></a>
|
||||
<a href="https://codecov.io/github/breejs/bree"><img src="https://img.shields.io/codecov/c/github/breejs/bree/master.svg" alt="code coverage" /></a>
|
||||
<a href="https://github.com/sindresorhus/xo"><img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg" alt="code style" /></a>
|
||||
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" alt="styled with prettier" /></a>
|
||||
<a href="https://lass.js.org"><img src="https://img.shields.io/badge/made_with-lass-95CC28.svg" alt="made with lass" /></a>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
files: ['test/*.js', 'test/**/*.js', '!test/jobs', '!test/noIndexJobs'],
|
||||
verbose: true,
|
||||
require: ['events.once/polyfill']
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
extension: ['.js'],
|
||||
'report-dir': './coverage',
|
||||
'temp-dir': './.nyc_output',
|
||||
reporter: ['lcov', 'html', 'text'],
|
||||
'check-coverage': true,
|
||||
lines: 100,
|
||||
functions: 100,
|
||||
branches: 100
|
||||
};
|
||||
+24
-91
@@ -3,18 +3,6 @@
|
||||
"description": "The best job scheduler for Node.js and JavaScript with cron, dates, ms, later, and human-friendly support. Works in Node v12.11.0+, uses worker threads to spawn sandboxed processes, and supports async/await, retries, throttling, concurrency, and cancelable promises (graceful shutdown). Simple, fast, and lightweight. Made for Forward Email and Lad.",
|
||||
"version": "8.0.3",
|
||||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)",
|
||||
"ava": {
|
||||
"files": [
|
||||
"test/*.js",
|
||||
"test/**/*.js",
|
||||
"!test/jobs",
|
||||
"!test/noIndexJobs"
|
||||
],
|
||||
"verbose": true,
|
||||
"require": [
|
||||
"events.once/polyfill"
|
||||
]
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/breejs/bree/issues",
|
||||
"email": "niftylettuce@gmail.com"
|
||||
@@ -25,10 +13,10 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@breejs/later": "^4.1.0",
|
||||
"boolean": "^3.1.4",
|
||||
"boolean": "^3.2.0",
|
||||
"combine-errors": "^3.0.3",
|
||||
"cron-validate": "^1.4.3",
|
||||
"debug": "^4.3.3",
|
||||
"debug": "^4.3.4",
|
||||
"human-interval": "^2.0.1",
|
||||
"is-string-and-not-blank": "^0.0.2",
|
||||
"is-valid-path": "^0.1.1",
|
||||
@@ -37,31 +25,32 @@
|
||||
"safe-timers": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "latest",
|
||||
"@commitlint/config-conventional": "latest",
|
||||
"@commitlint/cli": "^17.0.2",
|
||||
"@commitlint/config-conventional": "^17.0.2",
|
||||
"@goto-bus-stop/envify": "^5.0.0",
|
||||
"@sinonjs/fake-timers": "^8.1.0",
|
||||
"@types/node": "^14.0.0",
|
||||
"@sinonjs/fake-timers": "^9.1.2",
|
||||
"@types/node": "^17.0.40",
|
||||
"@types/safe-timers": "^1.1.0",
|
||||
"ava": "latest",
|
||||
"codecov": "latest",
|
||||
"cross-env": "latest",
|
||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||
"@typescript-eslint/parser": "^5.27.0",
|
||||
"ava": "^4.3.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"delay": "^5.0.0",
|
||||
"dtslint": "^4.2.1",
|
||||
"eslint": "^8.5.0",
|
||||
"eslint-config-xo-lass": "latest",
|
||||
"eslint-plugin-compat": "^4.0.0",
|
||||
"eslint": "^8.17.0",
|
||||
"eslint-config-xo-lass": "^2.0.1",
|
||||
"eslint-plugin-compat": "^4.0.2",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"events.once": "^2.0.2",
|
||||
"fixpack": "latest",
|
||||
"husky": "^7.0.4",
|
||||
"husky": "^8.0.1",
|
||||
"into-stream": "^7.0.0",
|
||||
"lint-staged": "latest",
|
||||
"nyc": "latest",
|
||||
"remark-cli": "latest",
|
||||
"remark-preset-github": "latest",
|
||||
"lint-staged": "^13.0.0",
|
||||
"nyc": "^15.1.0",
|
||||
"remark-cli": "^10.0.1",
|
||||
"remark-preset-github": "^4.0.4",
|
||||
"unassertify": "^2.1.1",
|
||||
"xo": "^0.47.0"
|
||||
"xo": "^0.49.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12.11.0"
|
||||
@@ -163,71 +152,15 @@
|
||||
},
|
||||
"scripts": {
|
||||
"ava": "cross-env NODE_ENV=test ava",
|
||||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
||||
"dtslint": "cross-env NODE_ENV=test dtslint types",
|
||||
"lint": "yarn run lint:js && yarn run lint:md",
|
||||
"lint": "npm run lint:js && npm run lint:md",
|
||||
"lint:js": "xo --ignore examples/",
|
||||
"lint:md": "remark . -qfo",
|
||||
"nyc": "cross-env NODE_ENV=test nyc ava",
|
||||
"prepare": "husky install",
|
||||
"pretest": "yarn run lint",
|
||||
"test": "yarn run ava && yarn run dtslint",
|
||||
"test-coverage": "cross-env NODE_ENV=test nyc yarn run test"
|
||||
"pretest": "npm run lint",
|
||||
"test": "npm run ava && npm run dtslint",
|
||||
"test-coverage": "cross-env NODE_ENV=test nyc npm run test"
|
||||
},
|
||||
"types": "types",
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"space": true,
|
||||
"extends": [
|
||||
"xo-lass"
|
||||
],
|
||||
"ignore": [
|
||||
"config.js"
|
||||
],
|
||||
"rules": {
|
||||
"capitalized-comments": "off",
|
||||
"unicorn/catch-error-name": "off",
|
||||
"unicorn/require-post-message-target-origin": "off",
|
||||
"node/no-unsupported-features/node-builtins": [
|
||||
"error",
|
||||
{
|
||||
"ignores": [
|
||||
"events.once"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"test/jobs/*.js"
|
||||
],
|
||||
"rules": {
|
||||
"unicorn/no-process-exit": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.ts"
|
||||
],
|
||||
"parserOptions": {
|
||||
"project": [
|
||||
"types/tsconfig.json"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"types/tests.ts"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||
"@typescript-eslint/no-unsafe-call": "off"
|
||||
}
|
||||
}
|
||||
],
|
||||
"parser": "@typescript-eslint/parser"
|
||||
}
|
||||
"types": "types"
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ test('returns meta if output set to true', (t) => {
|
||||
|
||||
test('returns meta and worker data if running', async (t) => {
|
||||
const logger = {
|
||||
info: () => {}
|
||||
info() {}
|
||||
};
|
||||
|
||||
const bree = new Bree({
|
||||
@@ -86,14 +86,14 @@ test('job with worker data sent by job', async (t) => {
|
||||
t.plan(1);
|
||||
|
||||
const logger = {
|
||||
info: (...args) => {
|
||||
info(...args) {
|
||||
if (!args[1] || !args[1].message) {
|
||||
return;
|
||||
}
|
||||
|
||||
t.is(args[1].message.test, 'test');
|
||||
},
|
||||
error: () => {}
|
||||
error() {}
|
||||
};
|
||||
|
||||
const bree = new Bree({
|
||||
|
||||
+9
-9
@@ -22,7 +22,7 @@ test('successfully run job', async (t) => {
|
||||
t.plan(2);
|
||||
|
||||
const logger = {
|
||||
info: () => {}
|
||||
info() {}
|
||||
};
|
||||
|
||||
const bree = new Bree({
|
||||
@@ -77,8 +77,8 @@ test('throws if jobs is not an array and logs MODULE_NOT_FOUND error by default'
|
||||
t.plan(2);
|
||||
|
||||
const logger = {
|
||||
info: () => {},
|
||||
error: (err) => {
|
||||
info() {},
|
||||
error(err) {
|
||||
t.is(err.code, 'MODULE_NOT_FOUND');
|
||||
}
|
||||
};
|
||||
@@ -101,8 +101,8 @@ test('logs MODULE_NOT_FOUND error if array is empty', (t) => {
|
||||
t.plan(2);
|
||||
|
||||
const logger = {
|
||||
info: () => {},
|
||||
error: (err) => {
|
||||
info() {},
|
||||
error(err) {
|
||||
t.is(err.code, 'MODULE_NOT_FOUND');
|
||||
}
|
||||
};
|
||||
@@ -119,8 +119,8 @@ test('logs MODULE_NOT_FOUND error if array is empty', (t) => {
|
||||
|
||||
test('does not log MODULE_NOT_FOUND error if silenceRootCheckError is false', (t) => {
|
||||
const logger = {
|
||||
info: () => {},
|
||||
error: () => {
|
||||
info() {},
|
||||
error() {
|
||||
t.fail();
|
||||
}
|
||||
};
|
||||
@@ -138,8 +138,8 @@ test('does not log MODULE_NOT_FOUND error if silenceRootCheckError is false', (t
|
||||
|
||||
test('does not log MODULE_NOT_FOUND error if doRootCheck is false', (t) => {
|
||||
const logger = {
|
||||
info: () => {},
|
||||
error: () => {
|
||||
info() {},
|
||||
error() {
|
||||
t.fail();
|
||||
}
|
||||
};
|
||||
|
||||
+14
-12
@@ -118,6 +118,7 @@ test('job terminates on message "done"', async (t) => {
|
||||
t.is(message, 'get ready');
|
||||
|
||||
await once(bree, 'worker deleted');
|
||||
await delay(1);
|
||||
t.false(bree.workers.has('done'));
|
||||
});
|
||||
|
||||
@@ -141,6 +142,7 @@ test('job terminates on message "done" should clear closeWorkerAfterMs', async (
|
||||
t.true(bree.closeWorkerAfterMs.has('done'));
|
||||
|
||||
await once(bree, 'worker deleted');
|
||||
await delay(1);
|
||||
t.false(bree.workers.has('done'));
|
||||
t.false(bree.closeWorkerAfterMs.has('done'));
|
||||
});
|
||||
@@ -168,12 +170,12 @@ test('job sent a message', async (t) => {
|
||||
|
||||
test('job sent an error', async (t) => {
|
||||
const logger = {
|
||||
error: (message) => {
|
||||
error(message) {
|
||||
if (message === 'Worker for job "message" had an error') {
|
||||
t.pass();
|
||||
}
|
||||
},
|
||||
info: () => {}
|
||||
info() {}
|
||||
};
|
||||
|
||||
const bree = new Bree({
|
||||
@@ -193,15 +195,15 @@ test('job sent an error', async (t) => {
|
||||
test('job sent an error with custom handler', async (t) => {
|
||||
t.plan(5);
|
||||
const logger = {
|
||||
error: () => {},
|
||||
info: () => {}
|
||||
error() {},
|
||||
info() {}
|
||||
};
|
||||
|
||||
const bree = new Bree({
|
||||
root,
|
||||
jobs: [{ name: 'message' }],
|
||||
logger,
|
||||
errorHandler: (err, workerMeta) => {
|
||||
errorHandler(err, workerMeta) {
|
||||
t.true(workerMeta.name === 'message');
|
||||
|
||||
if (workerMeta.err) {
|
||||
@@ -225,15 +227,15 @@ test('job sent a message with custom worker message handler', async (t) => {
|
||||
t.plan(3);
|
||||
|
||||
const logger = {
|
||||
error: () => {},
|
||||
info: () => {}
|
||||
error() {},
|
||||
info() {}
|
||||
};
|
||||
|
||||
const bree = new Bree({
|
||||
root,
|
||||
jobs: [{ name: 'message' }],
|
||||
logger,
|
||||
workerMessageHandler: (metadata) => {
|
||||
workerMessageHandler(metadata) {
|
||||
t.is(Object.keys(metadata).length, 2);
|
||||
t.is(metadata.message, 'hey Bob!');
|
||||
t.is(metadata.name, 'message');
|
||||
@@ -251,8 +253,8 @@ test('job sent a message with custom worker message handler and metadata', async
|
||||
t.plan(4);
|
||||
|
||||
const logger = {
|
||||
error: () => {},
|
||||
info: () => {}
|
||||
error() {},
|
||||
info() {}
|
||||
};
|
||||
|
||||
const bree = new Bree({
|
||||
@@ -260,7 +262,7 @@ test('job sent a message with custom worker message handler and metadata', async
|
||||
jobs: [{ name: 'message' }],
|
||||
logger,
|
||||
outputWorkerMetadata: true,
|
||||
workerMessageHandler: (metadata) => {
|
||||
workerMessageHandler(metadata) {
|
||||
t.is(Object.keys(metadata).length, 3);
|
||||
t.is(metadata.message, 'hi Alice!');
|
||||
t.is(metadata.name, 'message');
|
||||
@@ -321,7 +323,7 @@ test('job runs with no worker options in config', async (t) => {
|
||||
test('job runs and passes workerData from config', async (t) => {
|
||||
t.plan(4);
|
||||
const logger = {
|
||||
info: (...args) => {
|
||||
info(...args) {
|
||||
if (!args[1] || !args[1].message) {
|
||||
return;
|
||||
}
|
||||
|
||||
+11
-6
@@ -48,7 +48,7 @@ test('fails if date is in the past', async (t) => {
|
||||
t.plan(3);
|
||||
|
||||
const logger = {
|
||||
warn: (msg) => {
|
||||
warn(msg) {
|
||||
t.is(msg, `Job "basic" was skipped because it was in the past.`);
|
||||
}
|
||||
};
|
||||
@@ -104,7 +104,7 @@ test('sets interval if date is in the future and interval is schedule', async (t
|
||||
jobs: [
|
||||
{
|
||||
name: 'short',
|
||||
date: new Date(Date.now() + 10),
|
||||
date: new Date(Date.now() + 1000),
|
||||
interval: later.parse.text('every 1 second')
|
||||
}
|
||||
]
|
||||
@@ -122,6 +122,7 @@ test('sets interval if date is in the future and interval is schedule', async (t
|
||||
t.is(code, 2);
|
||||
|
||||
await once(bree, 'worker created');
|
||||
await delay(1);
|
||||
t.pass();
|
||||
|
||||
await bree.stop();
|
||||
@@ -153,6 +154,7 @@ test('sets interval if date is in the future and interval is number', async (t)
|
||||
t.is(code, 2);
|
||||
|
||||
await once(bree, 'worker created');
|
||||
await delay(1);
|
||||
t.pass();
|
||||
|
||||
await bree.stop();
|
||||
@@ -187,6 +189,7 @@ test('sets timeout if interval is schedule and timeout is schedule', async (t) =
|
||||
t.is(code, 2);
|
||||
|
||||
await once(bree, 'worker created');
|
||||
await delay(1);
|
||||
t.pass();
|
||||
|
||||
await bree.stop();
|
||||
@@ -213,7 +216,7 @@ test('sets timeout if interval is number and timeout is schedule', async (t) =>
|
||||
t.true(bree.timeouts.has('short'));
|
||||
|
||||
await once(bree, 'worker created');
|
||||
await delay('1');
|
||||
await delay(1);
|
||||
t.true(bree.intervals.has('short'));
|
||||
t.false(bree.timeouts.has('short'));
|
||||
|
||||
@@ -221,6 +224,7 @@ test('sets timeout if interval is number and timeout is schedule', async (t) =>
|
||||
t.is(code, 2);
|
||||
|
||||
await once(bree, 'worker created');
|
||||
await delay(1);
|
||||
t.pass();
|
||||
|
||||
await bree.stop();
|
||||
@@ -247,7 +251,6 @@ test('sets timeout if interval is 0 and timeout is schedule', async (t) => {
|
||||
t.true(bree.timeouts.has('short'));
|
||||
|
||||
await once(bree, 'worker created');
|
||||
|
||||
await delay(1);
|
||||
|
||||
t.false(bree.timeouts.has('short'));
|
||||
@@ -341,6 +344,7 @@ test('sets interval if interval is schedule', async (t) => {
|
||||
bree.start('infinite');
|
||||
|
||||
await once(bree, 'worker created');
|
||||
await delay(1);
|
||||
t.true(bree.intervals.has('infinite'));
|
||||
|
||||
const [code] = await once(bree.workers.get('infinite'), 'exit');
|
||||
@@ -363,6 +367,7 @@ test('sets interval if interval is number', async (t) => {
|
||||
|
||||
bree.start('infinite');
|
||||
await once(bree, 'worker created');
|
||||
await delay(1);
|
||||
t.true(bree.intervals.has('infinite'));
|
||||
|
||||
const [code] = await once(bree.workers.get('infinite'), 'exit');
|
||||
@@ -403,7 +408,7 @@ test.serial('uses job.timezone to schedule a job', (t) => {
|
||||
const bree = new Bree({
|
||||
root,
|
||||
jobs: [
|
||||
// todo: job.date
|
||||
// TODO: job.date
|
||||
{
|
||||
name: 'tz_cron',
|
||||
path: noop,
|
||||
@@ -449,7 +454,7 @@ test.serial('uses default timezone to schedule a job', (t) => {
|
||||
timezone: 'America/Mexico_City',
|
||||
root,
|
||||
jobs: [
|
||||
// todo: job.date
|
||||
// TODO: job.date
|
||||
{
|
||||
name: 'tz_cron',
|
||||
path: noop,
|
||||
|
||||
+2
-2
@@ -70,12 +70,12 @@ test('job stops when process.exit(0) is called', async (t) => {
|
||||
|
||||
test('does not send graceful notice if no cancelled message', async (t) => {
|
||||
const logger = {
|
||||
info: (message) => {
|
||||
info(message) {
|
||||
if (message === 'Gracefully cancelled worker for job "message"') {
|
||||
t.fail();
|
||||
}
|
||||
},
|
||||
error: () => {}
|
||||
error() {}
|
||||
};
|
||||
|
||||
const bree = new Bree({
|
||||
|
||||
Reference in New Issue
Block a user