This change removes `gulp` and replaces it with plain ol' `babel` and `mocha`.
## `appium`
- No gulp.
- `test/` has been re-organized. All test files now end in the extension `.spec.js`, which is a recognized convention and understood by editors/IDEs. The tests are further split into `unit` and `e2e` subdirs. This makes working with both `babel` and `mocha` easier.
- The tests are _not_ run against the transpiled code; code is now transpiled on-the-fly via `@babel/register`. This only affects `appium`.
- `commands-yml/validator.js` moved to `scripts/parse-yml-commands.js`. It has been rewritten as a CJS module. `commands-yml/` should not contain `.js` files.
- `test/setup.js` is a new test harness specific to Appium, which loads & configures `@babel/register`. Eventually, the contents of this file can be moved into the root monorepo's `test/setup.js`, but the rest of the packages do not need `@babel/register`, so we avoid the overhead.
## `@appium/gulp-plugins`
- Unfortunately, due to the new `npm test` strategy (see below), we cannot use the `nyan` reporter. Or rather, we _can_, but will not see the animation. So the reporter is now set to default to `spec`.
- Modified tests so they didn't overwrite the actual `build` dir with transpiled fixtures, which is what was happening. This was causing failures depending on the transpile/test order.
## All Packages
- All packages now have their own `build`, `test`, `test:e2e` and `dev` (just build + watch mode) npm scripts. This makes running a complete build easier, since each package can now provide its own appropriate command. This is _mostly_ just `gulp once` (where `gulp` was used before), except for `appium`, where `@babel/cli` is used directly.
- This is what happens when `npm test` is run from the monorepo (in order):
1. All packages are built (in parallel) by running `npm run build` in each folder (via `lerna`). See `pretest`
2. All code is linted directly via `eslint`.
3. All _unit tests_ are run w/ `npm test` in each folder, having assumed transpilation already occurred (if necessary).
- `npm run e2e-test` runs the `npm run test:e2e` in each folder. No transpilation occurs! Careful.
- All scripts are expected to live in `packages/*/scripts`, and this directory enforces CJS via ESLint. `postinstall.js` moved, as well as `check-npm-pack-files.js`. `generate-schema-declarations.mjs` moved from the root `scripts/` dir into `packages/appium/scripts/`; it's now CJS instead of ESM.
- I had profiled running various things with `lerna run --parallel`, but it turns out this is not faster. I'm not sure why, but I think it may have something to do with streaming STDOUT/STDERR, or potentially the overhead of running child processes outweighs the time it takes to actually run tests and builds.
- The behavior of `lerna run` now mimicks `lerna exec`, which was "run stuff in serial, streaming the output". The default behavior of `lerna run` is "run stuff in parallel, buffering the output". Buffered output sucks, and streaming the output from all tasks at once creates chaos. To override this behavior, you'll see `--parallel --concurrency=8 --prefix` for tasks that can truly be parallelized, like transpilation. The number 8 is the "maximum", and CI usually won't have more than 2 cores available anyway.
- When run in CI, Mocha runs with `--forbid-only`, which will fail if there's an `.only()` somewhere in the tests. Further, it forces color output.
## Etc.
- Updated Wallaby config, `.gitignore`, `.eslintignore`.
- Sorted `package.json` files
- Removed `watch` and `coverage` scripts which were broken anyway.
chore(appium): fix schema json path issues
- the path to the JSON schema is now correct: `lib/appium-config-schema.json`
- add `log-symbols` to devdeps for niceness. this is already a transitive dep
This should (hopefully) fix the Lerna issues we've been encountering. With this change, the root monorepo lists all packages as dependencies and uses relative `file:` URLs to do so. This means `lerna bootstrap` is no longer necessary.
In addition, defaults to `--save-exact` in `npm install` and `lerna add`. Also installs peer dependencies of `@appium/eslint-config-appium`.
1. Uses `sync-monorepo-packages` to keep `README.md` and `packages/appium/README.md` in sync. Since `README` gets published to npm but _also_ shows in the GitHub repo, both places need a `README`. In lieu of a custom `README`, we can just sync it for now. This is called via a `preversion` script.
1. Various fields are synced in `package.json`. This does not include dependencies—but those _in common_ should probably be kept in sync as well.
1. Lerna uses conventional commits and Git tags to figure out what to do. It should automatically determine what needs releasing and what version it should be released as.
1. Tags have been pushed to the repo for Lerna to use. In the case where the changesets are functionally identical to the latest code in the old repositories, the version number has been retained, and the tag is of the format `[@scope/]<package-name>@<version>`. In the case where the old repos had _unreleased_ changesets, I’ve tagged with a new patch release and adopted the `-rc.0` suffix. So if we were at v5.5.0 in `appium-gulp-plugins`, `@appium/gulp-plugins` is tagged as `@appium/gulp-plugins@5.5.1-rc.0`. I have not modified the version in `package.json`.
1. As with adopting any new release/publishing strategy, we should be meticulous about what we’re doing until we’re comfortable with how it works. Lerna supports dry runs; we should use them.
1. Documentation on usage will arrive in next changes to this PR.
this pkg is unique in that it does not use `gulp`, so for now we tell lerna to always ignore it when running `lerna exec` across packages. it has no tests, but it's marginally useful to lint the `index.js`, so we'll do that (see `lint` script in root `package.json`).
the canonical way to handle plugin deps in a sharable config is to use `peerDependencies`, so it now uses `peerDependencies` instead of `dependencies`. these peer deps are installed by the dependencies of `@appium-gulp-plugins`. see [docs](https://eslint.org/docs/developer-guide/shareable-configs#publishing-a-shareable-config)
our root `.eslintrc` depends upon `@appium/eslint-config-appium` (which is not an unusual situation). to pull this off in a monorepo, a cheat is to `file:` schema in the dependency specifier of the root `package.json`.
also tweaked `lerna.json` to _always_ run `bootstrap` with the `--no-ci` flag. lerna will attempt to use `npm ci` if `CI` env var is present, but for that to work, we must have `package-lock.json` under version control.
This PR supersedes PR #14562.
This is my first attempt at making this repo a monorepo and moving appium-proper into `packages/appium`.
I had tried to make this work with npm's "workspaces", but it seems lifecycle scripts don't run as you'd expect them to upon install. Instead, I'm using Lerna, which provides more features for monorepos.
Changes include:
- The root `package.json` is now a package named `appium-monorepo`, which is `private`. The monorepo should not be published.
- All dev dependencies remain in the root `package.json`.
- `gulpfile.js` _moved_ into `packages/appium/gulpfile.js`, but this should be **temporary**--`appium-gulp-plugins` makes certain assumptions which a monorepo violates, and I was unable to get it working without patching `appium-gulp-plugins`.
- Most of the `package.json` `scripts` moved into `packages/appium/package.json` due to the above. This too should be considered **temporary**.
- Adds a root `postinstall` lifecycle script which calls `lerna bootstrap` to install/link packages. I don't see a `package-lock.json` in `packages/appium/`; this needs investigating.
- Adds a root `test` lifecycle script which executes `npm run test` in all packages. The tests do not pass, but I don't know if this is my fault.
- The `clean` script will purge all `node_modules` folders in each package, as well.
- I removed `scripts/release*.sh`, since it seems they would fail anyway--`lerna` should be used for releases instead
- The shrinkwrap-related stuff is untested.
- Renamed `tags` prop in `packages/appium/package.json` to `keywords`. I don't know if `tags` is supported.