fix(fake-driver): create cjs wrapper
MODIFY
packages/fake-driver/index.js
packages/fake-driver/index.js
#!/usr/bin/env node
-// transpile:main
-import { asyncify } from 'asyncbox';
-import * as driver from './lib/driver';
-import * as server from './lib/server';
-
-
-const { FakeDriver } = driver;
-const { startServer } = server;
-
-const DEFAULT_HOST = 'localhost';
-const DEFAULT_PORT = 4774;
-
-async function main () {
- const getArgValue = (argName) => {
- const argIndex = process.argv.indexOf(argName);
- return argIndex > 0 ? process.argv[argIndex + 1] : null;
- };
- const port = parseInt(getArgValue('--port'), 10) || DEFAULT_PORT;
- const host = getArgValue('--host') || DEFAULT_HOST;
- return await startServer(port, host);
-}
-
-if (require.main === module) {
- asyncify(main);
-}
-
-export { FakeDriver, startServer };
+module.exports = require('./build/lib');

ADD
packages/fake-driver/lib/index.js
+#!/usr/bin/env node
+// transpile:main
+
+import { asyncify } from 'asyncbox';
+import * as driver from './driver';
+import * as server from './server';
+
+
+const { FakeDriver } = driver;
+const { startServer } = server;
+
+const DEFAULT_HOST = 'localhost';
+const DEFAULT_PORT = 4774;
+
+async function main () {
+ const getArgValue = (argName) => {
+ const argIndex = process.argv.indexOf(argName);
+ return argIndex > 0 ? process.argv[argIndex + 1] : null;
+ };
+ const port = parseInt(getArgValue('--port'), 10) || DEFAULT_PORT;
+ const host = getArgValue('--host') || DEFAULT_HOST;
+ return await startServer(port, host);
+}
+
+if (require.main === module) {
+ asyncify(main);
+}
+
+export { FakeDriver, startServer };

MODIFY
packages/fake-driver/package.json
packages/fake-driver/package.json
},
"license": "Apache-2.0",
"author": "https://github.com/appium",
- "main": "./build/index.js",
"bin": {
- "appium-fake-driver": "./build/index.js"
+ "appium-fake-driver": "index.js"
},
"directories": {
"lib": "lib"
"files": [
"index.js",
"lib",
- "build/index.js",
- "build/lib",
+ "build",
"test/fixtures",
"screen.png"
],
"dependencies": {
- "@appium/base-driver": "^8.2.0",
- "@appium/support": "^2.55.1",
+ "@appium/base-driver": "file:../base-driver",
+ "@appium/support": "file:../support",
"@babel/runtime": "7.16.3",
"asyncbox": "2.9.2",
"bluebird": "3.7.2",
"xmldom": "0.6.0",
"xpath": "0.0.32"
},
- "devDependencies": {
- "@appium/gulp-plugins": "^5.5.5"
- },
"engines": {
"node": ">=12",
"npm": ">=6"
"fake-success": "./build/lib/scripts/fake-success.js"
}
},
- "greenkeeper": {
- "ignore": []
- },
"publishConfig": {
"access": "public"
},

MODIFY
packages/fake-driver/test/driver-e2e-specs.js
packages/fake-driver/test/driver-e2e-specs.js
import axios from 'axios';
import { baseDriverE2ETests } from '@appium/base-driver/build/test/basedriver';
-import { FakeDriver, startServer } from '../index.js';
+import { FakeDriver, startServer } from '../lib/index.js';
import { BASE_CAPS, deleteSession, initSession, TEST_HOST, TEST_PORT, W3C_PREFIXED_CAPS } from './helpers';
import contextTests from './context-tests';
import findElementTests from './find-element-tests';

MODIFY
packages/fake-driver/test/driver-specs.js
packages/fake-driver/test/driver-specs.js
// transpile:mocha
import _ from 'lodash';
-import { FakeDriver } from '..';
+import { FakeDriver } from '../lib';
import { W3C_CAPS, W3C_PREFIXED_CAPS } from './helpers';
import { baseDriverUnitTests } from '@appium/base-driver/build/test/basedriver';

fix(fake-driver): create cjs wrapper