react-native-update-cli 2.8.5 → 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 (106) 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/zh.d.ts +136 -0
  18. package/lib/module-manager.d.ts +20 -0
  19. package/lib/module-manager.js +3 -9
  20. package/lib/modules/app-module.d.ts +2 -0
  21. package/lib/modules/app-module.js +84 -44
  22. package/lib/modules/bundle-module.d.ts +2 -0
  23. package/lib/modules/bundle-module.js +7 -8
  24. package/lib/modules/index.d.ts +6 -0
  25. package/lib/modules/package-module.d.ts +2 -0
  26. package/lib/modules/user-module.d.ts +2 -0
  27. package/lib/modules/user-module.js +55 -44
  28. package/lib/modules/version-module.d.ts +2 -0
  29. package/lib/package.d.ts +58 -0
  30. package/lib/package.js +103 -139
  31. package/lib/provider.d.ts +26 -0
  32. package/lib/provider.js +115 -217
  33. package/lib/types.d.ts +120 -0
  34. package/lib/user.d.ts +8 -0
  35. package/lib/utils/add-gitignore.d.ts +1 -0
  36. package/lib/utils/app-info-parser/aab.d.ts +22 -0
  37. package/lib/utils/app-info-parser/aab.js +0 -4
  38. package/lib/utils/app-info-parser/apk.d.ts +14 -0
  39. package/lib/utils/app-info-parser/apk.js +6 -4
  40. package/lib/utils/app-info-parser/app.d.ts +4 -0
  41. package/lib/utils/app-info-parser/app.js +3 -0
  42. package/lib/utils/app-info-parser/index.d.ts +16 -0
  43. package/lib/utils/app-info-parser/index.js +2 -0
  44. package/lib/utils/app-info-parser/ipa.d.ts +14 -0
  45. package/lib/utils/app-info-parser/ipa.js +1 -1
  46. package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
  47. package/lib/utils/app-info-parser/utils.d.ts +31 -0
  48. package/lib/utils/app-info-parser/utils.js +1 -0
  49. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +56 -0
  50. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +10 -0
  51. package/lib/utils/app-info-parser/zip.d.ts +18 -0
  52. package/lib/utils/app-info-parser/zip.js +7 -9
  53. package/lib/utils/check-lockfile.d.ts +1 -0
  54. package/lib/utils/check-plugin.d.ts +7 -0
  55. package/lib/utils/command-result.d.ts +3 -0
  56. package/lib/utils/command-result.js +35 -0
  57. package/lib/utils/constants.d.ts +9 -0
  58. package/lib/utils/dep-versions.d.ts +1 -0
  59. package/lib/utils/git.d.ts +8 -0
  60. package/lib/utils/http-helper.d.ts +4 -0
  61. package/lib/utils/i18n.d.ts +12 -0
  62. package/lib/utils/index.d.ts +22 -0
  63. package/lib/utils/index.js +52 -22
  64. package/lib/utils/latest-version/cli.d.ts +1 -0
  65. package/lib/utils/latest-version/cli.js +24 -60
  66. package/lib/utils/latest-version/index.d.ts +146 -0
  67. package/lib/utils/latest-version/index.js +22 -22
  68. package/lib/utils/options.d.ts +4 -0
  69. package/lib/utils/options.js +63 -0
  70. package/lib/utils/plugin-config.d.ts +9 -0
  71. package/lib/utils/zip-entries.d.ts +3 -0
  72. package/lib/versions.d.ts +43 -0
  73. package/lib/workflow-runner.d.ts +2 -0
  74. package/lib/workflow-runner.js +25 -0
  75. package/package.json +20 -5
  76. package/src/api.ts +1 -1
  77. package/src/app.ts +20 -11
  78. package/src/bundle-pack.ts +51 -0
  79. package/src/bundle-runner.ts +463 -0
  80. package/src/bundle.ts +184 -571
  81. package/src/diff.ts +208 -174
  82. package/src/index.ts +15 -17
  83. package/src/module-manager.ts +15 -15
  84. package/src/modules/app-module.ts +120 -48
  85. package/src/modules/bundle-module.ts +21 -11
  86. package/src/modules/package-module.ts +0 -1
  87. package/src/modules/user-module.ts +117 -58
  88. package/src/package.ts +158 -138
  89. package/src/provider.ts +164 -240
  90. package/src/types.ts +13 -8
  91. package/src/utils/app-info-parser/aab.ts +0 -7
  92. package/src/utils/app-info-parser/apk.ts +9 -6
  93. package/src/utils/app-info-parser/app.ts +5 -1
  94. package/src/utils/app-info-parser/index.ts +11 -6
  95. package/src/utils/app-info-parser/ipa.ts +1 -1
  96. package/src/utils/app-info-parser/utils.ts +3 -0
  97. package/src/utils/app-info-parser/xml-parser/manifest.ts +3 -1
  98. package/src/utils/app-info-parser/zip.ts +12 -14
  99. package/src/utils/command-result.ts +24 -0
  100. package/src/utils/index.ts +138 -39
  101. package/src/utils/latest-version/cli.ts +22 -20
  102. package/src/utils/latest-version/index.ts +20 -20
  103. package/src/utils/options.ts +56 -0
  104. package/src/utils/zip-entries.ts +1 -1
  105. package/src/workflow-runner.ts +24 -0
  106. package/index.js +0 -1
@@ -1,5 +1,39 @@
1
- import { appCommands } from '../app';
2
- import type { CLIModule, CommandContext } from '../types';
1
+ import { appCommands, listApp } from '../app';
2
+ import type { CLIModule, CommandContext, Platform } from '../types';
3
+ import { getStringOption, toObjectState } from '../utils/options';
4
+
5
+ type WorkflowApp = {
6
+ id: string;
7
+ name: string;
8
+ platform: string;
9
+ version: string;
10
+ status: 'active' | 'inactive';
11
+ };
12
+
13
+ type AppAnalysis = {
14
+ totalApps: number;
15
+ activeApps: number;
16
+ inactiveApps: number;
17
+ platformDistribution: Record<Platform, number>;
18
+ issues: string[];
19
+ };
20
+
21
+ const allPlatforms: Platform[] = ['ios', 'android', 'harmony'];
22
+ const emptyAppsData: Record<Platform, WorkflowApp[]> = {
23
+ ios: [],
24
+ android: [],
25
+ harmony: [],
26
+ };
27
+
28
+ type AppWorkflowState = Record<string, unknown>;
29
+
30
+ function isPlatform(value: unknown): value is Platform {
31
+ return value === 'ios' || value === 'android' || value === 'harmony';
32
+ }
33
+
34
+ function normalizePlatformOption(value: unknown): Platform | '' {
35
+ return isPlatform(value) ? value : '';
36
+ }
3
37
 
4
38
  export const appModule: CLIModule = {
5
39
  name: 'app',
@@ -17,12 +51,14 @@ export const appModule: CLIModule = {
17
51
  description: 'Create the app',
18
52
  execute: async (context: CommandContext) => {
19
53
  console.log('Creating app in workflow');
20
- const { name, downloadUrl, platform } = context.options;
54
+ const name = getStringOption(context.options, 'name');
55
+ const downloadUrl = getStringOption(context.options, 'downloadUrl');
56
+ const platform = normalizePlatformOption(context.options.platform);
21
57
  await appCommands.createApp({
22
58
  options: {
23
- name: name || '',
24
- downloadUrl: downloadUrl || '',
25
- platform: platform || '',
59
+ name,
60
+ downloadUrl,
61
+ platform,
26
62
  },
27
63
  });
28
64
  return { appCreated: true };
@@ -31,14 +67,18 @@ export const appModule: CLIModule = {
31
67
  {
32
68
  name: 'select',
33
69
  description: 'Select the created app',
34
- execute: async (context: CommandContext, previousResult: any) => {
70
+ execute: async (
71
+ context: CommandContext,
72
+ previousResult?: unknown,
73
+ ) => {
35
74
  console.log('Selecting app in workflow');
36
- const { platform } = context.options;
75
+ const state = toObjectState<AppWorkflowState>(previousResult, {});
76
+ const platform = normalizePlatformOption(context.options.platform);
37
77
  await appCommands.selectApp({
38
78
  args: [],
39
- options: { platform: platform || '' },
79
+ options: { platform },
40
80
  });
41
- return { ...previousResult, appSelected: true };
81
+ return { ...state, appSelected: true };
42
82
  },
43
83
  },
44
84
  ],
@@ -52,9 +92,9 @@ export const appModule: CLIModule = {
52
92
  description: 'List all apps',
53
93
  execute: async (context: CommandContext) => {
54
94
  console.log('Listing all apps');
55
- const { platform } = context.options;
95
+ const platform = normalizePlatformOption(context.options.platform);
56
96
  await appCommands.apps({
57
- options: { platform: platform || '' },
97
+ options: { platform },
58
98
  });
59
99
  return { appsListed: true };
60
100
  },
@@ -62,14 +102,18 @@ export const appModule: CLIModule = {
62
102
  {
63
103
  name: 'select-target-app',
64
104
  description: 'Select target app for operations',
65
- execute: async (context: CommandContext, previousResult: any) => {
105
+ execute: async (
106
+ context: CommandContext,
107
+ previousResult?: unknown,
108
+ ) => {
66
109
  console.log('Selecting target app');
67
- const { platform } = context.options;
110
+ const state = toObjectState<AppWorkflowState>(previousResult, {});
111
+ const platform = normalizePlatformOption(context.options.platform);
68
112
  await appCommands.selectApp({
69
113
  args: [],
70
- options: { platform: platform || '' },
114
+ options: { platform },
71
115
  });
72
- return { ...previousResult, targetAppSelected: true };
116
+ return { ...state, targetAppSelected: true };
73
117
  },
74
118
  },
75
119
  ],
@@ -84,50 +128,70 @@ export const appModule: CLIModule = {
84
128
  execute: async (context: CommandContext) => {
85
129
  console.log('🔍 Scanning apps on all platforms...');
86
130
 
87
- const platforms = ['ios', 'android', 'harmony'];
88
- const appsData = {};
131
+ const appsData: Record<Platform, WorkflowApp[]> = {
132
+ ios: [],
133
+ android: [],
134
+ harmony: [],
135
+ };
89
136
 
90
- for (const platform of platforms) {
137
+ for (const platform of allPlatforms) {
91
138
  console.log(` Scanning ${platform} platform...`);
92
139
 
93
- // Simulate getting app list
94
- await new Promise((resolve) => setTimeout(resolve, 500));
95
-
96
- const appCount = Math.floor(Math.random() * 5) + 1;
97
- const apps = Array.from({ length: appCount }, (_, i) => ({
98
- id: `${platform}_app_${i + 1}`,
99
- name: `App ${i + 1}`,
100
- platform,
101
- version: `1.${i}.0`,
102
- status: Math.random() > 0.2 ? 'active' : 'inactive',
103
- }));
104
-
105
- appsData[platform] = apps;
106
- console.log(` ✅ Found ${appCount} apps`);
140
+ try {
141
+ const rawApps = await listApp(platform);
142
+ const apps = rawApps.map((app, index) => ({
143
+ id: String(app.id ?? `${platform}-app-${index + 1}`),
144
+ name: app.name ?? `App ${index + 1}`,
145
+ platform: app.platform ?? platform,
146
+ version:
147
+ typeof (app as { version?: unknown }).version === 'string'
148
+ ? ((app as { version?: string }).version ?? 'unknown')
149
+ : 'unknown',
150
+ status:
151
+ (app as { status?: unknown }).status === 'inactive'
152
+ ? ('inactive' as const)
153
+ : ('active' as const),
154
+ }));
155
+ appsData[platform] = apps;
156
+ console.log(` ✅ Found ${apps.length} apps`);
157
+ } catch (error) {
158
+ appsData[platform] = [];
159
+ console.warn(` ⚠️ Failed to scan ${platform}:`, error);
160
+ }
107
161
  }
108
162
 
109
163
  console.log('✅ Platform scanning completed');
110
164
 
111
- return { platforms, appsData, scanned: true };
165
+ return { platforms: allPlatforms, appsData, scanned: true };
112
166
  },
113
167
  },
114
168
  {
115
169
  name: 'analyze-apps',
116
170
  description: 'Analyze app status',
117
- execute: async (context: CommandContext, previousResult: any) => {
171
+ execute: async (
172
+ context: CommandContext,
173
+ previousResult?: unknown,
174
+ ) => {
118
175
  console.log('📊 Analyzing app status...');
119
176
 
120
- const { appsData } = previousResult;
121
- const analysis = {
177
+ const state = toObjectState<AppWorkflowState>(previousResult, {});
178
+ const appsData =
179
+ (state.appsData as Record<Platform, WorkflowApp[]> | undefined) ??
180
+ emptyAppsData;
181
+ const analysis: AppAnalysis = {
122
182
  totalApps: 0,
123
183
  activeApps: 0,
124
184
  inactiveApps: 0,
125
- platformDistribution: {},
185
+ platformDistribution: {
186
+ ios: 0,
187
+ android: 0,
188
+ harmony: 0,
189
+ },
126
190
  issues: [],
127
191
  };
128
192
 
129
- for (const [platform, apps] of Object.entries(appsData)) {
130
- const platformApps = apps as any[];
193
+ for (const platform of allPlatforms) {
194
+ const platformApps = appsData[platform] ?? [];
131
195
  analysis.totalApps += platformApps.length;
132
196
  analysis.platformDistribution[platform] = platformApps.length;
133
197
 
@@ -150,20 +214,30 @@ export const appModule: CLIModule = {
150
214
 
151
215
  if (analysis.issues.length > 0) {
152
216
  console.log('⚠️ Issues found:');
153
- analysis.issues.forEach((issue) => console.log(` - ${issue}`));
217
+ for (const issue of analysis.issues) {
218
+ console.log(` - ${issue}`);
219
+ }
154
220
  }
155
221
 
156
- return { ...previousResult, analysis };
222
+ return { ...state, analysis };
157
223
  },
158
224
  },
159
225
  {
160
226
  name: 'optimize-apps',
161
227
  description: 'Optimize app configuration',
162
- execute: async (context: CommandContext, previousResult: any) => {
228
+ execute: async (
229
+ context: CommandContext,
230
+ previousResult?: unknown,
231
+ ) => {
163
232
  console.log('⚡ Optimizing app configuration...');
164
233
 
165
- const { analysis } = previousResult;
166
- const optimizations = [];
234
+ const state = toObjectState<AppWorkflowState>(previousResult, {});
235
+ const analysis = state.analysis as AppAnalysis | undefined;
236
+ if (!analysis) {
237
+ console.log(' No analysis data, skip optimization');
238
+ return { ...state, optimizations: [], optimized: false };
239
+ }
240
+ const optimizations: string[] = [];
167
241
 
168
242
  if (analysis.inactiveApps > 0) {
169
243
  console.log(' Handling inactive apps...');
@@ -175,16 +249,14 @@ export const appModule: CLIModule = {
175
249
  optimizations.push('Create app groups');
176
250
  }
177
251
 
178
- // Simulate optimization process
179
252
  for (const optimization of optimizations) {
180
253
  console.log(` Executing: ${optimization}...`);
181
- await new Promise((resolve) => setTimeout(resolve, 800));
182
254
  console.log(` ✅ ${optimization} completed`);
183
255
  }
184
256
 
185
257
  console.log('✅ App optimization completed');
186
258
 
187
- return { ...previousResult, optimizations, optimized: true };
259
+ return { ...state, optimizations, optimized: true };
188
260
  },
189
261
  },
190
262
  ],
@@ -18,17 +18,14 @@ export const bundleModule: CLIModule = {
18
18
  execute: async (context: CommandContext) => {
19
19
  console.log('🔍 Detecting base version...');
20
20
 
21
- const { baseVersion, platform } = context.options;
21
+ const { baseVersion } = context.options;
22
22
 
23
23
  if (baseVersion) {
24
24
  console.log(`✅ Using specified base version: ${baseVersion}`);
25
25
  return { baseVersion, specified: true };
26
26
  }
27
27
 
28
- console.log('Auto detecting latest version...');
29
- await new Promise((resolve) => setTimeout(resolve, 800));
30
-
31
- const autoDetectedVersion = `v${Math.floor(Math.random() * 3) + 1}.${Math.floor(Math.random() * 10)}.${Math.floor(Math.random() * 10)}`;
28
+ const autoDetectedVersion = 'latest';
32
29
 
33
30
  console.log(
34
31
  `✅ Auto detected base version: ${autoDetectedVersion}`,
@@ -40,8 +37,15 @@ export const bundleModule: CLIModule = {
40
37
  {
41
38
  name: 'build-current-version',
42
39
  description: 'Build current version',
43
- execute: async (context: CommandContext, previousResult: any) => {
40
+ execute: async (
41
+ context: CommandContext,
42
+ previousResult?: unknown,
43
+ ) => {
44
44
  console.log('🏗️ Building current version...');
45
+ const state =
46
+ previousResult && typeof previousResult === 'object'
47
+ ? (previousResult as Record<string, unknown>)
48
+ : {};
45
49
 
46
50
  const {
47
51
  platform,
@@ -64,7 +68,7 @@ export const bundleModule: CLIModule = {
64
68
  console.log(` Source maps: ${sourcemap}`);
65
69
 
66
70
  try {
67
- const buildOptions: any = {
71
+ const buildOptions: Record<string, unknown> = {
68
72
  platform,
69
73
  dev,
70
74
  sourcemap,
@@ -86,11 +90,17 @@ export const bundleModule: CLIModule = {
86
90
  options: buildOptions,
87
91
  });
88
92
 
93
+ const bundlePath =
94
+ typeof output === 'string'
95
+ ? output
96
+ : '${tempDir}/output/${platform}.${time}.ppk';
89
97
  const currentBuild = {
90
- version: `v${Math.floor(Math.random() * 3) + 2}.0.0`,
98
+ version:
99
+ typeof state.baseVersion === 'string'
100
+ ? state.baseVersion
101
+ : 'current',
91
102
  platform,
92
- bundlePath: `./build/current_${platform}.ppk`,
93
- size: Math.floor(Math.random() * 15) + 10,
103
+ bundlePath,
94
104
  buildTime: Date.now(),
95
105
  };
96
106
 
@@ -98,7 +108,7 @@ export const bundleModule: CLIModule = {
98
108
  `✅ Current version build completed: ${currentBuild.version}`,
99
109
  );
100
110
 
101
- return { ...previousResult, currentBuild };
111
+ return { ...state, currentBuild };
102
112
  } catch (error) {
103
113
  console.error('❌ Current version build failed:', error);
104
114
  throw error;
@@ -1,4 +1,3 @@
1
- import { packageCommands } from '../package';
2
1
  import type { CLIModule } from '../types';
3
2
 
4
3
  export const packageModule: CLIModule = {