Skip to content

Commit 36e1be0

Browse files
committed
remove request
1 parent e099002 commit 36e1be0

File tree

6 files changed

+172
-372
lines changed

6 files changed

+172
-372
lines changed

bun.lockb

-9.76 KB
Binary file not shown.

index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
/**
2-
* Created by tdzl2003 on 2/22/16.
3-
*/
4-
module.exports = require('./lib');
1+
module.exports = require('./lib');

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update-cli",
3-
"version": "1.32.0",
3+
"version": "1.32.2",
44
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
55
"main": "index.js",
66
"bin": {
@@ -39,6 +39,7 @@
3939
"commander": "^12.1.0",
4040
"compare-versions": "^6.1.1",
4141
"filesize-parser": "^1.5.1",
42+
"form-data": "^4.0.1",
4243
"fs-extra": "8",
4344
"gradle-to-js": "^2.0.1",
4445
"isomorphic-unzip": "^1.1.5",

src/api.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import tcpp from 'tcp-ping';
88
import filesizeParser from 'filesize-parser';
99
import { pricingPageUrl } from './utils';
1010
import { Session } from 'types';
11+
import FormData from 'form-data';
1112

1213
const tcpPing = util.promisify(tcpp.ping);
1314

@@ -75,12 +76,7 @@ async function query(url: string, options: fetch.RequestInit) {
7576
}
7677

7778
if (resp.status !== 200) {
78-
throw Object.assign(
79-
new Error(json.message || json.error || resp.statusText),
80-
{
81-
status: resp.status,
82-
},
83-
);
79+
throw new Error(`${resp.status}: ${resp.statusText}`);
8480
}
8581
return json;
8682
}
@@ -116,7 +112,7 @@ export const post = queryWithBody('POST');
116112
export const put = queryWithBody('PUT');
117113
export const doDelete = queryWithBody('DELETE');
118114

119-
export async function uploadFile(fn: string, key: string) {
115+
export async function uploadFile(fn: string, key?: string) {
120116
const { url, backupUrl, formData, maxSize } = await post('/upload', {
121117
ext: path.extname(fn),
122118
});
@@ -156,27 +152,27 @@ export async function uploadFile(fn: string, key: string) {
156152
const form = new FormData();
157153

158154
Object.entries(formData).forEach(([k, v]) => {
159-
form.set(k, v);
155+
form.append(k, v);
160156
});
161157
const fileStream = fs.createReadStream(fn);
162158
fileStream.on('data', function (data) {
163159
bar.tick(data.length);
164160
});
165161

166162
if (key) {
167-
form.set('key', key);
163+
form.append('key', key);
168164
}
169-
form.set('file', fileStream);
165+
form.append('file', fileStream);
170166

171-
const res = await fetch(url, {
167+
const res = await fetch(realUrl, {
172168
method: 'POST',
173169
body: form,
174170
});
175171

176172
if (res.status > 299) {
177-
throw new Error(`${res.status}: ${await res.text()}`);
173+
throw new Error(`${res.status}: ${res.statusText}`);
178174
}
179175

180176
// const body = await response.json();
181-
return { hash: key };
177+
return { hash: key || formData.key };
182178
}

src/utils/index.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
import fs from 'fs-extra';
2-
import os from 'os';
3-
import path from 'path';
2+
import os from 'node:os';
3+
import path from 'node:path';
44
import pkg from '../../package.json';
55
import AppInfoParser from './app-info-parser';
66
import semverSatisfies from 'semver/functions/satisfies';
77

8-
import read from 'read';
8+
import { read } from 'read';
99

10-
export function question(query, password) {
10+
export async function question(query, password) {
1111
if (NO_INTERACTIVE) {
12-
return Promise.resolve('');
12+
return '';
1313
}
14-
return new Promise((resolve, reject) =>
15-
read(
16-
{
17-
prompt: query,
18-
silent: password,
19-
replace: password ? '*' : undefined,
20-
},
21-
(err, result) => (err ? reject(err) : resolve(result)),
22-
),
23-
);
14+
return read({
15+
prompt: query,
16+
silent: password,
17+
replace: password ? '*' : undefined,
18+
});
2419
}
2520

2621
export function translateOptions(options) {

0 commit comments

Comments
 (0)