node-devicectl 1.0.0 → 1.1.0
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.
- package/CHANGELOG.md +21 -0
- package/build/lib/devicectl.d.ts +39 -0
- package/build/lib/devicectl.d.ts.map +1 -0
- package/build/lib/devicectl.js +111 -0
- package/build/lib/devicectl.js.map +1 -0
- package/build/lib/index.d.ts +3 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +6 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/mixins/copy.d.ts +11 -0
- package/build/lib/mixins/copy.d.ts.map +1 -0
- package/build/lib/mixins/copy.js +45 -0
- package/build/lib/mixins/copy.js.map +1 -0
- package/build/lib/mixins/info.d.ts +11 -0
- package/build/lib/mixins/info.d.ts.map +1 -0
- package/build/lib/mixins/info.js +25 -0
- package/build/lib/mixins/info.js.map +1 -0
- package/build/lib/mixins/list.d.ts +8 -0
- package/build/lib/mixins/list.d.ts.map +1 -0
- package/build/lib/mixins/list.js +14 -0
- package/build/lib/mixins/list.js.map +1 -0
- package/build/lib/mixins/process.d.ts +17 -0
- package/build/lib/mixins/process.d.ts.map +1 -0
- package/build/lib/mixins/process.js +48 -0
- package/build/lib/mixins/process.js.map +1 -0
- package/build/lib/types.d.ts +293 -0
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/types.js +3 -0
- package/build/lib/types.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/lib/devicectl.ts +12 -16
- package/lib/index.ts +1 -1
- package/lib/mixins/copy.ts +15 -14
- package/lib/mixins/info.ts +5 -8
- package/lib/mixins/list.ts +13 -0
- package/lib/mixins/process.ts +13 -16
- package/lib/types.ts +201 -4
- package/package.json +4 -3
package/lib/mixins/process.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type {LaunchAppOptions} from '../types';
|
|
3
|
+
import type {Devicectl} from '../devicectl';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Simulates memory warning for the process with the given PID
|
|
7
7
|
*/
|
|
8
|
-
export async function sendMemoryWarning(
|
|
9
|
-
this: Devicectl,
|
|
10
|
-
pid: number | string
|
|
11
|
-
): Promise<void> {
|
|
8
|
+
export async function sendMemoryWarning(this: Devicectl, pid: number | string): Promise<void> {
|
|
12
9
|
await this.execute(['device', 'process', 'sendMemoryWarning'], {
|
|
13
|
-
subcommandOptions: ['--pid', `${pid}`]
|
|
10
|
+
subcommandOptions: ['--pid', `${pid}`],
|
|
14
11
|
});
|
|
15
12
|
}
|
|
16
13
|
|
|
@@ -20,10 +17,10 @@ export async function sendMemoryWarning(
|
|
|
20
17
|
export async function sendSignalToProcess(
|
|
21
18
|
this: Devicectl,
|
|
22
19
|
pid: number | string,
|
|
23
|
-
signal: number | string
|
|
20
|
+
signal: number | string,
|
|
24
21
|
): Promise<void> {
|
|
25
22
|
await this.execute(['device', 'process', 'signal'], {
|
|
26
|
-
subcommandOptions: ['--signal', `${signal}`, '--pid', `${pid}`]
|
|
23
|
+
subcommandOptions: ['--signal', `${signal}`, '--pid', `${pid}`],
|
|
27
24
|
});
|
|
28
25
|
}
|
|
29
26
|
|
|
@@ -35,12 +32,9 @@ export async function sendSignalToProcess(
|
|
|
35
32
|
export async function launchApp(
|
|
36
33
|
this: Devicectl,
|
|
37
34
|
bundleId: string,
|
|
38
|
-
opts: LaunchAppOptions = {}
|
|
35
|
+
opts: LaunchAppOptions = {},
|
|
39
36
|
): Promise<void> {
|
|
40
|
-
const {
|
|
41
|
-
env,
|
|
42
|
-
terminateExisting = false
|
|
43
|
-
} = opts;
|
|
37
|
+
const {env, terminateExisting = false} = opts;
|
|
44
38
|
|
|
45
39
|
const subcommandOptions: string[] = [];
|
|
46
40
|
|
|
@@ -49,7 +43,10 @@ export async function launchApp(
|
|
|
49
43
|
}
|
|
50
44
|
|
|
51
45
|
if (!_.isEmpty(env)) {
|
|
52
|
-
subcommandOptions.push(
|
|
46
|
+
subcommandOptions.push(
|
|
47
|
+
'--environment-variables',
|
|
48
|
+
JSON.stringify(_.mapValues(env, (v) => _.toString(v))),
|
|
49
|
+
);
|
|
53
50
|
}
|
|
54
51
|
|
|
55
52
|
// The bundle id should be the last to apply arguments properly.
|
|
@@ -58,6 +55,6 @@ export async function launchApp(
|
|
|
58
55
|
|
|
59
56
|
await this.execute(['device', 'process', 'launch'], {
|
|
60
57
|
subcommandOptions,
|
|
61
|
-
asJson: false
|
|
58
|
+
asJson: false,
|
|
62
59
|
});
|
|
63
60
|
}
|
package/lib/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {SubProcess, TeenProcessExecResult} from 'teen_process';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Information about a running process on the device
|
|
@@ -42,11 +42,25 @@ export interface AppInfo {
|
|
|
42
42
|
* Options for executing devicectl commands
|
|
43
43
|
*/
|
|
44
44
|
export interface ExecuteOptions {
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Whether to drop the --device option from the actual devicectl command
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
noDevice?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to log stdout output
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
46
54
|
logStdout?: boolean;
|
|
47
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Whether to return JSON output
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
48
59
|
asJson?: boolean;
|
|
49
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Whether to run the command asynchronously
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
50
64
|
asynchronous?: boolean;
|
|
51
65
|
/** Additional subcommand options */
|
|
52
66
|
subcommandOptions?: string[] | string;
|
|
@@ -111,3 +125,186 @@ export type AsyncExecuteResult = SubProcess;
|
|
|
111
125
|
export type ExecuteResult<T extends ExecuteOptions> = T extends AsyncExecuteOptions
|
|
112
126
|
? AsyncExecuteResult
|
|
113
127
|
: SyncExecuteResult;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* CPU type information
|
|
131
|
+
*/
|
|
132
|
+
export interface CPUType {
|
|
133
|
+
/** The CPU type name
|
|
134
|
+
* @example "arm64e" */
|
|
135
|
+
name: string;
|
|
136
|
+
/** The CPU subtype
|
|
137
|
+
* @example 2 */
|
|
138
|
+
subType: number;
|
|
139
|
+
/** The CPU type identifier
|
|
140
|
+
* @example 16777228 */
|
|
141
|
+
type: number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Device capability information
|
|
146
|
+
*/
|
|
147
|
+
export interface Capability {
|
|
148
|
+
/** The feature identifier
|
|
149
|
+
* @example "com.apple.coredevice.feature.installapp" */
|
|
150
|
+
featureIdentifier: string;
|
|
151
|
+
/** The capability name
|
|
152
|
+
* @example "Install Application" */
|
|
153
|
+
name: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Connection properties for the device
|
|
158
|
+
*/
|
|
159
|
+
export interface ConnectionProperties {
|
|
160
|
+
/** The authentication type
|
|
161
|
+
* @example "manualPairing" */
|
|
162
|
+
authenticationType: string;
|
|
163
|
+
/** Whether this is a mobile device only
|
|
164
|
+
* @example false */
|
|
165
|
+
isMobileDeviceOnly: boolean;
|
|
166
|
+
/** The last connection date in ISO format
|
|
167
|
+
* @example "2025-01-01T12:00:00.000Z" */
|
|
168
|
+
lastConnectionDate?: string;
|
|
169
|
+
/** List of local hostnames
|
|
170
|
+
* @example ["MyDevice.coredevice.local", "ABCD1234-5678-90EF-GHIJ-KLMNOPQRSTUV.coredevice.local"] */
|
|
171
|
+
localHostnames?: string[];
|
|
172
|
+
/** The pairing state
|
|
173
|
+
* @example "paired" */
|
|
174
|
+
pairingState: string;
|
|
175
|
+
/** List of potential hostnames
|
|
176
|
+
* @example ["MyDevice.coredevice.local", "ABCD1234-5678-90EF-GHIJ-KLMNOPQRSTUV.coredevice.local"] */
|
|
177
|
+
potentialHostnames: string[];
|
|
178
|
+
/** The transport type
|
|
179
|
+
* @example "wired" */
|
|
180
|
+
transportType?: string;
|
|
181
|
+
/** The tunnel IP address
|
|
182
|
+
* @example "fdda:f9b3:f5d9::1" */
|
|
183
|
+
tunnelIPAddress?: string;
|
|
184
|
+
/** The tunnel state
|
|
185
|
+
* @example "connected" */
|
|
186
|
+
tunnelState: string;
|
|
187
|
+
/** The tunnel transport protocol
|
|
188
|
+
* @example "tcp" */
|
|
189
|
+
tunnelTransportProtocol?: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Device properties
|
|
194
|
+
*/
|
|
195
|
+
export interface DeviceProperties {
|
|
196
|
+
/** The boot state
|
|
197
|
+
* @example "booted" */
|
|
198
|
+
bootState?: string;
|
|
199
|
+
/** Whether booted from snapshot
|
|
200
|
+
* @example true */
|
|
201
|
+
bootedFromSnapshot?: boolean;
|
|
202
|
+
/** The booted snapshot name
|
|
203
|
+
* @example "com.apple.os.update-ABCDEF1234567890" */
|
|
204
|
+
bootedSnapshotName?: string;
|
|
205
|
+
/** Whether DDI services are available
|
|
206
|
+
* @example true */
|
|
207
|
+
ddiServicesAvailable?: boolean;
|
|
208
|
+
/** The developer mode status
|
|
209
|
+
* @example "enabled" */
|
|
210
|
+
developerModeStatus?: string;
|
|
211
|
+
/** Whether has internal OS build
|
|
212
|
+
* @example false */
|
|
213
|
+
hasInternalOSBuild?: boolean;
|
|
214
|
+
/** The device name
|
|
215
|
+
* @example "My iPhone" */
|
|
216
|
+
name: string;
|
|
217
|
+
/** The OS build update
|
|
218
|
+
* @example "22A100" */
|
|
219
|
+
osBuildUpdate: string;
|
|
220
|
+
/** The OS version number
|
|
221
|
+
* @example "18.0.0" */
|
|
222
|
+
osVersionNumber: string;
|
|
223
|
+
/** Whether root file system is writable
|
|
224
|
+
* @example false */
|
|
225
|
+
rootFileSystemIsWritable?: boolean;
|
|
226
|
+
/** The screen viewing URL
|
|
227
|
+
* @example "devices://device/open?id=ABCD1234-5678-90EF-GHIJ-KLMNOPQRSTUV" */
|
|
228
|
+
screenViewingURL?: string;
|
|
229
|
+
/** Whether supports checked allocations
|
|
230
|
+
* @example false */
|
|
231
|
+
supportsCheckedAllocations?: boolean;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Hardware properties for the device
|
|
236
|
+
*/
|
|
237
|
+
export interface HardwareProperties {
|
|
238
|
+
/** The CPU type
|
|
239
|
+
* @example { name: "arm64e", subType: 2, type: 16777228 } */
|
|
240
|
+
cpuType: CPUType;
|
|
241
|
+
/** The device type
|
|
242
|
+
* @example "iPhone" */
|
|
243
|
+
deviceType: string;
|
|
244
|
+
/** The ECID
|
|
245
|
+
* @example 1234567890123456 */
|
|
246
|
+
ecid: number;
|
|
247
|
+
/** The hardware model
|
|
248
|
+
* @example "D63AP" */
|
|
249
|
+
hardwareModel: string;
|
|
250
|
+
/** The internal storage capacity in bytes
|
|
251
|
+
* @example 128000000000 */
|
|
252
|
+
internalStorageCapacity?: number;
|
|
253
|
+
/** Whether is production fused
|
|
254
|
+
* @example true */
|
|
255
|
+
isProductionFused?: boolean;
|
|
256
|
+
/** The marketing name
|
|
257
|
+
* @example "iPhone 15" */
|
|
258
|
+
marketingName?: string;
|
|
259
|
+
/** The platform
|
|
260
|
+
* @example "iOS", "tvOS" */
|
|
261
|
+
platform: string;
|
|
262
|
+
/** The product type
|
|
263
|
+
* @example "iPhone16,1" */
|
|
264
|
+
productType: string;
|
|
265
|
+
/** The reality type (physical or simulator)
|
|
266
|
+
* @example "physical" */
|
|
267
|
+
reality?: string;
|
|
268
|
+
/** The serial number
|
|
269
|
+
* @example "ABC1234XYZ" */
|
|
270
|
+
serialNumber?: string;
|
|
271
|
+
/** List of supported CPU types
|
|
272
|
+
* @example [{ name: "arm64e", subType: 2, type: 16777228 }, { name: "arm64", subType: 0, type: 16777228 }] */
|
|
273
|
+
supportedCPUTypes?: CPUType[];
|
|
274
|
+
/** List of supported device families
|
|
275
|
+
* @example [1, 2], [3] */
|
|
276
|
+
supportedDeviceFamilies: number[];
|
|
277
|
+
/** The thinning product type
|
|
278
|
+
* @example "iPhone16,1" */
|
|
279
|
+
thinningProductType?: string;
|
|
280
|
+
/** The UDID
|
|
281
|
+
* @example "00000000-0000000000000000" */
|
|
282
|
+
udid: string;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Complete device information
|
|
287
|
+
*/
|
|
288
|
+
export interface DeviceInfo {
|
|
289
|
+
/** List of device capabilities
|
|
290
|
+
* @example [{ featureIdentifier: "com.apple.coredevice.feature.installapp", name: "Install Application" }] */
|
|
291
|
+
capabilities: Capability[];
|
|
292
|
+
/** Connection properties
|
|
293
|
+
* @example { authenticationType: "manualPairing", pairingState: "paired", transportType: "wired" } */
|
|
294
|
+
connectionProperties: ConnectionProperties;
|
|
295
|
+
/** Device properties
|
|
296
|
+
* @example { name: "My iPhone", bootState: "booted", osVersionNumber: "18.0.0" } */
|
|
297
|
+
deviceProperties: DeviceProperties;
|
|
298
|
+
/** Hardware properties
|
|
299
|
+
* @example { deviceType: "iPhone", platform: "iOS", udid: "00000000-0000000000000000" } */
|
|
300
|
+
hardwareProperties: HardwareProperties;
|
|
301
|
+
/** The device identifier
|
|
302
|
+
* @example "ABCD1234-5678-90EF-GHIJ-KLMNOPQRSTUV" */
|
|
303
|
+
identifier: string;
|
|
304
|
+
/** List of tags
|
|
305
|
+
* @example [] */
|
|
306
|
+
tags: string[];
|
|
307
|
+
/** The visibility class
|
|
308
|
+
* @example "default" */
|
|
309
|
+
visibilityClass: string;
|
|
310
|
+
}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"device",
|
|
9
9
|
"xcode"
|
|
10
10
|
],
|
|
11
|
-
"version": "1.
|
|
11
|
+
"version": "1.1.0",
|
|
12
12
|
"author": "Appium Contributors",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"repository": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0",
|
|
23
23
|
"npm": ">=10"
|
|
24
24
|
},
|
|
25
|
-
"main": "./build/index.js",
|
|
26
|
-
"types": "./build/index.d.ts",
|
|
25
|
+
"main": "./build/lib/index.js",
|
|
26
|
+
"types": "./build/lib/index.d.ts",
|
|
27
27
|
"bin": {},
|
|
28
28
|
"directories": {
|
|
29
29
|
"lib": "./lib"
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"clean": "npm run build -- --clean",
|
|
44
44
|
"rebuild": "npm run clean; npm run build",
|
|
45
45
|
"dev": "npm run build -- --watch",
|
|
46
|
+
"format": "prettier -w ./lib",
|
|
46
47
|
"lint": "eslint .",
|
|
47
48
|
"lint:fix": "npm run lint -- --fix",
|
|
48
49
|
"prepare": "npm run build",
|