This commit is contained in:
Tw93
2022-12-10 22:46:53 +08:00
10 changed files with 39 additions and 22 deletions

1
.gitignore vendored
View File

@@ -26,6 +26,7 @@ dist-ssr
output
*.msi
*.deb
*.AppImage
*.dmg
package-lock.json

View File

@@ -146,7 +146,7 @@ npm i
npm run dev
// 打包应用
npm run build:release
npm run build
```

View File

@@ -146,7 +146,7 @@ npm i
npm run dev
// Pack application
npm run build:release
npm run build
```

View File

@@ -61,7 +61,7 @@ Terminal=false
Type=Application
`
await fs.writeFile(assertPath, desktopStr);
const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build`);
let arch = "";
if (process.arch === "x64") {
arch = "amd64";
@@ -69,19 +69,28 @@ Type=Application
arch = process.arch;
}
const debName = `${name}_${tauriConf.package.version}_${arch}.deb`;
const appPath = this.getBuildedAppPath(npmDirectory, debName);
const appPath = this.getBuildedAppPath(npmDirectory, "deb", debName);
const distPath = path.resolve(`${name}.deb`);
await fs.copyFile(appPath, distPath);
await fs.unlink(appPath);
const appImageName = `${name}_${tauriConf.package.version}_${arch}.AppImage`;
const appImagePath = this.getBuildedAppPath(npmDirectory, "appimage", appImageName);
const distAppPath = path.resolve(`${name}.AppImage`);
await fs.copyFile(appImagePath, distAppPath);
await fs.unlink(appImagePath);
logger.success('Build success!');
logger.success('You can find the app installer in', distPath);
logger.success('You can find the deb app installer in', distPath);
logger.success('You can find the Appimage app installer in', distAppPath);
}
getBuildedAppPath(npmDirectory: string, dmgName: string) {
getBuildedAppPath(npmDirectory: string,packageType: string, packageName: string) {
return path.join(
npmDirectory,
'src-tauri/target/release/bundle/deb',
dmgName
'src-tauri/target/release/bundle/',
packageType,
packageName
);
}
}

View File

@@ -40,7 +40,7 @@ export default class MacBuilder implements IBuilder {
await mergeTauriConfig(url, options, tauriConf);
const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build`);
let arch = "x64";
if (process.arch === "arm64") {
arch = "aarch64";

View File

@@ -47,7 +47,7 @@ export default class WinBuilder implements IBuilder {
await mergeTauriConfig(url, options, tauriConf);
const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build`);
const language = tauriConf.tauri.bundle.windows.wix.language[0];
const arch = process.arch;
const msiName = `${name}_${tauriConf.package.version}_${arch}_${language}.msi`;

25
dist/cli.js vendored
View File

@@ -1943,7 +1943,8 @@ var tauri = {
],
shortDescription: "",
targets: [
"deb"
"deb",
"appimage"
]
}
};
@@ -1996,7 +1997,7 @@ class MacBuilder {
log.debug('PakeAppOptions', options);
const { name } = options;
yield mergeTauriConfig(url, options, tauriConf);
yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
let arch = "x64";
if (process.arch === "arm64") {
arch = "aarch64";
@@ -2046,7 +2047,7 @@ class WinBuilder {
logger.debug('PakeAppOptions', options);
const { name } = options;
yield mergeTauriConfig(url, options, tauriConf);
yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
const language = tauriConf.tauri.bundle.windows.wix.language[0];
const arch = process.arch;
const msiName = `${name}_${tauriConf.package.version}_${arch}_${language}.msi`;
@@ -2106,7 +2107,7 @@ Terminal=false
Type=Application
`;
yield fs.writeFile(assertPath, desktopStr);
yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
let arch = "";
if (process.arch === "x64") {
arch = "amd64";
@@ -2115,16 +2116,22 @@ Type=Application
arch = process.arch;
}
const debName = `${name}_${tauriConf.package.version}_${arch}.deb`;
const appPath = this.getBuildedAppPath(npmDirectory, debName);
const appPath = this.getBuildedAppPath(npmDirectory, "deb", debName);
const distPath = path.resolve(`${name}.deb`);
yield fs.copyFile(appPath, distPath);
yield fs.unlink(appPath);
const appImageName = `${name}_${tauriConf.package.version}_${arch}.AppImage`;
const appImagePath = this.getBuildedAppPath(npmDirectory, "appimage", appImageName);
const distAppPath = path.resolve(`${name}.AppImage`);
yield fs.copyFile(appImagePath, distAppPath);
yield fs.unlink(appImagePath);
logger.success('Build success!');
logger.success('You can find the app installer in', distPath);
logger.success('You can find the deb app installer in', distPath);
logger.success('You can find the Appimage app installer in', distAppPath);
});
}
getBuildedAppPath(npmDirectory, dmgName) {
return path.join(npmDirectory, 'src-tauri/target/release/bundle/deb', dmgName);
getBuildedAppPath(npmDirectory, packageType, packageName) {
return path.join(npmDirectory, 'src-tauri/target/release/bundle/', packageType, packageName);
}
}
@@ -2168,7 +2175,7 @@ var scripts = {
start: "npm run dev",
dev: "npm run tauri dev",
"dev:debug": "npm run tauri dev -- --features devtools",
"build:release": "npm run tauri build --release",
build: "npm run tauri build --release",
"build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
"build:all-windows": ".\\script\\build.bat",
tauri: "tauri",

View File

@@ -24,7 +24,6 @@
"dev": "npm run tauri dev",
"dev:debug": "npm run tauri dev -- --features devtools",
"build": "npm run tauri build --release",
"build:release": "npm run tauri build --release",
"build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
"build:all-windows": ".\\script\\build.bat",
"tauri": "tauri",

3
script/build.sh vendored
View File

@@ -102,7 +102,8 @@ do
if [[ "$OSTYPE" =~ ^linux ]]; then
npm run tauri build
mv src-tauri/target/release/bundle/deb/*.deb output/linux/${package_title}_amd64.deb
mv src-tauri/target/release/bundle/deb/${package_prefix}-${package_name}*.deb output/linux/${package_title}_amd64.deb
mv src-tauri/target/release/bundle/appimage/${package_prefix}-${package_name}*.AppImage output/linux/${package_title}_amd64.AppImage
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then

View File

@@ -28,7 +28,7 @@
"longDescription": "",
"resources": [],
"shortDescription": "",
"targets": ["deb"]
"targets": ["deb", "appimage"]
}
}
}