Pake-cli adds the parameter to select the packaging format.
This commit is contained in:
8
bin/README.md
vendored
8
bin/README.md
vendored
@@ -132,6 +132,14 @@ url 为你需要打包的网页链接 🔗,必须提供。
|
||||
|
||||
打包结果同时支持英特尔和 m1 芯片,仅适用于 MacOS,默认为 `false`。
|
||||
|
||||
#### [targets]
|
||||
|
||||
选择输出的包格式,支持deb/appimage/all,如果选择all,则同时打包deb和appimage,该选项仅支持Linux,默认为`all`。
|
||||
|
||||
```shell
|
||||
--targets xxx
|
||||
```
|
||||
|
||||
##### 准备工作
|
||||
|
||||
- 注意:开启该选项后,需要用 rust 官网的 rustup 安装 rust,不支持 brew 安装。
|
||||
|
||||
8
bin/README_EN.md
vendored
8
bin/README_EN.md
vendored
@@ -134,6 +134,14 @@ Use the command below to disable this feature.
|
||||
|
||||
Package results support both Intel and m1 chips, only for MacOS. The default is `false`.
|
||||
|
||||
#### [targets]
|
||||
|
||||
Select the output package format, support deb/appimage/all, if all is selected, deb and appimage will be packaged at the same time, this option only supports Linux, the default is `all`.
|
||||
|
||||
```shell
|
||||
--targets xxx
|
||||
```
|
||||
|
||||
##### Preparation
|
||||
|
||||
- Note: After enabling this option, you need to use rustup on the rust official website to install rust, brew installation is not supported.
|
||||
|
||||
32
bin/builders/LinuxBuilder.ts
vendored
32
bin/builders/LinuxBuilder.ts
vendored
@@ -54,20 +54,24 @@ export default class LinuxBuilder implements IBuilder {
|
||||
} else {
|
||||
arch = process.arch;
|
||||
}
|
||||
const debName = `${name}_${tauriConf.package.version}_${arch}.deb`;
|
||||
const appPath = this.getBuildAppPath(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.getBuildAppPath(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 deb app installer in', distPath);
|
||||
logger.success('You can find the AppImage app installer in', distAppPath);
|
||||
if (options.targets === "deb" || options.targets === "all") {
|
||||
const debName = `${name}_${tauriConf.package.version}_${arch}.deb`;
|
||||
const appPath = this.getBuildAppPath(npmDirectory, "deb", debName);
|
||||
const distPath = path.resolve(`${name}.deb`);
|
||||
await fs.copyFile(appPath, distPath);
|
||||
await fs.unlink(appPath);
|
||||
logger.success('Build Deb success!');
|
||||
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 appImagePath = this.getBuildAppPath(npmDirectory, "appimage", appImageName);
|
||||
const distAppPath = path.resolve(`${name}.AppImage`);
|
||||
await fs.copyFile(appImagePath, distAppPath);
|
||||
await fs.unlink(appImagePath);
|
||||
logger.success('Build AppImage success!');
|
||||
logger.success('You can find the AppImage app installer in', distAppPath);
|
||||
}
|
||||
}
|
||||
|
||||
getBuildAppPath(npmDirectory: string, packageType: string, packageName: string) {
|
||||
|
||||
9
bin/builders/common.ts
vendored
9
bin/builders/common.ts
vendored
@@ -82,6 +82,11 @@ export async function mergeTauriConfig(
|
||||
updateIconPath = false;
|
||||
logger.warn(`icon file in Linux must be 512 * 512 pix with .png type, but you give ${customIconExt}`);
|
||||
}
|
||||
if (["all", "deb", "appimage"].includes(options.targets)) {
|
||||
tauriConf.tauri.bundle.targets = [options.targets];
|
||||
} else {
|
||||
logger.warn("targets must be 'all', 'deb', 'appimage', we will use default 'all'");
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === "darwin" && customIconExt !== ".icns") {
|
||||
@@ -117,13 +122,13 @@ export async function mergeTauriConfig(
|
||||
let bundleConf = {tauri: {bundle: tauriConf.tauri.bundle}};
|
||||
await fs.writeFile(
|
||||
configPath,
|
||||
Buffer.from(JSON.stringify(bundleConf), 'utf-8')
|
||||
Buffer.from(JSON.stringify(bundleConf, null, '\t'), 'utf-8')
|
||||
);
|
||||
|
||||
|
||||
const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json')
|
||||
await fs.writeFile(
|
||||
configJsonPath,
|
||||
Buffer.from(JSON.stringify(tauriConf), 'utf-8')
|
||||
Buffer.from(JSON.stringify(tauriConf, null, '\t'), 'utf-8')
|
||||
);
|
||||
}
|
||||
|
||||
1
bin/cli.ts
vendored
1
bin/cli.ts
vendored
@@ -23,6 +23,7 @@ program
|
||||
.option('-r, --no-resizable', 'whether the window can be resizable', DEFAULT_PAKE_OPTIONS.resizable)
|
||||
.option('-d, --debug', 'debug', DEFAULT_PAKE_OPTIONS.debug)
|
||||
.option('-m, --multi-arch', "available for Mac only, and supports both Intel and M1", DEFAULT_PAKE_OPTIONS.multiArch)
|
||||
.option('--targets <string>', "Select the output package format, support deb/appimage/all, only for Linux", DEFAULT_PAKE_OPTIONS.targets)
|
||||
.action(async (url: string, options: PakeCliOptions) => {
|
||||
|
||||
await checkUpdateTips();
|
||||
|
||||
1
bin/defaults.ts
vendored
1
bin/defaults.ts
vendored
@@ -9,6 +9,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
||||
transparent: false,
|
||||
debug: false,
|
||||
multiArch: false,
|
||||
targets: "all",
|
||||
};
|
||||
|
||||
export const DEFAULT_APP_NAME = 'Pake';
|
||||
|
||||
3
bin/types.ts
vendored
3
bin/types.ts
vendored
@@ -25,6 +25,9 @@ export interface PakeCliOptions {
|
||||
|
||||
/** mutli arch, Supports both Intel and m1 chips, only for Mac */
|
||||
multiArch: boolean;
|
||||
|
||||
/** Select the output package format, support deb/appimage/all, only for Linux */
|
||||
targets: string,
|
||||
}
|
||||
|
||||
export interface PakeAppOptions extends PakeCliOptions {
|
||||
|
||||
Reference in New Issue
Block a user