react-native-update-cli 2.12.0 → 2.13.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/lib/utils/git.d.ts +2 -1
- package/lib/utils/git.js +82 -40
- package/lib/utils/http-helper.js +6 -1
- package/lib/utils/runtime.js +5 -7
- package/lib/utils/zip-entries.js +1 -2
- package/package.json +1 -2
- package/src/utils/git.ts +52 -31
- package/src/utils/http-helper.ts +6 -1
- package/src/utils/runtime.ts +5 -8
- package/src/utils/zip-entries.ts +2 -4
package/lib/utils/git.d.ts
CHANGED
package/lib/utils/git.js
CHANGED
|
@@ -2,57 +2,99 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get getCommitInfo () {
|
|
8
13
|
return getCommitInfo;
|
|
14
|
+
},
|
|
15
|
+
get getCurrentCommit () {
|
|
16
|
+
return getCurrentCommit;
|
|
9
17
|
}
|
|
10
18
|
});
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
const _child_process = require("child_process");
|
|
20
|
+
const _util = require("util");
|
|
21
|
+
const execFile = (0, _util.promisify)(_child_process.execFile);
|
|
22
|
+
function getCurrentCommit() {
|
|
23
|
+
const result = (0, _child_process.spawnSync)('git', [
|
|
24
|
+
'rev-parse',
|
|
25
|
+
'HEAD'
|
|
26
|
+
]);
|
|
27
|
+
if (result.status !== 0) {
|
|
28
|
+
throw new Error('Not a git repository');
|
|
29
|
+
}
|
|
30
|
+
return result.stdout.toString().trim();
|
|
31
|
+
}
|
|
32
|
+
async function gitOutput(args, cwd = process.cwd()) {
|
|
33
|
+
const { stdout } = await execFile('git', args, {
|
|
34
|
+
cwd,
|
|
35
|
+
encoding: 'utf8',
|
|
36
|
+
windowsHide: true
|
|
37
|
+
});
|
|
38
|
+
return stdout.trimEnd();
|
|
18
39
|
}
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
async function getRemoteOrigin(cwd) {
|
|
41
|
+
const origin = await gitOutput([
|
|
42
|
+
'remote',
|
|
43
|
+
'get-url',
|
|
44
|
+
'origin'
|
|
45
|
+
], cwd).catch(()=>'');
|
|
46
|
+
if (origin) {
|
|
47
|
+
return origin;
|
|
24
48
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
49
|
+
const remotes = await gitOutput([
|
|
50
|
+
'remote'
|
|
51
|
+
], cwd).catch(()=>'');
|
|
52
|
+
const firstRemote = remotes.split(/\r?\n/).find(Boolean);
|
|
53
|
+
if (!firstRemote) {
|
|
54
|
+
return undefined;
|
|
28
55
|
}
|
|
29
|
-
return
|
|
56
|
+
return gitOutput([
|
|
57
|
+
'remote',
|
|
58
|
+
'get-url',
|
|
59
|
+
firstRemote
|
|
60
|
+
], cwd).catch(()=>undefined);
|
|
30
61
|
}
|
|
31
|
-
const gitRoot = findGitRoot();
|
|
32
62
|
async function getCommitInfo() {
|
|
33
|
-
if (!gitRoot) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
63
|
try {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
64
|
+
const gitRoot = await gitOutput([
|
|
65
|
+
'rev-parse',
|
|
66
|
+
'--show-toplevel'
|
|
67
|
+
]);
|
|
68
|
+
const [hash, message, author, timestamp, origin] = await Promise.all([
|
|
69
|
+
gitOutput([
|
|
70
|
+
'rev-parse',
|
|
71
|
+
'HEAD'
|
|
72
|
+
], gitRoot),
|
|
73
|
+
gitOutput([
|
|
74
|
+
'log',
|
|
75
|
+
'-1',
|
|
76
|
+
'--format=%B'
|
|
77
|
+
], gitRoot),
|
|
78
|
+
gitOutput([
|
|
79
|
+
'log',
|
|
80
|
+
'-1',
|
|
81
|
+
'--format=%an'
|
|
82
|
+
], gitRoot),
|
|
83
|
+
gitOutput([
|
|
84
|
+
'log',
|
|
85
|
+
'-1',
|
|
86
|
+
'--format=%ct'
|
|
87
|
+
], gitRoot),
|
|
88
|
+
getRemoteOrigin(gitRoot)
|
|
89
|
+
]);
|
|
47
90
|
return {
|
|
48
|
-
hash
|
|
49
|
-
message
|
|
50
|
-
author
|
|
51
|
-
timestamp
|
|
52
|
-
origin
|
|
91
|
+
hash,
|
|
92
|
+
message,
|
|
93
|
+
author,
|
|
94
|
+
timestamp,
|
|
95
|
+
origin
|
|
53
96
|
};
|
|
54
|
-
} catch (
|
|
55
|
-
console.error(error);
|
|
97
|
+
} catch (_error) {
|
|
56
98
|
return;
|
|
57
99
|
}
|
|
58
100
|
}
|
package/lib/utils/http-helper.js
CHANGED
|
@@ -67,7 +67,12 @@ const testUrls = async (urls)=>{
|
|
|
67
67
|
if (!(urls == null ? void 0 : urls.length)) {
|
|
68
68
|
return null;
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
let ret = null;
|
|
71
|
+
try {
|
|
72
|
+
ret = await promiseAny(urls.map(ping));
|
|
73
|
+
} catch (_e) {
|
|
74
|
+
// fallback to urls[0]
|
|
75
|
+
}
|
|
71
76
|
if (ret) {
|
|
72
77
|
return ret;
|
|
73
78
|
}
|
package/lib/utils/runtime.js
CHANGED
|
@@ -91,13 +91,11 @@ function measureTcpConnectOnce(host, port, timeout) {
|
|
|
91
91
|
}
|
|
92
92
|
async function measureTcpLatency(input, { attempts = 4, timeout = 1000 } = {}) {
|
|
93
93
|
const { host, port } = resolveTcpTarget(input);
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
}
|
|
94
|
+
const promises = Array.from({
|
|
95
|
+
length: attempts
|
|
96
|
+
}, ()=>measureTcpConnectOnce(host, port, timeout));
|
|
97
|
+
const results = await Promise.all(promises);
|
|
98
|
+
const latencies = results.filter(Number.isFinite);
|
|
101
99
|
if (latencies.length === 0) {
|
|
102
100
|
return Number.POSITIVE_INFINITY;
|
|
103
101
|
}
|
package/lib/utils/zip-entries.js
CHANGED
|
@@ -175,8 +175,7 @@ async function enumZipEntries(zipFn, callback, nestedPath = '') {
|
|
|
175
175
|
const fullPath = nestedPath + entry.fileName;
|
|
176
176
|
try {
|
|
177
177
|
if (!entry.fileName.endsWith('/') && entry.fileName.toLowerCase().endsWith('.hap')) {
|
|
178
|
-
const tempDir = _path.default.join(_os.default.tmpdir(),
|
|
179
|
-
await _fsextra.ensureDir(tempDir);
|
|
178
|
+
const tempDir = await _fsextra.mkdtemp(_path.default.join(_os.default.tmpdir(), 'nested_zip_'));
|
|
180
179
|
const tempZipPath = _path.default.join(tempDir, 'temp.zip');
|
|
181
180
|
await new Promise((res, rej)=>{
|
|
182
181
|
zipfile.openReadStream(entry, async (err, readStream)=>{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
|
5
5
|
"main": "lib/exports.js",
|
|
6
6
|
"types": "lib/exports.d.ts",
|
|
@@ -71,7 +71,6 @@
|
|
|
71
71
|
"global-dirs": "^4.0.0",
|
|
72
72
|
"gradle-to-js": "^2.0.1",
|
|
73
73
|
"i18next": "^26.0.4",
|
|
74
|
-
"isomorphic-git": "^1.37.5",
|
|
75
74
|
"node-fetch": "^2.6.1",
|
|
76
75
|
"plist": "^3.1.0",
|
|
77
76
|
"progress": "^2.0.3",
|
package/src/utils/git.ts
CHANGED
|
@@ -1,50 +1,71 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import path from 'path';
|
|
1
|
+
import { execFile as execFileCallback, spawnSync } from 'child_process';
|
|
2
|
+
import { promisify } from 'util';
|
|
4
3
|
|
|
5
4
|
export interface CommitInfo {
|
|
6
5
|
hash: string;
|
|
7
6
|
message: string;
|
|
8
7
|
author: string;
|
|
9
8
|
timestamp: string;
|
|
10
|
-
origin
|
|
9
|
+
origin?: string;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const parentDir = path.dirname(dir);
|
|
20
|
-
if (parentDir === dir) {
|
|
21
|
-
return null;
|
|
12
|
+
const execFile = promisify(execFileCallback);
|
|
13
|
+
|
|
14
|
+
export function getCurrentCommit() {
|
|
15
|
+
const result = spawnSync('git', ['rev-parse', 'HEAD']);
|
|
16
|
+
if (result.status !== 0) {
|
|
17
|
+
throw new Error('Not a git repository');
|
|
22
18
|
}
|
|
23
|
-
return
|
|
19
|
+
return result.stdout.toString().trim();
|
|
24
20
|
}
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
async function gitOutput(args: string[], cwd = process.cwd()): Promise<string> {
|
|
23
|
+
const { stdout } = await execFile('git', args, {
|
|
24
|
+
cwd,
|
|
25
|
+
encoding: 'utf8',
|
|
26
|
+
windowsHide: true,
|
|
27
|
+
});
|
|
28
|
+
return stdout.trimEnd();
|
|
29
|
+
}
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
async function getRemoteOrigin(cwd: string) {
|
|
32
|
+
const origin = await gitOutput(['remote', 'get-url', 'origin'], cwd).catch(
|
|
33
|
+
() => '',
|
|
34
|
+
);
|
|
35
|
+
if (origin) {
|
|
36
|
+
return origin;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const remotes = await gitOutput(['remote'], cwd).catch(() => '');
|
|
40
|
+
const firstRemote = remotes.split(/\r?\n/).find(Boolean);
|
|
41
|
+
if (!firstRemote) {
|
|
42
|
+
return undefined;
|
|
31
43
|
}
|
|
44
|
+
|
|
45
|
+
return gitOutput(['remote', 'get-url', firstRemote], cwd).catch(
|
|
46
|
+
() => undefined,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function getCommitInfo(): Promise<CommitInfo | undefined> {
|
|
32
51
|
try {
|
|
33
|
-
const
|
|
34
|
-
const origin =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
const gitRoot = await gitOutput(['rev-parse', '--show-toplevel']);
|
|
53
|
+
const [hash, message, author, timestamp, origin] = await Promise.all([
|
|
54
|
+
gitOutput(['rev-parse', 'HEAD'], gitRoot),
|
|
55
|
+
gitOutput(['log', '-1', '--format=%B'], gitRoot),
|
|
56
|
+
gitOutput(['log', '-1', '--format=%an'], gitRoot),
|
|
57
|
+
gitOutput(['log', '-1', '--format=%ct'], gitRoot),
|
|
58
|
+
getRemoteOrigin(gitRoot),
|
|
59
|
+
]);
|
|
60
|
+
|
|
39
61
|
return {
|
|
40
|
-
hash
|
|
41
|
-
message
|
|
42
|
-
author
|
|
43
|
-
timestamp
|
|
44
|
-
origin
|
|
62
|
+
hash,
|
|
63
|
+
message,
|
|
64
|
+
author,
|
|
65
|
+
timestamp,
|
|
66
|
+
origin,
|
|
45
67
|
};
|
|
46
|
-
} catch (
|
|
47
|
-
console.error(error);
|
|
68
|
+
} catch (_error) {
|
|
48
69
|
return;
|
|
49
70
|
}
|
|
50
71
|
}
|
package/src/utils/http-helper.ts
CHANGED
|
@@ -57,7 +57,12 @@ export const testUrls = async (urls?: string[]) => {
|
|
|
57
57
|
if (!urls?.length) {
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
let ret: string | null = null;
|
|
61
|
+
try {
|
|
62
|
+
ret = await promiseAny(urls.map(ping));
|
|
63
|
+
} catch (_e) {
|
|
64
|
+
// fallback to urls[0]
|
|
65
|
+
}
|
|
61
66
|
if (ret) {
|
|
62
67
|
return ret;
|
|
63
68
|
}
|
package/src/utils/runtime.ts
CHANGED
|
@@ -98,14 +98,11 @@ export async function measureTcpLatency(
|
|
|
98
98
|
} = {},
|
|
99
99
|
): Promise<number> {
|
|
100
100
|
const { host, port } = resolveTcpTarget(input);
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
latencies.push(latency);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
101
|
+
const promises = Array.from({ length: attempts }, () =>
|
|
102
|
+
measureTcpConnectOnce(host, port, timeout),
|
|
103
|
+
);
|
|
104
|
+
const results = await Promise.all(promises);
|
|
105
|
+
const latencies = results.filter(Number.isFinite);
|
|
109
106
|
|
|
110
107
|
if (latencies.length === 0) {
|
|
111
108
|
return Number.POSITIVE_INFINITY;
|
package/src/utils/zip-entries.ts
CHANGED
|
@@ -143,11 +143,9 @@ export async function enumZipEntries(
|
|
|
143
143
|
!entry.fileName.endsWith('/') &&
|
|
144
144
|
entry.fileName.toLowerCase().endsWith('.hap')
|
|
145
145
|
) {
|
|
146
|
-
const tempDir =
|
|
147
|
-
os.tmpdir(),
|
|
148
|
-
`nested_zip_${Date.now()}`,
|
|
146
|
+
const tempDir = await fs.mkdtemp(
|
|
147
|
+
path.join(os.tmpdir(), 'nested_zip_'),
|
|
149
148
|
);
|
|
150
|
-
await fs.ensureDir(tempDir);
|
|
151
149
|
const tempZipPath = path.join(tempDir, 'temp.zip');
|
|
152
150
|
|
|
153
151
|
await new Promise((res, rej) => {
|