react-native-update-cli 1.42.1 → 1.43.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 +11 -11
- package/lib/api.js +9 -4
- package/lib/app.js +34 -26
- package/lib/bundle.js +10 -1
- package/lib/locales/en.js +22 -2
- package/lib/locales/zh.js +21 -1
- package/lib/utils/add-gitignore.js +43 -0
- package/lib/utils/app-info-parser/index.js +13 -4
- package/lib/utils/check-lockfile.js +42 -0
- package/lib/utils/check-plugin.js +2 -2
- package/lib/utils/constants.js +4 -0
- package/lib/utils/i18n.js +7 -2
- package/lib/utils/index.js +44 -23
- package/lib/versions.js +1 -1
- package/package.json +1 -1
- package/src/api.ts +13 -9
- package/src/app.ts +20 -32
- package/src/bundle.ts +9 -1
- package/src/locales/en.ts +27 -1
- package/src/locales/zh.ts +26 -1
- package/src/utils/add-gitignore.ts +34 -0
- package/src/utils/app-info-parser/{index.js → index.ts} +7 -5
- package/src/utils/check-lockfile.ts +29 -0
- package/src/utils/check-plugin.ts +2 -2
- package/src/utils/constants.ts +5 -3
- package/src/utils/i18n.ts +8 -2
- package/src/utils/index.ts +54 -39
- package/src/versions.ts +9 -3
- package/lib/utils/lock-checker.js +0 -8
- package/src/utils/lock-checker.ts +0 -7
package/cli.json
CHANGED
|
@@ -136,11 +136,11 @@
|
|
|
136
136
|
"hasValue": true
|
|
137
137
|
},
|
|
138
138
|
"intermediaDir": {
|
|
139
|
-
"default": "
|
|
139
|
+
"default": "${tempDir}/intermedia/${platform}",
|
|
140
140
|
"hasValue": true
|
|
141
141
|
},
|
|
142
142
|
"output": {
|
|
143
|
-
"default": "
|
|
143
|
+
"default": "${tempDir}/output/${platform}.${time}.ppk",
|
|
144
144
|
"hasValue": true
|
|
145
145
|
},
|
|
146
146
|
"sourcemap": {
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"description": "Create diff patch",
|
|
168
168
|
"options": {
|
|
169
169
|
"output": {
|
|
170
|
-
"default": "
|
|
170
|
+
"default": "${tempDir}/output/diff",
|
|
171
171
|
"hasValue": true
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"description": "Create diff patch from a Android package(.apk)",
|
|
177
177
|
"options": {
|
|
178
178
|
"output": {
|
|
179
|
-
"default": "
|
|
179
|
+
"default": "${tempDir}/output/diff-${time}.apk-patch",
|
|
180
180
|
"hasValue": true
|
|
181
181
|
}
|
|
182
182
|
}
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
"description": "Create diff patch from a iOS package(.ipa)",
|
|
186
186
|
"options": {
|
|
187
187
|
"output": {
|
|
188
|
-
"default": "
|
|
188
|
+
"default": "${tempDir}/output/diff-${time}.ipa-patch",
|
|
189
189
|
"hasValue": true
|
|
190
190
|
}
|
|
191
191
|
}
|
|
@@ -194,7 +194,7 @@
|
|
|
194
194
|
"description": "Create hdiff patch",
|
|
195
195
|
"options": {
|
|
196
196
|
"output": {
|
|
197
|
-
"default": "
|
|
197
|
+
"default": "${tempDir}/output/hdiff",
|
|
198
198
|
"hasValue": true
|
|
199
199
|
}
|
|
200
200
|
}
|
|
@@ -203,7 +203,7 @@
|
|
|
203
203
|
"description": "Create hdiff patch from a Android package(.apk)",
|
|
204
204
|
"options": {
|
|
205
205
|
"output": {
|
|
206
|
-
"default": "
|
|
206
|
+
"default": "${tempDir}/output/hdiff-${time}.apk-patch",
|
|
207
207
|
"hasValue": true
|
|
208
208
|
}
|
|
209
209
|
}
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
"description": "Create hdiff patch from a Prepare package(.ppk)",
|
|
213
213
|
"options": {
|
|
214
214
|
"output": {
|
|
215
|
-
"default": "
|
|
215
|
+
"default": "${tempDir}/output/hdiff-${time}.ppk-patch",
|
|
216
216
|
"hasValue": true
|
|
217
217
|
}
|
|
218
218
|
}
|
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
"description": "Create hdiff patch from a Harmony package(.app)",
|
|
222
222
|
"options": {
|
|
223
223
|
"output": {
|
|
224
|
-
"default": "
|
|
224
|
+
"default": "${tempDir}/output/hdiff-${time}.app-patch",
|
|
225
225
|
"hasValue": true
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
"description": "Create hdiff patch from a iOS package(.ipa)",
|
|
231
231
|
"options": {
|
|
232
232
|
"output": {
|
|
233
|
-
"default": "
|
|
233
|
+
"default": "${tempDir}/output/hdiff-${time}.ipa-patch",
|
|
234
234
|
"hasValue": true
|
|
235
235
|
}
|
|
236
236
|
}
|
|
@@ -241,4 +241,4 @@
|
|
|
241
241
|
"default": false
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
}
|
|
244
|
+
}
|
package/lib/api.js
CHANGED
|
@@ -50,6 +50,7 @@ const _tcpping = /*#__PURE__*/ _interop_require_default(require("tcp-ping"));
|
|
|
50
50
|
const _filesizeparser = /*#__PURE__*/ _interop_require_default(require("filesize-parser"));
|
|
51
51
|
const _constants = require("./utils/constants");
|
|
52
52
|
const _formdata = /*#__PURE__*/ _interop_require_default(require("form-data"));
|
|
53
|
+
const _i18n = require("./utils/i18n");
|
|
53
54
|
function _interop_require_default(obj) {
|
|
54
55
|
return obj && obj.__esModule ? obj : {
|
|
55
56
|
default: obj
|
|
@@ -58,8 +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
|
|
62
|
-
const host = process.env.PUSHY_REGISTRY || process.env.RNU_API || defaultEndpoint;
|
|
62
|
+
const host = process.env.PUSHY_REGISTRY || process.env.RNU_API || _constants.defaultEndpoint;
|
|
63
63
|
const userAgent = `react-native-update-cli/${_packagejson.default.version}`;
|
|
64
64
|
const getSession = ()=>session;
|
|
65
65
|
const replaceSession = (newSession)=>{
|
|
@@ -102,7 +102,7 @@ async function query(url, options) {
|
|
|
102
102
|
if (resp.status !== 200) {
|
|
103
103
|
const message = (json == null ? void 0 : json.message) || resp.statusText;
|
|
104
104
|
if (resp.status === 401) {
|
|
105
|
-
throw new Error(
|
|
105
|
+
throw new Error((0, _i18n.t)('loginExpired'));
|
|
106
106
|
}
|
|
107
107
|
throw new Error(message);
|
|
108
108
|
}
|
|
@@ -155,7 +155,12 @@ async function uploadFile(fn, key) {
|
|
|
155
155
|
}
|
|
156
156
|
const fileSize = _nodefs.default.statSync(fn).size;
|
|
157
157
|
if (maxSize && fileSize > (0, _filesizeparser.default)(maxSize)) {
|
|
158
|
-
|
|
158
|
+
const readableFileSize = `${(fileSize / 1048576).toFixed(1)}m`;
|
|
159
|
+
throw new Error((0, _i18n.t)('fileSizeExceeded', {
|
|
160
|
+
fileSize: readableFileSize,
|
|
161
|
+
maxSize,
|
|
162
|
+
pricingPageUrl: _constants.pricingPageUrl
|
|
163
|
+
}));
|
|
159
164
|
}
|
|
160
165
|
const bar = new _progress.default(' Uploading [:bar] :percent :etas', {
|
|
161
166
|
complete: '=',
|
package/lib/app.js
CHANGED
|
@@ -29,45 +29,52 @@ const _utils = require("./utils");
|
|
|
29
29
|
const _nodefs = /*#__PURE__*/ _interop_require_default(require("node:fs"));
|
|
30
30
|
const _ttytable = /*#__PURE__*/ _interop_require_default(require("tty-table"));
|
|
31
31
|
const _api = require("./api");
|
|
32
|
+
const _i18n = require("./utils/i18n");
|
|
32
33
|
function _interop_require_default(obj) {
|
|
33
34
|
return obj && obj.__esModule ? obj : {
|
|
34
35
|
default: obj
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
|
-
const validPlatforms =
|
|
38
|
-
ios
|
|
39
|
-
android
|
|
40
|
-
harmony
|
|
41
|
-
|
|
38
|
+
const validPlatforms = [
|
|
39
|
+
'ios',
|
|
40
|
+
'android',
|
|
41
|
+
'harmony'
|
|
42
|
+
];
|
|
42
43
|
function checkPlatform(platform) {
|
|
43
|
-
if (!validPlatforms
|
|
44
|
-
throw new Error(
|
|
44
|
+
if (!validPlatforms.includes(platform)) {
|
|
45
|
+
throw new Error((0, _i18n.t)('unsupportedPlatform', {
|
|
46
|
+
platform
|
|
47
|
+
}));
|
|
45
48
|
}
|
|
46
49
|
return platform;
|
|
47
50
|
}
|
|
48
51
|
function getSelectedApp(platform) {
|
|
49
52
|
checkPlatform(platform);
|
|
50
53
|
if (!_nodefs.default.existsSync('update.json')) {
|
|
51
|
-
throw new Error(
|
|
54
|
+
throw new Error((0, _i18n.t)('appNotSelected', {
|
|
55
|
+
platform
|
|
56
|
+
}));
|
|
52
57
|
}
|
|
53
58
|
const updateInfo = JSON.parse(_nodefs.default.readFileSync('update.json', 'utf8'));
|
|
54
59
|
if (!updateInfo[platform]) {
|
|
55
|
-
throw new Error(
|
|
60
|
+
throw new Error((0, _i18n.t)('appNotSelected', {
|
|
61
|
+
platform
|
|
62
|
+
}));
|
|
56
63
|
}
|
|
57
64
|
return updateInfo[platform];
|
|
58
65
|
}
|
|
59
|
-
async function listApp(platform) {
|
|
66
|
+
async function listApp(platform = '') {
|
|
60
67
|
const { data } = await (0, _api.get)('/app/list');
|
|
61
68
|
const list = platform ? data.filter((v)=>v.platform === platform) : data;
|
|
62
69
|
const header = [
|
|
63
70
|
{
|
|
64
|
-
value:
|
|
71
|
+
value: (0, _i18n.t)('appId')
|
|
65
72
|
},
|
|
66
73
|
{
|
|
67
|
-
value: '
|
|
74
|
+
value: (0, _i18n.t)('appName')
|
|
68
75
|
},
|
|
69
76
|
{
|
|
70
|
-
value: '
|
|
77
|
+
value: (0, _i18n.t)('platform')
|
|
71
78
|
}
|
|
72
79
|
];
|
|
73
80
|
const rows = [];
|
|
@@ -79,17 +86,16 @@ async function listApp(platform) {
|
|
|
79
86
|
]);
|
|
80
87
|
}
|
|
81
88
|
console.log((0, _ttytable.default)(header, rows).render());
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
89
|
+
console.log(`\n${(0, _i18n.t)('totalApps', {
|
|
90
|
+
count: list.length,
|
|
91
|
+
platform
|
|
92
|
+
})}`);
|
|
87
93
|
return list;
|
|
88
94
|
}
|
|
89
95
|
async function chooseApp(platform) {
|
|
90
96
|
const list = await listApp(platform);
|
|
91
97
|
while(true){
|
|
92
|
-
const id = await (0, _utils.question)(
|
|
98
|
+
const id = await (0, _utils.question)((0, _i18n.t)('enterAppIdQuestion'));
|
|
93
99
|
const app = list.find((v)=>v.id === Number(id));
|
|
94
100
|
if (app) {
|
|
95
101
|
return app;
|
|
@@ -98,15 +104,17 @@ async function chooseApp(platform) {
|
|
|
98
104
|
}
|
|
99
105
|
const commands = {
|
|
100
106
|
createApp: async function({ options }) {
|
|
101
|
-
const name = options.name || await (0, _utils.question)('
|
|
107
|
+
const name = options.name || await (0, _utils.question)((0, _i18n.t)('appNameQuestion'));
|
|
102
108
|
const { downloadUrl } = options;
|
|
103
|
-
const platform = checkPlatform(options.platform || await (0, _utils.question)(
|
|
109
|
+
const platform = checkPlatform(options.platform || await (0, _utils.question)((0, _i18n.t)('platformQuestion')));
|
|
104
110
|
const { id } = await (0, _api.post)('/app/create', {
|
|
105
111
|
name,
|
|
106
112
|
platform,
|
|
107
113
|
downloadUrl
|
|
108
114
|
});
|
|
109
|
-
console.log(
|
|
115
|
+
console.log((0, _i18n.t)('createAppSuccess', {
|
|
116
|
+
id
|
|
117
|
+
}));
|
|
110
118
|
await this.selectApp({
|
|
111
119
|
args: [
|
|
112
120
|
id
|
|
@@ -120,24 +128,24 @@ const commands = {
|
|
|
120
128
|
const { platform } = options;
|
|
121
129
|
const id = args[0] || chooseApp(platform);
|
|
122
130
|
if (!id) {
|
|
123
|
-
console.log('
|
|
131
|
+
console.log((0, _i18n.t)('cancelled'));
|
|
124
132
|
}
|
|
125
133
|
await (0, _api.doDelete)(`/app/${id}`);
|
|
126
|
-
console.log('
|
|
134
|
+
console.log((0, _i18n.t)('operationSuccess'));
|
|
127
135
|
},
|
|
128
136
|
apps: async ({ options })=>{
|
|
129
137
|
const { platform } = options;
|
|
130
138
|
listApp(platform);
|
|
131
139
|
},
|
|
132
140
|
selectApp: async ({ args, options })=>{
|
|
133
|
-
const platform = checkPlatform(options.platform || await (0, _utils.question)(
|
|
141
|
+
const platform = checkPlatform(options.platform || await (0, _utils.question)((0, _i18n.t)('platformQuestion')));
|
|
134
142
|
const id = args[0] ? Number.parseInt(args[0]) : (await chooseApp(platform)).id;
|
|
135
143
|
let updateInfo = {};
|
|
136
144
|
if (_nodefs.default.existsSync('update.json')) {
|
|
137
145
|
try {
|
|
138
146
|
updateInfo = JSON.parse(_nodefs.default.readFileSync('update.json', 'utf8'));
|
|
139
147
|
} catch (e) {
|
|
140
|
-
console.error(
|
|
148
|
+
console.error((0, _i18n.t)('failedToParseUpdateJson'));
|
|
141
149
|
throw e;
|
|
142
150
|
}
|
|
143
151
|
}
|
package/lib/bundle.js
CHANGED
|
@@ -29,6 +29,10 @@ const _nodechild_process = require("node:child_process");
|
|
|
29
29
|
const _satisfies = /*#__PURE__*/ _interop_require_default(require("semver/functions/satisfies"));
|
|
30
30
|
const _nodeos = /*#__PURE__*/ _interop_require_default(require("node:os"));
|
|
31
31
|
const _depversions = require("./utils/dep-versions");
|
|
32
|
+
const _i18n = require("./utils/i18n");
|
|
33
|
+
const _constants = require("./utils/constants");
|
|
34
|
+
const _checklockfile = require("./utils/check-lockfile");
|
|
35
|
+
const _addgitignore = require("./utils/add-gitignore");
|
|
32
36
|
function _interop_require_default(obj) {
|
|
33
37
|
return obj && obj.__esModule ? obj : {
|
|
34
38
|
default: obj
|
|
@@ -464,7 +468,9 @@ async function pack(dir, output) {
|
|
|
464
468
|
});
|
|
465
469
|
zipfile.end();
|
|
466
470
|
});
|
|
467
|
-
console.log(
|
|
471
|
+
console.log((0, _i18n.t)('ppkPackageGenerated', {
|
|
472
|
+
output
|
|
473
|
+
}));
|
|
468
474
|
}
|
|
469
475
|
function readEntire(entry, zipFile) {
|
|
470
476
|
const buffers = [];
|
|
@@ -757,8 +763,11 @@ const commands = {
|
|
|
757
763
|
const platform = (0, _app.checkPlatform)(options.platform || await (0, _utils.question)('平台(ios/android/harmony):'));
|
|
758
764
|
const { bundleName, entryFile, intermediaDir, output, dev, sourcemap, taro, expo, rncli, disableHermes } = (0, _utils.translateOptions)({
|
|
759
765
|
...options,
|
|
766
|
+
tempDir: _constants.tempDir,
|
|
760
767
|
platform
|
|
761
768
|
});
|
|
769
|
+
(0, _checklockfile.checkLockFiles)();
|
|
770
|
+
(0, _addgitignore.addGitIgnore)();
|
|
762
771
|
const bundleParams = await (0, _utils.checkPlugins)();
|
|
763
772
|
const sourcemapPlugin = bundleParams.sourcemap;
|
|
764
773
|
const isSentry = bundleParams.sentry;
|
package/lib/locales/en.js
CHANGED
|
@@ -12,12 +12,32 @@ const _default = {
|
|
|
12
12
|
updateNotifier: 'Run `{updateCommand}` to update the CLI to get continuous improvements in features, performance, and security.',
|
|
13
13
|
loginFirst: 'Not logged in.\nPlease run `cresc login` in the project directory to login.',
|
|
14
14
|
lockNotFound: 'No lock file detected, which may cause inconsistent dependencies and hot-updating issues.',
|
|
15
|
-
multipleLocksFound: 'Multiple lock files detected ({lockFiles}), which may cause inconsistent dependencies and hot-updating issues.',
|
|
15
|
+
multipleLocksFound: 'Multiple lock files detected ({{lockFiles}}), which may cause inconsistent dependencies and hot-updating issues.',
|
|
16
16
|
lockBestPractice: `
|
|
17
17
|
Best practices for lock files:
|
|
18
18
|
1. All members of the development team should use the same package manager to maintain a single lock file.
|
|
19
19
|
2. Add the lock file to version control (but do not commit multiple lock files of different formats).
|
|
20
20
|
3. Pay attention to changes in the lock file during code review.
|
|
21
21
|
This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
22
|
-
|
|
22
|
+
`,
|
|
23
|
+
loginExpired: 'Login information has expired. Please use `cresc login` command to re-login',
|
|
24
|
+
fileSizeExceeded: 'This file size is {{fileSize}} , exceeding the current quota {{maxSize}} . You may consider upgrading to a higher plan to increase this quota. Details can be found at: {{pricingPageUrl}}',
|
|
25
|
+
bundleNotFound: 'Bundle file not found. Please ensure that this {{packageType}} is a release version and the bundle file name is the default `{{entryFile}}`',
|
|
26
|
+
buildTimeNotFound: 'Cannot get the build timestamp of this package. Please update `react-native-update` to the latest version and re-package and upload.',
|
|
27
|
+
latestVersionTag: '(latest: {{version}})',
|
|
28
|
+
rnuVersionNotFound: 'react-native-update: Cannot get the version number. Please run the command in the project directory',
|
|
29
|
+
unsupportedPlatform: 'Unsupported platform `{{platform}}`',
|
|
30
|
+
appId: 'App ID',
|
|
31
|
+
appName: 'App Name',
|
|
32
|
+
platform: 'Platform',
|
|
33
|
+
totalApps: 'Total {{count}} apps',
|
|
34
|
+
appNotSelected: 'App not selected. run `cresc selectApp --platform {{platform}}` first!',
|
|
35
|
+
enterAppIdQuestion: 'Enter AppId:',
|
|
36
|
+
appNameQuestion: 'App Name:',
|
|
37
|
+
platformQuestion: 'Platform(ios/android/harmony):',
|
|
38
|
+
createAppSuccess: 'App created successfully (id: {{id}})',
|
|
39
|
+
cancelled: 'Cancelled',
|
|
40
|
+
operationSuccess: 'Operation successful',
|
|
41
|
+
failedToParseUpdateJson: 'Failed to parse file `update.json`. Try to remove it manually.',
|
|
42
|
+
ppkPackageGenerated: 'ppk package generated and saved to: {{output}}'
|
|
23
43
|
};
|
package/lib/locales/zh.js
CHANGED
|
@@ -19,5 +19,25 @@ const _default = {
|
|
|
19
19
|
3. 代码审核时应关注 lock 文件的变化。
|
|
20
20
|
这样可以最大限度避免因依赖关系不一致而导致的热更异常,也降低供应链攻击等安全隐患。
|
|
21
21
|
`,
|
|
22
|
-
multipleLocksFound: '检测到多种不同格式的锁文件({lockFiles}),这可能导致依赖关系不一致而使热更异常。'
|
|
22
|
+
multipleLocksFound: '检测到多种不同格式的锁文件({{lockFiles}}),这可能导致依赖关系不一致而使热更异常。',
|
|
23
|
+
loginExpired: '登录信息已过期,请使用 `pushy login` 命令重新登录',
|
|
24
|
+
fileSizeExceeded: '此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{pricingPageUrl}}',
|
|
25
|
+
bundleNotFound: '找不到 bundle 文件。请确保此 {{packageType}} 为 release 版本,且 bundle 文件名为默认的 `{{entryFile}}`',
|
|
26
|
+
buildTimeNotFound: '无法获取此包的编译时间戳。请更新 `react-native-update` 到最新版本后重新打包上传。',
|
|
27
|
+
latestVersionTag: '(最新:{{version}})',
|
|
28
|
+
rnuVersionNotFound: 'react-native-update: 无法获取版本号。请在项目目录中运行命令',
|
|
29
|
+
unsupportedPlatform: '无法识别的平台 `{{platform}}`',
|
|
30
|
+
appId: '应用 id',
|
|
31
|
+
appName: '应用名称',
|
|
32
|
+
platform: '平台',
|
|
33
|
+
totalApps: '共 {{count}} 个{{platform}}应用',
|
|
34
|
+
appNotSelected: '尚未选择应用。请先运行 `pushy selectApp --platform {{platform}}` 来选择应用',
|
|
35
|
+
enterAppIdQuestion: '输入应用 id:',
|
|
36
|
+
appNameQuestion: '应用名称:',
|
|
37
|
+
platformQuestion: '平台(ios/android/harmony):',
|
|
38
|
+
createAppSuccess: '已成功创建应用(id: {{id}})',
|
|
39
|
+
cancelled: '已取消',
|
|
40
|
+
operationSuccess: '操作成功',
|
|
41
|
+
failedToParseUpdateJson: '无法解析文件 `update.json`。请手动删除它。',
|
|
42
|
+
ppkPackageGenerated: 'ppk 热更包已生成并保存到: {{output}}'
|
|
23
43
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "addGitIgnore", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return addGitIgnore;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _nodefs = /*#__PURE__*/ _interop_require_default(require("node:fs"));
|
|
12
|
+
const _constants = require("./constants");
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function addGitIgnore() {
|
|
19
|
+
const shouldIgnore = [
|
|
20
|
+
_constants.credentialFile,
|
|
21
|
+
_constants.tempDir
|
|
22
|
+
];
|
|
23
|
+
const gitignorePath = '.gitignore';
|
|
24
|
+
if (!_nodefs.default.existsSync(gitignorePath)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const gitignoreContent = _nodefs.default.readFileSync(gitignorePath, 'utf-8');
|
|
28
|
+
const gitignoreLines = gitignoreContent.split('\n');
|
|
29
|
+
for (const line of gitignoreLines){
|
|
30
|
+
const index = shouldIgnore.indexOf(line.trim());
|
|
31
|
+
if (index !== -1) {
|
|
32
|
+
shouldIgnore.splice(index, 1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (shouldIgnore.length > 0) {
|
|
36
|
+
gitignoreLines.push('# react-native-update');
|
|
37
|
+
for (const line of shouldIgnore){
|
|
38
|
+
gitignoreLines.push(line);
|
|
39
|
+
console.log(`Added ${line} to .gitignore`);
|
|
40
|
+
}
|
|
41
|
+
_nodefs.default.writeFileSync(gitignorePath, gitignoreLines.join('\n'));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
2
11
|
const ApkParser = require('./apk');
|
|
3
12
|
const IpaParser = require('./ipa');
|
|
4
13
|
const AppParser = require('./app');
|
|
@@ -13,12 +22,12 @@ class AppInfoParser {
|
|
|
13
22
|
}
|
|
14
23
|
/**
|
|
15
24
|
* parser for parsing .ipa or .apk file
|
|
16
|
-
* @param {String | File
|
|
25
|
+
* @param {String | File} file // file's path in Node, instance of File in Browser
|
|
17
26
|
*/ constructor(file){
|
|
18
27
|
if (!file) {
|
|
19
|
-
throw new Error("Param miss: file(file's path in Node, instance of File
|
|
28
|
+
throw new Error("Param miss: file(file's path in Node, instance of File in browser).");
|
|
20
29
|
}
|
|
21
|
-
const splits = (file
|
|
30
|
+
const splits = (typeof file === 'string' ? file : file.name).split('.');
|
|
22
31
|
const fileType = splits[splits.length - 1].toLowerCase();
|
|
23
32
|
if (!supportFileTypes.includes(fileType)) {
|
|
24
33
|
throw new Error('Unsupported file type, only support .ipa or .apk or .app file.');
|
|
@@ -37,4 +46,4 @@ class AppInfoParser {
|
|
|
37
46
|
}
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
|
-
|
|
49
|
+
const _default = AppInfoParser;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "checkLockFiles", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return checkLockFiles;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _nodefs = /*#__PURE__*/ _interop_require_default(require("node:fs"));
|
|
12
|
+
const _i18n = require("./i18n");
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const lockFiles = [
|
|
19
|
+
'package-lock.json',
|
|
20
|
+
'yarn.lock',
|
|
21
|
+
'pnpm-lock.yaml',
|
|
22
|
+
'bun.lockb',
|
|
23
|
+
'bun.lock'
|
|
24
|
+
];
|
|
25
|
+
const existingLockFiles = [];
|
|
26
|
+
function checkLockFiles() {
|
|
27
|
+
for (const file of lockFiles){
|
|
28
|
+
if (_nodefs.default.existsSync(file)) {
|
|
29
|
+
existingLockFiles.push(file);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (existingLockFiles.length === 1) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
console.warn((0, _i18n.t)('lockBestPractice'));
|
|
36
|
+
if (existingLockFiles.length === 0) {
|
|
37
|
+
throw new Error((0, _i18n.t)('lockNotFound'));
|
|
38
|
+
}
|
|
39
|
+
throw new Error((0, _i18n.t)('multipleLocksFound', {
|
|
40
|
+
lockFiles: existingLockFiles.join(', ')
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
@@ -19,10 +19,10 @@ async function checkPlugins() {
|
|
|
19
19
|
const isEnabled = await plugin.detect();
|
|
20
20
|
if (isEnabled && plugin.bundleParams) {
|
|
21
21
|
Object.assign(params, plugin.bundleParams);
|
|
22
|
-
console.log(
|
|
22
|
+
console.log(`detected ${plugin.name} plugin`);
|
|
23
23
|
}
|
|
24
24
|
} catch (err) {
|
|
25
|
-
console.warn(
|
|
25
|
+
console.warn(`error while detecting ${plugin.name} plugin:`, err);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
return params;
|
package/lib/utils/constants.js
CHANGED
|
@@ -15,6 +15,9 @@ _export(exports, {
|
|
|
15
15
|
credentialFile: function() {
|
|
16
16
|
return credentialFile;
|
|
17
17
|
},
|
|
18
|
+
defaultEndpoint: function() {
|
|
19
|
+
return defaultEndpoint;
|
|
20
|
+
},
|
|
18
21
|
pricingPageUrl: function() {
|
|
19
22
|
return pricingPageUrl;
|
|
20
23
|
},
|
|
@@ -37,3 +40,4 @@ const credentialFile = IS_CRESC ? '.cresc.token' : '.update';
|
|
|
37
40
|
const updateJson = IS_CRESC ? 'cresc.config.json' : 'update.json';
|
|
38
41
|
const tempDir = IS_CRESC ? '.cresc.temp' : '.pushy';
|
|
39
42
|
const pricingPageUrl = IS_CRESC ? 'https://cresc.dev/pricing' : 'https://pushy.reactnative.cn/pricing.html';
|
|
43
|
+
const defaultEndpoint = IS_CRESC ? 'https://api.cresc.dev' : 'https://update.reactnative.cn/api';
|
package/lib/utils/i18n.js
CHANGED
|
@@ -20,9 +20,14 @@ function _interop_require_default(obj) {
|
|
|
20
20
|
_i18next.default.init({
|
|
21
21
|
lng: _constants.IS_CRESC ? 'en' : 'zh',
|
|
22
22
|
// debug: process.env.NODE_ENV !== 'production',
|
|
23
|
+
// debug: true,
|
|
23
24
|
resources: {
|
|
24
|
-
en:
|
|
25
|
-
|
|
25
|
+
en: {
|
|
26
|
+
translation: _en.default
|
|
27
|
+
},
|
|
28
|
+
zh: {
|
|
29
|
+
translation: _zh.default
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
32
|
});
|
|
28
33
|
const t = _i18next.default.t;
|