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
@@ -1,4 +1,5 @@
1
1
  import { checkPlugins } from './check-plugin';
2
+ export declare function isNonInteractive(): boolean;
2
3
  export declare function question(query: string, password?: boolean): Promise<string>;
3
4
  export declare function translateOptions<T extends Record<string, unknown>>(options: T): T & Record<string, unknown>;
4
5
  export declare function getApkInfo(fn: string): Promise<{
@@ -17,6 +18,5 @@ export declare function getAabInfo(fn: string): Promise<{
17
18
  versionName: string;
18
19
  buildTime: number;
19
20
  }>;
20
- export declare function saveToLocal(_originPath: string, _destName: string): void;
21
21
  export declare function printVersionCommand(): Promise<void>;
22
22
  export { checkPlugins };
@@ -24,23 +24,21 @@ _export(exports, {
24
24
  get getIpaInfo () {
25
25
  return getIpaInfo;
26
26
  },
27
+ get isNonInteractive () {
28
+ return isNonInteractive;
29
+ },
27
30
  get printVersionCommand () {
28
31
  return printVersionCommand;
29
32
  },
30
33
  get question () {
31
34
  return question;
32
35
  },
33
- get saveToLocal () {
34
- return saveToLocal;
35
- },
36
36
  get translateOptions () {
37
37
  return translateOptions;
38
38
  }
39
39
  });
40
40
  const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
41
41
  const _compareversions = require("compare-versions");
42
- const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
43
- const _os = /*#__PURE__*/ _interop_require_default(require("os"));
44
42
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
45
43
  const _read = require("read");
46
44
  const _yauzl = require("yauzl");
@@ -56,8 +54,13 @@ function _interop_require_default(obj) {
56
54
  default: obj
57
55
  };
58
56
  }
57
+ function isNonInteractive() {
58
+ var _process_env_NO_INTERACTIVE;
59
+ const envValue = (_process_env_NO_INTERACTIVE = process.env.NO_INTERACTIVE) == null ? void 0 : _process_env_NO_INTERACTIVE.toLowerCase();
60
+ return global.NO_INTERACTIVE === true || envValue === 'true' || envValue === '1';
61
+ }
59
62
  async function question(query, password) {
60
- if (NO_INTERACTIVE) {
63
+ if (isNonInteractive()) {
61
64
  return '';
62
65
  }
63
66
  return (0, _read.read)({
@@ -336,14 +339,6 @@ async function resolveResource(fn, resourceId, root) {
336
339
  }
337
340
  return null;
338
341
  }
339
- const localDir = _path.default.resolve(_os.default.homedir(), _constants.tempDir);
340
- _fsextra.default.ensureDirSync(localDir);
341
- function saveToLocal(_originPath, _destName) {
342
- // TODO
343
- // const destPath = path.join(localDir, destName);
344
- // fs.ensureDirSync(path.dirname(destPath));
345
- // fs.copyFileSync(originPath, destPath);
346
- }
347
342
  async function getLatestVersion(pkgNames) {
348
343
  return (0, _latestversion.default)(pkgNames, {
349
344
  // useCache: true,
@@ -8,11 +8,47 @@ Object.defineProperty(exports, "plugins", {
8
8
  return plugins;
9
9
  }
10
10
  });
11
- const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
12
- function _interop_require_default(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
11
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
12
+ function _getRequireWildcardCache(nodeInterop) {
13
+ if (typeof WeakMap !== "function") return null;
14
+ var cacheBabelInterop = new WeakMap();
15
+ var cacheNodeInterop = new WeakMap();
16
+ return (_getRequireWildcardCache = function(nodeInterop) {
17
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
18
+ })(nodeInterop);
19
+ }
20
+ function _interop_require_wildcard(obj, nodeInterop) {
21
+ if (!nodeInterop && obj && obj.__esModule) {
22
+ return obj;
23
+ }
24
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
25
+ return {
26
+ default: obj
27
+ };
28
+ }
29
+ var cache = _getRequireWildcardCache(nodeInterop);
30
+ if (cache && cache.has(obj)) {
31
+ return cache.get(obj);
32
+ }
33
+ var newObj = {
34
+ __proto__: null
15
35
  };
36
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
37
+ for(var key in obj){
38
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
39
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
40
+ if (desc && (desc.get || desc.set)) {
41
+ Object.defineProperty(newObj, key, desc);
42
+ } else {
43
+ newObj[key] = obj[key];
44
+ }
45
+ }
46
+ }
47
+ newObj.default = obj;
48
+ if (cache) {
49
+ cache.set(obj, newObj);
50
+ }
51
+ return newObj;
16
52
  }
17
53
  const plugins = [
18
54
  {
@@ -23,11 +59,11 @@ const plugins = [
23
59
  },
24
60
  detect: async ()=>{
25
61
  try {
26
- await _fsextra.default.access('ios/sentry.properties');
62
+ await _fsextra.access('ios/sentry.properties');
27
63
  return true;
28
64
  } catch (unused) {
29
65
  try {
30
- await _fsextra.default.access('android/sentry.properties');
66
+ await _fsextra.access('android/sentry.properties');
31
67
  return true;
32
68
  } catch (unused) {
33
69
  return false;
@@ -0,0 +1,28 @@
1
+ import { type ChildProcessWithoutNullStreams, type SpawnOptionsWithoutStdio, type SpawnSyncOptions } from 'child_process';
2
+ export type RuntimeRequestInit = {
3
+ method?: string;
4
+ headers?: Record<string, string>;
5
+ body?: any;
6
+ signal?: AbortSignal;
7
+ };
8
+ export type RuntimeResponse = {
9
+ status: number;
10
+ statusText: string;
11
+ text: () => Promise<string>;
12
+ };
13
+ export type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
14
+ export type JavaScriptRuntime = 'bun' | 'node';
15
+ export declare const isBunRuntime: boolean;
16
+ export declare function runtimeFetch(url: string, options?: RuntimeRequestInit): Promise<RuntimeResponse>;
17
+ export declare function measureTcpLatency(input: string, { attempts, timeout, }?: {
18
+ attempts?: number;
19
+ timeout?: number;
20
+ }): Promise<number>;
21
+ export declare function detectPackageManager(cwd?: string, env?: NodeJS.ProcessEnv): PackageManager;
22
+ export declare function getInstallCommand(installArgs: string[], cwd?: string): {
23
+ command: string;
24
+ args: string[];
25
+ };
26
+ export declare function getJavaScriptRuntime(env?: NodeJS.ProcessEnv): JavaScriptRuntime;
27
+ export declare function spawnJavaScript(args: string[], options?: SpawnOptionsWithoutStdio, env?: NodeJS.ProcessEnv): ChildProcessWithoutNullStreams;
28
+ export declare function spawnJavaScriptSync(args: string[], options?: SpawnSyncOptions, env?: NodeJS.ProcessEnv): import("node:child_process").SpawnSyncReturns<string | NonSharedBuffer>;
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get detectPackageManager () {
13
+ return detectPackageManager;
14
+ },
15
+ get getInstallCommand () {
16
+ return getInstallCommand;
17
+ },
18
+ get getJavaScriptRuntime () {
19
+ return getJavaScriptRuntime;
20
+ },
21
+ get isBunRuntime () {
22
+ return isBunRuntime;
23
+ },
24
+ get measureTcpLatency () {
25
+ return measureTcpLatency;
26
+ },
27
+ get runtimeFetch () {
28
+ return runtimeFetch;
29
+ },
30
+ get spawnJavaScript () {
31
+ return spawnJavaScript;
32
+ },
33
+ get spawnJavaScriptSync () {
34
+ return spawnJavaScriptSync;
35
+ }
36
+ });
37
+ const _child_process = require("child_process");
38
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
39
+ const _net = require("net");
40
+ const _nodefetch = /*#__PURE__*/ _interop_require_default(require("node-fetch"));
41
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
42
+ function _interop_require_default(obj) {
43
+ return obj && obj.__esModule ? obj : {
44
+ default: obj
45
+ };
46
+ }
47
+ const isBunRuntime = typeof process.versions.bun === 'string';
48
+ function runtimeFetch(url, options) {
49
+ const fetchImpl = typeof globalThis.fetch === 'function' ? globalThis.fetch.bind(globalThis) : _nodefetch.default;
50
+ return fetchImpl(url, options);
51
+ }
52
+ function resolveTcpTarget(input) {
53
+ try {
54
+ const parsed = new URL(input);
55
+ const port = parsed.port || (parsed.protocol === 'http:' ? '80' : '443');
56
+ return {
57
+ host: parsed.hostname,
58
+ port: Number(port)
59
+ };
60
+ } catch (unused) {
61
+ const [host, port] = input.split(':');
62
+ return {
63
+ host,
64
+ port: port ? Number(port) : 443
65
+ };
66
+ }
67
+ }
68
+ function measureTcpConnectOnce(host, port, timeout) {
69
+ return new Promise((resolve)=>{
70
+ const startedAt = Date.now();
71
+ const socket = (0, _net.createConnection)({
72
+ host,
73
+ port
74
+ });
75
+ const finish = (latency)=>{
76
+ socket.removeAllListeners();
77
+ socket.destroy();
78
+ resolve(latency);
79
+ };
80
+ socket.setTimeout(timeout);
81
+ socket.once('connect', ()=>{
82
+ finish(Date.now() - startedAt);
83
+ });
84
+ socket.once('timeout', ()=>{
85
+ finish(Number.POSITIVE_INFINITY);
86
+ });
87
+ socket.once('error', ()=>{
88
+ finish(Number.POSITIVE_INFINITY);
89
+ });
90
+ });
91
+ }
92
+ async function measureTcpLatency(input, { attempts = 4, timeout = 1000 } = {}) {
93
+ const { host, port } = resolveTcpTarget(input);
94
+ const latencies = [];
95
+ for(let i = 0; i < attempts; i++){
96
+ const latency = await measureTcpConnectOnce(host, port, timeout);
97
+ if (Number.isFinite(latency)) {
98
+ latencies.push(latency);
99
+ }
100
+ }
101
+ if (latencies.length === 0) {
102
+ return Number.POSITIVE_INFINITY;
103
+ }
104
+ return latencies.reduce((sum, latency)=>sum + latency, 0) / latencies.length;
105
+ }
106
+ function detectPackageManager(cwd = process.cwd(), env = process.env) {
107
+ var _env_npm_config_user_agent;
108
+ const lockFiles = [
109
+ [
110
+ 'bun.lock',
111
+ 'bun'
112
+ ],
113
+ [
114
+ 'bun.lockb',
115
+ 'bun'
116
+ ],
117
+ [
118
+ 'pnpm-lock.yaml',
119
+ 'pnpm'
120
+ ],
121
+ [
122
+ 'yarn.lock',
123
+ 'yarn'
124
+ ],
125
+ [
126
+ 'package-lock.json',
127
+ 'npm'
128
+ ]
129
+ ];
130
+ for (const [lockFile, manager] of lockFiles){
131
+ if (_fs.default.existsSync(_path.default.join(cwd, lockFile))) {
132
+ return manager;
133
+ }
134
+ }
135
+ const userAgent = (_env_npm_config_user_agent = env.npm_config_user_agent) != null ? _env_npm_config_user_agent : '';
136
+ if (userAgent.startsWith('bun/')) {
137
+ return 'bun';
138
+ }
139
+ if (userAgent.startsWith('pnpm/')) {
140
+ return 'pnpm';
141
+ }
142
+ if (userAgent.startsWith('yarn/')) {
143
+ return 'yarn';
144
+ }
145
+ if (userAgent.startsWith('npm/')) {
146
+ return 'npm';
147
+ }
148
+ return isBunRuntime ? 'bun' : 'npm';
149
+ }
150
+ function getInstallCommand(installArgs, cwd = process.cwd()) {
151
+ const packageManager = detectPackageManager(cwd);
152
+ if (packageManager === 'npm') {
153
+ return {
154
+ command: 'npm',
155
+ args: [
156
+ 'install',
157
+ ...installArgs
158
+ ]
159
+ };
160
+ }
161
+ return {
162
+ command: packageManager,
163
+ args: [
164
+ 'add',
165
+ ...installArgs
166
+ ]
167
+ };
168
+ }
169
+ function getJavaScriptRuntime(env = process.env) {
170
+ var _env_RNU_JS_RUNTIME;
171
+ const configured = (_env_RNU_JS_RUNTIME = env.RNU_JS_RUNTIME) == null ? void 0 : _env_RNU_JS_RUNTIME.toLowerCase();
172
+ if (configured === 'bun') {
173
+ return 'bun';
174
+ }
175
+ if (configured === 'auto') {
176
+ return isBunRuntime ? 'bun' : 'node';
177
+ }
178
+ return 'node';
179
+ }
180
+ function spawnJavaScript(args, options, env = process.env) {
181
+ return (0, _child_process.spawn)(getJavaScriptRuntime(env), args, options != null ? options : {});
182
+ }
183
+ function spawnJavaScriptSync(args, options, env = process.env) {
184
+ return (0, _child_process.spawnSync)(getJavaScriptRuntime(env), args, options != null ? options : {});
185
+ }
package/lib/versions.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import type { Package, Platform } from './types';
1
+ import type { Package, Platform, Version } from './types';
2
2
  interface VersionCommandOptions {
3
+ [key: string]: unknown;
3
4
  appId?: string;
4
5
  name?: string;
5
6
  description?: string;
@@ -11,14 +12,16 @@ interface VersionCommandOptions {
11
12
  minPackageVersion?: string;
12
13
  maxPackageVersion?: string;
13
14
  packageVersionRange?: string;
14
- rollout?: string;
15
+ rollout?: number | string;
15
16
  dryRun?: boolean;
16
17
  versionDeps?: Record<string, string>;
17
18
  warnDepsChanges?: boolean;
19
+ 'no-interactive'?: boolean | string;
18
20
  }
21
+ export declare function fetchVersions(appId: string, offset?: number, limit?: number): Promise<Version[]>;
19
22
  export declare const bindVersionToPackages: ({ appId, versionId, pkgs, rollout, dryRun, }: {
20
23
  appId: string;
21
- versionId: string;
24
+ versionId: string | null;
22
25
  pkgs: Package[];
23
26
  rollout?: number;
24
27
  dryRun?: boolean;
package/lib/versions.js CHANGED
@@ -12,6 +12,9 @@ _export(exports, {
12
12
  get bindVersionToPackages () {
13
13
  return bindVersionToPackages;
14
14
  },
15
+ get fetchVersions () {
16
+ return fetchVersions;
17
+ },
15
18
  get versionCommands () {
16
19
  return versionCommands;
17
20
  }
@@ -26,6 +29,7 @@ const _utils = require("./utils");
26
29
  const _depversions = require("./utils/dep-versions");
27
30
  const _git = require("./utils/git");
28
31
  const _i18n = require("./utils/i18n");
32
+ const _options = require("./utils/options");
29
33
  function _interop_require_default(obj) {
30
34
  return obj && obj.__esModule ? obj : {
31
35
  default: obj
@@ -207,8 +211,13 @@ async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVers
207
211
  console.log(_chalk.default.yellow((0, _i18n.t)('depsChangeNonBlockingHint')));
208
212
  }
209
213
  }
214
+ const versionPageLimit = 10;
215
+ async function fetchVersions(appId, offset = 0, limit = versionPageLimit) {
216
+ const { data } = await (0, _api.get)(`/app/${appId}/version/list?offset=${offset}&limit=${limit}`);
217
+ return Array.isArray(data) ? data : [];
218
+ }
210
219
  async function showVersion(appId, offset) {
211
- const { data } = await (0, _api.get)(`/app/${appId}/version/list`);
220
+ const data = await fetchVersions(appId, offset, versionPageLimit);
212
221
  console.log((0, _i18n.t)('offset', {
213
222
  offset
214
223
  }));
@@ -220,7 +229,7 @@ async function showVersion(appId, offset) {
220
229
  packageInfo = 'no package';
221
230
  } else {
222
231
  var _version_packages1;
223
- packageInfo = (_version_packages1 = version.packages) == null ? void 0 : _version_packages1.slice(0, 3).map((pkg)=>pkg.name).join(', ');
232
+ packageInfo = ((_version_packages1 = version.packages) != null ? _version_packages1 : []).slice(0, 3).map((pkg)=>pkg.name).join(', ');
224
233
  if (pkgCount > 3) {
225
234
  packageInfo += `...and ${pkgCount - 3} more`;
226
235
  } else {
@@ -231,10 +240,13 @@ async function showVersion(appId, offset) {
231
240
  }
232
241
  return data;
233
242
  }
234
- async function listVersions(appId) {
243
+ async function listVersions(appId, interactive = true) {
235
244
  let offset = 0;
236
245
  while(true){
237
- await showVersion(appId, offset);
246
+ const data = await showVersion(appId, offset);
247
+ if (!interactive) {
248
+ return data;
249
+ }
238
250
  const cmd = await (0, _utils.question)('page Up/page Down/Begin/Quit(U/D/B/Q)');
239
251
  switch(cmd.toLowerCase()){
240
252
  case 'u':
@@ -247,7 +259,9 @@ async function listVersions(appId) {
247
259
  offset = 0;
248
260
  break;
249
261
  case 'q':
250
- return;
262
+ return data;
263
+ case '':
264
+ return data;
251
265
  }
252
266
  }
253
267
  }
@@ -255,6 +269,9 @@ async function chooseVersion(appId) {
255
269
  let offset = 0;
256
270
  while(true){
257
271
  const data = await showVersion(appId, offset);
272
+ if ((0, _utils.isNonInteractive)()) {
273
+ throw new Error((0, _i18n.t)('versionIdRequired'));
274
+ }
258
275
  const cmd = await (0, _utils.question)('Enter versionId or page Up/page Down/Begin(U/D/B)');
259
276
  switch(cmd.toUpperCase()){
260
277
  case 'U':
@@ -314,18 +331,17 @@ const versionCommands = {
314
331
  }
315
332
  const platform = await (0, _app.getPlatform)(options.platform);
316
333
  const { appId } = await (0, _app.getSelectedApp)(platform);
334
+ const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
317
335
  const { hash } = await (0, _api.uploadFile)(fn);
318
- const versionName = name || await (0, _utils.question)((0, _i18n.t)('versionNameQuestion')) || (0, _i18n.t)('unnamed');
336
+ const versionName = name || (nonInteractive ? '' : await (0, _utils.question)((0, _i18n.t)('versionNameQuestion'))) || (0, _i18n.t)('unnamed');
319
337
  const { id } = await (0, _api.post)(`/app/${appId}/version/create`, {
320
338
  name: versionName,
321
339
  hash,
322
- description: description || await (0, _utils.question)((0, _i18n.t)('versionDescriptionQuestion')),
323
- metaInfo: metaInfo || await (0, _utils.question)((0, _i18n.t)('versionMetaInfoQuestion')),
340
+ description: description != null ? description : nonInteractive ? '' : await (0, _utils.question)((0, _i18n.t)('versionDescriptionQuestion')),
341
+ metaInfo: metaInfo != null ? metaInfo : nonInteractive ? '' : await (0, _utils.question)((0, _i18n.t)('versionMetaInfoQuestion')),
324
342
  deps: _depversions.depVersions,
325
343
  commit: await (0, _git.getCommitInfo)()
326
344
  });
327
- // TODO local diff
328
- (0, _utils.saveToLocal)(fn, `${appId}/ppk/${id}.ppk`);
329
345
  console.log((0, _i18n.t)('packageUploadSuccess', {
330
346
  id
331
347
  }));
@@ -346,7 +362,7 @@ const versionCommands = {
346
362
  warnDepsChanges: true
347
363
  }
348
364
  });
349
- } else {
365
+ } else if (!nonInteractive) {
350
366
  const q = await (0, _utils.question)((0, _i18n.t)('updateNativePackageQuestion'));
351
367
  if (q.toLowerCase() === 'y') {
352
368
  await versionCommands.update({
@@ -362,16 +378,33 @@ const versionCommands = {
362
378
  return versionName;
363
379
  },
364
380
  versions: async ({ options })=>{
365
- const platform = await (0, _app.getPlatform)(options.platform);
366
- const { appId } = await (0, _app.getSelectedApp)(platform);
367
- await listVersions(String(appId));
381
+ let appId = options.appId;
382
+ if (!appId) {
383
+ const platform = await (0, _app.getPlatform)(options.platform);
384
+ appId = (await (0, _app.getSelectedApp)(platform)).appId;
385
+ }
386
+ const interactive = !((0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)());
387
+ await listVersions(String(appId), interactive);
368
388
  },
369
389
  update: async ({ options })=>{
370
- const platform = await (0, _app.getPlatform)(options.platform);
371
- const appId = options.appId || (await (0, _app.getSelectedApp)(platform)).appId;
372
- let versionId = options.versionId || (await chooseVersion(String(appId))).id;
390
+ const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
391
+ let appId = options.appId;
392
+ let platform = options.platform;
393
+ if (!appId) {
394
+ platform = await (0, _app.getPlatform)(platform);
395
+ appId = (await (0, _app.getSelectedApp)(platform)).appId;
396
+ } else if (platform) {
397
+ platform = await (0, _app.getPlatform)(platform);
398
+ }
399
+ let versionId = options.versionId;
400
+ if (!versionId) {
401
+ if (nonInteractive) {
402
+ throw new Error((0, _i18n.t)('versionIdRequired'));
403
+ }
404
+ versionId = (await chooseVersion(String(appId))).id;
405
+ }
373
406
  if (versionId === 'null') {
374
- versionId = undefined;
407
+ versionId = null;
375
408
  }
376
409
  let pkgId = options.packageId;
377
410
  let pkgVersion = options.packageVersion;
@@ -380,7 +413,7 @@ const versionCommands = {
380
413
  let packageVersionRange = options.packageVersionRange;
381
414
  let rollout;
382
415
  if (options.rollout !== undefined) {
383
- rollout = Number.parseInt(options.rollout, 10);
416
+ rollout = Number.parseInt(String(options.rollout), 10);
384
417
  if (Number.isNaN(rollout) || rollout < 1 || rollout > 100) {
385
418
  throw new Error((0, _i18n.t)('rolloutRangeError'));
386
419
  }
@@ -394,7 +427,7 @@ const versionCommands = {
394
427
  let pkgsToBind = [];
395
428
  if (minPkgVersion) {
396
429
  minPkgVersion = String(minPkgVersion).trim();
397
- pkgsToBind = allPkgs.filter((pkg)=>(0, _compareversions.satisfies)(pkg.name, `>=${minPkgVersion}`));
430
+ pkgsToBind = allPkgs.filter((pkg)=>(0, _compareversions.compare)(pkg.name, minPkgVersion, '>='));
398
431
  if (pkgsToBind.length === 0) {
399
432
  throw new Error((0, _i18n.t)('nativeVersionNotFoundGte', {
400
433
  version: minPkgVersion
@@ -402,7 +435,9 @@ const versionCommands = {
402
435
  }
403
436
  } else if (maxPkgVersion) {
404
437
  maxPkgVersion = String(maxPkgVersion).trim();
405
- pkgsToBind = allPkgs.filter((pkg)=>(0, _compareversions.satisfies)(pkg.name, `<=${maxPkgVersion}`));
438
+ pkgsToBind = allPkgs.filter((pkg)=>{
439
+ return (0, _compareversions.compare)(pkg.name, maxPkgVersion, '<=');
440
+ });
406
441
  if (pkgsToBind.length === 0) {
407
442
  throw new Error((0, _i18n.t)('nativeVersionNotFoundLte', {
408
443
  version: maxPkgVersion
@@ -430,6 +465,9 @@ const versionCommands = {
430
465
  }
431
466
  } else {
432
467
  if (!pkgId) {
468
+ if (nonInteractive) {
469
+ throw new Error((0, _i18n.t)('packageIdRequired'));
470
+ }
433
471
  pkgId = (await (0, _package.choosePackage)(String(appId))).id;
434
472
  }
435
473
  if (!pkgId) {
@@ -446,7 +484,7 @@ const versionCommands = {
446
484
  }));
447
485
  }
448
486
  }
449
- if (options.warnDepsChanges) {
487
+ if (options.warnDepsChanges && versionId) {
450
488
  await printDepsChangesForPublish({
451
489
  appId: String(appId),
452
490
  versionId: String(versionId),
@@ -463,9 +501,22 @@ const versionCommands = {
463
501
  });
464
502
  },
465
503
  updateVersionInfo: async ({ options })=>{
466
- const platform = await (0, _app.getPlatform)(options.platform);
467
- const { appId } = await (0, _app.getSelectedApp)(platform);
468
- const versionId = options.versionId || (await chooseVersion(String(appId))).id;
504
+ const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
505
+ let appId = options.appId;
506
+ let platform = options.platform;
507
+ if (!appId) {
508
+ platform = await (0, _app.getPlatform)(platform);
509
+ appId = (await (0, _app.getSelectedApp)(platform)).appId;
510
+ } else if (platform) {
511
+ await (0, _app.getPlatform)(platform);
512
+ }
513
+ let versionId = options.versionId;
514
+ if (!versionId) {
515
+ if (nonInteractive) {
516
+ throw new Error((0, _i18n.t)('versionIdRequired'));
517
+ }
518
+ versionId = (await chooseVersion(String(appId))).id;
519
+ }
469
520
  const updateParams = {};
470
521
  if (options.name) updateParams.name = options.name;
471
522
  if (options.description) updateParams.description = options.description;
@@ -474,6 +525,7 @@ const versionCommands = {
474
525
  console.log((0, _i18n.t)('operationSuccess'));
475
526
  },
476
527
  deleteVersion: async ({ options })=>{
528
+ const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
477
529
  let appId = options.appId;
478
530
  if (!appId) {
479
531
  const platform = await (0, _app.getPlatform)(options.platform);
@@ -481,6 +533,9 @@ const versionCommands = {
481
533
  }
482
534
  let versionId = options.versionId;
483
535
  if (!versionId) {
536
+ if (nonInteractive) {
537
+ throw new Error((0, _i18n.t)('versionIdRequired'));
538
+ }
484
539
  versionId = (await chooseVersion(String(appId))).id;
485
540
  }
486
541
  try {