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/src/versions.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { get, getAllPackages, post, put, uploadFile, doDelete } from './api';
1
+ import { doDelete, get, getAllPackages, post, put, uploadFile } from './api';
2
2
  import { question, saveToLocal } from './utils';
3
3
  import { t } from './utils/i18n';
4
4
 
5
5
  import chalk from 'chalk';
6
6
  import { satisfies } from 'compare-versions';
7
+ import Table from 'tty-table';
7
8
  import { getPlatform, getSelectedApp } from './app';
8
9
  import { choosePackage } from './package';
9
10
  import type { Package, Platform, Version } from './types';
@@ -24,6 +25,258 @@ interface VersionCommandOptions {
24
25
  packageVersionRange?: string;
25
26
  rollout?: string;
26
27
  dryRun?: boolean;
28
+ versionDeps?: Record<string, string>;
29
+ }
30
+
31
+ type Deps = Record<string, string>;
32
+ type DepChangeType = 'added' | 'removed' | 'changed';
33
+
34
+ interface DepChange {
35
+ dependency: string;
36
+ oldVersion: string;
37
+ newVersion: string;
38
+ type: DepChangeType;
39
+ }
40
+
41
+ interface DepsChangeSummary {
42
+ added: number;
43
+ removed: number;
44
+ changed: number;
45
+ }
46
+
47
+ function normalizeDeps(input: unknown): Deps | undefined {
48
+ if (!input) {
49
+ return undefined;
50
+ }
51
+
52
+ let raw: unknown = input;
53
+ if (typeof input === 'string') {
54
+ try {
55
+ raw = JSON.parse(input);
56
+ } catch (_e) {
57
+ return undefined;
58
+ }
59
+ }
60
+
61
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
62
+ return undefined;
63
+ }
64
+
65
+ const deps: Deps = {};
66
+ for (const [name, version] of Object.entries(
67
+ raw as Record<string, unknown>,
68
+ )) {
69
+ if (typeof version === 'string' && version) {
70
+ deps[name] = version;
71
+ }
72
+ }
73
+
74
+ return Object.keys(deps).length > 0 ? deps : undefined;
75
+ }
76
+
77
+ function getDepsChanges(oldDeps?: Deps, newDeps?: Deps): DepChange[] {
78
+ if (!oldDeps || !newDeps) {
79
+ return [];
80
+ }
81
+
82
+ const rows: DepChange[] = [];
83
+ const keys = Object.keys({ ...oldDeps, ...newDeps }).sort((a, b) =>
84
+ a.localeCompare(b),
85
+ );
86
+
87
+ for (const key of keys) {
88
+ const oldVersion = oldDeps[key];
89
+ const newVersion = newDeps[key];
90
+
91
+ if (oldVersion === undefined && newVersion !== undefined) {
92
+ rows.push({
93
+ dependency: key,
94
+ oldVersion: '-',
95
+ newVersion,
96
+ type: 'added',
97
+ });
98
+ continue;
99
+ }
100
+
101
+ if (oldVersion !== undefined && newVersion === undefined) {
102
+ rows.push({
103
+ dependency: key,
104
+ oldVersion,
105
+ newVersion: '-',
106
+ type: 'removed',
107
+ });
108
+ continue;
109
+ }
110
+
111
+ if (
112
+ oldVersion !== undefined &&
113
+ newVersion !== undefined &&
114
+ oldVersion !== newVersion
115
+ ) {
116
+ rows.push({
117
+ dependency: key,
118
+ oldVersion,
119
+ newVersion,
120
+ type: 'changed',
121
+ });
122
+ }
123
+ }
124
+
125
+ return rows;
126
+ }
127
+
128
+ function getDepsChangeSummary(changes: DepChange[]): DepsChangeSummary {
129
+ return changes.reduce(
130
+ (acc, item) => {
131
+ if (item.type === 'added') {
132
+ acc.added += 1;
133
+ } else if (item.type === 'removed') {
134
+ acc.removed += 1;
135
+ } else {
136
+ acc.changed += 1;
137
+ }
138
+ return acc;
139
+ },
140
+ { added: 0, removed: 0, changed: 0 },
141
+ );
142
+ }
143
+
144
+ function renderVersionChange(change: DepChange) {
145
+ const arrow = chalk.gray(` ${t('depsChangeArrow')} `);
146
+
147
+ if (change.type === 'added') {
148
+ return `${chalk.red(t('depsChangeAddedLabel'))} | ${chalk.gray(
149
+ change.oldVersion,
150
+ )}${arrow}${chalk.red(change.newVersion)}`;
151
+ }
152
+
153
+ if (change.type === 'removed') {
154
+ return `${chalk.green(t('depsChangeRemovedLabel'))} | ${chalk.green(
155
+ change.oldVersion,
156
+ )}${arrow}${chalk.gray(change.newVersion)}`;
157
+ }
158
+
159
+ return `${chalk.yellow(t('depsChangeChangedLabel'))} | ${chalk.yellow(
160
+ change.oldVersion,
161
+ )}${arrow}${chalk.yellow(change.newVersion)}`;
162
+ }
163
+
164
+ function printDepsChangesForPackage({
165
+ pkg,
166
+ versionDeps,
167
+ }: {
168
+ pkg: Package;
169
+ versionDeps: Deps;
170
+ }) {
171
+ const pkgDeps = normalizeDeps(pkg.deps);
172
+ if (!pkgDeps) {
173
+ return false;
174
+ }
175
+
176
+ const changes = getDepsChanges(pkgDeps, versionDeps);
177
+ if (changes.length === 0) {
178
+ return false;
179
+ }
180
+
181
+ const summary = getDepsChangeSummary(changes);
182
+ const summaryText = t('depsChangeSummary', {
183
+ added: chalk.red(String(summary.added)),
184
+ removed: chalk.green(String(summary.removed)),
185
+ changed: chalk.yellow(String(summary.changed)),
186
+ });
187
+ const header = [
188
+ { value: t('depsChangeDependencyHeader') },
189
+ { value: t('depsChangeVersionHeader') },
190
+ ];
191
+ const rows = changes.map((change) => [
192
+ change.dependency,
193
+ renderVersionChange(change),
194
+ ]);
195
+
196
+ console.log('');
197
+ console.log(
198
+ chalk.yellow(
199
+ t('depsChangeTargetPackage', {
200
+ packageName: pkg.name,
201
+ packageId: pkg.id,
202
+ }),
203
+ ),
204
+ );
205
+ console.log(summaryText);
206
+ console.log(Table(header, rows).render());
207
+ console.log(chalk.yellow(t('depsChangeRiskWarning')));
208
+ return true;
209
+ }
210
+
211
+ async function findVersionDeps(appId: string, versionId: string) {
212
+ const targetId = String(versionId);
213
+ const limit = 100;
214
+ let offset = 0;
215
+
216
+ while (true) {
217
+ const { data, count } = await get(
218
+ `/app/${appId}/version/list?offset=${offset}&limit=${limit}`,
219
+ );
220
+ const versions: Version[] = Array.isArray(data) ? data : [];
221
+ const version = versions.find((item) => String(item.id) === targetId);
222
+
223
+ if (version) {
224
+ return normalizeDeps(version.deps);
225
+ }
226
+
227
+ offset += versions.length;
228
+ if (versions.length === 0 || offset >= Number(count || 0)) {
229
+ break;
230
+ }
231
+ }
232
+
233
+ return undefined;
234
+ }
235
+
236
+ async function printDepsChangesForPublish({
237
+ appId,
238
+ versionId,
239
+ pkgs,
240
+ providedVersionDeps,
241
+ }: {
242
+ appId: string;
243
+ versionId?: string;
244
+ pkgs: Package[];
245
+ providedVersionDeps?: Deps;
246
+ }) {
247
+ if (!versionId || pkgs.length === 0) {
248
+ return;
249
+ }
250
+
251
+ let versionDeps = normalizeDeps(providedVersionDeps);
252
+ if (!versionDeps) {
253
+ try {
254
+ versionDeps = await findVersionDeps(appId, versionId);
255
+ } catch (error: any) {
256
+ console.warn(
257
+ chalk.yellow(
258
+ t('depsChangeFetchFailed', {
259
+ error: error?.message || String(error),
260
+ }),
261
+ ),
262
+ );
263
+ return;
264
+ }
265
+ }
266
+
267
+ if (!versionDeps) {
268
+ return;
269
+ }
270
+
271
+ let hasChanges = false;
272
+ for (const pkg of pkgs) {
273
+ const printed = printDepsChangesForPackage({ pkg, versionDeps });
274
+ hasChanges = hasChanges || printed;
275
+ }
276
+
277
+ if (hasChanges) {
278
+ console.log(chalk.yellow(t('depsChangeNonBlockingHint')));
279
+ }
27
280
  }
28
281
 
29
282
  async function showVersion(appId: string, offset: number) {
@@ -211,12 +464,15 @@ export const versionCommands = {
211
464
  maxPackageVersion,
212
465
  rollout,
213
466
  dryRun,
467
+ versionDeps: depVersions,
214
468
  },
215
469
  });
216
470
  } else {
217
471
  const q = await question(t('updateNativePackageQuestion'));
218
472
  if (q.toLowerCase() === 'y') {
219
- await this.update({ options: { versionId: id, platform } });
473
+ await this.update({
474
+ options: { versionId: id, platform, versionDeps: depVersions },
475
+ });
220
476
  }
221
477
  }
222
478
  return versionName;
@@ -318,6 +574,13 @@ export const versionCommands = {
318
574
  }
319
575
  }
320
576
 
577
+ await printDepsChangesForPublish({
578
+ appId,
579
+ versionId,
580
+ pkgs: pkgsToBind,
581
+ providedVersionDeps: options.versionDeps,
582
+ });
583
+
321
584
  await bindVersionToPackages({
322
585
  appId,
323
586
  versionId,
@@ -0,0 +1,24 @@
1
+ import type { CommandContext, CustomWorkflow } from './types';
2
+
3
+ export async function runWorkflow(
4
+ workflowName: string,
5
+ workflow: CustomWorkflow,
6
+ context: CommandContext,
7
+ ): Promise<unknown> {
8
+ if (workflow.validate && !workflow.validate(context)) {
9
+ throw new Error(`Workflow '${workflowName}' validation failed`);
10
+ }
11
+
12
+ let previousResult: unknown;
13
+ for (const step of workflow.steps) {
14
+ if (step.condition && !step.condition(context)) {
15
+ console.log(`Skipping step '${step.name}' due to condition`);
16
+ continue;
17
+ }
18
+
19
+ console.log(`Executing step '${step.name}'`);
20
+ previousResult = await step.execute(context, previousResult);
21
+ }
22
+
23
+ return previousResult;
24
+ }
package/index.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./lib');