react-native-update-cli 1.42.2 → 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/bundle.js +10 -1
- package/lib/locales/en.js +3 -2
- package/lib/locales/zh.js +3 -2
- package/lib/utils/add-gitignore.js +43 -0
- package/lib/utils/check-lockfile.js +42 -0
- package/package.json +1 -1
- package/src/bundle.ts +9 -1
- package/src/locales/en.ts +2 -1
- package/src/locales/zh.ts +2 -1
- package/src/utils/add-gitignore.ts +34 -0
- package/src/utils/check-lockfile.ts +29 -0
- 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/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,7 +12,7 @@ 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.
|
|
@@ -38,5 +38,6 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
38
38
|
createAppSuccess: 'App created successfully (id: {{id}})',
|
|
39
39
|
cancelled: 'Cancelled',
|
|
40
40
|
operationSuccess: 'Operation successful',
|
|
41
|
-
failedToParseUpdateJson: 'Failed to parse file `update.json`. Try to remove it manually.'
|
|
41
|
+
failedToParseUpdateJson: 'Failed to parse file `update.json`. Try to remove it manually.',
|
|
42
|
+
ppkPackageGenerated: 'ppk package generated and saved to: {{output}}'
|
|
42
43
|
};
|
package/lib/locales/zh.js
CHANGED
|
@@ -19,7 +19,7 @@ const _default = {
|
|
|
19
19
|
3. 代码审核时应关注 lock 文件的变化。
|
|
20
20
|
这样可以最大限度避免因依赖关系不一致而导致的热更异常,也降低供应链攻击等安全隐患。
|
|
21
21
|
`,
|
|
22
|
-
multipleLocksFound: '检测到多种不同格式的锁文件({lockFiles}),这可能导致依赖关系不一致而使热更异常。',
|
|
22
|
+
multipleLocksFound: '检测到多种不同格式的锁文件({{lockFiles}}),这可能导致依赖关系不一致而使热更异常。',
|
|
23
23
|
loginExpired: '登录信息已过期,请使用 `pushy login` 命令重新登录',
|
|
24
24
|
fileSizeExceeded: '此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{pricingPageUrl}}',
|
|
25
25
|
bundleNotFound: '找不到 bundle 文件。请确保此 {{packageType}} 为 release 版本,且 bundle 文件名为默认的 `{{entryFile}}`',
|
|
@@ -38,5 +38,6 @@ const _default = {
|
|
|
38
38
|
createAppSuccess: '已成功创建应用(id: {{id}})',
|
|
39
39
|
cancelled: '已取消',
|
|
40
40
|
operationSuccess: '操作成功',
|
|
41
|
-
failedToParseUpdateJson: '无法解析文件 `update.json`。请手动删除它。'
|
|
41
|
+
failedToParseUpdateJson: '无法解析文件 `update.json`。请手动删除它。',
|
|
42
|
+
ppkPackageGenerated: 'ppk 热更包已生成并保存到: {{output}}'
|
|
42
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
|
+
}
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
package/src/bundle.ts
CHANGED
|
@@ -11,6 +11,10 @@ const g2js = require('gradle-to-js/lib/parser');
|
|
|
11
11
|
import os from 'node:os';
|
|
12
12
|
const properties = require('properties');
|
|
13
13
|
import { depVersions } from './utils/dep-versions';
|
|
14
|
+
import { t } from './utils/i18n';
|
|
15
|
+
import { tempDir } from './utils/constants';
|
|
16
|
+
import { checkLockFiles } from './utils/check-lockfile';
|
|
17
|
+
import { addGitIgnore } from './utils/add-gitignore';
|
|
14
18
|
|
|
15
19
|
let bsdiff;
|
|
16
20
|
let hdiff;
|
|
@@ -512,7 +516,7 @@ async function pack(dir: string, output: string) {
|
|
|
512
516
|
});
|
|
513
517
|
zipfile.end();
|
|
514
518
|
});
|
|
515
|
-
console.log(
|
|
519
|
+
console.log(t('ppkPackageGenerated', { output }));
|
|
516
520
|
}
|
|
517
521
|
|
|
518
522
|
export function readEntire(entry: string, zipFile: ZipFile) {
|
|
@@ -907,9 +911,13 @@ export const commands = {
|
|
|
907
911
|
disableHermes,
|
|
908
912
|
} = translateOptions({
|
|
909
913
|
...options,
|
|
914
|
+
tempDir,
|
|
910
915
|
platform,
|
|
911
916
|
});
|
|
912
917
|
|
|
918
|
+
checkLockFiles();
|
|
919
|
+
addGitIgnore();
|
|
920
|
+
|
|
913
921
|
const bundleParams = await checkPlugins();
|
|
914
922
|
const sourcemapPlugin = bundleParams.sourcemap;
|
|
915
923
|
const isSentry = bundleParams.sentry;
|
package/src/locales/en.ts
CHANGED
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
lockNotFound:
|
|
7
7
|
'No lock file detected, which may cause inconsistent dependencies and hot-updating issues.',
|
|
8
8
|
multipleLocksFound:
|
|
9
|
-
'Multiple lock files detected ({lockFiles}), which may cause inconsistent dependencies and hot-updating issues.',
|
|
9
|
+
'Multiple lock files detected ({{lockFiles}}), which may cause inconsistent dependencies and hot-updating issues.',
|
|
10
10
|
lockBestPractice: `
|
|
11
11
|
Best practices for lock files:
|
|
12
12
|
1. All members of the development team should use the same package manager to maintain a single lock file.
|
|
@@ -39,4 +39,5 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
39
39
|
cancelled: 'Cancelled',
|
|
40
40
|
operationSuccess: 'Operation successful',
|
|
41
41
|
failedToParseUpdateJson: 'Failed to parse file `update.json`. Try to remove it manually.',
|
|
42
|
+
ppkPackageGenerated: 'ppk package generated and saved to: {{output}}',
|
|
42
43
|
};
|
package/src/locales/zh.ts
CHANGED
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
这样可以最大限度避免因依赖关系不一致而导致的热更异常,也降低供应链攻击等安全隐患。
|
|
13
13
|
`,
|
|
14
14
|
multipleLocksFound:
|
|
15
|
-
'检测到多种不同格式的锁文件({lockFiles}),这可能导致依赖关系不一致而使热更异常。',
|
|
15
|
+
'检测到多种不同格式的锁文件({{lockFiles}}),这可能导致依赖关系不一致而使热更异常。',
|
|
16
16
|
loginExpired: '登录信息已过期,请使用 `pushy login` 命令重新登录',
|
|
17
17
|
fileSizeExceeded:
|
|
18
18
|
'此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{pricingPageUrl}}',
|
|
@@ -37,4 +37,5 @@ export default {
|
|
|
37
37
|
cancelled: '已取消',
|
|
38
38
|
operationSuccess: '操作成功',
|
|
39
39
|
failedToParseUpdateJson: '无法解析文件 `update.json`。请手动删除它。',
|
|
40
|
+
ppkPackageGenerated: 'ppk 热更包已生成并保存到: {{output}}',
|
|
40
41
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
// import path from 'node:path';
|
|
3
|
+
import { credentialFile, tempDir } from './constants';
|
|
4
|
+
|
|
5
|
+
export function addGitIgnore() {
|
|
6
|
+
const shouldIgnore = [credentialFile, tempDir];
|
|
7
|
+
|
|
8
|
+
const gitignorePath = '.gitignore';
|
|
9
|
+
|
|
10
|
+
if (!fs.existsSync(gitignorePath)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const gitignoreContent = fs.readFileSync(gitignorePath, 'utf-8');
|
|
15
|
+
|
|
16
|
+
const gitignoreLines = gitignoreContent.split('\n');
|
|
17
|
+
|
|
18
|
+
for (const line of gitignoreLines) {
|
|
19
|
+
const index = shouldIgnore.indexOf(line.trim());
|
|
20
|
+
if (index !== -1) {
|
|
21
|
+
shouldIgnore.splice(index, 1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (shouldIgnore.length > 0) {
|
|
26
|
+
gitignoreLines.push('# react-native-update');
|
|
27
|
+
for (const line of shouldIgnore) {
|
|
28
|
+
gitignoreLines.push(line);
|
|
29
|
+
console.log(`Added ${line} to .gitignore`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fs.writeFileSync(gitignorePath, gitignoreLines.join('\n'));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { t } from './i18n';
|
|
3
|
+
|
|
4
|
+
const lockFiles = [
|
|
5
|
+
'package-lock.json',
|
|
6
|
+
'yarn.lock',
|
|
7
|
+
'pnpm-lock.yaml',
|
|
8
|
+
'bun.lockb',
|
|
9
|
+
'bun.lock',
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const existingLockFiles: string[] = [];
|
|
13
|
+
export function checkLockFiles() {
|
|
14
|
+
for (const file of lockFiles) {
|
|
15
|
+
if (fs.existsSync(file)) {
|
|
16
|
+
existingLockFiles.push(file);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (existingLockFiles.length === 1) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
console.warn(t('lockBestPractice'));
|
|
23
|
+
if (existingLockFiles.length === 0) {
|
|
24
|
+
throw new Error(t('lockNotFound'));
|
|
25
|
+
}
|
|
26
|
+
throw new Error(
|
|
27
|
+
t('multipleLocksFound', { lockFiles: existingLockFiles.join(', ') }),
|
|
28
|
+
);
|
|
29
|
+
}
|