device-shots 0.5.7 → 0.5.8
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/dist/index.js +23 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -334,49 +334,37 @@ async function discoverAndroidDevices(bundleId) {
|
|
|
334
334
|
}
|
|
335
335
|
return devices;
|
|
336
336
|
}
|
|
337
|
-
|
|
337
|
+
function sleep(ms) {
|
|
338
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
339
|
+
}
|
|
340
|
+
async function adbShell(serial, args) {
|
|
338
341
|
const adb = getAdbPath();
|
|
339
|
-
const { stdout, stderr } = await run(adb, ["-s", serial, "shell",
|
|
342
|
+
const { stdout, stderr } = await run(adb, ["-s", serial, "shell", ...args]);
|
|
340
343
|
return stdout || stderr;
|
|
341
344
|
}
|
|
342
|
-
function
|
|
343
|
-
|
|
345
|
+
async function demoBroadcast(serial, extras) {
|
|
346
|
+
await adbShell(serial, [
|
|
347
|
+
"am",
|
|
348
|
+
"broadcast",
|
|
349
|
+
"-a",
|
|
350
|
+
"com.android.systemui.demo",
|
|
351
|
+
...extras
|
|
352
|
+
]);
|
|
344
353
|
}
|
|
345
354
|
async function setAndroidDemoMode(serial, time = "9:30") {
|
|
346
355
|
const hhmm = time.replace(":", "");
|
|
347
|
-
await adbShell(serial, "settings put global sysui_demo_allowed 1");
|
|
348
|
-
await
|
|
349
|
-
serial,
|
|
350
|
-
"am broadcast -a com.android.systemui.demo -e command enter"
|
|
351
|
-
);
|
|
352
|
-
await sleep(500);
|
|
353
|
-
await adbShell(
|
|
354
|
-
serial,
|
|
355
|
-
`am broadcast -a com.android.systemui.demo -e command clock -e hhmm ${hhmm}`
|
|
356
|
-
);
|
|
357
|
-
await adbShell(
|
|
358
|
-
serial,
|
|
359
|
-
"am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level 4"
|
|
360
|
-
);
|
|
361
|
-
await adbShell(
|
|
362
|
-
serial,
|
|
363
|
-
"am broadcast -a com.android.systemui.demo -e command network -e mobile show -e datatype none -e level 4"
|
|
364
|
-
);
|
|
365
|
-
await adbShell(
|
|
366
|
-
serial,
|
|
367
|
-
"am broadcast -a com.android.systemui.demo -e command battery -e level 100 -e plugged false"
|
|
368
|
-
);
|
|
369
|
-
await adbShell(
|
|
370
|
-
serial,
|
|
371
|
-
"am broadcast -a com.android.systemui.demo -e command notifications -e visible false"
|
|
372
|
-
);
|
|
356
|
+
await adbShell(serial, ["settings", "put", "global", "sysui_demo_allowed", "1"]);
|
|
357
|
+
await demoBroadcast(serial, ["-e", "command", "enter"]);
|
|
373
358
|
await sleep(500);
|
|
359
|
+
await demoBroadcast(serial, ["-e", "command", "clock", "-e", "hhmm", hhmm]);
|
|
360
|
+
await demoBroadcast(serial, ["-e", "command", "network", "-e", "wifi", "show", "-e", "level", "4"]);
|
|
361
|
+
await demoBroadcast(serial, ["-e", "command", "network", "-e", "mobile", "show", "-e", "datatype", "none", "-e", "level", "4"]);
|
|
362
|
+
await demoBroadcast(serial, ["-e", "command", "battery", "-e", "level", "100", "-e", "plugged", "false"]);
|
|
363
|
+
await demoBroadcast(serial, ["-e", "command", "notifications", "-e", "visible", "false"]);
|
|
364
|
+
await sleep(1e3);
|
|
374
365
|
}
|
|
375
366
|
async function clearAndroidDemoMode(serial) {
|
|
376
|
-
await
|
|
377
|
-
serial,
|
|
378
|
-
"am broadcast -a com.android.systemui.demo -e command exit"
|
|
379
|
-
);
|
|
367
|
+
await demoBroadcast(serial, ["-e", "command", "exit"]);
|
|
380
368
|
}
|
|
381
369
|
async function captureAndroidScreenshot(serial, outputPath) {
|
|
382
370
|
const adb = getAdbPath();
|
|
@@ -860,7 +848,7 @@ async function frameCommand(dir, options) {
|
|
|
860
848
|
var program = new Command();
|
|
861
849
|
program.name("device-shots").description(
|
|
862
850
|
"Capture and frame mobile app screenshots from iOS simulators and Android emulators"
|
|
863
|
-
).version("0.5.
|
|
851
|
+
).version("0.5.8");
|
|
864
852
|
program.command("capture").description("Capture screenshots from running devices").argument("[name]", "Screenshot name").option("-b, --bundle-id <id>", "App bundle ID").option("-o, --output <dir>", "Output directory").option("-p, --platform <platform>", "ios, android, or both").option("--no-frame", "Skip framing after capture").option("--time <time>", "Status bar time", "9:41").action(async (name, opts) => {
|
|
865
853
|
await captureCommand({ name, ...opts });
|
|
866
854
|
});
|