Skip to content

Commit

Permalink
Update all dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Liam McLoughlin <lmcloughlin@google.com>
  • Loading branch information
Hexxeh committed Jun 23, 2022
1 parent 9dcf9f7 commit 69b5403
Show file tree
Hide file tree
Showing 31 changed files with 4,050 additions and 5,068 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
node_version: [12, 14, 16]
node_version: [14, 16, 18]
name: ${{ matrix.os }} / Node v${{ matrix.node_version }}
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npx lint-staged
npm test
5 changes: 0 additions & 5 deletions .huskyrc.json

This file was deleted.

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@
"test:coveralls": "jest --runInBand --coverage && cat coverage/lcov.info | coveralls",
"lint": "tslint --project packages/tsconfig.settings.json --format code-frame",
"checkstyle": "prettier --list-different \"**/*.{js,jsx,ts,tsx,json}\"",
"publish": "yarn run test && lerna publish"
"publish": "yarn run test && lerna publish",
"prepare": "husky install"
},
"devDependencies": {
"@types/jest": "^26.0.13",
"coveralls": "^3.1.0",
"husky": "^4.3.0",
"jest": "^26.4.2",
"lerna": "^3.22.1",
"lint-staged": "^10.5.1",
"prettier": "^2.1.2",
"ts-jest": "^26.3.0",
"@types/jest": "^28.1.2",
"coveralls": "^3.1.1",
"husky": "^8.0.1",
"jest": "^28.1.1",
"lerna": "^5.1.4",
"lint-staged": "^13.0.2",
"prettier": "^2.7.1",
"ts-jest": "^28.0.5",
"tslint": "^6.1.3",
"tslint-config-airbnb": "^5.11.2",
"tslint-config-prettier": "^1.18.0",
"typescript": "~4.0.2"
"typescript": "~4.7.4"
},
"workspaces": [
"packages/*"
Expand Down
2 changes: 1 addition & 1 deletion packages/app-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"devDependencies": {
"@types/lodash": "^4.14.160",
"@types/node": "^14.6.0",
"@types/node": "^16.11.7",
"jszip": "^3.5.0"
}
}
2 changes: 1 addition & 1 deletion packages/fdb-debugger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@types/cbor": "^5.0.1",
"@types/duplexify": "^3.6.0",
"@types/lodash": "^4.14.160",
"@types/node": "^14.6.0",
"@types/node": "^16.11.7",
"duplexify": "^4.1.1"
}
}
4 changes: 2 additions & 2 deletions packages/fdb-debugger/src/BulkDataReceiver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ describe('when the stream open promise resolution is delayed', () => {
};

receiver = new BulkDataReceiver(
(mockBulkData as Partial<BulkData>) as BulkData,
mockBulkData as Partial<BulkData> as BulkData,
'test',
);

openPromise = receiver.receiveFromStream(
() =>
new Promise((resolve, reject) => {
new Promise<void>((resolve, reject) => {
openResolve = resolve;
openReject = reject;
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/fdb-debugger/src/ConfigurableEncode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class ConfigurableEncode extends Transform {
try {
encodedChunk = encoders[this.encoder](chunk);
} catch (e) {
callback(e);
callback(e as Error);
return;
}
callback(undefined, encodedChunk);
Expand Down
12 changes: 7 additions & 5 deletions packages/fdb-debugger/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {

import { ConsoleMessage, ConsoleTrace, RemoteHost } from '.';

jest.useFakeTimers();
jest.useFakeTimers({ legacyFakeTimers: true });

function wrapPeer(peer: Peer) {
const parser = new ParseJSON();
Expand Down Expand Up @@ -90,10 +90,11 @@ describe('connect()', () => {

it('waits a nonzero amount of time for the initialize response', () => {
waitInit();
const setTimeoutSpy = jest.spyOn(global, 'setTimeout');
const hostPromise = RemoteHost.connect(mockStream, { timeout: 10000 });
// The obvious way to test doesn't work because of a Jest bug.
// https://github.com/facebook/jest/issues/5960
expect(setTimeout).toHaveBeenLastCalledWith(expect.anything(), 10000);
expect(setTimeoutSpy).toHaveBeenLastCalledWith(expect.anything(), 10000);
return expect(hostPromise).resolves.toEqual(expect.anything());
});

Expand Down Expand Up @@ -231,8 +232,9 @@ it('sideloads an app', async () => {
// Pump the promise queue in between timers so that timer-triggered
// promises get a chance to run before the next set of timers expire.
for (let i = 0; i < 250; i += 1) {
await new Promise((resolve) => setImmediate(resolve));
await jest.runTimersToTime(100);
const delay = new Promise((resolve) => setImmediate(resolve));
jest.advanceTimersByTime(100);
await delay;
}
await expect(install).resolves.toEqual(expectedInstallResult);
expect(events).toEqual(['begin', 'finalize']);
Expand Down Expand Up @@ -422,7 +424,7 @@ it('successfully sideloads if the finalize response is slow', async () => {
() =>
new Promise((resolve) =>
setImmediate(() => {
jest.runTimersToTime(25000);
jest.advanceTimersByTime(25000);
resolve(expectedInstallResult);
}),
),
Expand Down
21 changes: 11 additions & 10 deletions packages/fdb-debugger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,17 @@ export class RemoteHost extends EventEmitter {
*/
const writes: Promise<any>[] = [];
for (let cursor = 0; cursor < data.length; cursor += maxDataBytes) {
const chunk: FDBTypes.IOWriteParams = this.serializerTransform.canAcceptRawBuffers()
? {
stream,
data: data.slice(cursor, cursor + maxDataBytes),
encoding: 'none',
}
: {
stream,
data: data.toString('base64', cursor, cursor + maxDataBytes),
};
const chunk: FDBTypes.IOWriteParams =
this.serializerTransform.canAcceptRawBuffers()
? {
stream,
data: data.slice(cursor, cursor + maxDataBytes),
encoding: 'none',
}
: {
stream,
data: data.toString('base64', cursor, cursor + maxDataBytes),
};

writes.push(
this.ioWrite(chunk).then(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/fdb-host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"devDependencies": {
"@types/duplexify": "^3.6.0",
"@types/node": "^14.6.0",
"@types/node": "^16.11.7",
"duplexify": "^4.1.1"
}
}
12 changes: 7 additions & 5 deletions packages/fdb-host/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {

import { Host, HostInfo, InstallHandlerReturn } from '.';

jest.useFakeTimers();
jest.useFakeTimers({ legacyFakeTimers: true });

function wrapPeer(peer: Peer) {
const parser = new ParseJSON();
Expand Down Expand Up @@ -206,8 +206,9 @@ describe('app install', () => {

it('can start a new install after it has successfully finalized', async () => {
await host.handleAppInstallFinalize({ stream });
const newStream = host.handleAppInstallBegin({ componentBundle: 'app' })
.stream;
const newStream = host.handleAppInstallBegin({
componentBundle: 'app',
}).stream;
expect(newStream).not.toEqual(stream);
});
});
Expand All @@ -227,8 +228,9 @@ describe('app install', () => {

it('can start a new install after it has aborted', async () => {
await host.handleAppInstallAbort({ stream });
const newStream = host.handleAppInstallBegin({ componentBundle: 'app' })
.stream;
const newStream = host.handleAppInstallBegin({
componentBundle: 'app',
}).stream;
expect(newStream).not.toEqual(stream);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/fdb-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"devDependencies": {
"@types/invariant": "^2.2.33",
"@types/node": "^14.6.0",
"@types/node": "^16.11.7",
"@types/semver": "^7.3.3",
"@types/validator": "^13.1.0"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const baseConfig = {
roots: ['<rootDir>/src'],
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.json',
tsconfig: '<rootDir>/tsconfig.json',
},
},
testEnvironment: 'node',
Expand Down
2 changes: 1 addition & 1 deletion packages/memory-profiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@types/cbor": "^5.0.1",
"@types/node": "^14.6.0",
"@types/node": "^16.11.7",
"@types/yargs": "^15.0.5"
}
}
2 changes: 1 addition & 1 deletion packages/sdk-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@types/minimist": "^1.2.0",
"@types/mock-fs": "^4.10.0",
"@types/mockdate": "^2.0.0",
"@types/node": "^14.6.0",
"@types/node": "^16.11.7",
"@types/opener": "^1.4.0",
"@types/pngjs": "^3.4.1",
"@types/semver": "^7.3.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
exports[`connect() when the WebSocket connection is unsucessful throws 1`] = `"Connection failed!"`;

exports[`hosts() handles a 403 response with a malformed payload 1`] = `
[Error: fetch of https://api.fitbit.com:443/1/user/-/developer-relay/hosts.json returned status 403 Forbidden with body: {
[Error: fetch of https://api.fitbit.com/1/user/-/developer-relay/hosts.json returned status 403 Forbidden with body: {
"message": "reason 2"
}]
`;

exports[`hosts() handles a 403 response with a non JSON payload 1`] = `[Error: Fetch of https://api.fitbit.com:443/1/user/-/developer-relay/hosts.json returned status 403 Forbidden]`;
exports[`hosts() handles a 403 response with a non JSON payload 1`] = `[Error: Fetch of https://api.fitbit.com/1/user/-/developer-relay/hosts.json returned status 403 Forbidden]`;

exports[`hosts() handles a non 403 error response 1`] = `[Error: Fetch of https://api.fitbit.com:443/1/user/-/developer-relay/hosts.json returned status 500 Internal Server Error]`;
exports[`hosts() handles a non 403 error response 1`] = `[Error: Fetch of https://api.fitbit.com/1/user/-/developer-relay/hosts.json returned status 500 Internal Server Error]`;
24 changes: 12 additions & 12 deletions packages/sdk-cli/src/api/baseAPI.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ describe('apiFetch()', () => {
Authorization: `Bearer ${mockAccessTokenContent}`,
},
});
});

it.each(['GET', 'POST'])(
'sends an authorization header with requests where method is %s',
async (method) => {
const endpointCall = endpointScope
.intercept(fakeAPIPath, method)
.reply(200);
it.each(['GET', 'POST'])(
'sends an authorization header with requests where method is %s',
async (method) => {
const endpointCall = endpointScope
.intercept(`/${fakeAPIPath}`, method)
.reply(200);

mockAuthToken();
await baseAPI.apiFetch(fakeAPIPath, { method });
expect(endpointCall.isDone()).toBe(true);
},
);
});
mockAuthToken();
await baseAPI.apiFetch(fakeAPIPath, { method });
expect(endpointCall.isDone()).toBe(true);
},
);
});
});

Expand Down
8 changes: 4 additions & 4 deletions packages/sdk-cli/src/api/baseAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export const assertAPIResponseOK = okOrElse((response) => {
);
});

export const decodeJSON = <A, O, I>(endpointType: t.Type<A, O, I>) => (
response: Response,
): Promise<A> =>
assertAPIResponseOK(response).then(assertJSON()).then(decode(endpointType));
export const decodeJSON =
<A, O, I>(endpointType: t.Type<A, O, I>) =>
(response: Response): Promise<A> =>
assertAPIResponseOK(response).then(assertJSON()).then(decode(endpointType));

export async function apiFetch(path: string, init: RequestInit = {}) {
const authToken = await auth.getAccessToken();
Expand Down
8 changes: 5 additions & 3 deletions packages/sdk-cli/src/checkLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function checkEnvVarLogin() {
try {
await auth.loginResourceOwnerFlow(username, password);
} catch (ex) {
console.error(`Resource owner login failed: ${ex.message}`);
console.error(`Resource owner login failed: ${(ex as Error).message}`);
process.exit(1);
}

Expand All @@ -33,7 +33,9 @@ async function checkStoredLogin() {
// thrown is a fatal error.
accessToken = await auth.getAccessToken();
} catch (ex) {
console.error(`Failed to read auth token from keychain: ${ex.message}`);
console.error(
`Failed to read auth token from keychain: ${(ex as Error).message}`,
);
if (os.platform() === 'darwin') {
console.error(
"Try locking and then unlocking your 'login' keychain using the Keychain Access app.",
Expand All @@ -47,7 +49,7 @@ async function checkStoredLogin() {
try {
await auth.loginAuthCodeFlow();
} catch (ex) {
console.error(`Login failed: ${ex.message}`);
console.error(`Login failed: ${(ex as Error).message}`);
process.exit(1);
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk-cli/src/commands/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export const connectAction = async (
} catch (error) {
cli.log(
// tslint:disable-next-line:max-line-length
`An error was encountered when loading the list of available ${deviceType} hosts: ${error.message}`,
`An error was encountered when loading the list of available ${deviceType} hosts: ${
(error as Error).message
}`,
);
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/sdk-cli/src/commands/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ beforeEach(() => {
sideloadCompanionSpy.mockResolvedValue({ installType: 'full' });

mockDevice.host.hasCapability.mockReturnValue(true);
mockDevice.host.info.capabilities.appHost.launch.appComponent.canLaunch = true;
mockDevice.host.info.capabilities.appHost.launch.appComponent.canLaunch =
true;
});

it('loads the app at provided path', async () => {
Expand Down Expand Up @@ -187,7 +188,8 @@ describe('when an app is loaded', () => {
describe('app launch is not supported', () => {
beforeEach(() => {
mockDevice.host.hasCapability.mockReturnValueOnce(false);
mockDevice.host.info.capabilities.appHost.launch.appComponent.canLaunch = false;
mockDevice.host.info.capabilities.appHost.launch.appComponent.canLaunch =
false;
return doInstall();
});
it('does not launch the app', () => {
Expand Down
Loading

0 comments on commit 69b5403

Please sign in to comment.