chore: correctly configure monorepo to do away with unnecessary deps and consolidate strategies
DELETE
packages/appium-plugins/.eslintignore
-node_modules

MODIFY
packages/appium-plugins/.eslintrc
packages/appium-plugins/.eslintrc
{
- "extends": "appium"
+ "extends": "appium",
+ "root": true,
+ "ignorePatterns": ["node_modules", "packages/*/node_modules", "packages/*/build"]
}

MODIFY
packages/appium-plugins/.gitignore
packages/appium-plugins/.gitignore
@@ -14,3 +14,4 @@ package-lock.json
build/
.idea
*DerivedData
+.eslintcache

MODIFY
packages/appium-plugins/package.json
packages/appium-plugins/package.json
"name": "appium-plugins-monorepo",
"private": true,
"devDependencies": {
- "appium-gulp-plugins": "^5.2.1",
+ "chai": "4.x",
+ "chai-as-promised": "7.x",
"eslint": "^7.14.0",
"eslint-config-appium": "^4.5.0",
"lerna": "^3.22.1",
- "chai": "4.x",
- "chai-as-promised": "7.x",
- "gulp": "^4.0.0",
"mocha": "^7.0.1",
+ "npm-run-all": "^4.1.5",
"pre-commit": "1.x",
- "sinon": "^9.0.0"
+ "rimraf": "^3.0.2",
+ "shelljs": "^0.8.4",
+ "sinon": "^9.0.0",
+ "ts-mocha": "^8.0.0",
+ "typescript": "^4.1.2"
},
"scripts": {
- "lint": "lerna run lint",
- "precommit-msg": "echo 'Pre-commit checks...' && exit 0",
- "precommit-test": "lerna run test"
+ "clean": "run-p clean:* && npm install && npm run bootstrap",
+ "clean:modules": "rimraf node_modules && rimraf packages/*/node_modules",
+ "clean:pkglock": "rimraf package-lock.json && rimraf packages/*/package-lock.json",
+ "build": "node ./scripts/build.js",
+ "watch": "node ./scripts/build.js --watch",
+ "bootstrap": "lerna bootstrap --hoist",
+ "test:lint": "eslint --cache packages",
+ "test:unit": "lerna run test:unit",
+ "test:e2e": "lerna run test:e2e",
+ "precommit:msg": "echo 'Running pre-commit checks...' && exit 0",
+ "precommit:test": "npm run test:lint && npm run test:unit"
},
"pre-commit": [
- "precommit-msg",
- "precommit-test"
+ "precommit:msg",
+ "precommit:test"
]
}

DELETE
packages/appium-plugins/packages/base/gulpfile.js
-/* eslint no-console:0 */
-/* eslint-disable promise/prefer-await-to-callbacks */
-'use strict';
-
-const gulp = require('gulp');
-const boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp);
-
-boilerplate({
- build: 'appium-base-plugin',
- projectRoot: __dirname,
- files: [
- '*.js',
- 'lib/**/*.js',
- 'test/**/*.js',
- '!gulpfile.js',
- ],
- test: {
- files: ['${testDir}/**/*-specs.js']
- },
- testTimeout: 160000,
- preCommitTasks: ['eslint', 'once'],
-});

MODIFY
packages/appium-plugins/packages/base/package.json
packages/appium-plugins/packages/base/package.json
"appium"
],
"version": "1.5.0",
- "author": "https://github.com/appium",
+ "author": "Appium <maintainers@appium.io>",
"license": "Apache-2.0",
"repository": {
"type": "git",
"build"
],
"dependencies": {
- "@babel/runtime": "^7.6.0",
- "appium-support": "^2.48.0",
- "source-map-support": "0.x"
+ "appium-support": "^2.48.0"
},
"scripts": {
- "clean": "rm -rf node_modules && rm -f package-lock.json && npm install",
- "prepare": "gulp prepublish",
- "test": "gulp once",
- "e2e-test": "gulp e2e-test",
- "watch": "gulp watch",
- "build": "gulp transpile",
- "lint": "gulp lint",
- "lint:fix": "gulp lint --fix",
- "coverage": "gulp coveralls"
+ "test:unit": "mocha ./build/test/unit/*-specs.js",
+ "test:e2e": "ts-mocha test/e2e/*-specs.js"
+ },
+ "devDependencies": {
}
}

RENAME
packages/appium-plugins/packages/base/test/plugin-specs.js
packages/appium-plugins/packages/base/test/unit/plugin-specs.js
-import BasePlugin from '..';
+import BasePlugin from '../../index';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';

ADD
packages/appium-plugins/packages/base/tsconfig.json
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./build",
+ "sourceRoot": "."
+ },
+ "include": [
+ "./index.js",
+ "./lib/**/*",
+ "./test/**/*"
+ ],
+ "exclude": [
+ "build/*",
+ "./node_modules"
+ ]
+}

ADD
packages/appium-plugins/packages/images/index.js
+import ImageElementPlugin from './lib/plugin';
+export default ImageElementPlugin;

ADD
packages/appium-plugins/packages/images/lib/plugin.js
+import BasePlugin from '@appium/base-plugin';
+
+export default class ImageElementPlugin extends BasePlugin {
+}

MODIFY
packages/appium-plugins/packages/images/package.json
packages/appium-plugins/packages/images/package.json
"@appium/base-plugin": "^1.5.0"
},
"scripts": {
- "clean": "rm -rf node_modules && rm -f package-lock.json && npm install",
- "prepare": "npm run build",
- "test": "mocha test/unit/*-specs.js",
- "e2e-test": "mocha test/e2e/*-specs.js",
- "lint": "eslint **/*.js"
+ "test:unit": "ts-mocha test/unit/*-specs.js",
+ "test:e2e": "ts-mocha test/e2e/*-specs.js"
+ },
+ "devDependencies": {
}
}

MODIFY
packages/appium-plugins/packages/images/test/unit/basic-specs.js
packages/appium-plugins/packages/images/test/unit/basic-specs.js
-describe('Stub', function () {
- it('should do nothing', function () {
+import ImageElementPlugin from '../../index';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+
+chai.use(chaiAsPromised);
+const should = chai.should();
+
+
+describe('ImageElementPlugin', function () {
+ it('should exist', function () {
+ should.exist(ImageElementPlugin);
});
});

ADD
packages/appium-plugins/packages/images/tsconfig.json
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./build"
+ },
+ "include": [
+ "./*.js",
+ "./lib/**/*",
+ "./test/**/*"
+ ],
+ "exclude": [
+ "./build",
+ "./node_modules"
+ ]
+}

ADD
packages/appium-plugins/scripts/build.js
+#!/usr/bin/env node
+
+const path = require('path');
+const shell = require('shelljs');
+
+const args = process.argv.slice(2);
+const HAS_WATCH_FLAG = args[0] === '--watch';
+
+if (HAS_WATCH_FLAG) {
+ args.shift();
+}
+
+const packages = shell.ls(path.join(__dirname, '..', 'packages'))
+ .filter((pkg) => pkg !== 'node_modules')
+ .filter((pkg) => args.length === 0 || args.includes(pkg));
+
+shell.cd(path.join(__dirname, '..'));
+const buildSpec = `${packages.map((pkg) => `packages/${pkg}`).join(' ')}`;
+const cmd = `npx tsc -b ${buildSpec}${HAS_WATCH_FLAG ? ' --watch' : ''}`;
+
+console.log(cmd); // eslint-disable-line no-console
+const { code } = shell.exec(cmd);
+
+if (code) {
+ throw new Error('Failed compiling TypeScript files!');
+}

ADD
packages/appium-plugins/tsconfig.json
+{
+ "compilerOptions": {
+ "allowJs": true,
+ "inlineSourceMap": true,
+ "moduleResolution": "Node",
+ "module": "CommonJS",
+ "esModuleInterop": true,
+ "target": "ES2016"
+ }
+}

chore: correctly configure monorepo to do away with unnecessary deps and consolidate strategies