Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
const path = require('path');
const { asyncify } = require('asyncbox');
const { logger, fs } = require('@appium/support');
const { exec } = require('teen_process');
const xcode = require('appium-xcode');
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { asyncify } from 'asyncbox';
import { logger, fs } from '@appium/support';
import { exec } from 'teen_process';
import * as xcode from 'appium-xcode';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const isMainModule = process.argv[1] && path.resolve(process.argv[1]) === __filename;

const LOG = new logger.getLogger('WDABuild');
const ROOT_DIR = path.resolve(__dirname, '..');
Expand Down Expand Up @@ -72,8 +77,9 @@ async function buildWebDriverAgent (xcodeVersion) {
LOG.info(`Zip bundled at "${appBundleZipPath}"`);
}

if (require.main === module) {
if (isMainModule) {
asyncify(buildWebDriverAgent);
}

module.exports = buildWebDriverAgent;
export default buildWebDriverAgent;

26 changes: 17 additions & 9 deletions Scripts/fetch-prebuilt-wda.js → Scripts/fetch-prebuilt-wda.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
const path = require('path');
const axios = require('axios');
const { asyncify } = require('asyncbox');
const { logger, fs, mkdirp, net } = require('@appium/support');
const _ = require('lodash');
const B = require('bluebird');
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { readFileSync } from 'node:fs';
import axios from 'axios';
import { asyncify } from 'asyncbox';
import { logger, fs, mkdirp, net } from '@appium/support';
import _ from 'lodash';
import B from 'bluebird';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const isMainModule = process.argv[1] && path.resolve(process.argv[1]) === __filename;

const log = logger.getLogger('WDA');

async function fetchPrebuiltWebDriverAgentAssets () {
const tag = require('../package.json').version;
const packageJson = JSON.parse(readFileSync(path.resolve(__dirname, '..', 'package.json'), 'utf8'));
const tag = packageJson.version;
log.info(`Getting links to webdriveragent release ${tag}`);
const downloadUrl = `https://api.github.com/repos/appium/webdriveragent/releases/tags/v${tag}`;
log.info(`Getting WDA release ${downloadUrl}`);
Expand Down Expand Up @@ -54,8 +61,9 @@ async function fetchPrebuiltWebDriverAgentAssets () {
return await B.all(agentsDownloading);
}

if (require.main === module) {
if (isMainModule) {
asyncify(fetchPrebuiltWebDriverAgentAssets);
}

module.exports = fetchPrebuiltWebDriverAgentAssets;
export default fetchPrebuiltWebDriverAgentAssets;

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {plist, logger} = require('@appium/support');
const path = require('node:path');
const semver = require('semver');
import {plist, logger} from '@appium/support';
import path from 'node:path';
import semver from 'semver';

const log = logger.getLogger('Versioner');

Expand Down Expand Up @@ -39,3 +39,4 @@ async function updateWdaVersion() {
}

(async () => await updateWdaVersion())();

2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { checkForDependencies, bundleWDASim } from './lib/check-dependencies';
export { bundleWDASim } from './lib/check-dependencies';
export { NoSessionProxy } from './lib/no-session-proxy';
export { WebDriverAgent } from './lib/webdriveragent';
export { WDA_BASE_URL, WDA_RUNNER_BUNDLE_ID, PROJECT_FILE } from './lib/constants';
Expand Down
17 changes: 4 additions & 13 deletions lib/check-dependencies.js → lib/check-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
WDA_SCHEME, SDK_SIMULATOR, WDA_RUNNER_APP
} from './constants';
import { BOOTSTRAP_PATH } from './utils';
import log from './logger';
import type { XcodeBuild } from './xcodebuild';

async function buildWDASim () {
async function buildWDASim (): Promise<void> {
const args = [
'-project', path.join(BOOTSTRAP_PATH, 'WebDriverAgent.xcodeproj'),
'-scheme', WDA_SCHEME,
Expand All @@ -19,17 +19,7 @@ async function buildWDASim () {
await exec('xcodebuild', args);
}

export async function checkForDependencies () {
log.debug('Dependencies are up to date');
return false;
}

/**
*
* @param {import('./xcodebuild').XcodeBuild} xcodebuild
* @returns {Promise<string>}
*/
export async function bundleWDASim (xcodebuild) {
export async function bundleWDASim (xcodebuild: XcodeBuild): Promise<string> {
const derivedDataPath = await xcodebuild.retrieveDerivedDataPath();
if (!derivedDataPath) {
throw new Error('Cannot retrieve the path to the Xcode derived data folder');
Expand All @@ -41,3 +31,4 @@ export async function bundleWDASim (xcodebuild) {
await buildWDASim();
return wdaBundlePath;
}

24 changes: 0 additions & 24 deletions lib/constants.js

This file was deleted.

18 changes: 18 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import path from 'node:path';

export const DEFAULT_TEST_BUNDLE_SUFFIX = '.xctrunner';
export const WDA_RUNNER_BUNDLE_ID = 'com.facebook.WebDriverAgentRunner';
export const WDA_RUNNER_BUNDLE_ID_FOR_XCTEST = `${WDA_RUNNER_BUNDLE_ID}${DEFAULT_TEST_BUNDLE_SUFFIX}`;
export const WDA_RUNNER_APP = 'WebDriverAgentRunner-Runner.app';
export const WDA_SCHEME = 'WebDriverAgentRunner';
export const PROJECT_FILE = 'project.pbxproj';
export const WDA_BASE_URL = 'http://127.0.0.1';

export const PLATFORM_NAME_TVOS = 'tvOS';
export const PLATFORM_NAME_IOS = 'iOS';

export const SDK_SIMULATOR = 'iphonesimulator';
export const SDK_DEVICE = 'iphoneos';

export const WDA_UPGRADE_TIMESTAMP_PATH = path.join('.appium', 'webdriveragent', 'upgrade.time');

5 changes: 0 additions & 5 deletions lib/logger.js

This file was deleted.

3 changes: 3 additions & 0 deletions lib/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { logger } from '@appium/support';

export const log = logger.getLogger('WebDriverAgent');
9 changes: 4 additions & 5 deletions lib/no-session-proxy.js → lib/no-session-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { JWProxy } from '@appium/base-driver';
import type { ProxyOptions } from '@appium/types';


class NoSessionProxy extends JWProxy {
constructor (opts = {}) {
export class NoSessionProxy extends JWProxy {
constructor (opts: ProxyOptions = {}) {
super(opts);
}

getUrlForProxy (url) {
override getUrlForProxy (url: string): string {
if (url === '') {
url = '/';
}
Expand All @@ -22,5 +23,3 @@ class NoSessionProxy extends JWProxy {
}
}

export { NoSessionProxy };
export default NoSessionProxy;
Loading