Commit Graph

11 Commits

Author SHA1 Message Date
Christopher Hiller 133db5355f chore: reformat everything
this reformats all `.js`, `.ts`, and `.d.ts` files.
2022-05-09 19:09:50 -07:00
Christopher Hiller 868517b6f4 chore: remove gulp from appium package (#16459)
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
2022-03-09 14:50:45 -08:00
Christopher Hiller f9de06341d chore(gulp-plugins): replace find-root with pkg-dir
`find-root` is unmaintained
2022-03-09 14:50:45 -08:00
Christopher Hiller b3771b0042 fix(gulp-plugins): do not transpile pkg root .js files by default
BREAKING CHANGE:

Package-root `.js` files (typically `index.js`) are now (typically) cjs wrappers.  These files needn't be transpiled, and in fact, doing so will create an invalid module because it will attempt to reference `build/whatever` but the resulting artifact would live in `build/index.js`.  `build/index.js` will no longer exist.
2021-11-18 12:08:50 -08:00
Christopher Hiller 0ef53d4e99 fix(gulp-plugins): fix potential race condition re: gulpfile.js
the `configure()` function in the spawn watcher could fail in some circumstances because because the task created by the call to `this.gulp.watch('./gulpfile.js')` does not actually signal completion, which can cause gulp to fail with a "did you forget to signal async completion?" error.

instead of trying to watch gulpfiles, we can just ignore them.  not ideal, but at least it won't break.
2021-11-09 11:57:26 -08:00
Christopher Hiller a91bec3456 chore(gulp-plugins): postTranspile task always runs after transpile task; add dev task
- `postTranspile` would only run from certain _other_ tasks (like `test`).  This seemed incorrect, so now it runs after `transpile`, regardless of what task (or human) runs `transpile`.
- Added a `dev` task, which is like `watch`, except does not run tests (only transpiles)
2021-10-20 16:02:32 -07:00
Christopher Hiller 6c769a2b7c chore: housecleaning
Just a bunch of random (mostly path-related) fixes.

## Monorepo

- Make `npm run clean` work cross-platform
- Sort root `package.json`
- Update Babel configs to suppress warning about `@babel/plugin-proposal-private-property-in-object`
- Add `.nyc_output` and `*.lerna_backup` to `.gitignore`
- Replace references to `appium-support`
- Sync `package.json` fields
- Add a [Wallaby](https://wallabyjs.com) configuration file

## appium

- `lib/config`: `package.json` resolution
- split some tests out of `config-specs.js` and into `config-e2e-specs.js` since they are very clearly not unit tests
- Improve `PROJECT_ROOT` resolution, which is still a hack
- Copy fixtures & fix paths to fixtures in tests

## @appium/base-driver

- `lib/basedriver/driver`: `package.json` resolution
- Fix broken tests when run in isolation (`chai.should()`)

## @appium/doctor

- `lib/doctor`: `package.json` resolution
- `lib/utils`: `package.json` resolution & exposed `resetLog()` which undoes what `configureBinaryLog()` does (for testing purposes)
- `utils-specs.js`: clean up after `onLogMessage` test
- copy fixtures into `build` upon transpile
- Upgrade `@appium/gulp-plugins`

## @appium/gulp-plugins

- Ensure `postTranspile` is run when `transpile` is run before tests
- Fix `.babelrc` like `babel.config.json`

## @appium/support

- Fixture resolution
- Fix broken tests when run in isolation (`chai-as-promised`)
- Copy fixtures when transpiling
2021-08-10 11:52:57 -07:00
Christopher Hiller e00fe2644b chore(gulp-plugins): enable consumers to use mocha's "exit" flag
unit tests _should_ not need `--exit`, but this is real life, so things aren't perfect.

boilerplate configs can pass `{test: {exit: true}}` to cause Mocha to force-exit.

note that this is enabled by default for e2e tests (which _also_ shouldn't be necessary, but one thing at a time...)
2021-06-15 11:17:17 -07:00
Christopher Hiller 4c4b25e476 chore: cleanup base-driver
- remove dupe files
- move dev deps into root
- move `.azure-pipelines.yml` to root for reasons
- tweak gulp `lint` task to avoid linting `.min.js` files (vendored jQuery)
- update `.eslintignore` to do the same
2021-05-17 14:59:51 -07:00
Christopher Hiller 51625af447 chore: disable "exit: true" in unit test config; force color
`exit: true` is only necessary in mocha if your code doesn't clean up after itself.  this is not needed for the unit tests--haven't tested with e2e tests yet
2021-05-17 14:17:48 -07:00
Christopher Hiller f26bdb18d3 chore: add @appium/gulp-plugins to monorepo 2021-05-17 14:17:42 -07:00