diff --git a/.npmignore b/.npmignore deleted file mode 100644 index a8462c09c..000000000 --- a/.npmignore +++ /dev/null @@ -1,23 +0,0 @@ -assets/ -submodules/ -test/ -coverage/ -commands-yml/ -docs/ -sample-code/ -.vscode/ - -_vimrc_local.vim -*.swp -*.swo -*~ -.*~ -.DS_Store -.travis.yml -*.log -*.trace -*.sublime- -*.prefs -./.npmignore -coverage -sample-code/ diff --git a/.travis.yml b/.travis.yml index ba40b2929..83b3b9840 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,12 +23,6 @@ jobs: - sudo: false script: npm run test && npm run e2e-test node_js: "8" - - stage: - os: - - linux - - sudo: false - script: npm run test && npm run e2e-test - node_js: "6" - stage: os: - linux diff --git a/commands-yml/parse.js b/commands-yml/parse.js index 12a9d69a6..f52f9f106 100644 --- a/commands-yml/parse.js +++ b/commands-yml/parse.js @@ -73,7 +73,7 @@ Handlebars.registerHelper('versions', (object, name, driverName) => { return `${min} to ${max}`; }); -Handlebars.registerHelper('hyphenate', (str) => str.replace('_', '-')); +Handlebars.registerHelper('hyphenate', (str) => str.replace('_', '-')); Handlebars.registerHelper('uppercase', (str) => str.toUpperCase()); Handlebars.registerHelper('capitalize', function (driverName) { diff --git a/docs/en/commands/device/authentication/finger-print.md b/docs/en/commands/device/authentication/finger_print.md similarity index 100% rename from docs/en/commands/device/authentication/finger-print.md rename to docs/en/commands/device/authentication/finger_print.md diff --git a/gulpfile.js b/gulpfile.js index 79927deec..df585b611 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,13 +4,14 @@ // turn all logging on since we have tests that rely on npmlog logs actually // getting sent to the handler -process.env._FORCE_LOGS="1"; +process.env._FORCE_LOGS = "1"; const gulp = require('gulp'); const boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp); const path = require('path'); const fs = require('fs'); + // remove 'fsevents' from shrinkwrap, since it causes errors on non-Mac hosts // see https://github.com/npm/npm/issues/2679 gulp.task('fixShrinkwrap', function (done) { @@ -20,16 +21,13 @@ gulp.task('fixShrinkwrap', function (done) { } catch (err) { console.error('Could not find shrinkwrap; skipping fixing shrinkwrap. ' + '(Original error: ' + err.message + ')'); - return; + return done(); } delete shrinkwrap.dependencies.fsevents; const shrinkwrapString = JSON.stringify(shrinkwrap, null, ' ') + '\n'; fs.writeFile('./npm-shrinkwrap.json', shrinkwrapString, done); }); - - - boilerplate({ build: 'appium', test: { @@ -40,7 +38,7 @@ boilerplate({ }); // generates server arguments readme -gulp.task('docs', ['transpile'], function () { +gulp.task('docs', gulp.series(['transpile']), function () { const parser = require('./build/lib/parser.js'); const appiumArguments = parser.getParser().rawArgs; const docFile = path.resolve(__dirname, "docs/en/writing-running-appium/server-args.md"); @@ -77,7 +75,7 @@ gulp.task('docs', ['transpile'], function () { md += "|" + ((typeof argOpts.example === "undefined") ? "" : "`" + exampleArg + " " + argOpts.example + "`"); md += "|\n"; }); - // console.log(md); + fs.writeFile(docFile, md, function (err) { if (err) { console.log(err.stack); diff --git a/lib/appium.js b/lib/appium.js index ca2a7670a..0ee588196 100755 --- a/lib/appium.js +++ b/lib/appium.js @@ -202,9 +202,9 @@ class AppiumDriver extends BaseDriver { log.warn(`Unable to get version of driver '${driver.name}'`); } - async getStatus () { + async getStatus () { // eslint-disable-line require-await return { - build: _.clone(await getBuildInfo()), + build: _.clone(getBuildInfo()), }; } diff --git a/lib/config.js b/lib/config.js index 97dfc5c79..8c434fc2e 100644 --- a/lib/config.js +++ b/lib/config.js @@ -116,7 +116,7 @@ async function getGitTimestamp (commitSha, useGitHubFallback = false) { * and git commit hash asynchronously as soon as `updateBuildInfo` is called * and succeeds. */ -async function getBuildInfo () { +function getBuildInfo () { return BUILD_INFO; } @@ -139,7 +139,7 @@ function warnNodeDeprecations () { async function showConfig () { await updateBuildInfo(); - console.log(JSON.stringify(await getBuildInfo())); // eslint-disable-line no-console + console.log(JSON.stringify(getBuildInfo())); // eslint-disable-line no-console } function getNonDefaultArgs (parser, args) { @@ -228,7 +228,8 @@ async function validateTmpDir (tmpDir) { } } -export { getBuildInfo, validateServerArgs, checkNodeOk, showConfig, - warnNodeDeprecations, validateTmpDir, getNonDefaultArgs, - getDeprecatedArgs, getGitRev, checkValidPort, APPIUM_VER, - updateBuildInfo }; +export { + getBuildInfo, validateServerArgs, checkNodeOk, showConfig, + warnNodeDeprecations, validateTmpDir, getNonDefaultArgs, getDeprecatedArgs, + getGitRev, checkValidPort, APPIUM_VER, updateBuildInfo, +}; diff --git a/lib/grid-register.js b/lib/grid-register.js index 11c1e491a..eafcdaad6 100644 --- a/lib/grid-register.js +++ b/lib/grid-register.js @@ -21,7 +21,7 @@ async function registerNode (configFile, addr, port) { logger.error('No data found in the node configuration file to send to the grid'); return; } - await postRequest(data, addr, port); + postRequest(data, addr, port); } async function registerToGrid (options_post, jsonObject) { @@ -37,7 +37,7 @@ async function registerToGrid (options_post, jsonObject) { } } -async function postRequest (data, addr, port) { +function postRequest (data, addr, port) { // parse json to get hub host and port let jsonObject; try { @@ -121,8 +121,8 @@ async function isAlreadyRegistered (jsonObject) { try { let response = await request({ uri: `${hubUri(jsonObject.configuration)}/grid/api/proxy?id=${id}`, - method : 'GET', - timeout : 10000, + method: 'GET', + timeout: 10000, resolveWithFullResponse: true // return the full response, not just the body }); if (response === undefined || response.statusCode !== 200) { diff --git a/lib/logsink.js b/lib/logsink.js index 026ab7b6b..9063f3d4b 100644 --- a/lib/logsink.js +++ b/lib/logsink.js @@ -1,5 +1,5 @@ import npmlog from 'npmlog'; -import winston from 'winston'; +import winston from 'winston'; import { fs, logger } from 'appium-support'; import dateformat from 'dateformat'; import _ from 'lodash'; @@ -52,7 +52,7 @@ function timestamp () { function applyStripColorPatch (transport) { let _log = transport.log.bind(transport); transport.log = function (level, msg, meta, callback) { // eslint-disable-line promise/prefer-await-to-callbacks - let code = /\u001b\[(\d+(;\d+)*)?m/g; + const code = /\u001b\[(\d+(;\d+)*)?m/g; // eslint-disable-line no-control-regex msg = ('' + msg).replace(code, ''); _log(level, msg, meta, callback); }; @@ -130,7 +130,7 @@ async function _createTransports (args) { if (args.loglevel && args.loglevel.match(":")) { // --log-level arg can optionally provide diff logging levels for console and file, separated by a colon let lvlPair = args.loglevel.split(':'); - consoleLogLevel = lvlPair[0] || consoleLogLevel; + consoleLogLevel = lvlPair[0] || consoleLogLevel; fileLogLevel = lvlPair[1] || fileLogLevel; } else { consoleLogLevel = fileLogLevel = args.loglevel; diff --git a/lib/main.js b/lib/main.js index 55ea7d733..7baa008ed 100755 --- a/lib/main.js +++ b/lib/main.js @@ -78,10 +78,10 @@ async function logStartupInfo (parser, args) { logDefaultCapabilitiesWarning(args.defaultCapabilities); } // TODO: bring back loglevel reporting below once logger is flushed out - //logger.info('Console LogLevel: ' + logger.transports.console.level); - //if (logger.transports.file) { - //logger.info('File LogLevel: ' + logger.transports.file.level); - //} + // logger.info('Console LogLevel: ' + logger.transports.console.level); + // if (logger.transports.file) { + // logger.info('File LogLevel: ' + logger.transports.file.level); + // } } function logServerPort (address, port) { diff --git a/lib/parser.js b/lib/parser.js index 5480acd13..abacdee7d 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -111,10 +111,12 @@ const args = [ }], [['--log-level'], { - choices: ['info', 'info:debug', 'info:info', 'info:warn', 'info:error', - 'warn', 'warn:debug', 'warn:info', 'warn:warn', 'warn:error', - 'error', 'error:debug', 'error:info', 'error:warn', 'error:error', - 'debug', 'debug:debug', 'debug:info', 'debug:warn', 'debug:error'], + choices: [ + 'info', 'info:debug', 'info:info', 'info:warn', 'info:error', + 'warn', 'warn:debug', 'warn:info', 'warn:warn', 'warn:error', + 'error', 'error:debug', 'error:info', 'error:warn', 'error:error', + 'debug', 'debug:debug', 'debug:info', 'debug:warn', 'debug:error', + ], defaultValue: 'debug', dest: 'loglevel', required: false, diff --git a/lib/utils.js b/lib/utils.js index 5ffdf20d2..ca8d4904c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -253,5 +253,7 @@ function getPackageVersion (pkgName) { const rootDir = findRoot(__dirname); -export { inspectObject, parseCapsForInnerDriver, insertAppiumPrefixes, rootDir, - getPackageVersion }; +export { + inspectObject, parseCapsForInnerDriver, insertAppiumPrefixes, rootDir, + getPackageVersion, +}; diff --git a/package.json b/package.json index 1db7b63d8..9c275c157 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "url": "https://github.com/appium/appium/issues" }, "engines": { - "node": ">=6", - "npm": ">=3" + "node": ">=8", + "npm": ">=6" }, "main": "./build/lib/main.js", "bin": { @@ -33,7 +33,13 @@ "lib": "./lib", "doc": "./docs" }, + "files": [ + "bin", + "lib", + "build/lib" + ], "dependencies": { + "@babel/runtime": "^7.0.0", "appium-android-driver": "^4.0.0", "appium-base-driver": "3.x", "appium-espresso-driver": ">=1.0.0-beta.13", @@ -50,7 +56,6 @@ "argparse": "^1.0.10", "async-lock": "^1.0.0", "asyncbox": "2.x", - "babel-runtime": "=5.8.24", "bluebird": "3.x", "continuation-local-storage": "3.x", "dateformat": "^3.0.3", @@ -66,7 +71,7 @@ "winston": "2.x" }, "scripts": { - "prepublish": "gulp prepublish", + "prepare": "gulp prepublish", "publish": "gulp prepublish", "test": "gulp once", "e2e-test": "gulp e2e-test", @@ -90,20 +95,20 @@ "precommit-test" ], "devDependencies": { - "appium-gulp-plugins": "^2.4.0", + "ajv": "^6.5.3", + "appium-gulp-plugins": "^3.1.0", "babel-cli": "^6.26.0", - "babel-eslint": "^7.x", + "babel-eslint": "^10.0.0", "babel-preset-env": "^1.7.0", "chai": "4.x", "chai-as-promised": "7.x", - "eslint": "^3.x", - "eslint-config-appium": "2.x", - "eslint-plugin-babel": "3.x", - "eslint-plugin-import": "2.x", - "eslint-plugin-mocha": "4.x", - "eslint-plugin-promise": "3.x", + "eslint": "^5.2.0", + "eslint-config-appium": "3.x", + "eslint-plugin-import": "^2.2.0", + "eslint-plugin-mocha": "^5.0.0", + "eslint-plugin-promise": "^4.0.0", "fancy-log": "^1.3.2", - "gulp": "^3.9.1", + "gulp": "^4.0.0", "handlebars": "^4.0.10", "mocha": "5.x", "pre-commit": "1.x", @@ -120,15 +125,6 @@ }, "greenkeeper": { "ignore": [ - "babel-eslint", - "babel-preset-env", - "eslint", - "eslint-plugin-babel", - "eslint-plugin-import", - "eslint-plugin-mocha", - "eslint-plugin-promise", - "gulp", - "babel-runtime", "winston" ] } diff --git a/test/config-specs.js b/test/config-specs.js index 75a938fb5..a2c9bb0ec 100644 --- a/test/config-specs.js +++ b/test/config-specs.js @@ -30,7 +30,7 @@ describe('Config', function () { describe('Appium config', function () { describe('getBuildInfo', function () { async function verifyBuildInfoUpdate (useLocalGit) { - const buildInfo = await getBuildInfo(); + const buildInfo = getBuildInfo(); mockFs.expects('exists').atLeast(1).returns(useLocalGit); buildInfo['git-sha'] = undefined; buildInfo.built = undefined; @@ -118,9 +118,9 @@ describe('Config', function () { sinon.spy(console, "log"); }); it('should log the config to console', async function () { - const config = await getBuildInfo(); + const config = getBuildInfo(); await showConfig(); - console.log.calledOnce.should.be.true; // eslint-disable-line no-console + console.log.calledOnce.should.be.true; // eslint-disable-line no-console console.log.getCall(0).args[0].should.contain(JSON.stringify(config)); // eslint-disable-line no-console }); }); @@ -136,10 +136,10 @@ describe('Config', function () { for (let [prop, value] of _.toPairs(process)) { tempProcess[prop] = value; } - process = tempProcess; + process = tempProcess; // eslint-disable-line no-global-assign }); after(function () { - process = _process; + process = _process; // eslint-disable-line no-global-assign }); describe('checkNodeOk', function () { it('should fail if node is below 6', function () { @@ -259,13 +259,13 @@ describe('Config', function () { }); describe('validateTmpDir', function () { - it('should fail to use a tmp dir with incorrect permissions', async function () { + it('should fail to use a tmp dir with incorrect permissions', function () { validateTmpDir('/private/if_you_run_with_sudo_this_wont_fail').should.be.rejectedWith(/could not ensure/); }); - it('should fail to use an undefined tmp dir', async function () { + it('should fail to use an undefined tmp dir', function () { validateTmpDir().should.be.rejectedWith(/could not ensure/); }); - it('should be able to use a tmp dir with correct permissions', async function () { + it('should be able to use a tmp dir with correct permissions', function () { validateTmpDir('/tmp/test_tmp_dir/with/any/number/of/levels').should.not.be.rejected; }); }); diff --git a/test/driver-e2e-specs.js b/test/driver-e2e-specs.js index e27973830..87294f9a5 100644 --- a/test/driver-e2e-specs.js +++ b/test/driver-e2e-specs.js @@ -105,14 +105,14 @@ describe('FakeDriver - via HTTP', function () { }); // Now use that sessionId to call /screenshot - const {status:screenshotStatus, value:screenshotValue} = await request({url: `${baseUrl}/${value.sessionId}/screenshot`, json: true}); + const {status: screenshotStatus, value: screenshotValue} = await request({url: `${baseUrl}/${value.sessionId}/screenshot`, json: true}); should.not.exist(screenshotStatus); screenshotValue.should.equal('hahahanotreallyascreenshot'); // Now use that sessionID to call an arbitrary W3C-only endpoint that isn't implemented to see if it responds with correct error const {statusCode, error} = await request.post({url: `${baseUrl}/${value.sessionId}/execute/async`, json: {script: '', args: ['a']}}).should.eventually.be.rejected; statusCode.should.equal(404); - const {error:errorMessage, message, stacktrace} = error.value; + const {error: errorMessage, message, stacktrace} = error.value; errorMessage.should.match(/unknown method/); message.should.match(/Method has not yet been implemented/); stacktrace.should.match(/FakeDriver.executeCommand/); @@ -287,7 +287,7 @@ describe('FakeDriver - via HTTP', function () { }; // Have an MJSONWP and W3C session running concurrently - const {sessionId:mjsonwpSessId, value:mjsonwpValue, status} = await request.post({url: baseUrl, json: _.omit(combinedCaps, 'capabilities')}); + const {sessionId: mjsonwpSessId, value: mjsonwpValue, status} = await request.post({url: baseUrl, json: _.omit(combinedCaps, 'capabilities')}); status.should.exist; mjsonwpValue.should.eql(caps); mjsonwpSessId.should.exist; @@ -335,7 +335,7 @@ describe('Logsink', function () { await server.close(); }); - it('should send logs to a logHandler passed in by a parent package', async function () { + it('should send logs to a logHandler passed in by a parent package', function () { logs.length.should.be.above(1); let welcomeIndex = logs[0][1].includes('versions of node') ? 1 : 0; logs[welcomeIndex].length.should.equal(2); diff --git a/test/driver-specs.js b/test/driver-specs.js index 194a560f9..84c6dc738 100644 --- a/test/driver-specs.js +++ b/test/driver-specs.js @@ -24,7 +24,7 @@ describe('AppiumDriver', function () { let fakeDriver = new FakeDriver(); let mockFakeDriver = sinon.mock(fakeDriver); appium.getDriverForCaps = function (/*args*/) { - return () => { + return function Driver () { return fakeDriver; }; }; @@ -41,16 +41,16 @@ describe('AppiumDriver', function () { await appium.deleteSession(SESSION_ID); }); - it('should call inner driver\'s createSession with desired capabilities', async function () { + it(`should call inner driver's createSession with desired capabilities`, async function () { mockFakeDriver.expects("createSession") .once().withExactArgs(BASE_CAPS, undefined, null, []) .returns([SESSION_ID, BASE_CAPS]); await appium.createSession(BASE_CAPS); mockFakeDriver.verify(); }); - it('should call inner driver\'s createSession with desired and default capabilities', async function () { - let defaultCaps = {deviceName: 'Emulator'} - , allCaps = _.extend(_.clone(defaultCaps), BASE_CAPS); + it(`should call inner driver's createSession with desired and default capabilities`, async function () { + let defaultCaps = {deviceName: 'Emulator'}; + let allCaps = _.extend(_.clone(defaultCaps), BASE_CAPS); appium.args.defaultCapabilities = defaultCaps; mockFakeDriver.expects("createSession") .once().withArgs(allCaps) @@ -58,7 +58,7 @@ describe('AppiumDriver', function () { await appium.createSession(BASE_CAPS); mockFakeDriver.verify(); }); - it('should call inner driver\'s createSession with desired and default capabilities without overriding caps', async function () { + it(`should call inner driver's createSession with desired and default capabilities without overriding caps`, async function () { // a default capability with the same key as a desired capability // should do nothing let defaultCaps = {platformName: 'Ersatz'}; @@ -73,9 +73,11 @@ describe('AppiumDriver', function () { appium.args.sessionOverride = true; // mock three sessions that should be removed when the new one is created - let fakeDrivers = [new FakeDriver(), - new FakeDriver(), - new FakeDriver()]; + let fakeDrivers = [ + new FakeDriver(), + new FakeDriver(), + new FakeDriver(), + ]; let mockFakeDrivers = _.map(fakeDrivers, (fd) => {return sinon.mock(fd);}); mockFakeDrivers[0].expects('deleteSession') .once(); @@ -182,7 +184,7 @@ describe('AppiumDriver', function () { sessions.should.have.length(0); }); it('should call inner driver\'s deleteSession method', async function () { - const [sessionId] = (await appium.createSession(BASE_CAPS)).value; + const [sessionId] = (await appium.createSession(BASE_CAPS)).value; mockFakeDriver.expects("deleteSession") .once().withExactArgs(sessionId, []) .returns(); @@ -236,8 +238,8 @@ describe('AppiumDriver', function () { describe('sessionExists', function () { }); describe('attachUnexpectedShutdownHandler', function () { - let appium - , mockFakeDriver; + let appium; + let mockFakeDriver; beforeEach(function () { [appium, mockFakeDriver] = getDriverAndFakeDriver(); }); @@ -273,11 +275,11 @@ describe('AppiumDriver', function () { }); }); describe('getDriverForCaps', function () { - it('should not blow up if user does not provide platformName', async function () { + it('should not blow up if user does not provide platformName', function () { let appium = new AppiumDriver({}); (() => { appium.getDriverForCaps({}); }).should.throw(/platformName/); }); - it('should get XCUITestDriver driver for automationName of XCUITest', async function () { + it('should get XCUITestDriver driver for automationName of XCUITest', function () { let appium = new AppiumDriver({}); let driver = appium.getDriverForCaps({ platformName: 'iOS', @@ -286,7 +288,7 @@ describe('AppiumDriver', function () { driver.should.be.an.instanceof(Function); driver.should.equal(XCUITestDriver); }); - it('should get iosdriver for ios < 10', async function () { + it('should get iosdriver for ios < 10', function () { let appium = new AppiumDriver({}); let caps = { platformName: 'iOS', @@ -316,7 +318,7 @@ describe('AppiumDriver', function () { driver = appium.getDriverForCaps(caps); driver.should.equal(IosDriver); }); - it('should get xcuitestdriver for ios >= 10', async function () { + it('should get xcuitestdriver for ios >= 10', function () { let appium = new AppiumDriver({}); let caps = { platformName: 'iOS', diff --git a/test/helpers.js b/test/helpers.js index cf9b394c9..c042384c3 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -28,7 +28,7 @@ function initSession (caps) { const BASE_CAPS = {platformName: 'Fake', deviceName: 'Fake', app: TEST_FAKE_APP}; const W3C_PREFIXED_CAPS = {...insertAppiumPrefixes(BASE_CAPS)}; const W3C_CAPS = { - alwaysMatch:{...W3C_PREFIXED_CAPS}, + alwaysMatch: {...W3C_PREFIXED_CAPS}, firstMatch: [{}], }; diff --git a/test/parser-specs.js b/test/parser-specs.js index 546d03803..09fee0e73 100644 --- a/test/parser-specs.js +++ b/test/parser-specs.js @@ -25,14 +25,12 @@ describe('Parser', function () { }); it('should parse default capabilities correctly from a string', function () { let defaultCapabilities = {a: 'b'}; - let args = p.parseArgs(['--default-capabilities', - JSON.stringify(defaultCapabilities)]); + let args = p.parseArgs(['--default-capabilities', JSON.stringify(defaultCapabilities)]); args.defaultCapabilities.should.eql(defaultCapabilities); }); it('should parse default capabilities correctly from a file', function () { let defaultCapabilities = {a: 'b'}; - let args = p.parseArgs(['--default-capabilities', - 'test/fixtures/caps.json']); + let args = p.parseArgs(['--default-capabilities', 'test/fixtures/caps.json']); args.defaultCapabilities.should.eql(defaultCapabilities); }); it('should throw an error with invalid arg to default capabilities', function () { diff --git a/test/shrinkwrap-specs.js b/test/shrinkwrap-specs.js index c0827cadc..d0eb6654f 100644 --- a/test/shrinkwrap-specs.js +++ b/test/shrinkwrap-specs.js @@ -9,11 +9,11 @@ chai.use(chaiAsPromised); const expect = chai.expect; describe.skip('shrinkwrap checks', function () { - it('shrinkwrap file should exist', async function () { + it('shrinkwrap file should exist', function () { require('../../npm-shrinkwrap.json'); }); - it('shrinkwrap should not include fsevents', async function () { + it('shrinkwrap should not include fsevents', function () { // fsevents is an optional dep that only works on Mac. // if it's in shrinkwrap, non-Mac hosts won't be able to install appium let shrinkwrap = require('../../npm-shrinkwrap.json');