Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor: Decouple the module from @appium/gulp-plugins #70

Merged
merged 4 commits into from
Aug 24, 2022
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
coverage
build
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@appium/eslint-config-appium",
"overrides": [
{
"files": "test/**/*.js",
"rules": {
"func-names": "off"
}
}
]
}
9 changes: 4 additions & 5 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
name: Node.js CI
on: [push, pull_request]
env:
NODE_VERSION: 14.x
NODE_VERSION: 16.x

jobs:
build:

# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md
runs-on: macos-10.15
runs-on: macos-11

strategy:
matrix:
xcode-version: ["10.3", "11.7", "12.4"]
xcode-version: ["11.7", "12.4", "13.2"]

steps:
- uses: actions/checkout@v2
Expand All @@ -21,5 +20,5 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
- name: Select Xcode ${{ matrix.xcode-version }}
run: sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode-version }}.app
- run: npm run clean
- run: npm install
- run: _FORCE_LOGS=1 npm run test
4 changes: 2 additions & 2 deletions .github/workflows/publish.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 18.x
- run: npm install --no-package-lock
name: Install dev dependencies
- run: npm test
Expand Down
4 changes: 4 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
require: ['@babel/register'],
forbidOnly: Boolean(process.env.CI)
};
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ appium-xcode
ES7 module for interacting with Xcode and Xcode-related functions.
Used by [Appium](github.com/appium/appium)

*Note*: Issue tracking for this repo has been disabled. Please use the [main Appium issue tracker](https://github.com/appium/appium/issues) instead.

API
===

Expand Down Expand Up @@ -66,21 +64,16 @@ clears the internal cache used for memoizing functions.
Develop
=======

## Watch

```
npm run watch
```

## Test

```
npm test
npm e2e-test
```

Debug
=====

After cloning appium-xcode, execute `npm link` in the appium-xcode directory. Next run `npm link appium-xcode` from the appium directory. This will symlink appium-xcode to node_modules/appium-xcode. If the clone becomes out of date remember to unlink or delete node_modules and reinstall.

For quick debugging you could cd into the node_modules/appium-xcode folder and run `npm install` followed by `gulp transpile`.
For quick debugging you could cd into the node_modules/appium-xcode folder and run `npm install` followed by `npm run build`.
25 changes: 25 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "14"
},
"shippedProposals": true
}
]
],
"plugins": [
"source-map-support",
"@babel/plugin-transform-runtime"
],
"comments": false,
"sourceMaps": "both",
"env": {
"test": {
"retainLines": true,
"comments": true
}
}
}
14 changes: 0 additions & 14 deletions gulpfile.js

This file was deleted.

9 changes: 7 additions & 2 deletions lib/xcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,16 @@ async function getPathFromXcodeSelect (timeout = XCRUN_TIMEOUT) {
const getPath = _.memoize(function getPath (timeout = XCRUN_TIMEOUT) {
// first we try using xcode-select to find the path
// then we try using the symlinks that Apple has by default
return getPathFromXcodeSelect(timeout).catch(getPathFromSymlink);
return (async () => {
try {
return await getPathFromXcodeSelect(timeout);
} catch (e) {
return await getPathFromSymlink(e.message);
}
})();
});



async function getVersionWithoutRetry (timeout = XCRUN_TIMEOUT) {
const xcodePath = await getPath(timeout);

Expand Down
54 changes: 37 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"xcode"
],
"version": "4.0.0",
"author": "appium",
"author": "Appium Contributors",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand All @@ -16,9 +16,10 @@
"bugs": {
"url": "https://github.com/appium/appium-xcode/issues"
},
"engines": [
"node"
],
"engines": {
"node": ">=14",
"npm": ">=8"
},
"main": "./build/index.js",
"bin": {},
"directories": {
Expand All @@ -41,32 +42,51 @@
"teen_process": "^2.0.0"
},
"scripts": {
"clean": "rm -rf node_modules && rm -f package-lock.json && npm install",
"prepare": "gulp prepublish",
"test": "gulp once",
"watch": "gulp watch",
"mocha": "mocha",
"build": "gulp transpile",
"e2e-test": "gulp e2e-test",
"coverage": "gulp coveralls",
"build": "rm -rf build && babel --out-dir=build/lib lib && babel --out-dir=build index.js",
"dev": "npm run build -- --watch",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"precommit-lint": "lint-staged",
"precommit-msg": "echo 'Pre-commit checks...' && exit 0",
"lint": "gulp lint",
"lint:fix": "gulp eslint --fix"
"prepare": "npm run build",
"test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.js\"",
"e2e-test": "mocha --exit --timeout 5m \"./test/e2e/**/*-specs.js\""
},
"pre-commit": [
"precommit-msg",
"test"
"precommit-lint"
],
"lint-staged": {
"*.js": [
"eslint --fix"
]
},
"prettier": {
"bracketSpacing": false,
"printWidth": 100,
"singleQuote": true
},
"devDependencies": {
"@appium/gulp-plugins": "^7.0.0",
"@appium/eslint-config-appium": "^6.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",
"@semantic-release/git": "^10.0.1",
"babel-plugin-source-map-support": "^2.2.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"gulp": "^4.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-mocha": "^9.0.0",
"eslint-plugin-promise": "^6.0.0",
"lint-staged": "^13.0.3",
"mocha": "^10.0.0",
"pre-commit": "^1.1.3",
"prettier": "^2.7.1",
"semantic-release": "^19.0.2"
}
}
5 changes: 0 additions & 5 deletions test/.eslintrc

This file was deleted.

4 changes: 1 addition & 3 deletions test/xcode-specs.js → test/e2e/xcode-specs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// transpile:mocha

import xcode from '../index';
import xcode from '../../index';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { fs, util } from '@appium/support';
Expand Down
4 changes: 1 addition & 3 deletions test/index-specs.js → test/unit/index-specs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// transpile:mocha

import xcode from '../index.js';
import xcode from '../../index.js';
import chai from 'chai';

chai.should();
Expand Down