device-shots 0.6.0 → 0.6.2
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 +1 -49
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -269,7 +269,6 @@ async function captureIosScreenshot(udid, outputPath) {
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
// src/devices/android.ts
|
|
272
|
-
import { execSync } from "child_process";
|
|
273
272
|
function sanitizeName2(name) {
|
|
274
273
|
return name.replace(/[ (),]/g, "_").replace(/[^A-Za-z0-9_-]/g, "");
|
|
275
274
|
}
|
|
@@ -335,42 +334,6 @@ async function discoverAndroidDevices(bundleId) {
|
|
|
335
334
|
}
|
|
336
335
|
return devices;
|
|
337
336
|
}
|
|
338
|
-
function sleep(ms) {
|
|
339
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
340
|
-
}
|
|
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
|
-
}
|
|
351
|
-
}
|
|
352
|
-
async function setAndroidDemoMode(serial, time = "9:30") {
|
|
353
|
-
const hhmm = time.replace(":", "");
|
|
354
|
-
const adb = getAdbPath();
|
|
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
|
-
await sleep(500);
|
|
359
|
-
adbShellSync(adb, serial, `am broadcast -a ${ACTION} --es command enter`);
|
|
360
|
-
await sleep(1e3);
|
|
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
|
-
await sleep(1e3);
|
|
367
|
-
}
|
|
368
|
-
async function clearAndroidDemoMode(serial) {
|
|
369
|
-
const adb = getAdbPath();
|
|
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");
|
|
373
|
-
}
|
|
374
337
|
async function captureAndroidScreenshot(serial, outputPath) {
|
|
375
338
|
const adb = getAdbPath();
|
|
376
339
|
const deviceTmp = "/sdcard/screenshot_tmp.png";
|
|
@@ -606,7 +569,6 @@ async function captureCommand(options) {
|
|
|
606
569
|
const outputDir = options.output || config.output;
|
|
607
570
|
const platform = options.platform || config.platform;
|
|
608
571
|
const iosTime = options.time || config.time;
|
|
609
|
-
const androidTime = config.androidTime;
|
|
610
572
|
const shouldFrame = !options.noFrame && config.frame;
|
|
611
573
|
const spinner = ora("Discovering devices...").start();
|
|
612
574
|
const devices = await discoverDevices(bundleId, platform);
|
|
@@ -683,13 +645,6 @@ Detected ${devices.length} device(s) with ${bundleIdDisplay}:`)
|
|
|
683
645
|
await setIosStatusBar(iosTime);
|
|
684
646
|
s.succeed("iOS status bar set");
|
|
685
647
|
}
|
|
686
|
-
if (androidDevices.length > 0) {
|
|
687
|
-
const s = ora("Setting clean Android status bar...").start();
|
|
688
|
-
for (const device of androidDevices) {
|
|
689
|
-
await setAndroidDemoMode(device.captureId, androidTime);
|
|
690
|
-
}
|
|
691
|
-
s.succeed("Android demo mode set");
|
|
692
|
-
}
|
|
693
648
|
console.log("");
|
|
694
649
|
const captured = [];
|
|
695
650
|
for (const device of devices) {
|
|
@@ -741,9 +696,6 @@ Detected ${devices.length} device(s) with ${bundleIdDisplay}:`)
|
|
|
741
696
|
if (iosDevices.length > 0) {
|
|
742
697
|
await clearIosStatusBar();
|
|
743
698
|
}
|
|
744
|
-
for (const device of androidDevices) {
|
|
745
|
-
await clearAndroidDemoMode(device.captureId);
|
|
746
|
-
}
|
|
747
699
|
const skippedDupes = captured.length - movedBuckets.size;
|
|
748
700
|
let msg = `
|
|
749
701
|
Captured ${movedBuckets.size} screenshot(s) as '${screenshotName}'.`;
|
|
@@ -853,7 +805,7 @@ async function frameCommand(dir, options) {
|
|
|
853
805
|
var program = new Command();
|
|
854
806
|
program.name("device-shots").description(
|
|
855
807
|
"Capture and frame mobile app screenshots from iOS simulators and Android emulators"
|
|
856
|
-
).version("0.6.
|
|
808
|
+
).version("0.6.1");
|
|
857
809
|
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) => {
|
|
858
810
|
await captureCommand({ name, ...opts });
|
|
859
811
|
});
|