Commit Graph

9510 Commits

Author SHA1 Message Date
Christopher Hiller 6b224f545f feat(appium,support): extension check improvements
This PR changes a few things:

- Extension problems are now displayed correctly at `appium server` startup.  This was done by changing the default `npmlog` level, then reesetting it to `silent` when `winston` takes over (in `logsink.init()`)
- Extension problems are also displayed at install time.
- Improved performance of `appium <driver|plugin> install` in many cases by actually checking if the thing is installed _before_ installing it.
- `ExtensionCommand` uses a new console logging mechanism (`console` in `@appium/support`) tailored to CLI usage, since it is intended to be run via the CLI.  Using this, we handle the result of extension checks both at server runtime and during CLI tool usage in the appropriate manner.  The implementation is just a dumb wrapper around `console.log` and should eventually be removed when we revisit the logging architecture.
- Separated extension checks further into "errors" ("Problems") and "warnings".  As these demand distinct log levels, `ExtensionConfig` no longer accepts a `logFn` in its constructor (since this restricted to a single level ("error"))
- Generally improved specificity, helpfulness, and reduced extraneous verbosity (like this sentence) of warnings
- Removed `strip-colors`, as this functionality is present in `@colors/colors`.  The E2E test helper now automatically strips colors from child processes.
- More tests
- Change `e2e-helpers` to use `CliConsole` for command logging output during tests
- Change the "uninstall" command to use `npm uninstall`, since `rm -rf` will hose `node_modules` if the current project has a dependency on `appium` (in other words, if they are otherwise using a package manager to manage extensions).  This is slower but safer.
2022-05-26 12:07:17 -07:00
Renovate Bot 3316ba65ef chore(): update dependency type-fest to v2.13.0 2022-05-25 20:37:45 +00:00
Renovate Bot c5a51c24b2 chore(gulp-plugins): update dependency del to v6.1.1 2022-05-25 17:22:23 +00:00
Renovate Bot 4d6c114fe8 chore(gulp-plugins): update babel monorepo to v7.18.2 2022-05-25 14:28:48 +00:00
Renovate Bot cf7a133cc6 chore(): update dependency lint-staged to v12.4.2 2022-05-25 11:57:29 +00:00
Renovate Bot 75da9aa6a2 chore(doctor): update dependency appium-adb to v9.6.0 2022-05-22 12:48:01 +00:00
Renovate Bot 92b17d6c2e chore(gulp-plugins): update babel monorepo to v7.18.0 2022-05-20 14:59:10 -07:00
Christopher Hiller b1b363f09f test(appium): increase e2e test timeout 2022-05-20 14:08:52 -07:00
Christopher Hiller e0f14b5931 chore(appium,base-plugin,types): cli args changes for plugins
This changes how plugins handle CLI args:

- The `cliArgs` instance prop of a `Plugin` will never be `undefined`. If there are no args, the prop will be an empty object.
- The `cliArgs` instance prop of a `Plugin` will now contain default values, if any were provided by the `Plugin`'s schema.

This differs from how the same property is handled in drivers.  To that end, I split `AppiumDriver#getCliArgsForExtension()` (previously `assignCliArgsToExtension()`) into two separate methods for clarity.

This change also contains a few associated improvements to tests and types.
2022-05-20 14:08:52 -07:00
Christopher Hiller 55504514a9 chore(fake-plugin): remove now-invalid constructor 2022-05-20 14:08:52 -07:00
Christopher Hiller f4c0b5b9b4 chore(appium,base-plugin,types): plugin name is derived from manifest
This PR changes the shape of plugin classes as well as how CLI args get assigned.

- The `pluginName` static property has been removed.  `name` is now assigned via the `BasePlugin` constructor, and is derived from the plugin name in the manifest.  This means that an implementor only needs to provide a `pluginName` in the manifest, and the data is not duplicated.  The value in this map (the plugin name) is used to instantiate the plugin, instead of passing static `pluginName` property into the constructor.
- CLI args are now passed in through the constructor instead of assigned to the plugin instance after the fact.

Implementation details:

`getActivePlugins()` and `getActiveDrivers()` now return a `Map` of an extension _class_ to an extension name.  The key is _not_ an instance, and is effectively a singleton, so we are not at risk of a memory leak.

This change does not otherwise affect drivers.
2022-05-20 14:08:52 -07:00
neilnaveen 7e2412499a chore: Set permissions for GitHub actions
Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

Signed-off-by: neilnaveen <42328488+neilnaveen@users.noreply.github.com>
2022-05-18 11:58:51 -07:00
Renovate Bot c0f71ef3ff chore(doctor): update dependency appium-adb to v9.5.0 2022-05-18 13:44:07 +00:00
Renovate Bot 45285429d6 chore(gulp-plugins): update babel monorepo to v7.17.12 2022-05-17 21:31:08 +00:00
Renovate Bot db2a4fe60b chore(): update dependency @types/node to v16.11.36 2022-05-17 11:21:50 +00:00
Renovate Bot 48b465f0fe chore(gulp-plugins): update dependency del to v6.1.0 2022-05-16 11:54:26 -07:00
Renovate Bot 11975dafd9 chore(appium): update dependency yaml to v2.1.0 2022-05-16 11:54:08 -07:00
Renovate Bot cffaa2dcc9 chore(images-plugin): update dependency lru-cache to v7.10.1 2022-05-16 11:53:54 -07:00
Renovate Bot 8c956e9f09 chore(gulp-plugins): update dependency yargs to v17.5.1 2022-05-16 11:53:37 -07:00
Renovate Bot 5a149d35fc chore(support): update dependency glob to v8.0.3 2022-05-16 11:53:12 -07:00
Renovate Bot b359f29df5 chore(): update dependency @types/node to v16.11.35 2022-05-13 13:02:20 +00:00
Christopher Hiller 5f28ce81df chore(appium): renamed postinstall.js to autoinstall-extensions.js
...just so we're clear about what it does.  Added some more explanation
in docstrings.
2022-05-12 14:47:51 -07:00
Christopher Hiller 936427f1d1 test(appium): bump exec time of cli e2e tests to avoid flake 2022-05-12 14:47:51 -07:00
Christopher Hiller 3e2c05d8a2 fix(appium): fix extension autoinstall postinstall script
Resolves #16924

Because the `postinstall` script of `appium` needs functions in `@appium/support`, that module must be compiled _before_ its `postinstall` script runs.  Prior to this PR, only the monorepo root would run a `postinstall` script to build the subpackages.  Now, each package has a `prepare` script which runs its own build; this happens prior to any `postinstall`.  This way, the `postinstall` script in `appium` can run successfully.
2022-05-12 14:47:51 -07:00
Christopher Hiller 9f551e274f chore(gulp-plugins): remove unneeded dependencies
These two deps are devDependencies of the monorepo root.  Since we do not use TS in any "production" capacity, typings should not be production dependencies anyway.
2022-05-12 14:07:18 -07:00
Christopher Hiller 147d1d1d34 test(images-plugin): avoid call to deprecated reset() method 2022-05-12 14:07:07 -07:00
Christopher Hiller 2289b45272 fix(types,base-plugin): fix static prop types for plugins
This change modifies the type of `BasePlugin.newMethodMap`, adds a
parameter to the `MethodMap` type, and updates the base plugin TS
config for better incremental builds.
2022-05-12 14:06:55 -07:00
Christopher Hiller 59b885aa66 chore(base-driver): guard against null sessions if proxy used weirdly 2022-05-12 12:32:57 -07:00
Christopher Hiller d5ca3007b3 chore(types): restore example comment for newMethodMap in PluginStatic 2022-05-12 12:32:57 -07:00
Christopher Hiller 0676cd27c3 chore(appium,support,opencv,docutils): assorted type fixes
- Some types in `appium` were renamed
- Others avoid errors
- Some are minor tweaks to `tsconfig.json` files

# Conflicts:
#	packages/appium/lib/extension/extension-config.js
#	packages/appium/types/extension-manifest.ts
#	packages/appium/types/extension.ts
#	packages/base-driver/lib/jsonwp-proxy/proxy.js
#	packages/support/lib/logging.js
#	packages/support/test/unit/logger/logger-force.spec.js
2022-05-12 12:32:57 -07:00
Christopher Hiller e5b21b5674 chore(base-driver): enable type checks
and a bunch of associated fixes

# Conflicts:
#	packages/base-driver/lib/basedriver/core.js
#	packages/base-driver/lib/basedriver/desired-caps.js
#	packages/base-driver/lib/basedriver/helpers.js
#	packages/base-driver/lib/express/server.js
2022-05-12 12:32:57 -07:00
Christopher Hiller 5ba245c819 chore(appium,types): move DriverType, PluginType etc. into @appium/types
- Also split out types into more files, since they were getting hefty
- The `Plugin` type conflicts with the [Plugin API](https://developer.mozilla.org/en-US/docs/Web/API/Plugin), which is detailed in TypeScript's DOM library.  This changes makes `@appium/types` _avoid_ this library entirely, and only use the basic JS/Node.js types.

# Conflicts:
#	packages/appium/types/extension.ts
#	packages/types/lib/index.ts
2022-05-12 12:32:57 -07:00
Christopher Hiller 5e96a6d2a7 feat(base-plugin): prepare for use by plugins
This adds the requisite TS setup for base-plugin
2022-05-12 12:32:57 -07:00
Christopher Hiller 48f1d99087 feat(appium): appium now expects extensions to use peer dependencies
The peer dependency value is stored in the `extensions.yaml` manifest for each extension as `appiumVersion` (if present).

If the peer dependency is _not_ present, the user will be warned, but Appium will still try to load the extension (I have a feeling that most of the time, this will be fine).  When warned, the user will receive information about available extension upgrades, if any.

This required some refactors in the `lib/extension/` dir.  Extension validation was previously a synchronous process, but because we now (potentially) display information to the user about upgrades (which is async), validation must also be async.  This means that the `ExtensionConfig` constructor (and the constructors of its subclasses) cannot run validation.  Validation must happen after the config object is instantiated, which is handled in `loadExtensions()` of `lib/extension/index.js`.  The constructor signatures have changed accordingly.

While extensions now soft-require a `peerDependencies.appium` field, in the monorepo, the value of this dependency is `file:../appium`.  This is treated as a special case, and acts as if the dependency is just the current version of `appium` (as in its `package.json`).  This is handled in `Manifest#addExtension()`.

To further support this, `appium` now exports `@appium/base-driver` as `driver`, `@appium/base-plugin` as `plugin`, and `@appium/support` as `support`.  `tsconfig.json` files have changed in these affected packages.

In addition, a new reusable TS config file has been added for use with basic plugins.

# Conflicts:
#	.eslintrc
#	packages/appium/lib/extension/extension-config.js
#	packages/appium/lib/extension/index.js
#	packages/appium/lib/extension/manifest.js
#	packages/appium/test/unit/extension/manifest.spec.js
#	packages/appium/test/unit/extension/mocks.js
2022-05-12 12:32:57 -07:00
Renovate Bot 5835a8ab7e chore(appium): update dependency @sidvind/better-ajv-errors to v2 2022-05-10 17:56:16 -07:00
Renovate Bot a1dff640b1 chore(test-support): update dependency sinon to v14 2022-05-10 17:55:55 -07:00
Christopher Hiller 133db5355f chore: reformat everything
this reformats all `.js`, `.ts`, and `.d.ts` files.
2022-05-09 19:09:50 -07:00
renovate[bot] 68feafb5d3 chore(doctor): update dependency appium-adb to v9.2.3 (#16917)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-05-09 01:32:07 +09:00
renovate[bot] 3d2db4538e chore(images-plugin): update dependency lru-cache to v7.9.0 (#16780)
* chore(images-plugin): update dependency lru-cache to v7.9.0

* Update cache properties

* Only set max size

* Set max cache size

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Mykola Mokhnach <mokhnach@gmail.com>
2022-05-07 15:39:15 +02:00
Renovate Bot b0d5d3e4e7 chore(support): update dependency bplist-parser to v0.3.2 2022-05-05 15:20:14 -07:00
Christopher Hiller 4198253cf9 chore(appium): simplify types
`import` in jsdoc types previously using relative paths to reference the `types` folder can now be referenced via `appium/types`; e.g., `import('../types').Foo`, `import('./types').Foo`, `import('../../../types/bar').Foo` are now just `import('appium/types').Foo`

Also add some missing descriptions
2022-05-04 18:11:42 -07:00
Renovate Bot 7797a4f685 chore(support): update dependency bplist-creator to v0.1.1 2022-05-04 13:58:26 +00:00
Renovate Bot 8f926e9bc0 chore(execute-driver-plugin): update dependency webdriverio to v7.19.7 2022-05-04 11:52:40 +00:00
Christopher Hiller 5928026f9c Publish
- @appium/eslint-config-appium@6.0.0
 - @appium/gulp-plugins@7.0.0
@appium/eslint-config-appium@6.0.0 @appium/gulp-plugins@7.0.0
2022-05-03 15:02:23 -07:00
Christopher Hiller 878bb6a44f feat(eslint-config-appium,gulp-plugins): add prettier
BREAKING CHANGE:

`@appium/eslint-config-appium` now requires peer dependency `eslint-config-prettier`.  Because `@appium/gulp-plugins` always uses the latest development version of `@appium/eslint-config-appium`, the dependency needs to be added there, too.

In addition, this disables some rules, so _may_ cause code which previously passed lint checks _not_ to pass lint checks.
2022-05-03 14:57:14 -07:00
Jonathan Lipps 59dd30ba20 Publish
- appium@2.0.0-beta.35
 - @appium/doctor@1.16.19
 - @appium/eslint-config-appium@5.1.1
 - @appium/gulp-plugins@6.0.10
@appium/doctor@1.16.19 @appium/eslint-config-appium@5.1.1 @appium/gulp-plugins@6.0.10 appium@2.0.0-beta.35
2022-05-03 13:42:56 -07:00
Christopher Hiller 6480679bfb chore(appium): lint again 2022-05-03 13:34:10 -07:00
Christopher Hiller c2753107c6 test(appium): e2e helpers now log executed child process commands 2022-05-03 13:12:31 -07:00
Christopher Hiller a794ade7b0 chore(appium): lint 2022-05-03 13:09:17 -07:00
Christopher Hiller 5e24fbac5c chore(ci): add Node v18 to matrix; remove Node v17 2022-05-03 12:50:20 -07:00