mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-11-24 01:03:37 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf679715a5 | ||
|
|
ebd6d36b30 | ||
|
|
818907f811 | ||
|
|
6751daf8e0 | ||
|
|
b973ace443 |
21
package.json
21
package.json
@@ -1,17 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"name": "react-native-update-cli",
|
||||||
"version": "2.3.0",
|
"version": "2.4.2",
|
||||||
"description": "command line tool for react-native-update (remote updates for react native)",
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"pushy": "lib/index.js",
|
"pushy": "lib/index.js",
|
||||||
"cresc": "lib/index.js"
|
"cresc": "lib/index.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": ["lib", "src", "cli.json"],
|
||||||
"lib",
|
|
||||||
"src",
|
|
||||||
"cli.json"
|
|
||||||
],
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "swc src -d lib --strip-leading-paths",
|
"build": "swc src -d lib --strip-leading-paths",
|
||||||
"prepublishOnly": "npm run build && chmod +x lib/index.js",
|
"prepublishOnly": "npm run build && chmod +x lib/index.js",
|
||||||
@@ -21,13 +17,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/reactnativecn/react-native-update-cli.git"
|
"url": "git+https://github.com/reactnativecn/react-native-update-cli.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": ["react-native", "ios", "android", "harmony", "update"],
|
||||||
"react-native",
|
|
||||||
"ios",
|
|
||||||
"android",
|
|
||||||
"harmony",
|
|
||||||
"update"
|
|
||||||
],
|
|
||||||
"author": "reactnativecn",
|
"author": "reactnativecn",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@@ -81,8 +71,5 @@
|
|||||||
"@types/yazl": "^2.4.6",
|
"@types/yazl": "^2.4.6",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
},
|
},
|
||||||
"trustedDependencies": [
|
"trustedDependencies": ["@biomejs/biome", "@swc/core"]
|
||||||
"@biomejs/biome",
|
|
||||||
"@swc/core"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,14 +85,30 @@ async function runReactNativeBundleCommand({
|
|||||||
|
|
||||||
const getExpoCli = () => {
|
const getExpoCli = () => {
|
||||||
try {
|
try {
|
||||||
cliPath = require.resolve('@expo/cli', {
|
const searchPaths = [process.cwd()];
|
||||||
|
|
||||||
|
// 尝试添加 expo 包的路径作为额外的搜索路径
|
||||||
|
try {
|
||||||
|
const expoPath = require.resolve('expo/package.json', {
|
||||||
paths: [process.cwd()],
|
paths: [process.cwd()],
|
||||||
});
|
});
|
||||||
|
// 获取 expo 包的目录路径
|
||||||
|
const expoDir = expoPath.replace(/\/package\.json$/, '');
|
||||||
|
searchPaths.push(expoDir);
|
||||||
|
} catch {
|
||||||
|
// expo 包不存在,忽略
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试从搜索路径中解析 @expo/cli
|
||||||
|
cliPath = require.resolve('@expo/cli', {
|
||||||
|
paths: searchPaths,
|
||||||
|
});
|
||||||
|
|
||||||
const expoCliVersion = JSON.parse(
|
const expoCliVersion = JSON.parse(
|
||||||
fs
|
fs
|
||||||
.readFileSync(
|
.readFileSync(
|
||||||
require.resolve('@expo/cli/package.json', {
|
require.resolve('@expo/cli/package.json', {
|
||||||
paths: [process.cwd()],
|
paths: searchPaths,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.toString(),
|
.toString(),
|
||||||
@@ -256,6 +272,19 @@ async function runReactNativeBundleCommand({
|
|||||||
!isSentry,
|
!isSentry,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (platform === 'harmony') {
|
||||||
|
const harmonyRawAssetsPath =
|
||||||
|
'harmony/entry/src/main/resources/rawfile/assets';
|
||||||
|
// copy all files in outputFolder to harmonyRawPath
|
||||||
|
// assets should be in rawfile/assets
|
||||||
|
fs.ensureDirSync(harmonyRawAssetsPath);
|
||||||
|
fs.copySync(outputFolder, harmonyRawAssetsPath, { overwrite: true });
|
||||||
|
fs.moveSync(
|
||||||
|
`${harmonyRawAssetsPath}/bundle.harmony.js`,
|
||||||
|
`${harmonyRawAssetsPath}/../bundle.harmony.js`,
|
||||||
|
{ overwrite: true },
|
||||||
|
);
|
||||||
|
}
|
||||||
resolve(null);
|
resolve(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -549,7 +578,6 @@ async function diffFromPPK(origin: string, next: string, output: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const copies = {};
|
const copies = {};
|
||||||
const copiesv2 = {};
|
|
||||||
|
|
||||||
const zipfile = new YazlZipFile();
|
const zipfile = new YazlZipFile();
|
||||||
|
|
||||||
@@ -611,7 +639,6 @@ async function diffFromPPK(origin: string, next: string, output: string) {
|
|||||||
addEntry(base);
|
addEntry(base);
|
||||||
}
|
}
|
||||||
copies[entry.fileName] = originMap[entry.crc32];
|
copies[entry.fileName] = originMap[entry.crc32];
|
||||||
copiesv2[entry.crc32] = entry.fileName;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,7 +671,7 @@ async function diffFromPPK(origin: string, next: string, output: string) {
|
|||||||
|
|
||||||
//console.log({copies, deletes});
|
//console.log({copies, deletes});
|
||||||
zipfile.addBuffer(
|
zipfile.addBuffer(
|
||||||
Buffer.from(JSON.stringify({ copies, copiesv2, deletes })),
|
Buffer.from(JSON.stringify({ copies, deletes })),
|
||||||
'__diff.json',
|
'__diff.json',
|
||||||
);
|
);
|
||||||
zipfile.end();
|
zipfile.end();
|
||||||
@@ -689,7 +716,6 @@ async function diffFromPackage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const copies = {};
|
const copies = {};
|
||||||
const copiesv2 = {};
|
|
||||||
|
|
||||||
const zipfile = new YazlZipFile();
|
const zipfile = new YazlZipFile();
|
||||||
|
|
||||||
@@ -725,7 +751,6 @@ async function diffFromPackage(
|
|||||||
// If moved from other place
|
// If moved from other place
|
||||||
if (originMap[entry.crc32]) {
|
if (originMap[entry.crc32]) {
|
||||||
copies[entry.fileName] = originMap[entry.crc32];
|
copies[entry.fileName] = originMap[entry.crc32];
|
||||||
copiesv2[entry.crc32] = entry.fileName;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,10 +769,7 @@ async function diffFromPackage(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
zipfile.addBuffer(
|
zipfile.addBuffer(Buffer.from(JSON.stringify({ copies })), '__diff.json');
|
||||||
Buffer.from(JSON.stringify({ copies, copiesv2 })),
|
|
||||||
'__diff.json',
|
|
||||||
);
|
|
||||||
zipfile.end();
|
zipfile.end();
|
||||||
await writePromise;
|
await writePromise;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { defaultEndpoints } from './constants';
|
import { defaultEndpoints } from './constants';
|
||||||
|
import fetch from 'node-fetch';
|
||||||
|
|
||||||
// const baseUrl = `http://localhost:9000`;
|
// const baseUrl = `http://localhost:9000`;
|
||||||
// let baseUrl = SERVER.main[0];
|
// let baseUrl = SERVER.main[0];
|
||||||
|
|||||||
@@ -122,17 +122,6 @@ export const bindVersionToPackages = async ({
|
|||||||
console.log(chalk.yellow(t('dryRun')));
|
console.log(chalk.yellow(t('dryRun')));
|
||||||
}
|
}
|
||||||
if (rollout !== undefined) {
|
if (rollout !== undefined) {
|
||||||
const rolloutConfig: Record<string, number> = {};
|
|
||||||
for (const pkg of pkgs) {
|
|
||||||
rolloutConfig[pkg.name] = rollout;
|
|
||||||
}
|
|
||||||
if (!dryRun) {
|
|
||||||
await put(`/app/${appId}/version/${versionId}`, {
|
|
||||||
config: {
|
|
||||||
rollout: rolloutConfig,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
console.log(
|
console.log(
|
||||||
`${t('rolloutConfigSet', {
|
`${t('rolloutConfigSet', {
|
||||||
versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
|
versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
|
||||||
@@ -142,8 +131,10 @@ export const bindVersionToPackages = async ({
|
|||||||
}
|
}
|
||||||
for (const pkg of pkgs) {
|
for (const pkg of pkgs) {
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
await put(`/app/${appId}/package/${pkg.id}`, {
|
await post(`/app/${appId}/binding`, {
|
||||||
versionId,
|
versionId,
|
||||||
|
rollout,
|
||||||
|
packageId: pkg.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(
|
console.log(
|
||||||
|
|||||||
Reference in New Issue
Block a user