device-shots 0.5.11 → 0.6.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/dist/index.js +24 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -269,6 +269,7 @@ async function captureIosScreenshot(udid, outputPath) {
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
// src/devices/android.ts
|
|
272
|
+
import { execSync } from "child_process";
|
|
272
273
|
function sanitizeName2(name) {
|
|
273
274
|
return name.replace(/[ (),]/g, "_").replace(/[^A-Za-z0-9_-]/g, "");
|
|
274
275
|
}
|
|
@@ -337,38 +338,38 @@ async function discoverAndroidDevices(bundleId) {
|
|
|
337
338
|
function sleep(ms) {
|
|
338
339
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
339
340
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
"
|
|
349
|
-
|
|
350
|
-
...extras
|
|
351
|
-
]);
|
|
341
|
+
function adbShellSync(adb, serial, cmd) {
|
|
342
|
+
try {
|
|
343
|
+
const result = execSync(`${adb} -s ${serial} shell ${cmd}`, {
|
|
344
|
+
encoding: "utf-8",
|
|
345
|
+
timeout: 1e4
|
|
346
|
+
});
|
|
347
|
+
return result.trim();
|
|
348
|
+
} catch (e) {
|
|
349
|
+
return e.stdout?.trim() || e.stderr?.trim() || "";
|
|
350
|
+
}
|
|
352
351
|
}
|
|
353
352
|
async function setAndroidDemoMode(serial, time = "9:30") {
|
|
354
353
|
const hhmm = time.replace(":", "");
|
|
355
354
|
const adb = getAdbPath();
|
|
356
|
-
|
|
357
|
-
|
|
355
|
+
const ACTION = "com.android.systemui.demo";
|
|
356
|
+
adbShellSync(adb, serial, "settings put global sysui_demo_allowed 1");
|
|
357
|
+
adbShellSync(adb, serial, "settings put global sysui_tuner_demo_on 1");
|
|
358
358
|
await sleep(500);
|
|
359
|
-
|
|
359
|
+
adbShellSync(adb, serial, `am broadcast -a ${ACTION} --es command enter`);
|
|
360
360
|
await sleep(1e3);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
361
|
+
adbShellSync(adb, serial, `am broadcast -a ${ACTION} --es command clock --es hhmm ${hhmm}`);
|
|
362
|
+
adbShellSync(adb, serial, `am broadcast -a ${ACTION} --es command network --es wifi show --es level 4`);
|
|
363
|
+
adbShellSync(adb, serial, `am broadcast -a ${ACTION} --es command network --es mobile show --es datatype none --es level 4`);
|
|
364
|
+
adbShellSync(adb, serial, `am broadcast -a ${ACTION} --es command battery --es level 100 --es plugged false`);
|
|
365
|
+
adbShellSync(adb, serial, `am broadcast -a ${ACTION} --es command notifications --es visible false`);
|
|
366
366
|
await sleep(1e3);
|
|
367
367
|
}
|
|
368
368
|
async function clearAndroidDemoMode(serial) {
|
|
369
|
-
await demoBroadcast(serial, ["--es", "command", "exit"]);
|
|
370
369
|
const adb = getAdbPath();
|
|
371
|
-
|
|
370
|
+
const ACTION = "com.android.systemui.demo";
|
|
371
|
+
adbShellSync(adb, serial, `am broadcast -a ${ACTION} --es command exit`);
|
|
372
|
+
adbShellSync(adb, serial, "settings put global sysui_tuner_demo_on 0");
|
|
372
373
|
}
|
|
373
374
|
async function captureAndroidScreenshot(serial, outputPath) {
|
|
374
375
|
const adb = getAdbPath();
|
|
@@ -852,7 +853,7 @@ async function frameCommand(dir, options) {
|
|
|
852
853
|
var program = new Command();
|
|
853
854
|
program.name("device-shots").description(
|
|
854
855
|
"Capture and frame mobile app screenshots from iOS simulators and Android emulators"
|
|
855
|
-
).version("0.
|
|
856
|
+
).version("0.6.0");
|
|
856
857
|
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) => {
|
|
857
858
|
await captureCommand({ name, ...opts });
|
|
858
859
|
});
|