Skip to content

Commit

Permalink
chore: support bree v8
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowgate15 committed Jun 4, 2022
1 parent 7f707be commit 6a58ebf
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 59 deletions.
6 changes: 3 additions & 3 deletions app/controllers/api/v1/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ async function get(ctx) {
body = body.map((j) => {
j.status = 'done';

if (bree.workers[j.name]) j.status = 'active';
else if (bree.timeouts[j.name]) j.status = 'delayed';
else if (bree.intervals[j.name]) j.status = 'waiting';
if (bree.workers.has(j.name)) j.status = 'active';
else if (bree.timeouts.has(j.name)) j.status = 'delayed';
else if (bree.intervals.has(j.name)) j.status = 'waiting';

return j;
});
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"ava": "^3.15.0",
"bree": "^6.3.0",
"bree": "^8.0.0",
"codecov": "^3.8.1",
"delay": "^5.0.0",
"eslint": "^7.19.0",
Expand Down Expand Up @@ -104,6 +104,9 @@
"test/**"
]
},
"peerDependencies": {
"bree": "~8.0"
},
"prettier": {
"singleQuote": true,
"bracketSpacing": true,
Expand Down
12 changes: 6 additions & 6 deletions test/api/v1/jobs/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test('successfully add one job', async (t) => {

t.truthy(bree.config.jobs.find((j) => j.name === 'successfulOne'));
// ensure job hasn't been started
t.falsy(bree.workers.successfulOne);
t.falsy(bree.workers.has('successfulOne'));
});

test('successfully add multiple jobs', async (t) => {
Expand Down Expand Up @@ -66,9 +66,9 @@ test('successfully add multiple jobs', async (t) => {
t.truthy(bree.config.jobs.find((j) => j.name === 'array2'));
t.truthy(bree.config.jobs.find((j) => j.name === 'array3'));
// ensure job hasn't been started
t.falsy(bree.workers.array1);
t.falsy(bree.workers.array2);
t.falsy(bree.workers.array3);
t.falsy(bree.workers.has('array1'));
t.falsy(bree.workers.has('array2'));
t.falsy(bree.workers.has('array3'));
});

test('fails if data is bad', async (t) => {
Expand Down Expand Up @@ -100,7 +100,7 @@ test('successfully auto start job', async (t) => {

t.truthy(bree.config.jobs.find((j) => j.name === 'auto-start'));
// ensure job hasn't been started
t.truthy(bree.workers['auto-start']);
t.truthy(bree.workers.has('auto-start'));
});

test('successfully duplicate job', async (t) => {
Expand All @@ -121,5 +121,5 @@ test('successfully duplicate job', async (t) => {

t.truthy(bree.config.jobs.find((j) => j.name === 'orig(2)'));

t.falsy(bree.workers['orig(2)']);
t.falsy(bree.workers.has('org(2)'));
});
8 changes: 4 additions & 4 deletions test/api/v1/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ test('successfully run named job', async (t) => {

await delay(200);

t.falsy(bree.workers.active);
t.falsy(bree.intervals.waiting);
t.falsy(bree.timeouts.delayed);
t.truthy(bree.workers.delayed);
t.falsy(bree.workers.has('active'));
t.falsy(bree.intervals.has('waiting'));
t.falsy(bree.timeouts.has('delayed'));
t.truthy(bree.workers.has('delayed'));
});
10 changes: 5 additions & 5 deletions test/api/v1/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ test.serial('successfully start all jobs', async (t) => {

await delay(200);

t.truthy(bree.workers.active);
t.truthy(bree.timeouts.delayed);
t.truthy(bree.intervals.waiting);
t.truthy(bree.workers.has('active'));
t.truthy(bree.timeouts.has('delayed'));
t.truthy(bree.intervals.has('waiting'));
});

test.serial('successfully start named job', async (t) => {
Expand Down Expand Up @@ -73,6 +73,6 @@ test.serial('successfully start named job', async (t) => {

await delay(200);

t.falsy(bree.workers.immediate);
t.truthy(bree.timeouts.timeout);
t.falsy(bree.workers.has('immediate'));
t.truthy(bree.timeouts.has('timeout'));
});
14 changes: 7 additions & 7 deletions test/api/v1/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ test.before(async (t) => {
test.serial('successfully stop named job', async (t) => {
const { api, bree } = t.context;

t.truthy(bree.workers.active);
t.truthy(bree.workers.has('active'));

const res = await api.post(`${rootUrl}/active`).send({});

t.is(res.status, 200);

t.falsy(bree.workers.active);
t.falsy(bree.workers.has('active'));
});

test.serial('successfully stop all jobs', async (t) => {
const { bree, api } = t.context;

t.not(Object.values(bree.timeouts).length, 0);
t.not(Object.values(bree.intervals).length, 0);
t.not(bree.timeouts.size, 0);
t.not(bree.intervals.size, 0);

const res = await api.post(rootUrl).send({});

t.is(res.status, 200);

t.is(Object.values(bree.workers).length, 0);
t.is(Object.values(bree.timeouts).length, 0);
t.is(Object.values(bree.intervals).length, 0);
t.is(bree.workers.size, 0);
t.is(bree.timeouts.size, 0);
t.is(bree.intervals.size, 0);
});
64 changes: 31 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.2.tgz#3723cd5c8d8773eef96ce57ea1d9b7faaccd12ac"
integrity sha512-RUVpT0G2h6rOZwqLDTrKk7ksNv7YpAilTnYe1/Q+eDjxEceRMKVWbCsX7t8h6C1qCFi/1Y8WZjcEPBAFG27GPw==

"@babel/runtime@^7.10.5", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5":
"@babel/runtime@^7.10.5", "@babel/runtime@^7.11.2":
version "7.16.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.0.tgz#e27b977f2e2088ba24748bf99b5e1dece64e4f0b"
integrity sha512-Nht8L0O8YCktmsDV6FqFue7vQLRx3Hb0B37lS5y0jDRqRxlBG4wIJHnf9/bgSE2UyipKFA01YtS+npRdTWBUyw==
Expand Down Expand Up @@ -1496,6 +1496,11 @@ boolean@^3.0.2:
resolved "https://registry.yarnpkg.com/boolean/-/boolean-3.1.4.tgz#f51a2fb5838a99e06f9b6ec1edb674de67026435"
integrity sha512-3hx0kwU3uzG6ReQ3pnaFQPSktpBw6RHN3/ivDKEuU8g1XSfafowyvDnadjv1xp8IZqhtSukxlwv9bF6FhX8m0w==

boolean@^3.1.4:
version "3.2.0"
resolved "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz#9e5294af4e98314494cbb17979fa54ca159f116b"
integrity sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==

boxen@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/boxen/-/boxen-4.2.0.tgz#e411b62357d6d6d36587c8ac3d5d974daa070e64"
Expand Down Expand Up @@ -1555,23 +1560,21 @@ braces@^3.0.1, braces@~3.0.2:
dependencies:
fill-range "^7.0.1"

bree@^6.3.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/bree/-/bree-6.4.0.tgz#73155fd0468fecc5f60c1ad5443a421f11bc7f38"
integrity sha512-eSxoBsIP4eiE4qew03wrMrvLWcYp6arA3Cx8oco7rugldBGFqeMdFnqnH1y/wnjzrcs49jJ8LCuL22MGrO03yQ==
bree@^8.0.0:
version "8.0.3"
resolved "https://registry.npmjs.org/bree/-/bree-8.0.3.tgz#811b8477d2e1fa9caa085e21bb0ef772eaa3031c"
integrity sha512-rz2v8P+Y+VgI9sEzrOhBHDcmLclI+Yu1oCunPuX5SIVMctqRp1zJdaS7wjaJoSIFJm6XJC/QrpxK1dvWzAbMgw==
dependencies:
"@babel/runtime" "^7.12.5"
"@breejs/later" "^4.1.0"
boolean "^3.0.2"
bthreads "^0.5.1"
boolean "^3.1.4"
combine-errors "^3.0.3"
cron-validate "^1.4.1"
debug "^4.3.1"
human-interval "^2.0.0"
cron-validate "^1.4.3"
debug "^4.3.3"
human-interval "^2.0.1"
is-string-and-not-blank "^0.0.2"
is-valid-path "^0.1.1"
ms "^2.1.2"
p-wait-for "3.1.0"
ms "^2.1.3"
p-wait-for "3"
safe-timers "^1.1.0"

brorand@^1.0.1, brorand@^1.1.0:
Expand Down Expand Up @@ -1661,13 +1664,6 @@ bson-objectid@^1.3.1:
resolved "https://registry.yarnpkg.com/bson-objectid/-/bson-objectid-1.3.1.tgz#11e4ce4c3419161fd388113781bb62c1dfbce34b"
integrity sha512-eQBNQXsisEAXlwiSy8zRNZdW2xDBJaEVkTPbodYR9hGxxtE548Qq7ilYOd8WAQ86xF7NRUdiWSQ1pa/TkKiE2A==

bthreads@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/bthreads/-/bthreads-0.5.1.tgz#c7a4dacc2d159c50de08b37b1e2a7da836171063"
integrity sha512-nK7Jo9ll+r1FRMNPWEFRTZMQrX6HhX8JjPAofxmbTNILHqWVIJPmWzCi9JlX/K0DL5AKZTFZg2Qser5C6gVs9A==
dependencies:
bufio "~1.0.5"

buf-compare@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/buf-compare/-/buf-compare-1.0.1.tgz#fef28da8b8113a0a0db4430b0b6467b69730b34a"
Expand Down Expand Up @@ -1710,11 +1706,6 @@ buffer@^5.5.0:
base64-js "^1.3.1"
ieee754 "^1.1.13"

bufio@~1.0.5:
version "1.0.7"
resolved "https://registry.yarnpkg.com/bufio/-/bufio-1.0.7.tgz#b7f63a1369a0829ed64cc14edf0573b3e382a33e"
integrity sha512-bd1dDQhiC+bEbEfg56IdBv7faWa6OipMs/AFFFvtFnB3wAYjlwQpQRZ0pm6ZkgtfL0pILRXhKxOiQj6UzoMR7A==

builtin-status-codes@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
Expand Down Expand Up @@ -2575,9 +2566,9 @@ credit-card-type@^8.3.0:
resolved "https://registry.yarnpkg.com/credit-card-type/-/credit-card-type-8.3.0.tgz#f93c187c9362411544158c91d552efcc443aa87a"
integrity sha512-czfZUpQ7W9CDxZL4yFLb1kFtM/q2lTOY975hL2aO+DC8+GRNDVSXVCHXhVFZPxiUKmQCZbFP8vIhxx5TBQaThw==

cron-validate@^1.4.1:
cron-validate@^1.4.3:
version "1.4.3"
resolved "https://registry.yarnpkg.com/cron-validate/-/cron-validate-1.4.3.tgz#d4ad8fb5b559a7df73b81e79c95c21b87bb4c5f4"
resolved "https://registry.npmjs.org/cron-validate/-/cron-validate-1.4.3.tgz#d4ad8fb5b559a7df73b81e79c95c21b87bb4c5f4"
integrity sha512-N+qKw019oQBEPIP5Qwi8Z5XelQ00ThN6Maahwv+9UGu2u/b/MPb35zngMQI0T8pBoNiBrIXGlhvsmspNSYae/w==
dependencies:
yup "0.32.9"
Expand Down Expand Up @@ -2711,6 +2702,13 @@ debug@^3.1.0, debug@^3.2.6, debug@^3.2.7:
dependencies:
ms "^2.1.1"

debug@^4.3.3:
version "4.3.4"
resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"

decamelize-keys@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9"
Expand Down Expand Up @@ -4991,9 +4989,9 @@ https-proxy-agent@^5.0.0:
agent-base "6"
debug "4"

human-interval@^2.0.0:
human-interval@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/human-interval/-/human-interval-2.0.1.tgz#655baf606c7067bb26042dcae14ec777b099af15"
resolved "https://registry.npmjs.org/human-interval/-/human-interval-2.0.1.tgz#655baf606c7067bb26042dcae14ec777b099af15"
integrity sha512-r4Aotzf+OtKIGQCB3odUowy4GfUDTy3aTWTfLd7ZF2gBCy3XW3v/dJLRefZnOFFnjqs5B1TypvS8WarpBkYUNQ==
dependencies:
numbered "^1.1.0"
Expand Down Expand Up @@ -7983,10 +7981,10 @@ p-try@^2.0.0:
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==

p-wait-for@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/p-wait-for/-/p-wait-for-3.1.0.tgz#9da568a2adda3ea8175a3c43f46a5317e28c0e47"
integrity sha512-0Uy19uhxbssHelu9ynDMcON6BmMk6pH8551CvxROhiz3Vx+yC4RqxjyIDk2V4ll0g9177RKT++PK4zcV58uJ7A==
p-wait-for@3:
version "3.2.0"
resolved "https://registry.npmjs.org/p-wait-for/-/p-wait-for-3.2.0.tgz#640429bcabf3b0dd9f492c31539c5718cb6a3f1f"
integrity sha512-wpgERjNkLrBiFmkMEjuZJEWKKDrNfHCKA1OhyN1wg1FrLkULbviEy6py1AyJUgZ72YWFbZ38FIpnqvVqAlDUwA==
dependencies:
p-timeout "^3.0.0"

Expand Down

0 comments on commit 6a58ebf

Please sign in to comment.