react-native-update-cli 2.10.1 → 2.10.2

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 (62) hide show
  1. package/README.md +47 -497
  2. package/README.zh-CN.md +52 -500
  3. package/cli.json +2 -16
  4. package/lib/api.js +1 -1
  5. package/lib/exports.d.ts +1 -1
  6. package/lib/index.d.ts +2 -3
  7. package/lib/index.js +14 -62
  8. package/lib/locales/en.d.ts +1 -0
  9. package/lib/locales/en.js +1 -0
  10. package/lib/locales/zh.d.ts +1 -0
  11. package/lib/locales/zh.js +1 -0
  12. package/lib/module-manager.d.ts +1 -5
  13. package/lib/module-manager.js +2 -30
  14. package/lib/modules/app-module.js +1 -249
  15. package/lib/modules/bundle-module.js +1 -173
  16. package/lib/modules/package-module.js +1 -2
  17. package/lib/modules/user-module.js +1 -399
  18. package/lib/modules/version-module.js +1 -2
  19. package/lib/package.d.ts +1 -2
  20. package/lib/package.js +6 -6
  21. package/lib/provider.d.ts +1 -4
  22. package/lib/provider.js +2 -21
  23. package/lib/types.d.ts +0 -20
  24. package/lib/user.d.ts +1 -1
  25. package/lib/user.js +1 -1
  26. package/lib/utils/app-info-parser/aab.js +1 -1
  27. package/lib/utils/app-info-parser/resource-finder.js +5 -5
  28. package/lib/utils/app-info-parser/utils.js +3 -2
  29. package/lib/utils/check-lockfile.js +1 -1
  30. package/lib/utils/dep-versions.js +2 -2
  31. package/lib/utils/http-helper.js +2 -2
  32. package/lib/utils/index.d.ts +1 -1
  33. package/lib/utils/index.js +1 -1
  34. package/lib/versions.d.ts +1 -0
  35. package/lib/versions.js +19 -14
  36. package/package.json +1 -1
  37. package/src/api.ts +1 -1
  38. package/src/exports.ts +0 -2
  39. package/src/index.ts +16 -81
  40. package/src/locales/en.ts +1 -0
  41. package/src/locales/zh.ts +1 -0
  42. package/src/module-manager.ts +1 -41
  43. package/src/modules/app-module.ts +1 -271
  44. package/src/modules/bundle-module.ts +1 -206
  45. package/src/modules/package-module.ts +0 -3
  46. package/src/modules/user-module.ts +1 -459
  47. package/src/modules/version-module.ts +0 -1
  48. package/src/package.ts +5 -7
  49. package/src/provider.ts +4 -25
  50. package/src/types.ts +0 -32
  51. package/src/user.ts +1 -1
  52. package/src/utils/app-info-parser/aab.ts +1 -1
  53. package/src/utils/app-info-parser/resource-finder.ts +5 -5
  54. package/src/utils/app-info-parser/utils.ts +2 -2
  55. package/src/utils/check-lockfile.ts +1 -1
  56. package/src/utils/dep-versions.ts +2 -2
  57. package/src/utils/http-helper.ts +2 -2
  58. package/src/utils/index.ts +1 -1
  59. package/src/versions.ts +24 -14
  60. package/lib/workflow-runner.d.ts +0 -2
  61. package/lib/workflow-runner.js +0 -25
  62. package/src/workflow-runner.ts +0 -24
package/lib/provider.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import type { BundleOptions, CLIProvider, CommandContext, CommandResult, CustomWorkflow, Platform, PublishOptions, Session, UploadOptions, Version } from './types';
1
+ import type { BundleOptions, CLIProvider, CommandResult, Platform, PublishOptions, Session, UploadOptions, Version } from './types';
2
2
  export declare class CLIProviderImpl implements CLIProvider {
3
- private workflows;
4
3
  private session?;
5
4
  private sessionInitPromise?;
6
5
  private createContext;
@@ -20,7 +19,5 @@ export declare class CLIProviderImpl implements CLIProvider {
20
19
  updateVersion(appId: string, versionId: string, updates: Partial<Version>): Promise<CommandResult>;
21
20
  getPlatform(platform?: Platform): Promise<Platform>;
22
21
  loadSession(): Promise<Session>;
23
- registerWorkflow(workflow: CustomWorkflow): void;
24
- executeWorkflow(workflowName: string, context: CommandContext): Promise<CommandResult>;
25
22
  listPackages(appId?: string): Promise<CommandResult>;
26
23
  }
package/lib/provider.js CHANGED
@@ -11,7 +11,6 @@ Object.defineProperty(exports, "CLIProviderImpl", {
11
11
  const _api = require("./api");
12
12
  const _app = require("./app");
13
13
  const _commandresult = require("./utils/command-result");
14
- const _workflowrunner = require("./workflow-runner");
15
14
  function _getRequireWildcardCache(nodeInterop) {
16
15
  if (typeof WeakMap !== "function") return null;
17
16
  var cacheBabelInterop = new WeakMap();
@@ -53,6 +52,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
53
52
  }
54
53
  return newObj;
55
54
  }
55
+ const DEFAULT_BUNDLE_OUTPUT = '$' + '{tempDir}/output/$' + '{platform}.$' + '{time}.ppk';
56
56
  class CLIProviderImpl {
57
57
  createContext(options, args = []) {
58
58
  return {
@@ -99,7 +99,7 @@ class CLIProviderImpl {
99
99
  platform: options.platform,
100
100
  bundleName: options.bundleName || 'index.bundlejs',
101
101
  entryFile: options.entryFile || 'index.js',
102
- output: options.output || '${tempDir}/output/${platform}.${time}.ppk',
102
+ output: options.output || DEFAULT_BUNDLE_OUTPUT,
103
103
  sourcemap: options.sourcemap || false,
104
104
  taro: options.taro || false,
105
105
  expo: options.expo || false,
@@ -214,29 +214,10 @@ class CLIProviderImpl {
214
214
  }
215
215
  return this.session;
216
216
  }
217
- registerWorkflow(workflow) {
218
- this.workflows.set(workflow.name, workflow);
219
- }
220
- async executeWorkflow(workflowName, context) {
221
- return this.runDataCommand(async ()=>{
222
- const workflow = this.workflows.get(workflowName);
223
- if (!workflow) {
224
- throw new Error(`Workflow '${workflowName}' not found`);
225
- }
226
- const result = await (0, _workflowrunner.runWorkflow)(workflowName, workflow, context);
227
- return {
228
- message: `Workflow '${workflowName}' completed successfully`,
229
- result
230
- };
231
- }, `Workflow '${workflowName}' failed`);
232
- }
233
217
  async listPackages(appId) {
234
218
  return this.runDataCommand(async ()=>{
235
219
  const { listPackage } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./package")));
236
220
  return listPackage(appId || '');
237
221
  }, 'Unknown error listing packages');
238
222
  }
239
- constructor(){
240
- this.workflows = new Map();
241
- }
242
223
  }
package/lib/types.d.ts CHANGED
@@ -76,23 +76,6 @@ export interface UploadOptions {
76
76
  appId?: string;
77
77
  version?: string;
78
78
  }
79
- export interface WorkflowStep {
80
- name: string;
81
- description?: string;
82
- execute: (context: CommandContext, previousResult?: unknown) => Promise<unknown>;
83
- condition?: (context: CommandContext) => boolean;
84
- }
85
- export interface CustomWorkflow {
86
- name: string;
87
- description?: string;
88
- steps: WorkflowStep[];
89
- validate?: (context: CommandContext) => boolean;
90
- options?: Record<string, {
91
- hasValue?: boolean;
92
- default?: unknown;
93
- description?: string;
94
- }>;
95
- }
96
79
  export interface CLIProvider {
97
80
  bundle: (options: BundleOptions) => Promise<CommandResult>;
98
81
  publish: (options: PublishOptions) => Promise<CommandResult>;
@@ -107,14 +90,11 @@ export interface CLIProvider {
107
90
  updateVersion: (appId: string, versionId: string, updates: Partial<Version>) => Promise<CommandResult>;
108
91
  getPlatform: (platform?: Platform) => Promise<Platform>;
109
92
  loadSession: () => Promise<Session>;
110
- registerWorkflow: (workflow: CustomWorkflow) => void;
111
- executeWorkflow: (workflowName: string, context: CommandContext) => Promise<CommandResult>;
112
93
  }
113
94
  export interface CLIModule {
114
95
  name: string;
115
96
  version: string;
116
97
  commands?: CommandDefinition[];
117
- workflows?: CustomWorkflow[];
118
98
  init?: (provider: CLIProvider) => void;
119
99
  cleanup?: () => void;
120
100
  }
package/lib/user.d.ts CHANGED
@@ -3,6 +3,6 @@ export declare const userCommands: {
3
3
  login: ({ args }: {
4
4
  args: string[];
5
5
  }) => Promise<void>;
6
- logout: (context: CommandContext) => Promise<void>;
6
+ logout: (_context: CommandContext) => Promise<void>;
7
7
  me: () => Promise<void>;
8
8
  };
package/lib/user.js CHANGED
@@ -36,7 +36,7 @@ const userCommands = {
36
36
  name: info.name
37
37
  }));
38
38
  },
39
- logout: async (context)=>{
39
+ logout: async (_context)=>{
40
40
  await (0, _api.closeSession)();
41
41
  console.log((0, _i18n.t)('loggedOut'));
42
42
  },
@@ -88,7 +88,7 @@ class AabParser extends _zip.Zip {
88
88
  '--overwrite',
89
89
  ...modulesArgs
90
90
  ]);
91
- } catch (e) {
91
+ } catch (_e) {
92
92
  // Fallback to npx node-bundletool if bundletool is not in PATH
93
93
  // We use -y to avoid interactive prompt for installation
94
94
  if (await needsNpxDownload()) {
@@ -59,14 +59,14 @@ class ResourceFinder {
59
59
  while(true){
60
60
  let pos = 0;
61
61
  let t = 0;
62
- let hs = 0;
62
+ let _hs = 0;
63
63
  let s = 0;
64
64
  try {
65
65
  pos = bb.offset;
66
66
  t = bb.readShort();
67
- hs = bb.readShort();
67
+ _hs = bb.readShort();
68
68
  s = bb.readInt();
69
- } catch (e) {
69
+ } catch (_e) {
70
70
  break;
71
71
  }
72
72
  if (t === RES_STRING_POOL_TYPE) {
@@ -181,7 +181,7 @@ class ResourceFinder {
181
181
  if (!bb.remaining()) {
182
182
  break;
183
183
  }
184
- } catch (e) {
184
+ } catch (_e) {
185
185
  break;
186
186
  }
187
187
  }
@@ -225,7 +225,7 @@ class ResourceFinder {
225
225
  entrySize = bb.readShort();
226
226
  entryFlag = bb.readShort();
227
227
  entryKey = bb.readInt();
228
- } catch (e) {
228
+ } catch (_e) {
229
229
  break;
230
230
  }
231
231
  void entrySize;
@@ -92,7 +92,8 @@ const isBrowser = ()=>typeof window !== 'undefined' && typeof window.document !=
92
92
  * find .apk file's icon path from json info
93
93
  * @param info // json info parsed from .apk file
94
94
  */ const findApkIconPath = (info)=>{
95
- if (!info.application.icon || !info.application.icon.splice) {
95
+ var _info_application_icon;
96
+ if (!((_info_application_icon = info.application.icon) == null ? void 0 : _info_application_icon.splice)) {
96
97
  return '';
97
98
  }
98
99
  const rulesMap = {
@@ -152,7 +153,7 @@ const isBrowser = ()=>typeof window !== 'undefined' && typeof window.document !=
152
153
  * @param {String} str
153
154
  */ const decodeNullUnicode = (value)=>{
154
155
  if (typeof value === 'string') {
155
- // biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
156
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: strips null unicode padding from decoded strings
156
157
  return value.replace(/\u0000/g, '');
157
158
  }
158
159
  return value;
@@ -30,7 +30,7 @@ function hasWorkspaces(dir) {
30
30
  try {
31
31
  const pkg = JSON.parse(_fs.default.readFileSync(pkgPath, 'utf-8'));
32
32
  return !!pkg.workspaces;
33
- } catch (e) {
33
+ } catch (_e) {
34
34
  // Ignore parsing errors
35
35
  }
36
36
  }
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "depVersions", {
11
11
  let currentPackage = null;
12
12
  try {
13
13
  currentPackage = require(`${process.cwd()}/package.json`);
14
- } catch (e) {
14
+ } catch (_e) {
15
15
  // console.warn('No package.json file were found');
16
16
  }
17
17
  const _depVersions = {};
@@ -33,7 +33,7 @@ if (currentPackage) {
33
33
  });
34
34
  const version = require(packageJsonPath).version;
35
35
  _depVersions[dep] = version;
36
- } catch (e) {}
36
+ } catch (_e) {}
37
37
  }
38
38
  }
39
39
  const depVersions = Object.keys(_depVersions).sort() // Sort the keys alphabetically
@@ -47,7 +47,7 @@ const ping = async (url)=>{
47
47
  return Promise.race([
48
48
  (0, _nodefetch.default)(url, {
49
49
  method: 'HEAD'
50
- }).then(({ status, statusText })=>{
50
+ }).then(({ status })=>{
51
51
  pingFinished = true;
52
52
  if (status === 200) {
53
53
  // console.log('ping success', url);
@@ -55,7 +55,7 @@ const ping = async (url)=>{
55
55
  }
56
56
  // console.log('ping failed', url, status, statusText);
57
57
  throw new Error('ping failed');
58
- }).catch((e)=>{
58
+ }).catch((_e)=>{
59
59
  pingFinished = true;
60
60
  // console.log('ping error', url, e);
61
61
  throw new Error('ping error');
@@ -17,6 +17,6 @@ export declare function getAabInfo(fn: string): Promise<{
17
17
  versionName: string;
18
18
  buildTime: number;
19
19
  }>;
20
- export declare function saveToLocal(originPath: string, destName: string): void;
20
+ export declare function saveToLocal(_originPath: string, _destName: string): void;
21
21
  export declare function printVersionCommand(): Promise<void>;
22
22
  export { checkPlugins };
@@ -338,7 +338,7 @@ async function resolveResource(fn, resourceId, root) {
338
338
  }
339
339
  const localDir = _path.default.resolve(_os.default.homedir(), _constants.tempDir);
340
340
  _fsextra.default.ensureDirSync(localDir);
341
- function saveToLocal(originPath, destName) {
341
+ function saveToLocal(_originPath, _destName) {
342
342
  // TODO
343
343
  // const destPath = path.join(localDir, destName);
344
344
  // fs.ensureDirSync(path.dirname(destPath));
package/lib/versions.d.ts CHANGED
@@ -14,6 +14,7 @@ interface VersionCommandOptions {
14
14
  rollout?: string;
15
15
  dryRun?: boolean;
16
16
  versionDeps?: Record<string, string>;
17
+ warnDepsChanges?: boolean;
17
18
  }
18
19
  export declare const bindVersionToPackages: ({ appId, versionId, pkgs, rollout, dryRun, }: {
19
20
  appId: string;
package/lib/versions.js CHANGED
@@ -149,6 +149,7 @@ function printDepsChangesForPackage({ pkg, versionDeps }) {
149
149
  renderVersionChange(change)
150
150
  ]);
151
151
  console.log('');
152
+ console.log(_chalk.default.bgYellow.black.bold(` ${(0, _i18n.t)('depsChangeWarningTitle')} `));
152
153
  console.log(_chalk.default.yellow((0, _i18n.t)('depsChangeTargetPackage', {
153
154
  packageName: pkg.name,
154
155
  packageId: pkg.id
@@ -177,7 +178,7 @@ async function findVersionDeps(appId, versionId) {
177
178
  return undefined;
178
179
  }
179
180
  async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVersionDeps }) {
180
- if (!versionId || pkgs.length === 0) {
181
+ if (!versionId || pkgs.length !== 1) {
181
182
  return;
182
183
  }
183
184
  let versionDeps = normalizeDeps(providedVersionDeps);
@@ -207,7 +208,7 @@ async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVers
207
208
  }
208
209
  }
209
210
  async function showVersion(appId, offset) {
210
- const { data, count } = await (0, _api.get)(`/app/${appId}/version/list`);
211
+ const { data } = await (0, _api.get)(`/app/${appId}/version/list`);
211
212
  console.log((0, _i18n.t)('offset', {
212
213
  offset
213
214
  }));
@@ -305,10 +306,10 @@ const bindVersionToPackages = async ({ appId, versionId, pkgs, rollout, dryRun }
305
306
  }));
306
307
  };
307
308
  const versionCommands = {
308
- publish: async function({ args, options }) {
309
+ publish: async ({ args, options })=>{
309
310
  const fn = args[0];
310
311
  const { name, description, metaInfo } = options;
311
- if (!fn || !fn.endsWith('.ppk')) {
312
+ if (!(fn == null ? void 0 : fn.endsWith('.ppk'))) {
312
313
  throw new Error((0, _i18n.t)('publishUsage'));
313
314
  }
314
315
  const platform = await (0, _app.getPlatform)(options.platform);
@@ -330,7 +331,7 @@ const versionCommands = {
330
331
  }));
331
332
  const { packageId, packageVersion, packageVersionRange, minPackageVersion, maxPackageVersion, rollout, dryRun } = options;
332
333
  if (packageId || packageVersion || packageVersionRange || minPackageVersion || maxPackageVersion) {
333
- await this.update({
334
+ await versionCommands.update({
334
335
  options: {
335
336
  versionId: id,
336
337
  platform,
@@ -341,17 +342,19 @@ const versionCommands = {
341
342
  maxPackageVersion,
342
343
  rollout,
343
344
  dryRun,
344
- versionDeps: _depversions.depVersions
345
+ versionDeps: _depversions.depVersions,
346
+ warnDepsChanges: true
345
347
  }
346
348
  });
347
349
  } else {
348
350
  const q = await (0, _utils.question)((0, _i18n.t)('updateNativePackageQuestion'));
349
351
  if (q.toLowerCase() === 'y') {
350
- await this.update({
352
+ await versionCommands.update({
351
353
  options: {
352
354
  versionId: id,
353
355
  platform,
354
- versionDeps: _depversions.depVersions
356
+ versionDeps: _depversions.depVersions,
357
+ warnDepsChanges: true
355
358
  }
356
359
  });
357
360
  }
@@ -443,12 +446,14 @@ const versionCommands = {
443
446
  }));
444
447
  }
445
448
  }
446
- await printDepsChangesForPublish({
447
- appId: String(appId),
448
- versionId: String(versionId),
449
- pkgs: pkgsToBind,
450
- providedVersionDeps: options.versionDeps
451
- });
449
+ if (options.warnDepsChanges) {
450
+ await printDepsChangesForPublish({
451
+ appId: String(appId),
452
+ versionId: String(versionId),
453
+ pkgs: pkgsToBind,
454
+ providedVersionDeps: options.versionDeps
455
+ });
456
+ }
452
457
  await bindVersionToPackages({
453
458
  appId: String(appId),
454
459
  versionId: String(versionId),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.10.1",
3
+ "version": "2.10.2",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "lib/exports.js",
6
6
  "types": "lib/exports.d.ts",
package/src/api.ts CHANGED
@@ -98,7 +98,7 @@ async function query(url: string, options: fetch.RequestInit) {
98
98
  let json: any;
99
99
  try {
100
100
  json = JSON.parse(text);
101
- } catch (e) {
101
+ } catch (_e) {
102
102
  if (resp.status === 200 && text) {
103
103
  console.warn(
104
104
  `Warning: API returned 200 with non-JSON body (${text.length} bytes)`,
package/src/exports.ts CHANGED
@@ -16,13 +16,11 @@ export type {
16
16
  CommandContext,
17
17
  CommandDefinition,
18
18
  CommandResult,
19
- CustomWorkflow,
20
19
  Package,
21
20
  Platform,
22
21
  PublishOptions,
23
22
  Session,
24
23
  UploadOptions,
25
24
  Version,
26
- WorkflowStep,
27
25
  } from './types';
28
26
  export { question, saveToLocal } from './utils';
package/src/index.ts CHANGED
@@ -5,16 +5,13 @@ import { appCommands } from './app';
5
5
  import { bundleCommands } from './bundle';
6
6
  import { diffCommands } from './diff';
7
7
  import { installCommands } from './install';
8
- import { moduleManager } from './module-manager';
9
- import { builtinModules } from './modules';
10
8
  import { packageCommands } from './package';
11
- import type { CommandContext } from './types';
12
9
  import { userCommands } from './user';
13
10
  import { printVersionCommand } from './utils';
14
11
  import { t } from './utils/i18n';
15
12
  import { versionCommands } from './versions';
16
13
 
17
- type LegacyCommandHandler = (argv: any) => Promise<unknown> | unknown;
14
+ type CliCommandHandler = (argv: any) => Promise<unknown> | unknown;
18
15
 
19
16
  interface CliArgv {
20
17
  command: string;
@@ -22,56 +19,27 @@ interface CliArgv {
22
19
  options: Record<string, any>;
23
20
  }
24
21
 
25
- function registerBuiltinModules() {
26
- for (const module of builtinModules) {
27
- try {
28
- moduleManager.registerModule(module);
29
- } catch (error) {
30
- console.error(`Failed to register module ${module.name}:`, error);
31
- }
32
- }
33
- }
34
-
35
- function printUsage() {
22
+ function printUsage(exitCode = 1) {
36
23
  console.log('React Native Update CLI');
37
24
  console.log('');
38
- console.log('Traditional commands:');
39
- for (const name of Object.keys(legacyCommands)) {
40
- console.log(` ${name}: Legacy command`);
41
- }
42
-
43
- console.log('');
44
- console.log('Modular commands:');
45
- const commands = moduleManager.listCommands();
46
- for (const command of commands) {
47
- console.log(
48
- ` ${command.name}: ${command.description || 'No description'}`,
49
- );
50
- }
51
-
52
- console.log('');
53
- console.log('Available workflows:');
54
- const workflows = moduleManager.listWorkflows();
55
- for (const workflow of workflows) {
56
- console.log(
57
- ` ${workflow.name}: ${workflow.description || 'No description'}`,
58
- );
25
+ console.log('Commands:');
26
+ for (const name of Object.keys(commandHandlers)) {
27
+ console.log(` ${name}`);
59
28
  }
60
29
 
61
30
  console.log('');
62
31
  console.log('Special commands:');
63
- console.log(' list: List all available commands and workflows');
64
- console.log(' workflow <name>: Execute a specific workflow');
32
+ console.log(' list: List all available commands');
65
33
  console.log(' help: Show this help message');
66
34
 
67
35
  console.log('');
68
36
  console.log(
69
37
  'Visit `https://github.com/reactnativecn/react-native-update` for document.',
70
38
  );
71
- process.exit(1);
39
+ process.exit(exitCode);
72
40
  }
73
41
 
74
- const legacyCommands: Record<string, LegacyCommandHandler> = {
42
+ const commandHandlers: Record<string, CliCommandHandler> = {
75
43
  ...userCommands,
76
44
  ...bundleCommands,
77
45
  ...diffCommands,
@@ -88,53 +56,22 @@ async function run() {
88
56
  process.exit();
89
57
  }
90
58
 
91
- // Register builtin modules for modular functionality
92
- registerBuiltinModules();
93
-
94
59
  const argv: CliArgv = require('cli-arguments').parse(require('../cli.json'));
95
60
  global.NO_INTERACTIVE = argv.options['no-interactive'];
96
61
  global.USE_ACC_OSS = argv.options.acc;
97
62
 
98
- const context: CommandContext = {
99
- args: argv.args || [],
100
- options: argv.options || {},
101
- };
102
-
103
63
  try {
104
64
  await loadSession();
105
- context.session = require('./api').getSession();
106
65
 
107
- // Handle special modular commands first
108
66
  if (argv.command === 'help') {
109
- printUsage();
67
+ printUsage(0);
110
68
  } else if (argv.command === 'list') {
111
- moduleManager.listAll();
112
- } else if (argv.command === 'workflow') {
113
- const workflowName = argv.args[0];
114
- if (!workflowName) {
115
- console.error('Workflow name is required');
116
- process.exit(1);
117
- }
118
- const result = await moduleManager.executeWorkflow(workflowName, context);
119
- if (!result.success) {
120
- console.error('Workflow execution failed:', result.error);
121
- process.exit(1);
122
- }
123
- console.log('Workflow completed successfully:', result.data);
124
- }
125
- // Try legacy commands first for backward compatibility
126
- else if (legacyCommands[argv.command]) {
127
- const legacyHandler = legacyCommands[argv.command];
128
- await legacyHandler(argv);
129
- }
130
- // Fall back to modular commands
131
- else {
132
- const result = await moduleManager.executeCommand(argv.command, context);
133
- if (!result.success) {
134
- console.error('Command execution failed:', result.error);
135
- process.exit(1);
136
- }
137
- console.log('Command completed successfully:', result.data);
69
+ printUsage(0);
70
+ } else if (commandHandlers[argv.command]) {
71
+ const handler = commandHandlers[argv.command];
72
+ await handler(argv);
73
+ } else {
74
+ throw new Error(`Unknown command: ${argv.command}`);
138
75
  }
139
76
  } catch (err: any) {
140
77
  if (err.status === 401) {
@@ -146,14 +83,12 @@ async function run() {
146
83
  }
147
84
  }
148
85
 
86
+ export { moduleManager } from './module-manager';
149
87
  export { CLIProviderImpl } from './provider';
150
88
  export type {
151
89
  CLIModule,
152
90
  CLIProvider,
153
91
  CommandDefinition,
154
- CustomWorkflow,
155
- WorkflowStep,
156
92
  } from './types';
157
- export { moduleManager };
158
93
 
159
94
  run();
package/src/locales/en.ts CHANGED
@@ -96,6 +96,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
96
96
  packageIdRequired: 'Please provide packageId or packageVersion parameter',
97
97
  packageUploadSuccess:
98
98
  'Successfully uploaded new hot update package (id: {{id}})',
99
+ depsChangeWarningTitle: 'Dependency changes detected',
99
100
  depsChangeSummary:
100
101
  'Dependency changes: added {{added}}, removed {{removed}}, changed {{changed}}.',
101
102
  depsChangeTargetPackage:
package/src/locales/zh.ts CHANGED
@@ -89,6 +89,7 @@ export default {
89
89
  operationSuccess: '操作成功',
90
90
  packageIdRequired: '请提供 packageId 或 packageVersion 参数',
91
91
  packageUploadSuccess: '已成功上传新热更包(id: {{id}})',
92
+ depsChangeWarningTitle: '检测到依赖变化',
92
93
  depsChangeSummary:
93
94
  '依赖变化:新增 {{added}} 项,移除 {{removed}} 项,版本变更 {{changed}} 项。',
94
95
  depsChangeTargetPackage: '目标原生包:{{packageName}} (id: {{packageId}})',
@@ -5,14 +5,12 @@ import type {
5
5
  CommandContext,
6
6
  CommandDefinition,
7
7
  CommandResult,
8
- CustomWorkflow,
9
8
  } from './types';
10
9
 
11
10
  export class ModuleManager {
12
11
  private modules: Map<string, CLIModule> = new Map();
13
12
  private provider: CLIProvider;
14
13
  private commands: Map<string, CommandDefinition> = new Map();
15
- private workflows: Map<string, CustomWorkflow> = new Map();
16
14
 
17
15
  constructor() {
18
16
  this.provider = new CLIProviderImpl();
@@ -31,12 +29,6 @@ export class ModuleManager {
31
29
  }
32
30
  }
33
31
 
34
- if (module.workflows) {
35
- for (const workflow of module.workflows) {
36
- this.registerWorkflow(workflow);
37
- }
38
- }
39
-
40
32
  if (module.init) {
41
33
  module.init(this.provider);
42
34
  }
@@ -54,12 +46,6 @@ export class ModuleManager {
54
46
  }
55
47
  }
56
48
 
57
- if (module.workflows) {
58
- for (const workflow of module.workflows) {
59
- this.workflows.delete(workflow.name);
60
- }
61
- }
62
-
63
49
  if (module.cleanup) {
64
50
  module.cleanup();
65
51
  }
@@ -75,14 +61,6 @@ export class ModuleManager {
75
61
  this.commands.set(command.name, command);
76
62
  }
77
63
 
78
- registerWorkflow(workflow: CustomWorkflow): void {
79
- if (this.workflows.has(workflow.name)) {
80
- throw new Error(`Workflow '${workflow.name}' is already registered`);
81
- }
82
- this.workflows.set(workflow.name, workflow);
83
- this.provider.registerWorkflow(workflow);
84
- }
85
-
86
64
  async executeCommand(
87
65
  commandName: string,
88
66
  context: CommandContext,
@@ -95,13 +73,6 @@ export class ModuleManager {
95
73
  return await command.handler(context);
96
74
  }
97
75
 
98
- async executeWorkflow(
99
- workflowName: string,
100
- context: CommandContext,
101
- ): Promise<CommandResult> {
102
- return await this.provider.executeWorkflow(workflowName, context);
103
- }
104
-
105
76
  getProvider(): CLIProvider {
106
77
  return this.provider;
107
78
  }
@@ -110,10 +81,6 @@ export class ModuleManager {
110
81
  return Array.from(this.commands.values());
111
82
  }
112
83
 
113
- listWorkflows(): CustomWorkflow[] {
114
- return Array.from(this.workflows.values());
115
- }
116
-
117
84
  listModules(): CLIModule[] {
118
85
  return Array.from(this.modules.values());
119
86
  }
@@ -126,17 +93,10 @@ export class ModuleManager {
126
93
  );
127
94
  }
128
95
 
129
- console.log('\n=== Registered Workflows ===');
130
- for (const workflow of this.workflows.values()) {
131
- console.log(
132
- ` ${workflow.name}: ${workflow.description || 'No description'}`,
133
- );
134
- }
135
-
136
96
  console.log('\n=== Registered Modules ===');
137
97
  for (const module of this.modules.values()) {
138
98
  console.log(
139
- ` ${module.name} (v${module.version}): ${module.commands?.length || 0} commands, ${module.workflows?.length || 0} workflows`,
99
+ ` ${module.name} (v${module.version}): ${module.commands?.length || 0} commands`,
140
100
  );
141
101
  }
142
102
  }