react-native-update-cli 2.10.0 → 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.
- package/README.md +47 -497
- package/README.zh-CN.md +52 -500
- package/cli.json +2 -16
- package/lib/api.js +1 -1
- package/lib/app.d.ts +7 -6
- package/lib/app.js +23 -22
- package/lib/exports.d.ts +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +14 -62
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/module-manager.d.ts +1 -5
- package/lib/module-manager.js +2 -30
- package/lib/modules/app-module.js +1 -249
- package/lib/modules/bundle-module.js +1 -173
- package/lib/modules/package-module.js +1 -2
- package/lib/modules/user-module.js +1 -399
- package/lib/modules/version-module.js +1 -2
- package/lib/package.d.ts +1 -2
- package/lib/package.js +6 -6
- package/lib/provider.d.ts +1 -4
- package/lib/provider.js +2 -21
- package/lib/types.d.ts +0 -20
- package/lib/user.d.ts +1 -1
- package/lib/user.js +1 -1
- package/lib/utils/app-info-parser/aab.js +1 -1
- package/lib/utils/app-info-parser/resource-finder.js +5 -5
- package/lib/utils/app-info-parser/utils.js +3 -2
- package/lib/utils/check-lockfile.js +1 -1
- package/lib/utils/dep-versions.js +2 -2
- package/lib/utils/http-helper.js +2 -2
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/versions.d.ts +1 -0
- package/lib/versions.js +19 -14
- package/package.json +1 -1
- package/src/api.ts +1 -1
- package/src/app.ts +39 -40
- package/src/exports.ts +0 -2
- package/src/index.ts +16 -81
- package/src/locales/en.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/src/module-manager.ts +1 -41
- package/src/modules/app-module.ts +1 -271
- package/src/modules/bundle-module.ts +1 -206
- package/src/modules/package-module.ts +0 -3
- package/src/modules/user-module.ts +1 -459
- package/src/modules/version-module.ts +0 -1
- package/src/package.ts +5 -7
- package/src/provider.ts +4 -25
- package/src/types.ts +0 -32
- package/src/user.ts +1 -1
- package/src/utils/app-info-parser/aab.ts +1 -1
- package/src/utils/app-info-parser/resource-finder.ts +5 -5
- package/src/utils/app-info-parser/utils.ts +2 -2
- package/src/utils/check-lockfile.ts +1 -1
- package/src/utils/dep-versions.ts +2 -2
- package/src/utils/http-helper.ts +2 -2
- package/src/utils/index.ts +1 -1
- package/src/versions.ts +24 -14
- package/lib/workflow-runner.d.ts +0 -2
- package/lib/workflow-runner.js +0 -25
- package/src/workflow-runner.ts +0 -24
package/lib/provider.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { BundleOptions, CLIProvider,
|
|
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 ||
|
|
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
package/lib/user.js
CHANGED
|
@@ -88,7 +88,7 @@ class AabParser extends _zip.Zip {
|
|
|
88
88
|
'--overwrite',
|
|
89
89
|
...modulesArgs
|
|
90
90
|
]);
|
|
91
|
-
} catch (
|
|
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
|
|
62
|
+
let _hs = 0;
|
|
63
63
|
let s = 0;
|
|
64
64
|
try {
|
|
65
65
|
pos = bb.offset;
|
|
66
66
|
t = bb.readShort();
|
|
67
|
-
|
|
67
|
+
_hs = bb.readShort();
|
|
68
68
|
s = bb.readInt();
|
|
69
|
-
} catch (
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
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:
|
|
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;
|
|
@@ -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 (
|
|
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 (
|
|
36
|
+
} catch (_e) {}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
const depVersions = Object.keys(_depVersions).sort() // Sort the keys alphabetically
|
package/lib/utils/http-helper.js
CHANGED
|
@@ -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
|
|
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((
|
|
58
|
+
}).catch((_e)=>{
|
|
59
59
|
pingFinished = true;
|
|
60
60
|
// console.log('ping error', url, e);
|
|
61
61
|
throw new Error('ping error');
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -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(
|
|
20
|
+
export declare function saveToLocal(_originPath: string, _destName: string): void;
|
|
21
21
|
export declare function printVersionCommand(): Promise<void>;
|
|
22
22
|
export { checkPlugins };
|
package/lib/utils/index.js
CHANGED
|
@@ -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(
|
|
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
|
|
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
|
|
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
|
|
309
|
+
publish: async ({ args, options })=>{
|
|
309
310
|
const fn = args[0];
|
|
310
311
|
const { name, description, metaInfo } = options;
|
|
311
|
-
if (!fn
|
|
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
|
|
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
|
|
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
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
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
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 (
|
|
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/app.ts
CHANGED
|
@@ -87,19 +87,53 @@ export async function chooseApp(platform: Platform) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
async function selectApp({
|
|
91
|
+
args,
|
|
92
|
+
options,
|
|
93
|
+
}: {
|
|
94
|
+
args: string[];
|
|
95
|
+
options: { platform?: Platform | '' };
|
|
96
|
+
}) {
|
|
97
|
+
const platform = await getPlatform(options.platform);
|
|
98
|
+
const id = args[0]
|
|
99
|
+
? Number.parseInt(args[0], 10)
|
|
100
|
+
: (await chooseApp(platform)).id;
|
|
101
|
+
|
|
102
|
+
let updateInfo: Partial<Record<Platform, { appId: number; appKey: string }>> =
|
|
103
|
+
{};
|
|
104
|
+
try {
|
|
105
|
+
updateInfo = JSON.parse(await fs.promises.readFile('update.json', 'utf8'));
|
|
106
|
+
} catch (e: any) {
|
|
107
|
+
if (e.code !== 'ENOENT') {
|
|
108
|
+
console.error(t('failedToParseUpdateJson'));
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const { appKey } = await get(`/app/${id}`);
|
|
113
|
+
updateInfo[platform] = {
|
|
114
|
+
appId: id,
|
|
115
|
+
appKey,
|
|
116
|
+
};
|
|
117
|
+
await fs.promises.writeFile(
|
|
118
|
+
'update.json',
|
|
119
|
+
JSON.stringify(updateInfo, null, 4),
|
|
120
|
+
'utf8',
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
90
124
|
export const appCommands = {
|
|
91
|
-
createApp: async
|
|
125
|
+
createApp: async ({
|
|
92
126
|
options,
|
|
93
127
|
}: {
|
|
94
128
|
options: { name: string; downloadUrl: string; platform?: Platform | '' };
|
|
95
|
-
}) {
|
|
129
|
+
}) => {
|
|
96
130
|
const name = options.name || (await question(t('appNameQuestion')));
|
|
97
131
|
const { downloadUrl } = options;
|
|
98
132
|
const platform = await getPlatform(options.platform);
|
|
99
133
|
const { id } = await post('/app/create', { name, platform, downloadUrl });
|
|
100
134
|
console.log(t('createAppSuccess', { id }));
|
|
101
|
-
await
|
|
102
|
-
args: [id],
|
|
135
|
+
await selectApp({
|
|
136
|
+
args: [String(id)],
|
|
103
137
|
options: { platform },
|
|
104
138
|
});
|
|
105
139
|
},
|
|
@@ -122,40 +156,5 @@ export const appCommands = {
|
|
|
122
156
|
const { platform = '' } = options;
|
|
123
157
|
await listApp(platform);
|
|
124
158
|
},
|
|
125
|
-
selectApp
|
|
126
|
-
args,
|
|
127
|
-
options,
|
|
128
|
-
}: {
|
|
129
|
-
args: string[];
|
|
130
|
-
options: { platform?: Platform | '' };
|
|
131
|
-
}) => {
|
|
132
|
-
const platform = await getPlatform(options.platform);
|
|
133
|
-
const id = args[0]
|
|
134
|
-
? Number.parseInt(args[0])
|
|
135
|
-
: (await chooseApp(platform)).id;
|
|
136
|
-
|
|
137
|
-
let updateInfo: Partial<
|
|
138
|
-
Record<Platform, { appId: number; appKey: string }>
|
|
139
|
-
> = {};
|
|
140
|
-
try {
|
|
141
|
-
updateInfo = JSON.parse(
|
|
142
|
-
await fs.promises.readFile('update.json', 'utf8'),
|
|
143
|
-
);
|
|
144
|
-
} catch (e: any) {
|
|
145
|
-
if (e.code !== 'ENOENT') {
|
|
146
|
-
console.error(t('failedToParseUpdateJson'));
|
|
147
|
-
throw e;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
const { appKey } = await get(`/app/${id}`);
|
|
151
|
-
updateInfo[platform] = {
|
|
152
|
-
appId: id,
|
|
153
|
-
appKey,
|
|
154
|
-
};
|
|
155
|
-
await fs.promises.writeFile(
|
|
156
|
-
'update.json',
|
|
157
|
-
JSON.stringify(updateInfo, null, 4),
|
|
158
|
-
'utf8',
|
|
159
|
-
);
|
|
160
|
-
},
|
|
159
|
+
selectApp,
|
|
161
160
|
};
|
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
|
|
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
|
|
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('
|
|
39
|
-
for (const name of Object.keys(
|
|
40
|
-
console.log(` ${name}
|
|
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
|
|
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(
|
|
39
|
+
process.exit(exitCode);
|
|
72
40
|
}
|
|
73
41
|
|
|
74
|
-
const
|
|
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
|
-
|
|
112
|
-
} else if (argv.command
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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}})',
|