react-native-update-cli 2.10.2 → 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.
- package/lib/app.d.ts +1 -1
- package/lib/app.js +42 -45
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +70 -0
- package/lib/bundle-runner.d.ts +1 -0
- package/lib/bundle-runner.js +46 -10
- package/lib/exports.d.ts +2 -9
- package/lib/exports.js +0 -31
- package/lib/index.d.ts +1 -4
- package/lib/index.js +12 -80
- package/lib/package.js +44 -4
- package/lib/provider.js +4 -4
- package/lib/types.d.ts +0 -17
- package/lib/utils/app-info-parser/aab.js +45 -4
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -13
- package/lib/utils/plugin-config.js +42 -6
- package/lib/versions.js +0 -2
- package/package.json +8 -10
- package/src/app.ts +40 -40
- package/src/bin.ts +86 -0
- package/src/bundle-runner.ts +70 -12
- package/src/exports.ts +1 -10
- package/src/index.ts +1 -94
- package/src/package.ts +1 -3
- package/src/provider.ts +6 -4
- package/src/types.ts +0 -22
- package/src/utils/app-info-parser/aab.ts +1 -1
- package/src/utils/index.ts +1 -12
- package/src/utils/plugin-config.ts +1 -1
- package/src/versions.ts +1 -3
- package/lib/module-manager.d.ts +0 -16
- package/lib/module-manager.js +0 -90
- package/lib/modules/app-module.d.ts +0 -2
- package/lib/modules/app-module.js +0 -15
- package/lib/modules/bundle-module.d.ts +0 -2
- package/lib/modules/bundle-module.js +0 -15
- package/lib/modules/index.d.ts +0 -6
- package/lib/modules/index.js +0 -42
- package/lib/modules/package-module.d.ts +0 -2
- package/lib/modules/package-module.js +0 -15
- package/lib/modules/user-module.d.ts +0 -2
- package/lib/modules/user-module.js +0 -15
- package/lib/modules/version-module.d.ts +0 -2
- package/lib/modules/version-module.js +0 -15
- package/src/module-manager.ts +0 -105
- package/src/modules/app-module.ts +0 -7
- package/src/modules/bundle-module.ts +0 -7
- package/src/modules/index.ts +0 -19
- package/src/modules/package-module.ts +0 -7
- package/src/modules/user-module.ts +0 -7
- package/src/modules/version-module.ts +0 -7
package/lib/utils/index.js
CHANGED
|
@@ -30,17 +30,12 @@ _export(exports, {
|
|
|
30
30
|
get question () {
|
|
31
31
|
return question;
|
|
32
32
|
},
|
|
33
|
-
get saveToLocal () {
|
|
34
|
-
return saveToLocal;
|
|
35
|
-
},
|
|
36
33
|
get translateOptions () {
|
|
37
34
|
return translateOptions;
|
|
38
35
|
}
|
|
39
36
|
});
|
|
40
37
|
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
|
|
41
38
|
const _compareversions = require("compare-versions");
|
|
42
|
-
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra"));
|
|
43
|
-
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
44
39
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
45
40
|
const _read = require("read");
|
|
46
41
|
const _yauzl = require("yauzl");
|
|
@@ -336,14 +331,6 @@ async function resolveResource(fn, resourceId, root) {
|
|
|
336
331
|
}
|
|
337
332
|
return null;
|
|
338
333
|
}
|
|
339
|
-
const localDir = _path.default.resolve(_os.default.homedir(), _constants.tempDir);
|
|
340
|
-
_fsextra.default.ensureDirSync(localDir);
|
|
341
|
-
function saveToLocal(_originPath, _destName) {
|
|
342
|
-
// TODO
|
|
343
|
-
// const destPath = path.join(localDir, destName);
|
|
344
|
-
// fs.ensureDirSync(path.dirname(destPath));
|
|
345
|
-
// fs.copyFileSync(originPath, destPath);
|
|
346
|
-
}
|
|
347
334
|
async function getLatestVersion(pkgNames) {
|
|
348
335
|
return (0, _latestversion.default)(pkgNames, {
|
|
349
336
|
// useCache: true,
|
|
@@ -8,11 +8,47 @@ Object.defineProperty(exports, "plugins", {
|
|
|
8
8
|
return plugins;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _fsextra = /*#__PURE__*/
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
13
|
+
if (typeof WeakMap !== "function") return null;
|
|
14
|
+
var cacheBabelInterop = new WeakMap();
|
|
15
|
+
var cacheNodeInterop = new WeakMap();
|
|
16
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
17
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
18
|
+
})(nodeInterop);
|
|
19
|
+
}
|
|
20
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
21
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
24
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
25
|
+
return {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
30
|
+
if (cache && cache.has(obj)) {
|
|
31
|
+
return cache.get(obj);
|
|
32
|
+
}
|
|
33
|
+
var newObj = {
|
|
34
|
+
__proto__: null
|
|
15
35
|
};
|
|
36
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
37
|
+
for(var key in obj){
|
|
38
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
39
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
40
|
+
if (desc && (desc.get || desc.set)) {
|
|
41
|
+
Object.defineProperty(newObj, key, desc);
|
|
42
|
+
} else {
|
|
43
|
+
newObj[key] = obj[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
newObj.default = obj;
|
|
48
|
+
if (cache) {
|
|
49
|
+
cache.set(obj, newObj);
|
|
50
|
+
}
|
|
51
|
+
return newObj;
|
|
16
52
|
}
|
|
17
53
|
const plugins = [
|
|
18
54
|
{
|
|
@@ -23,11 +59,11 @@ const plugins = [
|
|
|
23
59
|
},
|
|
24
60
|
detect: async ()=>{
|
|
25
61
|
try {
|
|
26
|
-
await _fsextra.
|
|
62
|
+
await _fsextra.access('ios/sentry.properties');
|
|
27
63
|
return true;
|
|
28
64
|
} catch (unused) {
|
|
29
65
|
try {
|
|
30
|
-
await _fsextra.
|
|
66
|
+
await _fsextra.access('android/sentry.properties');
|
|
31
67
|
return true;
|
|
32
68
|
} catch (unused) {
|
|
33
69
|
return false;
|
package/lib/versions.js
CHANGED
|
@@ -324,8 +324,6 @@ const versionCommands = {
|
|
|
324
324
|
deps: _depversions.depVersions,
|
|
325
325
|
commit: await (0, _git.getCommitInfo)()
|
|
326
326
|
});
|
|
327
|
-
// TODO local diff
|
|
328
|
-
(0, _utils.saveToLocal)(fn, `${appId}/ppk/${id}.ppk`);
|
|
329
327
|
console.log((0, _i18n.t)('packageUploadSuccess', {
|
|
330
328
|
id
|
|
331
329
|
}));
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
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",
|
|
7
7
|
"bin": {
|
|
8
|
-
"pushy": "lib/
|
|
9
|
-
"cresc": "lib/
|
|
8
|
+
"pushy": "lib/bin.js",
|
|
9
|
+
"cresc": "lib/bin.js"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -14,11 +14,6 @@
|
|
|
14
14
|
"require": "./lib/exports.js",
|
|
15
15
|
"default": "./lib/exports.js"
|
|
16
16
|
},
|
|
17
|
-
"./cli": {
|
|
18
|
-
"types": "./lib/index.d.ts",
|
|
19
|
-
"require": "./lib/index.js",
|
|
20
|
-
"default": "./lib/index.js"
|
|
21
|
-
},
|
|
22
17
|
"./diff": {
|
|
23
18
|
"types": "./lib/diff.d.ts",
|
|
24
19
|
"require": "./lib/diff.js",
|
|
@@ -37,8 +32,8 @@
|
|
|
37
32
|
"cli.json"
|
|
38
33
|
],
|
|
39
34
|
"scripts": {
|
|
40
|
-
"build": "rm -rf lib && swc src -d lib --strip-leading-paths && bun run typecheck:build",
|
|
41
|
-
"prepublishOnly": "bun run build
|
|
35
|
+
"build": "rm -rf lib && swc src -d lib --strip-leading-paths && bun run typecheck:build && chmod +x lib/bin.js",
|
|
36
|
+
"prepublishOnly": "bun run build",
|
|
42
37
|
"typecheck": "tsc --noEmit",
|
|
43
38
|
"typecheck:build": "tsc -p tsconfig.build.json",
|
|
44
39
|
"lint": "bun run typecheck && biome check .",
|
|
@@ -93,6 +88,9 @@
|
|
|
93
88
|
"yauzl": "^3.3.0",
|
|
94
89
|
"yazl": "3.3.1"
|
|
95
90
|
},
|
|
91
|
+
"overrides": {
|
|
92
|
+
"@xmldom/xmldom": "0.8.13"
|
|
93
|
+
},
|
|
96
94
|
"engines": {
|
|
97
95
|
"node": ">= 16.6.0"
|
|
98
96
|
},
|
package/src/app.ts
CHANGED
|
@@ -11,8 +11,6 @@ interface AppSummary {
|
|
|
11
11
|
platform: Platform;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const validPlatforms = ['ios', 'android', 'harmony'] as const;
|
|
15
|
-
|
|
16
14
|
export async function getPlatform(platform?: string) {
|
|
17
15
|
return assertPlatform(
|
|
18
16
|
platform || (await question(t('platformQuestion'))),
|
|
@@ -20,7 +18,7 @@ export async function getPlatform(platform?: string) {
|
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
export function assertPlatform(platform: string): Platform {
|
|
23
|
-
if (
|
|
21
|
+
if (platform !== 'ios' && platform !== 'android' && platform !== 'harmony') {
|
|
24
22
|
throw new Error(t('unsupportedPlatform', { platform }));
|
|
25
23
|
}
|
|
26
24
|
return platform as Platform;
|
|
@@ -121,40 +119,42 @@ async function selectApp({
|
|
|
121
119
|
);
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
122
|
+
export function getAppCommands() {
|
|
123
|
+
return {
|
|
124
|
+
createApp: async ({
|
|
125
|
+
options,
|
|
126
|
+
}: {
|
|
127
|
+
options: { name: string; downloadUrl: string; platform?: Platform | '' };
|
|
128
|
+
}) => {
|
|
129
|
+
const name = options.name || (await question(t('appNameQuestion')));
|
|
130
|
+
const { downloadUrl } = options;
|
|
131
|
+
const platform = await getPlatform(options.platform);
|
|
132
|
+
const { id } = await post('/app/create', { name, platform, downloadUrl });
|
|
133
|
+
console.log(t('createAppSuccess', { id }));
|
|
134
|
+
await selectApp({
|
|
135
|
+
args: [String(id)],
|
|
136
|
+
options: { platform },
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
deleteApp: async ({
|
|
140
|
+
args,
|
|
141
|
+
options,
|
|
142
|
+
}: {
|
|
143
|
+
args: string[];
|
|
144
|
+
options: { platform: Platform };
|
|
145
|
+
}) => {
|
|
146
|
+
const { platform } = options;
|
|
147
|
+
const id = args[0] || (await chooseApp(platform)).id;
|
|
148
|
+
if (!id) {
|
|
149
|
+
console.log(t('cancelled'));
|
|
150
|
+
}
|
|
151
|
+
await doDelete(`/app/${id}`);
|
|
152
|
+
console.log(t('operationSuccess'));
|
|
153
|
+
},
|
|
154
|
+
apps: async ({ options }: { options: { platform?: Platform | '' } }) => {
|
|
155
|
+
const { platform = '' } = options;
|
|
156
|
+
await listApp(platform);
|
|
157
|
+
},
|
|
158
|
+
selectApp,
|
|
159
|
+
};
|
|
160
|
+
}
|
package/src/bin.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { loadSession } from './api';
|
|
4
|
+
import { getAppCommands } from './app';
|
|
5
|
+
import { bundleCommands } from './bundle';
|
|
6
|
+
import { diffCommands } from './diff';
|
|
7
|
+
import { installCommands } from './install';
|
|
8
|
+
import { packageCommands } from './package';
|
|
9
|
+
import { userCommands } from './user';
|
|
10
|
+
import { printVersionCommand } from './utils';
|
|
11
|
+
import { t } from './utils/i18n';
|
|
12
|
+
import { versionCommands } from './versions';
|
|
13
|
+
|
|
14
|
+
type CliCommandHandler = (argv: any) => Promise<unknown> | unknown;
|
|
15
|
+
|
|
16
|
+
interface CliArgv {
|
|
17
|
+
command: string;
|
|
18
|
+
args: string[];
|
|
19
|
+
options: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function printUsage(exitCode = 1) {
|
|
23
|
+
console.log('React Native Update CLI');
|
|
24
|
+
console.log('');
|
|
25
|
+
console.log('Commands:');
|
|
26
|
+
for (const name of Object.keys(commandHandlers)) {
|
|
27
|
+
console.log(` ${name}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.log('');
|
|
31
|
+
console.log('Special commands:');
|
|
32
|
+
console.log(' list: List all available commands');
|
|
33
|
+
console.log(' help: Show this help message');
|
|
34
|
+
|
|
35
|
+
console.log('');
|
|
36
|
+
console.log(
|
|
37
|
+
'Visit `https://github.com/reactnativecn/react-native-update` for document.',
|
|
38
|
+
);
|
|
39
|
+
process.exit(exitCode);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const commandHandlers: Record<string, CliCommandHandler> = {
|
|
43
|
+
...userCommands,
|
|
44
|
+
...bundleCommands,
|
|
45
|
+
...diffCommands,
|
|
46
|
+
...getAppCommands(),
|
|
47
|
+
...packageCommands,
|
|
48
|
+
...versionCommands,
|
|
49
|
+
...installCommands,
|
|
50
|
+
help: printUsage,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
async function run() {
|
|
54
|
+
await printVersionCommand();
|
|
55
|
+
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
|
56
|
+
process.exit();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const argv: CliArgv = require('cli-arguments').parse(require('../cli.json'));
|
|
60
|
+
global.NO_INTERACTIVE = argv.options['no-interactive'];
|
|
61
|
+
global.USE_ACC_OSS = argv.options.acc;
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
await loadSession();
|
|
65
|
+
|
|
66
|
+
if (argv.command === 'help') {
|
|
67
|
+
printUsage(0);
|
|
68
|
+
} else if (argv.command === 'list') {
|
|
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}`);
|
|
75
|
+
}
|
|
76
|
+
} catch (err: any) {
|
|
77
|
+
if (err.status === 401) {
|
|
78
|
+
console.log(t('loginFirst'));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
console.error(err.stack);
|
|
82
|
+
process.exit(-1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
run();
|
package/src/bundle-runner.ts
CHANGED
|
@@ -331,6 +331,75 @@ function getHermesOSBin() {
|
|
|
331
331
|
if (os.platform() === 'linux') return 'linux64-bin';
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
+
function getHermesExecutableName() {
|
|
335
|
+
return os.platform() === 'win32' ? 'hermesc.exe' : 'hermesc';
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function dirnameOfPackage(
|
|
339
|
+
packageJsonPath: string,
|
|
340
|
+
projectRoot = process.cwd(),
|
|
341
|
+
) {
|
|
342
|
+
return path.dirname(
|
|
343
|
+
require.resolve(packageJsonPath, {
|
|
344
|
+
paths: [projectRoot],
|
|
345
|
+
}),
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function resolveHermesCommand(projectRoot = process.cwd()): string {
|
|
350
|
+
const osBin = getHermesOSBin();
|
|
351
|
+
if (!osBin) {
|
|
352
|
+
throw new Error(`Unsupported platform for Hermes: ${os.platform()}`);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const executableName = getHermesExecutableName();
|
|
356
|
+
const candidates: string[] = [];
|
|
357
|
+
|
|
358
|
+
try {
|
|
359
|
+
const rnDir = dirnameOfPackage('react-native/package.json', projectRoot);
|
|
360
|
+
candidates.push(path.join(rnDir, 'sdks', 'hermesc', osBin, executableName));
|
|
361
|
+
} catch {
|
|
362
|
+
// react-native is required for normal RN projects; keep looking so the
|
|
363
|
+
// final error can include all candidates we were able to infer.
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
try {
|
|
367
|
+
const hermesCompilerDir = dirnameOfPackage(
|
|
368
|
+
'hermes-compiler/package.json',
|
|
369
|
+
projectRoot,
|
|
370
|
+
);
|
|
371
|
+
candidates.push(
|
|
372
|
+
path.join(hermesCompilerDir, 'hermesc', osBin, executableName),
|
|
373
|
+
);
|
|
374
|
+
} catch {
|
|
375
|
+
// RN 0.85+ uses hermes-compiler, older projects may still use other paths.
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
try {
|
|
379
|
+
const hermesEngineDir = dirnameOfPackage(
|
|
380
|
+
'hermes-engine/package.json',
|
|
381
|
+
projectRoot,
|
|
382
|
+
);
|
|
383
|
+
candidates.push(
|
|
384
|
+
path.join(hermesEngineDir, osBin, executableName),
|
|
385
|
+
path.join(hermesEngineDir, 'hermesc', osBin, executableName),
|
|
386
|
+
);
|
|
387
|
+
} catch {
|
|
388
|
+
// RN 0.70-era projects commonly used hermes-engine; optional for newer RN.
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const hermesCommand = candidates.find((candidate) =>
|
|
392
|
+
fs.existsSync(candidate),
|
|
393
|
+
);
|
|
394
|
+
if (hermesCommand) {
|
|
395
|
+
return hermesCommand;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
throw new Error(
|
|
399
|
+
`Cannot find hermesc. Tried:\n${candidates.map((candidate) => `- ${candidate}`).join('\n')}`,
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
334
403
|
async function checkGradleConfig(): Promise<GradleConfig> {
|
|
335
404
|
let enableHermes = false;
|
|
336
405
|
let crunchPngs: boolean | undefined;
|
|
@@ -365,18 +434,7 @@ async function compileHermesByteCode(
|
|
|
365
434
|
shouldCleanSourcemap: boolean,
|
|
366
435
|
) {
|
|
367
436
|
console.log(t('hermesEnabledCompiling'));
|
|
368
|
-
const
|
|
369
|
-
require.resolve('react-native', {
|
|
370
|
-
paths: [process.cwd()],
|
|
371
|
-
}),
|
|
372
|
-
);
|
|
373
|
-
let hermesPath = path.join(rnDir, `/sdks/hermesc/${getHermesOSBin()}`);
|
|
374
|
-
|
|
375
|
-
if (!fs.existsSync(hermesPath)) {
|
|
376
|
-
hermesPath = `node_modules/hermes-engine/${getHermesOSBin()}`;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const hermesCommand = `${hermesPath}/hermesc`;
|
|
437
|
+
const hermesCommand = resolveHermesCommand();
|
|
380
438
|
|
|
381
439
|
const args = [
|
|
382
440
|
'-emit-binary',
|
package/src/exports.ts
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
export { getSession, loadSession } from './api';
|
|
2
2
|
export { getPlatform, getSelectedApp } from './app';
|
|
3
3
|
export { diffCommands } from './diff';
|
|
4
|
-
export { moduleManager } from './module-manager';
|
|
5
|
-
export { builtinModules } from './modules';
|
|
6
|
-
export { appModule } from './modules/app-module';
|
|
7
|
-
export { bundleModule } from './modules/bundle-module';
|
|
8
|
-
export { packageModule } from './modules/package-module';
|
|
9
|
-
export { userModule } from './modules/user-module';
|
|
10
|
-
export { versionModule } from './modules/version-module';
|
|
11
4
|
export { CLIProviderImpl } from './provider';
|
|
12
5
|
export type {
|
|
13
6
|
BundleOptions,
|
|
14
|
-
CLIModule,
|
|
15
7
|
CLIProvider,
|
|
16
8
|
CommandContext,
|
|
17
|
-
CommandDefinition,
|
|
18
9
|
CommandResult,
|
|
19
10
|
Package,
|
|
20
11
|
Platform,
|
|
@@ -23,4 +14,4 @@ export type {
|
|
|
23
14
|
UploadOptions,
|
|
24
15
|
Version,
|
|
25
16
|
} from './types';
|
|
26
|
-
export { question
|
|
17
|
+
export { question } from './utils';
|
package/src/index.ts
CHANGED
|
@@ -1,94 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { loadSession } from './api';
|
|
4
|
-
import { appCommands } from './app';
|
|
5
|
-
import { bundleCommands } from './bundle';
|
|
6
|
-
import { diffCommands } from './diff';
|
|
7
|
-
import { installCommands } from './install';
|
|
8
|
-
import { packageCommands } from './package';
|
|
9
|
-
import { userCommands } from './user';
|
|
10
|
-
import { printVersionCommand } from './utils';
|
|
11
|
-
import { t } from './utils/i18n';
|
|
12
|
-
import { versionCommands } from './versions';
|
|
13
|
-
|
|
14
|
-
type CliCommandHandler = (argv: any) => Promise<unknown> | unknown;
|
|
15
|
-
|
|
16
|
-
interface CliArgv {
|
|
17
|
-
command: string;
|
|
18
|
-
args: string[];
|
|
19
|
-
options: Record<string, any>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function printUsage(exitCode = 1) {
|
|
23
|
-
console.log('React Native Update CLI');
|
|
24
|
-
console.log('');
|
|
25
|
-
console.log('Commands:');
|
|
26
|
-
for (const name of Object.keys(commandHandlers)) {
|
|
27
|
-
console.log(` ${name}`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
console.log('');
|
|
31
|
-
console.log('Special commands:');
|
|
32
|
-
console.log(' list: List all available commands');
|
|
33
|
-
console.log(' help: Show this help message');
|
|
34
|
-
|
|
35
|
-
console.log('');
|
|
36
|
-
console.log(
|
|
37
|
-
'Visit `https://github.com/reactnativecn/react-native-update` for document.',
|
|
38
|
-
);
|
|
39
|
-
process.exit(exitCode);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const commandHandlers: Record<string, CliCommandHandler> = {
|
|
43
|
-
...userCommands,
|
|
44
|
-
...bundleCommands,
|
|
45
|
-
...diffCommands,
|
|
46
|
-
...appCommands,
|
|
47
|
-
...packageCommands,
|
|
48
|
-
...versionCommands,
|
|
49
|
-
...installCommands,
|
|
50
|
-
help: printUsage,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
async function run() {
|
|
54
|
-
await printVersionCommand();
|
|
55
|
-
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
|
56
|
-
process.exit();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const argv: CliArgv = require('cli-arguments').parse(require('../cli.json'));
|
|
60
|
-
global.NO_INTERACTIVE = argv.options['no-interactive'];
|
|
61
|
-
global.USE_ACC_OSS = argv.options.acc;
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
await loadSession();
|
|
65
|
-
|
|
66
|
-
if (argv.command === 'help') {
|
|
67
|
-
printUsage(0);
|
|
68
|
-
} else if (argv.command === 'list') {
|
|
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}`);
|
|
75
|
-
}
|
|
76
|
-
} catch (err: any) {
|
|
77
|
-
if (err.status === 401) {
|
|
78
|
-
console.log(t('loginFirst'));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
console.error(err.stack);
|
|
82
|
-
process.exit(-1);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export { moduleManager } from './module-manager';
|
|
87
|
-
export { CLIProviderImpl } from './provider';
|
|
88
|
-
export type {
|
|
89
|
-
CLIModule,
|
|
90
|
-
CLIProvider,
|
|
91
|
-
CommandDefinition,
|
|
92
|
-
} from './types';
|
|
93
|
-
|
|
94
|
-
run();
|
|
1
|
+
export * from './exports';
|
package/src/package.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
1
|
+
import * as fs from 'fs-extra';
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import Table from 'tty-table';
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
getAppInfo,
|
|
12
12
|
getIpaInfo,
|
|
13
13
|
question,
|
|
14
|
-
saveToLocal,
|
|
15
14
|
} from './utils';
|
|
16
15
|
import { AabParser } from './utils/app-info-parser/aab';
|
|
17
16
|
import { depVersions } from './utils/dep-versions';
|
|
@@ -129,7 +128,6 @@ async function uploadNativePackage(
|
|
|
129
128
|
deps: depVersions,
|
|
130
129
|
commit: await getCommitInfo(),
|
|
131
130
|
});
|
|
132
|
-
saveToLocal(filePath, `${appId}/package/${id}${config.extension}`);
|
|
133
131
|
console.log(
|
|
134
132
|
t(config.successKey, {
|
|
135
133
|
id,
|
package/src/provider.ts
CHANGED
|
@@ -171,8 +171,10 @@ export class CLIProviderImpl implements CLIProvider {
|
|
|
171
171
|
return this.runMessageCommand(
|
|
172
172
|
async () => {
|
|
173
173
|
const resolvedPlatform = await this.getPlatform(platform);
|
|
174
|
-
const {
|
|
175
|
-
await
|
|
174
|
+
const { getAppCommands } = await import('./app');
|
|
175
|
+
await getAppCommands().apps({
|
|
176
|
+
options: { platform: resolvedPlatform },
|
|
177
|
+
});
|
|
176
178
|
},
|
|
177
179
|
'Unknown error listing apps',
|
|
178
180
|
'Apps listed successfully',
|
|
@@ -182,8 +184,8 @@ export class CLIProviderImpl implements CLIProvider {
|
|
|
182
184
|
async createApp(name: string, platform: Platform): Promise<CommandResult> {
|
|
183
185
|
return this.runMessageCommand(
|
|
184
186
|
async () => {
|
|
185
|
-
const {
|
|
186
|
-
await
|
|
187
|
+
const { getAppCommands } = await import('./app');
|
|
188
|
+
await getAppCommands().createApp({
|
|
187
189
|
options: {
|
|
188
190
|
name,
|
|
189
191
|
platform,
|
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;
|
|
@@ -113,11 +99,3 @@ export interface CLIProvider {
|
|
|
113
99
|
getPlatform: (platform?: Platform) => Promise<Platform>;
|
|
114
100
|
loadSession: () => Promise<Session>;
|
|
115
101
|
}
|
|
116
|
-
|
|
117
|
-
export interface CLIModule {
|
|
118
|
-
name: string;
|
|
119
|
-
version: string;
|
|
120
|
-
commands?: CommandDefinition[];
|
|
121
|
-
init?: (provider: CLIProvider) => void;
|
|
122
|
-
cleanup?: () => void;
|
|
123
|
-
}
|
package/src/utils/index.ts
CHANGED
|
@@ -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
|
|
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,
|