I had intended to allow extensions to define a schema via `package.json` instead of a path to a file, and apparently forgot to implement this. So, now it is implemented.
Logging was happening here before the logger was properly initialized, which looked weird. Just remove logs for now until we find a better solution.
In addition, fixed some typing problems:
- we need `@types/node` for node globals (like errors that have a `code` property)
- set various typings as globals: `node`, `mocha`, `chai` & its ilk
- we want to reference this file from the documentation, and the easiest way to do so is just to add it to vcs. we can change where it lives later, if necessary.
- modify gulpfile to handle this
- revert changes to default boolean values
- fix types w/r/t the object returned by `parseArgs()`
- `.d.ts` files _and_ `.js` files can now be checked via `tsc` (given typescript Version 4.6.0-dev.20211102 or newer); remove `jsconfig.json` in lieu of `tsconfig.json`. js files will only be checked if `// @ts-check` pragma is present
- add more comments explaining various types
- fix some types in `lib/main.js`
- rename `args` to `parsedArgs` to be more obvious about what's what
- `parsedArgs` is now correctly typed! I think.
- fix `NormalizedAppiumConfiguration` (and rename to `NormalizedAppiumConfig`) which was essentially incorrect, since it did not respect `appiumCliDest` (e.g., `tmp` would be `tmpDir` in the config normalized by the code, but the type would not reflect this)
- add type for `driverConfig` prop to `AppiumDriver`
- remove a bunch of `default: false` nonsense from schema
- fix `tmp`, which is now stored in `tmpDir` as it should be
Note that any source file with a `// @ts-check` in it which operates on the parsed arguments object will have type support available. we're not linting the types (yet), but when we do, it will save us some potential headaches like incorrect usage or unknown arguments
When combining extension schemas with the base schema, the keywords weren't quite right (the extension name was not being recognized in any config files).
refactored a few things to support this, but the nut of it is in `AppiumSchema#finalize`, where we no longer use `anyOf`. I added a couple more functions to `ArgSpec` which generate various IDs and references in order to avoid having mysterious calls to `_.kebabCase()` everywhere.
in addition:
- no longer breaks if the exact same extension tries to register itself twice. this can happen if one happens to, say, instantiate multiple `DriverConfig`s. this happens in the tests. it _should_ not happen, since it's really unnecessary, so instead of this, we have a `DriverConfig.getInstance()` (and for `PluginConfig`) which keeps track of singletons linked to `APPIUM_HOME` dirs. at runtime, we're unlikely to ever need to instantiate multiple instances of these classes _anyway_, so it's on a per-appium-home basis mainly for testing purposes. the constructors are still usable directly, but discouraged (now marked `@private`).
- updated tests to reflect this change. in at least one place in the tests, we're trying to get at the actual extension class constructor, and were instantiating an extra `DriverConfig` to do that--but now we do not need to, as `DriverConfig.getInstance()` just grabs the one already created when we called `runExtensionCommand()`.
- removed unused `AppiumSchema#getAllSchemas`
- renamed "ID" to "ref" to be more clear about which identifier we're talking about--a schema reference, as one would put in a `$ref` field
- renamed arg `<extension-type>s` to `use-<extension-type>s` wherever necessary, since that arg was renamed; fix a bunch of fixtures
- restore default value of `[]` to `use-plugins`, since the code expects it to be defined
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.
previously, we'd create a new schema for every single argument. I felt this was probably wrong... and I was right. `ajv` allows getting the schema (and thus validation) by reference path! so `appium.json#/properties/server/properties/address` would be the schema for `address`.
this necessitated storing the reference path for each argument, so `ArgSpec` was updated to reflect that. further, we add references (`$ref`) to each schema added by each extension under an `anyOf` prop of the `driver` and `plugin` config attributes.
- in addition, added some more tests to more thoroughly cover branches and define behavior (especially in `toParserArgs()`)
- moved some tests into `test/schema/`
- added a couple tests for `ArgSpec`
- renamed `--plugins` to `--use-plugins` and `--drivers` to `--use-drivers`
- schema updated to nest `driver` and `plugin` under `server`. `server` is now currently the only top-level prop.
- removed all hard-coded `$id` fields from arguments, as they aren't needed anyway (and maintaining them is likely going to be a source of bugs)
- `ArgumentDefinition` type becomes `ArgumentDefinitions` and is now a `Map`, as it's basically a devolved `Map` anyway.
- fixed problem with extensions using `appiumCliAliases`, which could allow conflicts with base appium server args.
- add some missing `appiumCliDescription` fields