Skip to content

Commit c401942

Browse files
tune
1 parent caff121 commit c401942

File tree

7 files changed

+57
-58
lines changed

7 files changed

+57
-58
lines changed

.github/workflows/pr-title.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@ on:
33
pull_request:
44
types: [opened, edited, synchronize, reopened]
55

6-
76
jobs:
87
lint:
9-
name: https://www.conventionalcommits.org
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: beemojs/conventional-pr-action@v3
13-
with:
14-
config-preset: angular
15-
env:
16-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8+
uses: appium/appium-workflows/.github/workflows/pr-title.yml@main
9+
with:
10+
config-preset: angular

.github/workflows/publish.js.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ jobs:
2020
uses: actions/setup-node@v3
2121
with:
2222
node-version: lts/*
23-
- run: npm install --no-package-lock
23+
- uses: SocketDev/action@v1
24+
with:
25+
mode: firewall-free
26+
- run: sfw npm install --no-package-lock
2427
name: Install dependencies
2528
- run: npm run test
2629
name: Run NPM Test
@@ -37,4 +40,3 @@ jobs:
3740
env:
3841
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3942
name: Release
40-

.github/workflows/unit-test.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,25 @@ on: [pull_request, push]
44

55

66
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"
7+
node_matrix:
8+
uses: appium/appium-workflows/.github/workflows/node-lts-matrix.yml@main
159

1610
test:
1711
needs:
18-
- prepare_matrix
12+
- node_matrix
1913
strategy:
2014
matrix:
21-
node-version: ${{ fromJSON(needs.prepare_matrix.outputs.versions) }}
15+
node-version: ${{ fromJSON(needs.node_matrix.outputs.versions) }}
2216
runs-on: windows-latest
2317
steps:
2418
- uses: actions/checkout@v3
2519
- uses: actions/setup-node@v3
2620
with:
2721
node-version: ${{ matrix.node-version }}
28-
- run: npm install --no-package-lock
22+
- uses: SocketDev/action@v1
23+
with:
24+
mode: firewall-free
25+
- run: sfw npm install --no-package-lock
2926
name: Install dev dependencies
3027
- run: npm run lint
3128
name: Run linter

lib/installer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,3 @@ export async function isAdmin(): Promise<boolean> {
114114
return false;
115115
}
116116
}
117-

lib/registry.ts

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,12 @@ import { runElevated } from './utils';
44
const REG = 'reg.exe';
55
const ENTRY_PATTERN = /^\s+(\w+)\s+([A-Z_]+)\s*(.*)/;
66

7-
export interface RegEntry {
8-
/** Full path to the registry branch, for example
9-
* HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\DirectDrawEx */
10-
root: string;
11-
/** The registry key name */
12-
key: string;
13-
/** One of possible registry value types, for example REG_DWORD or REG_SZ */
14-
type: string;
15-
/** The actual value. Could be empty */
16-
value: string;
17-
}
18-
19-
function parseRegEntries(root: string | undefined, block: string[]): RegEntry[] {
20-
if (_.isEmpty(block) || !root || _.isEmpty(root)) {
21-
return [];
22-
}
23-
return block.reduce((acc: RegEntry[], line: string) => {
24-
const match = ENTRY_PATTERN.exec(line);
25-
if (match) {
26-
acc.push({root, key: match[1], type: match[2], value: match[3] || ''});
27-
}
28-
return acc;
29-
}, []);
30-
}
31-
7+
/**
8+
* Parses the output of the reg query command into a list of RegEntry instances
9+
*
10+
* @param output - The output of the reg query command
11+
* @returns List of matched RegEntry instances
12+
*/
3213
export function parseRegQueryOutput(output: string): RegEntry[] {
3314
const result: RegEntry[] = [];
3415
let root: string | undefined;
@@ -73,3 +54,27 @@ export async function queryRegistry(root: string): Promise<RegEntry[]> {
7354
return parseRegQueryOutput(stdout);
7455
}
7556

57+
function parseRegEntries(root: string | undefined, block: string[]): RegEntry[] {
58+
if (_.isEmpty(block) || !root || _.isEmpty(root)) {
59+
return [];
60+
}
61+
return block.reduce((acc: RegEntry[], line: string) => {
62+
const match = ENTRY_PATTERN.exec(line);
63+
if (match) {
64+
acc.push({root, key: match[1], type: match[2], value: match[3] || ''});
65+
}
66+
return acc;
67+
}, []);
68+
}
69+
70+
export interface RegEntry {
71+
/** Full path to the registry branch, for example
72+
* HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\DirectDrawEx */
73+
root: string;
74+
/** The registry key name */
75+
key: string;
76+
/** One of possible registry value types, for example REG_DWORD or REG_SZ */
77+
type: string;
78+
/** The actual value. Could be empty */
79+
value: string;
80+
}

lib/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ import { log } from './logger';
88

99
const execAsync = promisify(exec);
1010

11-
export interface RunElevatedOptions extends ExecOptions {
12-
timeoutMs?: number;
13-
}
14-
1511
/**
1612
* This API triggers UAC when necessary
1713
*
@@ -61,3 +57,6 @@ export async function downloadToFile(srcUrl: string, dstPath: string): Promise<v
6157
await net.downloadFile(srcUrl, dstPath);
6258
}
6359

60+
export interface RunElevatedOptions extends ExecOptions {
61+
timeoutMs?: number;
62+
}

test/unit/driver-specs.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,24 @@ describe('driver', function () {
3232
sinon.mock(driver).expects('startWinAppDriverSession')
3333
.once()
3434
.returns(B.resolve());
35-
// @ts-ignore
36-
await driver.createSession(null as any, null as any, { alwaysMatch: { 'appium:cap': 'foo' }});
35+
await driver.createSession(
36+
{ alwaysMatch: { 'appium:automationName': 'Windows', 'appium:app': 'myapp' }, firstMatch: [] },
37+
undefined,
38+
undefined
39+
);
3740
expect(driver.sessionId).to.exist;
38-
expect((driver.caps as any).cap).to.equal('foo');
41+
expect((driver.caps as any).app).to.equal('myapp');
3942
});
4043

4144
describe('context simulation', function () {
4245
it('should support context commands', async function () {
43-
const driver = new WindowsDriver({ app: 'myapp'} as any, false);
46+
const driver = new WindowsDriver({} as any, false);
4447
expect(await driver.getCurrentContext()).to.equal('NATIVE_APP');
4548
expect(await driver.getContexts()).to.eql(['NATIVE_APP']);
4649
await driver.setContext('NATIVE_APP');
4750
});
4851
it('should throw an error if invalid context', async function () {
49-
const driver = new WindowsDriver({ app: 'myapp'} as any, false);
52+
const driver = new WindowsDriver({} as any, false);
5053
await expect(driver.setContext('INVALID_CONTEXT')).to.be.rejected;
5154
});
5255
});
@@ -55,7 +58,7 @@ describe('driver', function () {
5558
describe('proxying', function () {
5659
let driver: WindowsDriver;
5760
before(function () {
58-
driver = new WindowsDriver({} as any, false);
61+
driver = new WindowsDriver({ address: '127.0.0.1', port: 4723 } as any, false);
5962
driver.sessionId = 'abc';
6063
});
6164
describe('#proxyActive', function () {

0 commit comments

Comments
 (0)