Add the targets parameter of the master branch to the pake-cli

This commit is contained in:
Tlntin
2023-04-08 11:22:13 +08:00
parent da615bb1c7
commit 994b1d4157

View File

@@ -47,43 +47,33 @@ export default class LinuxBuilder implements IBuilder {
await mergeTauriConfig(url, options, tauriConf); await mergeTauriConfig(url, options, tauriConf);
const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build`); const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build`);
let arch = ""; let arch: string;
if (process.arch === "x64") { if (process.arch === "x64") {
arch = "amd64"; arch = "amd64";
} else { } else {
arch = process.arch; arch = process.arch;
} }
const debName = `${name}_${tauriConf.package.version}_${arch}.deb`; if (options.targets === "deb" || options.targets === "all") {
const debPath = this.getBuildedAppPath(npmDirectory, "deb", debName); const debName = `${name}_${tauriConf.package.version}_${arch}.deb`;
const distPath = path.resolve(`${name}.deb`); const appPath = this.getBuildAppPath(npmDirectory, "deb", debName);
// 增加文件是否存在验证再决定是否copy文件 const distPath = path.resolve(`${name}.deb`);
const debExists = await fs.stat(debPath) await fs.copyFile(appPath, distPath);
.then(() => true) await fs.unlink(appPath);
.catch(() => false); logger.success('Build Deb success!');
if (debExists) {
await fs.copyFile(debPath, distPath);
await fs.unlink(debPath);
logger.success('Build success!');
logger.success('You can find the deb app installer in', distPath); logger.success('You can find the deb app installer in', distPath);
} }
if (options.targets === "appimage" || options.targets === "all") {
const appImageName = `${name}_${tauriConf.package.version}_${arch}.AppImage`;
const appImageName = `${name}_${tauriConf.package.version}_${arch}.AppImage`; const appImagePath = this.getBuildAppPath(npmDirectory, "appimage", appImageName);
const appImagePath = this.getBuildedAppPath(npmDirectory, "appimage", appImageName); const distAppPath = path.resolve(`${name}.AppImage`);
const distAppPath = path.resolve(`${name}.AppImage`);
const appExists = await fs.stat(appImagePath)
.then(() => true)
.catch(() => false);
if (appExists) {
await fs.copyFile(appImagePath, distAppPath); await fs.copyFile(appImagePath, distAppPath);
await fs.unlink(appImagePath); await fs.unlink(appImagePath);
logger.success('Build success!'); logger.success('Build AppImage success!');
logger.success('You can find the Appimage app installer in', distAppPath); logger.success('You can find the AppImage app installer in', distAppPath);
} }
} }
getBuildedAppPath(npmDirectory: string,packageType: string, packageName: string) { getBuildAppPath(npmDirectory: string, packageType: string, packageName: string) {
return path.join( return path.join(
npmDirectory, npmDirectory,
'src-tauri/target/release/bundle/', 'src-tauri/target/release/bundle/',