@onekeyfe/hardware-cli 1.2.0-alpha.107 → 1.2.0-alpha.109
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/cli.js +3 -9
- package/package.json +6 -6
- package/src/__tests__/wallpaper-upload-command.test.ts +1 -0
- package/src/cli.ts +3 -11
package/dist/cli.js
CHANGED
|
@@ -62,15 +62,11 @@ program
|
|
|
62
62
|
program
|
|
63
63
|
.command('upload-wallpaper')
|
|
64
64
|
.description('Upload and activate a Pro2 wallpaper')
|
|
65
|
-
.requiredOption('--
|
|
65
|
+
.requiredOption('--jpeg <path>', '604x1024 JPEG file')
|
|
66
66
|
.option('--file-name <name>', 'Device wallpaper file name', 'wallpaper-cli')
|
|
67
67
|
.option('--chunk-size <bytes>', 'Transfer chunk size in bytes')
|
|
68
68
|
.action(opts => runCommand({}, async ({ sdk, globalOpts, params }) => {
|
|
69
|
-
const
|
|
70
|
-
const expectedBytes = 604 * 1024 * 4;
|
|
71
|
-
if (rgba.byteLength !== expectedBytes) {
|
|
72
|
-
throw new Error(`Invalid RGBA size: expected ${expectedBytes} bytes, received ${rgba.byteLength}`);
|
|
73
|
-
}
|
|
69
|
+
const jpegBase64 = (0, node_fs_1.readFileSync)(opts.jpeg).toString('base64');
|
|
74
70
|
let transferStartedAt;
|
|
75
71
|
let transferEndedAt;
|
|
76
72
|
let lastProgress = -1;
|
|
@@ -111,9 +107,7 @@ program
|
|
|
111
107
|
try {
|
|
112
108
|
result = await sdk.deviceUploadWallpaper(globalOpts.connectId, {
|
|
113
109
|
...params,
|
|
114
|
-
|
|
115
|
-
height: 1024,
|
|
116
|
-
rgba,
|
|
110
|
+
jpegBase64,
|
|
117
111
|
fileName: opts.fileName,
|
|
118
112
|
chunkSize: opts.chunkSize ? safeParseInt(opts.chunkSize, '--chunk-size') : undefined,
|
|
119
113
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hardware-cli",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.109",
|
|
4
4
|
"description": "OneKey hardware wallet CLI for testing device communication",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"test": "jest"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.
|
|
35
|
-
"@onekeyfe/hd-core": "1.2.0-alpha.
|
|
36
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
37
|
-
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.
|
|
34
|
+
"@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.109",
|
|
35
|
+
"@onekeyfe/hd-core": "1.2.0-alpha.109",
|
|
36
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.109",
|
|
37
|
+
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.109",
|
|
38
38
|
"@stoprocent/noble": "2.3.16",
|
|
39
39
|
"commander": "^12.0.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "ce211fcfff013b1904caa876b7010590be633713"
|
|
42
42
|
}
|
|
@@ -6,6 +6,7 @@ describe('upload-wallpaper CLI command', () => {
|
|
|
6
6
|
|
|
7
7
|
expect(command).toBeDefined();
|
|
8
8
|
expect(command?.description()).toBe('Upload and activate a Pro2 wallpaper');
|
|
9
|
+
expect(command?.options.some(option => option.long === '--jpeg' && option.required)).toBe(true);
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
test('reports effective transfer speed from encoded bytes and elapsed time', () => {
|
package/src/cli.ts
CHANGED
|
@@ -99,18 +99,12 @@ program
|
|
|
99
99
|
program
|
|
100
100
|
.command('upload-wallpaper')
|
|
101
101
|
.description('Upload and activate a Pro2 wallpaper')
|
|
102
|
-
.requiredOption('--
|
|
102
|
+
.requiredOption('--jpeg <path>', '604x1024 JPEG file')
|
|
103
103
|
.option('--file-name <name>', 'Device wallpaper file name', 'wallpaper-cli')
|
|
104
104
|
.option('--chunk-size <bytes>', 'Transfer chunk size in bytes')
|
|
105
105
|
.action(opts =>
|
|
106
106
|
runCommand({}, async ({ sdk, globalOpts, params }) => {
|
|
107
|
-
const
|
|
108
|
-
const expectedBytes = 604 * 1024 * 4;
|
|
109
|
-
if (rgba.byteLength !== expectedBytes) {
|
|
110
|
-
throw new Error(
|
|
111
|
-
`Invalid RGBA size: expected ${expectedBytes} bytes, received ${rgba.byteLength}`
|
|
112
|
-
);
|
|
113
|
-
}
|
|
107
|
+
const jpegBase64 = readFileSync(opts.jpeg).toString('base64');
|
|
114
108
|
|
|
115
109
|
let transferStartedAt: number | undefined;
|
|
116
110
|
let transferEndedAt: number | undefined;
|
|
@@ -159,9 +153,7 @@ program
|
|
|
159
153
|
try {
|
|
160
154
|
result = await sdk.deviceUploadWallpaper(globalOpts.connectId, {
|
|
161
155
|
...params,
|
|
162
|
-
|
|
163
|
-
height: 1024,
|
|
164
|
-
rgba,
|
|
156
|
+
jpegBase64,
|
|
165
157
|
fileName: opts.fileName,
|
|
166
158
|
chunkSize: opts.chunkSize ? safeParseInt(opts.chunkSize, '--chunk-size') : undefined,
|
|
167
159
|
});
|