react-native-update-cli 2.18.0 → 2.19.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 (52) hide show
  1. package/lib/api.d.ts +1 -1
  2. package/lib/api.js +140 -134
  3. package/lib/app.d.ts +2 -2
  4. package/lib/app.js +60 -107
  5. package/lib/bin.js +38 -35
  6. package/lib/bundle-pack.js +57 -77
  7. package/lib/bundle-runner.js +249 -312
  8. package/lib/bundle.js +71 -89
  9. package/lib/diff.js +188 -235
  10. package/lib/exports.js +14 -37
  11. package/lib/index.js +16 -17
  12. package/lib/install.js +24 -37
  13. package/lib/locales/en.js +3 -11
  14. package/lib/locales/zh.js +3 -11
  15. package/lib/package.js +164 -218
  16. package/lib/provider.js +85 -107
  17. package/lib/types.js +1 -3
  18. package/lib/user.d.ts +1 -1
  19. package/lib/user.js +26 -39
  20. package/lib/utils/add-gitignore.js +16 -29
  21. package/lib/utils/app-info-parser/aab.js +133 -157
  22. package/lib/utils/app-info-parser/apk.js +42 -39
  23. package/lib/utils/app-info-parser/app.js +5 -11
  24. package/lib/utils/app-info-parser/index.js +21 -31
  25. package/lib/utils/app-info-parser/ipa.js +35 -35
  26. package/lib/utils/app-info-parser/resource-finder.js +84 -71
  27. package/lib/utils/app-info-parser/utils.js +52 -77
  28. package/lib/utils/app-info-parser/xml-parser/binary.js +82 -90
  29. package/lib/utils/app-info-parser/xml-parser/manifest.js +88 -98
  30. package/lib/utils/app-info-parser/zip.js +43 -51
  31. package/lib/utils/check-lockfile.js +28 -37
  32. package/lib/utils/check-plugin.js +16 -32
  33. package/lib/utils/command-result.js +7 -20
  34. package/lib/utils/constants.js +23 -63
  35. package/lib/utils/dep-versions.js +21 -27
  36. package/lib/utils/git.js +20 -64
  37. package/lib/utils/hbcTransform.js +133 -246
  38. package/lib/utils/http-helper.js +33 -44
  39. package/lib/utils/i18n.js +17 -26
  40. package/lib/utils/index.js +137 -179
  41. package/lib/utils/latest-version/index.js +128 -137
  42. package/lib/utils/options.js +13 -34
  43. package/lib/utils/plugin-config.js +43 -56
  44. package/lib/utils/runtime.js +50 -108
  45. package/lib/utils/zip-entries.js +70 -97
  46. package/lib/utils/zip-options.js +80 -181
  47. package/lib/versions.js +231 -265
  48. package/package.json +19 -21
  49. package/src/api.ts +44 -3
  50. package/src/package.ts +1 -1
  51. package/src/user.ts +1 -1
  52. package/src/versions.ts +1 -1
package/lib/provider.js CHANGED
@@ -1,92 +1,74 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
4
17
  });
5
- Object.defineProperty(exports, "CLIProviderImpl", {
6
- enumerable: true,
7
- get: function() {
8
- return CLIProviderImpl;
9
- }
10
- });
11
- const _api = require("./api");
12
- const _app = require("./app");
13
- const _commandresult = require("./utils/command-result");
14
- const _i18n = require("./utils/i18n");
15
- function _getRequireWildcardCache(nodeInterop) {
16
- if (typeof WeakMap !== "function") return null;
17
- var cacheBabelInterop = new WeakMap();
18
- var cacheNodeInterop = new WeakMap();
19
- return (_getRequireWildcardCache = function(nodeInterop) {
20
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
21
- })(nodeInterop);
22
- }
23
- function _interop_require_wildcard(obj, nodeInterop) {
24
- if (!nodeInterop && obj && obj.__esModule) {
25
- return obj;
26
- }
27
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
28
- return {
29
- default: obj
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
30
24
  };
31
- }
32
- var cache = _getRequireWildcardCache(nodeInterop);
33
- if (cache && cache.has(obj)) {
34
- return cache.get(obj);
35
- }
36
- var newObj = {
37
- __proto__: null
25
+ return ownKeys(o);
38
26
  };
39
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
40
- for(var key in obj){
41
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
42
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
43
- if (desc && (desc.get || desc.set)) {
44
- Object.defineProperty(newObj, key, desc);
45
- } else {
46
- newObj[key] = obj[key];
47
- }
48
- }
49
- }
50
- newObj.default = obj;
51
- if (cache) {
52
- cache.set(obj, newObj);
53
- }
54
- return newObj;
55
- }
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CLIProviderImpl = void 0;
37
+ const api_1 = require("./api");
38
+ const app_1 = require("./app");
39
+ const command_result_1 = require("./utils/command-result");
40
+ const i18n_1 = require("./utils/i18n");
56
41
  const DEFAULT_BUNDLE_OUTPUT = '$' + '{tempDir}/output/$' + '{platform}.$' + '{time}.ppk';
57
42
  class CLIProviderImpl {
43
+ session;
44
+ sessionInitPromise;
58
45
  createContext(options, args = []) {
59
- return {
60
- args,
61
- options
62
- };
46
+ return { args, options };
63
47
  }
64
48
  async ensureInitialized() {
65
49
  if (this.session) {
66
50
  return;
67
51
  }
68
52
  if (!this.sessionInitPromise) {
69
- this.sessionInitPromise = (async ()=>{
70
- await (0, _api.loadSession)();
71
- this.session = (0, _api.getSession)();
72
- })().finally(()=>{
53
+ this.sessionInitPromise = (async () => {
54
+ await (0, api_1.loadSession)();
55
+ this.session = (0, api_1.getSession)();
56
+ })().finally(() => {
73
57
  this.sessionInitPromise = undefined;
74
58
  });
75
59
  }
76
60
  await this.sessionInitPromise;
77
61
  }
78
62
  runMessageCommand(task, fallbackError, successMessage, requireSession = true) {
79
- return (0, _commandresult.runAsCommandResult)(async ()=>{
63
+ return (0, command_result_1.runAsCommandResult)(async () => {
80
64
  if (requireSession) {
81
65
  await this.ensureInitialized();
82
66
  }
83
67
  await task();
84
- }, fallbackError, ()=>({
85
- message: successMessage
86
- }));
68
+ }, fallbackError, () => ({ message: successMessage }));
87
69
  }
88
70
  runDataCommand(task, fallbackError, requireSession = true) {
89
- return (0, _commandresult.runAsCommandResult)(async ()=>{
71
+ return (0, command_result_1.runAsCommandResult)(async () => {
90
72
  if (requireSession) {
91
73
  await this.ensureInitialized();
92
74
  }
@@ -94,7 +76,7 @@ class CLIProviderImpl {
94
76
  }, fallbackError);
95
77
  }
96
78
  async bundle(options) {
97
- return this.runMessageCommand(async ()=>{
79
+ return this.runMessageCommand(async () => {
98
80
  const context = this.createContext({
99
81
  dev: options.dev || false,
100
82
  platform: options.platform,
@@ -108,14 +90,14 @@ class CLIProviderImpl {
108
90
  rncli: options.rncli || false,
109
91
  hermes: options.hermes || false,
110
92
  sentryRelease: options.sentryRelease,
111
- sentryDist: options.sentryDist
93
+ sentryDist: options.sentryDist,
112
94
  });
113
- const { bundleCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bundle")));
95
+ const { bundleCommands } = await Promise.resolve().then(() => __importStar(require('./bundle')));
114
96
  await bundleCommands.bundle(context);
115
97
  }, 'Unknown error during bundling', 'Bundle created successfully', false);
116
98
  }
117
99
  async publish(options) {
118
- return this.runMessageCommand(async ()=>{
100
+ return this.runMessageCommand(async () => {
119
101
  const context = this.createContext({
120
102
  name: options.name,
121
103
  description: options.description,
@@ -127,107 +109,103 @@ class CLIProviderImpl {
127
109
  packageVersionRange: options.packageVersionRange,
128
110
  platform: options.platform,
129
111
  'no-interactive': true,
130
- rollout: options.rollout === undefined ? undefined : String(options.rollout),
131
- dryRun: options.dryRun || false
132
- }, options.filePath ? [
133
- options.filePath
134
- ] : []);
135
- const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
112
+ rollout: options.rollout === undefined
113
+ ? undefined
114
+ : String(options.rollout),
115
+ dryRun: options.dryRun || false,
116
+ }, options.filePath ? [options.filePath] : []);
117
+ const { versionCommands } = await Promise.resolve().then(() => __importStar(require('./versions')));
136
118
  await versionCommands.publish(context);
137
119
  }, 'Unknown error during publishing', 'Version published successfully');
138
120
  }
139
121
  async upload(options) {
140
- return this.runMessageCommand(async ()=>{
141
- var _filePath_split_pop;
122
+ return this.runMessageCommand(async () => {
142
123
  const filePath = options.filePath;
143
- const fileType = (_filePath_split_pop = filePath.split('.').pop()) == null ? void 0 : _filePath_split_pop.toLowerCase();
124
+ const fileType = filePath.split('.').pop()?.toLowerCase();
144
125
  const context = this.createContext({
145
126
  platform: options.platform,
146
127
  appId: options.appId,
147
128
  appKey: options.appKey,
148
129
  version: options.version,
149
- config: options.config
150
- }, [
151
- filePath
152
- ]);
153
- const { packageCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./package")));
130
+ config: options.config,
131
+ }, [filePath]);
132
+ const { packageCommands } = await Promise.resolve().then(() => __importStar(require('./package')));
154
133
  const uploadHandlerMap = {
155
134
  ipa: packageCommands.uploadIpa,
156
135
  apk: packageCommands.uploadApk,
157
136
  aab: packageCommands.uploadAab,
158
- app: packageCommands.uploadApp
137
+ app: packageCommands.uploadApp,
159
138
  };
160
- const uploadHandler = fileType && fileType in uploadHandlerMap ? uploadHandlerMap[fileType] : undefined;
139
+ const uploadHandler = fileType && fileType in uploadHandlerMap
140
+ ? uploadHandlerMap[fileType]
141
+ : undefined;
161
142
  if (!uploadHandler) {
162
- throw new Error((0, _i18n.t)('unsupportedFileType', {
163
- fileType
164
- }));
143
+ throw new Error((0, i18n_1.t)('unsupportedFileType', { fileType }));
165
144
  }
166
145
  await uploadHandler(context);
167
146
  }, 'Unknown error during upload', 'File uploaded successfully');
168
147
  }
169
148
  async getSelectedApp(platform) {
170
149
  const resolvedPlatform = await this.getPlatform(platform);
171
- return (0, _app.getSelectedApp)(resolvedPlatform);
150
+ return (0, app_1.getSelectedApp)(resolvedPlatform);
172
151
  }
173
152
  async listApps(platform) {
174
- return this.runDataCommand(async ()=>{
175
- const { getAppCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
153
+ return this.runDataCommand(async () => {
154
+ const { getAppCommands } = await Promise.resolve().then(() => __importStar(require('./app')));
176
155
  return getAppCommands().apps({
177
- options: {
178
- platform: platform != null ? platform : ''
179
- }
156
+ options: { platform: platform ?? '' },
180
157
  });
181
158
  }, 'Unknown error listing apps');
182
159
  }
183
160
  async createApp(name, platform) {
184
- return this.runMessageCommand(async ()=>{
185
- const { getAppCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
161
+ return this.runMessageCommand(async () => {
162
+ const { getAppCommands } = await Promise.resolve().then(() => __importStar(require('./app')));
186
163
  await getAppCommands().createApp({
187
164
  options: {
188
165
  name,
189
166
  platform,
190
- downloadUrl: ''
191
- }
167
+ downloadUrl: '',
168
+ },
192
169
  });
193
170
  }, 'Unknown error creating app', 'App created successfully');
194
171
  }
195
172
  async listVersions(appId) {
196
- return this.runDataCommand(async ()=>{
197
- const { fetchVersions } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
173
+ return this.runDataCommand(async () => {
174
+ const { fetchVersions } = await Promise.resolve().then(() => __importStar(require('./versions')));
198
175
  return fetchVersions(appId);
199
176
  }, 'Unknown error listing versions');
200
177
  }
201
178
  async updateVersion(appId, versionId, updates) {
202
- return this.runMessageCommand(async ()=>{
179
+ return this.runMessageCommand(async () => {
203
180
  const context = this.createContext({
204
181
  appId,
205
182
  versionId,
206
183
  ...updates,
207
184
  'no-interactive': true,
208
- rollout: updates.rollout === undefined ? undefined : String(updates.rollout)
185
+ rollout: updates.rollout === undefined ? undefined : String(updates.rollout),
209
186
  });
210
- const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
187
+ const { versionCommands } = await Promise.resolve().then(() => __importStar(require('./versions')));
211
188
  await versionCommands.update(context);
212
189
  }, 'Unknown error updating version', 'Version updated successfully');
213
190
  }
214
191
  async getPlatform(platform) {
215
- return (0, _app.getPlatform)(platform);
192
+ return (0, app_1.getPlatform)(platform);
216
193
  }
217
194
  async loadSession() {
218
195
  await this.ensureInitialized();
219
196
  if (!this.session) {
220
- throw new Error((0, _i18n.t)('failedToLoadSession'));
197
+ throw new Error((0, i18n_1.t)('failedToLoadSession'));
221
198
  }
222
199
  return this.session;
223
200
  }
224
201
  async listPackages(appId) {
225
- return this.runDataCommand(async ()=>{
202
+ return this.runDataCommand(async () => {
226
203
  if (!appId) {
227
- throw new Error((0, _i18n.t)('appIdRequired'));
204
+ throw new Error((0, i18n_1.t)('appIdRequired'));
228
205
  }
229
- const { listPackage } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./package")));
206
+ const { listPackage } = await Promise.resolve().then(() => __importStar(require('./package')));
230
207
  return listPackage(appId);
231
208
  }, 'Unknown error listing packages');
232
209
  }
233
210
  }
211
+ exports.CLIProviderImpl = CLIProviderImpl;
package/lib/types.js CHANGED
@@ -1,4 +1,2 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/user.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CommandContext } from 'types';
1
+ import type { CommandContext } from './types';
2
2
  export declare const userCommands: {
3
3
  login: ({ args }: {
4
4
  args: string[];
package/lib/user.js CHANGED
@@ -1,51 +1,38 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "userCommands", {
6
- enumerable: true,
7
- get: function() {
8
- return userCommands;
9
- }
10
- });
11
- const _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
12
- const _api = require("./api");
13
- const _utils = require("./utils");
14
- const _i18n = require("./utils/i18n");
15
- function _interop_require_default(obj) {
16
- return obj && obj.__esModule ? obj : {
17
- default: obj
18
- };
19
- }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.userCommands = void 0;
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ const api_1 = require("./api");
9
+ const utils_1 = require("./utils");
10
+ const i18n_1 = require("./utils/i18n");
20
11
  function md5(str) {
21
- return _crypto.default.createHash('md5').update(str).digest('hex');
12
+ return crypto_1.default.createHash('md5').update(str).digest('hex');
22
13
  }
23
- const userCommands = {
24
- login: async ({ args })=>{
25
- const email = args[0] || await (0, _utils.question)('email:');
26
- const pwd = args[1] || await (0, _utils.question)('password:', true);
27
- const { token, info } = await (0, _api.post)('/user/login', {
14
+ exports.userCommands = {
15
+ login: async ({ args }) => {
16
+ const email = args[0] || (await (0, utils_1.question)('email:'));
17
+ const pwd = args[1] || (await (0, utils_1.question)('password:', true));
18
+ const { token, info } = await (0, api_1.post)('/user/login', {
28
19
  email,
29
- pwd: md5(pwd)
20
+ pwd: md5(pwd),
30
21
  });
31
- (0, _api.replaceSession)({
32
- token
33
- });
34
- await (0, _api.saveSession)();
35
- console.log((0, _i18n.t)('welcomeMessage', {
36
- name: info.name
37
- }));
22
+ (0, api_1.replaceSession)({ token });
23
+ await (0, api_1.saveSession)();
24
+ console.log((0, i18n_1.t)('welcomeMessage', { name: info.name }));
38
25
  },
39
- logout: async (_context)=>{
40
- await (0, _api.closeSession)();
41
- console.log((0, _i18n.t)('loggedOut'));
26
+ logout: async (_context) => {
27
+ await (0, api_1.closeSession)();
28
+ console.log((0, i18n_1.t)('loggedOut'));
42
29
  },
43
- me: async ()=>{
44
- const me = await (0, _api.get)('/user/me');
45
- for(const k in me){
30
+ me: async () => {
31
+ const me = await (0, api_1.get)('/user/me');
32
+ for (const k in me) {
46
33
  if (k !== 'ok') {
47
34
  console.log(`${k}: ${me[k]}`);
48
35
  }
49
36
  }
50
- }
37
+ },
51
38
  };
@@ -1,33 +1,22 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "addGitIgnore", {
6
- enumerable: true,
7
- get: function() {
8
- return addGitIgnore;
9
- }
10
- });
11
- const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
- const _constants = require("./constants");
13
- const _i18n = require("./i18n");
14
- function _interop_require_default(obj) {
15
- return obj && obj.__esModule ? obj : {
16
- default: obj
17
- };
18
- }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.addGitIgnore = addGitIgnore;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ // import path from 'path';
9
+ const constants_1 = require("./constants");
10
+ const i18n_1 = require("./i18n");
19
11
  function addGitIgnore() {
20
- const shouldIgnore = [
21
- _constants.credentialFile,
22
- _constants.tempDir
23
- ];
12
+ const shouldIgnore = [constants_1.credentialFile, constants_1.tempDir];
24
13
  const gitignorePath = '.gitignore';
25
- if (!_fs.default.existsSync(gitignorePath)) {
14
+ if (!fs_1.default.existsSync(gitignorePath)) {
26
15
  return;
27
16
  }
28
- const gitignoreContent = _fs.default.readFileSync(gitignorePath, 'utf-8');
17
+ const gitignoreContent = fs_1.default.readFileSync(gitignorePath, 'utf-8');
29
18
  const gitignoreLines = gitignoreContent.split('\n');
30
- for (const line of gitignoreLines){
19
+ for (const line of gitignoreLines) {
31
20
  const index = shouldIgnore.indexOf(line.trim());
32
21
  if (index !== -1) {
33
22
  shouldIgnore.splice(index, 1);
@@ -35,12 +24,10 @@ function addGitIgnore() {
35
24
  }
36
25
  if (shouldIgnore.length > 0) {
37
26
  gitignoreLines.push('# react-native-update');
38
- for (const line of shouldIgnore){
27
+ for (const line of shouldIgnore) {
39
28
  gitignoreLines.push(line);
40
- console.log((0, _i18n.t)('addedToGitignore', {
41
- line
42
- }));
29
+ console.log((0, i18n_1.t)('addedToGitignore', { line }));
43
30
  }
44
- _fs.default.writeFileSync(gitignorePath, gitignoreLines.join('\n'));
31
+ fs_1.default.writeFileSync(gitignorePath, gitignoreLines.join('\n'));
45
32
  }
46
33
  }