1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-09-17 10:02:19 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Compare commits

..

7 Commits

Author SHA1 Message Date
sunnylqm
4326c08d79 downgrade commander 2025-04-09 10:52:38 +08:00
sunnylqm
20010a9ea6 Update version to 1.43.1 and handle optional chaining for origin URL in getCommitInfo function 2025-04-07 19:56:17 +08:00
sunnylqm
36220a48aa Update package description for clarity and specificity 2025-04-02 08:39:26 +08:00
sunnylqm
d281d72737 check lockfiles 2025-04-02 08:27:05 +08:00
sunnylqm
d351243ab7 check lockfile 2025-04-01 23:24:02 +08:00
sunnylqm
fbdacfffd2 add gitignore check 2025-04-01 23:13:20 +08:00
sunnylqm
b725d2b08e i18n 2025-03-30 23:40:28 +08:00
10 changed files with 94 additions and 28 deletions

View File

@@ -9,7 +9,7 @@
"cgbi-to-png": "^1.0.7",
"chalk": "4",
"cli-arguments": "^0.2.1",
"commander": "^13.1.0",
"commander": "^10",
"compare-versions": "^6.1.1",
"filesize-parser": "^1.5.1",
"form-data": "^4.0.2",
@@ -293,7 +293,7 @@
"combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
"commander": ["commander@13.1.0", "", {}, "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw=="],
"commander": ["commander@10.0.1", "", {}, "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug=="],
"compare-versions": ["compare-versions@6.1.1", "", {}, "sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg=="],

View File

@@ -136,11 +136,11 @@
"hasValue": true
},
"intermediaDir": {
"default": ".pushy/intermedia/${platform}",
"default": "${tempDir}/intermedia/${platform}",
"hasValue": true
},
"output": {
"default": ".pushy/output/${platform}.${time}.ppk",
"default": "${tempDir}/output/${platform}.${time}.ppk",
"hasValue": true
},
"sourcemap": {
@@ -167,7 +167,7 @@
"description": "Create diff patch",
"options": {
"output": {
"default": ".pushy/output/diff",
"default": "${tempDir}/output/diff",
"hasValue": true
}
}
@@ -176,7 +176,7 @@
"description": "Create diff patch from a Android package(.apk)",
"options": {
"output": {
"default": ".pushy/output/diff-${time}.apk-patch",
"default": "${tempDir}/output/diff-${time}.apk-patch",
"hasValue": true
}
}
@@ -185,7 +185,7 @@
"description": "Create diff patch from a iOS package(.ipa)",
"options": {
"output": {
"default": ".pushy/output/diff-${time}.ipa-patch",
"default": "${tempDir}/output/diff-${time}.ipa-patch",
"hasValue": true
}
}
@@ -194,7 +194,7 @@
"description": "Create hdiff patch",
"options": {
"output": {
"default": ".pushy/output/hdiff",
"default": "${tempDir}/output/hdiff",
"hasValue": true
}
}
@@ -203,7 +203,7 @@
"description": "Create hdiff patch from a Android package(.apk)",
"options": {
"output": {
"default": ".pushy/output/hdiff-${time}.apk-patch",
"default": "${tempDir}/output/hdiff-${time}.apk-patch",
"hasValue": true
}
}
@@ -212,7 +212,7 @@
"description": "Create hdiff patch from a Prepare package(.ppk)",
"options": {
"output": {
"default": ".pushy/output/hdiff-${time}.ppk-patch",
"default": "${tempDir}/output/hdiff-${time}.ppk-patch",
"hasValue": true
}
}
@@ -221,7 +221,7 @@
"description": "Create hdiff patch from a Harmony package(.app)",
"options": {
"output": {
"default": ".pushy/output/hdiff-${time}.app-patch",
"default": "${tempDir}/output/hdiff-${time}.app-patch",
"hasValue": true
}
}
@@ -230,7 +230,7 @@
"description": "Create hdiff patch from a iOS package(.ipa)",
"options": {
"output": {
"default": ".pushy/output/hdiff-${time}.ipa-patch",
"default": "${tempDir}/output/hdiff-${time}.ipa-patch",
"hasValue": true
}
}
@@ -241,4 +241,4 @@
"default": false
}
}
}
}

View File

@@ -1,7 +1,7 @@
{
"name": "react-native-update-cli",
"version": "1.42.2",
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
"version": "1.43.2",
"description": "command line tool for react-native-update (remote updates for react native)",
"main": "index.js",
"bin": {
"pushy": "lib/index.js",
@@ -41,7 +41,7 @@
"cgbi-to-png": "^1.0.7",
"chalk": "4",
"cli-arguments": "^0.2.1",
"commander": "^13.1.0",
"commander": "^10",
"compare-versions": "^6.1.1",
"filesize-parser": "^1.5.1",
"form-data": "^4.0.2",
@@ -63,7 +63,7 @@
"yazl": "3.3.1"
},
"engines": {
"node": ">= 10"
"node": ">= 14"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",

View File

@@ -11,6 +11,10 @@ const g2js = require('gradle-to-js/lib/parser');
import os from 'node:os';
const properties = require('properties');
import { depVersions } from './utils/dep-versions';
import { t } from './utils/i18n';
import { tempDir } from './utils/constants';
import { checkLockFiles } from './utils/check-lockfile';
import { addGitIgnore } from './utils/add-gitignore';
let bsdiff;
let hdiff;
@@ -512,7 +516,7 @@ async function pack(dir: string, output: string) {
});
zipfile.end();
});
console.log(`ppk热更包已生成并保存到: ${output}`);
console.log(t('ppkPackageGenerated', { output }));
}
export function readEntire(entry: string, zipFile: ZipFile) {
@@ -907,9 +911,13 @@ export const commands = {
disableHermes,
} = translateOptions({
...options,
tempDir,
platform,
});
checkLockFiles();
addGitIgnore();
const bundleParams = await checkPlugins();
const sourcemapPlugin = bundleParams.sourcemap;
const isSentry = bundleParams.sentry;

View File

@@ -6,7 +6,7 @@ export default {
lockNotFound:
'No lock file detected, which may cause inconsistent dependencies and hot-updating issues.',
multipleLocksFound:
'Multiple lock files detected ({lockFiles}), which may cause inconsistent dependencies and hot-updating issues.',
'Multiple lock files detected ({{lockFiles}}), which may cause inconsistent dependencies and hot-updating issues.',
lockBestPractice: `
Best practices for lock files:
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.
cancelled: 'Cancelled',
operationSuccess: 'Operation successful',
failedToParseUpdateJson: 'Failed to parse file `update.json`. Try to remove it manually.',
ppkPackageGenerated: 'ppk package generated and saved to: {{output}}',
};

View File

@@ -12,7 +12,7 @@ export default {
这样可以最大限度避免因依赖关系不一致而导致的热更异常,也降低供应链攻击等安全隐患。
`,
multipleLocksFound:
'检测到多种不同格式的锁文件({lockFiles}),这可能导致依赖关系不一致而使热更异常。',
'检测到多种不同格式的锁文件({{lockFiles}}),这可能导致依赖关系不一致而使热更异常。',
loginExpired: '登录信息已过期,请使用 `pushy login` 命令重新登录',
fileSizeExceeded:
'此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{pricingPageUrl}}',
@@ -37,4 +37,5 @@ export default {
cancelled: '已取消',
operationSuccess: '操作成功',
failedToParseUpdateJson: '无法解析文件 `update.json`。请手动删除它。',
ppkPackageGenerated: 'ppk 热更包已生成并保存到: {{output}}',
};

View File

@@ -0,0 +1,34 @@
import fs from 'node:fs';
// import path from 'node:path';
import { credentialFile, tempDir } from './constants';
export function addGitIgnore() {
const shouldIgnore = [credentialFile, tempDir];
const gitignorePath = '.gitignore';
if (!fs.existsSync(gitignorePath)) {
return;
}
const gitignoreContent = fs.readFileSync(gitignorePath, 'utf-8');
const gitignoreLines = gitignoreContent.split('\n');
for (const line of gitignoreLines) {
const index = shouldIgnore.indexOf(line.trim());
if (index !== -1) {
shouldIgnore.splice(index, 1);
}
}
if (shouldIgnore.length > 0) {
gitignoreLines.push('# react-native-update');
for (const line of shouldIgnore) {
gitignoreLines.push(line);
console.log(`Added ${line} to .gitignore`);
}
fs.writeFileSync(gitignorePath, gitignoreLines.join('\n'));
}
}

View File

@@ -0,0 +1,29 @@
import fs from 'node:fs';
import { t } from './i18n';
const lockFiles = [
'package-lock.json',
'yarn.lock',
'pnpm-lock.yaml',
'bun.lockb',
'bun.lock',
];
const existingLockFiles: string[] = [];
export function checkLockFiles() {
for (const file of lockFiles) {
if (fs.existsSync(file)) {
existingLockFiles.push(file);
}
}
if (existingLockFiles.length === 1) {
return;
}
console.warn(t('lockBestPractice'));
if (existingLockFiles.length === 0) {
throw new Error(t('lockNotFound'));
}
throw new Error(
t('multipleLocksFound', { lockFiles: existingLockFiles.join(', ') }),
);
}

View File

@@ -41,7 +41,7 @@ export async function getCommitInfo(): Promise<CommitInfo | undefined> {
message: commit.message,
author: commit.author.name || commit.committer.name,
timestamp: String(commit.committer.timestamp),
origin: origin.url,
origin: origin?.url,
};
} catch (error) {
console.error(error);

View File

@@ -1,7 +0,0 @@
const lockFiles = [
'package-lock.json',
'yarn.lock',
'pnpm-lock.yaml',
'bun.lockb',
'bun.lock',
];