appium 2.0.0-beta.46 → 2.0.0-beta.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/README.md +145 -44
  2. package/build/lib/appium.d.ts +3 -103
  3. package/build/lib/appium.d.ts.map +1 -1
  4. package/build/lib/appium.js +679 -549
  5. package/build/lib/appium.js.map +1 -1
  6. package/build/lib/cli/args.js +247 -127
  7. package/build/lib/cli/args.js.map +1 -1
  8. package/build/lib/cli/driver-command.d.ts +24 -5
  9. package/build/lib/cli/driver-command.d.ts.map +1 -1
  10. package/build/lib/cli/driver-command.js +78 -88
  11. package/build/lib/cli/driver-command.js.map +1 -1
  12. package/build/lib/cli/extension-command.d.ts +33 -24
  13. package/build/lib/cli/extension-command.d.ts.map +1 -1
  14. package/build/lib/cli/extension-command.js +729 -512
  15. package/build/lib/cli/extension-command.js.map +1 -1
  16. package/build/lib/cli/extension.d.ts +7 -6
  17. package/build/lib/cli/extension.d.ts.map +1 -1
  18. package/build/lib/cli/extension.js +68 -65
  19. package/build/lib/cli/extension.js.map +1 -1
  20. package/build/lib/cli/parser.d.ts +3 -3
  21. package/build/lib/cli/parser.d.ts.map +1 -1
  22. package/build/lib/cli/parser.js +234 -192
  23. package/build/lib/cli/parser.js.map +1 -1
  24. package/build/lib/cli/plugin-command.js +58 -87
  25. package/build/lib/cli/plugin-command.js.map +1 -1
  26. package/build/lib/cli/utils.js +66 -69
  27. package/build/lib/cli/utils.js.map +1 -1
  28. package/build/lib/config-file.d.ts.map +1 -1
  29. package/build/lib/config-file.js +189 -120
  30. package/build/lib/config-file.js.map +1 -1
  31. package/build/lib/config.d.ts.map +1 -1
  32. package/build/lib/config.js +254 -213
  33. package/build/lib/config.js.map +1 -1
  34. package/build/lib/constants.d.ts +6 -5
  35. package/build/lib/constants.d.ts.map +1 -1
  36. package/build/lib/constants.js +65 -59
  37. package/build/lib/constants.js.map +1 -1
  38. package/build/lib/extension/driver-config.js +199 -164
  39. package/build/lib/extension/driver-config.js.map +1 -1
  40. package/build/lib/extension/extension-config.d.ts +33 -26
  41. package/build/lib/extension/extension-config.d.ts.map +1 -1
  42. package/build/lib/extension/extension-config.js +541 -396
  43. package/build/lib/extension/extension-config.js.map +1 -1
  44. package/build/lib/extension/index.js +98 -68
  45. package/build/lib/extension/index.js.map +1 -1
  46. package/build/lib/extension/manifest-migrations.d.ts +27 -0
  47. package/build/lib/extension/manifest-migrations.d.ts.map +1 -0
  48. package/build/lib/extension/manifest-migrations.js +118 -0
  49. package/build/lib/extension/manifest-migrations.js.map +1 -0
  50. package/build/lib/extension/manifest.d.ts +35 -63
  51. package/build/lib/extension/manifest.d.ts.map +1 -1
  52. package/build/lib/extension/manifest.js +500 -240
  53. package/build/lib/extension/manifest.js.map +1 -1
  54. package/build/lib/extension/package-changed.js +57 -61
  55. package/build/lib/extension/package-changed.js.map +1 -1
  56. package/build/lib/extension/plugin-config.d.ts +2 -3
  57. package/build/lib/extension/plugin-config.d.ts.map +1 -1
  58. package/build/lib/extension/plugin-config.js +94 -70
  59. package/build/lib/extension/plugin-config.js.map +1 -1
  60. package/build/lib/grid-register.js +119 -137
  61. package/build/lib/grid-register.js.map +1 -1
  62. package/build/lib/logger.d.ts +1 -1
  63. package/build/lib/logger.d.ts.map +1 -1
  64. package/build/lib/logger.js +5 -15
  65. package/build/lib/logger.js.map +1 -1
  66. package/build/lib/logsink.d.ts.map +1 -1
  67. package/build/lib/logsink.js +189 -183
  68. package/build/lib/logsink.js.map +1 -1
  69. package/build/lib/main.d.ts +19 -12
  70. package/build/lib/main.d.ts.map +1 -1
  71. package/build/lib/main.js +330 -304
  72. package/build/lib/main.js.map +1 -1
  73. package/build/lib/schema/arg-spec.js +153 -108
  74. package/build/lib/schema/arg-spec.js.map +1 -1
  75. package/build/lib/schema/cli-args.js +203 -164
  76. package/build/lib/schema/cli-args.js.map +1 -1
  77. package/build/lib/schema/cli-transformers.js +117 -72
  78. package/build/lib/schema/cli-transformers.js.map +1 -1
  79. package/build/lib/schema/index.js +17 -32
  80. package/build/lib/schema/index.js.map +1 -1
  81. package/build/lib/schema/keywords.js +125 -67
  82. package/build/lib/schema/keywords.js.map +1 -1
  83. package/build/lib/schema/schema.d.ts.map +1 -1
  84. package/build/lib/schema/schema.js +582 -417
  85. package/build/lib/schema/schema.js.map +1 -1
  86. package/build/lib/utils.d.ts +41 -255
  87. package/build/lib/utils.d.ts.map +1 -1
  88. package/build/lib/utils.js +342 -193
  89. package/build/lib/utils.js.map +1 -1
  90. package/build/tsconfig.tsbuildinfo +1 -1
  91. package/build/types/cli.d.ts +45 -34
  92. package/build/types/cli.d.ts.map +1 -1
  93. package/build/types/cli.js +3 -0
  94. package/build/types/cli.js.map +1 -0
  95. package/build/types/index.d.ts +1 -2
  96. package/build/types/index.d.ts.map +1 -1
  97. package/build/types/index.js +19 -0
  98. package/build/types/index.js.map +1 -0
  99. package/build/types/manifest/base.d.ts +135 -0
  100. package/build/types/manifest/base.d.ts.map +1 -0
  101. package/build/types/manifest/base.js +3 -0
  102. package/build/types/manifest/base.js.map +1 -0
  103. package/build/types/manifest/index.d.ts +19 -0
  104. package/build/types/manifest/index.d.ts.map +1 -0
  105. package/build/types/manifest/index.js +40 -0
  106. package/build/types/manifest/index.js.map +1 -0
  107. package/build/types/manifest/v3.d.ts +139 -0
  108. package/build/types/manifest/v3.d.ts.map +1 -0
  109. package/build/types/manifest/v3.js +3 -0
  110. package/build/types/manifest/v3.js.map +1 -0
  111. package/lib/appium.js +1 -1
  112. package/lib/cli/args.js +1 -1
  113. package/lib/cli/driver-command.js +17 -0
  114. package/lib/cli/extension-command.js +119 -65
  115. package/lib/cli/extension.js +9 -8
  116. package/lib/cli/parser.js +2 -2
  117. package/lib/config-file.js +2 -3
  118. package/lib/config.js +3 -2
  119. package/lib/constants.js +7 -5
  120. package/lib/extension/extension-config.js +52 -47
  121. package/lib/extension/manifest-migrations.js +120 -0
  122. package/lib/extension/manifest.js +184 -103
  123. package/lib/extension/plugin-config.js +1 -2
  124. package/lib/logsink.js +26 -5
  125. package/lib/main.js +58 -50
  126. package/lib/schema/schema.js +6 -1
  127. package/lib/utils.js +62 -0
  128. package/package.json +24 -25
  129. package/scripts/autoinstall-extensions.js +78 -26
  130. package/types/cli.ts +81 -42
  131. package/types/index.ts +1 -2
  132. package/types/manifest/README.md +30 -0
  133. package/types/manifest/base.ts +158 -0
  134. package/types/manifest/index.ts +27 -0
  135. package/types/manifest/v3.ts +161 -0
  136. package/build/types/appium-manifest.d.ts +0 -59
  137. package/build/types/appium-manifest.d.ts.map +0 -1
  138. package/build/types/extension-manifest.d.ts +0 -55
  139. package/build/types/extension-manifest.d.ts.map +0 -1
  140. package/types/appium-manifest.ts +0 -73
  141. package/types/extension-manifest.ts +0 -64
package/types/cli.ts CHANGED
@@ -1,23 +1,39 @@
1
- import {ServerArgs} from '@appium/types';
2
- export type ServerSubcommand = 'server';
3
- export type DriverSubcommand = 'driver';
4
- export type PluginSubcommand = 'plugin';
1
+ import {DriverType, PluginType, ServerArgs} from '@appium/types';
2
+ import {SetOptional} from 'type-fest';
3
+ import {InstallType} from './manifest';
4
+ export type ServerCommand = 'server';
5
+ export type DriverCommand = DriverType;
6
+ export type PluginCommand = PluginType;
5
7
 
6
8
  /**
7
- * Possible subcommands for the `appium` CLI.
9
+ * Extension-specific commands
8
10
  */
9
- export type CliSubcommand = ServerSubcommand | DriverSubcommand | PluginSubcommand;
11
+ export type CliExtensionCommand = DriverCommand | PluginCommand;
10
12
 
11
13
  /**
12
- * Possible subcommands of {@linkcode DriverSubcommand} or
13
- * {@linkcode PluginSubcommand}.
14
+ * Possible commands for the `appium` CLI.
14
15
  */
15
- export type CliExtensionSubcommand =
16
- | 'install'
17
- | 'list'
18
- | 'run'
19
- | 'uninstall'
20
- | 'update';
16
+ export type CliCommand = ServerCommand | CliExtensionCommand;
17
+
18
+ /**
19
+ * Possible subcommands of {@linkcode DriverCommand} or
20
+ * {@linkcode PluginCommand}.
21
+ */
22
+ export type CliExtensionSubcommand = 'install' | 'list' | 'run' | 'uninstall' | 'update';
23
+
24
+ export interface CliExtensionSubcommandListArgs {
25
+ showInstalled?: boolean;
26
+ showUpdates?: boolean;
27
+ }
28
+
29
+ export interface CliExtensionSubcommandInstallArgs {
30
+ installType: InstallType;
31
+ packageName?: string;
32
+ }
33
+
34
+ export interface CliExtensionSubcommandUpdateArgs {
35
+ unsafe?: boolean;
36
+ }
21
37
 
22
38
  /**
23
39
  * Random stuff that may appear in the parsed args which has no equivalent in a
@@ -25,9 +41,9 @@ export type CliExtensionSubcommand =
25
41
  */
26
42
  export interface MoreArgs {
27
43
  /**
28
- * Possible subcommands. If empty, defaults to {@linkcode ServerSubcommand}.
44
+ * Possible subcommands. If empty, defaults to {@linkcode ServerCommand}.
29
45
  */
30
- subcommand?: CliSubcommand;
46
+ subcommand?: CliCommand;
31
47
 
32
48
  /**
33
49
  * Path to config file, if any. Does not make sense for this to be allowed in a config file!
@@ -79,19 +95,21 @@ export interface ProgrammaticArgs {
79
95
  showConfig?: boolean;
80
96
  }
81
97
 
98
+ export interface DriverExtArgs {
99
+ driverCommand: CliExtensionSubcommand;
100
+ driver?: string;
101
+ }
102
+
103
+ export interface PluginExtArgs {
104
+ pluginCommand: CliExtensionSubcommand;
105
+ plugin?: string;
106
+ }
107
+
82
108
  /**
83
109
  * These are args which the user will specify if using an extension command
84
110
  */
85
- export interface ExtArgs extends WithExtSubcommand {
86
- /**
87
- * Subcommands of `driver` subcommand
88
- */
89
- driverCommand?: CliExtensionSubcommand;
90
-
91
- /**
92
- * Subcommands of `plugin` subcommand
93
- */
94
- pluginCommand?: CliExtensionSubcommand;
111
+ export interface BaseExtArgs<Cmd extends CliExtensionCommand> {
112
+ subcommand: Cmd;
95
113
 
96
114
  /**
97
115
  * Output JSON instead of human-readable text
@@ -110,35 +128,56 @@ export interface ExtArgs extends WithExtSubcommand {
110
128
  }
111
129
 
112
130
  /**
113
- * Args having the `server` subcommand
131
+ * Args for extension commands; includes a subcommand
114
132
  */
115
- export interface WithServerSubcommand {
116
- subcommand?: ServerSubcommand;
117
- }
118
-
119
- /**
120
- * Args having the `driver` or `plugin` subcommand
121
- */
122
- export interface WithExtSubcommand {
123
- subcommand: DriverSubcommand | PluginSubcommand;
124
- }
133
+ export type ExtArgs<
134
+ Cmd extends CliExtensionCommand,
135
+ SubCmd extends CliExtensionSubcommand
136
+ > = BaseExtArgs<Cmd> &
137
+ (Cmd extends DriverCommand ? DriverExtArgs : Cmd extends PluginCommand ? PluginExtArgs : never) &
138
+ (SubCmd extends 'install'
139
+ ? CliExtensionSubcommandInstallArgs
140
+ : SubCmd extends 'list'
141
+ ? CliExtensionSubcommandListArgs
142
+ : SubCmd extends 'update'
143
+ ? CliExtensionSubcommandUpdateArgs
144
+ : never);
125
145
 
126
146
  /**
127
147
  * Some generic bits of arguments; should not be used outside this declaration
128
148
  */
129
- type CommonArgs<SArgs, T = WithServerSubcommand> = MoreArgs &
149
+ export type CommonArgs<
150
+ Cmd extends CliCommand = ServerCommand,
151
+ SubCmd extends CliExtensionSubcommand | void = void
152
+ > = MoreArgs &
130
153
  ProgrammaticArgs &
131
- (T extends WithServerSubcommand ? SArgs : T extends WithExtSubcommand ? ExtArgs : never);
154
+ (Cmd extends ServerCommand
155
+ ? ServerArgs
156
+ : Cmd extends CliExtensionCommand
157
+ ? SubCmd extends CliExtensionSubcommand
158
+ ? ExtArgs<Cmd, SubCmd>
159
+ : never
160
+ : never);
132
161
 
133
162
  /**
134
163
  * Fully-parsed arguments, containing defaults, computed args, and config file values.
135
164
  */
136
- export type ParsedArgs<T = WithServerSubcommand> = CommonArgs<ServerArgs, T>;
165
+ export type ParsedArgs<
166
+ Cmd extends CliCommand = ServerCommand,
167
+ SubCmd extends CliExtensionSubcommand | void = void
168
+ > = CommonArgs<Cmd, SubCmd>;
137
169
 
138
170
  /**
139
- * Partial arguments, as supplied by a user. _May_ have defaults applied; _may_ contain config values; _may_ contain computed args.
171
+ * Like {@linkcode ParsedArgs} except server arguments are all optional.
172
+ *
173
+ * _May_ have defaults applied; _may_ contain config values; _may_ contain computed args.
140
174
  */
141
- export type Args<T = WithServerSubcommand> = CommonArgs<Partial<ServerArgs>, T>;
175
+ export type Args<
176
+ Cmd extends CliCommand = ServerCommand,
177
+ SubCmd extends CliExtensionSubcommand | void = void
178
+ > = Cmd extends ServerCommand
179
+ ? SetOptional<CommonArgs<Cmd>, keyof ServerArgs>
180
+ : ParsedArgs<Cmd, SubCmd>;
142
181
 
143
182
  /**
144
183
  * Shown by `appium --build-info`
package/types/index.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import {ExtensionType, DriverType, DriverClass, PluginType, PluginClass} from '@appium/types';
2
2
 
3
- export * from './appium-manifest';
4
- export * from './extension-manifest';
3
+ export * from './manifest';
5
4
  export * from './cli';
6
5
 
7
6
  /**
@@ -0,0 +1,30 @@
1
+ # appium-manifest types
2
+
3
+ This dir contains versioned type declarations for our manifest file (`extensions.yaml`).
4
+
5
+ ## About
6
+
7
+ Originally, the manifest file was versioned; it had a `schemaRev` prop. Eventually, the requirement for this prop was dropped, and became optional. As of this writing, it is now required again.
8
+
9
+ The idea was that if Appium found an `extensions.yaml` with a `schemaRev` lower than its "current" revision, it would "migrate" the file to the current revision. When we removed the requirement for the `schemaRev` prop, we removed this logic.
10
+
11
+ As of _v3_ of the schema, we are reinstating versioning and migrations.
12
+
13
+ ## How To Add A New Version
14
+
15
+ The manifest file types—and thus its format—is composed of types used elsewhere in our codebase. This is probably a design flaw, but the fact remains that the manifest file's format is strongly coupled to Appium's extension-handling logic.
16
+
17
+ For that reason, it is _non-trivial_ to reuse the types declared by older revisions to declare a new revision. If and when someone de-couples the types from the schema, we will have to use the _copy-and-paste_ strategy to create a new version.
18
+
19
+ 1. The current version of the schema is defined in `constants.js` as `CURRENT_SCHEMA_REV`. **Increment** this value.
20
+ 2. **Copy** the `.ts` file in this directory corresponding to the (now old) current version of the schema into a new file named `v<new-version>.ts`. For example, if the current version is `3`, and you're creating `4`, then you would copy `v3.ts` to `v4.ts`.
21
+ 3. **Modify** your new file to do whatever it is you need to do with it. Do _not_ build types upon old versions of the schema.
22
+ 4. **Modify** `index.ts`:
23
+ 1. **Append** `import * as ManifestV<new-version> from './v<new-version>'`
24
+ 2. **Replace** `export * from './v<current-version>'` with `export * from './v<new-version>'`
25
+ 3. **Append** `ManifestV<new-version>` to the `export {ManifestV...}` line.
26
+ 4. **Append** a key/value pair to `ManifestDataVersions` with the new _numeric_ version number as the key and the value `ManifestV<new-version>.ManifestData`.
27
+ 5. **Create** a new `const SCHEMA_REV_<new-version> = <new-version>` in `manifest-migrations.js`.
28
+ 6. Finally, **append** a new key/value pair to the `Migrations` object in `manifest-migrations.js`. The key should be a reference to the constant created in step 5, and the value should be a function which performs the migration from the (old) current version to the new version.
29
+
30
+ -- @boneskull, Nov 8 2022
@@ -0,0 +1,158 @@
1
+ import {DriverType, ExtensionType, PluginType} from '@appium/types';
2
+ import {SchemaObject} from 'ajv';
3
+ import {PackageJson, SetRequired} from 'type-fest';
4
+
5
+ /**
6
+ * One of the possible extension installation stratgies
7
+ */
8
+ export type InstallType = 'npm' | 'git' | 'local' | 'github';
9
+
10
+ export interface InternalMetadata {
11
+ /**
12
+ * Package name of extension
13
+ *
14
+ * `name` from its `package.json`
15
+ */
16
+ pkgName: string;
17
+ /**
18
+ * Version of extension
19
+ *
20
+ * `version` from its `package.json`
21
+ */
22
+ version: string;
23
+ /**
24
+ * The method in which the user installed the extension (the `source` CLI arg)
25
+ */
26
+ installType: InstallType;
27
+ /**
28
+ * Whatever the user typed as the extension to install. May be derived from `package.json`
29
+ */
30
+ installSpec: string;
31
+ /**
32
+ * Maximum version of Appium that this extension is compatible with.
33
+ *
34
+ * If `undefined`, we'll try anyway.
35
+ */
36
+ appiumVersion?: string;
37
+ }
38
+
39
+ /**
40
+ * Shape of the `appium.schema` property in an extension's `package.json` (if it exists)
41
+ */
42
+ export type ExtSchemaMetadata = string | (SchemaObject & {[key: number]: never});
43
+
44
+ /**
45
+ * Manifest data shared by all extensions, as contained in `package.json`
46
+ */
47
+ export interface CommonExtMetadata {
48
+ /**
49
+ * The main class of the extension.
50
+ *
51
+ * The extension must export this class by name.
52
+ */
53
+ mainClass: string;
54
+
55
+ /**
56
+ * Lookup table of scripts to run via `appium <driver|plugin> run <script>` keyed by name.
57
+ */
58
+ scripts?: Record<string, string>;
59
+
60
+ /**
61
+ * Schema describing configuration options (and CLI args) for the extension.
62
+ *
63
+ * Can also just be a path (relative to the extension root) to an external JSON schema file.
64
+ */
65
+
66
+ schema?: ExtSchemaMetadata;
67
+ }
68
+
69
+ /**
70
+ * Driver-specific manifest data as stored in a driver's `package.json`
71
+ */
72
+ export interface DriverMetadata {
73
+ /**
74
+ * Automation name of the driver
75
+ */
76
+ automationName: string;
77
+ /**
78
+ * Platforms the driver supports
79
+ */
80
+ platformNames: string[];
81
+ /**
82
+ * Short name of the driver (displayed in `appium list`, etc.)
83
+ */
84
+ driverName: string;
85
+ }
86
+
87
+ /**
88
+ * Plugin-specific manifest data as stored in a plugin's `package.json`
89
+ */
90
+ export interface PluginMetadata {
91
+ /**
92
+ * Short name of the plugin (displayed in `appium list`, etc.)
93
+ */
94
+ pluginName: string;
95
+ }
96
+
97
+ /**
98
+ * Generic extension metadata as stored in the `appium` prop of an extension's `package.json`.
99
+ */
100
+ export type ExtMetadata<ExtType extends ExtensionType> = (ExtType extends DriverType
101
+ ? DriverMetadata
102
+ : ExtType extends PluginType
103
+ ? PluginMetadata
104
+ : never) &
105
+ CommonExtMetadata;
106
+
107
+ /**
108
+ * Combination of external + internal extension data with `driverName`/`pluginName` removed (it becomes a key in an {@linkcode ExtRecord} object).
109
+ * Part of `extensions.yaml`.
110
+ */
111
+ export type ExtManifest<ExtType extends ExtensionType> = Omit<
112
+ ExtMetadata<ExtType>,
113
+ 'driverName' | 'pluginName'
114
+ > &
115
+ InternalMetadata;
116
+
117
+ /**
118
+ * Lookup of extension name to {@linkcode ExtManifest}.
119
+ * @see {ManifestData}
120
+ */
121
+ export type ExtRecord<ExtType extends ExtensionType> = Record<string, ExtManifest<ExtType>>;
122
+
123
+ /**
124
+ * The shape of the `extensions.yaml` file
125
+ */
126
+ export interface ManifestData {
127
+ drivers: ExtRecord<DriverType>;
128
+ plugins: ExtRecord<PluginType>;
129
+ schemaRev?: number;
130
+ }
131
+
132
+ /**
133
+ * The name of an installed extension, as it appears in `extensions.yaml`
134
+ * (as a property name under `drivers` or `plugins`)
135
+ */
136
+ export type ExtName<ExtType extends ExtensionType> = keyof ExtRecord<ExtType>;
137
+
138
+ /**
139
+ * A `package.json` containing extension metadata.
140
+ * Must have the following properties:
141
+ * - `name`: the name of the extension
142
+ * - `version`: the version of the extension
143
+ * - `appium`: the metadata for the extension
144
+ * - `peerDependencies.appium`: the maximum compatible version of Appium
145
+ */
146
+ export type ExtPackageJson<ExtType extends ExtensionType> = SetRequired<
147
+ PackageJson,
148
+ 'name' | 'version'
149
+ > & {
150
+ appium: ExtMetadata<ExtType>;
151
+ peerDependencies: {appium: string; [key: string]: string};
152
+ };
153
+
154
+ /**
155
+ * A transient format between installation and insertion of extension metadata into the manifest.
156
+ */
157
+ export type ExtInstallReceipt<ExtType extends ExtensionType> = ExtMetadata<ExtType> &
158
+ InternalMetadata;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * See `README.md` for information on how to add a new version of the schema.
3
+ * @module
4
+ */
5
+
6
+ import * as ManifestV2 from './base';
7
+ import * as ManifestV3 from './v3';
8
+
9
+ // add `import * as ManifestV<new-version> from './v<new-version>';` above
10
+
11
+ export * from './v3';
12
+ // replace above line with `export * from './v<new-version>';`
13
+
14
+ export {ManifestV2, ManifestV3};
15
+
16
+ export interface ManifestDataVersions {
17
+ 2: ManifestV2.ManifestData;
18
+ 3: ManifestV3.ManifestData;
19
+ }
20
+ // append to this interface your new version of `ManifestData`
21
+
22
+ /**
23
+ * One of the known versions of the `extensions.yaml` schema.
24
+ *
25
+ * @privateRemarks You probably don't need to edit this.
26
+ */
27
+ export type AnyManifestDataVersion = ManifestDataVersions[keyof ManifestDataVersions];
@@ -0,0 +1,161 @@
1
+ import {DriverType, ExtensionType, PluginType} from '@appium/types';
2
+ import {SchemaObject} from 'ajv';
3
+ import {PackageJson, SetRequired} from 'type-fest';
4
+
5
+ /**
6
+ * One of the possible extension installation stratgies
7
+ */
8
+ export type InstallType = 'npm' | 'git' | 'local' | 'github';
9
+
10
+ export interface InternalMetadata {
11
+ /**
12
+ * Package name of extension
13
+ *
14
+ * `name` from its `package.json`
15
+ */
16
+ pkgName: string;
17
+ /**
18
+ * Version of extension
19
+ *
20
+ * `version` from its `package.json`
21
+ */
22
+ version: string;
23
+ /**
24
+ * The method in which the user installed the extension (the `source` CLI arg)
25
+ */
26
+ installType: InstallType;
27
+ /**
28
+ * Whatever the user typed as the extension to install. May be derived from `package.json`
29
+ */
30
+ installSpec: string;
31
+ /**
32
+ * Maximum version of Appium that this extension is compatible with.
33
+ *
34
+ * If `undefined`, we'll try anyway.
35
+ */
36
+ appiumVersion?: string;
37
+ /**
38
+ * Path to the extension's root directory
39
+ */
40
+ installPath: string;
41
+ }
42
+
43
+ /**
44
+ * Shape of the `appium.schema` property in an extension's `package.json` (if it exists)
45
+ */
46
+ export type ExtSchemaMetadata = string | (SchemaObject & {[key: number]: never});
47
+
48
+ /**
49
+ * Manifest data shared by all extensions, as contained in `package.json`
50
+ */
51
+ export interface CommonExtMetadata {
52
+ /**
53
+ * The main class of the extension.
54
+ *
55
+ * The extension must export this class by name.
56
+ */
57
+ mainClass: string;
58
+
59
+ /**
60
+ * Lookup table of scripts to run via `appium <driver|plugin> run <script>` keyed by name.
61
+ */
62
+ scripts?: Record<string, string>;
63
+
64
+ /**
65
+ * Schema describing configuration options (and CLI args) for the extension.
66
+ *
67
+ * Can also just be a path (relative to the extension root) to an external JSON schema file.
68
+ */
69
+ schema?: ExtSchemaMetadata;
70
+ }
71
+
72
+ /**
73
+ * Driver-specific manifest data as stored in a driver's `package.json`
74
+ */
75
+ export interface DriverMetadata {
76
+ /**
77
+ * Automation name of the driver
78
+ */
79
+ automationName: string;
80
+ /**
81
+ * Platforms the driver supports
82
+ */
83
+ platformNames: string[];
84
+ /**
85
+ * Short name of the driver (displayed in `appium list`, etc.)
86
+ */
87
+ driverName: string;
88
+ }
89
+
90
+ /**
91
+ * Plugin-specific manifest data as stored in a plugin's `package.json`
92
+ */
93
+ export interface PluginMetadata {
94
+ /**
95
+ * Short name of the plugin (displayed in `appium list`, etc.)
96
+ */
97
+ pluginName: string;
98
+ }
99
+
100
+ /**
101
+ * Generic extension metadata as stored in the `appium` prop of an extension's `package.json`.
102
+ */
103
+ export type ExtMetadata<ExtType extends ExtensionType> = (ExtType extends DriverType
104
+ ? DriverMetadata
105
+ : ExtType extends PluginType
106
+ ? PluginMetadata
107
+ : never) &
108
+ CommonExtMetadata;
109
+
110
+ /**
111
+ * Combination of external + internal extension data with `driverName`/`pluginName` removed (it becomes a key in an {@linkcode ExtRecord} object).
112
+ * Part of `extensions.yaml`.
113
+ */
114
+ export type ExtManifest<ExtType extends ExtensionType> = Omit<
115
+ ExtMetadata<ExtType>,
116
+ 'driverName' | 'pluginName'
117
+ > &
118
+ InternalMetadata;
119
+
120
+ /**
121
+ * Lookup of extension name to {@linkcode ExtManifest}.
122
+ * @see {ManifestData}
123
+ */
124
+ export type ExtRecord<ExtType extends ExtensionType> = Record<string, ExtManifest<ExtType>>;
125
+
126
+ /**
127
+ * The shape of the `extensions.yaml` file
128
+ */
129
+ export interface ManifestData {
130
+ drivers: ExtRecord<DriverType>;
131
+ plugins: ExtRecord<PluginType>;
132
+ schemaRev: number;
133
+ }
134
+
135
+ /**
136
+ * The name of an installed extension, as it appears in `extensions.yaml`
137
+ * (as a property name under `drivers` or `plugins`)
138
+ */
139
+ export type ExtName<ExtType extends ExtensionType> = keyof ExtRecord<ExtType>;
140
+
141
+ /**
142
+ * A `package.json` containing extension metadata.
143
+ * Must have the following properties:
144
+ * - `name`: the name of the extension
145
+ * - `version`: the version of the extension
146
+ * - `appium`: the metadata for the extension
147
+ * - `peerDependencies.appium`: the maximum compatible version of Appium
148
+ */
149
+ export type ExtPackageJson<ExtType extends ExtensionType> = SetRequired<
150
+ PackageJson,
151
+ 'name' | 'version'
152
+ > & {
153
+ appium: ExtMetadata<ExtType>;
154
+ peerDependencies: {appium: string; [key: string]: string};
155
+ };
156
+
157
+ /**
158
+ * A transient format between installation and insertion of extension metadata into the manifest.
159
+ */
160
+ export type ExtInstallReceipt<ExtType extends ExtensionType> = ExtMetadata<ExtType> &
161
+ InternalMetadata;
@@ -1,59 +0,0 @@
1
- import { CommonExtMetadata, ExtMetadata, ExtSchemaMetadata } from './extension-manifest';
2
- import { ExtensionType, DriverType, PluginType } from '@appium/types';
3
- export declare type InstallType = 'npm' | 'git' | 'local' | 'github';
4
- export interface InternalMetadata {
5
- /**
6
- * Package name of extension
7
- *
8
- * `name` from its `package.json`
9
- */
10
- pkgName: string;
11
- /**
12
- * Version of extension
13
- *
14
- * `version` from its `package.json`
15
- */
16
- version: string;
17
- /**
18
- * The method in which the user installed the extension (the `source` CLI arg)
19
- */
20
- installType: InstallType;
21
- /**
22
- * Whatever the user typed as the extension to install. May be derived from `package.json`
23
- */
24
- installSpec: string;
25
- /**
26
- * Maximum version of Appium that this extension is compatible with.
27
- *
28
- * If `undefined`, we'll try anyway.
29
- */
30
- appiumVersion?: string;
31
- }
32
- /**
33
- * Combination of external + internal extension data with `driverName`/`pluginName` removed (it becomes a key in an {@linkcode ExtRecord} object).
34
- * Part of `extensions.yaml`.
35
- */
36
- export declare type ExtManifest<ExtType extends ExtensionType> = Omit<ExtMetadata<ExtType>, ExtType extends DriverType ? 'driverName' : ExtType extends PluginType ? 'pluginName' : never> & InternalMetadata & CommonExtMetadata;
37
- export declare type WithSchemaManifest = {
38
- schema: ExtSchemaMetadata;
39
- };
40
- /**
41
- * This is just a {@linkcode ExtManifest} except it _for sure_ has a `schema` prop.
42
- */
43
- export declare type ExtManifestWithSchema<ExtType extends ExtensionType> = ExtManifest<ExtType> & WithSchemaManifest;
44
- /**
45
- * Generic type for an object keyed by extension name, with values of type {@linkcode ExtData}
46
- */
47
- export declare type ExtRecord<ExtType extends ExtensionType> = Record<string, ExtManifest<ExtType>>;
48
- export declare type DriverRecord = ExtRecord<DriverType>;
49
- export declare type PluginRecord = ExtRecord<PluginType>;
50
- export declare type ExtName<ExtType extends ExtensionType> = keyof ExtRecord<ExtType>;
51
- /**
52
- * Represents an entire YAML manifest (`extensions.yaml`)
53
- */
54
- export interface ManifestData {
55
- drivers: DriverRecord;
56
- plugins: PluginRecord;
57
- schemaRev?: number;
58
- }
59
- //# sourceMappingURL=appium-manifest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"appium-manifest.d.ts","sourceRoot":"","sources":["../../types/appium-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,WAAW,EAAE,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAC,aAAa,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAEpE,oBAAY,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,oBAAY,WAAW,CAAC,OAAO,SAAS,aAAa,IAAI,IAAI,CAC3D,WAAW,CAAC,OAAO,CAAC,EACpB,OAAO,SAAS,UAAU,GAAG,YAAY,GAAG,OAAO,SAAS,UAAU,GAAG,YAAY,GAAG,KAAK,CAC9F,GACC,gBAAgB,GAChB,iBAAiB,CAAC;AAEpB,oBAAY,kBAAkB,GAAG;IAC/B,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,oBAAY,qBAAqB,CAAC,OAAO,SAAS,aAAa,IAAI,WAAW,CAAC,OAAO,CAAC,GACrF,kBAAkB,CAAC;AAErB;;GAEG;AACH,oBAAY,SAAS,CAAC,OAAO,SAAS,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AAE5F,oBAAY,YAAY,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;AACjD,oBAAY,YAAY,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;AAEjD,oBAAY,OAAO,CAAC,OAAO,SAAS,aAAa,IAAI,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -1,55 +0,0 @@
1
- /**
2
- * These types describe information about external extensions and the contents of their `package.json` files
3
- */
4
- import type { SchemaObject } from 'ajv';
5
- import type { PackageJson, SetRequired } from 'type-fest';
6
- import { DriverType, ExtensionType, PluginType } from '@appium/types';
7
- /**
8
- * This is what is allowed in the `appium.schema` prop of an extension's `package.json`.
9
- */
10
- export declare type ExtSchemaMetadata = string | (SchemaObject & {
11
- [key: number]: never;
12
- });
13
- /**
14
- * Manifest data shared by all extensions, as contained in `package.json`
15
- */
16
- export interface CommonExtMetadata {
17
- mainClass: string;
18
- scripts?: Record<string, string>;
19
- schema?: ExtSchemaMetadata;
20
- }
21
- /**
22
- * Driver-specific manifest data as contained in `package.json`
23
- */
24
- export interface DriverMetadata {
25
- automationName: string;
26
- platformNames: string[];
27
- driverName: string;
28
- }
29
- /**
30
- * Plugin-specific manifest data as stored in `package.json`
31
- */
32
- export interface PluginMetadata {
33
- pluginName: string;
34
- }
35
- /**
36
- * Generic type to refer to either {@linkcode DriverMetadata} or {@linkcode PluginMetadata}
37
- * Corresponds to the `appium` prop in an extension's `package.json`.
38
- */
39
- export declare type ExtMetadata<ExtType extends ExtensionType> = (ExtType extends DriverType ? DriverMetadata : ExtType extends PluginType ? PluginMetadata : never) & CommonExtMetadata;
40
- /**
41
- * A `package.json` containing extension metadata.
42
- * Must have the following properties:
43
- * - `name`: the name of the extension
44
- * - `version`: the version of the extension
45
- * - `appium`: the metadata for the extension
46
- * - `peerDependencies.appium`: the maximum compatible version of Appium
47
- */
48
- export declare type ExtPackageJson<ExtType extends ExtensionType> = SetRequired<PackageJson, 'name' | 'version'> & {
49
- appium: ExtMetadata<ExtType>;
50
- peerDependencies: {
51
- appium: string;
52
- [key: string]: string;
53
- };
54
- };
55
- //# sourceMappingURL=extension-manifest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extension-manifest.d.ts","sourceRoot":"","sources":["../../types/extension-manifest.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAC,WAAW,EAAE,WAAW,EAAC,MAAM,WAAW,CAAC;AACxD,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAEpE;;GAEG;AACH,oBAAY,iBAAiB,GAAG,MAAM,GAAG,CAAC,YAAY,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;CAAC,CAAC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,oBAAY,WAAW,CAAC,OAAO,SAAS,aAAa,IAAI,CAAC,OAAO,SAAS,UAAU,GAChF,cAAc,GACd,OAAO,SAAS,UAAU,GAC1B,cAAc,GACd,KAAK,CAAC,GACR,iBAAiB,CAAC;AAEpB;;;;;;;GAOG;AACH,oBAAY,cAAc,CAAC,OAAO,SAAS,aAAa,IAAI,WAAW,CACrE,WAAW,EACX,MAAM,GAAG,SAAS,CACnB,GAAG;IACF,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,gBAAgB,EAAE;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAC;CAC3D,CAAC"}