mirror of
https://github.com/Mintplex-Labs/bree.git
synced 2026-07-01 20:04:39 -04:00
fix: version bump, attempt to fix ts issues, drop node v12 from tests
This commit is contained in:
@@ -12,7 +12,6 @@ jobs:
|
||||
# TODO: re-enable windows
|
||||
#- windows-latest
|
||||
node_version:
|
||||
- 12
|
||||
- 14
|
||||
- 16
|
||||
- 18
|
||||
|
||||
+2
-1
@@ -8,7 +8,8 @@ module.exports = {
|
||||
'unicorn/catch-error-name': 'off',
|
||||
'unicorn/require-post-message-target-origin': 'off',
|
||||
'unicorn/prefer-node-protocol': 'warn',
|
||||
'unicorn/prefer-top-level-await': 'warn'
|
||||
'unicorn/prefer-top-level-await': 'warn',
|
||||
'unicorn/prefer-event-target': 'off'
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
||||
@@ -5,5 +5,4 @@ console.log('Hello Commonjs!');
|
||||
|
||||
// signal to parent that the job is done
|
||||
if (parentPort) parentPort.postMessage('done');
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
else process.exit(0);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const os = require('os');
|
||||
const process = require('process');
|
||||
const { parentPort } = require('worker_threads');
|
||||
|
||||
const os = require('node:os');
|
||||
const process = require('node:process');
|
||||
const { parentPort } = require('node:worker_threads');
|
||||
const Cabin = require('cabin');
|
||||
const Email = require('email-templates');
|
||||
const pMap = require('p-map');
|
||||
|
||||
@@ -5,5 +5,4 @@ console.log('Hello ESM!');
|
||||
|
||||
// signal to parent that the job is done
|
||||
if (parentPort) parentPort.postMessage('done');
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
else process.exit(0);
|
||||
|
||||
@@ -5,5 +5,4 @@ console.log('Hello TypeScript with ESM!');
|
||||
|
||||
// signal to parent that the job is done
|
||||
if (parentPort) parentPort.postMessage('done');
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
else process.exit(0);
|
||||
|
||||
@@ -5,5 +5,4 @@ console.log('Hello TypeScript Defaults!');
|
||||
|
||||
// signal to parent that the job is done
|
||||
if (parentPort) parentPort.postMessage('done');
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
else process.exit(0);
|
||||
|
||||
@@ -5,5 +5,4 @@ console.log('Hello TypeScript!');
|
||||
|
||||
// signal to parent that the job is done
|
||||
if (parentPort) parentPort.postMessage('done');
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
else process.exit(0);
|
||||
|
||||
@@ -5,5 +5,4 @@ console.log('Hello TypeScript!');
|
||||
|
||||
// signal to parent that the job is done
|
||||
if (parentPort) parentPort.postMessage('done');
|
||||
// eslint-disable-next-line unicorn/no-process-exit
|
||||
else process.exit(0);
|
||||
|
||||
+9
-9
@@ -27,26 +27,26 @@
|
||||
"@commitlint/cli": "^18.4.3",
|
||||
"@commitlint/config-conventional": "^18.4.3",
|
||||
"@goto-bus-stop/envify": "^5.0.0",
|
||||
"@sinonjs/fake-timers": "^9.1.2",
|
||||
"@types/node": "^17.0.41",
|
||||
"@types/safe-timers": "^1.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.27.1",
|
||||
"@typescript-eslint/parser": "^5.27.1",
|
||||
"ava": "^4.3.0",
|
||||
"@sinonjs/fake-timers": "^11.2.2",
|
||||
"@types/node": "^20.9.3",
|
||||
"@types/safe-timers": "^1.1.2",
|
||||
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
||||
"@typescript-eslint/parser": "^6.12.0",
|
||||
"ava": "^5.3.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"delay": "^5.0.0",
|
||||
"delay": "5",
|
||||
"dtslint": "^4.2.1",
|
||||
"eslint": "8.39.0",
|
||||
"eslint-config-xo-lass": "^2.0.1",
|
||||
"events.once": "^2.0.2",
|
||||
"fixpack": "^4.0.0",
|
||||
"husky": "^8.0.3",
|
||||
"into-stream": "^7.0.0",
|
||||
"into-stream": "7",
|
||||
"lint-staged": "^15.1.0",
|
||||
"nyc": "^15.1.0",
|
||||
"remark-cli": "11",
|
||||
"remark-preset-github": "^4.0.4",
|
||||
"xo": "0.52"
|
||||
"xo": "0.56"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.17.0 <13.0.0-0||>=13.2.0"
|
||||
|
||||
+3
-6
@@ -8,14 +8,12 @@ const { pathToFileURL } = require('node:url');
|
||||
const { Worker } = require('node:worker_threads');
|
||||
const { join, resolve } = require('node:path');
|
||||
const { debuglog } = require('node:util');
|
||||
|
||||
const combineErrors = require('combine-errors');
|
||||
const isSANB = require('is-string-and-not-blank');
|
||||
const isValidPath = require('is-valid-path');
|
||||
const later = require('@breejs/later');
|
||||
const pWaitFor = require('p-wait-for');
|
||||
const { setTimeout, setInterval } = require('safe-timers');
|
||||
|
||||
const {
|
||||
isSchedule,
|
||||
getName,
|
||||
@@ -328,8 +326,7 @@ class Bree extends EventEmitter {
|
||||
}
|
||||
|
||||
if (!this.config.outputWorkerMetadata && !job.outputWorkerMetadata) {
|
||||
return meta &&
|
||||
(typeof meta.err !== 'undefined' || typeof meta.message !== 'undefined')
|
||||
return meta && (meta.err !== undefined || meta.message !== undefined)
|
||||
? meta
|
||||
: undefined;
|
||||
}
|
||||
@@ -371,8 +368,8 @@ class Bree extends EventEmitter {
|
||||
|
||||
debug('starting worker', name);
|
||||
const object = {
|
||||
...(this.config.worker ? this.config.worker : {}),
|
||||
...(job.worker ? job.worker : {}),
|
||||
...this.config.worker,
|
||||
...job.worker,
|
||||
workerData: {
|
||||
job: {
|
||||
...job,
|
||||
|
||||
+11
-13
@@ -77,16 +77,16 @@ const buildJob = (job, config) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof job.timeout !== 'undefined') {
|
||||
if (job.timeout !== undefined) {
|
||||
job.timeout = parseValue(job.timeout);
|
||||
}
|
||||
|
||||
if (typeof job.interval !== 'undefined') {
|
||||
if (job.interval !== undefined) {
|
||||
job.interval = parseValue(job.interval);
|
||||
}
|
||||
|
||||
// Build cron
|
||||
if (typeof job.cron !== 'undefined') {
|
||||
if (job.cron !== undefined) {
|
||||
if (isSchedule(job.cron)) {
|
||||
job.interval = job.cron;
|
||||
// Delete job.cron;
|
||||
@@ -94,9 +94,7 @@ const buildJob = (job, config) => {
|
||||
job.interval = later.parse.cron(
|
||||
job.cron,
|
||||
boolean(
|
||||
typeof job.hasSeconds === 'undefined'
|
||||
? config.hasSeconds
|
||||
: job.hasSeconds
|
||||
job.hasSeconds === undefined ? config.hasSeconds : job.hasSeconds
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -108,10 +106,10 @@ const buildJob = (job, config) => {
|
||||
if (
|
||||
Number.isFinite(config.timeout) &&
|
||||
config.timeout >= 0 &&
|
||||
typeof job.timeout === 'undefined' &&
|
||||
typeof job.cron === 'undefined' &&
|
||||
typeof job.date === 'undefined' &&
|
||||
typeof job.interval === 'undefined'
|
||||
job.timeout === undefined &&
|
||||
job.cron === undefined &&
|
||||
job.date === undefined &&
|
||||
job.interval === undefined
|
||||
) {
|
||||
job.timeout = config.timeout;
|
||||
}
|
||||
@@ -122,9 +120,9 @@ const buildJob = (job, config) => {
|
||||
if (
|
||||
((Number.isFinite(config.interval) && config.interval > 0) ||
|
||||
isSchedule(config.interval)) &&
|
||||
typeof job.interval === 'undefined' &&
|
||||
typeof job.cron === 'undefined' &&
|
||||
typeof job.date === 'undefined'
|
||||
job.interval === undefined &&
|
||||
job.cron === undefined &&
|
||||
job.date === undefined
|
||||
) {
|
||||
job.interval = config.interval;
|
||||
}
|
||||
|
||||
+10
-17
@@ -4,7 +4,6 @@ const combineErrors = require('combine-errors');
|
||||
const cron = require('cron-validate');
|
||||
const isSANB = require('is-string-and-not-blank');
|
||||
const isValidPath = require('is-valid-path');
|
||||
|
||||
const { getName, isSchedule, parseValue, getJobPath } = require('./job-utils');
|
||||
|
||||
const validateReservedJobName = (name) => {
|
||||
@@ -111,8 +110,8 @@ const cronValidateWithSeconds = (job, config) => {
|
||||
job.cronValidate && job.cronValidate.preset
|
||||
? job.cronValidate.preset
|
||||
: config.cronValidate && config.cronValidate.preset
|
||||
? config.cronValidate.preset
|
||||
: 'default';
|
||||
? config.cronValidate.preset
|
||||
: 'default';
|
||||
const override = {
|
||||
...(config.cronValidate && config.cronValidate.override
|
||||
? config.cronValidate.override
|
||||
@@ -223,14 +222,14 @@ const validate = async (job, i, names, config) => {
|
||||
errors.push(...(await validateJobPath(job, prefix, config)));
|
||||
|
||||
// Don't allow users to mix interval AND cron
|
||||
if (typeof job.interval !== 'undefined' && typeof job.cron !== 'undefined') {
|
||||
if (job.interval !== undefined && job.cron !== undefined) {
|
||||
errors.push(
|
||||
new Error(`${prefix} cannot have both interval and cron configuration`)
|
||||
);
|
||||
}
|
||||
|
||||
// Don't allow users to mix timeout AND date
|
||||
if (typeof job.timeout !== 'undefined' && typeof job.date !== 'undefined') {
|
||||
if (job.timeout !== undefined && job.date !== undefined) {
|
||||
errors.push(new Error(`${prefix} cannot have both timeout and date`));
|
||||
}
|
||||
|
||||
@@ -240,12 +239,12 @@ const validate = async (job, i, names, config) => {
|
||||
}
|
||||
|
||||
// Validate date
|
||||
if (typeof job.date !== 'undefined' && !(job.date instanceof Date)) {
|
||||
if (job.date !== undefined && !(job.date instanceof Date)) {
|
||||
errors.push(new Error(`${prefix} had an invalid Date of ${job.date}`));
|
||||
}
|
||||
|
||||
for (const prop of ['timeout', 'interval']) {
|
||||
if (typeof job[prop] !== 'undefined') {
|
||||
if (job[prop] !== undefined) {
|
||||
try {
|
||||
parseValue(job[prop]);
|
||||
} catch (err) {
|
||||
@@ -260,10 +259,7 @@ const validate = async (job, i, names, config) => {
|
||||
}
|
||||
|
||||
// Validate hasSeconds
|
||||
if (
|
||||
typeof job.hasSeconds !== 'undefined' &&
|
||||
typeof job.hasSeconds !== 'boolean'
|
||||
) {
|
||||
if (job.hasSeconds !== undefined && typeof job.hasSeconds !== 'boolean') {
|
||||
errors.push(
|
||||
new Error(
|
||||
`${prefix} had hasSeconds value of ${job.hasSeconds} (it must be a Boolean)`
|
||||
@@ -272,10 +268,7 @@ const validate = async (job, i, names, config) => {
|
||||
}
|
||||
|
||||
// Validate cronValidate
|
||||
if (
|
||||
typeof job.cronValidate !== 'undefined' &&
|
||||
typeof job.cronValidate !== 'object'
|
||||
) {
|
||||
if (job.cronValidate !== undefined && typeof job.cronValidate !== 'object') {
|
||||
errors.push(
|
||||
new Error(
|
||||
`${prefix} had cronValidate value set, but it must be an Object`
|
||||
@@ -283,13 +276,13 @@ const validate = async (job, i, names, config) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof job.cron !== 'undefined') {
|
||||
if (job.cron !== undefined) {
|
||||
errors.push(...validateCron(job, prefix, config));
|
||||
}
|
||||
|
||||
// Validate closeWorkerAfterMs
|
||||
if (
|
||||
typeof job.closeWorkerAfterMs !== 'undefined' &&
|
||||
job.closeWorkerAfterMs !== undefined &&
|
||||
(!Number.isFinite(job.closeWorkerAfterMs) || job.closeWorkerAfterMs <= 0)
|
||||
) {
|
||||
errors.push(
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
const path = require('node:path');
|
||||
const FakeTimers = require('@sinonjs/fake-timers');
|
||||
|
||||
const test = require('ava');
|
||||
|
||||
const Bree = require('../src');
|
||||
|
||||
const root = path.join(__dirname, 'jobs');
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
const path = require('node:path');
|
||||
|
||||
const test = require('ava');
|
||||
|
||||
const delay = require('delay');
|
||||
const Bree = require('../src');
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
const path = require('node:path');
|
||||
const { once } = require('node:events');
|
||||
|
||||
const test = require('ava');
|
||||
|
||||
const delay = require('delay');
|
||||
const humanInterval = require('human-interval');
|
||||
const FakeTimers = require('@sinonjs/fake-timers');
|
||||
|
||||
const Bree = require('../src');
|
||||
|
||||
const root = path.join(__dirname, 'jobs');
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
const path = require('node:path');
|
||||
const { once } = require('node:events');
|
||||
|
||||
const test = require('ava');
|
||||
|
||||
const Bree = require('../../src');
|
||||
|
||||
const root = path.join(__dirname, '../jobs');
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
const path = require('node:path');
|
||||
const { SHARE_ENV } = require('node:worker_threads');
|
||||
|
||||
const test = require('ava');
|
||||
|
||||
const Bree = require('../../src');
|
||||
|
||||
const root = path.join(__dirname, '../jobs');
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
const path = require('node:path');
|
||||
const { once } = require('node:events');
|
||||
|
||||
const test = require('ava');
|
||||
|
||||
const Bree = require('../../../src');
|
||||
|
||||
const root = path.join(__dirname, 'jobs');
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
const path = require('node:path');
|
||||
const test = require('ava');
|
||||
const later = require('@breejs/later');
|
||||
|
||||
const jobBuilder = require('../src/job-builder');
|
||||
|
||||
const root = path.join(__dirname, 'jobs');
|
||||
@@ -18,7 +17,7 @@ const baseConfig = {
|
||||
|
||||
function job(t, _job, config, expected) {
|
||||
t.deepEqual(
|
||||
jobBuilder(_job ? _job : 'basic', { ...baseConfig, ...config }),
|
||||
jobBuilder(_job || 'basic', { ...baseConfig, ...config }),
|
||||
expected
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const test = require('ava');
|
||||
|
||||
const jobUtils = require('../src/job-utils');
|
||||
|
||||
test('isSchedule: passes for valid schedule object', (t) => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const path = require('node:path');
|
||||
const test = require('ava');
|
||||
const later = require('@breejs/later');
|
||||
|
||||
const jobValidator = require('../src/job-validator');
|
||||
|
||||
const root = path.join(__dirname, 'jobs');
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const process = require('node:process');
|
||||
const { parentPort } = require('node:worker_threads');
|
||||
|
||||
const delay = require('delay');
|
||||
|
||||
setInterval(() => {}, 10);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const path = require('node:path');
|
||||
const test = require('ava');
|
||||
|
||||
const Bree = require('../../src');
|
||||
|
||||
const root = path.join(__dirname, '..', 'jobs');
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const path = require('node:path');
|
||||
const test = require('ava');
|
||||
|
||||
const Bree = require('../../src');
|
||||
|
||||
const root = path.join(__dirname, '..', 'jobs');
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const path = require('node:path');
|
||||
const delay = require('delay');
|
||||
const test = require('ava');
|
||||
|
||||
const Bree = require('../src');
|
||||
|
||||
const root = path.join(__dirname, 'jobs');
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
const path = require('node:path');
|
||||
const { once } = require('node:events');
|
||||
|
||||
const test = require('ava');
|
||||
|
||||
const delay = require('delay');
|
||||
const Bree = require('../src');
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
const path = require('node:path');
|
||||
const { once } = require('node:events');
|
||||
const FakeTimers = require('@sinonjs/fake-timers');
|
||||
|
||||
const test = require('ava');
|
||||
|
||||
const later = require('@breejs/later');
|
||||
const delay = require('delay');
|
||||
const Bree = require('../src');
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
const path = require('node:path');
|
||||
const { once } = require('node:events');
|
||||
|
||||
const test = require('ava');
|
||||
|
||||
const delay = require('delay');
|
||||
const Bree = require('../src');
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as path from 'node:path';
|
||||
|
||||
import * as Bree from 'bree';
|
||||
|
||||
Bree.extend((o, b) => {}, {});
|
||||
|
||||
Reference in New Issue
Block a user