react-native-update-cli 2.7.2 → 2.8.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/cli.json +0 -1
- package/lib/bundle.js +22 -7
- package/package.json +26 -24
- package/src/bundle.ts +19 -9
- package/lib/esm/api..mjs +0 -183
- package/lib/esm/app..mjs +0 -130
- package/lib/esm/bundle..mjs +0 -823
- package/lib/esm/exports..mjs +0 -11
- package/lib/esm/index..mjs +0 -122
- package/lib/esm/install..mjs +0 -18
- package/lib/esm/locales/en..mjs +0 -131
- package/lib/esm/locales/zh..mjs +0 -130
- package/lib/esm/module-manager..mjs +0 -109
- package/lib/esm/modules/app-module..mjs +0 -213
- package/lib/esm/modules/bundle-module..mjs +0 -178
- package/lib/esm/modules/index..mjs +0 -17
- package/lib/esm/modules/package-module..mjs +0 -6
- package/lib/esm/modules/user-module..mjs +0 -351
- package/lib/esm/modules/version-module..mjs +0 -6
- package/lib/esm/package..mjs +0 -316
- package/lib/esm/provider..mjs +0 -293
- package/lib/esm/types..mjs +0 -1
- package/lib/esm/user..mjs +0 -36
- package/lib/esm/utils/add-gitignore..mjs +0 -32
- package/lib/esm/utils/app-info-parser/aab..mjs +0 -215
- package/lib/esm/utils/app-info-parser/apk..mjs +0 -75
- package/lib/esm/utils/app-info-parser/app..mjs +0 -3
- package/lib/esm/utils/app-info-parser/index..mjs +0 -44
- package/lib/esm/utils/app-info-parser/ipa..mjs +0 -73
- package/lib/esm/utils/app-info-parser/resource-finder..mjs +0 -401
- package/lib/esm/utils/app-info-parser/utils..mjs +0 -121
- package/lib/esm/utils/app-info-parser/xml-parser/binary..mjs +0 -569
- package/lib/esm/utils/app-info-parser/xml-parser/manifest..mjs +0 -200
- package/lib/esm/utils/app-info-parser/zip..mjs +0 -65
- package/lib/esm/utils/check-lockfile..mjs +0 -78
- package/lib/esm/utils/check-plugin..mjs +0 -25
- package/lib/esm/utils/constants..mjs +0 -19
- package/lib/esm/utils/dep-versions..mjs +0 -33
- package/lib/esm/utils/git..mjs +0 -43
- package/lib/esm/utils/http-helper..mjs +0 -70
- package/lib/esm/utils/i18n..mjs +0 -23
- package/lib/esm/utils/index..mjs +0 -316
- package/lib/esm/utils/latest-version/cli..mjs +0 -294
- package/lib/esm/utils/latest-version/index..mjs +0 -238
- package/lib/esm/utils/plugin-config..mjs +0 -23
- package/lib/esm/versions..mjs +0 -290
package/cli.json
CHANGED
package/lib/bundle.js
CHANGED
|
@@ -28,6 +28,7 @@ const _yazl = require("yazl");
|
|
|
28
28
|
const _app = require("./app");
|
|
29
29
|
const _utils = require("./utils");
|
|
30
30
|
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
31
|
+
const _globaldirs = require("global-dirs");
|
|
31
32
|
const _addgitignore = require("./utils/add-gitignore");
|
|
32
33
|
const _checklockfile = require("./utils/check-lockfile");
|
|
33
34
|
const _constants = require("./utils/constants");
|
|
@@ -80,17 +81,31 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
80
81
|
}
|
|
81
82
|
return newObj;
|
|
82
83
|
}
|
|
84
|
+
var _loadDiffModule;
|
|
83
85
|
const g2js = require('gradle-to-js/lib/parser');
|
|
84
86
|
const properties = require('properties');
|
|
85
|
-
|
|
87
|
+
const loadDiffModule = (pkgName)=>{
|
|
88
|
+
const resolvePaths = [
|
|
89
|
+
process.cwd(),
|
|
90
|
+
_globaldirs.npm.packages,
|
|
91
|
+
_globaldirs.yarn.packages
|
|
92
|
+
];
|
|
93
|
+
try {
|
|
94
|
+
const resolved = require.resolve(pkgName, {
|
|
95
|
+
paths: resolvePaths
|
|
96
|
+
});
|
|
97
|
+
const mod = require(resolved);
|
|
98
|
+
if (mod == null ? void 0 : mod.diff) {
|
|
99
|
+
return mod.diff;
|
|
100
|
+
}
|
|
101
|
+
} catch (e) {}
|
|
102
|
+
return undefined;
|
|
103
|
+
};
|
|
86
104
|
let hdiff;
|
|
105
|
+
hdiff = (_loadDiffModule = loadDiffModule('node-hdiffpatch')) == null ? void 0 : _loadDiffModule.diff;
|
|
106
|
+
let bsdiff;
|
|
87
107
|
let diff;
|
|
88
|
-
|
|
89
|
-
bsdiff = require('node-bsdiff').diff;
|
|
90
|
-
} catch (e) {}
|
|
91
|
-
try {
|
|
92
|
-
hdiff = require('node-hdiffpatch').diff;
|
|
93
|
-
} catch (e) {}
|
|
108
|
+
bsdiff = loadDiffModule('node-bsdiff');
|
|
94
109
|
async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli }) {
|
|
95
110
|
let gradleConfig = {};
|
|
96
111
|
if (platform === 'android') {
|
package/package.json
CHANGED
|
@@ -1,40 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": {
|
|
8
|
-
"import": "./lib/esm/index.mjs",
|
|
9
|
-
"require": "./lib/index.js"
|
|
10
|
-
},
|
|
11
|
-
"./cli.json": "./cli.json",
|
|
12
|
-
"./package.json": "./package.json",
|
|
13
|
-
"./lib/*": "./lib/*",
|
|
14
|
-
"./src/*": "./src/*",
|
|
15
|
-
"./proto/*": "./proto/*",
|
|
16
|
-
"./*": {
|
|
17
|
-
"import": "./lib/esm/*.mjs",
|
|
18
|
-
"require": "./lib/*.js"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
6
|
"bin": {
|
|
22
7
|
"pushy": "lib/index.js",
|
|
23
8
|
"cresc": "lib/index.js"
|
|
24
9
|
},
|
|
25
|
-
"files": [
|
|
10
|
+
"files": [
|
|
11
|
+
"lib",
|
|
12
|
+
"src",
|
|
13
|
+
"proto",
|
|
14
|
+
"cli.json"
|
|
15
|
+
],
|
|
26
16
|
"scripts": {
|
|
27
|
-
"build
|
|
28
|
-
"
|
|
29
|
-
"build": "npm run build:cjs && npm run build:esm",
|
|
30
|
-
"prepublishOnly": "npm run build && chmod +x lib/index.js",
|
|
17
|
+
"build": "swc src -d lib --strip-leading-paths",
|
|
18
|
+
"prepublishOnly": "bun scripts/prepublish.js && bun run build && chmod +x lib/index.js",
|
|
31
19
|
"lint": "tsc --noEmit & biome check --write ."
|
|
32
20
|
},
|
|
33
21
|
"repository": {
|
|
34
22
|
"type": "git",
|
|
35
23
|
"url": "git+https://github.com/reactnativecn/react-native-update-cli.git"
|
|
36
24
|
},
|
|
37
|
-
"keywords": [
|
|
25
|
+
"keywords": [
|
|
26
|
+
"react-native",
|
|
27
|
+
"ios",
|
|
28
|
+
"android",
|
|
29
|
+
"harmony",
|
|
30
|
+
"update"
|
|
31
|
+
],
|
|
38
32
|
"author": "reactnativecn",
|
|
39
33
|
"license": "BSD-3-Clause",
|
|
40
34
|
"bugs": {
|
|
@@ -78,6 +72,7 @@
|
|
|
78
72
|
"@biomejs/biome": "^1.9.4",
|
|
79
73
|
"@swc/cli": "0.7.7",
|
|
80
74
|
"@swc/core": "^1.11.24",
|
|
75
|
+
"@types/bun": "^1.3.8",
|
|
81
76
|
"@types/filesize-parser": "^1.5.3",
|
|
82
77
|
"@types/fs-extra": "^11.0.4",
|
|
83
78
|
"@types/node": "^22.15.18",
|
|
@@ -89,5 +84,12 @@
|
|
|
89
84
|
"@types/yazl": "^2.4.6",
|
|
90
85
|
"typescript": "^5.8.3"
|
|
91
86
|
},
|
|
92
|
-
"
|
|
93
|
-
|
|
87
|
+
"optionalDependencies": {
|
|
88
|
+
"node-hdiffpatch": "^1.2.1"
|
|
89
|
+
},
|
|
90
|
+
"trustedDependencies": [
|
|
91
|
+
"@biomejs/biome",
|
|
92
|
+
"@swc/core",
|
|
93
|
+
"node-hdiffpatch"
|
|
94
|
+
]
|
|
95
|
+
}
|
package/src/bundle.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { translateOptions } from './utils';
|
|
|
13
13
|
import { checkPlugins, question } from './utils';
|
|
14
14
|
const g2js = require('gradle-to-js/lib/parser');
|
|
15
15
|
import os from 'os';
|
|
16
|
+
import { npm, yarn } from 'global-dirs';
|
|
16
17
|
const properties = require('properties');
|
|
17
18
|
import { addGitIgnore } from './utils/add-gitignore';
|
|
18
19
|
import { checkLockFiles } from './utils/check-lockfile';
|
|
@@ -23,16 +24,25 @@ import { versionCommands } from './versions';
|
|
|
23
24
|
|
|
24
25
|
type Diff = (oldSource?: Buffer, newSource?: Buffer) => Buffer;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const loadDiffModule = (pkgName: string): Diff | undefined => {
|
|
28
|
+
const resolvePaths = [process.cwd(), npm.packages, yarn.packages];
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const resolved = require.resolve(pkgName, { paths: resolvePaths });
|
|
32
|
+
const mod = require(resolved);
|
|
33
|
+
if (mod?.diff) {
|
|
34
|
+
return mod.diff as Diff;
|
|
35
|
+
}
|
|
36
|
+
} catch {}
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
return undefined;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
let hdiff: Diff | undefined;
|
|
42
|
+
hdiff = (loadDiffModule('node-hdiffpatch') as any)?.diff;
|
|
43
|
+
let bsdiff: Diff | undefined;
|
|
44
|
+
let diff: Diff;
|
|
45
|
+
bsdiff = loadDiffModule('node-bsdiff');
|
|
36
46
|
|
|
37
47
|
async function runReactNativeBundleCommand({
|
|
38
48
|
bundleName,
|
package/lib/esm/api..mjs
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import util from "util";
|
|
4
|
-
import filesizeParser from "filesize-parser";
|
|
5
|
-
import FormData from "form-data";
|
|
6
|
-
import fetch from "node-fetch";
|
|
7
|
-
import ProgressBar from "progress";
|
|
8
|
-
import tcpp from "tcp-ping";
|
|
9
|
-
import { getBaseUrl } from "./utils/http-helper";
|
|
10
|
-
import packageJson from "../package.json";
|
|
11
|
-
import { credentialFile, pricingPageUrl, IS_CRESC } from "./utils/constants";
|
|
12
|
-
import { t } from "./utils/i18n";
|
|
13
|
-
const tcpPing = util.promisify(tcpp.ping);
|
|
14
|
-
let session;
|
|
15
|
-
let savedSession;
|
|
16
|
-
let apiToken;
|
|
17
|
-
const userAgent = `react-native-update-cli/${packageJson.version}`;
|
|
18
|
-
export const getSession = ()=>session;
|
|
19
|
-
export const getApiToken = ()=>apiToken;
|
|
20
|
-
export const setApiToken = (token)=>{
|
|
21
|
-
apiToken = token;
|
|
22
|
-
};
|
|
23
|
-
const loadApiTokenFromEnv = ()=>{
|
|
24
|
-
// Use CRESC_API_TOKEN for cresc, PUSHY_API_TOKEN for pushy
|
|
25
|
-
const envToken = IS_CRESC ? process.env.CRESC_API_TOKEN : process.env.PUSHY_API_TOKEN;
|
|
26
|
-
if (envToken) {
|
|
27
|
-
apiToken = envToken;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
export const replaceSession = (newSession)=>{
|
|
31
|
-
session = newSession;
|
|
32
|
-
};
|
|
33
|
-
export const loadSession = async ()=>{
|
|
34
|
-
loadApiTokenFromEnv();
|
|
35
|
-
if (fs.existsSync(credentialFile)) {
|
|
36
|
-
try {
|
|
37
|
-
replaceSession(JSON.parse(fs.readFileSync(credentialFile, 'utf8')));
|
|
38
|
-
savedSession = session;
|
|
39
|
-
} catch (e) {
|
|
40
|
-
console.error(`Failed to parse file ${credentialFile}. Try to remove it manually.`);
|
|
41
|
-
throw e;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
export const saveSession = ()=>{
|
|
46
|
-
// Only save on change.
|
|
47
|
-
if (session !== savedSession) {
|
|
48
|
-
const current = session;
|
|
49
|
-
const data = JSON.stringify(current, null, 4);
|
|
50
|
-
fs.writeFileSync(credentialFile, data, 'utf8');
|
|
51
|
-
savedSession = current;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
export const closeSession = ()=>{
|
|
55
|
-
if (fs.existsSync(credentialFile)) {
|
|
56
|
-
fs.unlinkSync(credentialFile);
|
|
57
|
-
savedSession = undefined;
|
|
58
|
-
}
|
|
59
|
-
session = undefined;
|
|
60
|
-
};
|
|
61
|
-
async function query(url, options) {
|
|
62
|
-
const baseUrl = await getBaseUrl;
|
|
63
|
-
const fullUrl = `${baseUrl}${url}`;
|
|
64
|
-
const resp = await fetch(fullUrl, options);
|
|
65
|
-
const text = await resp.text();
|
|
66
|
-
let json;
|
|
67
|
-
try {
|
|
68
|
-
json = JSON.parse(text);
|
|
69
|
-
} catch (e) {}
|
|
70
|
-
if (resp.status !== 200) {
|
|
71
|
-
const message = (json == null ? void 0 : json.message) || resp.statusText;
|
|
72
|
-
if (resp.status === 401) {
|
|
73
|
-
throw new Error(t('loginExpired'));
|
|
74
|
-
}
|
|
75
|
-
throw new Error(message);
|
|
76
|
-
}
|
|
77
|
-
return json;
|
|
78
|
-
}
|
|
79
|
-
function queryWithoutBody(method) {
|
|
80
|
-
return (api)=>{
|
|
81
|
-
const headers = {
|
|
82
|
-
'User-Agent': userAgent
|
|
83
|
-
};
|
|
84
|
-
if (apiToken) {
|
|
85
|
-
headers['x-api-token'] = apiToken;
|
|
86
|
-
} else if (session == null ? void 0 : session.token) {
|
|
87
|
-
headers['X-AccessToken'] = session.token;
|
|
88
|
-
}
|
|
89
|
-
return query(api, {
|
|
90
|
-
method,
|
|
91
|
-
headers
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function queryWithBody(method) {
|
|
96
|
-
return (api, body)=>{
|
|
97
|
-
const headers = {
|
|
98
|
-
'User-Agent': userAgent,
|
|
99
|
-
'Content-Type': 'application/json'
|
|
100
|
-
};
|
|
101
|
-
if (apiToken) {
|
|
102
|
-
headers['x-api-token'] = apiToken;
|
|
103
|
-
} else if (session == null ? void 0 : session.token) {
|
|
104
|
-
headers['X-AccessToken'] = session.token;
|
|
105
|
-
}
|
|
106
|
-
return query(api, {
|
|
107
|
-
method,
|
|
108
|
-
headers,
|
|
109
|
-
body: JSON.stringify(body)
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
export const get = queryWithoutBody('GET');
|
|
114
|
-
export const post = queryWithBody('POST');
|
|
115
|
-
export const put = queryWithBody('PUT');
|
|
116
|
-
export const doDelete = queryWithBody('DELETE');
|
|
117
|
-
export async function uploadFile(fn, key) {
|
|
118
|
-
const { url, backupUrl, formData, maxSize } = await post('/upload', {
|
|
119
|
-
ext: path.extname(fn)
|
|
120
|
-
});
|
|
121
|
-
let realUrl = url;
|
|
122
|
-
if (backupUrl) {
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
if (global.USE_ACC_OSS) {
|
|
125
|
-
realUrl = backupUrl;
|
|
126
|
-
} else {
|
|
127
|
-
const pingResult = await tcpPing({
|
|
128
|
-
address: url.replace('https://', ''),
|
|
129
|
-
attempts: 4,
|
|
130
|
-
timeout: 1000
|
|
131
|
-
});
|
|
132
|
-
// console.log({pingResult});
|
|
133
|
-
if (Number.isNaN(pingResult.avg) || pingResult.avg > 150) {
|
|
134
|
-
realUrl = backupUrl;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
// console.log({realUrl});
|
|
138
|
-
}
|
|
139
|
-
const fileSize = fs.statSync(fn).size;
|
|
140
|
-
if (maxSize && fileSize > filesizeParser(maxSize)) {
|
|
141
|
-
const readableFileSize = `${(fileSize / 1048576).toFixed(1)}m`;
|
|
142
|
-
throw new Error(t('fileSizeExceeded', {
|
|
143
|
-
fileSize: readableFileSize,
|
|
144
|
-
maxSize,
|
|
145
|
-
pricingPageUrl
|
|
146
|
-
}));
|
|
147
|
-
}
|
|
148
|
-
const bar = new ProgressBar(' Uploading [:bar] :percent :etas', {
|
|
149
|
-
complete: '=',
|
|
150
|
-
incomplete: ' ',
|
|
151
|
-
total: fileSize
|
|
152
|
-
});
|
|
153
|
-
const form = new FormData();
|
|
154
|
-
for (const [k, v] of Object.entries(formData)){
|
|
155
|
-
form.append(k, v);
|
|
156
|
-
}
|
|
157
|
-
const fileStream = fs.createReadStream(fn);
|
|
158
|
-
fileStream.on('data', (data)=>{
|
|
159
|
-
bar.tick(data.length);
|
|
160
|
-
});
|
|
161
|
-
if (key) {
|
|
162
|
-
form.append('key', key);
|
|
163
|
-
}
|
|
164
|
-
form.append('file', fileStream);
|
|
165
|
-
// form.append('file', fileStream, {
|
|
166
|
-
// contentType: 'application/octet-stream',
|
|
167
|
-
// });
|
|
168
|
-
const res = await fetch(realUrl, {
|
|
169
|
-
method: 'POST',
|
|
170
|
-
body: form
|
|
171
|
-
});
|
|
172
|
-
if (res.status > 299) {
|
|
173
|
-
throw new Error(`${res.status}: ${res.statusText}`);
|
|
174
|
-
}
|
|
175
|
-
// const body = await response.json();
|
|
176
|
-
return {
|
|
177
|
-
hash: key || formData.key
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
export const getAllPackages = async (appId)=>{
|
|
181
|
-
const { data } = await get(`/app/${appId}/package/list?limit=1000`);
|
|
182
|
-
return data;
|
|
183
|
-
};
|
package/lib/esm/app..mjs
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import Table from "tty-table";
|
|
3
|
-
import { question } from "./utils";
|
|
4
|
-
import { doDelete, get, post } from "./api";
|
|
5
|
-
import { t } from "./utils/i18n";
|
|
6
|
-
const validPlatforms = [
|
|
7
|
-
'ios',
|
|
8
|
-
'android',
|
|
9
|
-
'harmony'
|
|
10
|
-
];
|
|
11
|
-
export async function getPlatform(platform) {
|
|
12
|
-
return assertPlatform(platform || await question(t('platformQuestion')));
|
|
13
|
-
}
|
|
14
|
-
export function assertPlatform(platform) {
|
|
15
|
-
if (!validPlatforms.includes(platform)) {
|
|
16
|
-
throw new Error(t('unsupportedPlatform', {
|
|
17
|
-
platform
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
return platform;
|
|
21
|
-
}
|
|
22
|
-
export function getSelectedApp(platform) {
|
|
23
|
-
assertPlatform(platform);
|
|
24
|
-
if (!fs.existsSync('update.json')) {
|
|
25
|
-
throw new Error(t('appNotSelected', {
|
|
26
|
-
platform
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
const updateInfo = JSON.parse(fs.readFileSync('update.json', 'utf8'));
|
|
30
|
-
if (!updateInfo[platform]) {
|
|
31
|
-
throw new Error(t('appNotSelected', {
|
|
32
|
-
platform
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
return updateInfo[platform];
|
|
36
|
-
}
|
|
37
|
-
export async function listApp(platform = '') {
|
|
38
|
-
const { data } = await get('/app/list');
|
|
39
|
-
const list = platform ? data.filter((v)=>v.platform === platform) : data;
|
|
40
|
-
const header = [
|
|
41
|
-
{
|
|
42
|
-
value: t('appId')
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
value: t('appName')
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
value: t('platform')
|
|
49
|
-
}
|
|
50
|
-
];
|
|
51
|
-
const rows = [];
|
|
52
|
-
for (const app of list){
|
|
53
|
-
rows.push([
|
|
54
|
-
app.id,
|
|
55
|
-
app.name,
|
|
56
|
-
app.platform
|
|
57
|
-
]);
|
|
58
|
-
}
|
|
59
|
-
console.log(Table(header, rows).render());
|
|
60
|
-
console.log(`\n${t('totalApps', {
|
|
61
|
-
count: list.length,
|
|
62
|
-
platform
|
|
63
|
-
})}`);
|
|
64
|
-
return list;
|
|
65
|
-
}
|
|
66
|
-
export async function chooseApp(platform) {
|
|
67
|
-
const list = await listApp(platform);
|
|
68
|
-
while(true){
|
|
69
|
-
const id = await question(t('enterAppIdQuestion'));
|
|
70
|
-
const app = list.find((v)=>v.id === Number(id));
|
|
71
|
-
if (app) {
|
|
72
|
-
return app;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
export const appCommands = {
|
|
77
|
-
createApp: async function({ options }) {
|
|
78
|
-
const name = options.name || await question(t('appNameQuestion'));
|
|
79
|
-
const { downloadUrl } = options;
|
|
80
|
-
const platform = await getPlatform(options.platform);
|
|
81
|
-
const { id } = await post('/app/create', {
|
|
82
|
-
name,
|
|
83
|
-
platform,
|
|
84
|
-
downloadUrl
|
|
85
|
-
});
|
|
86
|
-
console.log(t('createAppSuccess', {
|
|
87
|
-
id
|
|
88
|
-
}));
|
|
89
|
-
await this.selectApp({
|
|
90
|
-
args: [
|
|
91
|
-
id
|
|
92
|
-
],
|
|
93
|
-
options: {
|
|
94
|
-
platform
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
deleteApp: async ({ args, options })=>{
|
|
99
|
-
const { platform } = options;
|
|
100
|
-
const id = args[0] || chooseApp(platform);
|
|
101
|
-
if (!id) {
|
|
102
|
-
console.log(t('cancelled'));
|
|
103
|
-
}
|
|
104
|
-
await doDelete(`/app/${id}`);
|
|
105
|
-
console.log(t('operationSuccess'));
|
|
106
|
-
},
|
|
107
|
-
apps: async ({ options })=>{
|
|
108
|
-
const { platform } = options;
|
|
109
|
-
listApp(platform);
|
|
110
|
-
},
|
|
111
|
-
selectApp: async ({ args, options })=>{
|
|
112
|
-
const platform = await getPlatform(options.platform);
|
|
113
|
-
const id = args[0] ? Number.parseInt(args[0]) : (await chooseApp(platform)).id;
|
|
114
|
-
let updateInfo = {};
|
|
115
|
-
if (fs.existsSync('update.json')) {
|
|
116
|
-
try {
|
|
117
|
-
updateInfo = JSON.parse(fs.readFileSync('update.json', 'utf8'));
|
|
118
|
-
} catch (e) {
|
|
119
|
-
console.error(t('failedToParseUpdateJson'));
|
|
120
|
-
throw e;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const { appKey } = await get(`/app/${id}`);
|
|
124
|
-
updateInfo[platform] = {
|
|
125
|
-
appId: id,
|
|
126
|
-
appKey
|
|
127
|
-
};
|
|
128
|
-
fs.writeFileSync('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
|
|
129
|
-
}
|
|
130
|
-
};
|