react-native-update-cli 2.11.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.
Files changed (51) hide show
  1. package/README.md +4 -0
  2. package/README.zh-CN.md +4 -0
  3. package/cli.json +6 -0
  4. package/lib/api.js +10 -12
  5. package/lib/app.d.ts +1 -1
  6. package/lib/app.js +1 -1
  7. package/lib/bin.js +5 -2
  8. package/lib/bundle-runner.js +22 -12
  9. package/lib/install.js +3 -4
  10. package/lib/locales/en.d.ts +1 -0
  11. package/lib/locales/en.js +1 -0
  12. package/lib/locales/zh.d.ts +1 -0
  13. package/lib/locales/zh.js +1 -0
  14. package/lib/package.d.ts +3 -0
  15. package/lib/package.js +6 -2
  16. package/lib/provider.d.ts +2 -2
  17. package/lib/provider.js +23 -22
  18. package/lib/types.d.ts +17 -4
  19. package/lib/utils/app-info-parser/zip.d.ts +3 -3
  20. package/lib/utils/app-info-parser/zip.js +33 -19
  21. package/lib/utils/git.d.ts +2 -1
  22. package/lib/utils/git.js +82 -40
  23. package/lib/utils/http-helper.js +8 -8
  24. package/lib/utils/index.d.ts +1 -0
  25. package/lib/utils/index.js +9 -1
  26. package/lib/utils/runtime.d.ts +28 -0
  27. package/lib/utils/runtime.js +183 -0
  28. package/lib/utils/zip-entries.js +1 -2
  29. package/lib/versions.d.ts +6 -3
  30. package/lib/versions.js +80 -23
  31. package/package.json +1 -7
  32. package/src/api.ts +23 -15
  33. package/src/app.ts +1 -1
  34. package/src/bin.ts +9 -2
  35. package/src/bundle-runner.ts +91 -50
  36. package/src/install.ts +3 -1
  37. package/src/locales/en.ts +1 -0
  38. package/src/locales/zh.ts +1 -0
  39. package/src/package.ts +11 -2
  40. package/src/provider.ts +47 -40
  41. package/src/types.ts +18 -4
  42. package/src/utils/app-info-parser/zip.ts +41 -24
  43. package/src/utils/git.ts +52 -31
  44. package/src/utils/http-helper.ts +8 -3
  45. package/src/utils/index.ts +8 -1
  46. package/src/utils/runtime.ts +187 -0
  47. package/src/utils/zip-entries.ts +2 -4
  48. package/src/versions.ts +105 -32
  49. package/lib/utils/latest-version/cli.d.ts +0 -1
  50. package/lib/utils/latest-version/cli.js +0 -308
  51. package/src/utils/latest-version/cli.ts +0 -445
package/src/provider.ts CHANGED
@@ -8,8 +8,8 @@ import type {
8
8
  Platform,
9
9
  PublishOptions,
10
10
  Session,
11
+ UpdateVersionOptions,
11
12
  UploadOptions,
12
- Version,
13
13
  } from './types';
14
14
  import { runAsCommandResult } from './utils/command-result';
15
15
 
@@ -84,6 +84,7 @@ export class CLIProviderImpl implements CLIProvider {
84
84
  bundleName: options.bundleName || 'index.bundlejs',
85
85
  entryFile: options.entryFile || 'index.js',
86
86
  output: options.output || DEFAULT_BUNDLE_OUTPUT,
87
+ 'no-interactive': true,
87
88
  sourcemap: options.sourcemap || false,
88
89
  taro: options.taro || false,
89
90
  expo: options.expo || false,
@@ -103,18 +104,26 @@ export class CLIProviderImpl implements CLIProvider {
103
104
  async publish(options: PublishOptions): Promise<CommandResult> {
104
105
  return this.runMessageCommand(
105
106
  async () => {
106
- const context = this.createContext({
107
- name: options.name,
108
- description: options.description,
109
- metaInfo: options.metaInfo,
110
- packageId: options.packageId,
111
- packageVersion: options.packageVersion,
112
- minPackageVersion: options.minPackageVersion,
113
- maxPackageVersion: options.maxPackageVersion,
114
- packageVersionRange: options.packageVersionRange,
115
- rollout: options.rollout,
116
- dryRun: options.dryRun || false,
117
- });
107
+ const context = this.createContext(
108
+ {
109
+ name: options.name,
110
+ description: options.description,
111
+ metaInfo: options.metaInfo,
112
+ packageId: options.packageId,
113
+ packageVersion: options.packageVersion,
114
+ minPackageVersion: options.minPackageVersion,
115
+ maxPackageVersion: options.maxPackageVersion,
116
+ packageVersionRange: options.packageVersionRange,
117
+ platform: options.platform,
118
+ 'no-interactive': true,
119
+ rollout:
120
+ options.rollout === undefined
121
+ ? undefined
122
+ : String(options.rollout),
123
+ dryRun: options.dryRun || false,
124
+ },
125
+ options.filePath ? [options.filePath] : [],
126
+ );
118
127
 
119
128
  const { versionCommands } = await import('./versions');
120
129
  await versionCommands.publish(context);
@@ -127,14 +136,16 @@ export class CLIProviderImpl implements CLIProvider {
127
136
  async upload(options: UploadOptions): Promise<CommandResult> {
128
137
  return this.runMessageCommand(
129
138
  async () => {
130
- const platform = await this.getPlatform(options.platform);
131
- const { appId } = await this.getSelectedApp(platform);
132
-
133
139
  const filePath = options.filePath;
134
140
  const fileType = filePath.split('.').pop()?.toLowerCase();
135
141
 
136
142
  const context = this.createContext(
137
- { platform, appId, version: options.version },
143
+ {
144
+ platform: options.platform,
145
+ appId: options.appId,
146
+ appKey: options.appKey,
147
+ version: options.version,
148
+ },
138
149
  [filePath],
139
150
  );
140
151
 
@@ -168,17 +179,12 @@ export class CLIProviderImpl implements CLIProvider {
168
179
  }
169
180
 
170
181
  async listApps(platform?: Platform): Promise<CommandResult> {
171
- return this.runMessageCommand(
172
- async () => {
173
- const resolvedPlatform = await this.getPlatform(platform);
174
- const { getAppCommands } = await import('./app');
175
- await getAppCommands().apps({
176
- options: { platform: resolvedPlatform },
177
- });
178
- },
179
- 'Unknown error listing apps',
180
- 'Apps listed successfully',
181
- );
182
+ return this.runDataCommand(async () => {
183
+ const { getAppCommands } = await import('./app');
184
+ return getAppCommands().apps({
185
+ options: { platform: platform ?? '' },
186
+ });
187
+ }, 'Unknown error listing apps');
182
188
  }
183
189
 
184
190
  async createApp(name: string, platform: Platform): Promise<CommandResult> {
@@ -199,26 +205,27 @@ export class CLIProviderImpl implements CLIProvider {
199
205
  }
200
206
 
201
207
  async listVersions(appId: string): Promise<CommandResult> {
202
- return this.runMessageCommand(
203
- async () => {
204
- const context = this.createContext({ appId });
205
-
206
- const { versionCommands } = await import('./versions');
207
- await versionCommands.versions(context);
208
- },
209
- 'Unknown error listing versions',
210
- 'Versions listed successfully',
211
- );
208
+ return this.runDataCommand(async () => {
209
+ const { fetchVersions } = await import('./versions');
210
+ return fetchVersions(appId);
211
+ }, 'Unknown error listing versions');
212
212
  }
213
213
 
214
214
  async updateVersion(
215
215
  appId: string,
216
216
  versionId: string,
217
- updates: Partial<Version>,
217
+ updates: UpdateVersionOptions,
218
218
  ): Promise<CommandResult> {
219
219
  return this.runMessageCommand(
220
220
  async () => {
221
- const context = this.createContext({ appId, ...updates }, [versionId]);
221
+ const context = this.createContext({
222
+ appId,
223
+ versionId,
224
+ ...updates,
225
+ 'no-interactive': true,
226
+ rollout:
227
+ updates.rollout === undefined ? undefined : String(updates.rollout),
228
+ });
222
229
 
223
230
  const { versionCommands } = await import('./versions');
224
231
  await versionCommands.update(context);
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  declare global {
2
- var NO_INTERACTIVE: boolean;
3
- var USE_ACC_OSS: boolean;
2
+ var NO_INTERACTIVE: boolean | undefined;
3
+ var USE_ACC_OSS: boolean | undefined;
4
4
  }
5
5
 
6
6
  export interface Session {
@@ -59,6 +59,8 @@ export interface BundleOptions {
59
59
  }
60
60
 
61
61
  export interface PublishOptions {
62
+ filePath?: string;
63
+ platform?: Platform;
62
64
  name?: string;
63
65
  description?: string;
64
66
  metaInfo?: string;
@@ -67,7 +69,7 @@ export interface PublishOptions {
67
69
  minPackageVersion?: string;
68
70
  maxPackageVersion?: string;
69
71
  packageVersionRange?: string;
70
- rollout?: number;
72
+ rollout?: number | string;
71
73
  dryRun?: boolean;
72
74
  }
73
75
 
@@ -75,9 +77,21 @@ export interface UploadOptions {
75
77
  platform?: Platform;
76
78
  filePath: string;
77
79
  appId?: string;
80
+ appKey?: string;
78
81
  version?: string;
79
82
  }
80
83
 
84
+ export interface UpdateVersionOptions {
85
+ platform?: Platform;
86
+ packageId?: string;
87
+ packageVersion?: string;
88
+ minPackageVersion?: string;
89
+ maxPackageVersion?: string;
90
+ packageVersionRange?: string;
91
+ rollout?: number | string;
92
+ dryRun?: boolean;
93
+ }
94
+
81
95
  export interface CLIProvider {
82
96
  bundle: (options: BundleOptions) => Promise<CommandResult>;
83
97
  publish: (options: PublishOptions) => Promise<CommandResult>;
@@ -93,7 +107,7 @@ export interface CLIProvider {
93
107
  updateVersion: (
94
108
  appId: string,
95
109
  versionId: string,
96
- updates: Partial<Version>,
110
+ updates: UpdateVersionOptions,
97
111
  ) => Promise<CommandResult>;
98
112
 
99
113
  getPlatform: (platform?: Platform) => Promise<Platform>;
@@ -1,17 +1,12 @@
1
1
  import path from 'path';
2
- import { decodeNullUnicode } from './utils';
3
-
4
- const Unzip = require('isomorphic-unzip');
5
-
6
2
  import { enumZipEntries, readEntry } from '../zip-entries';
3
+ import { decodeNullUnicode } from './utils';
7
4
 
8
5
  export class Zip {
9
6
  file: string | File;
10
- unzip: any;
11
7
 
12
8
  constructor(file: string | File) {
13
9
  this.file = typeof file === 'string' ? path.resolve(file) : file;
14
- this.unzip = new Unzip(this.file);
15
10
  }
16
11
 
17
12
  /**
@@ -24,15 +19,7 @@ export class Zip {
24
19
  type: 'buffer' | 'blob' = 'buffer',
25
20
  ) {
26
21
  const decoded = regexps.map((regex) => decodeNullUnicode(regex));
27
- return new Promise<Record<string, Buffer | Blob>>((resolve, reject) => {
28
- this.unzip.getBuffer(
29
- decoded,
30
- { type },
31
- (err: Error | null, buffers: Record<string, Buffer | Blob>) => {
32
- err ? reject(err) : resolve(buffers);
33
- },
34
- );
35
- });
22
+ return this.readEntries(decoded, type);
36
23
  }
37
24
 
38
25
  /**
@@ -42,15 +29,9 @@ export class Zip {
42
29
  */
43
30
  getEntry(regex: RegExp | string, type: 'buffer' | 'blob' = 'buffer') {
44
31
  const decoded = decodeNullUnicode(regex);
45
- return new Promise<Buffer | Blob | undefined>((resolve, reject) => {
46
- this.unzip.getBuffer(
47
- [decoded],
48
- { type },
49
- (err: Error | null, buffers: Record<string, Buffer | Blob>) => {
50
- err ? reject(err) : resolve(buffers[decoded as any]);
51
- },
52
- );
53
- });
32
+ return this.readEntries([decoded], type).then(
33
+ (buffers) => buffers[decoded as any],
34
+ );
54
35
  }
55
36
 
56
37
  async getEntryFromHarmonyApp(
@@ -71,4 +52,40 @@ export class Zip {
71
52
  console.error('Error in getEntryFromHarmonyApp:', error);
72
53
  }
73
54
  }
55
+
56
+ private async readEntries(
57
+ decoded: Array<RegExp | string>,
58
+ type: 'buffer' | 'blob',
59
+ ): Promise<Record<string, Buffer | Blob>> {
60
+ if (typeof this.file !== 'string') {
61
+ throw new Error('Param error: [file] must be file path in Node.');
62
+ }
63
+
64
+ const buffers: Record<string, Buffer | Blob> = {};
65
+ await enumZipEntries(this.file, async (entry, zipFile) => {
66
+ if (entry.fileName.endsWith('/')) {
67
+ return;
68
+ }
69
+
70
+ const entryName = decodeNullUnicode(entry.fileName).toString();
71
+ const lowerEntryName = entryName.toLowerCase();
72
+ const matched = decoded.find((pattern) => {
73
+ if (typeof pattern === 'string') {
74
+ return pattern === entryName || pattern === lowerEntryName;
75
+ }
76
+ pattern.lastIndex = 0;
77
+ return pattern.test(lowerEntryName);
78
+ });
79
+
80
+ if (!matched) {
81
+ return;
82
+ }
83
+
84
+ const buffer = await readEntry(entry, zipFile);
85
+ buffers[matched as any] =
86
+ type === 'blob' ? new Blob([buffer as any]) : buffer;
87
+ });
88
+
89
+ return buffers;
90
+ }
74
91
  }
package/src/utils/git.ts CHANGED
@@ -1,50 +1,71 @@
1
- import fs from 'fs';
2
- import git from 'isomorphic-git';
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: string;
9
+ origin?: string;
11
10
  }
12
11
 
13
- function findGitRoot(dir = process.cwd()) {
14
- const gitRoot = fs.readdirSync(dir).find((dir) => dir === '.git');
15
- if (gitRoot) {
16
- // console.log({ gitRoot });
17
- return path.join(dir, gitRoot);
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 findGitRoot(parentDir);
19
+ return result.stdout.toString().trim();
24
20
  }
25
21
 
26
- const gitRoot = findGitRoot();
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
- export async function getCommitInfo(): Promise<CommitInfo | undefined> {
29
- if (!gitRoot) {
30
- return;
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 remotes = await git.listRemotes({ fs, gitdir: gitRoot });
34
- const origin =
35
- remotes.find((remote) => remote.remote === 'origin') || remotes[0];
36
- const { commit, oid } = (
37
- await git.log({ fs, gitdir: gitRoot, depth: 1 })
38
- )[0];
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: oid,
41
- message: commit.message,
42
- author: commit.author.name || commit.committer.name,
43
- timestamp: String(commit.committer.timestamp),
44
- origin: origin?.url,
62
+ hash,
63
+ message,
64
+ author,
65
+ timestamp,
66
+ origin,
45
67
  };
46
- } catch (error) {
47
- console.error(error);
68
+ } catch (_error) {
48
69
  return;
49
70
  }
50
71
  }
@@ -1,5 +1,5 @@
1
- import fetch from 'node-fetch';
2
1
  import { defaultEndpoints } from './constants';
2
+ import { runtimeFetch } from './runtime';
3
3
 
4
4
  // const baseUrl = `http://localhost:9000`;
5
5
  // let baseUrl = SERVER.main[0];
@@ -25,7 +25,7 @@ export function promiseAny<T>(promises: Promise<T>[]) {
25
25
  export const ping = async (url: string) => {
26
26
  let pingFinished = false;
27
27
  return Promise.race([
28
- fetch(url, {
28
+ runtimeFetch(url, {
29
29
  method: 'HEAD',
30
30
  })
31
31
  .then(({ status }) => {
@@ -57,7 +57,12 @@ export const testUrls = async (urls?: string[]) => {
57
57
  if (!urls?.length) {
58
58
  return null;
59
59
  }
60
- const ret = await promiseAny(urls.map(ping));
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
  }
@@ -83,8 +83,15 @@ type AabResourceTableObject = {
83
83
  package: AabResourcePackage[];
84
84
  };
85
85
 
86
+ export function isNonInteractive() {
87
+ const envValue = process.env.NO_INTERACTIVE?.toLowerCase();
88
+ return (
89
+ global.NO_INTERACTIVE === true || envValue === 'true' || envValue === '1'
90
+ );
91
+ }
92
+
86
93
  export async function question(query: string, password?: boolean) {
87
- if (NO_INTERACTIVE) {
94
+ if (isNonInteractive()) {
88
95
  return '';
89
96
  }
90
97
  return read({
@@ -0,0 +1,187 @@
1
+ import {
2
+ type ChildProcessWithoutNullStreams,
3
+ type SpawnOptionsWithoutStdio,
4
+ type SpawnSyncOptions,
5
+ spawn,
6
+ spawnSync,
7
+ } from 'child_process';
8
+ import fs from 'fs';
9
+ import { createConnection } from 'net';
10
+ import nodeFetch from 'node-fetch';
11
+ import path from 'path';
12
+
13
+ export type RuntimeRequestInit = {
14
+ method?: string;
15
+ headers?: Record<string, string>;
16
+ body?: any;
17
+ signal?: AbortSignal;
18
+ };
19
+
20
+ export type RuntimeResponse = {
21
+ status: number;
22
+ statusText: string;
23
+ text: () => Promise<string>;
24
+ };
25
+
26
+ export type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
27
+ export type JavaScriptRuntime = 'bun' | 'node';
28
+
29
+ export const isBunRuntime =
30
+ typeof (process.versions as NodeJS.ProcessVersions & { bun?: string }).bun ===
31
+ 'string';
32
+
33
+ export function runtimeFetch(
34
+ url: string,
35
+ options?: RuntimeRequestInit,
36
+ ): Promise<RuntimeResponse> {
37
+ const fetchImpl =
38
+ typeof globalThis.fetch === 'function'
39
+ ? globalThis.fetch.bind(globalThis)
40
+ : nodeFetch;
41
+
42
+ return fetchImpl(url, options as any) as Promise<RuntimeResponse>;
43
+ }
44
+
45
+ function resolveTcpTarget(input: string): { host: string; port: number } {
46
+ try {
47
+ const parsed = new URL(input);
48
+ const port = parsed.port || (parsed.protocol === 'http:' ? '80' : '443');
49
+ return {
50
+ host: parsed.hostname,
51
+ port: Number(port),
52
+ };
53
+ } catch {
54
+ const [host, port] = input.split(':');
55
+ return {
56
+ host,
57
+ port: port ? Number(port) : 443,
58
+ };
59
+ }
60
+ }
61
+
62
+ function measureTcpConnectOnce(
63
+ host: string,
64
+ port: number,
65
+ timeout: number,
66
+ ): Promise<number> {
67
+ return new Promise((resolve) => {
68
+ const startedAt = Date.now();
69
+ const socket = createConnection({ host, port });
70
+
71
+ const finish = (latency: number) => {
72
+ socket.removeAllListeners();
73
+ socket.destroy();
74
+ resolve(latency);
75
+ };
76
+
77
+ socket.setTimeout(timeout);
78
+ socket.once('connect', () => {
79
+ finish(Date.now() - startedAt);
80
+ });
81
+ socket.once('timeout', () => {
82
+ finish(Number.POSITIVE_INFINITY);
83
+ });
84
+ socket.once('error', () => {
85
+ finish(Number.POSITIVE_INFINITY);
86
+ });
87
+ });
88
+ }
89
+
90
+ export async function measureTcpLatency(
91
+ input: string,
92
+ {
93
+ attempts = 4,
94
+ timeout = 1000,
95
+ }: {
96
+ attempts?: number;
97
+ timeout?: number;
98
+ } = {},
99
+ ): Promise<number> {
100
+ const { host, port } = resolveTcpTarget(input);
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);
106
+
107
+ if (latencies.length === 0) {
108
+ return Number.POSITIVE_INFINITY;
109
+ }
110
+ return (
111
+ latencies.reduce((sum, latency) => sum + latency, 0) / latencies.length
112
+ );
113
+ }
114
+
115
+ export function detectPackageManager(
116
+ cwd = process.cwd(),
117
+ env: NodeJS.ProcessEnv = process.env,
118
+ ): PackageManager {
119
+ const lockFiles: Array<[string, PackageManager]> = [
120
+ ['bun.lock', 'bun'],
121
+ ['bun.lockb', 'bun'],
122
+ ['pnpm-lock.yaml', 'pnpm'],
123
+ ['yarn.lock', 'yarn'],
124
+ ['package-lock.json', 'npm'],
125
+ ];
126
+ for (const [lockFile, manager] of lockFiles) {
127
+ if (fs.existsSync(path.join(cwd, lockFile))) {
128
+ return manager;
129
+ }
130
+ }
131
+
132
+ const userAgent = env.npm_config_user_agent ?? '';
133
+ if (userAgent.startsWith('bun/')) {
134
+ return 'bun';
135
+ }
136
+ if (userAgent.startsWith('pnpm/')) {
137
+ return 'pnpm';
138
+ }
139
+ if (userAgent.startsWith('yarn/')) {
140
+ return 'yarn';
141
+ }
142
+ if (userAgent.startsWith('npm/')) {
143
+ return 'npm';
144
+ }
145
+
146
+ return isBunRuntime ? 'bun' : 'npm';
147
+ }
148
+
149
+ export function getInstallCommand(
150
+ installArgs: string[],
151
+ cwd = process.cwd(),
152
+ ): { command: string; args: string[] } {
153
+ const packageManager = detectPackageManager(cwd);
154
+ if (packageManager === 'npm') {
155
+ return { command: 'npm', args: ['install', ...installArgs] };
156
+ }
157
+ return { command: packageManager, args: ['add', ...installArgs] };
158
+ }
159
+
160
+ export function getJavaScriptRuntime(
161
+ env: NodeJS.ProcessEnv = process.env,
162
+ ): JavaScriptRuntime {
163
+ const configured = env.RNU_JS_RUNTIME?.toLowerCase();
164
+ if (configured === 'bun') {
165
+ return 'bun';
166
+ }
167
+ if (configured === 'auto') {
168
+ return isBunRuntime ? 'bun' : 'node';
169
+ }
170
+ return 'node';
171
+ }
172
+
173
+ export function spawnJavaScript(
174
+ args: string[],
175
+ options?: SpawnOptionsWithoutStdio,
176
+ env: NodeJS.ProcessEnv = process.env,
177
+ ): ChildProcessWithoutNullStreams {
178
+ return spawn(getJavaScriptRuntime(env), args, options ?? {});
179
+ }
180
+
181
+ export function spawnJavaScriptSync(
182
+ args: string[],
183
+ options?: SpawnSyncOptions,
184
+ env: NodeJS.ProcessEnv = process.env,
185
+ ) {
186
+ return spawnSync(getJavaScriptRuntime(env), args, options ?? {});
187
+ }
@@ -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 = path.join(
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) => {