mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-05 05:50:04 +08:00
fix(build): bundle service tools from the resolved IPC source
This commit is contained in:
+20
-17
@@ -9,7 +9,7 @@ import AdmZip from 'adm-zip'
|
||||
import { HttpsProxyAgent } from 'https-proxy-agent'
|
||||
import { extract } from 'tar'
|
||||
|
||||
import { resolveServiceRelease } from './service-release.mjs'
|
||||
import { resolveServiceBundle as serviceBundleFromMetadata } from './service-release.mjs'
|
||||
import { log_debug, log_error, log_info, log_success } from './utils.mjs'
|
||||
|
||||
/** Prepares platform resources, caching versions and unchanged files unless `--force` is used. */
|
||||
@@ -581,23 +581,30 @@ async function resolveServiceBundle() {
|
||||
}
|
||||
})
|
||||
|
||||
const cargoManifest = await fsp.readFile(
|
||||
path.join(cwd, 'src-tauri', 'Cargo.toml'),
|
||||
'utf8',
|
||||
const metadata = JSON.parse(
|
||||
execFileSync(
|
||||
'cargo',
|
||||
[
|
||||
'metadata',
|
||||
'--locked',
|
||||
'--format-version',
|
||||
'1',
|
||||
'--filter-platform',
|
||||
SIDECAR_HOST,
|
||||
],
|
||||
{ cwd, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 },
|
||||
),
|
||||
)
|
||||
const serviceDependency = cargoManifest
|
||||
.split(/\r?\n/)
|
||||
.find((line) => line.trimStart().startsWith('clash_verge_service_ipc ='))
|
||||
const sourcePath = serviceDependency?.match(/\bpath\s*=\s*"([^"]+)"/)?.[1]
|
||||
if (sourcePath) {
|
||||
const manifest = path.resolve(cwd, 'src-tauri', sourcePath, 'Cargo.toml')
|
||||
const bundle = serviceBundleFromMetadata(metadata, SIDECAR_HOST, platform)
|
||||
if (bundle.manifest) {
|
||||
const targetDirectory = path.join(cwd, 'target', 'bundled-service')
|
||||
execFileSync(
|
||||
'cargo',
|
||||
[
|
||||
'build',
|
||||
'--locked',
|
||||
'--manifest-path',
|
||||
manifest,
|
||||
bundle.manifest,
|
||||
'--target-dir',
|
||||
targetDirectory,
|
||||
'--target',
|
||||
@@ -605,7 +612,7 @@ async function resolveServiceBundle() {
|
||||
'--release',
|
||||
'--features',
|
||||
'standalone,client',
|
||||
'--bins',
|
||||
...SERVICE_BINARIES.flatMap((name) => ['--bin', name]),
|
||||
],
|
||||
{ stdio: 'inherit' },
|
||||
)
|
||||
@@ -620,11 +627,7 @@ async function resolveServiceBundle() {
|
||||
}
|
||||
return
|
||||
}
|
||||
const { archiveFile, downloadURL } = resolveServiceRelease(
|
||||
cargoManifest,
|
||||
SIDECAR_HOST,
|
||||
platform,
|
||||
)
|
||||
const { archiveFile, downloadURL } = bundle
|
||||
const tempDir = path.join(TEMP_DIR, 'clash-verge-service-ipc')
|
||||
const tempArchive = path.join(tempDir, archiveFile)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user