@myerscarpenter/quest-dev 1.0.8 → 1.2.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/build/commands/battery.d.ts +9 -0
- package/build/commands/battery.d.ts.map +1 -0
- package/build/commands/battery.js +31 -0
- package/build/commands/battery.js.map +1 -0
- package/build/commands/logcat.d.ts +24 -0
- package/build/commands/logcat.d.ts.map +1 -0
- package/build/commands/logcat.js +261 -0
- package/build/commands/logcat.js.map +1 -0
- package/build/commands/open.d.ts +1 -1
- package/build/commands/open.d.ts.map +1 -1
- package/build/commands/open.js +14 -14
- package/build/commands/open.js.map +1 -1
- package/build/commands/screenshot.d.ts +1 -1
- package/build/commands/screenshot.d.ts.map +1 -1
- package/build/commands/screenshot.js +55 -9
- package/build/commands/screenshot.js.map +1 -1
- package/build/commands/stay-awake.d.ts +14 -0
- package/build/commands/stay-awake.d.ts.map +1 -0
- package/build/commands/stay-awake.js +234 -0
- package/build/commands/stay-awake.js.map +1 -0
- package/build/index.js +84 -5
- package/build/index.js.map +1 -1
- package/build/utils/adb.d.ts +12 -7
- package/build/utils/adb.d.ts.map +1 -1
- package/build/utils/adb.js +138 -31
- package/build/utils/adb.js.map +1 -1
- package/build/utils/filename.d.ts +9 -0
- package/build/utils/filename.d.ts.map +1 -0
- package/build/utils/filename.js +17 -0
- package/build/utils/filename.js.map +1 -0
- package/build/utils/filename.test.d.ts +5 -0
- package/build/utils/filename.test.d.ts.map +1 -0
- package/build/utils/filename.test.js +40 -0
- package/build/utils/filename.test.js.map +1 -0
- package/package.json +2 -1
- package/src/commands/battery.ts +34 -0
- package/src/commands/logcat.ts +288 -0
- package/src/commands/open.ts +18 -14
- package/src/commands/screenshot.ts +61 -9
- package/src/commands/stay-awake.ts +254 -0
- package/src/index.ts +119 -9
- package/src/utils/adb.ts +148 -31
- package/src/utils/filename.test.ts +55 -0
- package/src/utils/filename.ts +18 -0
- package/tests/adb.test.ts +2 -2
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for filename generation utilities
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect } from 'vitest';
|
|
6
|
+
import { generateScreenshotFilename } from './filename.js';
|
|
7
|
+
|
|
8
|
+
describe('generateScreenshotFilename', () => {
|
|
9
|
+
it('formats UTC timestamp correctly', () => {
|
|
10
|
+
const date = new Date('2026-01-15T14:30:45Z');
|
|
11
|
+
expect(generateScreenshotFilename(date))
|
|
12
|
+
.toBe('screenshot-2026-01-15-14-30-45-Z.jpg');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('pads single digits with zeros', () => {
|
|
16
|
+
const date = new Date('2026-01-05T08:09:03Z');
|
|
17
|
+
expect(generateScreenshotFilename(date))
|
|
18
|
+
.toBe('screenshot-2026-01-05-08-09-03-Z.jpg');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('handles midnight correctly', () => {
|
|
22
|
+
const date = new Date('2026-12-31T00:00:00Z');
|
|
23
|
+
expect(generateScreenshotFilename(date))
|
|
24
|
+
.toBe('screenshot-2026-12-31-00-00-00-Z.jpg');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('generates filename with current time when no date provided', () => {
|
|
28
|
+
const filename = generateScreenshotFilename();
|
|
29
|
+
|
|
30
|
+
// Verify format is correct
|
|
31
|
+
expect(filename).toMatch(/^screenshot-\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}-Z\.jpg$/);
|
|
32
|
+
|
|
33
|
+
// Extract timestamp from filename
|
|
34
|
+
const match = filename.match(/^screenshot-(\d{4})-(\d{2})-(\d{2})-(\d{2})-(\d{2})-(\d{2})-Z\.jpg$/);
|
|
35
|
+
expect(match).not.toBeNull();
|
|
36
|
+
|
|
37
|
+
if (match) {
|
|
38
|
+
const [, year, month, day, hours, minutes, seconds] = match;
|
|
39
|
+
const filenameDate = new Date(Date.UTC(
|
|
40
|
+
parseInt(year),
|
|
41
|
+
parseInt(month) - 1,
|
|
42
|
+
parseInt(day),
|
|
43
|
+
parseInt(hours),
|
|
44
|
+
parseInt(minutes),
|
|
45
|
+
parseInt(seconds)
|
|
46
|
+
));
|
|
47
|
+
|
|
48
|
+
// Verify the timestamp is reasonable (within last minute)
|
|
49
|
+
const now = new Date();
|
|
50
|
+
const diff = now.getTime() - filenameDate.getTime();
|
|
51
|
+
expect(diff).toBeGreaterThanOrEqual(0);
|
|
52
|
+
expect(diff).toBeLessThan(60000); // Within last 60 seconds
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filename generation utilities for screenshots
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generate UTC timestamp filename
|
|
7
|
+
* Format: screenshot-YYYY-MM-DD-HH-MM-SS-Z.jpg
|
|
8
|
+
*/
|
|
9
|
+
export function generateScreenshotFilename(date: Date = new Date()): string {
|
|
10
|
+
const year = date.getUTCFullYear();
|
|
11
|
+
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
|
12
|
+
const day = String(date.getUTCDate()).padStart(2, '0');
|
|
13
|
+
const hours = String(date.getUTCHours()).padStart(2, '0');
|
|
14
|
+
const minutes = String(date.getUTCMinutes()).padStart(2, '0');
|
|
15
|
+
const seconds = String(date.getUTCSeconds()).padStart(2, '0');
|
|
16
|
+
|
|
17
|
+
return `screenshot-${year}-${month}-${day}-${hours}-${minutes}-${seconds}-Z.jpg`;
|
|
18
|
+
}
|
package/tests/adb.test.ts
CHANGED
|
@@ -28,8 +28,8 @@ describe('isPortListening', () => {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
describe('getCDPPort', () => {
|
|
31
|
-
it('should return the default CDP port', () => {
|
|
32
|
-
const port = getCDPPort();
|
|
31
|
+
it('should return the default CDP port', async () => {
|
|
32
|
+
const port = await getCDPPort();
|
|
33
33
|
expect(port).toBe(9223);
|
|
34
34
|
});
|
|
35
35
|
});
|