Skip to content
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

chore: build with typescript instead of babel #813

Merged
merged 1 commit into from
May 25, 2023
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
5 changes: 3 additions & 2 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
require: ['@babel/register'],
forbidOnly: Boolean(process.env.CI)
require: ['ts-node/register'],
forbidOnly: Boolean(process.env.CI),
color: true
};
25 changes: 0 additions & 25 deletions babel.config.json

This file was deleted.

4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node
// transpile:main
import {install} from 'source-map-support';
install();

import * as driver from './lib/driver';
import * as androidHelperIndex from './lib/android-helpers';
import * as commandIndex from './lib/commands/index';
Expand Down
3 changes: 2 additions & 1 deletion lib/android-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import Bootstrap from './bootstrap';
import B from 'bluebird';
import ADB from 'appium-adb';
import {
default as unlocker, PIN_UNLOCK, PIN_UNLOCK_KEY_EVENT,
helpers as unlocker,
PIN_UNLOCK, PIN_UNLOCK_KEY_EVENT,
PASSWORD_UNLOCK, PATTERN_UNLOCK, FINGERPRINT_UNLOCK
} from './unlock-helpers';
import { EOL } from 'os';
Expand Down
8 changes: 8 additions & 0 deletions lib/stubs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* This module contains delcaration stubs for dependencies that are untyped.
* @module
*/

declare module 'appium-adb';
declare module 'shared-preferences-builder';
declare module 'io.appium.settings';
4 changes: 2 additions & 2 deletions lib/unlock-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const UNLOCK_WAIT_TIME = 100;
const INPUT_KEYS_WAIT_TIME = 100;
const NUMBER_ZERO_KEYCODE = 7;

const helpers = {};
export const helpers = {};

helpers.validateUnlockCapabilities = function validateUnlockCapabilities (caps = {}) {
const {
Expand Down Expand Up @@ -273,6 +273,6 @@ helpers.FINGERPRINT_UNLOCK = FINGERPRINT_UNLOCK;

export {
PIN_UNLOCK, PIN_UNLOCK_KEY_EVENT, PASSWORD_UNLOCK, PATTERN_UNLOCK,
FINGERPRINT_UNLOCK, helpers
FINGERPRINT_UNLOCK
};
export default helpers;
35 changes: 22 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"CHANGELOG.md"
],
"dependencies": {
"@babel/runtime": "^7.0.0",
"appium-adb": "^9.11.2",
"appium-chromedriver": "^5.2.0",
"asyncbox": "^2.8.0",
Expand All @@ -60,21 +59,23 @@
"moment-timezone": "^0.5.26",
"portfinder": "^1.0.6",
"portscanner": "2.2.0",
"semver": "^7.0.0",
"shared-preferences-builder": "^0.x",
"sharp": "^0.x",
"semver": "^7.0.0",
"source-map-support": "^0.x",
"teen_process": "^2.0.0",
"ws": "^8.0.0"
},
"scripts": {
"build": "rimraf build && babel --out-dir=build/lib lib && babel --out-dir=build index.js",
"build": "tsc -b",
"clean": "npm run build -- --clean",
"dev": "npm run build -- --watch",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"precommit-msg": "echo 'Pre-commit checks...' && exit 0",
"precommit-lint": "lint-staged",
"prepare": "npm run build",
"prepare": "npm run rebuild",
"rebuild": "npm run clean && npm run build",
"test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.js\"",
"e2e-test": "mocha --exit --timeout 10m \"./test/functional/**/*-specs.js\""
},
Expand All @@ -86,20 +87,27 @@
"appium": "^2.0.0-beta.40"
},
"devDependencies": {
"@appium/support": "^4.0.0",
"@appium/eslint-config-appium": "^6.0.0",
"@appium/support": "^4.0.0",
"@appium/test-support": "^3.0.0",
"@babel/cli": "^7.18.10",
"@babel/core": "^7.18.10",
"@babel/eslint-parser": "^7.18.9",
"@babel/plugin-transform-runtime": "^7.18.10",
"@babel/preset-env": "^7.18.10",
"@babel/register": "^7.18.9",
"@appium/tsconfig": "^0.3.0",
"@appium/types": "^0.11.1",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@types/bluebird": "^3.5.38",
"@types/chai": "^4.3.5",
"@types/chai-as-promised": "^7.1.5",
"@types/lodash": "^4.14.194",
"@types/mocha": "^10.0.1",
"@types/node": "^20.2.3",
"@types/portscanner": "^2.1.1",
"@types/semver": "^7.5.0",
"@types/sinon": "^10.0.15",
"@types/source-map-support": "^0.5.6",
"@types/teen_process": "^2.0.0",
"@types/ws": "^8.5.4",
"@xmldom/xmldom": "^0.x",
"android-apidemos": "^4.1.0",
"babel-plugin-source-map-support": "^2.2.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"conventional-changelog-conventionalcommits": "^5.0.0",
Expand All @@ -110,11 +118,12 @@
"eslint-plugin-promise": "^6.0.0",
"lint-staged": "^13.0.3",
"mocha": "^10.0.0",
"mock-fs": "^5.0.0",
"pre-commit": "^1.1.3",
"rimraf": "^5.0.0",
"semantic-release": "^20.0.2",
"sinon": "^15.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"xpath": "^0.x"
}
}
2 changes: 0 additions & 2 deletions test/functional/bootstrap/bootstrap-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// transpile :mocha

import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { AndroidBootstrap, COMMAND_TYPES } from '../../../lib/bootstrap';
Expand Down
2 changes: 0 additions & 2 deletions test/functional/bootstrap/uiautomator-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// transpile :mocha

import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { UiAutomator } from '../../../lib/uiautomator';
Expand Down
2 changes: 0 additions & 2 deletions test/unit/bootstrap/bootstrap-specs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// transpile :mocha

import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { AndroidBootstrap, COMMAND_TYPES } from '../../../lib/bootstrap';
Expand Down
2 changes: 0 additions & 2 deletions test/unit/bootstrap/uiautomator-specs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// transpile :mocha

import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinon from 'sinon';
Expand Down
13 changes: 13 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@appium/tsconfig/tsconfig.json",
"compilerOptions": {
"outDir": "build",
"types": ["node", "mocha", "chai", "chai-as-promised", "sinon"]
},
"include": [
"index.js",
"lib",
"test"
]
}