Commit Graph

10167 Commits

Author SHA1 Message Date
Renovate Bot 6701251411 chore(doctor): update dependency appium-adb to v9.2.1 2022-04-07 11:37:22 +00:00
Renovate Bot bc36b8dfcc chore(gulp-plugins): update dependency eslint-plugin-import to v2.26.0 2022-04-06 13:39:35 +00:00
Renovate Bot 4060c17cc6 chore(fake-driver): update dependency @xmldom/xmldom to v0.8.2 2022-04-06 10:39:12 +00:00
Renovate Bot fa20f8058f chore(appium): update dependency winston to v3.7.2 2022-04-05 12:39:42 +00:00
Kazuaki Matsuo 8f4a5e9752 ci: drop nodejs 12, add 17 (#16703)
* ci: drop nodejs 12, add 18

* 17, not 18 yet as maximum version

* test: increase timeout
2022-04-05 15:31:25 +09:00
Renovate Bot 7c7a290cfa chore(doctor): update dependency appium-adb to v9 2022-04-04 15:30:56 -07:00
Renovate Bot 919d55d1cb chore(gulp-plugins): update dependency fancy-log to v2 2022-04-04 15:25:38 -07:00
Kazuaki Matsuo 4235f27445 docs(appium): merge from master (#16672) 2022-04-04 15:20:18 -07:00
renovate[bot] d23907def5 chore: update dependency webdriverio to v7 (#15489)
* chore(): update dependency webdriverio to v7

* chore(fake-driver,appium): upgrade webdriverio to latest

- fixed broken tests in `@appium/fake-driver` and `appium`
- remove unused `appium-base-driver` from root of monorepo

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Christopher Hiller <boneskull@boneskull.com>
2022-04-04 15:14:59 -07:00
Renovate Bot dd38c6f42c chore(base-driver): update dependency body-parser to v1.20.0 2022-04-04 15:13:29 +00:00
Renovate Bot 2a5f7c2b73 chore(support): update dependency moment to v2.29.2 2022-04-04 12:19:16 +00:00
Renovate Bot 3f388b935a chore(): update dependency @types/base64-stream to v1.0.2 2022-04-01 23:31:46 +00:00
Mykola Mokhnach a9651d3c59 fix(base-driver): Update/simplify the logic for logger prefix (#16683) 2022-04-01 22:34:57 +02:00
Renovate Bot a91d283128 chore(support): update dependency type-fest to v2.12.2 2022-04-01 11:55:17 +00:00
Mykola Mokhnach d8a9b4da36 feat(base-driver): Add more shadow root-related W3C routes (#16700) 2022-03-31 17:46:44 +02:00
Renovate Bot 4f41ec3c7a chore(base-driver): update dependency lru-cache to v7.7.3 2022-03-31 13:25:29 +00:00
Christopher Hiller 8c3d9ec347 docs: add migration information for nodeconfig, allow-insecure and deny-insecure
Closes #16593
2022-03-30 14:43:47 -07:00
Christopher Hiller 0bbec13d1e fix(appium): allow multiple drivers to be installed
Closes #16674

the problem here was the existence of the empty `package.json`.  it should exist, because if it doesn't, then `npm` may end up using a `package.json` in a parent directory.  but it can't be _empty_, because subsequent `npm install`s will essentially remove any package that it's currently not installing!  `npm` likes to "fix" `node_modules`, which is undesirable here.

to avoid this, the behavior has changed to persisting the dependency version to `package.json`.  behavior differs if we're using a local `APPIUM_HOME` or the default one.  with the default, we have more control, and choose to use `--save-dev --save-exact --no-package-lock --global-style` which gives us what we need.  if `APPIUM_HOME` is a local package, all we can do is `--save-dev` (since it's _likely_ that an extension will be a dev dependency).  in the future, we may choose to actually determine _what kind_ of dependency `appium` is and tell `npm` to use the same one.  not sure if that's needed, though.

further, in the case of a local appium dep (local `APPIUM_HOME`), updating `package.json` should cause the package hash (used by the thing that syncs `extensions.yaml` with installed packages) to update as well, so we're doing that.

modified the logic in `ExtensionCommand` to treat `--source=local` to pass the `installSpec` thru verbatim.

also fixed `BuildInfo` type to reflect reality and use `@types/teen_process`.  fixed some other broken types in `test` (files in `test` are not checked by typescript yet; we'll need a separate `tsconfig.json` for this, since we do not want to emit declarations)
2022-03-30 14:43:21 -07:00
Christopher Hiller 61b05063ee fix(support): avoid 'npm link' for local-sourced extensions
'npm link' is weird and we do not need to use it.  `npm install /path/to/some/module` will create a symbolic link, but it _won't_ create a global link.  it otherwise behaves similarly to `npm install`.

- also updated to use `@types/teen_process`
- fixed some weird types in `util.getLockFileGuard()`
2022-03-30 14:43:21 -07:00
Christopher Hiller 7a028c8d9a chore: add types for teen_process
which magically appeared. thanks definitelytyped!
2022-03-30 14:43:21 -07:00
Christopher Hiller 06f75a281c chore(base-driver): remove ts-expect-error directive from elementShadowRoot route 2022-03-30 14:42:56 -07:00
Christopher Hiller 47b0df06ec fix(types): add method for elementShadowRoot 2022-03-30 14:42:56 -07:00
Christopher Hiller b7b8b12eff chore(appium): switch type of inner drivers
This PR changes the type of inner drives from `Driver` to `ExternalDriver`, which is more accurate.
2022-03-30 14:42:22 -07:00
Renovate Bot 6fbff601b6 chore(base-driver): update dependency lru-cache to v7.7.2 2022-03-30 10:23:14 +00:00
Renovate Bot e5ad7a9fd8 chore(workflows): update actions/checkout action to v3 2022-03-29 17:46:52 -07:00
Jonathan Lipps 54f1308a36 chore: fix reinstall script and clean ordering 2022-03-29 17:46:16 -07:00
Christopher Hiller 826de8c346 chore(doctor): remove gulp
- removes gulp, builds w/ babel, tests w/ mocha
- reorg test files
2022-03-29 15:56:02 -07:00
Christopher Hiller 3833b237df chore(opencv): remove gulp
- build now happens via babel
- test now happens via mocha
- renamed/reorganized test files
2022-03-29 15:55:48 -07:00
Christopher Hiller d400405296 chore(test-support): remove gulp
- use mocha, babel
- reorg test files
2022-03-29 15:55:34 -07:00
Christopher Hiller e439387d5c docs(types): add README.md
- update keywords
2022-03-29 15:55:16 -07:00
Christopher Hiller 7498a7ab90 chore: add a script to sync LICENSE files across packages
This will be run before publish, and will copy the root `LICENSE` file to all packages, so that they appear in the published tarballs.

`packages/*/LICENSE` are ignored by Git, since they are redundant with the root `LICENSE` file.
2022-03-29 15:54:55 -07:00
Mykola Mokhnach 6973f54e06 chore: Fix indentation (#16678) 2022-03-29 08:00:54 +02:00
Mykola Mokhnach c63e9bf8e0 fix(base-driver): Make sure we never mutate incoming args (#16670) 2022-03-28 20:35:37 +02:00
Renovate Bot 25fab42940 chore(test-support): update dependency sinon to v13 2022-03-28 11:28:31 -07:00
Renovate Bot 3bfee19a66 chore(workflows): update actions/setup-node action to v3 2022-03-28 11:27:40 -07:00
Renovate Bot 6cf1590a2d chore(): update dependency @types/json-schema to v7.0.11 2022-03-26 17:39:51 +00:00
Renovate Bot b6b9a2b019 chore(support): update dependency type-fest to v2.12.1 2022-03-26 10:49:56 +00:00
Renovate Bot 9b6565b3ba chore(gulp-plugins): update dependency eslint-plugin-promise to v6 2022-03-25 15:25:20 -07:00
Christopher Hiller 06a605420d feat(appium): generate declaration files (#16597)
* feat(appium): generate declaration files

Configure TS to generate declaration files for `appium` package.

Most of these changes are just types getting added or changed via docstrings; in other places, typechecking has caught problems and I had to refactor code to address them.

- Removed `// @ts-check` pragma from all files in `lib/`, since now `checkJs: true` is in `tsconfig.json`.  It needs to stay in place elsewhere (I think) because only sources in `lib` have declarations generated.
- The `install`, `uninstall`, `update` and `run` functions in the base `ExtensionCommand` class were renamed and prefixed with a `_`; TS does not allow overridden functions with differing signatures.   It no longer exports a default.
- Removed `type` prop of options for `DriverCommand` and `PluginCommand` constructors, respectively (this value is derived from the `ExtensionConfig` `config` parameter instead)
- `AppiumDriver` now extends `DriverCore` instead of `BaseDriver`, since some of its function signatures differ from `BaseDriver`'s.
- Small refactor of `deleteSession` to make typechecker happy.
- `executeCommand` now calls to `BaseDriver` directly if `isUmbrellaCmd` is truthy.  This is one place where inheritance just kind of breaks, since `BaseDriver#executeCommand` returns something entirely different than `AppiumDriver#executeCommand` would otherwise.
- Removed `--delete-dir-on-start` from build command, since it may blast generated declarations.
- Reorganize declarations in `types/`; moved some of them out of `@typedef`s. `types.d.ts` becomes `index.d.ts`
- Note that this contains the declarations for `PluginClass` and `DriverClass`, which correspond to the types of extension "main" classes. This differs from the interfaces provided in `@appium/types` (e.g., `Driver`, `ExternalDriver`) in that these aren't just objects; they are classes with constructors and static members. I may end up moving some of this stuff into `@appium/types`, but I'm not sure how useful it will be.  Will see when I add types to `@appium/fake-driver`.

* chore(appium): remove transpile directives
this was ostensibly for gulp-babel

* chore(appium): remove redundant type declaration

* fix(appium): avoid potential unhandled rejections

- make types more readable

* chore(appium): fix capabilities types

- move `scripts/generate*` elsewhere
- add reference to `@appium/types` in `tsconfig.json`

* chore(appium): review updates for legibility
2022-03-25 14:54:45 -07:00
Christopher Hiller 164bedb2f1 feat(base-driver): generate declaration files
This was not as easy as the other two.  The main issue involves the `BaseDriver` class and is threefold:

1. `BaseDriver` and a valid external subclass thereof (a `Driver`) are not the same, because the former is essentially _abstract_. There is no notion of an abstract class in JS nor in TS for JS.
2. Splitting `BaseDriver` into several modules and "mixing in" some modules is just not well-understood by TS.
3. `AppiumDriver` inherits _most_ of `BaseDriver`, but overrides some functions with differing signatures. This is unsupported by TS.

To work around these problems, I had to:

1. Move the `Driver` interface into `@appium/types`, since other packages may depend on it.  We do not want circular dependencies, which is likely to occur otherwise.  Further, there is no way to tell TS for JS that a class _implements_ an interface or type.
2. Refactor the mixins (in `basedriver/commands/`) into "mixin classes", as understood by typescript. These are dynamic classes returned by functions which accept a class parameter, and _extend_ that class. The result is marginally better, but the implementation is ... well, see for yourself.  It is not possible to use declaration merging to just "trick" TS into thinking that `BaseDriver` has all of these extra methods; classes cannot be merged, and even if you could, you can't use declaration merging to "add" methods afaict.
3. `BaseDriver` is now an empty class which inherits from all mixins applied to `DriverCore`.  Due to syntactic restrictions, it must be a `class` statement in order to use the `@implements` tag, which causes TS to check that the result fully implements `Driver`.  `AppiumDriver` _also_ inherits from `DriverCore`, since it does not override `BaseDriver` "properly".  `BaseDriverCore` itself is pretty small, containing only those functions which `AppiumDriver` defines as differing.

Otherwise:

- `BaseDriver` does not inherit from `Protocol`, which is just an empty class. `Protocol` was removed.
- All of the error classes are exported from `protocol/errors`, because TS cannot see them otherwise.
- Exported missing `GET_STATUS_COMMAND` from `protocol/index`
- Re-exported `normalizeBasePath` from `server` instead of `protocol`, since that's where it's defined
- Removed `index.d.ts`
- Mixins use `@implements` as well. Note that `@implements` does not support `import('..')` syntax.

chore(base-driver): attempted to make types for mixins less awful

fixed a couple issues in the types in `driver.js`

core(base-driver): add capabilities types

- also move the bluebird config into the index
- fix references to `DriverOpts`
- add `assignServer()` to `BaseDriverCore`, used by `AppiumDriver`

chore(base-driver): fix more types

add missing reference to `@appium/types` in `tsconfig.json`

fix(base-driver): ensure getLogEvents is async

fix(base-driver): add some more type checks and fix logCustomEvent to be async

chore(base-driver): reformat
2022-03-25 14:54:45 -07:00
Christopher Hiller 326b7b4e06 feat(support): generate declaration files
Most of these changes are the addition of types.  There are a few places in which the typechecker found weirdness, and I have addressed those.

- In `logging.js`, `parseInt()` was being called on props of `process.env`; this is not allowed, because `parseInt()` only accepts a string, and props may be `undefined`.
- In `log-internal.js`, I had to remove the `raiseError()` function because TypeScript is unable to understand that a function, when called, will always throw.  The fix was just to replace with `throw new Error...`
- Introduced a var in `mjpeg.js` to avoid repeated casting
- Added some type guards to `net.js`. as function parameters, union types kind of suck. This is definitely one place TS would have helped, since it allows function overloads.  Also dropped use of deprecated `url` module in lieu of W3C `URL`.
- Removed some old-node-version cruft from `util.js`.

Non-code changes:

- Needed to use an override for `type-fest`, as it's included as a transitive dependency, but otherwise is only present in the devdeps of the monorepo root `package.json`. This means, due to version conflicts, a `support/node_modules/type-fest` would be created with an old, incompatible version, which would be preferred over the monorepo one due to Node's resolution algorithm.  This needs npm v8.3+ to work properly, but is only a problem for contributors (not consumers).
- Pinned type of `opencvv-bindings`.
- No longer deleting `build` dir before transpilation since it may contain generated declarations!
2022-03-25 14:54:45 -07:00
Christopher Hiller 72085caa0a feat(types): add new @appium/types package
This changes the TS configuration to to a) emit declarations for supported packages, and b) build declarations incrementally by package.

To begin, we are targeting `appium`, `@appium/base-driver` and `@appium/support` for declarations; these three are intended to be published with declarations generated via their JS.

Both `@appium/support` and `appium` are fully typechecked (sans implicit `any` types), but `@appium/base-driver` is mostly not.  Regardless, declarations are generated for all three.

Each package will have its own `tsconfig.json` which "inherits" from `config/tsconfig.base.json`.  Each will also need to declare relative paths to dependencies. e.g., the `appium` package must configure its `tsconfig.json` so that it depends on the declarations of `@appium/support` and also where to find `@appium/support`. Essentially, a small dependency tree gets built, and those at the "root" get their declarations built first; then the consumers use those declarations.

Also reorganized some scripts and added `npm-run-all` to help and added a "typecheck" job to CI.

Since `npm install` will build, it's pretty inconvenient to have `npm` abort installation if the build fails.  In that case, if any of the build steps fail (see `build:loose`) the installation will continue.  Added a `prepublishOnly` which runs a build in "strict" mode where everything must pass.

_Note: there's still a strong coupling of "what `BaseDriver` provides" and "what an external driver *may* provide".  It's unclear to me if this is a problem, though there seem to be a handful of methods that external drivers *must* implement.  The easiest way to get around this would probably be to extract these required properties and methods into their own interface (duplication) if we cannot otherwise declare methods as "abstract".  As it stands, the `Driver` is basically just `BaseDriver`._

Also:

- Moved some configuration types out of `appium` and into here, since they are used both by `appium` and `base-driver` via `DriverOpts`
- Split `Driver` type into "the thing that BaseDriver is" and "all the other methods external drivers can implement"
- Added missing `proxyCommand` method
- Better generics for `LogType`
- Remove unused `Constructor` type
- Better types for `getSession`/`getSessions`
- Added util `Class` type
- Added many missing typings from DefinitelyTyped
- Added `ts-node` for `@wdio/types` (I need to send a PR to webdriver to eliminate this dependency)
- Type checks in their CI step
2022-03-25 14:54:45 -07:00
Renovate Bot 4ff63e2425 chore(): update dependency serve-static to v1.15.0 2022-03-25 14:43:56 +00:00
Renovate Bot a4229f9382 chore(doctor): update dependency inquirer to v8.2.2 2022-03-25 12:09:52 +00:00
Renovate Bot 075eaeb8ce chore(): update dependency typescript to v4.6.3 2022-03-25 09:30:00 +00:00
Renovate Bot 523301199a chore(support): update dependency plist to v3.0.5 2022-03-24 11:48:16 +00:00
Renovate Bot 6cf9c63da2 chore(appium): update dependency lilconfig to v2.0.5 2022-03-24 10:02:20 +00:00
Jonathan Lipps 6d35def9ed Publish
- appium@2.0.0-beta.27
 - @appium/base-driver@8.3.1
 - @appium/doctor@1.16.11
 - @appium/fake-driver@3.2.6
 - @appium/support@2.56.1
 - @appium/test-support@1.3.13
@appium/base-driver@8.3.1 @appium/doctor@1.16.11 @appium/fake-driver@3.2.6 @appium/support@2.56.1 @appium/test-support@1.3.13 appium@2.0.0-beta.27
2022-03-23 11:50:58 -07:00
Christopher Hiller 77727dc913 fix(support): add missing resolve-from dependency
see https://github.com/appium/java-client/issues/1667
2022-03-23 11:44:51 -07:00
Mykola Mokhnach bbfc7ef51d fix(base-driver): Use WeakRef to reference the driver instance in the log prefix generator (#16636) 2022-03-23 18:48:33 +01:00