Skip to content

fix(deps): Update dependency adbkit to v3.2.3 #2397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ commands:
## the production mode tests to fail if any of the dependencies is a
## binary dependency that is built using node-gyp.
- run: npm config set python /bin/false
- configure_global_npm
- run:
## (See #1082 for rationale).
name: run functional tests in npm production environment
Expand Down Expand Up @@ -149,15 +148,6 @@ commands:
steps:
- run: npm run github-pr-title-lint

# This is required to avoid a `EACCES` when running `npm link` (which is
# executed in the test suite).
configure_global_npm:
description: create custom directory for global npm installs
steps:
# NOTE: keep the following steps compatible with both bash and cmd.exe
- run: cd .. && mkdir .npm-global
- run: npm config set prefix '../.npm-global'

jobs:
build:
<<: *defaults
Expand Down
9 changes: 2 additions & 7 deletions .nsprc
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"exceptions": [
// node-forge advisories (transitive dependency introduced by @devicefarmer/adbkit).
"https://github.com/advisories/GHSA-5rrq-pxf6-6jx5",
"https://github.com/advisories/GHSA-gf8q-jrpm-jvxq",
"https://github.com/advisories/GHSA-8fr3-hfg3-gpgp",
"https://github.com/advisories/GHSA-2r2c-g63r-vccr",
"https://github.com/advisories/GHSA-x4jg-mjrx-434g",
"https://github.com/advisories/GHSA-cfm4-qjh2-4765"
// async advisory (transitive dependency introduced by @devicefarmer/adbkit -> @devicefarmer/adbkit-monkey).
"https://github.com/advisories/GHSA-fwr7-v2mv-hh25"
]
}
86 changes: 53 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
],
"dependencies": {
"@babel/runtime": "7.13.9",
"@devicefarmer/adbkit": "2.11.3",
"@devicefarmer/adbkit": "3.2.3",
"addons-linter": "4.14.0",
"bunyan": "1.8.15",
"camelcase": "6.2.0",
Expand Down
22 changes: 13 additions & 9 deletions src/util/adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export default class ADBUtils {
log.debug(`Run adb shell command on ${deviceId}: ${JSON.stringify(cmd)}`);

return wrapADBCall(async () => {
return await adbClient.shell(deviceId, cmd).then(adb.util.readAll);
return await adbClient.getDevice(deviceId).shell(cmd).then(
adb.util.readAll
);
}).then((res) => res.toString());
}

Expand Down Expand Up @@ -229,7 +231,9 @@ export default class ADBUtils {
log.debug('Checking adb device for existing web-ext artifacts dirs');

return wrapADBCall(async () => {
const files = await adbClient.readdir(deviceId, DEVICE_DIR_BASE);
const files = await adbClient.getDevice(deviceId).readdir(
DEVICE_DIR_BASE
);
let found = false;

for (const file of files) {
Expand Down Expand Up @@ -284,7 +288,7 @@ export default class ADBUtils {
log.debug(`Pushing ${localPath} to ${devicePath} on ${deviceId}`);

await wrapADBCall(async () => {
await adbClient.push(deviceId, localPath, devicePath)
await adbClient.getDevice(deviceId).push(localPath, devicePath)
.then(function(transfer) {
return new Promise((resolve) => {
transfer.on('end', resolve);
Expand Down Expand Up @@ -338,7 +342,7 @@ export default class ADBUtils {
const component = `${apk}/${apkComponent}`;

await wrapADBCall(async () => {
await adbClient.startActivity(deviceId, {
await adbClient.getDevice(deviceId).startActivity({
wait: true,
action: 'android.activity.MAIN',
component,
Expand Down Expand Up @@ -414,20 +418,20 @@ export default class ADBUtils {
log.debug(`Configuring ADB forward for ${deviceId}: ${remote} -> ${local}`);

await wrapADBCall(async () => {
await adbClient.forward(deviceId, local, remote);
await adbClient.getDevice(deviceId).forward(local, remote);
});
}
}

export async function listADBDevices(adbBin?: string): Promise<Array<string>> {
const adbClient = new ADBUtils({adbBin});
return adbClient.discoverDevices();
const adbUtils = new ADBUtils({adbBin});
return adbUtils.discoverDevices();
}

export async function listADBFirefoxAPKs(
deviceId: string,
adbBin?: string
): Promise<Array<string>> {
const adbClient = new ADBUtils({adbBin});
return adbClient.discoverInstalledFirefoxAPKs(deviceId);
const adbUtils = new ADBUtils({adbBin});
return adbUtils.discoverInstalledFirefoxAPKs(deviceId);
}
64 changes: 54 additions & 10 deletions tests/functional/test.lib.imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,56 @@ import {
withTempDir, fixturesUseAsLibrary,
} from './common';

const npm = shell.which('npm').toString();
const node = shell.which('node').toString();
const npm = shell.which('npm')?.toString();
const node = shell.which('node')?.toString();
const nvm = shell.which('nvm')?.toString();
const isWindows = process.platform === 'win32';

function npmGlobalDir() {
if (!process.env.HOME) {
throw new Error('HOME environment variable is undefined');
}
const npmDir = path.join(
process.env.HOME, '.npm-global'
);
if (!shell.test('-d', npmDir)) {
shell.echo(`Creating test npm directory at ${npmDir}`);
shell.mkdir(npmDir);
}
return npmDir;
}

function npmLink() {
if (nvm || isWindows) {
execFileSync(npm, ['link', '.'], {
cwd: path.resolve(path.join(__dirname, '..', '..')),
});
} else {
execFileSync(npm, ['link', '.'], {
cwd: path.resolve(path.join(__dirname, '..', '..')),
env: {
...process.env,
NPM_CONFIG_PREFIX: npmGlobalDir(),
},
});
}
}

function npmUnlink() {
if (nvm || isWindows) {
execFileSync(npm, ['unlink', '.'], {
cwd: path.resolve(path.join(__dirname, '..', '..')),
});
} else {
execFileSync(npm, ['unlink', '.'], {
cwd: path.resolve(path.join(__dirname, '..', '..')),
env: {
...process.env,
NPM_CONFIG_PREFIX: npmGlobalDir(),
},
});
}
}

describe('web-ext imported as a library', () => {
before(function() {
Expand All @@ -21,20 +69,16 @@ describe('web-ext imported as a library', () => {
this.skip();
}

execFileSync(npm, ['link', '.'], {
cwd: path.resolve(path.join(__dirname, '..', '..')),
});
npmLink();
});

after(() => {
execFileSync(npm, ['unlink', '.'], {
cwd: path.resolve(path.join(__dirname, '..', '..')),
});
npmUnlink();
});

it('can be imported as an ESM module', async () => {
await withTempDir(async (tmpDir) => {
execFileSync(npm, ['link', 'web-ext'], {cwd: tmpDir.path()});
execFileSync(npm, ['install', 'web-ext'], {cwd: tmpDir.path()});
shell.cp('-rf', `${fixturesUseAsLibrary}/*`, tmpDir.path());
execFileSync(node, ['--experimental-modules', 'test-import.mjs'], {
cwd: tmpDir.path(),
Expand All @@ -44,7 +88,7 @@ describe('web-ext imported as a library', () => {

it('can be imported as a CommonJS module', async () => {
await withTempDir(async (tmpDir) => {
execFileSync(npm, ['link', 'web-ext'], {cwd: tmpDir.path()});
execFileSync(npm, ['install', 'web-ext'], {cwd: tmpDir.path()});
shell.cp('-rf', `${fixturesUseAsLibrary}/*`, tmpDir.path());
execFileSync(node, ['--experimental-modules', 'test-require.js'], {
cwd: tmpDir.path(),
Expand Down
Loading