This PR moves the FOSSA check from the Node workflow to its own. It won't run if the API key secret is not present (which would be true when running PRs from forks).
In addition, the check
1. will only run on changes to any `package.json` in the monorepo
2. runs `fossa test` to fail upon failure (previously it would only fail upon _error_)
Some theoretical schemas are not in any sort of shape Appium can use, so we now catch them as soon as possible (at the registration phase).
- adds type guard
- adds
Extensions were not correctly receiving the default values as specified in their schemas. For example, in `xcuitest` driver, the `wdaLocalPort` option has a default value of `8100`, but this value would never make it to the driver.
The root cause was that `getDefaultsForSchema()` returns a _flattened_ object (which is useful for displaying to users as part of `getNonDefaultServerArgs()`), but by the time defaults should get assigned to parsed arguments in `main.js`, the parsed arguments object has already been expanded to a deeply-nested, non-flattened object. So `"driver.driverName.argName": "value"` would be set in the args, but not `{"driver": {"driverName": {"argName": "value"}}}`. Furthermore, the properties of `cliArgs` are not prefixed with `<extType>.<extName>.`, but are just the arg name itself (which makes sense).
To address this, two main changes:
1. `getDefaultsForSchema(flatten = true)` (renamed from `getDefaultsFromSchema()`) now accepts a `flatten` flag, which will return a flat object using `<extType>.<extName>.`-style prefixes. This is useful (and less computationally intensive) for comparing defaults across the whole of Appium and its extensions. This is _not_ useful when merging defaults into the parsed arguments object, however, as that object will be deeply-nested. If `flatten` is `false`, a deeply-nested object will be returned, which is consumed by the `main` module when post-processing parsed CLI arguments and config file values.
2. Added `getDefaultsForExtension(extType, extName)` which acts like `getDefaultsForSchema(flatten = true)` _but_ only returns defaults for a particular extension _and_ strips the leading prefixes. This is used by `assignCliArgsToExtension` in the `AppiumDriver` class.
Other changes:
1. `ArgSpec` now keeps a `rawDest` property which is like `dest` w/o the prefixes.
2. Make more types
3. Re-organize `driver-specs` unit test somewhat, and update to reflect changes.
The `inspectObject()` function in `utils` was doing... stuff... to display both the default caps and non-default arguments. Arrays, in particular, wound up looking like objects. I found this objectionable; I hope there isn't a good reason it's this way.
- Remove `utils.inspectObject()` and replace it with `inspect()`, which delegates to Node.js' built-in `util.inspect()` function (which does a bang-up job of dumping objects, including color!)
- Remove the `parser` argument (and return value!) from various functions where it was used. e.g., `init()` in `main.js` was returning the `parser` instance, but now we don't need it, since it was only needed for `getNonDefaultServerArgs()`, which doesn't need it. `parser` was being passed through several functions this way.
- Add a dumb test for `utils.inspect()`
- Add another dumb test for `getNonDefaultServerArgs()`
- Add `@types/express` since it was missing.
- More types in various associated places; fix other types
- Consistent naming in impl of `getNonDefaultServerArgs()`
This PR adds the `appiumDeprecated` keyword which can be used to mark an argument as deprecated in the `--help` text.
In addition:
- fix a bug where `--help` would cause Appium to exit with a nonzero exit code (it would essentially `throw undefined`)
- remove unused `lib/cli/argparse-actions` and stuff that used it, since that stuff was also unused
- implement `appiumCliIgnore`, though it's not actually being used atm.
- extract helpers for running `appium` into `test/cli/cli-helpers.js`
BREAKING CHANGE:
ESLint expects configs or plugins which require other configs or plugins to have _peer dependencies_ of those things _and_ of ESLint itself. All deps have been changed to peer deps, and this module now requires the installation of the following _if_ using npm older than v7:
```
"@babel/core": "7.16.0",
"@babel/eslint-parser": "7.16.3",
"eslint": "7.32.0",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-mocha": "9.0.0",
"eslint-plugin-promise": "5.1.1"
```
npm@7 will install these automatically if they do not exist.
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.
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`.