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/README.md
CHANGED
|
@@ -46,6 +46,8 @@ if (!bundleResult.success) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const publishResult = await provider.publish({
|
|
49
|
+
filePath: '.pushy/output/ios.ppk',
|
|
50
|
+
platform: 'ios',
|
|
49
51
|
name: 'v1.2.3',
|
|
50
52
|
description: 'Bug fixes and improvements',
|
|
51
53
|
rollout: 100,
|
|
@@ -125,6 +127,8 @@ interface CLIProvider {
|
|
|
125
127
|
|
|
126
128
|
## Environment Variables
|
|
127
129
|
|
|
130
|
+
`publish` requires a generated `.ppk` path via `filePath`. Provider list methods return data in `CommandResult.data` and do not enter interactive paging.
|
|
131
|
+
|
|
128
132
|
```bash
|
|
129
133
|
export PUSHY_REGISTRY=https://your-api-endpoint.com
|
|
130
134
|
export NO_INTERACTIVE=true
|
package/README.zh-CN.md
CHANGED
|
@@ -46,6 +46,8 @@ if (!bundleResult.success) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const publishResult = await provider.publish({
|
|
49
|
+
filePath: '.pushy/output/ios.ppk',
|
|
50
|
+
platform: 'ios',
|
|
49
51
|
name: 'v1.2.3',
|
|
50
52
|
description: 'Bug fixes and improvements',
|
|
51
53
|
rollout: 100,
|
|
@@ -125,6 +127,8 @@ interface CLIProvider {
|
|
|
125
127
|
|
|
126
128
|
## 环境变量
|
|
127
129
|
|
|
130
|
+
`publish` 需要通过 `filePath` 传入已生成的 `.ppk` 文件路径。Provider 的列表方法会把数据放在 `CommandResult.data`,不会进入交互式翻页。
|
|
131
|
+
|
|
128
132
|
```bash
|
|
129
133
|
export PUSHY_REGISTRY=https://your-api-endpoint.com
|
|
130
134
|
export NO_INTERACTIVE=true
|
package/cli.json
CHANGED
|
@@ -182,6 +182,9 @@
|
|
|
182
182
|
"platform": {
|
|
183
183
|
"hasValue": true
|
|
184
184
|
},
|
|
185
|
+
"appId": {
|
|
186
|
+
"hasValue": true
|
|
187
|
+
},
|
|
185
188
|
"versionId": {
|
|
186
189
|
"hasValue": true
|
|
187
190
|
},
|
|
@@ -342,6 +345,9 @@
|
|
|
342
345
|
"globalOptions": {
|
|
343
346
|
"no-interactive": {
|
|
344
347
|
"default": false
|
|
348
|
+
},
|
|
349
|
+
"acc": {
|
|
350
|
+
"default": false
|
|
345
351
|
}
|
|
346
352
|
}
|
|
347
353
|
}
|
package/lib/api.js
CHANGED
|
@@ -55,18 +55,16 @@ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
|
55
55
|
const _nodefetch = /*#__PURE__*/ _interop_require_default(require("node-fetch"));
|
|
56
56
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
57
57
|
const _progress = /*#__PURE__*/ _interop_require_default(require("progress"));
|
|
58
|
-
const _tcpping = /*#__PURE__*/ _interop_require_default(require("tcp-ping"));
|
|
59
|
-
const _util = /*#__PURE__*/ _interop_require_default(require("util"));
|
|
60
58
|
const _httphelper = require("./utils/http-helper");
|
|
61
59
|
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
|
|
62
60
|
const _constants = require("./utils/constants");
|
|
63
61
|
const _i18n = require("./utils/i18n");
|
|
62
|
+
const _runtime = require("./utils/runtime");
|
|
64
63
|
function _interop_require_default(obj) {
|
|
65
64
|
return obj && obj.__esModule ? obj : {
|
|
66
65
|
default: obj
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
|
-
const tcpPing = _util.default.promisify(_tcpping.default.ping);
|
|
70
68
|
let session;
|
|
71
69
|
let savedSession;
|
|
72
70
|
let apiToken;
|
|
@@ -114,16 +112,18 @@ const closeSession = ()=>{
|
|
|
114
112
|
}
|
|
115
113
|
session = undefined;
|
|
116
114
|
};
|
|
117
|
-
function createRequestError(error, requestUrl) {
|
|
115
|
+
function createRequestError(error, requestUrl, status) {
|
|
118
116
|
const message = typeof error === 'string' ? error : error instanceof Error ? error.message : String(error);
|
|
119
|
-
|
|
117
|
+
const requestError = new Error(`${message}\nURL: ${requestUrl}`);
|
|
118
|
+
requestError.status = status;
|
|
119
|
+
return requestError;
|
|
120
120
|
}
|
|
121
121
|
async function query(url, options) {
|
|
122
122
|
const baseUrl = await _httphelper.getBaseUrl;
|
|
123
123
|
const fullUrl = `${baseUrl}${url}`;
|
|
124
124
|
let resp;
|
|
125
125
|
try {
|
|
126
|
-
resp = await (0,
|
|
126
|
+
resp = await (0, _runtime.runtimeFetch)(fullUrl, options);
|
|
127
127
|
} catch (error) {
|
|
128
128
|
throw createRequestError(error, fullUrl);
|
|
129
129
|
}
|
|
@@ -139,9 +139,9 @@ async function query(url, options) {
|
|
|
139
139
|
if (resp.status !== 200) {
|
|
140
140
|
const message = (json == null ? void 0 : json.message) || resp.statusText || `HTTP ${resp.status}`;
|
|
141
141
|
if (resp.status === 401) {
|
|
142
|
-
throw createRequestError((0, _i18n.t)('loginExpired'), fullUrl);
|
|
142
|
+
throw createRequestError((0, _i18n.t)('loginExpired'), fullUrl, resp.status);
|
|
143
143
|
}
|
|
144
|
-
throw createRequestError(message, fullUrl);
|
|
144
|
+
throw createRequestError(message, fullUrl, resp.status);
|
|
145
145
|
}
|
|
146
146
|
return json;
|
|
147
147
|
}
|
|
@@ -192,13 +192,11 @@ async function uploadFile(fn, key) {
|
|
|
192
192
|
if (global.USE_ACC_OSS) {
|
|
193
193
|
realUrl = backupUrl;
|
|
194
194
|
} else {
|
|
195
|
-
const
|
|
196
|
-
address: url.replace('https://', ''),
|
|
195
|
+
const latency = await (0, _runtime.measureTcpLatency)(url, {
|
|
197
196
|
attempts: 4,
|
|
198
197
|
timeout: 1000
|
|
199
198
|
});
|
|
200
|
-
|
|
201
|
-
if (Number.isNaN(pingResult.avg) || pingResult.avg > 150) {
|
|
199
|
+
if (!Number.isFinite(latency) || latency > 150) {
|
|
202
200
|
realUrl = backupUrl;
|
|
203
201
|
}
|
|
204
202
|
}
|
package/lib/app.d.ts
CHANGED
package/lib/app.js
CHANGED
package/lib/bin.js
CHANGED
|
@@ -13,6 +13,9 @@ const _user = require("./user");
|
|
|
13
13
|
const _utils = require("./utils");
|
|
14
14
|
const _i18n = require("./utils/i18n");
|
|
15
15
|
const _versions = require("./versions");
|
|
16
|
+
function isTruthyEnv(value) {
|
|
17
|
+
return value === '1' || (value == null ? void 0 : value.toLowerCase()) === 'true';
|
|
18
|
+
}
|
|
16
19
|
function printUsage(exitCode = 1) {
|
|
17
20
|
console.log('React Native Update CLI');
|
|
18
21
|
console.log('');
|
|
@@ -44,8 +47,8 @@ async function run() {
|
|
|
44
47
|
process.exit();
|
|
45
48
|
}
|
|
46
49
|
const argv = require('cli-arguments').parse(require('../cli.json'));
|
|
47
|
-
global.NO_INTERACTIVE = argv.options['no-interactive'];
|
|
48
|
-
global.USE_ACC_OSS = argv.options.acc;
|
|
50
|
+
global.NO_INTERACTIVE = Boolean(argv.options['no-interactive']) || isTruthyEnv(process.env.NO_INTERACTIVE);
|
|
51
|
+
global.USE_ACC_OSS = Boolean(argv.options.acc) || isTruthyEnv(process.env.USE_ACC_OSS);
|
|
49
52
|
try {
|
|
50
53
|
await (0, _api.loadSession)();
|
|
51
54
|
if (argv.command === 'help') {
|
package/lib/bundle-runner.js
CHANGED
|
@@ -34,6 +34,7 @@ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
|
34
34
|
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
35
35
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
36
36
|
const _i18n = require("./utils/i18n");
|
|
37
|
+
const _runtime = require("./utils/runtime");
|
|
37
38
|
function _interop_require_default(obj) {
|
|
38
39
|
return obj && obj.__esModule ? obj : {
|
|
39
40
|
default: obj
|
|
@@ -242,8 +243,9 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
242
243
|
if (config) {
|
|
243
244
|
reactNativeBundleArgs.push('--config', config);
|
|
244
245
|
}
|
|
245
|
-
const
|
|
246
|
-
|
|
246
|
+
const jsRuntime = (0, _runtime.getJavaScriptRuntime)();
|
|
247
|
+
const reactNativeBundleProcess = (0, _runtime.spawnJavaScript)(reactNativeBundleArgs);
|
|
248
|
+
console.log(`Running bundle command: ${jsRuntime} ${reactNativeBundleArgs.join(' ')}`);
|
|
247
249
|
await new Promise((resolve, reject)=>{
|
|
248
250
|
reactNativeBundleProcess.stdout.on('data', (data)=>{
|
|
249
251
|
console.log(data.toString().trim());
|
|
@@ -314,6 +316,14 @@ function dirnameOfPackage(packageJsonPath, projectRoot = process.cwd()) {
|
|
|
314
316
|
]
|
|
315
317
|
}));
|
|
316
318
|
}
|
|
319
|
+
function assertSuccessfulSyncProcess(result, command) {
|
|
320
|
+
if (result.error) {
|
|
321
|
+
throw result.error;
|
|
322
|
+
}
|
|
323
|
+
if (result.status !== 0) {
|
|
324
|
+
throw new Error(`${command} failed with ${result.status === null ? `signal ${result.signal}` : `exit code ${result.status}`}`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
317
327
|
function resolveHermesCommand(projectRoot = process.cwd()) {
|
|
318
328
|
const osBin = getHermesOSBin();
|
|
319
329
|
if (!osBin) {
|
|
@@ -387,16 +397,16 @@ async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput,
|
|
|
387
397
|
command: hermesCommand,
|
|
388
398
|
args: args.join(' ')
|
|
389
399
|
}));
|
|
390
|
-
(0, _child_process.spawnSync)(hermesCommand, args, {
|
|
400
|
+
assertSuccessfulSyncProcess((0, _child_process.spawnSync)(hermesCommand, args, {
|
|
391
401
|
stdio: 'ignore'
|
|
392
|
-
});
|
|
402
|
+
}), hermesCommand);
|
|
393
403
|
if (sourcemapOutput) {
|
|
394
404
|
const composerPath = 'node_modules/react-native/scripts/compose-source-maps.js';
|
|
395
405
|
if (!_fsextra.existsSync(composerPath)) {
|
|
396
406
|
return;
|
|
397
407
|
}
|
|
398
408
|
console.log((0, _i18n.t)('composingSourceMap'));
|
|
399
|
-
(0,
|
|
409
|
+
assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
|
|
400
410
|
composerPath,
|
|
401
411
|
_path.default.join(outputFolder, `${bundleName}.txt.map`),
|
|
402
412
|
_path.default.join(outputFolder, `${bundleName}.map`),
|
|
@@ -404,7 +414,7 @@ async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput,
|
|
|
404
414
|
sourcemapOutput
|
|
405
415
|
], {
|
|
406
416
|
stdio: 'ignore'
|
|
407
|
-
});
|
|
417
|
+
}), composerPath);
|
|
408
418
|
}
|
|
409
419
|
if (shouldCleanSourcemap) {
|
|
410
420
|
_fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
|
|
@@ -427,13 +437,13 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
|
|
|
427
437
|
return;
|
|
428
438
|
}
|
|
429
439
|
console.log((0, _i18n.t)('copyingDebugId'));
|
|
430
|
-
(0,
|
|
440
|
+
assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
|
|
431
441
|
copyDebugidPath,
|
|
432
442
|
_path.default.join(outputFolder, `${bundleName}.txt.map`),
|
|
433
443
|
_path.default.join(outputFolder, `${bundleName}.map`)
|
|
434
444
|
], {
|
|
435
445
|
stdio: 'ignore'
|
|
436
|
-
});
|
|
446
|
+
}), copyDebugidPath);
|
|
437
447
|
}
|
|
438
448
|
_fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
|
|
439
449
|
}
|
|
@@ -455,7 +465,7 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
455
465
|
if (!_fsextra.existsSync(sentryCliPath)) {
|
|
456
466
|
return;
|
|
457
467
|
}
|
|
458
|
-
(0,
|
|
468
|
+
assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
|
|
459
469
|
sentryCliPath,
|
|
460
470
|
'releases',
|
|
461
471
|
'set-commits',
|
|
@@ -463,12 +473,12 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
463
473
|
'--auto'
|
|
464
474
|
], {
|
|
465
475
|
stdio: 'inherit'
|
|
466
|
-
});
|
|
476
|
+
}), sentryCliPath);
|
|
467
477
|
console.log((0, _i18n.t)('sentryReleaseCreated', {
|
|
468
478
|
version
|
|
469
479
|
}));
|
|
470
480
|
console.log((0, _i18n.t)('uploadingSourcemap'));
|
|
471
|
-
(0,
|
|
481
|
+
assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
|
|
472
482
|
sentryCliPath,
|
|
473
483
|
'releases',
|
|
474
484
|
'files',
|
|
@@ -480,5 +490,5 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
480
490
|
_path.default.join(outputFolder, `${bundleName}.map`)
|
|
481
491
|
], {
|
|
482
492
|
stdio: 'inherit'
|
|
483
|
-
});
|
|
493
|
+
}), sentryCliPath);
|
|
484
494
|
}
|
package/lib/install.js
CHANGED
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "installCommands", {
|
|
|
10
10
|
});
|
|
11
11
|
const _child_process = require("child_process");
|
|
12
12
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
const _runtime = require("./utils/runtime");
|
|
13
14
|
function _interop_require_default(obj) {
|
|
14
15
|
return obj && obj.__esModule ? obj : {
|
|
15
16
|
default: obj
|
|
@@ -21,10 +22,8 @@ const installCommands = {
|
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
const cliDir = _path.default.resolve(__dirname, '..');
|
|
24
|
-
(0,
|
|
25
|
-
|
|
26
|
-
...args
|
|
27
|
-
], {
|
|
25
|
+
const installCommand = (0, _runtime.getInstallCommand)(args, cliDir);
|
|
26
|
+
(0, _child_process.spawnSync)(installCommand.command, installCommand.args, {
|
|
28
27
|
cwd: cliDir,
|
|
29
28
|
stdio: 'inherit',
|
|
30
29
|
shell: true
|
package/lib/locales/en.d.ts
CHANGED
package/lib/locales/en.js
CHANGED
|
@@ -131,6 +131,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
131
131
|
usageUploadApp: 'Usage: cresc uploadApp <app file>',
|
|
132
132
|
usageUploadIpa: 'Usage: cresc uploadIpa <ipa file>',
|
|
133
133
|
versionBind: 'Bound hot update {{version}} to native version {{nativeVersion}} (id: {{id}})',
|
|
134
|
+
versionIdRequired: 'Please provide versionId in non-interactive mode.',
|
|
134
135
|
welcomeMessage: 'Welcome to Cresc hot update service, {{name}}.',
|
|
135
136
|
versionNameQuestion: 'Enter OTA update name:',
|
|
136
137
|
versionDescriptionQuestion: 'Enter OTA update description:',
|
package/lib/locales/zh.d.ts
CHANGED
package/lib/locales/zh.js
CHANGED
|
@@ -130,6 +130,7 @@ const _default = {
|
|
|
130
130
|
usageUploadApp: '使用方法: pushy uploadApp app后缀文件',
|
|
131
131
|
usageUploadIpa: '使用方法: pushy uploadIpa ipa后缀文件',
|
|
132
132
|
versionBind: '已将热更包 {{version}} 绑定到原生版本 {{nativeVersion}} (id: {{id}})',
|
|
133
|
+
versionIdRequired: '非交互模式下请提供 versionId。',
|
|
133
134
|
welcomeMessage: '欢迎使用 pushy 热更新服务,{{name}}。',
|
|
134
135
|
versionNameQuestion: '输入版本名称:',
|
|
135
136
|
versionDescriptionQuestion: '输入版本描述:',
|
package/lib/package.d.ts
CHANGED
package/lib/package.js
CHANGED
|
@@ -112,14 +112,18 @@ async function uploadNativePackage(filePath, options, config) {
|
|
|
112
112
|
const info = await config.getInfo(filePath);
|
|
113
113
|
const { versionName: extractedVersionName, buildTime } = info;
|
|
114
114
|
const { appId: appIdInPkg, appKey: appKeyInPkg } = info;
|
|
115
|
-
const
|
|
115
|
+
const selectedApp = options.appId ? {
|
|
116
|
+
appId: String(options.appId),
|
|
117
|
+
appKey: typeof options.appKey === 'string' ? options.appKey : undefined
|
|
118
|
+
} : await (0, _app.getSelectedApp)(config.platform);
|
|
119
|
+
const { appId, appKey } = selectedApp;
|
|
116
120
|
if (appIdInPkg && String(appIdInPkg) !== appId) {
|
|
117
121
|
throw new Error((0, _i18n.t)(config.appIdMismatchKey, {
|
|
118
122
|
appIdInPkg,
|
|
119
123
|
appId
|
|
120
124
|
}));
|
|
121
125
|
}
|
|
122
|
-
if (appKeyInPkg && appKeyInPkg !== appKey) {
|
|
126
|
+
if (appKeyInPkg && appKey && appKeyInPkg !== appKey) {
|
|
123
127
|
throw new Error((0, _i18n.t)(config.appKeyMismatchKey, {
|
|
124
128
|
appKeyInPkg,
|
|
125
129
|
appKey
|
package/lib/provider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BundleOptions, CLIProvider, CommandResult, Platform, PublishOptions, Session,
|
|
1
|
+
import type { BundleOptions, CLIProvider, CommandResult, Platform, PublishOptions, Session, UpdateVersionOptions, UploadOptions } from './types';
|
|
2
2
|
export declare class CLIProviderImpl implements CLIProvider {
|
|
3
3
|
private session?;
|
|
4
4
|
private sessionInitPromise?;
|
|
@@ -16,7 +16,7 @@ export declare class CLIProviderImpl implements CLIProvider {
|
|
|
16
16
|
listApps(platform?: Platform): Promise<CommandResult>;
|
|
17
17
|
createApp(name: string, platform: Platform): Promise<CommandResult>;
|
|
18
18
|
listVersions(appId: string): Promise<CommandResult>;
|
|
19
|
-
updateVersion(appId: string, versionId: string, updates:
|
|
19
|
+
updateVersion(appId: string, versionId: string, updates: UpdateVersionOptions): Promise<CommandResult>;
|
|
20
20
|
getPlatform(platform?: Platform): Promise<Platform>;
|
|
21
21
|
loadSession(): Promise<Session>;
|
|
22
22
|
listPackages(appId?: string): Promise<CommandResult>;
|
package/lib/provider.js
CHANGED
|
@@ -100,6 +100,7 @@ class CLIProviderImpl {
|
|
|
100
100
|
bundleName: options.bundleName || 'index.bundlejs',
|
|
101
101
|
entryFile: options.entryFile || 'index.js',
|
|
102
102
|
output: options.output || DEFAULT_BUNDLE_OUTPUT,
|
|
103
|
+
'no-interactive': true,
|
|
103
104
|
sourcemap: options.sourcemap || false,
|
|
104
105
|
taro: options.taro || false,
|
|
105
106
|
expo: options.expo || false,
|
|
@@ -121,9 +122,13 @@ class CLIProviderImpl {
|
|
|
121
122
|
minPackageVersion: options.minPackageVersion,
|
|
122
123
|
maxPackageVersion: options.maxPackageVersion,
|
|
123
124
|
packageVersionRange: options.packageVersionRange,
|
|
124
|
-
|
|
125
|
+
platform: options.platform,
|
|
126
|
+
'no-interactive': true,
|
|
127
|
+
rollout: options.rollout === undefined ? undefined : String(options.rollout),
|
|
125
128
|
dryRun: options.dryRun || false
|
|
126
|
-
}
|
|
129
|
+
}, options.filePath ? [
|
|
130
|
+
options.filePath
|
|
131
|
+
] : []);
|
|
127
132
|
const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
|
|
128
133
|
await versionCommands.publish(context);
|
|
129
134
|
}, 'Unknown error during publishing', 'Version published successfully');
|
|
@@ -131,13 +136,12 @@ class CLIProviderImpl {
|
|
|
131
136
|
async upload(options) {
|
|
132
137
|
return this.runMessageCommand(async ()=>{
|
|
133
138
|
var _filePath_split_pop;
|
|
134
|
-
const platform = await this.getPlatform(options.platform);
|
|
135
|
-
const { appId } = await this.getSelectedApp(platform);
|
|
136
139
|
const filePath = options.filePath;
|
|
137
140
|
const fileType = (_filePath_split_pop = filePath.split('.').pop()) == null ? void 0 : _filePath_split_pop.toLowerCase();
|
|
138
141
|
const context = this.createContext({
|
|
139
|
-
platform,
|
|
140
|
-
appId,
|
|
142
|
+
platform: options.platform,
|
|
143
|
+
appId: options.appId,
|
|
144
|
+
appKey: options.appKey,
|
|
141
145
|
version: options.version
|
|
142
146
|
}, [
|
|
143
147
|
filePath
|
|
@@ -161,15 +165,14 @@ class CLIProviderImpl {
|
|
|
161
165
|
return (0, _app.getSelectedApp)(resolvedPlatform);
|
|
162
166
|
}
|
|
163
167
|
async listApps(platform) {
|
|
164
|
-
return this.
|
|
165
|
-
const resolvedPlatform = await this.getPlatform(platform);
|
|
168
|
+
return this.runDataCommand(async ()=>{
|
|
166
169
|
const { getAppCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
|
|
167
|
-
|
|
170
|
+
return getAppCommands().apps({
|
|
168
171
|
options: {
|
|
169
|
-
platform:
|
|
172
|
+
platform: platform != null ? platform : ''
|
|
170
173
|
}
|
|
171
174
|
});
|
|
172
|
-
}, 'Unknown error listing apps'
|
|
175
|
+
}, 'Unknown error listing apps');
|
|
173
176
|
}
|
|
174
177
|
async createApp(name, platform) {
|
|
175
178
|
return this.runMessageCommand(async ()=>{
|
|
@@ -184,22 +187,20 @@ class CLIProviderImpl {
|
|
|
184
187
|
}, 'Unknown error creating app', 'App created successfully');
|
|
185
188
|
}
|
|
186
189
|
async listVersions(appId) {
|
|
187
|
-
return this.
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
|
|
192
|
-
await versionCommands.versions(context);
|
|
193
|
-
}, 'Unknown error listing versions', 'Versions listed successfully');
|
|
190
|
+
return this.runDataCommand(async ()=>{
|
|
191
|
+
const { fetchVersions } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
|
|
192
|
+
return fetchVersions(appId);
|
|
193
|
+
}, 'Unknown error listing versions');
|
|
194
194
|
}
|
|
195
195
|
async updateVersion(appId, versionId, updates) {
|
|
196
196
|
return this.runMessageCommand(async ()=>{
|
|
197
197
|
const context = this.createContext({
|
|
198
198
|
appId,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
versionId,
|
|
200
|
+
...updates,
|
|
201
|
+
'no-interactive': true,
|
|
202
|
+
rollout: updates.rollout === undefined ? undefined : String(updates.rollout)
|
|
203
|
+
});
|
|
203
204
|
const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
|
|
204
205
|
await versionCommands.update(context);
|
|
205
206
|
}, 'Unknown error updating version', 'Version updated successfully');
|
package/lib/types.d.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
|
export interface Session {
|
|
6
6
|
token: string;
|
|
@@ -49,6 +49,8 @@ export interface BundleOptions {
|
|
|
49
49
|
hermes?: boolean;
|
|
50
50
|
}
|
|
51
51
|
export interface PublishOptions {
|
|
52
|
+
filePath?: string;
|
|
53
|
+
platform?: Platform;
|
|
52
54
|
name?: string;
|
|
53
55
|
description?: string;
|
|
54
56
|
metaInfo?: string;
|
|
@@ -57,15 +59,26 @@ export interface PublishOptions {
|
|
|
57
59
|
minPackageVersion?: string;
|
|
58
60
|
maxPackageVersion?: string;
|
|
59
61
|
packageVersionRange?: string;
|
|
60
|
-
rollout?: number;
|
|
62
|
+
rollout?: number | string;
|
|
61
63
|
dryRun?: boolean;
|
|
62
64
|
}
|
|
63
65
|
export interface UploadOptions {
|
|
64
66
|
platform?: Platform;
|
|
65
67
|
filePath: string;
|
|
66
68
|
appId?: string;
|
|
69
|
+
appKey?: string;
|
|
67
70
|
version?: string;
|
|
68
71
|
}
|
|
72
|
+
export interface UpdateVersionOptions {
|
|
73
|
+
platform?: Platform;
|
|
74
|
+
packageId?: string;
|
|
75
|
+
packageVersion?: string;
|
|
76
|
+
minPackageVersion?: string;
|
|
77
|
+
maxPackageVersion?: string;
|
|
78
|
+
packageVersionRange?: string;
|
|
79
|
+
rollout?: number | string;
|
|
80
|
+
dryRun?: boolean;
|
|
81
|
+
}
|
|
69
82
|
export interface CLIProvider {
|
|
70
83
|
bundle: (options: BundleOptions) => Promise<CommandResult>;
|
|
71
84
|
publish: (options: PublishOptions) => Promise<CommandResult>;
|
|
@@ -77,7 +90,7 @@ export interface CLIProvider {
|
|
|
77
90
|
platform: Platform;
|
|
78
91
|
}>;
|
|
79
92
|
listVersions: (appId: string) => Promise<CommandResult>;
|
|
80
|
-
updateVersion: (appId: string, versionId: string, updates:
|
|
93
|
+
updateVersion: (appId: string, versionId: string, updates: UpdateVersionOptions) => Promise<CommandResult>;
|
|
81
94
|
getPlatform: (platform?: Platform) => Promise<Platform>;
|
|
82
95
|
loadSession: () => Promise<Session>;
|
|
83
96
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export declare class Zip {
|
|
2
2
|
file: string | File;
|
|
3
|
-
unzip: any;
|
|
4
3
|
constructor(file: string | File);
|
|
5
4
|
/**
|
|
6
5
|
* get entries by regexps, the return format is: { <filename>: <Buffer|Blob> }
|
|
7
6
|
* @param {Array} regexps // regexps for matching files
|
|
8
7
|
* @param {String} type // return type, can be buffer or blob, default buffer
|
|
9
8
|
*/
|
|
10
|
-
getEntries(regexps: Array<RegExp | string>, type?: 'buffer' | 'blob'): Promise<Record<string, Buffer<ArrayBufferLike
|
|
9
|
+
getEntries(regexps: Array<RegExp | string>, type?: 'buffer' | 'blob'): Promise<Record<string, Blob | Buffer<ArrayBufferLike>>>;
|
|
11
10
|
/**
|
|
12
11
|
* get entry by regex, return an instance of Buffer or Blob
|
|
13
12
|
* @param {Regex} regex // regex for matching file
|
|
14
13
|
* @param {String} type // return type, can be buffer or blob, default buffer
|
|
15
14
|
*/
|
|
16
|
-
getEntry(regex: RegExp | string, type?: 'buffer' | 'blob'): Promise<
|
|
15
|
+
getEntry(regex: RegExp | string, type?: 'buffer' | 'blob'): Promise<Blob | Buffer<ArrayBufferLike>>;
|
|
17
16
|
getEntryFromHarmonyApp(regex: RegExp): Promise<Buffer | Blob | undefined>;
|
|
17
|
+
private readEntries;
|
|
18
18
|
}
|
|
@@ -9,14 +9,13 @@ Object.defineProperty(exports, "Zip", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
-
const _utils = require("./utils");
|
|
13
12
|
const _zipentries = require("../zip-entries");
|
|
13
|
+
const _utils = require("./utils");
|
|
14
14
|
function _interop_require_default(obj) {
|
|
15
15
|
return obj && obj.__esModule ? obj : {
|
|
16
16
|
default: obj
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
const Unzip = require('isomorphic-unzip');
|
|
20
19
|
class Zip {
|
|
21
20
|
/**
|
|
22
21
|
* get entries by regexps, the return format is: { <filename>: <Buffer|Blob> }
|
|
@@ -24,13 +23,7 @@ class Zip {
|
|
|
24
23
|
* @param {String} type // return type, can be buffer or blob, default buffer
|
|
25
24
|
*/ getEntries(regexps, type = 'buffer') {
|
|
26
25
|
const decoded = regexps.map((regex)=>(0, _utils.decodeNullUnicode)(regex));
|
|
27
|
-
return
|
|
28
|
-
this.unzip.getBuffer(decoded, {
|
|
29
|
-
type
|
|
30
|
-
}, (err, buffers)=>{
|
|
31
|
-
err ? reject(err) : resolve(buffers);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
26
|
+
return this.readEntries(decoded, type);
|
|
34
27
|
}
|
|
35
28
|
/**
|
|
36
29
|
* get entry by regex, return an instance of Buffer or Blob
|
|
@@ -38,15 +31,9 @@ class Zip {
|
|
|
38
31
|
* @param {String} type // return type, can be buffer or blob, default buffer
|
|
39
32
|
*/ getEntry(regex, type = 'buffer') {
|
|
40
33
|
const decoded = (0, _utils.decodeNullUnicode)(regex);
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
], {
|
|
45
|
-
type
|
|
46
|
-
}, (err, buffers)=>{
|
|
47
|
-
err ? reject(err) : resolve(buffers[decoded]);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
34
|
+
return this.readEntries([
|
|
35
|
+
decoded
|
|
36
|
+
], type).then((buffers)=>buffers[decoded]);
|
|
50
37
|
}
|
|
51
38
|
async getEntryFromHarmonyApp(regex) {
|
|
52
39
|
try {
|
|
@@ -64,8 +51,35 @@ class Zip {
|
|
|
64
51
|
console.error('Error in getEntryFromHarmonyApp:', error);
|
|
65
52
|
}
|
|
66
53
|
}
|
|
54
|
+
async readEntries(decoded, type) {
|
|
55
|
+
if (typeof this.file !== 'string') {
|
|
56
|
+
throw new Error('Param error: [file] must be file path in Node.');
|
|
57
|
+
}
|
|
58
|
+
const buffers = {};
|
|
59
|
+
await (0, _zipentries.enumZipEntries)(this.file, async (entry, zipFile)=>{
|
|
60
|
+
if (entry.fileName.endsWith('/')) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const entryName = (0, _utils.decodeNullUnicode)(entry.fileName).toString();
|
|
64
|
+
const lowerEntryName = entryName.toLowerCase();
|
|
65
|
+
const matched = decoded.find((pattern)=>{
|
|
66
|
+
if (typeof pattern === 'string') {
|
|
67
|
+
return pattern === entryName || pattern === lowerEntryName;
|
|
68
|
+
}
|
|
69
|
+
pattern.lastIndex = 0;
|
|
70
|
+
return pattern.test(lowerEntryName);
|
|
71
|
+
});
|
|
72
|
+
if (!matched) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const buffer = await (0, _zipentries.readEntry)(entry, zipFile);
|
|
76
|
+
buffers[matched] = type === 'blob' ? new Blob([
|
|
77
|
+
buffer
|
|
78
|
+
]) : buffer;
|
|
79
|
+
});
|
|
80
|
+
return buffers;
|
|
81
|
+
}
|
|
67
82
|
constructor(file){
|
|
68
83
|
this.file = typeof file === 'string' ? _path.default.resolve(file) : file;
|
|
69
|
-
this.unzip = new Unzip(this.file);
|
|
70
84
|
}
|
|
71
85
|
}
|