react-native-update-cli 2.10.2 → 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.
Files changed (79) 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 +2 -2
  6. package/lib/app.js +42 -45
  7. package/lib/bin.d.ts +2 -0
  8. package/lib/bin.js +73 -0
  9. package/lib/bundle-runner.d.ts +1 -0
  10. package/lib/bundle-runner.js +68 -22
  11. package/lib/exports.d.ts +2 -9
  12. package/lib/exports.js +0 -31
  13. package/lib/index.d.ts +1 -4
  14. package/lib/index.js +12 -80
  15. package/lib/install.js +3 -4
  16. package/lib/locales/en.d.ts +1 -0
  17. package/lib/locales/en.js +1 -0
  18. package/lib/locales/zh.d.ts +1 -0
  19. package/lib/locales/zh.js +1 -0
  20. package/lib/package.d.ts +3 -0
  21. package/lib/package.js +50 -6
  22. package/lib/provider.d.ts +2 -2
  23. package/lib/provider.js +26 -25
  24. package/lib/types.d.ts +17 -21
  25. package/lib/utils/app-info-parser/aab.js +45 -4
  26. package/lib/utils/app-info-parser/zip.d.ts +3 -3
  27. package/lib/utils/app-info-parser/zip.js +33 -19
  28. package/lib/utils/http-helper.js +2 -7
  29. package/lib/utils/index.d.ts +1 -1
  30. package/lib/utils/index.js +9 -14
  31. package/lib/utils/plugin-config.js +42 -6
  32. package/lib/utils/runtime.d.ts +28 -0
  33. package/lib/utils/runtime.js +185 -0
  34. package/lib/versions.d.ts +6 -3
  35. package/lib/versions.js +80 -25
  36. package/package.json +8 -15
  37. package/src/api.ts +23 -15
  38. package/src/app.ts +40 -40
  39. package/src/bin.ts +93 -0
  40. package/src/bundle-runner.ts +161 -62
  41. package/src/exports.ts +1 -10
  42. package/src/index.ts +1 -94
  43. package/src/install.ts +3 -1
  44. package/src/locales/en.ts +1 -0
  45. package/src/locales/zh.ts +1 -0
  46. package/src/package.ts +12 -5
  47. package/src/provider.ts +49 -40
  48. package/src/types.ts +18 -26
  49. package/src/utils/app-info-parser/aab.ts +1 -1
  50. package/src/utils/app-info-parser/zip.ts +41 -24
  51. package/src/utils/http-helper.ts +2 -2
  52. package/src/utils/index.ts +9 -13
  53. package/src/utils/plugin-config.ts +1 -1
  54. package/src/utils/runtime.ts +190 -0
  55. package/src/versions.ts +105 -34
  56. package/lib/module-manager.d.ts +0 -16
  57. package/lib/module-manager.js +0 -90
  58. package/lib/modules/app-module.d.ts +0 -2
  59. package/lib/modules/app-module.js +0 -15
  60. package/lib/modules/bundle-module.d.ts +0 -2
  61. package/lib/modules/bundle-module.js +0 -15
  62. package/lib/modules/index.d.ts +0 -6
  63. package/lib/modules/index.js +0 -42
  64. package/lib/modules/package-module.d.ts +0 -2
  65. package/lib/modules/package-module.js +0 -15
  66. package/lib/modules/user-module.d.ts +0 -2
  67. package/lib/modules/user-module.js +0 -15
  68. package/lib/modules/version-module.d.ts +0 -2
  69. package/lib/modules/version-module.js +0 -15
  70. package/lib/utils/latest-version/cli.d.ts +0 -1
  71. package/lib/utils/latest-version/cli.js +0 -308
  72. package/src/module-manager.ts +0 -105
  73. package/src/modules/app-module.ts +0 -7
  74. package/src/modules/bundle-module.ts +0 -7
  75. package/src/modules/index.ts +0 -19
  76. package/src/modules/package-module.ts +0 -7
  77. package/src/modules/user-module.ts +0 -7
  78. package/src/modules/version-module.ts +0 -7
  79. package/src/utils/latest-version/cli.ts +0 -445
package/lib/index.js CHANGED
@@ -1,86 +1,18 @@
1
- #!/usr/bin/env node
2
1
  "use strict";
3
2
  Object.defineProperty(exports, "__esModule", {
4
3
  value: true
5
4
  });
6
- function _export(target, all) {
7
- for(var name in all)Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: Object.getOwnPropertyDescriptor(all, name).get
10
- });
11
- }
12
- _export(exports, {
13
- get CLIProviderImpl () {
14
- return _provider.CLIProviderImpl;
15
- },
16
- get moduleManager () {
17
- return _modulemanager.moduleManager;
18
- }
19
- });
20
- const _api = require("./api");
21
- const _app = require("./app");
22
- const _bundle = require("./bundle");
23
- const _diff = require("./diff");
24
- const _install = require("./install");
25
- const _package = require("./package");
26
- const _user = require("./user");
27
- const _utils = require("./utils");
28
- const _i18n = require("./utils/i18n");
29
- const _versions = require("./versions");
30
- const _modulemanager = require("./module-manager");
31
- const _provider = require("./provider");
32
- function printUsage(exitCode = 1) {
33
- console.log('React Native Update CLI');
34
- console.log('');
35
- console.log('Commands:');
36
- for (const name of Object.keys(commandHandlers)){
37
- console.log(` ${name}`);
38
- }
39
- console.log('');
40
- console.log('Special commands:');
41
- console.log(' list: List all available commands');
42
- console.log(' help: Show this help message');
43
- console.log('');
44
- console.log('Visit `https://github.com/reactnativecn/react-native-update` for document.');
45
- process.exit(exitCode);
46
- }
47
- const commandHandlers = {
48
- ..._user.userCommands,
49
- ..._bundle.bundleCommands,
50
- ..._diff.diffCommands,
51
- ..._app.appCommands,
52
- ..._package.packageCommands,
53
- ..._versions.versionCommands,
54
- ..._install.installCommands,
55
- help: printUsage
56
- };
57
- async function run() {
58
- await (0, _utils.printVersionCommand)();
59
- if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
60
- process.exit();
61
- }
62
- const argv = require('cli-arguments').parse(require('../cli.json'));
63
- global.NO_INTERACTIVE = argv.options['no-interactive'];
64
- global.USE_ACC_OSS = argv.options.acc;
65
- try {
66
- await (0, _api.loadSession)();
67
- if (argv.command === 'help') {
68
- printUsage(0);
69
- } else if (argv.command === 'list') {
70
- printUsage(0);
71
- } else if (commandHandlers[argv.command]) {
72
- const handler = commandHandlers[argv.command];
73
- await handler(argv);
74
- } else {
75
- throw new Error(`Unknown command: ${argv.command}`);
76
- }
77
- } catch (err) {
78
- if (err.status === 401) {
79
- console.log((0, _i18n.t)('loginFirst'));
80
- return;
5
+ _export_star(require("./exports"), exports);
6
+ function _export_star(from, to) {
7
+ Object.keys(from).forEach(function(k) {
8
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
+ Object.defineProperty(to, k, {
10
+ enumerable: true,
11
+ get: function() {
12
+ return from[k];
13
+ }
14
+ });
81
15
  }
82
- console.error(err.stack);
83
- process.exit(-1);
84
- }
16
+ });
17
+ return from;
85
18
  }
86
- run();
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, _child_process.spawnSync)('npm', [
25
- 'install',
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
@@ -115,6 +115,7 @@ declare const _default: {
115
115
  usageUploadApp: string;
116
116
  usageUploadIpa: string;
117
117
  versionBind: string;
118
+ versionIdRequired: string;
118
119
  welcomeMessage: string;
119
120
  versionNameQuestion: string;
120
121
  versionDescriptionQuestion: string;
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:',
@@ -114,6 +114,7 @@ declare const _default: {
114
114
  usageUploadApp: string;
115
115
  usageUploadIpa: string;
116
116
  versionBind: string;
117
+ versionIdRequired: string;
117
118
  welcomeMessage: string;
118
119
  versionNameQuestion: string;
119
120
  versionDescriptionQuestion: string;
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
@@ -1,5 +1,8 @@
1
1
  import type { Platform } from './types';
2
2
  type PackageCommandOptions = Record<string, unknown> & {
3
+ appId?: string;
4
+ appKey?: string;
5
+ platform?: Platform;
3
6
  version?: string;
4
7
  includeAllSplits?: boolean | string;
5
8
  splits?: string;
package/lib/package.js CHANGED
@@ -22,7 +22,7 @@ _export(exports, {
22
22
  return packageCommands;
23
23
  }
24
24
  });
25
- const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
25
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
26
26
  const _os = /*#__PURE__*/ _interop_require_default(require("os"));
27
27
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
28
28
  const _ttytable = /*#__PURE__*/ _interop_require_default(require("tty-table"));
@@ -38,6 +38,47 @@ function _interop_require_default(obj) {
38
38
  default: obj
39
39
  };
40
40
  }
41
+ function _getRequireWildcardCache(nodeInterop) {
42
+ if (typeof WeakMap !== "function") return null;
43
+ var cacheBabelInterop = new WeakMap();
44
+ var cacheNodeInterop = new WeakMap();
45
+ return (_getRequireWildcardCache = function(nodeInterop) {
46
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
47
+ })(nodeInterop);
48
+ }
49
+ function _interop_require_wildcard(obj, nodeInterop) {
50
+ if (!nodeInterop && obj && obj.__esModule) {
51
+ return obj;
52
+ }
53
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
54
+ return {
55
+ default: obj
56
+ };
57
+ }
58
+ var cache = _getRequireWildcardCache(nodeInterop);
59
+ if (cache && cache.has(obj)) {
60
+ return cache.get(obj);
61
+ }
62
+ var newObj = {
63
+ __proto__: null
64
+ };
65
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
66
+ for(var key in obj){
67
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
68
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
69
+ if (desc && (desc.get || desc.set)) {
70
+ Object.defineProperty(newObj, key, desc);
71
+ } else {
72
+ newObj[key] = obj[key];
73
+ }
74
+ }
75
+ }
76
+ newObj.default = obj;
77
+ if (cache) {
78
+ cache.set(obj, newObj);
79
+ }
80
+ return newObj;
81
+ }
41
82
  function normalizeUploadBuildTime(value) {
42
83
  return String(value);
43
84
  }
@@ -71,14 +112,18 @@ async function uploadNativePackage(filePath, options, config) {
71
112
  const info = await config.getInfo(filePath);
72
113
  const { versionName: extractedVersionName, buildTime } = info;
73
114
  const { appId: appIdInPkg, appKey: appKeyInPkg } = info;
74
- const { appId, appKey } = await (0, _app.getSelectedApp)(config.platform);
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;
75
120
  if (appIdInPkg && String(appIdInPkg) !== appId) {
76
121
  throw new Error((0, _i18n.t)(config.appIdMismatchKey, {
77
122
  appIdInPkg,
78
123
  appId
79
124
  }));
80
125
  }
81
- if (appKeyInPkg && appKeyInPkg !== appKey) {
126
+ if (appKeyInPkg && appKey && appKeyInPkg !== appKey) {
82
127
  throw new Error((0, _i18n.t)(config.appKeyMismatchKey, {
83
128
  appKeyInPkg,
84
129
  appKey
@@ -101,7 +146,6 @@ async function uploadNativePackage(filePath, options, config) {
101
146
  deps: _depversions.depVersions,
102
147
  commit: await (0, _git.getCommitInfo)()
103
148
  });
104
- (0, _utils.saveToLocal)(filePath, `${appId}/package/${id}${config.extension}`);
105
149
  console.log((0, _i18n.t)(config.successKey, {
106
150
  id,
107
151
  version: versionName,
@@ -204,8 +248,8 @@ const packageCommands = {
204
248
  options
205
249
  });
206
250
  } finally{
207
- if (await _fsextra.default.pathExists(output)) {
208
- await _fsextra.default.remove(output);
251
+ if (await _fsextra.pathExists(output)) {
252
+ await _fsextra.remove(output);
209
253
  }
210
254
  }
211
255
  },
package/lib/provider.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BundleOptions, CLIProvider, CommandResult, Platform, PublishOptions, Session, UploadOptions, Version } from './types';
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: Partial<Version>): Promise<CommandResult>;
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
- rollout: options.rollout,
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,20 +165,19 @@ class CLIProviderImpl {
161
165
  return (0, _app.getSelectedApp)(resolvedPlatform);
162
166
  }
163
167
  async listApps(platform) {
164
- return this.runMessageCommand(async ()=>{
165
- const resolvedPlatform = await this.getPlatform(platform);
166
- const { appCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
167
- await appCommands.apps({
168
+ return this.runDataCommand(async ()=>{
169
+ const { getAppCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
170
+ return getAppCommands().apps({
168
171
  options: {
169
- platform: resolvedPlatform
172
+ platform: platform != null ? platform : ''
170
173
  }
171
174
  });
172
- }, 'Unknown error listing apps', 'Apps listed successfully');
175
+ }, 'Unknown error listing apps');
173
176
  }
174
177
  async createApp(name, platform) {
175
178
  return this.runMessageCommand(async ()=>{
176
- const { appCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
177
- await appCommands.createApp({
179
+ const { getAppCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
180
+ await getAppCommands().createApp({
178
181
  options: {
179
182
  name,
180
183
  platform,
@@ -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.runMessageCommand(async ()=>{
188
- const context = this.createContext({
189
- appId
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
- ...updates
200
- }, [
201
- versionId
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;
@@ -36,16 +36,6 @@ export interface CommandResult {
36
36
  data?: unknown;
37
37
  error?: string;
38
38
  }
39
- export interface CommandDefinition {
40
- name: string;
41
- description?: string;
42
- handler: (context: CommandContext) => Promise<CommandResult>;
43
- options?: Record<string, {
44
- hasValue?: boolean;
45
- default?: unknown;
46
- description?: string;
47
- }>;
48
- }
49
39
  export interface BundleOptions {
50
40
  dev?: boolean;
51
41
  platform?: Platform;
@@ -59,6 +49,8 @@ export interface BundleOptions {
59
49
  hermes?: boolean;
60
50
  }
61
51
  export interface PublishOptions {
52
+ filePath?: string;
53
+ platform?: Platform;
62
54
  name?: string;
63
55
  description?: string;
64
56
  metaInfo?: string;
@@ -67,15 +59,26 @@ export interface PublishOptions {
67
59
  minPackageVersion?: string;
68
60
  maxPackageVersion?: string;
69
61
  packageVersionRange?: string;
70
- rollout?: number;
62
+ rollout?: number | string;
71
63
  dryRun?: boolean;
72
64
  }
73
65
  export interface UploadOptions {
74
66
  platform?: Platform;
75
67
  filePath: string;
76
68
  appId?: string;
69
+ appKey?: string;
77
70
  version?: string;
78
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
+ }
79
82
  export interface CLIProvider {
80
83
  bundle: (options: BundleOptions) => Promise<CommandResult>;
81
84
  publish: (options: PublishOptions) => Promise<CommandResult>;
@@ -87,14 +90,7 @@ export interface CLIProvider {
87
90
  platform: Platform;
88
91
  }>;
89
92
  listVersions: (appId: string) => Promise<CommandResult>;
90
- updateVersion: (appId: string, versionId: string, updates: Partial<Version>) => Promise<CommandResult>;
93
+ updateVersion: (appId: string, versionId: string, updates: UpdateVersionOptions) => Promise<CommandResult>;
91
94
  getPlatform: (platform?: Platform) => Promise<Platform>;
92
95
  loadSession: () => Promise<Session>;
93
96
  }
94
- export interface CLIModule {
95
- name: string;
96
- version: string;
97
- commands?: CommandDefinition[];
98
- init?: (provider: CLIProvider) => void;
99
- cleanup?: () => void;
100
- }
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "AabParser", {
9
9
  }
10
10
  });
11
11
  const _child_process = require("child_process");
12
- const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
12
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
13
13
  const _os = /*#__PURE__*/ _interop_require_default(require("os"));
14
14
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
15
15
  const _yauzl = require("yauzl");
@@ -23,6 +23,47 @@ function _interop_require_default(obj) {
23
23
  default: obj
24
24
  };
25
25
  }
26
+ function _getRequireWildcardCache(nodeInterop) {
27
+ if (typeof WeakMap !== "function") return null;
28
+ var cacheBabelInterop = new WeakMap();
29
+ var cacheNodeInterop = new WeakMap();
30
+ return (_getRequireWildcardCache = function(nodeInterop) {
31
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
32
+ })(nodeInterop);
33
+ }
34
+ function _interop_require_wildcard(obj, nodeInterop) {
35
+ if (!nodeInterop && obj && obj.__esModule) {
36
+ return obj;
37
+ }
38
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
39
+ return {
40
+ default: obj
41
+ };
42
+ }
43
+ var cache = _getRequireWildcardCache(nodeInterop);
44
+ if (cache && cache.has(obj)) {
45
+ return cache.get(obj);
46
+ }
47
+ var newObj = {
48
+ __proto__: null
49
+ };
50
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
51
+ for(var key in obj){
52
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
53
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
54
+ if (desc && (desc.get || desc.set)) {
55
+ Object.defineProperty(newObj, key, desc);
56
+ } else {
57
+ newObj[key] = obj[key];
58
+ }
59
+ }
60
+ }
61
+ newObj.default = obj;
62
+ if (cache) {
63
+ cache.set(obj, newObj);
64
+ }
65
+ return newObj;
66
+ }
26
67
  class AabParser extends _zip.Zip {
27
68
  async extractApk(outputPath, { includeAllSplits, splits }) {
28
69
  const normalizedSplits = Array.isArray(splits) ? splits.map((item)=>item.trim()).filter(Boolean) : [];
@@ -130,7 +171,7 @@ class AabParser extends _zip.Zip {
130
171
  reject(err || new Error((0, _i18n.t)('aabReadUniversalApkFailed')));
131
172
  return;
132
173
  }
133
- const writeStream = _fsextra.default.createWriteStream(outputPath);
174
+ const writeStream = _fsextra.createWriteStream(outputPath);
134
175
  readStream.pipe(writeStream);
135
176
  writeStream.on('close', ()=>{
136
177
  zipfile.close();
@@ -150,8 +191,8 @@ class AabParser extends _zip.Zip {
150
191
  });
151
192
  } finally{
152
193
  // Cleanup
153
- if (await _fsextra.default.pathExists(tempApksPath)) {
154
- await _fsextra.default.remove(tempApksPath);
194
+ if (await _fsextra.pathExists(tempApksPath)) {
195
+ await _fsextra.remove(tempApksPath);
155
196
  }
156
197
  }
157
198
  }
@@ -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> | Blob>>;
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<Buffer<ArrayBufferLike> | Blob | undefined>;
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 new Promise((resolve, reject)=>{
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 new Promise((resolve, reject)=>{
42
- this.unzip.getBuffer([
43
- decoded
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
  }
@@ -22,13 +22,8 @@ _export(exports, {
22
22
  return testUrls;
23
23
  }
24
24
  });
25
- const _nodefetch = /*#__PURE__*/ _interop_require_default(require("node-fetch"));
26
25
  const _constants = require("./constants");
27
- function _interop_require_default(obj) {
28
- return obj && obj.__esModule ? obj : {
29
- default: obj
30
- };
31
- }
26
+ const _runtime = require("./runtime");
32
27
  function promiseAny(promises) {
33
28
  return new Promise((resolve, reject)=>{
34
29
  let count = 0;
@@ -45,7 +40,7 @@ function promiseAny(promises) {
45
40
  const ping = async (url)=>{
46
41
  let pingFinished = false;
47
42
  return Promise.race([
48
- (0, _nodefetch.default)(url, {
43
+ (0, _runtime.runtimeFetch)(url, {
49
44
  method: 'HEAD'
50
45
  }).then(({ status })=>{
51
46
  pingFinished = true;