react-native-update-cli 2.8.4 → 2.9.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 (112) hide show
  1. package/lib/api.d.ts +18 -0
  2. package/lib/app.d.ts +38 -0
  3. package/lib/app.js +5 -4
  4. package/lib/bundle-pack.d.ts +1 -0
  5. package/lib/bundle-pack.js +104 -0
  6. package/lib/bundle-runner.d.ts +20 -0
  7. package/lib/bundle-runner.js +404 -0
  8. package/lib/bundle.d.ts +6 -0
  9. package/lib/bundle.js +73 -471
  10. package/lib/diff.d.ts +13 -0
  11. package/lib/diff.js +144 -123
  12. package/lib/exports.d.ts +12 -0
  13. package/lib/index.d.ts +5 -0
  14. package/lib/index.js +5 -13
  15. package/lib/install.d.ts +4 -0
  16. package/lib/locales/en.d.ts +137 -0
  17. package/lib/locales/en.js +11 -0
  18. package/lib/locales/zh.d.ts +136 -0
  19. package/lib/locales/zh.js +11 -0
  20. package/lib/module-manager.d.ts +20 -0
  21. package/lib/module-manager.js +3 -9
  22. package/lib/modules/app-module.d.ts +2 -0
  23. package/lib/modules/app-module.js +84 -44
  24. package/lib/modules/bundle-module.d.ts +2 -0
  25. package/lib/modules/bundle-module.js +7 -8
  26. package/lib/modules/index.d.ts +6 -0
  27. package/lib/modules/package-module.d.ts +2 -0
  28. package/lib/modules/user-module.d.ts +2 -0
  29. package/lib/modules/user-module.js +55 -44
  30. package/lib/modules/version-module.d.ts +2 -0
  31. package/lib/package.d.ts +58 -0
  32. package/lib/package.js +103 -139
  33. package/lib/provider.d.ts +26 -0
  34. package/lib/provider.js +115 -217
  35. package/lib/types.d.ts +120 -0
  36. package/lib/user.d.ts +8 -0
  37. package/lib/utils/add-gitignore.d.ts +1 -0
  38. package/lib/utils/app-info-parser/aab.d.ts +22 -0
  39. package/lib/utils/app-info-parser/aab.js +0 -4
  40. package/lib/utils/app-info-parser/apk.d.ts +14 -0
  41. package/lib/utils/app-info-parser/apk.js +6 -4
  42. package/lib/utils/app-info-parser/app.d.ts +4 -0
  43. package/lib/utils/app-info-parser/app.js +3 -0
  44. package/lib/utils/app-info-parser/index.d.ts +16 -0
  45. package/lib/utils/app-info-parser/index.js +2 -0
  46. package/lib/utils/app-info-parser/ipa.d.ts +14 -0
  47. package/lib/utils/app-info-parser/ipa.js +1 -1
  48. package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
  49. package/lib/utils/app-info-parser/utils.d.ts +31 -0
  50. package/lib/utils/app-info-parser/utils.js +1 -0
  51. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +56 -0
  52. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +10 -0
  53. package/lib/utils/app-info-parser/zip.d.ts +18 -0
  54. package/lib/utils/app-info-parser/zip.js +7 -9
  55. package/lib/utils/check-lockfile.d.ts +1 -0
  56. package/lib/utils/check-plugin.d.ts +7 -0
  57. package/lib/utils/command-result.d.ts +3 -0
  58. package/lib/utils/command-result.js +35 -0
  59. package/lib/utils/constants.d.ts +9 -0
  60. package/lib/utils/dep-versions.d.ts +1 -0
  61. package/lib/utils/git.d.ts +8 -0
  62. package/lib/utils/http-helper.d.ts +4 -0
  63. package/lib/utils/i18n.d.ts +12 -0
  64. package/lib/utils/index.d.ts +22 -0
  65. package/lib/utils/index.js +52 -22
  66. package/lib/utils/latest-version/cli.d.ts +1 -0
  67. package/lib/utils/latest-version/cli.js +24 -60
  68. package/lib/utils/latest-version/index.d.ts +146 -0
  69. package/lib/utils/latest-version/index.js +22 -22
  70. package/lib/utils/options.d.ts +4 -0
  71. package/lib/utils/options.js +63 -0
  72. package/lib/utils/plugin-config.d.ts +9 -0
  73. package/lib/utils/zip-entries.d.ts +3 -0
  74. package/lib/versions.d.ts +43 -0
  75. package/lib/versions.js +186 -2
  76. package/lib/workflow-runner.d.ts +2 -0
  77. package/lib/workflow-runner.js +25 -0
  78. package/package.json +20 -5
  79. package/src/api.ts +1 -1
  80. package/src/app.ts +20 -11
  81. package/src/bundle-pack.ts +51 -0
  82. package/src/bundle-runner.ts +463 -0
  83. package/src/bundle.ts +184 -571
  84. package/src/diff.ts +208 -174
  85. package/src/index.ts +15 -17
  86. package/src/locales/en.ts +15 -0
  87. package/src/locales/zh.ts +13 -0
  88. package/src/module-manager.ts +15 -15
  89. package/src/modules/app-module.ts +120 -48
  90. package/src/modules/bundle-module.ts +21 -11
  91. package/src/modules/package-module.ts +0 -1
  92. package/src/modules/user-module.ts +117 -58
  93. package/src/package.ts +158 -138
  94. package/src/provider.ts +164 -240
  95. package/src/types.ts +15 -8
  96. package/src/utils/app-info-parser/aab.ts +0 -7
  97. package/src/utils/app-info-parser/apk.ts +9 -6
  98. package/src/utils/app-info-parser/app.ts +5 -1
  99. package/src/utils/app-info-parser/index.ts +11 -6
  100. package/src/utils/app-info-parser/ipa.ts +1 -1
  101. package/src/utils/app-info-parser/utils.ts +3 -0
  102. package/src/utils/app-info-parser/xml-parser/manifest.ts +3 -1
  103. package/src/utils/app-info-parser/zip.ts +12 -14
  104. package/src/utils/command-result.ts +24 -0
  105. package/src/utils/index.ts +138 -39
  106. package/src/utils/latest-version/cli.ts +22 -20
  107. package/src/utils/latest-version/index.ts +20 -20
  108. package/src/utils/options.ts +56 -0
  109. package/src/utils/zip-entries.ts +1 -1
  110. package/src/versions.ts +265 -2
  111. package/src/workflow-runner.ts +24 -0
  112. package/index.js +0 -1
package/lib/versions.js CHANGED
@@ -21,6 +21,7 @@ const _utils = require("./utils");
21
21
  const _i18n = require("./utils/i18n");
22
22
  const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
23
23
  const _compareversions = require("compare-versions");
24
+ const _ttytable = /*#__PURE__*/ _interop_require_default(require("tty-table"));
24
25
  const _app = require("./app");
25
26
  const _package = require("./package");
26
27
  const _depversions = require("./utils/dep-versions");
@@ -30,6 +31,181 @@ function _interop_require_default(obj) {
30
31
  default: obj
31
32
  };
32
33
  }
34
+ function normalizeDeps(input) {
35
+ if (!input) {
36
+ return undefined;
37
+ }
38
+ let raw = input;
39
+ if (typeof input === 'string') {
40
+ try {
41
+ raw = JSON.parse(input);
42
+ } catch (_e) {
43
+ return undefined;
44
+ }
45
+ }
46
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
47
+ return undefined;
48
+ }
49
+ const deps = {};
50
+ for (const [name, version] of Object.entries(raw)){
51
+ if (typeof version === 'string' && version) {
52
+ deps[name] = version;
53
+ }
54
+ }
55
+ return Object.keys(deps).length > 0 ? deps : undefined;
56
+ }
57
+ function getDepsChanges(oldDeps, newDeps) {
58
+ if (!oldDeps || !newDeps) {
59
+ return [];
60
+ }
61
+ const rows = [];
62
+ const keys = Object.keys({
63
+ ...oldDeps,
64
+ ...newDeps
65
+ }).sort((a, b)=>a.localeCompare(b));
66
+ for (const key of keys){
67
+ const oldVersion = oldDeps[key];
68
+ const newVersion = newDeps[key];
69
+ if (oldVersion === undefined && newVersion !== undefined) {
70
+ rows.push({
71
+ dependency: key,
72
+ oldVersion: '-',
73
+ newVersion,
74
+ type: 'added'
75
+ });
76
+ continue;
77
+ }
78
+ if (oldVersion !== undefined && newVersion === undefined) {
79
+ rows.push({
80
+ dependency: key,
81
+ oldVersion,
82
+ newVersion: '-',
83
+ type: 'removed'
84
+ });
85
+ continue;
86
+ }
87
+ if (oldVersion !== undefined && newVersion !== undefined && oldVersion !== newVersion) {
88
+ rows.push({
89
+ dependency: key,
90
+ oldVersion,
91
+ newVersion,
92
+ type: 'changed'
93
+ });
94
+ }
95
+ }
96
+ return rows;
97
+ }
98
+ function getDepsChangeSummary(changes) {
99
+ return changes.reduce((acc, item)=>{
100
+ if (item.type === 'added') {
101
+ acc.added += 1;
102
+ } else if (item.type === 'removed') {
103
+ acc.removed += 1;
104
+ } else {
105
+ acc.changed += 1;
106
+ }
107
+ return acc;
108
+ }, {
109
+ added: 0,
110
+ removed: 0,
111
+ changed: 0
112
+ });
113
+ }
114
+ function renderVersionChange(change) {
115
+ const arrow = _chalk.default.gray(` ${(0, _i18n.t)('depsChangeArrow')} `);
116
+ if (change.type === 'added') {
117
+ return `${_chalk.default.red((0, _i18n.t)('depsChangeAddedLabel'))} | ${_chalk.default.gray(change.oldVersion)}${arrow}${_chalk.default.red(change.newVersion)}`;
118
+ }
119
+ if (change.type === 'removed') {
120
+ return `${_chalk.default.green((0, _i18n.t)('depsChangeRemovedLabel'))} | ${_chalk.default.green(change.oldVersion)}${arrow}${_chalk.default.gray(change.newVersion)}`;
121
+ }
122
+ return `${_chalk.default.yellow((0, _i18n.t)('depsChangeChangedLabel'))} | ${_chalk.default.yellow(change.oldVersion)}${arrow}${_chalk.default.yellow(change.newVersion)}`;
123
+ }
124
+ function printDepsChangesForPackage({ pkg, versionDeps }) {
125
+ const pkgDeps = normalizeDeps(pkg.deps);
126
+ if (!pkgDeps) {
127
+ return false;
128
+ }
129
+ const changes = getDepsChanges(pkgDeps, versionDeps);
130
+ if (changes.length === 0) {
131
+ return false;
132
+ }
133
+ const summary = getDepsChangeSummary(changes);
134
+ const summaryText = (0, _i18n.t)('depsChangeSummary', {
135
+ added: _chalk.default.red(String(summary.added)),
136
+ removed: _chalk.default.green(String(summary.removed)),
137
+ changed: _chalk.default.yellow(String(summary.changed))
138
+ });
139
+ const header = [
140
+ {
141
+ value: (0, _i18n.t)('depsChangeDependencyHeader')
142
+ },
143
+ {
144
+ value: (0, _i18n.t)('depsChangeVersionHeader')
145
+ }
146
+ ];
147
+ const rows = changes.map((change)=>[
148
+ change.dependency,
149
+ renderVersionChange(change)
150
+ ]);
151
+ console.log('');
152
+ console.log(_chalk.default.yellow((0, _i18n.t)('depsChangeTargetPackage', {
153
+ packageName: pkg.name,
154
+ packageId: pkg.id
155
+ })));
156
+ console.log(summaryText);
157
+ console.log((0, _ttytable.default)(header, rows).render());
158
+ console.log(_chalk.default.yellow((0, _i18n.t)('depsChangeRiskWarning')));
159
+ return true;
160
+ }
161
+ async function findVersionDeps(appId, versionId) {
162
+ const targetId = String(versionId);
163
+ const limit = 100;
164
+ let offset = 0;
165
+ while(true){
166
+ const { data, count } = await (0, _api.get)(`/app/${appId}/version/list?offset=${offset}&limit=${limit}`);
167
+ const versions = Array.isArray(data) ? data : [];
168
+ const version = versions.find((item)=>String(item.id) === targetId);
169
+ if (version) {
170
+ return normalizeDeps(version.deps);
171
+ }
172
+ offset += versions.length;
173
+ if (versions.length === 0 || offset >= Number(count || 0)) {
174
+ break;
175
+ }
176
+ }
177
+ return undefined;
178
+ }
179
+ async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVersionDeps }) {
180
+ if (!versionId || pkgs.length === 0) {
181
+ return;
182
+ }
183
+ let versionDeps = normalizeDeps(providedVersionDeps);
184
+ if (!versionDeps) {
185
+ try {
186
+ versionDeps = await findVersionDeps(appId, versionId);
187
+ } catch (error) {
188
+ console.warn(_chalk.default.yellow((0, _i18n.t)('depsChangeFetchFailed', {
189
+ error: (error == null ? void 0 : error.message) || String(error)
190
+ })));
191
+ return;
192
+ }
193
+ }
194
+ if (!versionDeps) {
195
+ return;
196
+ }
197
+ let hasChanges = false;
198
+ for (const pkg of pkgs){
199
+ const printed = printDepsChangesForPackage({
200
+ pkg,
201
+ versionDeps
202
+ });
203
+ hasChanges = hasChanges || printed;
204
+ }
205
+ if (hasChanges) {
206
+ console.log(_chalk.default.yellow((0, _i18n.t)('depsChangeNonBlockingHint')));
207
+ }
208
+ }
33
209
  async function showVersion(appId, offset) {
34
210
  const { data, count } = await (0, _api.get)(`/app/${appId}/version/list`);
35
211
  console.log((0, _i18n.t)('offset', {
@@ -164,7 +340,8 @@ const versionCommands = {
164
340
  minPackageVersion,
165
341
  maxPackageVersion,
166
342
  rollout,
167
- dryRun
343
+ dryRun,
344
+ versionDeps: _depversions.depVersions
168
345
  }
169
346
  });
170
347
  } else {
@@ -173,7 +350,8 @@ const versionCommands = {
173
350
  await this.update({
174
351
  options: {
175
352
  versionId: id,
176
- platform
353
+ platform,
354
+ versionDeps: _depversions.depVersions
177
355
  }
178
356
  });
179
357
  }
@@ -269,6 +447,12 @@ const versionCommands = {
269
447
  }));
270
448
  }
271
449
  }
450
+ await printDepsChangesForPublish({
451
+ appId,
452
+ versionId,
453
+ pkgs: pkgsToBind,
454
+ providedVersionDeps: options.versionDeps
455
+ });
272
456
  await bindVersionToPackages({
273
457
  appId,
274
458
  versionId,
@@ -0,0 +1,2 @@
1
+ import type { CommandContext, CustomWorkflow } from './types';
2
+ export declare function runWorkflow(workflowName: string, workflow: CustomWorkflow, context: CommandContext): Promise<unknown>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "runWorkflow", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return runWorkflow;
9
+ }
10
+ });
11
+ async function runWorkflow(workflowName, workflow, context) {
12
+ if (workflow.validate && !workflow.validate(context)) {
13
+ throw new Error(`Workflow '${workflowName}' validation failed`);
14
+ }
15
+ let previousResult;
16
+ for (const step of workflow.steps){
17
+ if (step.condition && !step.condition(context)) {
18
+ console.log(`Skipping step '${step.name}' due to condition`);
19
+ continue;
20
+ }
21
+ console.log(`Executing step '${step.name}'`);
22
+ previousResult = await step.execute(context, previousResult);
23
+ }
24
+ return previousResult;
25
+ }
package/package.json CHANGED
@@ -1,12 +1,25 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.8.4",
3
+ "version": "2.9.0",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
- "main": "index.js",
5
+ "main": "lib/exports.js",
6
+ "types": "lib/exports.d.ts",
6
7
  "bin": {
7
8
  "pushy": "lib/index.js",
8
9
  "cresc": "lib/index.js"
9
10
  },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./lib/exports.d.ts",
14
+ "require": "./lib/exports.js",
15
+ "default": "./lib/exports.js"
16
+ },
17
+ "./cli": {
18
+ "types": "./lib/index.d.ts",
19
+ "require": "./lib/index.js",
20
+ "default": "./lib/index.js"
21
+ }
22
+ },
10
23
  "files": [
11
24
  "lib",
12
25
  "src",
@@ -14,9 +27,11 @@
14
27
  "cli.json"
15
28
  ],
16
29
  "scripts": {
17
- "build": "swc src -d lib --strip-leading-paths",
18
- "prepublishOnly": "bun scripts/prepublish.js && bun run build && chmod +x lib/index.js",
19
- "lint": "tsc --noEmit & biome check --write ."
30
+ "build": "rm -rf lib && swc src -d lib --strip-leading-paths && tsc -p tsconfig.build.json",
31
+ "prepublishOnly": "bun scripts/prepublish.ts && bun run build && chmod +x lib/index.js",
32
+ "lint": "tsc --noEmit && biome check --write .",
33
+ "test": "bun test",
34
+ "test:coverage": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov"
20
35
  },
21
36
  "repository": {
22
37
  "type": "git",
package/src/api.ts CHANGED
@@ -9,7 +9,7 @@ import tcpp from 'tcp-ping';
9
9
  import { getBaseUrl } from 'utils/http-helper';
10
10
  import packageJson from '../package.json';
11
11
  import type { Package, Session } from './types';
12
- import { credentialFile, pricingPageUrl, IS_CRESC } from './utils/constants';
12
+ import { IS_CRESC, credentialFile, pricingPageUrl } from './utils/constants';
13
13
  import { t } from './utils/i18n';
14
14
 
15
15
  const tcpPing = util.promisify(tcpp.ping);
package/src/app.ts CHANGED
@@ -6,7 +6,13 @@ import { doDelete, get, post } from './api';
6
6
  import type { Platform } from './types';
7
7
  import { t } from './utils/i18n';
8
8
 
9
- const validPlatforms = ['ios', 'android', 'harmony'];
9
+ interface AppSummary {
10
+ id: number;
11
+ name: string;
12
+ platform: Platform;
13
+ }
14
+
15
+ const validPlatforms = ['ios', 'android', 'harmony'] as const;
10
16
 
11
17
  export async function getPlatform(platform?: string) {
12
18
  return assertPlatform(
@@ -14,11 +20,11 @@ export async function getPlatform(platform?: string) {
14
20
  ) as Platform;
15
21
  }
16
22
 
17
- export function assertPlatform(platform: string) {
18
- if (!validPlatforms.includes(platform)) {
23
+ export function assertPlatform(platform: string): Platform {
24
+ if (!validPlatforms.includes(platform as Platform)) {
19
25
  throw new Error(t('unsupportedPlatform', { platform }));
20
26
  }
21
- return platform;
27
+ return platform as Platform;
22
28
  }
23
29
 
24
30
  export function getSelectedApp(platform: Platform) {
@@ -36,7 +42,10 @@ export function getSelectedApp(platform: Platform) {
36
42
 
37
43
  export async function listApp(platform: Platform | '' = '') {
38
44
  const { data } = await get('/app/list');
39
- const list = platform ? data.filter((v) => v.platform === platform) : data;
45
+ const allApps = data as AppSummary[];
46
+ const list = platform
47
+ ? allApps.filter((app: AppSummary) => app.platform === platform)
48
+ : allApps;
40
49
 
41
50
  const header = [
42
51
  { value: t('appId') },
@@ -59,7 +68,7 @@ export async function chooseApp(platform: Platform) {
59
68
 
60
69
  while (true) {
61
70
  const id = await question(t('enterAppIdQuestion'));
62
- const app = list.find((v) => v.id === Number(id));
71
+ const app = list.find((item: AppSummary) => item.id === Number(id));
63
72
  if (app) {
64
73
  return app;
65
74
  }
@@ -70,7 +79,7 @@ export const appCommands = {
70
79
  createApp: async function ({
71
80
  options,
72
81
  }: {
73
- options: { name: string; downloadUrl: string; platform: Platform };
82
+ options: { name: string; downloadUrl: string; platform?: Platform | '' };
74
83
  }) {
75
84
  const name = options.name || (await question(t('appNameQuestion')));
76
85
  const { downloadUrl } = options;
@@ -97,16 +106,16 @@ export const appCommands = {
97
106
  await doDelete(`/app/${id}`);
98
107
  console.log(t('operationSuccess'));
99
108
  },
100
- apps: async ({ options }: { options: { platform: Platform } }) => {
101
- const { platform } = options;
102
- listApp(platform);
109
+ apps: async ({ options }: { options: { platform?: Platform | '' } }) => {
110
+ const { platform = '' } = options;
111
+ await listApp(platform);
103
112
  },
104
113
  selectApp: async ({
105
114
  args,
106
115
  options,
107
116
  }: {
108
117
  args: string[];
109
- options: { platform: Platform };
118
+ options: { platform?: Platform | '' };
110
119
  }) => {
111
120
  const platform = await getPlatform(options.platform);
112
121
  const id = args[0]
@@ -0,0 +1,51 @@
1
+ import path from 'path';
2
+ import * as fs from 'fs-extra';
3
+ import { ZipFile as YazlZipFile } from 'yazl';
4
+ import { t } from './utils/i18n';
5
+
6
+ const ignorePackingFileNames = [
7
+ '.',
8
+ '..',
9
+ 'index.bundlejs.map',
10
+ 'bundle.harmony.js.map',
11
+ ];
12
+ const ignorePackingExtensions = ['DS_Store', 'txt.map'];
13
+
14
+ export async function packBundle(dir: string, output: string): Promise<void> {
15
+ console.log(t('packing'));
16
+ fs.ensureDirSync(path.dirname(output));
17
+ await new Promise<void>((resolve, reject) => {
18
+ const zipfile = new YazlZipFile();
19
+
20
+ function addDirectory(root: string, rel: string) {
21
+ if (rel) {
22
+ zipfile.addEmptyDirectory(rel);
23
+ }
24
+ const children = fs.readdirSync(root);
25
+ for (const name of children) {
26
+ if (
27
+ ignorePackingFileNames.includes(name) ||
28
+ ignorePackingExtensions.some((ext) => name.endsWith(`.${ext}`))
29
+ ) {
30
+ continue;
31
+ }
32
+ const fullPath = path.join(root, name);
33
+ const stat = fs.statSync(fullPath);
34
+ if (stat.isFile()) {
35
+ zipfile.addFile(fullPath, rel + name);
36
+ } else if (stat.isDirectory()) {
37
+ addDirectory(fullPath, `${rel}${name}/`);
38
+ }
39
+ }
40
+ }
41
+
42
+ addDirectory(dir, '');
43
+
44
+ zipfile.outputStream.on('error', (err: unknown) => reject(err));
45
+ zipfile.outputStream.pipe(fs.createWriteStream(output)).on('close', () => {
46
+ resolve();
47
+ });
48
+ zipfile.end();
49
+ });
50
+ console.log(t('fileGenerated', { file: output }));
51
+ }