react-native-update-cli 1.46.2 → 2.0.1

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 (68) hide show
  1. package/README.md +603 -1
  2. package/README.zh-CN.md +601 -0
  3. package/cli.json +39 -3
  4. package/lib/api.js +5 -5
  5. package/lib/app.js +1 -1
  6. package/lib/bundle.js +30 -28
  7. package/lib/exports.js +65 -0
  8. package/lib/index.js +100 -9
  9. package/lib/locales/en.js +2 -1
  10. package/lib/locales/zh.js +2 -1
  11. package/lib/module-manager.js +125 -0
  12. package/lib/modules/app-module.js +223 -0
  13. package/lib/modules/bundle-module.js +188 -0
  14. package/lib/modules/index.js +42 -0
  15. package/lib/modules/package-module.js +16 -0
  16. package/lib/modules/user-module.js +402 -0
  17. package/lib/modules/version-module.js +16 -0
  18. package/lib/package.js +40 -9
  19. package/lib/provider.js +341 -0
  20. package/lib/user.js +3 -3
  21. package/lib/utils/app-info-parser/apk.js +1 -1
  22. package/lib/utils/app-info-parser/ipa.js +2 -2
  23. package/lib/utils/app-info-parser/resource-finder.js +35 -35
  24. package/lib/utils/app-info-parser/xml-parser/manifest.js +2 -2
  25. package/lib/utils/app-info-parser/zip.js +3 -6
  26. package/lib/utils/check-plugin.js +1 -1
  27. package/lib/utils/git.js +1 -1
  28. package/lib/utils/i18n.js +3 -1
  29. package/lib/utils/index.js +4 -4
  30. package/lib/utils/latest-version/cli.js +3 -3
  31. package/lib/utils/latest-version/index.js +4 -4
  32. package/lib/versions.js +2 -2
  33. package/package.json +4 -4
  34. package/src/api.ts +7 -7
  35. package/src/app.ts +2 -2
  36. package/src/bundle.ts +44 -32
  37. package/src/exports.ts +30 -0
  38. package/src/index.ts +118 -16
  39. package/src/locales/en.ts +1 -0
  40. package/src/locales/zh.ts +1 -0
  41. package/src/module-manager.ts +149 -0
  42. package/src/modules/app-module.ts +205 -0
  43. package/src/modules/bundle-module.ts +202 -0
  44. package/src/modules/index.ts +19 -0
  45. package/src/modules/package-module.ts +11 -0
  46. package/src/modules/user-module.ts +406 -0
  47. package/src/modules/version-module.ts +8 -0
  48. package/src/package.ts +59 -25
  49. package/src/provider.ts +341 -0
  50. package/src/types.ts +126 -0
  51. package/src/user.ts +4 -3
  52. package/src/utils/app-info-parser/apk.js +62 -52
  53. package/src/utils/app-info-parser/app.js +5 -5
  54. package/src/utils/app-info-parser/ipa.js +69 -57
  55. package/src/utils/app-info-parser/resource-finder.js +50 -54
  56. package/src/utils/app-info-parser/utils.js +59 -54
  57. package/src/utils/app-info-parser/xml-parser/binary.js +366 -354
  58. package/src/utils/app-info-parser/xml-parser/manifest.js +145 -137
  59. package/src/utils/app-info-parser/zip.js +1 -1
  60. package/src/utils/check-plugin.ts +4 -2
  61. package/src/utils/dep-versions.ts +13 -6
  62. package/src/utils/git.ts +1 -1
  63. package/src/utils/i18n.ts +3 -1
  64. package/src/utils/index.ts +8 -10
  65. package/src/utils/latest-version/cli.ts +4 -4
  66. package/src/utils/latest-version/index.ts +17 -17
  67. package/src/utils/plugin-config.ts +3 -3
  68. package/src/versions.ts +3 -3
@@ -0,0 +1,149 @@
1
+ import { CLIProviderImpl } from './provider';
2
+ import type {
3
+ CLIModule,
4
+ CLIProvider,
5
+ CommandDefinition,
6
+ CustomWorkflow,
7
+ } from './types';
8
+
9
+ export class ModuleManager {
10
+ private modules: Map<string, CLIModule> = new Map();
11
+ private provider: CLIProvider;
12
+ private commands: Map<string, CommandDefinition> = new Map();
13
+ private workflows: Map<string, CustomWorkflow> = new Map();
14
+
15
+ constructor() {
16
+ this.provider = new CLIProviderImpl();
17
+ }
18
+
19
+ registerModule(module: CLIModule): void {
20
+ if (this.modules.has(module.name)) {
21
+ throw new Error(`Module '${module.name}' is already registered`);
22
+ }
23
+
24
+ this.modules.set(module.name, module);
25
+
26
+ if (module.commands) {
27
+ for (const command of module.commands) {
28
+ this.registerCommand(command);
29
+ }
30
+ }
31
+
32
+ if (module.workflows) {
33
+ for (const workflow of module.workflows) {
34
+ this.registerWorkflow(workflow);
35
+ }
36
+ }
37
+
38
+ if (module.init) {
39
+ module.init(this.provider);
40
+ }
41
+
42
+ console.log(
43
+ `Module '${module.name}' (v${module.version}) registered successfully`,
44
+ );
45
+ }
46
+
47
+ unregisterModule(moduleName: string): void {
48
+ const module = this.modules.get(moduleName);
49
+ if (!module) {
50
+ throw new Error(`Module '${moduleName}' is not registered`);
51
+ }
52
+
53
+ if (module.commands) {
54
+ for (const command of module.commands) {
55
+ this.commands.delete(command.name);
56
+ }
57
+ }
58
+
59
+ if (module.workflows) {
60
+ for (const workflow of module.workflows) {
61
+ this.workflows.delete(workflow.name);
62
+ }
63
+ }
64
+
65
+ if (module.cleanup) {
66
+ module.cleanup();
67
+ }
68
+
69
+ this.modules.delete(moduleName);
70
+ console.log(`Module '${moduleName}' unregistered successfully`);
71
+ }
72
+
73
+ registerCommand(command: CommandDefinition): void {
74
+ if (this.commands.has(command.name)) {
75
+ throw new Error(`Command '${command.name}' is already registered`);
76
+ }
77
+ this.commands.set(command.name, command);
78
+ }
79
+
80
+ registerWorkflow(workflow: CustomWorkflow): void {
81
+ if (this.workflows.has(workflow.name)) {
82
+ throw new Error(`Workflow '${workflow.name}' is already registered`);
83
+ }
84
+ this.workflows.set(workflow.name, workflow);
85
+ this.provider.registerWorkflow(workflow);
86
+ }
87
+
88
+ getRegisteredCommands(): CommandDefinition[] {
89
+ return Array.from(this.commands.values());
90
+ }
91
+
92
+ getRegisteredWorkflows(): CustomWorkflow[] {
93
+ return Array.from(this.workflows.values());
94
+ }
95
+
96
+ getRegisteredModules(): CLIModule[] {
97
+ return Array.from(this.modules.values());
98
+ }
99
+
100
+ async executeCommand(commandName: string, context: any): Promise<any> {
101
+ const command = this.commands.get(commandName);
102
+ if (!command) {
103
+ throw new Error(`Command '${commandName}' not found`);
104
+ }
105
+
106
+ return await command.handler(context);
107
+ }
108
+
109
+ async executeWorkflow(workflowName: string, context: any): Promise<any> {
110
+ return await this.provider.executeWorkflow(workflowName, context);
111
+ }
112
+
113
+ getProvider(): CLIProvider {
114
+ return this.provider;
115
+ }
116
+
117
+ listCommands(): any[] {
118
+ return Array.from(this.commands.values());
119
+ }
120
+
121
+ listWorkflows(): CustomWorkflow[] {
122
+ return Array.from(this.workflows.values());
123
+ }
124
+
125
+ listAll(): void {
126
+ console.log('\n=== Registered Commands ===');
127
+ for (const command of this.commands.values()) {
128
+ console.log(
129
+ ` ${command.name}: ${command.description || 'No description'}`,
130
+ );
131
+ }
132
+
133
+ console.log('\n=== Registered Workflows ===');
134
+ for (const workflow of this.workflows.values()) {
135
+ console.log(
136
+ ` ${workflow.name}: ${workflow.description || 'No description'}`,
137
+ );
138
+ }
139
+
140
+ console.log('\n=== Registered Modules ===');
141
+ for (const module of this.modules.values()) {
142
+ console.log(
143
+ ` ${module.name} (v${module.version}): ${module.commands?.length || 0} commands, ${module.workflows?.length || 0} workflows`,
144
+ );
145
+ }
146
+ }
147
+ }
148
+
149
+ export const moduleManager = new ModuleManager();
@@ -0,0 +1,205 @@
1
+ import { appCommands } from '../app';
2
+ import type { CLIModule, CommandContext } from '../types';
3
+
4
+ export const appModule: CLIModule = {
5
+ name: 'app',
6
+ version: '1.0.0',
7
+
8
+ commands: [],
9
+
10
+ workflows: [
11
+ {
12
+ name: 'setup-app',
13
+ description: 'Setup a new app with initial configuration',
14
+ steps: [
15
+ {
16
+ name: 'create',
17
+ description: 'Create the app',
18
+ execute: async (context: CommandContext) => {
19
+ console.log('Creating app in workflow');
20
+ const { name, downloadUrl, platform } = context.options;
21
+ await appCommands.createApp({
22
+ options: {
23
+ name: name || '',
24
+ downloadUrl: downloadUrl || '',
25
+ platform: platform || '',
26
+ },
27
+ });
28
+ return { appCreated: true };
29
+ },
30
+ },
31
+ {
32
+ name: 'select',
33
+ description: 'Select the created app',
34
+ execute: async (context: CommandContext, previousResult: any) => {
35
+ console.log('Selecting app in workflow');
36
+ const { platform } = context.options;
37
+ await appCommands.selectApp({
38
+ args: [],
39
+ options: { platform: platform || '' },
40
+ });
41
+ return { ...previousResult, appSelected: true };
42
+ },
43
+ },
44
+ ],
45
+ },
46
+ {
47
+ name: 'manage-apps',
48
+ description: 'Manage multiple apps',
49
+ steps: [
50
+ {
51
+ name: 'list-apps',
52
+ description: 'List all apps',
53
+ execute: async (context: CommandContext) => {
54
+ console.log('Listing all apps');
55
+ const { platform } = context.options;
56
+ await appCommands.apps({
57
+ options: { platform: platform || '' },
58
+ });
59
+ return { appsListed: true };
60
+ },
61
+ },
62
+ {
63
+ name: 'select-target-app',
64
+ description: 'Select target app for operations',
65
+ execute: async (context: CommandContext, previousResult: any) => {
66
+ console.log('Selecting target app');
67
+ const { platform } = context.options;
68
+ await appCommands.selectApp({
69
+ args: [],
70
+ options: { platform: platform || '' },
71
+ });
72
+ return { ...previousResult, targetAppSelected: true };
73
+ },
74
+ },
75
+ ],
76
+ },
77
+ {
78
+ name: 'multi-platform-app-management',
79
+ description: 'Multi-platform app unified management workflow',
80
+ steps: [
81
+ {
82
+ name: 'scan-platforms',
83
+ description: 'Scan apps on all platforms',
84
+ execute: async (context: CommandContext) => {
85
+ console.log('🔍 Scanning apps on all platforms...');
86
+
87
+ const platforms = ['ios', 'android', 'harmony'];
88
+ const appsData = {};
89
+
90
+ for (const platform of platforms) {
91
+ console.log(` Scanning ${platform} platform...`);
92
+
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`);
107
+ }
108
+
109
+ console.log('✅ Platform scanning completed');
110
+
111
+ return { platforms, appsData, scanned: true };
112
+ },
113
+ },
114
+ {
115
+ name: 'analyze-apps',
116
+ description: 'Analyze app status',
117
+ execute: async (context: CommandContext, previousResult: any) => {
118
+ console.log('📊 Analyzing app status...');
119
+
120
+ const { appsData } = previousResult;
121
+ const analysis = {
122
+ totalApps: 0,
123
+ activeApps: 0,
124
+ inactiveApps: 0,
125
+ platformDistribution: {},
126
+ issues: [],
127
+ };
128
+
129
+ for (const [platform, apps] of Object.entries(appsData)) {
130
+ const platformApps = apps as any[];
131
+ analysis.totalApps += platformApps.length;
132
+ analysis.platformDistribution[platform] = platformApps.length;
133
+
134
+ for (const app of platformApps) {
135
+ if (app.status === 'active') {
136
+ analysis.activeApps++;
137
+ } else {
138
+ analysis.inactiveApps++;
139
+ analysis.issues.push(
140
+ `${platform}/${app.name}: App is inactive`,
141
+ );
142
+ }
143
+ }
144
+ }
145
+
146
+ console.log('📈 Analysis results:');
147
+ console.log(` Total apps: ${analysis.totalApps}`);
148
+ console.log(` Active apps: ${analysis.activeApps}`);
149
+ console.log(` Inactive apps: ${analysis.inactiveApps}`);
150
+
151
+ if (analysis.issues.length > 0) {
152
+ console.log('⚠️ Issues found:');
153
+ analysis.issues.forEach((issue) => console.log(` - ${issue}`));
154
+ }
155
+
156
+ return { ...previousResult, analysis };
157
+ },
158
+ },
159
+ {
160
+ name: 'optimize-apps',
161
+ description: 'Optimize app configuration',
162
+ execute: async (context: CommandContext, previousResult: any) => {
163
+ console.log('⚡ Optimizing app configuration...');
164
+
165
+ const { analysis } = previousResult;
166
+ const optimizations = [];
167
+
168
+ if (analysis.inactiveApps > 0) {
169
+ console.log(' Handling inactive apps...');
170
+ optimizations.push('Reactivate inactive apps');
171
+ }
172
+
173
+ if (analysis.totalApps > 10) {
174
+ console.log(' Many apps detected, suggest grouping...');
175
+ optimizations.push('Create app groups');
176
+ }
177
+
178
+ // Simulate optimization process
179
+ for (const optimization of optimizations) {
180
+ console.log(` Executing: ${optimization}...`);
181
+ await new Promise((resolve) => setTimeout(resolve, 800));
182
+ console.log(` ✅ ${optimization} completed`);
183
+ }
184
+
185
+ console.log('✅ App optimization completed');
186
+
187
+ return { ...previousResult, optimizations, optimized: true };
188
+ },
189
+ },
190
+ ],
191
+ options: {
192
+ includeInactive: {
193
+ hasValue: false,
194
+ default: true,
195
+ description: 'Include inactive apps',
196
+ },
197
+ autoOptimize: {
198
+ hasValue: false,
199
+ default: true,
200
+ description: 'Auto optimize configuration',
201
+ },
202
+ },
203
+ },
204
+ ],
205
+ };
@@ -0,0 +1,202 @@
1
+ import { bundleCommands } from '../bundle';
2
+ import type { CLIModule, CommandContext } from '../types';
3
+
4
+ export const bundleModule: CLIModule = {
5
+ name: 'bundle',
6
+ version: '1.0.0',
7
+
8
+ commands: [],
9
+
10
+ workflows: [
11
+ {
12
+ name: 'incremental-build',
13
+ description: 'Incremental build workflow - generate diff packages',
14
+ steps: [
15
+ {
16
+ name: 'detect-base-version',
17
+ description: 'Detect base version',
18
+ execute: async (context: CommandContext) => {
19
+ console.log('🔍 Detecting base version...');
20
+
21
+ const { baseVersion, platform } = context.options;
22
+
23
+ if (baseVersion) {
24
+ console.log(`✅ Using specified base version: ${baseVersion}`);
25
+ return { baseVersion, specified: true };
26
+ }
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)}`;
32
+
33
+ console.log(
34
+ `✅ Auto detected base version: ${autoDetectedVersion}`,
35
+ );
36
+
37
+ return { baseVersion: autoDetectedVersion, specified: false };
38
+ },
39
+ },
40
+ {
41
+ name: 'build-current-version',
42
+ description: 'Build current version',
43
+ execute: async (context: CommandContext, previousResult: any) => {
44
+ console.log('🏗️ Building current version...');
45
+
46
+ const {
47
+ platform,
48
+ dev = false,
49
+ sourcemap = false,
50
+ bundleName = 'index.bundlejs',
51
+ entryFile = 'index.js',
52
+ intermediaDir,
53
+ taro = false,
54
+ expo = false,
55
+ rncli = false,
56
+ disableHermes = false,
57
+ output,
58
+ } = context.options;
59
+
60
+ console.log(`Building ${platform} platform...`);
61
+ console.log(` Entry file: ${entryFile}`);
62
+ console.log(` Bundle name: ${bundleName}`);
63
+ console.log(` Development mode: ${dev}`);
64
+ console.log(` Source maps: ${sourcemap}`);
65
+
66
+ try {
67
+ const buildOptions: any = {
68
+ platform,
69
+ dev,
70
+ sourcemap,
71
+ bundleName,
72
+ entryFile,
73
+ taro,
74
+ expo,
75
+ rncli,
76
+ disableHermes,
77
+ intermediaDir: '${tempDir}/intermedia/${platform}',
78
+ output: '${tempDir}/output/${platform}.${time}.ppk',
79
+ };
80
+ if (intermediaDir) {
81
+ buildOptions.intermediaDir = intermediaDir;
82
+ }
83
+
84
+ await bundleCommands.bundle({
85
+ args: [],
86
+ options: buildOptions,
87
+ });
88
+
89
+ const currentBuild = {
90
+ version: `v${Math.floor(Math.random() * 3) + 2}.0.0`,
91
+ platform,
92
+ bundlePath: `./build/current_${platform}.ppk`,
93
+ size: Math.floor(Math.random() * 15) + 10,
94
+ buildTime: Date.now(),
95
+ };
96
+
97
+ console.log(
98
+ `✅ Current version build completed: ${currentBuild.version}`,
99
+ );
100
+
101
+ return { ...previousResult, currentBuild };
102
+ } catch (error) {
103
+ console.error('❌ Current version build failed:', error);
104
+ throw error;
105
+ }
106
+ },
107
+ },
108
+ ],
109
+ validate: (context: CommandContext) => {
110
+ if (!context.options.platform) {
111
+ console.error('❌ Incremental build requires platform specification');
112
+ return false;
113
+ }
114
+ return true;
115
+ },
116
+ options: {
117
+ platform: {
118
+ hasValue: true,
119
+ description: 'Target platform (required)',
120
+ },
121
+ baseVersion: {
122
+ hasValue: true,
123
+ description: 'Base version (auto detect if not specified)',
124
+ },
125
+ skipValidation: {
126
+ hasValue: false,
127
+ default: false,
128
+ description: 'Skip diff package validation',
129
+ },
130
+ dev: {
131
+ hasValue: false,
132
+ default: false,
133
+ description: 'Development mode build',
134
+ },
135
+ bundleName: {
136
+ hasValue: true,
137
+ default: 'index.bundlejs',
138
+ description: 'Bundle file name',
139
+ },
140
+ entryFile: {
141
+ hasValue: true,
142
+ default: 'index.js',
143
+ description: 'Entry file',
144
+ },
145
+ sourcemap: {
146
+ hasValue: false,
147
+ default: false,
148
+ description: 'Generate source maps',
149
+ },
150
+ output: {
151
+ hasValue: true,
152
+ description: 'Custom output path for diff package',
153
+ },
154
+ intermediaDir: {
155
+ hasValue: true,
156
+ description: 'Intermediate directory',
157
+ },
158
+ taro: {
159
+ hasValue: false,
160
+ default: false,
161
+ description: 'Use Taro CLI',
162
+ },
163
+ expo: {
164
+ hasValue: false,
165
+ default: false,
166
+ description: 'Use Expo CLI',
167
+ },
168
+ rncli: {
169
+ hasValue: false,
170
+ default: false,
171
+ description: 'Use React Native CLI',
172
+ },
173
+ disableHermes: {
174
+ hasValue: false,
175
+ default: false,
176
+ description: 'Disable Hermes',
177
+ },
178
+ name: {
179
+ hasValue: true,
180
+ description: 'Version name for publishing',
181
+ },
182
+ description: {
183
+ hasValue: true,
184
+ description: 'Version description for publishing',
185
+ },
186
+ metaInfo: {
187
+ hasValue: true,
188
+ description: 'Meta information for publishing',
189
+ },
190
+ rollout: {
191
+ hasValue: true,
192
+ description: 'Rollout percentage',
193
+ },
194
+ dryRun: {
195
+ hasValue: false,
196
+ default: false,
197
+ description: 'Dry run mode',
198
+ },
199
+ },
200
+ },
201
+ ],
202
+ };
@@ -0,0 +1,19 @@
1
+ import { appModule } from './app-module';
2
+ import { bundleModule } from './bundle-module';
3
+ import { packageModule } from './package-module';
4
+ import { userModule } from './user-module';
5
+ import { versionModule } from './version-module';
6
+
7
+ export { bundleModule } from './bundle-module';
8
+ export { versionModule } from './version-module';
9
+ export { appModule } from './app-module';
10
+ export { userModule } from './user-module';
11
+ export { packageModule } from './package-module';
12
+
13
+ export const builtinModules = [
14
+ bundleModule,
15
+ versionModule,
16
+ appModule,
17
+ userModule,
18
+ packageModule,
19
+ ];
@@ -0,0 +1,11 @@
1
+ import { packageCommands } from '../package';
2
+ import type { CLIModule } from '../types';
3
+
4
+ export const packageModule: CLIModule = {
5
+ name: 'package',
6
+ version: '1.0.0',
7
+
8
+ commands: [],
9
+
10
+ workflows: [],
11
+ };