react-native-update-cli 1.40.0 → 1.41.0-beta.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 +3 -0
- package/lib/api.js +14 -13
- package/lib/bundle.js +8 -4
- package/lib/index.js +16 -2
- package/lib/locales/en.js +11 -0
- package/lib/locales/zh.js +11 -0
- package/lib/utils/app-info-parser/zip.js +1 -1
- package/lib/utils/constants.js +28 -0
- package/lib/utils/index.js +2 -5
- package/package.json +6 -3
- package/src/.DS_Store +0 -0
- package/src/api.ts +17 -12
- package/src/bundle.ts +10 -3
- package/src/index.ts +19 -1
- package/src/locales/en.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/src/types.ts +1 -0
- package/src/utils/.DS_Store +0 -0
- package/src/utils/app-info-parser/zip.js +1 -1
- package/src/utils/constants.ts +6 -0
- package/src/utils/index.ts +8 -7
package/cli.json
CHANGED
package/lib/api.js
CHANGED
|
@@ -48,8 +48,9 @@ const _progress = /*#__PURE__*/ _interop_require_default(require("progress"));
|
|
|
48
48
|
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
|
|
49
49
|
const _tcpping = /*#__PURE__*/ _interop_require_default(require("tcp-ping"));
|
|
50
50
|
const _filesizeparser = /*#__PURE__*/ _interop_require_default(require("filesize-parser"));
|
|
51
|
-
const
|
|
51
|
+
const _constants = require("./utils/constants");
|
|
52
52
|
const _formdata = /*#__PURE__*/ _interop_require_default(require("form-data"));
|
|
53
|
+
const _constants1 = require("utils/constants");
|
|
53
54
|
function _interop_require_default(obj) {
|
|
54
55
|
return obj && obj.__esModule ? obj : {
|
|
55
56
|
default: obj
|
|
@@ -58,7 +59,7 @@ function _interop_require_default(obj) {
|
|
|
58
59
|
const tcpPing = _nodeutil.default.promisify(_tcpping.default.ping);
|
|
59
60
|
let session;
|
|
60
61
|
let savedSession;
|
|
61
|
-
const defaultEndpoint = 'https://update.reactnative.cn/api';
|
|
62
|
+
const defaultEndpoint = global.IS_CRESC ? 'https://api.cresc.dev' : 'https://update.reactnative.cn/api';
|
|
62
63
|
let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
|
|
63
64
|
const userAgent = `react-native-update-cli/${_packagejson.default.version}`;
|
|
64
65
|
const getSession = ()=>session;
|
|
@@ -66,12 +67,12 @@ const replaceSession = (newSession)=>{
|
|
|
66
67
|
session = newSession;
|
|
67
68
|
};
|
|
68
69
|
const loadSession = async ()=>{
|
|
69
|
-
if (_nodefs.default.existsSync(
|
|
70
|
+
if (_nodefs.default.existsSync(_constants1.credentialFile)) {
|
|
70
71
|
try {
|
|
71
|
-
replaceSession(JSON.parse(_nodefs.default.readFileSync(
|
|
72
|
+
replaceSession(JSON.parse(_nodefs.default.readFileSync(_constants1.credentialFile, 'utf8')));
|
|
72
73
|
savedSession = session;
|
|
73
74
|
} catch (e) {
|
|
74
|
-
console.error(
|
|
75
|
+
console.error(`Failed to parse file ${_constants1.credentialFile}. Try to remove it manually.`);
|
|
75
76
|
throw e;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
@@ -81,13 +82,13 @@ const saveSession = ()=>{
|
|
|
81
82
|
if (session !== savedSession) {
|
|
82
83
|
const current = session;
|
|
83
84
|
const data = JSON.stringify(current, null, 4);
|
|
84
|
-
_nodefs.default.writeFileSync(
|
|
85
|
+
_nodefs.default.writeFileSync(_constants1.credentialFile, data, 'utf8');
|
|
85
86
|
savedSession = current;
|
|
86
87
|
}
|
|
87
88
|
};
|
|
88
89
|
const closeSession = ()=>{
|
|
89
|
-
if (_nodefs.default.existsSync(
|
|
90
|
-
_nodefs.default.unlinkSync(
|
|
90
|
+
if (_nodefs.default.existsSync(_constants1.credentialFile)) {
|
|
91
|
+
_nodefs.default.unlinkSync(_constants1.credentialFile);
|
|
91
92
|
savedSession = undefined;
|
|
92
93
|
}
|
|
93
94
|
session = undefined;
|
|
@@ -148,7 +149,7 @@ async function uploadFile(fn, key) {
|
|
|
148
149
|
timeout: 1000
|
|
149
150
|
});
|
|
150
151
|
// console.log({pingResult});
|
|
151
|
-
if (isNaN(pingResult.avg) || pingResult.avg > 150) {
|
|
152
|
+
if (Number.isNaN(pingResult.avg) || pingResult.avg > 150) {
|
|
152
153
|
realUrl = backupUrl;
|
|
153
154
|
}
|
|
154
155
|
}
|
|
@@ -156,17 +157,17 @@ async function uploadFile(fn, key) {
|
|
|
156
157
|
}
|
|
157
158
|
const fileSize = _nodefs.default.statSync(fn).size;
|
|
158
159
|
if (maxSize && fileSize > (0, _filesizeparser.default)(maxSize)) {
|
|
159
|
-
throw new Error(`此文件大小 ${(fileSize / 1048576).toFixed(1)}m , 超出当前额度 ${maxSize} 。您可以考虑升级付费业务以提升此额度。详情请访问: ${
|
|
160
|
+
throw new Error(`此文件大小 ${(fileSize / 1048576).toFixed(1)}m , 超出当前额度 ${maxSize} 。您可以考虑升级付费业务以提升此额度。详情请访问: ${_constants.pricingPageUrl}`);
|
|
160
161
|
}
|
|
161
|
-
const bar = new _progress.default('
|
|
162
|
+
const bar = new _progress.default(' Uploading [:bar] :percent :etas', {
|
|
162
163
|
complete: '=',
|
|
163
164
|
incomplete: ' ',
|
|
164
165
|
total: fileSize
|
|
165
166
|
});
|
|
166
167
|
const form = new _formdata.default();
|
|
167
|
-
|
|
168
|
+
for (const [k, v] of Object.entries(formData)){
|
|
168
169
|
form.append(k, v);
|
|
169
|
-
}
|
|
170
|
+
}
|
|
170
171
|
const fileStream = _nodefs.default.createReadStream(fn);
|
|
171
172
|
fileStream.on('data', (data)=>{
|
|
172
173
|
bar.tick(data.length);
|
package/lib/bundle.js
CHANGED
|
@@ -85,7 +85,7 @@ try {
|
|
|
85
85
|
try {
|
|
86
86
|
hdiff = require('node-hdiffpatch').diff;
|
|
87
87
|
} catch (e) {}
|
|
88
|
-
async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, cli }) {
|
|
88
|
+
async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, disableHermes, cli }) {
|
|
89
89
|
let gradleConfig = {};
|
|
90
90
|
if (platform === 'android') {
|
|
91
91
|
gradleConfig = await checkGradleConfig();
|
|
@@ -112,7 +112,7 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
112
112
|
paths: [
|
|
113
113
|
process.cwd()
|
|
114
114
|
]
|
|
115
|
-
}))).version;
|
|
115
|
+
})).toString()).version;
|
|
116
116
|
// expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
|
|
117
117
|
if ((0, _satisfies.default)(expoCliVersion, '>= 0.10.17')) {
|
|
118
118
|
usingExpo = true;
|
|
@@ -231,7 +231,10 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
231
231
|
reject(new Error(`"react-native bundle" command exited with code ${exitCode}.`));
|
|
232
232
|
} else {
|
|
233
233
|
let hermesEnabled = false;
|
|
234
|
-
if (
|
|
234
|
+
if (disableHermes) {
|
|
235
|
+
hermesEnabled = false;
|
|
236
|
+
console.log('Hermes disabled');
|
|
237
|
+
} else if (platform === 'android') {
|
|
235
238
|
const gradlePropeties = await new Promise((resolve)=>{
|
|
236
239
|
properties.parse('./android/gradle.properties', {
|
|
237
240
|
path: true
|
|
@@ -751,7 +754,7 @@ function diffArgsCheck(args, options, diffFn) {
|
|
|
751
754
|
const commands = {
|
|
752
755
|
bundle: async function({ options }) {
|
|
753
756
|
const platform = (0, _app.checkPlatform)(options.platform || await (0, _utils.question)('平台(ios/android/harmony):'));
|
|
754
|
-
const { bundleName, entryFile, intermediaDir, output, dev, sourcemap, taro, expo, rncli } = (0, _utils.translateOptions)({
|
|
757
|
+
const { bundleName, entryFile, intermediaDir, output, dev, sourcemap, taro, expo, rncli, disableHermes } = (0, _utils.translateOptions)({
|
|
755
758
|
...options,
|
|
756
759
|
platform
|
|
757
760
|
});
|
|
@@ -772,6 +775,7 @@ const commands = {
|
|
|
772
775
|
outputFolder: intermediaDir,
|
|
773
776
|
platform,
|
|
774
777
|
sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
|
|
778
|
+
disableHermes,
|
|
775
779
|
cli: {
|
|
776
780
|
taro,
|
|
777
781
|
expo,
|
package/lib/index.js
CHANGED
|
@@ -5,13 +5,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
const _api = require("./api");
|
|
7
7
|
const _updatenotifier = /*#__PURE__*/ _interop_require_default(require("update-notifier"));
|
|
8
|
-
const
|
|
8
|
+
const _utils = require("./utils");
|
|
9
9
|
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
|
|
10
|
+
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
11
|
+
const _i18next = /*#__PURE__*/ _interop_require_default(require("i18next"));
|
|
12
|
+
const _en = /*#__PURE__*/ _interop_require_default(require("./locales/en"));
|
|
13
|
+
const _zh = /*#__PURE__*/ _interop_require_default(require("./locales/zh"));
|
|
10
14
|
function _interop_require_default(obj) {
|
|
11
15
|
return obj && obj.__esModule ? obj : {
|
|
12
16
|
default: obj
|
|
13
17
|
};
|
|
14
18
|
}
|
|
19
|
+
const scriptName = _nodepath.default.basename(process.argv[1]);
|
|
20
|
+
global.IS_CRESC = scriptName === 'cresc';
|
|
21
|
+
_i18next.default.init({
|
|
22
|
+
lng: global.IS_CRESC ? 'en' : 'zh',
|
|
23
|
+
// debug: process.env.NODE_ENV !== 'production',
|
|
24
|
+
resources: {
|
|
25
|
+
en: _en.default,
|
|
26
|
+
zh: _zh.default
|
|
27
|
+
}
|
|
28
|
+
});
|
|
15
29
|
(0, _updatenotifier.default)({
|
|
16
30
|
pkg: _packagejson.default
|
|
17
31
|
}).notify({
|
|
@@ -34,7 +48,7 @@ const commands = {
|
|
|
34
48
|
help: printUsage
|
|
35
49
|
};
|
|
36
50
|
async function run() {
|
|
37
|
-
await (0,
|
|
51
|
+
await (0, _utils.printVersionCommand)();
|
|
38
52
|
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
|
39
53
|
process.exit();
|
|
40
54
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
credentialFile: function() {
|
|
13
|
+
return credentialFile;
|
|
14
|
+
},
|
|
15
|
+
pricingPageUrl: function() {
|
|
16
|
+
return pricingPageUrl;
|
|
17
|
+
},
|
|
18
|
+
tempDir: function() {
|
|
19
|
+
return tempDir;
|
|
20
|
+
},
|
|
21
|
+
updateJson: function() {
|
|
22
|
+
return updateJson;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const credentialFile = global.IS_CRESC ? '.cresc.token' : '.update';
|
|
26
|
+
const updateJson = global.IS_CRESC ? 'cresc.config.json' : 'update.json';
|
|
27
|
+
const tempDir = global.IS_CRESC ? '.cresc.temp' : '.pushy';
|
|
28
|
+
const pricingPageUrl = global.IS_CRESC ? 'https://cresc.dev/pricing' : 'https://pushy.reactnative.cn/pricing.html';
|
package/lib/utils/index.js
CHANGED
|
@@ -24,9 +24,6 @@ _export(exports, {
|
|
|
24
24
|
getRNVersion: function() {
|
|
25
25
|
return getRNVersion;
|
|
26
26
|
},
|
|
27
|
-
pricingPageUrl: function() {
|
|
28
|
-
return pricingPageUrl;
|
|
29
|
-
},
|
|
30
27
|
printVersionCommand: function() {
|
|
31
28
|
return printVersionCommand;
|
|
32
29
|
},
|
|
@@ -50,6 +47,7 @@ const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
|
|
|
50
47
|
const _latestversion = /*#__PURE__*/ _interop_require_default(require("@badisi/latest-version"));
|
|
51
48
|
const _checkplugin = require("./check-plugin");
|
|
52
49
|
const _read = require("read");
|
|
50
|
+
const _constants = require("./constants");
|
|
53
51
|
function _interop_require_default(obj) {
|
|
54
52
|
return obj && obj.__esModule ? obj : {
|
|
55
53
|
default: obj
|
|
@@ -177,7 +175,7 @@ async function getIpaInfo(fn) {
|
|
|
177
175
|
...appCredential
|
|
178
176
|
};
|
|
179
177
|
}
|
|
180
|
-
const localDir = _nodepath.default.resolve(_nodeos.default.homedir(),
|
|
178
|
+
const localDir = _nodepath.default.resolve(_nodeos.default.homedir(), _constants.tempDir);
|
|
181
179
|
_fsextra.default.ensureDirSync(localDir);
|
|
182
180
|
function saveToLocal(originPath, destName) {
|
|
183
181
|
// TODO
|
|
@@ -221,4 +219,3 @@ async function printVersionCommand() {
|
|
|
221
219
|
}
|
|
222
220
|
}
|
|
223
221
|
}
|
|
224
|
-
const pricingPageUrl = 'https://pushy.reactnative.cn/pricing.html';
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0-beta.0",
|
|
4
4
|
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"pushy": "lib/index.js"
|
|
7
|
+
"pushy": "lib/index.js",
|
|
8
|
+
"cresc": "lib/index.js"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
10
11
|
"lib",
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"form-data": "^4.0.1",
|
|
47
48
|
"fs-extra": "8",
|
|
48
49
|
"gradle-to-js": "^2.0.1",
|
|
50
|
+
"i18next": "^24.2.2",
|
|
49
51
|
"isomorphic-unzip": "^1.1.5",
|
|
50
52
|
"node-fetch": "^2.6.1",
|
|
51
53
|
"plist": "^3.1.0",
|
|
@@ -68,5 +70,6 @@
|
|
|
68
70
|
"@swc/core": "^1.9.3",
|
|
69
71
|
"@types/node": "^22.9.3",
|
|
70
72
|
"typescript": "^5.7.2"
|
|
71
|
-
}
|
|
73
|
+
},
|
|
74
|
+
"packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
|
|
72
75
|
}
|
package/src/.DS_Store
ADDED
|
Binary file
|
package/src/api.ts
CHANGED
|
@@ -6,16 +6,19 @@ import ProgressBar from 'progress';
|
|
|
6
6
|
import packageJson from '../package.json';
|
|
7
7
|
import tcpp from 'tcp-ping';
|
|
8
8
|
import filesizeParser from 'filesize-parser';
|
|
9
|
-
import { pricingPageUrl } from './utils';
|
|
9
|
+
import { pricingPageUrl } from './utils/constants';
|
|
10
10
|
import type { Session } from 'types';
|
|
11
11
|
import FormData from 'form-data';
|
|
12
|
+
import { credentialFile } from 'utils/constants';
|
|
12
13
|
|
|
13
14
|
const tcpPing = util.promisify(tcpp.ping);
|
|
14
15
|
|
|
15
16
|
let session: Session | undefined;
|
|
16
17
|
let savedSession: Session | undefined;
|
|
17
18
|
|
|
18
|
-
const defaultEndpoint =
|
|
19
|
+
const defaultEndpoint = global.IS_CRESC
|
|
20
|
+
? 'https://api.cresc.dev'
|
|
21
|
+
: 'https://update.reactnative.cn/api';
|
|
19
22
|
let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
|
|
20
23
|
|
|
21
24
|
const userAgent = `react-native-update-cli/${packageJson.version}`;
|
|
@@ -26,14 +29,16 @@ export const replaceSession = (newSession: { token: string }) => {
|
|
|
26
29
|
session = newSession;
|
|
27
30
|
};
|
|
28
31
|
|
|
32
|
+
|
|
33
|
+
|
|
29
34
|
export const loadSession = async () => {
|
|
30
|
-
if (fs.existsSync(
|
|
35
|
+
if (fs.existsSync(credentialFile)) {
|
|
31
36
|
try {
|
|
32
|
-
replaceSession(JSON.parse(fs.readFileSync(
|
|
37
|
+
replaceSession(JSON.parse(fs.readFileSync(credentialFile, 'utf8')));
|
|
33
38
|
savedSession = session;
|
|
34
39
|
} catch (e) {
|
|
35
40
|
console.error(
|
|
36
|
-
|
|
41
|
+
`Failed to parse file ${credentialFile}. Try to remove it manually.`,
|
|
37
42
|
);
|
|
38
43
|
throw e;
|
|
39
44
|
}
|
|
@@ -45,14 +50,14 @@ export const saveSession = () => {
|
|
|
45
50
|
if (session !== savedSession) {
|
|
46
51
|
const current = session;
|
|
47
52
|
const data = JSON.stringify(current, null, 4);
|
|
48
|
-
fs.writeFileSync(
|
|
53
|
+
fs.writeFileSync(credentialFile, data, 'utf8');
|
|
49
54
|
savedSession = current;
|
|
50
55
|
}
|
|
51
56
|
};
|
|
52
57
|
|
|
53
58
|
export const closeSession = () => {
|
|
54
|
-
if (fs.existsSync(
|
|
55
|
-
fs.unlinkSync(
|
|
59
|
+
if (fs.existsSync(credentialFile)) {
|
|
60
|
+
fs.unlinkSync(credentialFile);
|
|
56
61
|
savedSession = undefined;
|
|
57
62
|
}
|
|
58
63
|
session = undefined;
|
|
@@ -121,7 +126,7 @@ export async function uploadFile(fn: string, key?: string) {
|
|
|
121
126
|
timeout: 1000,
|
|
122
127
|
});
|
|
123
128
|
// console.log({pingResult});
|
|
124
|
-
if (isNaN(pingResult.avg) || pingResult.avg > 150) {
|
|
129
|
+
if (Number.isNaN(pingResult.avg) || pingResult.avg > 150) {
|
|
125
130
|
realUrl = backupUrl;
|
|
126
131
|
}
|
|
127
132
|
}
|
|
@@ -137,7 +142,7 @@ export async function uploadFile(fn: string, key?: string) {
|
|
|
137
142
|
);
|
|
138
143
|
}
|
|
139
144
|
|
|
140
|
-
const bar = new ProgressBar('
|
|
145
|
+
const bar = new ProgressBar(' Uploading [:bar] :percent :etas', {
|
|
141
146
|
complete: '=',
|
|
142
147
|
incomplete: ' ',
|
|
143
148
|
total: fileSize,
|
|
@@ -145,9 +150,9 @@ export async function uploadFile(fn: string, key?: string) {
|
|
|
145
150
|
|
|
146
151
|
const form = new FormData();
|
|
147
152
|
|
|
148
|
-
|
|
153
|
+
for (const [k, v] of Object.entries(formData)) {
|
|
149
154
|
form.append(k, v);
|
|
150
|
-
}
|
|
155
|
+
}
|
|
151
156
|
const fileStream = fs.createReadStream(fn);
|
|
152
157
|
fileStream.on('data', (data) => {
|
|
153
158
|
bar.tick(data.length);
|
package/src/bundle.ts
CHANGED
|
@@ -30,6 +30,7 @@ async function runReactNativeBundleCommand({
|
|
|
30
30
|
platform,
|
|
31
31
|
sourcemapOutput,
|
|
32
32
|
config,
|
|
33
|
+
disableHermes,
|
|
33
34
|
cli,
|
|
34
35
|
}: {
|
|
35
36
|
bundleName: string;
|
|
@@ -39,6 +40,7 @@ async function runReactNativeBundleCommand({
|
|
|
39
40
|
platform: string;
|
|
40
41
|
sourcemapOutput: string;
|
|
41
42
|
config?: string;
|
|
43
|
+
disableHermes?: boolean;
|
|
42
44
|
cli: {
|
|
43
45
|
taro?: boolean;
|
|
44
46
|
expo?: boolean;
|
|
@@ -84,7 +86,7 @@ async function runReactNativeBundleCommand({
|
|
|
84
86
|
require.resolve('@expo/cli/package.json', {
|
|
85
87
|
paths: [process.cwd()],
|
|
86
88
|
}),
|
|
87
|
-
),
|
|
89
|
+
).toString(),
|
|
88
90
|
).version;
|
|
89
91
|
// expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
|
|
90
92
|
if (semverSatisfies(expoCliVersion, '>= 0.10.17')) {
|
|
@@ -221,7 +223,10 @@ async function runReactNativeBundleCommand({
|
|
|
221
223
|
} else {
|
|
222
224
|
let hermesEnabled: boolean | undefined = false;
|
|
223
225
|
|
|
224
|
-
if (
|
|
226
|
+
if (disableHermes) {
|
|
227
|
+
hermesEnabled = false;
|
|
228
|
+
console.log('Hermes disabled');
|
|
229
|
+
} else if (platform === 'android') {
|
|
225
230
|
const gradlePropeties = await new Promise<{
|
|
226
231
|
hermesEnabled?: boolean;
|
|
227
232
|
}>((resolve) => {
|
|
@@ -292,7 +297,7 @@ function getHermesOSBin() {
|
|
|
292
297
|
|
|
293
298
|
async function checkGradleConfig() {
|
|
294
299
|
let enableHermes = false;
|
|
295
|
-
let crunchPngs;
|
|
300
|
+
let crunchPngs: boolean | undefined;
|
|
296
301
|
try {
|
|
297
302
|
const gradleConfig = await g2js.parseFile('android/app/build.gradle');
|
|
298
303
|
crunchPngs = gradleConfig.android.buildTypes.release.crunchPngs;
|
|
@@ -904,6 +909,7 @@ export const commands = {
|
|
|
904
909
|
taro,
|
|
905
910
|
expo,
|
|
906
911
|
rncli,
|
|
912
|
+
disableHermes,
|
|
907
913
|
} = translateOptions({
|
|
908
914
|
...options,
|
|
909
915
|
platform,
|
|
@@ -932,6 +938,7 @@ export const commands = {
|
|
|
932
938
|
outputFolder: intermediaDir,
|
|
933
939
|
platform,
|
|
934
940
|
sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
|
|
941
|
+
disableHermes,
|
|
935
942
|
cli: {
|
|
936
943
|
taro,
|
|
937
944
|
expo,
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
import { loadSession } from './api';
|
|
4
4
|
import updateNotifier from 'update-notifier';
|
|
5
|
-
import { printVersionCommand } from './utils
|
|
5
|
+
import { printVersionCommand } from './utils';
|
|
6
6
|
import pkg from '../package.json';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import i18next from 'i18next';
|
|
9
|
+
import en from './locales/en';
|
|
10
|
+
import zh from './locales/zh';
|
|
11
|
+
|
|
12
|
+
const scriptName: 'cresc' | 'pushy' = path.basename(process.argv[1]) as
|
|
13
|
+
| 'cresc'
|
|
14
|
+
| 'pushy';
|
|
15
|
+
global.IS_CRESC = scriptName === 'cresc';
|
|
16
|
+
|
|
17
|
+
i18next.init({
|
|
18
|
+
lng: global.IS_CRESC ? 'en' : 'zh',
|
|
19
|
+
// debug: process.env.NODE_ENV !== 'production',
|
|
20
|
+
resources: {
|
|
21
|
+
en,
|
|
22
|
+
zh,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
7
25
|
|
|
8
26
|
updateNotifier({ pkg }).notify({
|
|
9
27
|
isGlobal: true,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
package/src/types.ts
CHANGED
|
Binary file
|
|
@@ -42,7 +42,7 @@ class Zip {
|
|
|
42
42
|
regex = decodeNullUnicode(regex);
|
|
43
43
|
return new Promise((resolve, reject) => {
|
|
44
44
|
this.unzip.getBuffer([regex], { type }, (err, buffers) => {
|
|
45
|
-
console.log(buffers);
|
|
45
|
+
// console.log(buffers);
|
|
46
46
|
err ? reject(err) : resolve(buffers[regex]);
|
|
47
47
|
});
|
|
48
48
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const credentialFile = global.IS_CRESC ? '.cresc.token' : '.update';
|
|
2
|
+
export const updateJson = global.IS_CRESC ? 'cresc.config.json' : 'update.json';
|
|
3
|
+
export const tempDir = global.IS_CRESC ? '.cresc.temp' : '.pushy';
|
|
4
|
+
export const pricingPageUrl = global.IS_CRESC
|
|
5
|
+
? 'https://cresc.dev/pricing'
|
|
6
|
+
: 'https://pushy.reactnative.cn/pricing.html';
|
package/src/utils/index.ts
CHANGED
|
@@ -9,8 +9,9 @@ import latestVersion from '@badisi/latest-version';
|
|
|
9
9
|
import { checkPlugins } from './check-plugin';
|
|
10
10
|
|
|
11
11
|
import { read } from 'read';
|
|
12
|
+
import { tempDir } from './constants';
|
|
12
13
|
|
|
13
|
-
export async function question(query, password) {
|
|
14
|
+
export async function question(query: string, password: boolean) {
|
|
14
15
|
if (NO_INTERACTIVE) {
|
|
15
16
|
return '';
|
|
16
17
|
}
|
|
@@ -21,7 +22,7 @@ export async function question(query, password) {
|
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export function translateOptions(options) {
|
|
25
|
+
export function translateOptions(options: Record<string, string>) {
|
|
25
26
|
const ret = {};
|
|
26
27
|
for (const key in options) {
|
|
27
28
|
const v = options[key];
|
|
@@ -55,7 +56,7 @@ export function getRNVersion() {
|
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
export async function getApkInfo(fn) {
|
|
59
|
+
export async function getApkInfo(fn: string) {
|
|
59
60
|
const appInfoParser = new AppInfoParser(fn);
|
|
60
61
|
const bundleFile = await appInfoParser.parser.getEntry(
|
|
61
62
|
/assets\/index.android.bundle/,
|
|
@@ -163,16 +164,16 @@ export async function getIpaInfo(fn: string) {
|
|
|
163
164
|
return { versionName, buildTime, ...appCredential };
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
const localDir = path.resolve(os.homedir(),
|
|
167
|
+
const localDir = path.resolve(os.homedir(), tempDir);
|
|
167
168
|
fs.ensureDirSync(localDir);
|
|
168
|
-
export function saveToLocal(originPath, destName) {
|
|
169
|
+
export function saveToLocal(originPath: string, destName: string) {
|
|
169
170
|
// TODO
|
|
170
171
|
// const destPath = path.join(localDir, destName);
|
|
171
172
|
// fs.ensureDirSync(path.dirname(destPath));
|
|
172
173
|
// fs.copyFileSync(originPath, destPath);
|
|
173
174
|
}
|
|
174
175
|
|
|
175
|
-
async function getLatestVersion(pkgName) {
|
|
176
|
+
async function getLatestVersion(pkgName: string) {
|
|
176
177
|
return Promise.race([
|
|
177
178
|
latestVersion(pkgName)
|
|
178
179
|
.then((p) => p.latest)
|
|
@@ -225,6 +226,6 @@ export async function printVersionCommand() {
|
|
|
225
226
|
}
|
|
226
227
|
}
|
|
227
228
|
|
|
228
|
-
|
|
229
|
+
|
|
229
230
|
|
|
230
231
|
export { checkPlugins };
|