react-native-update-cli 2.10.1 → 2.11.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 (82) 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/app.d.ts +1 -1
  6. package/lib/app.js +42 -45
  7. package/lib/bin.d.ts +2 -0
  8. package/lib/bin.js +70 -0
  9. package/lib/bundle-runner.d.ts +1 -0
  10. package/lib/bundle-runner.js +46 -10
  11. package/lib/exports.d.ts +2 -9
  12. package/lib/exports.js +0 -31
  13. package/lib/index.d.ts +1 -5
  14. package/lib/index.js +12 -128
  15. package/lib/locales/en.d.ts +1 -0
  16. package/lib/locales/en.js +1 -0
  17. package/lib/locales/zh.d.ts +1 -0
  18. package/lib/locales/zh.js +1 -0
  19. package/lib/package.d.ts +1 -2
  20. package/lib/package.js +50 -10
  21. package/lib/provider.d.ts +1 -4
  22. package/lib/provider.js +6 -25
  23. package/lib/types.d.ts +0 -37
  24. package/lib/user.d.ts +1 -1
  25. package/lib/user.js +1 -1
  26. package/lib/utils/app-info-parser/aab.js +46 -5
  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 +0 -1
  33. package/lib/utils/index.js +0 -13
  34. package/lib/utils/plugin-config.js +42 -6
  35. package/lib/versions.d.ts +1 -0
  36. package/lib/versions.js +19 -16
  37. package/package.json +8 -10
  38. package/src/api.ts +1 -1
  39. package/src/app.ts +40 -40
  40. package/src/bin.ts +86 -0
  41. package/src/bundle-runner.ts +70 -12
  42. package/src/exports.ts +1 -12
  43. package/src/index.ts +1 -159
  44. package/src/locales/en.ts +1 -0
  45. package/src/locales/zh.ts +1 -0
  46. package/src/package.ts +6 -10
  47. package/src/provider.ts +10 -29
  48. package/src/types.ts +0 -54
  49. package/src/user.ts +1 -1
  50. package/src/utils/app-info-parser/aab.ts +2 -2
  51. package/src/utils/app-info-parser/resource-finder.ts +5 -5
  52. package/src/utils/app-info-parser/utils.ts +2 -2
  53. package/src/utils/check-lockfile.ts +1 -1
  54. package/src/utils/dep-versions.ts +2 -2
  55. package/src/utils/http-helper.ts +2 -2
  56. package/src/utils/index.ts +1 -12
  57. package/src/utils/plugin-config.ts +1 -1
  58. package/src/versions.ts +25 -17
  59. package/lib/module-manager.d.ts +0 -20
  60. package/lib/module-manager.js +0 -118
  61. package/lib/modules/app-module.d.ts +0 -2
  62. package/lib/modules/app-module.js +0 -263
  63. package/lib/modules/bundle-module.d.ts +0 -2
  64. package/lib/modules/bundle-module.js +0 -187
  65. package/lib/modules/index.d.ts +0 -6
  66. package/lib/modules/index.js +0 -42
  67. package/lib/modules/package-module.d.ts +0 -2
  68. package/lib/modules/package-module.js +0 -16
  69. package/lib/modules/user-module.d.ts +0 -2
  70. package/lib/modules/user-module.js +0 -413
  71. package/lib/modules/version-module.d.ts +0 -2
  72. package/lib/modules/version-module.js +0 -16
  73. package/lib/workflow-runner.d.ts +0 -2
  74. package/lib/workflow-runner.js +0 -25
  75. package/src/module-manager.ts +0 -145
  76. package/src/modules/app-module.ts +0 -277
  77. package/src/modules/bundle-module.ts +0 -212
  78. package/src/modules/index.ts +0 -19
  79. package/src/modules/package-module.ts +0 -10
  80. package/src/modules/user-module.ts +0 -465
  81. package/src/modules/version-module.ts +0 -8
  82. package/src/workflow-runner.ts +0 -24
package/src/types.ts CHANGED
@@ -45,20 +45,6 @@ export interface CommandResult {
45
45
  error?: string;
46
46
  }
47
47
 
48
- export interface CommandDefinition {
49
- name: string;
50
- description?: string;
51
- handler: (context: CommandContext) => Promise<CommandResult>;
52
- options?: Record<
53
- string,
54
- {
55
- hasValue?: boolean;
56
- default?: unknown;
57
- description?: string;
58
- }
59
- >;
60
- }
61
-
62
48
  export interface BundleOptions {
63
49
  dev?: boolean;
64
50
  platform?: Platform;
@@ -92,31 +78,6 @@ export interface UploadOptions {
92
78
  version?: string;
93
79
  }
94
80
 
95
- export interface WorkflowStep {
96
- name: string;
97
- description?: string;
98
- execute: (
99
- context: CommandContext,
100
- previousResult?: unknown,
101
- ) => Promise<unknown>;
102
- condition?: (context: CommandContext) => boolean;
103
- }
104
-
105
- export interface CustomWorkflow {
106
- name: string;
107
- description?: string;
108
- steps: WorkflowStep[];
109
- validate?: (context: CommandContext) => boolean;
110
- options?: Record<
111
- string,
112
- {
113
- hasValue?: boolean;
114
- default?: unknown;
115
- description?: string;
116
- }
117
- >;
118
- }
119
-
120
81
  export interface CLIProvider {
121
82
  bundle: (options: BundleOptions) => Promise<CommandResult>;
122
83
  publish: (options: PublishOptions) => Promise<CommandResult>;
@@ -137,19 +98,4 @@ export interface CLIProvider {
137
98
 
138
99
  getPlatform: (platform?: Platform) => Promise<Platform>;
139
100
  loadSession: () => Promise<Session>;
140
-
141
- registerWorkflow: (workflow: CustomWorkflow) => void;
142
- executeWorkflow: (
143
- workflowName: string,
144
- context: CommandContext,
145
- ) => Promise<CommandResult>;
146
- }
147
-
148
- export interface CLIModule {
149
- name: string;
150
- version: string;
151
- commands?: CommandDefinition[];
152
- workflows?: CustomWorkflow[];
153
- init?: (provider: CLIProvider) => void;
154
- cleanup?: () => void;
155
101
  }
package/src/user.ts CHANGED
@@ -20,7 +20,7 @@ export const userCommands = {
20
20
  await saveSession();
21
21
  console.log(t('welcomeMessage', { name: info.name }));
22
22
  },
23
- logout: async (context: CommandContext) => {
23
+ logout: async (_context: CommandContext) => {
24
24
  await closeSession();
25
25
  console.log(t('loggedOut'));
26
26
  },
@@ -1,5 +1,5 @@
1
1
  import { spawn } from 'child_process';
2
- import fs from 'fs-extra';
2
+ import * as fs from 'fs-extra';
3
3
  import os from 'os';
4
4
  import path from 'path';
5
5
  import { open as openZipFile } from 'yauzl';
@@ -88,7 +88,7 @@ export class AabParser extends 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()) {
@@ -74,14 +74,14 @@ export class ResourceFinder {
74
74
  while (true) {
75
75
  let pos = 0;
76
76
  let t = 0;
77
- let hs = 0;
77
+ let _hs = 0;
78
78
  let s = 0;
79
79
  try {
80
80
  pos = bb.offset;
81
81
  t = bb.readShort();
82
- hs = bb.readShort();
82
+ _hs = bb.readShort();
83
83
  s = bb.readInt();
84
- } catch (e) {
84
+ } catch (_e) {
85
85
  break;
86
86
  }
87
87
  if (t === RES_STRING_POOL_TYPE) {
@@ -231,7 +231,7 @@ export class ResourceFinder {
231
231
  if (!bb.remaining()) {
232
232
  break;
233
233
  }
234
- } catch (e) {
234
+ } catch (_e) {
235
235
  break;
236
236
  }
237
237
  }
@@ -288,7 +288,7 @@ export class ResourceFinder {
288
288
  entrySize = bb.readShort();
289
289
  entryFlag = bb.readShort();
290
290
  entryKey = bb.readInt();
291
- } catch (e) {
291
+ } catch (_e) {
292
292
  break;
293
293
  }
294
294
 
@@ -71,7 +71,7 @@ const mapInfoResource = (
71
71
  * @param info // json info parsed from .apk file
72
72
  */
73
73
  const findApkIconPath = (info: any) => {
74
- if (!info.application.icon || !info.application.icon.splice) {
74
+ if (!info.application.icon?.splice) {
75
75
  return '';
76
76
  }
77
77
  const rulesMap: Record<string, number> = {
@@ -142,7 +142,7 @@ const getBase64FromBuffer = (buffer: Buffer | string) => {
142
142
  */
143
143
  const decodeNullUnicode = (value: string | RegExp) => {
144
144
  if (typeof value === 'string') {
145
- // biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
145
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: strips null unicode padding from decoded strings
146
146
  return value.replace(/\u0000/g, '');
147
147
  }
148
148
  return value;
@@ -17,7 +17,7 @@ function hasWorkspaces(dir: string): boolean {
17
17
  try {
18
18
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
19
19
  return !!pkg.workspaces;
20
- } catch (e) {
20
+ } catch (_e) {
21
21
  // Ignore parsing errors
22
22
  }
23
23
  }
@@ -1,7 +1,7 @@
1
1
  let currentPackage = null;
2
2
  try {
3
3
  currentPackage = require(`${process.cwd()}/package.json`);
4
- } catch (e) {
4
+ } catch (_e) {
5
5
  // console.warn('No package.json file were found');
6
6
  }
7
7
 
@@ -23,7 +23,7 @@ if (currentPackage) {
23
23
  });
24
24
  const version = require(packageJsonPath).version;
25
25
  _depVersions[dep] = version;
26
- } catch (e) {}
26
+ } catch (_e) {}
27
27
  }
28
28
  }
29
29
 
@@ -28,7 +28,7 @@ export const ping = async (url: string) => {
28
28
  fetch(url, {
29
29
  method: 'HEAD',
30
30
  })
31
- .then(({ status, statusText }) => {
31
+ .then(({ status }) => {
32
32
  pingFinished = true;
33
33
  if (status === 200) {
34
34
  // console.log('ping success', url);
@@ -37,7 +37,7 @@ export const ping = async (url: string) => {
37
37
  // console.log('ping failed', url, status, statusText);
38
38
  throw new Error('ping failed');
39
39
  })
40
- .catch((e) => {
40
+ .catch((_e) => {
41
41
  pingFinished = true;
42
42
  // console.log('ping error', url, e);
43
43
  throw new Error('ping error');
@@ -1,7 +1,5 @@
1
1
  import chalk from 'chalk';
2
2
  import { satisfies } from 'compare-versions';
3
- import fs from 'fs-extra';
4
- import os from 'os';
5
3
  import path from 'path';
6
4
  import type { Root as ProtobufRoot } from 'protobufjs';
7
5
  import { read } from 'read';
@@ -10,7 +8,7 @@ import pkg from '../../package.json';
10
8
  import latestVersion from '../utils/latest-version';
11
9
  import AppInfoParser from './app-info-parser';
12
10
  import { checkPlugins } from './check-plugin';
13
- import { IS_CRESC, tempDir } from './constants';
11
+ import { IS_CRESC } from './constants';
14
12
  import { depVersions } from './dep-versions';
15
13
  import { t } from './i18n';
16
14
 
@@ -401,15 +399,6 @@ async function resolveResource(
401
399
  return null;
402
400
  }
403
401
 
404
- const localDir = path.resolve(os.homedir(), tempDir);
405
- fs.ensureDirSync(localDir);
406
- export function saveToLocal(originPath: string, destName: string) {
407
- // TODO
408
- // const destPath = path.join(localDir, destName);
409
- // fs.ensureDirSync(path.dirname(destPath));
410
- // fs.copyFileSync(originPath, destPath);
411
- }
412
-
413
402
  async function getLatestVersion(pkgNames: string[]) {
414
403
  return latestVersion(pkgNames, {
415
404
  // useCache: true,
@@ -1,4 +1,4 @@
1
- import fs from 'fs-extra';
1
+ import * as fs from 'fs-extra';
2
2
 
3
3
  interface PluginConfig {
4
4
  name: string;
package/src/versions.ts CHANGED
@@ -5,7 +5,7 @@ import { doDelete, get, getAllPackages, post, put, uploadFile } from './api';
5
5
  import { getPlatform, getSelectedApp } from './app';
6
6
  import { choosePackage } from './package';
7
7
  import type { Package, Platform, Version } from './types';
8
- import { question, saveToLocal } from './utils';
8
+ import { question } from './utils';
9
9
  import { depVersions } from './utils/dep-versions';
10
10
  import { getCommitInfo } from './utils/git';
11
11
  import { t } from './utils/i18n';
@@ -25,6 +25,7 @@ interface VersionCommandOptions {
25
25
  rollout?: string;
26
26
  dryRun?: boolean;
27
27
  versionDeps?: Record<string, string>;
28
+ warnDepsChanges?: boolean;
28
29
  }
29
30
 
30
31
  type Deps = Record<string, string>;
@@ -193,6 +194,7 @@ function printDepsChangesForPackage({
193
194
  ]);
194
195
 
195
196
  console.log('');
197
+ console.log(chalk.bgYellow.black.bold(` ${t('depsChangeWarningTitle')} `));
196
198
  console.log(
197
199
  chalk.yellow(
198
200
  t('depsChangeTargetPackage', {
@@ -243,7 +245,7 @@ async function printDepsChangesForPublish({
243
245
  pkgs: Package[];
244
246
  providedVersionDeps?: Deps;
245
247
  }) {
246
- if (!versionId || pkgs.length === 0) {
248
+ if (!versionId || pkgs.length !== 1) {
247
249
  return;
248
250
  }
249
251
 
@@ -279,7 +281,7 @@ async function printDepsChangesForPublish({
279
281
  }
280
282
 
281
283
  async function showVersion(appId: string, offset: number) {
282
- const { data, count } = await get(`/app/${appId}/version/list`);
284
+ const { data } = await get(`/app/${appId}/version/list`);
283
285
  console.log(t('offset', { offset }));
284
286
  for (const version of data) {
285
287
  const pkgCount = version.packages?.length || 0;
@@ -401,17 +403,17 @@ export const bindVersionToPackages = async ({
401
403
  };
402
404
 
403
405
  export const versionCommands = {
404
- publish: async function ({
406
+ publish: async ({
405
407
  args,
406
408
  options,
407
409
  }: {
408
410
  args: string[];
409
411
  options: VersionCommandOptions;
410
- }) {
412
+ }) => {
411
413
  const fn = args[0];
412
414
  const { name, description, metaInfo } = options;
413
415
 
414
- if (!fn || !fn.endsWith('.ppk')) {
416
+ if (!fn?.endsWith('.ppk')) {
415
417
  throw new Error(t('publishUsage'));
416
418
  }
417
419
 
@@ -431,8 +433,6 @@ export const versionCommands = {
431
433
  deps: depVersions,
432
434
  commit: await getCommitInfo(),
433
435
  });
434
- // TODO local diff
435
- saveToLocal(fn, `${appId}/ppk/${id}.ppk`);
436
436
  console.log(t('packageUploadSuccess', { id }));
437
437
 
438
438
  const {
@@ -452,7 +452,7 @@ export const versionCommands = {
452
452
  minPackageVersion ||
453
453
  maxPackageVersion
454
454
  ) {
455
- await this.update({
455
+ await versionCommands.update({
456
456
  options: {
457
457
  versionId: id,
458
458
  platform,
@@ -464,13 +464,19 @@ export const versionCommands = {
464
464
  rollout,
465
465
  dryRun,
466
466
  versionDeps: depVersions,
467
+ warnDepsChanges: true,
467
468
  },
468
469
  });
469
470
  } else {
470
471
  const q = await question(t('updateNativePackageQuestion'));
471
472
  if (q.toLowerCase() === 'y') {
472
- await this.update({
473
- options: { versionId: id, platform, versionDeps: depVersions },
473
+ await versionCommands.update({
474
+ options: {
475
+ versionId: id,
476
+ platform,
477
+ versionDeps: depVersions,
478
+ warnDepsChanges: true,
479
+ },
474
480
  });
475
481
  }
476
482
  }
@@ -570,12 +576,14 @@ export const versionCommands = {
570
576
  }
571
577
  }
572
578
 
573
- await printDepsChangesForPublish({
574
- appId: String(appId),
575
- versionId: String(versionId),
576
- pkgs: pkgsToBind,
577
- providedVersionDeps: options.versionDeps,
578
- });
579
+ if (options.warnDepsChanges) {
580
+ await printDepsChangesForPublish({
581
+ appId: String(appId),
582
+ versionId: String(versionId),
583
+ pkgs: pkgsToBind,
584
+ providedVersionDeps: options.versionDeps,
585
+ });
586
+ }
579
587
 
580
588
  await bindVersionToPackages({
581
589
  appId: String(appId),
@@ -1,20 +0,0 @@
1
- import type { CLIModule, CLIProvider, CommandContext, CommandDefinition, CommandResult, CustomWorkflow } from './types';
2
- export declare class ModuleManager {
3
- private modules;
4
- private provider;
5
- private commands;
6
- private workflows;
7
- constructor();
8
- registerModule(module: CLIModule): void;
9
- unregisterModule(moduleName: string): void;
10
- registerCommand(command: CommandDefinition): void;
11
- registerWorkflow(workflow: CustomWorkflow): void;
12
- executeCommand(commandName: string, context: CommandContext): Promise<CommandResult>;
13
- executeWorkflow(workflowName: string, context: CommandContext): Promise<CommandResult>;
14
- getProvider(): CLIProvider;
15
- listCommands(): CommandDefinition[];
16
- listWorkflows(): CustomWorkflow[];
17
- listModules(): CLIModule[];
18
- listAll(): void;
19
- }
20
- export declare const moduleManager: ModuleManager;
@@ -1,118 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get ModuleManager () {
13
- return ModuleManager;
14
- },
15
- get moduleManager () {
16
- return moduleManager;
17
- }
18
- });
19
- const _provider = require("./provider");
20
- class ModuleManager {
21
- registerModule(module) {
22
- if (this.modules.has(module.name)) {
23
- throw new Error(`Module '${module.name}' is already registered`);
24
- }
25
- this.modules.set(module.name, module);
26
- if (module.commands) {
27
- for (const command of module.commands){
28
- this.registerCommand(command);
29
- }
30
- }
31
- if (module.workflows) {
32
- for (const workflow of module.workflows){
33
- this.registerWorkflow(workflow);
34
- }
35
- }
36
- if (module.init) {
37
- module.init(this.provider);
38
- }
39
- }
40
- unregisterModule(moduleName) {
41
- const module = this.modules.get(moduleName);
42
- if (!module) {
43
- throw new Error(`Module '${moduleName}' is not registered`);
44
- }
45
- if (module.commands) {
46
- for (const command of module.commands){
47
- this.commands.delete(command.name);
48
- }
49
- }
50
- if (module.workflows) {
51
- for (const workflow of module.workflows){
52
- this.workflows.delete(workflow.name);
53
- }
54
- }
55
- if (module.cleanup) {
56
- module.cleanup();
57
- }
58
- this.modules.delete(moduleName);
59
- console.log(`Module '${moduleName}' unregistered successfully`);
60
- }
61
- registerCommand(command) {
62
- if (this.commands.has(command.name)) {
63
- throw new Error(`Command '${command.name}' is already registered`);
64
- }
65
- this.commands.set(command.name, command);
66
- }
67
- registerWorkflow(workflow) {
68
- if (this.workflows.has(workflow.name)) {
69
- throw new Error(`Workflow '${workflow.name}' is already registered`);
70
- }
71
- this.workflows.set(workflow.name, workflow);
72
- this.provider.registerWorkflow(workflow);
73
- }
74
- async executeCommand(commandName, context) {
75
- const command = this.commands.get(commandName);
76
- if (!command) {
77
- throw new Error(`Command '${commandName}' not found`);
78
- }
79
- return await command.handler(context);
80
- }
81
- async executeWorkflow(workflowName, context) {
82
- return await this.provider.executeWorkflow(workflowName, context);
83
- }
84
- getProvider() {
85
- return this.provider;
86
- }
87
- listCommands() {
88
- return Array.from(this.commands.values());
89
- }
90
- listWorkflows() {
91
- return Array.from(this.workflows.values());
92
- }
93
- listModules() {
94
- return Array.from(this.modules.values());
95
- }
96
- listAll() {
97
- console.log('\n=== Registered Commands ===');
98
- for (const command of this.commands.values()){
99
- console.log(` ${command.name}: ${command.description || 'No description'}`);
100
- }
101
- console.log('\n=== Registered Workflows ===');
102
- for (const workflow of this.workflows.values()){
103
- console.log(` ${workflow.name}: ${workflow.description || 'No description'}`);
104
- }
105
- console.log('\n=== Registered Modules ===');
106
- for (const module of this.modules.values()){
107
- var _module_commands, _module_workflows;
108
- console.log(` ${module.name} (v${module.version}): ${((_module_commands = module.commands) == null ? void 0 : _module_commands.length) || 0} commands, ${((_module_workflows = module.workflows) == null ? void 0 : _module_workflows.length) || 0} workflows`);
109
- }
110
- }
111
- constructor(){
112
- this.modules = new Map();
113
- this.commands = new Map();
114
- this.workflows = new Map();
115
- this.provider = new _provider.CLIProviderImpl();
116
- }
117
- }
118
- const moduleManager = new ModuleManager();
@@ -1,2 +0,0 @@
1
- import type { CLIModule } from '../types';
2
- export declare const appModule: CLIModule;