Skip to content

Commit ac95eb0

Browse files
refactor!: Switch babel to typescript (#19)
* refactor!: Switch babel to typescript * tune flaky test * moar * moar * moar
1 parent d0adc21 commit ac95eb0

File tree

11 files changed

+110
-50
lines changed

11 files changed

+110
-50
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": "appium"
2+
"extends": ["@appium/eslint-config-appium-ts"]
33
}

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "11:00"
8+
open-pull-requests-limit: 10
9+
commit-message:
10+
prefix: "chore"
11+
include: "scope"

.github/workflows/pr-title.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Conventional Commits
2+
on:
3+
pull_request:
4+
5+
6+
jobs:
7+
lint:
8+
name: https://www.conventionalcommits.org
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: beemojs/conventional-pr-action@v2
12+
with:
13+
config-preset: angular
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/unit-test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Unit Tests
2+
3+
on: [pull_request, push]
4+
5+
6+
jobs:
7+
prepare_matrix:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
versions: ${{ steps.generate-matrix.outputs.versions }}
11+
steps:
12+
- name: Select 3 most recent LTS versions of Node.js
13+
id: generate-matrix
14+
run: echo "versions=$(curl -s https://endoflife.date/api/nodejs.json | jq -c '[[.[] | select(.lts != false)][:3] | .[].cycle | tonumber]')" >> "$GITHUB_OUTPUT"
15+
16+
test:
17+
needs:
18+
- prepare_matrix
19+
strategy:
20+
matrix:
21+
node-version: ${{ fromJSON(needs.prepare_matrix.outputs.versions) }}
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v3
25+
- uses: actions/setup-node@v3
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
- run: npm install --no-package-lock
29+
name: Install dev dependencies
30+
- run: npm run lint
31+
name: Run linter
32+
- run: npm run test
33+
name: Run unit tests

.mocharc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
require: ['ts-node/register'],
3+
forbidOnly: Boolean(process.env.CI)
4+
};

gulpfile.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/asyncbox.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// transpile:main
2-
31
import B from 'bluebird';
42
import _ from 'lodash';
53

package.json

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"url": "https://github.com/jlipps/asyncbox/issues"
1818
},
1919
"engines": {
20-
"node": ">=10"
20+
"node": ">=16"
2121
},
2222
"main": "./build/lib/asyncbox.js",
2323
"bin": {},
@@ -29,33 +29,41 @@
2929
"build/lib/**/*"
3030
],
3131
"dependencies": {
32-
"@babel/runtime": "^7.0.0",
3332
"bluebird": "^3.5.1",
3433
"lodash": "^4.17.4",
35-
"source-map-support": "^0.5.5",
36-
"@types/bluebird": "^3.5.37"
34+
"source-map-support": "^0.x"
3735
},
3836
"scripts": {
39-
"clean": "rm -rf node_modules && rm -f package-lock.json && npm install",
40-
"prepare": "gulp prepublish && tsc",
41-
"test": "gulp once",
42-
"e2e-test": "gulp e2e-test",
43-
"build": "gulp transpile && tsc",
44-
"lint": "gulp eslint",
45-
"watch": "gulp watch"
37+
"build": "tsc -b",
38+
"clean": "npm run build -- --clean",
39+
"rebuild": "npm run clean; npm run build",
40+
"dev": "npm run build -- --watch",
41+
"prepare": "npm run rebuild",
42+
"test": "mocha --exit --timeout 1m \"./test/**/*-specs.js\"",
43+
"lint": "eslint .",
44+
"watch": "npm run dev"
4645
},
4746
"devDependencies": {
47+
"@appium/eslint-config-appium": "^8.0.4",
48+
"@appium/eslint-config-appium-ts": "^0.x",
49+
"@appium/tsconfig": "^0.x",
50+
"@types/bluebird": "^3.5.37",
4851
"@types/lodash": "^4.14.189",
49-
"ajv": "^6.5.3",
50-
"appium-gulp-plugins": "^4.0.0",
51-
"chai": "4.2.0",
52+
"@types/node": "^20.4.7",
53+
"@typescript-eslint/eslint-plugin": "^6.9.0",
54+
"@typescript-eslint/parser": "^6.9.0",
55+
"chai": "^4.2.0",
5256
"chai-as-promised": "^7.1.1",
53-
"eslint-config-appium": "^4.0.0",
54-
"gulp": "^4.0.0",
55-
"request": "^2.47.0",
56-
"should": "^13.2.1",
57-
"sinon": "^11.1.2",
58-
"typescript": "~4.7.0"
57+
"eslint": "^8.46.0",
58+
"eslint-config-prettier": "^9.0.0",
59+
"eslint-import-resolver-typescript": "^3.5.5",
60+
"eslint-plugin-import": "^2.28.0",
61+
"eslint-plugin-mocha": "^10.1.0",
62+
"eslint-plugin-promise": "^6.1.1",
63+
"mocha": "^10.0.0",
64+
"sinon": "^16.0.0",
65+
"ts-node": "^10.9.1",
66+
"typescript": "^5.1.6"
5967
},
6068
"types": "./build/lib/asyncbox.d.ts"
6169
}

test/asyncbox-specs.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe('retry', function () {
149149
eventuallyOkFnCalls.should.equal(3);
150150
res.should.equal(9);
151151
// XXX: flaky
152-
(Date.now() - start).should.be.above(30);
152+
(Date.now() - start).should.be.least(30);
153153
});
154154
it('should not wait on the final error', async function () {
155155
const start = Date.now();
@@ -182,7 +182,7 @@ describe('nodeifyAll', function () {
182182
should.not.exist(err);
183183
should.not.exist(val2);
184184
val.should.equal('foo');
185-
(Date.now() - start).should.be.above(14);
185+
(Date.now() - start).should.be.least(14);
186186
done();
187187
});
188188
});
@@ -192,7 +192,7 @@ describe('nodeifyAll', function () {
192192
should.not.exist(err);
193193
should.not.exist(val2);
194194
val.should.equal('foo');
195-
(Date.now() - start).should.be.above(14);
195+
(Date.now() - start).should.be.least(14);
196196
done();
197197
});
198198
});
@@ -201,7 +201,7 @@ describe('nodeifyAll', function () {
201201
nodeify(asyncFn2('foo'), function (err, val) { // eslint-disable-line promise/prefer-await-to-callbacks
202202
should.not.exist(err);
203203
val.should.eql(['foo', 'foofoo']);
204-
(Date.now() - start).should.be.above(14);
204+
(Date.now() - start).should.be.least(14);
205205
done();
206206
});
207207
});
@@ -210,7 +210,7 @@ describe('nodeifyAll', function () {
210210
nodeify(badAsyncFn('foo'), function (err, val) { // eslint-disable-line promise/prefer-await-to-callbacks
211211
should.not.exist(val);
212212
err.message.should.equal('boo');
213-
(Date.now() - start).should.be.above(14);
213+
(Date.now() - start).should.be.least(14);
214214
done();
215215
});
216216
});
@@ -307,7 +307,7 @@ describe('parallel', function () {
307307
}
308308
await (waitForCondition(condFn, {waitMs: 20, intervalMs: 10}));
309309
let getLastCall = requestSpy.getCall(1);
310-
getLastCall.args[0].should.be.below(10);
310+
getLastCall.args[0].should.be.most(10);
311311
});
312312
});
313313
});
@@ -321,12 +321,12 @@ describe('asyncmap', function () {
321321
it('should map elements one at a time', async function () {
322322
let start = Date.now();
323323
(await asyncmap(coll, mapper, false)).should.eql([2, 4, 6]);
324-
(Date.now() - start).should.be.above(30);
324+
(Date.now() - start).should.be.least(30);
325325
});
326326
it('should map elements in parallel', async function () {
327327
let start = Date.now();
328328
(await asyncmap(coll, mapper)).should.eql([2, 4, 6]);
329-
(Date.now() - start).should.be.below(20);
329+
(Date.now() - start).should.be.most(20);
330330
});
331331
it('should handle an empty array', async function () {
332332
(await asyncmap([], mapper, false)).should.eql([]);

0 commit comments

Comments
 (0)