react-native-update-cli 2.17.0 → 2.19.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/api.d.ts +1 -1
- package/lib/api.js +140 -134
- package/lib/app.d.ts +2 -2
- package/lib/app.js +60 -107
- package/lib/bin.js +38 -35
- package/lib/bundle-pack.js +57 -77
- package/lib/bundle-runner.js +249 -312
- package/lib/bundle.js +71 -89
- package/lib/diff.js +224 -198
- package/lib/exports.js +14 -37
- package/lib/index.js +16 -17
- package/lib/install.js +24 -37
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +4 -11
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +4 -11
- package/lib/package.js +164 -218
- package/lib/provider.js +85 -107
- package/lib/types.js +1 -3
- package/lib/user.d.ts +1 -1
- package/lib/user.js +26 -39
- package/lib/utils/add-gitignore.js +16 -29
- package/lib/utils/app-info-parser/aab.js +133 -157
- package/lib/utils/app-info-parser/apk.js +42 -39
- package/lib/utils/app-info-parser/app.js +5 -11
- package/lib/utils/app-info-parser/index.js +21 -31
- package/lib/utils/app-info-parser/ipa.js +35 -35
- package/lib/utils/app-info-parser/resource-finder.js +84 -71
- package/lib/utils/app-info-parser/utils.js +52 -77
- package/lib/utils/app-info-parser/xml-parser/binary.js +82 -90
- package/lib/utils/app-info-parser/xml-parser/manifest.js +88 -98
- package/lib/utils/app-info-parser/zip.js +43 -51
- package/lib/utils/check-lockfile.js +28 -37
- package/lib/utils/check-plugin.js +16 -32
- package/lib/utils/command-result.js +7 -20
- package/lib/utils/constants.js +23 -63
- package/lib/utils/dep-versions.js +21 -27
- package/lib/utils/git.js +20 -64
- package/lib/utils/hbcTransform.js +133 -246
- package/lib/utils/http-helper.js +33 -44
- package/lib/utils/i18n.js +17 -26
- package/lib/utils/index.js +137 -179
- package/lib/utils/latest-version/index.js +128 -137
- package/lib/utils/options.js +13 -34
- package/lib/utils/plugin-config.js +43 -56
- package/lib/utils/runtime.js +50 -108
- package/lib/utils/zip-entries.js +70 -97
- package/lib/utils/zip-options.js +80 -181
- package/lib/versions.js +231 -265
- package/package.json +19 -20
- package/src/api.ts +44 -3
- package/src/diff.ts +129 -2
- package/src/locales/en.ts +2 -0
- package/src/locales/zh.ts +2 -0
- package/src/package.ts +1 -1
- package/src/user.ts +1 -1
- package/src/versions.ts +1 -1
package/lib/utils/runtime.js
CHANGED
|
@@ -1,52 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
get isBunRuntime () {
|
|
22
|
-
return isBunRuntime;
|
|
23
|
-
},
|
|
24
|
-
get measureTcpLatency () {
|
|
25
|
-
return measureTcpLatency;
|
|
26
|
-
},
|
|
27
|
-
get runtimeFetch () {
|
|
28
|
-
return runtimeFetch;
|
|
29
|
-
},
|
|
30
|
-
get spawnJavaScript () {
|
|
31
|
-
return spawnJavaScript;
|
|
32
|
-
},
|
|
33
|
-
get spawnJavaScriptSync () {
|
|
34
|
-
return spawnJavaScriptSync;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const _child_process = require("child_process");
|
|
38
|
-
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
39
|
-
const _net = require("net");
|
|
40
|
-
const _nodefetch = /*#__PURE__*/ _interop_require_default(require("node-fetch"));
|
|
41
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
42
|
-
function _interop_require_default(obj) {
|
|
43
|
-
return obj && obj.__esModule ? obj : {
|
|
44
|
-
default: obj
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
const isBunRuntime = typeof process.versions.bun === 'string';
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isBunRuntime = void 0;
|
|
7
|
+
exports.runtimeFetch = runtimeFetch;
|
|
8
|
+
exports.measureTcpLatency = measureTcpLatency;
|
|
9
|
+
exports.detectPackageManager = detectPackageManager;
|
|
10
|
+
exports.getInstallCommand = getInstallCommand;
|
|
11
|
+
exports.getJavaScriptRuntime = getJavaScriptRuntime;
|
|
12
|
+
exports.spawnJavaScript = spawnJavaScript;
|
|
13
|
+
exports.spawnJavaScriptSync = spawnJavaScriptSync;
|
|
14
|
+
const child_process_1 = require("child_process");
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const net_1 = require("net");
|
|
17
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
exports.isBunRuntime = typeof process.versions.bun ===
|
|
20
|
+
'string';
|
|
48
21
|
function runtimeFetch(url, options) {
|
|
49
|
-
const fetchImpl = typeof globalThis.fetch === 'function'
|
|
22
|
+
const fetchImpl = typeof globalThis.fetch === 'function'
|
|
23
|
+
? globalThis.fetch.bind(globalThis)
|
|
24
|
+
: node_fetch_1.default;
|
|
50
25
|
return fetchImpl(url, options);
|
|
51
26
|
}
|
|
52
27
|
function resolveTcpTarget(input) {
|
|
@@ -55,82 +30,62 @@ function resolveTcpTarget(input) {
|
|
|
55
30
|
const port = parsed.port || (parsed.protocol === 'http:' ? '80' : '443');
|
|
56
31
|
return {
|
|
57
32
|
host: parsed.hostname,
|
|
58
|
-
port: Number(port)
|
|
33
|
+
port: Number(port),
|
|
59
34
|
};
|
|
60
|
-
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
61
37
|
const [host, port] = input.split(':');
|
|
62
38
|
return {
|
|
63
39
|
host,
|
|
64
|
-
port: port ? Number(port) : 443
|
|
40
|
+
port: port ? Number(port) : 443,
|
|
65
41
|
};
|
|
66
42
|
}
|
|
67
43
|
}
|
|
68
44
|
function measureTcpConnectOnce(host, port, timeout) {
|
|
69
|
-
return new Promise((resolve)=>{
|
|
45
|
+
return new Promise((resolve) => {
|
|
70
46
|
const startedAt = Date.now();
|
|
71
|
-
const socket = (0,
|
|
72
|
-
|
|
73
|
-
port
|
|
74
|
-
});
|
|
75
|
-
const finish = (latency)=>{
|
|
47
|
+
const socket = (0, net_1.createConnection)({ host, port });
|
|
48
|
+
const finish = (latency) => {
|
|
76
49
|
socket.removeAllListeners();
|
|
77
50
|
socket.destroy();
|
|
78
51
|
resolve(latency);
|
|
79
52
|
};
|
|
80
53
|
socket.setTimeout(timeout);
|
|
81
|
-
socket.once('connect', ()=>{
|
|
54
|
+
socket.once('connect', () => {
|
|
82
55
|
finish(Date.now() - startedAt);
|
|
83
56
|
});
|
|
84
|
-
socket.once('timeout', ()=>{
|
|
57
|
+
socket.once('timeout', () => {
|
|
85
58
|
finish(Number.POSITIVE_INFINITY);
|
|
86
59
|
});
|
|
87
|
-
socket.once('error', ()=>{
|
|
60
|
+
socket.once('error', () => {
|
|
88
61
|
finish(Number.POSITIVE_INFINITY);
|
|
89
62
|
});
|
|
90
63
|
});
|
|
91
64
|
}
|
|
92
|
-
async function measureTcpLatency(input, { attempts = 4, timeout = 1000 } = {}) {
|
|
65
|
+
async function measureTcpLatency(input, { attempts = 4, timeout = 1000, } = {}) {
|
|
93
66
|
const { host, port } = resolveTcpTarget(input);
|
|
94
|
-
const promises = Array.from({
|
|
95
|
-
length: attempts
|
|
96
|
-
}, ()=>measureTcpConnectOnce(host, port, timeout));
|
|
67
|
+
const promises = Array.from({ length: attempts }, () => measureTcpConnectOnce(host, port, timeout));
|
|
97
68
|
const results = await Promise.all(promises);
|
|
98
69
|
const latencies = results.filter(Number.isFinite);
|
|
99
70
|
if (latencies.length === 0) {
|
|
100
71
|
return Number.POSITIVE_INFINITY;
|
|
101
72
|
}
|
|
102
|
-
return latencies.reduce((sum, latency)=>sum + latency, 0) / latencies.length;
|
|
73
|
+
return (latencies.reduce((sum, latency) => sum + latency, 0) / latencies.length);
|
|
103
74
|
}
|
|
104
75
|
function detectPackageManager(cwd = process.cwd(), env = process.env) {
|
|
105
|
-
var _env_npm_config_user_agent;
|
|
106
76
|
const lockFiles = [
|
|
107
|
-
[
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
],
|
|
111
|
-
[
|
|
112
|
-
'bun.lockb',
|
|
113
|
-
'bun'
|
|
114
|
-
],
|
|
115
|
-
[
|
|
116
|
-
'pnpm-lock.yaml',
|
|
117
|
-
'pnpm'
|
|
118
|
-
],
|
|
119
|
-
[
|
|
120
|
-
'yarn.lock',
|
|
121
|
-
'yarn'
|
|
122
|
-
],
|
|
123
|
-
[
|
|
124
|
-
'package-lock.json',
|
|
125
|
-
'npm'
|
|
126
|
-
]
|
|
77
|
+
['bun.lock', 'bun'],
|
|
78
|
+
['bun.lockb', 'bun'],
|
|
79
|
+
['pnpm-lock.yaml', 'pnpm'],
|
|
80
|
+
['yarn.lock', 'yarn'],
|
|
81
|
+
['package-lock.json', 'npm'],
|
|
127
82
|
];
|
|
128
|
-
for (const [lockFile, manager] of lockFiles){
|
|
129
|
-
if (
|
|
83
|
+
for (const [lockFile, manager] of lockFiles) {
|
|
84
|
+
if (fs_1.default.existsSync(path_1.default.join(cwd, lockFile))) {
|
|
130
85
|
return manager;
|
|
131
86
|
}
|
|
132
87
|
}
|
|
133
|
-
const userAgent =
|
|
88
|
+
const userAgent = env.npm_config_user_agent ?? '';
|
|
134
89
|
if (userAgent.startsWith('bun/')) {
|
|
135
90
|
return 'bun';
|
|
136
91
|
}
|
|
@@ -143,41 +98,28 @@ function detectPackageManager(cwd = process.cwd(), env = process.env) {
|
|
|
143
98
|
if (userAgent.startsWith('npm/')) {
|
|
144
99
|
return 'npm';
|
|
145
100
|
}
|
|
146
|
-
return isBunRuntime ? 'bun' : 'npm';
|
|
101
|
+
return exports.isBunRuntime ? 'bun' : 'npm';
|
|
147
102
|
}
|
|
148
103
|
function getInstallCommand(installArgs, cwd = process.cwd()) {
|
|
149
104
|
const packageManager = detectPackageManager(cwd);
|
|
150
105
|
if (packageManager === 'npm') {
|
|
151
|
-
return {
|
|
152
|
-
command: 'npm',
|
|
153
|
-
args: [
|
|
154
|
-
'install',
|
|
155
|
-
...installArgs
|
|
156
|
-
]
|
|
157
|
-
};
|
|
106
|
+
return { command: 'npm', args: ['install', ...installArgs] };
|
|
158
107
|
}
|
|
159
|
-
return {
|
|
160
|
-
command: packageManager,
|
|
161
|
-
args: [
|
|
162
|
-
'add',
|
|
163
|
-
...installArgs
|
|
164
|
-
]
|
|
165
|
-
};
|
|
108
|
+
return { command: packageManager, args: ['add', ...installArgs] };
|
|
166
109
|
}
|
|
167
110
|
function getJavaScriptRuntime(env = process.env) {
|
|
168
|
-
|
|
169
|
-
const configured = (_env_RNU_JS_RUNTIME = env.RNU_JS_RUNTIME) == null ? void 0 : _env_RNU_JS_RUNTIME.toLowerCase();
|
|
111
|
+
const configured = env.RNU_JS_RUNTIME?.toLowerCase();
|
|
170
112
|
if (configured === 'bun') {
|
|
171
113
|
return 'bun';
|
|
172
114
|
}
|
|
173
115
|
if (configured === 'auto') {
|
|
174
|
-
return isBunRuntime ? 'bun' : 'node';
|
|
116
|
+
return exports.isBunRuntime ? 'bun' : 'node';
|
|
175
117
|
}
|
|
176
118
|
return 'node';
|
|
177
119
|
}
|
|
178
120
|
function spawnJavaScript(args, options, env = process.env) {
|
|
179
|
-
return (0,
|
|
121
|
+
return (0, child_process_1.spawn)(getJavaScriptRuntime(env), args, options ?? {});
|
|
180
122
|
}
|
|
181
123
|
function spawnJavaScriptSync(args, options, env = process.env) {
|
|
182
|
-
return (0,
|
|
124
|
+
return (0, child_process_1.spawnSync)(getJavaScriptRuntime(env), args, options ?? {});
|
|
183
125
|
}
|
package/lib/utils/zip-entries.js
CHANGED
|
@@ -1,92 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get enumZipEntries () {
|
|
13
|
-
return enumZipEntries;
|
|
14
|
-
},
|
|
15
|
-
get readEntry () {
|
|
16
|
-
return readEntry;
|
|
17
|
-
},
|
|
18
|
-
get readEntryPrefix () {
|
|
19
|
-
return readEntryPrefix;
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
7
|
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
21
17
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return obj && obj.__esModule ? obj : {
|
|
29
|
-
default: obj
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
33
|
-
if (typeof WeakMap !== "function") return null;
|
|
34
|
-
var cacheBabelInterop = new WeakMap();
|
|
35
|
-
var cacheNodeInterop = new WeakMap();
|
|
36
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
37
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
38
|
-
})(nodeInterop);
|
|
39
|
-
}
|
|
40
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
41
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
42
|
-
return obj;
|
|
43
|
-
}
|
|
44
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
45
|
-
return {
|
|
46
|
-
default: obj
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
47
24
|
};
|
|
48
|
-
|
|
49
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
50
|
-
if (cache && cache.has(obj)) {
|
|
51
|
-
return cache.get(obj);
|
|
52
|
-
}
|
|
53
|
-
var newObj = {
|
|
54
|
-
__proto__: null
|
|
25
|
+
return ownKeys(o);
|
|
55
26
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.readEntry = readEntry;
|
|
40
|
+
exports.readEntryPrefix = readEntryPrefix;
|
|
41
|
+
exports.enumZipEntries = enumZipEntries;
|
|
42
|
+
const fs = __importStar(require("fs-extra"));
|
|
43
|
+
const os_1 = __importDefault(require("os"));
|
|
44
|
+
const path_1 = __importDefault(require("path"));
|
|
45
|
+
const yauzl_1 = require("yauzl");
|
|
46
|
+
const i18n_1 = require("./i18n");
|
|
73
47
|
function readEntry(entry, zipFile) {
|
|
74
48
|
const buffers = [];
|
|
75
|
-
return new Promise((resolve, reject)=>{
|
|
76
|
-
zipFile.openReadStream(entry, (err, stream)=>{
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
zipFile.openReadStream(entry, (err, stream) => {
|
|
77
51
|
if (err) {
|
|
78
52
|
return reject(err);
|
|
79
53
|
}
|
|
80
54
|
if (!stream) {
|
|
81
55
|
return reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
|
|
82
56
|
}
|
|
83
|
-
stream.on('data', (chunk)=>{
|
|
57
|
+
stream.on('data', (chunk) => {
|
|
84
58
|
buffers.push(chunk);
|
|
85
59
|
});
|
|
86
|
-
stream.on('end', ()=>{
|
|
60
|
+
stream.on('end', () => {
|
|
87
61
|
resolve(Buffer.concat(buffers));
|
|
88
62
|
});
|
|
89
|
-
stream.on('error', (err)=>{
|
|
63
|
+
stream.on('error', (err) => {
|
|
90
64
|
reject(err);
|
|
91
65
|
});
|
|
92
66
|
});
|
|
@@ -98,8 +72,8 @@ function readEntryPrefix(entry, zipFile, maxBytes) {
|
|
|
98
72
|
}
|
|
99
73
|
const buffers = [];
|
|
100
74
|
let length = 0;
|
|
101
|
-
return new Promise((resolve, reject)=>{
|
|
102
|
-
zipFile.openReadStream(entry, (err, stream)=>{
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
zipFile.openReadStream(entry, (err, stream) => {
|
|
103
77
|
if (err) {
|
|
104
78
|
return reject(err);
|
|
105
79
|
}
|
|
@@ -108,12 +82,12 @@ function readEntryPrefix(entry, zipFile, maxBytes) {
|
|
|
108
82
|
}
|
|
109
83
|
let settled = false;
|
|
110
84
|
let expectedDestroyError;
|
|
111
|
-
const cleanup = ()=>{
|
|
85
|
+
const cleanup = () => {
|
|
112
86
|
stream.off('data', onData);
|
|
113
87
|
stream.off('end', onEnd);
|
|
114
88
|
stream.off('error', onError);
|
|
115
89
|
};
|
|
116
|
-
const finish = (destroyStream = false)=>{
|
|
90
|
+
const finish = (destroyStream = false) => {
|
|
117
91
|
if (settled) {
|
|
118
92
|
return;
|
|
119
93
|
}
|
|
@@ -129,7 +103,7 @@ function readEntryPrefix(entry, zipFile, maxBytes) {
|
|
|
129
103
|
stream.destroy(expectedDestroyError);
|
|
130
104
|
}
|
|
131
105
|
};
|
|
132
|
-
const onData = (chunk)=>{
|
|
106
|
+
const onData = (chunk) => {
|
|
133
107
|
const remaining = maxBytes - length;
|
|
134
108
|
if (remaining <= 0) {
|
|
135
109
|
finish(true);
|
|
@@ -142,8 +116,8 @@ function readEntryPrefix(entry, zipFile, maxBytes) {
|
|
|
142
116
|
finish(true);
|
|
143
117
|
}
|
|
144
118
|
};
|
|
145
|
-
const onEnd = ()=>finish();
|
|
146
|
-
const onError = (error)=>{
|
|
119
|
+
const onEnd = () => finish();
|
|
120
|
+
const onError = (error) => {
|
|
147
121
|
if (settled && error === expectedDestroyError) {
|
|
148
122
|
cleanup();
|
|
149
123
|
return;
|
|
@@ -162,42 +136,41 @@ function readEntryPrefix(entry, zipFile, maxBytes) {
|
|
|
162
136
|
});
|
|
163
137
|
}
|
|
164
138
|
async function enumZipEntries(zipFn, callback, nestedPath = '') {
|
|
165
|
-
return new Promise((resolve, reject)=>{
|
|
166
|
-
(0,
|
|
167
|
-
lazyEntries: true
|
|
168
|
-
}, async (err, zipfile)=>{
|
|
139
|
+
return new Promise((resolve, reject) => {
|
|
140
|
+
(0, yauzl_1.open)(zipFn, { lazyEntries: true }, async (err, zipfile) => {
|
|
169
141
|
if (err) {
|
|
170
142
|
return reject(err);
|
|
171
143
|
}
|
|
172
144
|
zipfile.on('end', resolve);
|
|
173
145
|
zipfile.on('error', reject);
|
|
174
|
-
zipfile.on('entry', async (entry)=>{
|
|
146
|
+
zipfile.on('entry', async (entry) => {
|
|
175
147
|
const fullPath = nestedPath + entry.fileName;
|
|
176
148
|
try {
|
|
177
|
-
if (!entry.fileName.endsWith('/') &&
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
149
|
+
if (!entry.fileName.endsWith('/') &&
|
|
150
|
+
entry.fileName.toLowerCase().endsWith('.hap')) {
|
|
151
|
+
const tempDir = await fs.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'nested_zip_'));
|
|
152
|
+
const tempZipPath = path_1.default.join(tempDir, 'temp.zip');
|
|
153
|
+
await new Promise((res, rej) => {
|
|
154
|
+
zipfile.openReadStream(entry, async (err, readStream) => {
|
|
155
|
+
if (err)
|
|
156
|
+
return rej(err);
|
|
157
|
+
const writeStream = fs.createWriteStream(tempZipPath);
|
|
184
158
|
readStream.on('error', rej);
|
|
185
159
|
readStream.pipe(writeStream);
|
|
186
|
-
writeStream.on('finish', ()=>res(void 0));
|
|
160
|
+
writeStream.on('finish', () => res(void 0));
|
|
187
161
|
writeStream.on('error', rej);
|
|
188
162
|
});
|
|
189
163
|
});
|
|
190
164
|
await enumZipEntries(tempZipPath, callback, `${fullPath}/`);
|
|
191
|
-
await
|
|
165
|
+
await fs.remove(tempDir);
|
|
192
166
|
}
|
|
193
167
|
const result = callback(entry, zipfile, fullPath);
|
|
194
168
|
if (result && typeof result.then === 'function') {
|
|
195
169
|
await result;
|
|
196
170
|
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}));
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
console.error((0, i18n_1.t)('processingError', { error }));
|
|
201
174
|
zipfile.close();
|
|
202
175
|
reject(error);
|
|
203
176
|
return;
|