mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-17 10:02:19 +08:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4326c08d79 | ||
![]() |
20010a9ea6 | ||
![]() |
36220a48aa | ||
![]() |
d281d72737 | ||
![]() |
d351243ab7 | ||
![]() |
fbdacfffd2 | ||
![]() |
b725d2b08e |
4
bun.lock
4
bun.lock
@@ -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=="],
|
||||
|
||||
|
22
cli.json
22
cli.json
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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",
|
||||
|
@@ -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;
|
||||
|
@@ -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}}',
|
||||
};
|
||||
|
@@ -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}}',
|
||||
};
|
||||
|
34
src/utils/add-gitignore.ts
Normal file
34
src/utils/add-gitignore.ts
Normal 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'));
|
||||
}
|
||||
}
|
29
src/utils/check-lockfile.ts
Normal file
29
src/utils/check-lockfile.ts
Normal 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(', ') }),
|
||||
);
|
||||
}
|
@@ -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);
|
||||
|
@@ -1,7 +0,0 @@
|
||||
const lockFiles = [
|
||||
'package-lock.json',
|
||||
'yarn.lock',
|
||||
'pnpm-lock.yaml',
|
||||
'bun.lockb',
|
||||
'bun.lock',
|
||||
];
|
Reference in New Issue
Block a user