react-native-update-cli 2.11.0 → 2.12.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/README.md +4 -0
- package/README.zh-CN.md +4 -0
- package/cli.json +6 -0
- package/lib/api.js +10 -12
- package/lib/app.d.ts +1 -1
- package/lib/app.js +1 -1
- package/lib/bin.js +5 -2
- package/lib/bundle-runner.js +22 -12
- package/lib/install.js +3 -4
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/package.d.ts +3 -0
- package/lib/package.js +6 -2
- package/lib/provider.d.ts +2 -2
- package/lib/provider.js +23 -22
- package/lib/types.d.ts +17 -4
- package/lib/utils/app-info-parser/zip.d.ts +3 -3
- package/lib/utils/app-info-parser/zip.js +33 -19
- package/lib/utils/http-helper.js +2 -7
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +9 -1
- package/lib/utils/runtime.d.ts +28 -0
- package/lib/utils/runtime.js +185 -0
- package/lib/versions.d.ts +6 -3
- package/lib/versions.js +80 -23
- package/package.json +1 -6
- package/src/api.ts +23 -15
- package/src/app.ts +1 -1
- package/src/bin.ts +9 -2
- package/src/bundle-runner.ts +91 -50
- package/src/install.ts +3 -1
- package/src/locales/en.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/src/package.ts +11 -2
- package/src/provider.ts +47 -40
- package/src/types.ts +18 -4
- package/src/utils/app-info-parser/zip.ts +41 -24
- package/src/utils/http-helper.ts +2 -2
- package/src/utils/index.ts +8 -1
- package/src/utils/runtime.ts +190 -0
- package/src/versions.ts +105 -32
- package/lib/utils/latest-version/cli.d.ts +0 -1
- package/lib/utils/latest-version/cli.js +0 -308
- package/src/utils/latest-version/cli.ts +0 -445
package/src/bin.ts
CHANGED
|
@@ -19,6 +19,10 @@ interface CliArgv {
|
|
|
19
19
|
options: Record<string, any>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
function isTruthyEnv(value: string | undefined): boolean {
|
|
23
|
+
return value === '1' || value?.toLowerCase() === 'true';
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
function printUsage(exitCode = 1) {
|
|
23
27
|
console.log('React Native Update CLI');
|
|
24
28
|
console.log('');
|
|
@@ -57,8 +61,11 @@ async function run() {
|
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
const argv: CliArgv = require('cli-arguments').parse(require('../cli.json'));
|
|
60
|
-
global.NO_INTERACTIVE =
|
|
61
|
-
|
|
64
|
+
global.NO_INTERACTIVE =
|
|
65
|
+
Boolean(argv.options['no-interactive']) ||
|
|
66
|
+
isTruthyEnv(process.env.NO_INTERACTIVE);
|
|
67
|
+
global.USE_ACC_OSS =
|
|
68
|
+
Boolean(argv.options.acc) || isTruthyEnv(process.env.USE_ACC_OSS);
|
|
62
69
|
|
|
63
70
|
try {
|
|
64
71
|
await loadSession();
|
package/src/bundle-runner.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
2
|
import { satisfies } from 'compare-versions';
|
|
3
3
|
import * as fs from 'fs-extra';
|
|
4
4
|
import os from 'os';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { t } from './utils/i18n';
|
|
7
|
+
import {
|
|
8
|
+
getJavaScriptRuntime,
|
|
9
|
+
spawnJavaScript,
|
|
10
|
+
spawnJavaScriptSync,
|
|
11
|
+
} from './utils/runtime';
|
|
7
12
|
|
|
8
13
|
const g2js = require('gradle-to-js/lib/parser');
|
|
9
14
|
const properties = require('properties');
|
|
@@ -39,6 +44,12 @@ const dependencyFields = [
|
|
|
39
44
|
'optionalDependencies',
|
|
40
45
|
] as const;
|
|
41
46
|
|
|
47
|
+
type SyncProcessResult = {
|
|
48
|
+
status: number | null;
|
|
49
|
+
signal: NodeJS.Signals | null;
|
|
50
|
+
error?: Error;
|
|
51
|
+
};
|
|
52
|
+
|
|
42
53
|
type ResolvedExpoCli = {
|
|
43
54
|
cliPath: string;
|
|
44
55
|
usingExpo: boolean;
|
|
@@ -242,9 +253,10 @@ export async function runReactNativeBundleCommand({
|
|
|
242
253
|
reactNativeBundleArgs.push('--config', config);
|
|
243
254
|
}
|
|
244
255
|
|
|
245
|
-
const
|
|
256
|
+
const jsRuntime = getJavaScriptRuntime();
|
|
257
|
+
const reactNativeBundleProcess = spawnJavaScript(reactNativeBundleArgs);
|
|
246
258
|
console.log(
|
|
247
|
-
`Running bundle command:
|
|
259
|
+
`Running bundle command: ${jsRuntime} ${reactNativeBundleArgs.join(' ')}`,
|
|
248
260
|
);
|
|
249
261
|
|
|
250
262
|
await new Promise<void>((resolve, reject) => {
|
|
@@ -346,6 +358,24 @@ function dirnameOfPackage(
|
|
|
346
358
|
);
|
|
347
359
|
}
|
|
348
360
|
|
|
361
|
+
function assertSuccessfulSyncProcess(
|
|
362
|
+
result: SyncProcessResult,
|
|
363
|
+
command: string,
|
|
364
|
+
) {
|
|
365
|
+
if (result.error) {
|
|
366
|
+
throw result.error;
|
|
367
|
+
}
|
|
368
|
+
if (result.status !== 0) {
|
|
369
|
+
throw new Error(
|
|
370
|
+
`${command} failed with ${
|
|
371
|
+
result.status === null
|
|
372
|
+
? `signal ${result.signal}`
|
|
373
|
+
: `exit code ${result.status}`
|
|
374
|
+
}`,
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
349
379
|
export function resolveHermesCommand(projectRoot = process.cwd()): string {
|
|
350
380
|
const osBin = getHermesOSBin();
|
|
351
381
|
if (!osBin) {
|
|
@@ -453,9 +483,12 @@ async function compileHermesByteCode(
|
|
|
453
483
|
console.log(
|
|
454
484
|
t('runningHermesc', { command: hermesCommand, args: args.join(' ') }),
|
|
455
485
|
);
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
486
|
+
assertSuccessfulSyncProcess(
|
|
487
|
+
spawnSync(hermesCommand, args, {
|
|
488
|
+
stdio: 'ignore',
|
|
489
|
+
}),
|
|
490
|
+
hermesCommand,
|
|
491
|
+
);
|
|
459
492
|
if (sourcemapOutput) {
|
|
460
493
|
const composerPath =
|
|
461
494
|
'node_modules/react-native/scripts/compose-source-maps.js';
|
|
@@ -463,18 +496,20 @@ async function compileHermesByteCode(
|
|
|
463
496
|
return;
|
|
464
497
|
}
|
|
465
498
|
console.log(t('composingSourceMap'));
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
499
|
+
assertSuccessfulSyncProcess(
|
|
500
|
+
spawnJavaScriptSync(
|
|
501
|
+
[
|
|
502
|
+
composerPath,
|
|
503
|
+
path.join(outputFolder, `${bundleName}.txt.map`),
|
|
504
|
+
path.join(outputFolder, `${bundleName}.map`),
|
|
505
|
+
'-o',
|
|
506
|
+
sourcemapOutput,
|
|
507
|
+
],
|
|
508
|
+
{
|
|
509
|
+
stdio: 'ignore',
|
|
510
|
+
},
|
|
511
|
+
),
|
|
512
|
+
composerPath,
|
|
478
513
|
);
|
|
479
514
|
}
|
|
480
515
|
if (shouldCleanSourcemap) {
|
|
@@ -505,16 +540,18 @@ export async function copyDebugidForSentry(
|
|
|
505
540
|
return;
|
|
506
541
|
}
|
|
507
542
|
console.log(t('copyingDebugId'));
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
543
|
+
assertSuccessfulSyncProcess(
|
|
544
|
+
spawnJavaScriptSync(
|
|
545
|
+
[
|
|
546
|
+
copyDebugidPath,
|
|
547
|
+
path.join(outputFolder, `${bundleName}.txt.map`),
|
|
548
|
+
path.join(outputFolder, `${bundleName}.map`),
|
|
549
|
+
],
|
|
550
|
+
{
|
|
551
|
+
stdio: 'ignore',
|
|
552
|
+
},
|
|
553
|
+
),
|
|
554
|
+
copyDebugidPath,
|
|
518
555
|
);
|
|
519
556
|
}
|
|
520
557
|
fs.removeSync(path.join(outputFolder, `${bundleName}.txt.map`));
|
|
@@ -544,31 +581,35 @@ export async function uploadSourcemapForSentry(
|
|
|
544
581
|
return;
|
|
545
582
|
}
|
|
546
583
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
584
|
+
assertSuccessfulSyncProcess(
|
|
585
|
+
spawnJavaScriptSync(
|
|
586
|
+
[sentryCliPath, 'releases', 'set-commits', version, '--auto'],
|
|
587
|
+
{
|
|
588
|
+
stdio: 'inherit',
|
|
589
|
+
},
|
|
590
|
+
),
|
|
591
|
+
sentryCliPath,
|
|
553
592
|
);
|
|
554
593
|
console.log(t('sentryReleaseCreated', { version }));
|
|
555
594
|
|
|
556
595
|
console.log(t('uploadingSourcemap'));
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
596
|
+
assertSuccessfulSyncProcess(
|
|
597
|
+
spawnJavaScriptSync(
|
|
598
|
+
[
|
|
599
|
+
sentryCliPath,
|
|
600
|
+
'releases',
|
|
601
|
+
'files',
|
|
602
|
+
version,
|
|
603
|
+
'upload-sourcemaps',
|
|
604
|
+
'--strip-prefix',
|
|
605
|
+
path.join(process.cwd(), outputFolder),
|
|
606
|
+
path.join(outputFolder, bundleName),
|
|
607
|
+
path.join(outputFolder, `${bundleName}.map`),
|
|
608
|
+
],
|
|
609
|
+
{
|
|
610
|
+
stdio: 'inherit',
|
|
611
|
+
},
|
|
612
|
+
),
|
|
613
|
+
sentryCliPath,
|
|
573
614
|
);
|
|
574
615
|
}
|
package/src/install.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from 'child_process';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import type { CommandContext } from './types';
|
|
4
|
+
import { getInstallCommand } from './utils/runtime';
|
|
4
5
|
|
|
5
6
|
export const installCommands = {
|
|
6
7
|
install: async ({ args }: CommandContext) => {
|
|
@@ -9,8 +10,9 @@ export const installCommands = {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const cliDir = path.resolve(__dirname, '..');
|
|
13
|
+
const installCommand = getInstallCommand(args, cliDir);
|
|
12
14
|
|
|
13
|
-
spawnSync(
|
|
15
|
+
spawnSync(installCommand.command, installCommand.args, {
|
|
14
16
|
cwd: cliDir,
|
|
15
17
|
stdio: 'inherit',
|
|
16
18
|
shell: true,
|
package/src/locales/en.ts
CHANGED
|
@@ -156,6 +156,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
156
156
|
usageUploadIpa: 'Usage: cresc uploadIpa <ipa file>',
|
|
157
157
|
versionBind:
|
|
158
158
|
'Bound hot update {{version}} to native version {{nativeVersion}} (id: {{id}})',
|
|
159
|
+
versionIdRequired: 'Please provide versionId in non-interactive mode.',
|
|
159
160
|
welcomeMessage: 'Welcome to Cresc hot update service, {{name}}.',
|
|
160
161
|
versionNameQuestion: 'Enter OTA update name:',
|
|
161
162
|
versionDescriptionQuestion: 'Enter OTA update description:',
|
package/src/locales/zh.ts
CHANGED
|
@@ -145,6 +145,7 @@ export default {
|
|
|
145
145
|
usageUploadIpa: '使用方法: pushy uploadIpa ipa后缀文件',
|
|
146
146
|
versionBind:
|
|
147
147
|
'已将热更包 {{version}} 绑定到原生版本 {{nativeVersion}} (id: {{id}})',
|
|
148
|
+
versionIdRequired: '非交互模式下请提供 versionId。',
|
|
148
149
|
welcomeMessage: '欢迎使用 pushy 热更新服务,{{name}}。',
|
|
149
150
|
versionNameQuestion: '输入版本名称:',
|
|
150
151
|
versionDescriptionQuestion: '输入版本描述:',
|
package/src/package.ts
CHANGED
|
@@ -18,6 +18,9 @@ import { getCommitInfo } from './utils/git';
|
|
|
18
18
|
import { t } from './utils/i18n';
|
|
19
19
|
|
|
20
20
|
type PackageCommandOptions = Record<string, unknown> & {
|
|
21
|
+
appId?: string;
|
|
22
|
+
appKey?: string;
|
|
23
|
+
platform?: Platform;
|
|
21
24
|
version?: string;
|
|
22
25
|
includeAllSplits?: boolean | string;
|
|
23
26
|
splits?: string;
|
|
@@ -96,13 +99,19 @@ async function uploadNativePackage(
|
|
|
96
99
|
const info = await config.getInfo(filePath);
|
|
97
100
|
const { versionName: extractedVersionName, buildTime } = info;
|
|
98
101
|
const { appId: appIdInPkg, appKey: appKeyInPkg } = info;
|
|
99
|
-
const
|
|
102
|
+
const selectedApp = options.appId
|
|
103
|
+
? {
|
|
104
|
+
appId: String(options.appId),
|
|
105
|
+
appKey: typeof options.appKey === 'string' ? options.appKey : undefined,
|
|
106
|
+
}
|
|
107
|
+
: await getSelectedApp(config.platform);
|
|
108
|
+
const { appId, appKey } = selectedApp;
|
|
100
109
|
|
|
101
110
|
if (appIdInPkg && String(appIdInPkg) !== appId) {
|
|
102
111
|
throw new Error(t(config.appIdMismatchKey, { appIdInPkg, appId }));
|
|
103
112
|
}
|
|
104
113
|
|
|
105
|
-
if (appKeyInPkg && appKeyInPkg !== appKey) {
|
|
114
|
+
if (appKeyInPkg && appKey && appKeyInPkg !== appKey) {
|
|
106
115
|
throw new Error(t(config.appKeyMismatchKey, { appKeyInPkg, appKey }));
|
|
107
116
|
}
|
|
108
117
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
{
|
|
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.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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.
|
|
203
|
-
|
|
204
|
-
|
|
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:
|
|
217
|
+
updates: UpdateVersionOptions,
|
|
218
218
|
): Promise<CommandResult> {
|
|
219
219
|
return this.runMessageCommand(
|
|
220
220
|
async () => {
|
|
221
|
-
const context = this.createContext({
|
|
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:
|
|
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
|
|
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
|
|
46
|
-
|
|
47
|
-
|
|
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/http-helper.ts
CHANGED
|
@@ -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
|
-
|
|
28
|
+
runtimeFetch(url, {
|
|
29
29
|
method: 'HEAD',
|
|
30
30
|
})
|
|
31
31
|
.then(({ status }) => {
|
package/src/utils/index.ts
CHANGED
|
@@ -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 (
|
|
94
|
+
if (isNonInteractive()) {
|
|
88
95
|
return '';
|
|
89
96
|
}
|
|
90
97
|
return read({
|