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 {
|
||||
|
||||
107
dist/cli.js
vendored
107
dist/cli.js
vendored
@@ -49,6 +49,7 @@ const DEFAULT_PAKE_OPTIONS = {
|
||||
transparent: false,
|
||||
debug: false,
|
||||
multiArch: false,
|
||||
targets: "all",
|
||||
};
|
||||
|
||||
const tlds = [
|
||||
@@ -1677,6 +1678,12 @@ function mergeTauriConfig(url, options, tauriConf) {
|
||||
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") {
|
||||
updateIconPath = false;
|
||||
@@ -1708,9 +1715,9 @@ function mergeTauriConfig(url, options, tauriConf) {
|
||||
}
|
||||
}
|
||||
let bundleConf = { tauri: { bundle: tauriConf.tauri.bundle } };
|
||||
yield fs.writeFile(configPath, Buffer.from(JSON.stringify(bundleConf), 'utf-8'));
|
||||
yield fs.writeFile(configPath, Buffer.from(JSON.stringify(bundleConf, null, '\t'), 'utf-8'));
|
||||
const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json');
|
||||
yield fs.writeFile(configJsonPath, Buffer.from(JSON.stringify(tauriConf), 'utf-8'));
|
||||
yield fs.writeFile(configJsonPath, Buffer.from(JSON.stringify(tauriConf, null, '\t'), 'utf-8'));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1830,8 +1837,8 @@ function checkRustInstalled() {
|
||||
var tauri$3 = {
|
||||
windows: [
|
||||
{
|
||||
url: "https://weread.qq.com/",
|
||||
transparent: true,
|
||||
url: "https://www.baidu.com",
|
||||
transparent: false,
|
||||
fullscreen: false,
|
||||
width: 1200,
|
||||
height: 780,
|
||||
@@ -1843,21 +1850,46 @@ var tauri$3 = {
|
||||
},
|
||||
updater: {
|
||||
active: false
|
||||
},
|
||||
bundle: {
|
||||
icon: [
|
||||
"/home/tlntin/data/code/rust_study/pake-tw93/Pake/src-tauri/png/icon_512.png"
|
||||
],
|
||||
identifier: "pake-f9751d",
|
||||
active: true,
|
||||
category: "DeveloperTool",
|
||||
copyright: "",
|
||||
deb: {
|
||||
depends: [
|
||||
"libwebkit2gtk-4.0-dev",
|
||||
"build-essential",
|
||||
"curl",
|
||||
"wget",
|
||||
"libssl-dev",
|
||||
"libgtk-3-dev",
|
||||
"libayatana-appindicator3-dev",
|
||||
"librsvg2-dev",
|
||||
"gnome-video-effects",
|
||||
"gnome-video-effects-extra"
|
||||
]
|
||||
},
|
||||
externalBin: [
|
||||
],
|
||||
longDescription: "",
|
||||
resources: [
|
||||
],
|
||||
shortDescription: "",
|
||||
targets: [
|
||||
"deb"
|
||||
]
|
||||
}
|
||||
};
|
||||
var build = {
|
||||
devPath: "../dist",
|
||||
distDir: "../dist",
|
||||
beforeBuildCommand: "",
|
||||
beforeDevCommand: ""
|
||||
};
|
||||
var CommonConf = {
|
||||
"package": {
|
||||
productName: "WeRead",
|
||||
productName: "baidu",
|
||||
version: "1.0.0"
|
||||
},
|
||||
tauri: tauri$3,
|
||||
build: build
|
||||
tauri: tauri$3
|
||||
};
|
||||
|
||||
var tauri$2 = {
|
||||
@@ -1932,10 +1964,9 @@ var MacConf = {
|
||||
var tauri = {
|
||||
bundle: {
|
||||
icon: [
|
||||
"png/weread_256.ico",
|
||||
"png/weread_512.png"
|
||||
"/home/tlntin/data/code/rust_study/pake-tw93/Pake/src-tauri/png/icon_512.png"
|
||||
],
|
||||
identifier: "com.tw93.weread",
|
||||
identifier: "pake-f9751d",
|
||||
active: true,
|
||||
category: "DeveloperTool",
|
||||
copyright: "",
|
||||
@@ -1951,10 +1982,7 @@ var tauri = {
|
||||
"librsvg2-dev",
|
||||
"gnome-video-effects",
|
||||
"gnome-video-effects-extra"
|
||||
],
|
||||
files: {
|
||||
"/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"
|
||||
}
|
||||
]
|
||||
},
|
||||
externalBin: [
|
||||
],
|
||||
@@ -1963,8 +1991,7 @@ var tauri = {
|
||||
],
|
||||
shortDescription: "",
|
||||
targets: [
|
||||
"deb",
|
||||
"appimage"
|
||||
"deb"
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -2134,19 +2161,24 @@ class LinuxBuilder {
|
||||
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`);
|
||||
yield fs.copyFile(appPath, distPath);
|
||||
yield fs.unlink(appPath);
|
||||
const appImageName = `${name}_${tauriConf.package.version}_${arch}.AppImage`;
|
||||
const appImagePath = this.getBuildAppPath(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 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`);
|
||||
yield fs.copyFile(appPath, distPath);
|
||||
yield 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`);
|
||||
yield fs.copyFile(appImagePath, distAppPath);
|
||||
yield fs.unlink(appImagePath);
|
||||
logger.success('Build AppImage success!');
|
||||
logger.success('You can find the AppImage app installer in', distAppPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
getBuildAppPath(npmDirectory, packageType, packageName) {
|
||||
@@ -2170,7 +2202,7 @@ class BuilderFactory {
|
||||
}
|
||||
|
||||
var name = "pake-cli";
|
||||
var version = "1.2.7";
|
||||
var version = "1.2.8";
|
||||
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。";
|
||||
var engines = {
|
||||
node: ">=16.0.0"
|
||||
@@ -2206,7 +2238,7 @@ var scripts = {
|
||||
build: "npm run tauri build --release",
|
||||
"build:mac": "npm run tauri build -- --target universal-apple-darwin",
|
||||
"build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
|
||||
"build:all-windows": ".\\script\\build.bat",
|
||||
"build:all-windows": "pwsh ./script/build.ps1",
|
||||
tauri: "tauri",
|
||||
cli: "rollup -c rollup.config.js --watch",
|
||||
"cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js",
|
||||
@@ -2286,6 +2318,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((url, options) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
yield checkUpdateTips();
|
||||
if (!url) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pake-cli",
|
||||
"version": "1.2.7",
|
||||
"version": "1.2.8",
|
||||
"description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。",
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
|
||||
@@ -1,30 +1,54 @@
|
||||
{
|
||||
"package": {
|
||||
"productName": "WeRead",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"tauri": {
|
||||
"windows": [
|
||||
{
|
||||
"url": "https://weread.qq.com/",
|
||||
"transparent": true,
|
||||
"fullscreen": false,
|
||||
"width": 1200,
|
||||
"height": 780,
|
||||
"resizable": true
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
"updater": {
|
||||
"active": false
|
||||
}
|
||||
},
|
||||
"build": {
|
||||
"devPath": "../dist",
|
||||
"distDir": "../dist",
|
||||
"beforeBuildCommand": "",
|
||||
"beforeDevCommand": ""
|
||||
}
|
||||
}
|
||||
"package": {
|
||||
"productName": "baidu",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"tauri": {
|
||||
"windows": [
|
||||
{
|
||||
"url": "https://www.baidu.com",
|
||||
"transparent": false,
|
||||
"fullscreen": false,
|
||||
"width": 1200,
|
||||
"height": 780,
|
||||
"resizable": true
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
"updater": {
|
||||
"active": false
|
||||
},
|
||||
"bundle": {
|
||||
"icon": [
|
||||
"/home/tlntin/data/code/rust_study/pake-tw93/Pake/src-tauri/png/icon_512.png"
|
||||
],
|
||||
"identifier": "pake-f9751d",
|
||||
"active": true,
|
||||
"category": "DeveloperTool",
|
||||
"copyright": "",
|
||||
"deb": {
|
||||
"depends": [
|
||||
"libwebkit2gtk-4.0-dev",
|
||||
"build-essential",
|
||||
"curl",
|
||||
"wget",
|
||||
"libssl-dev",
|
||||
"libgtk-3-dev",
|
||||
"libayatana-appindicator3-dev",
|
||||
"librsvg2-dev",
|
||||
"gnome-video-effects",
|
||||
"gnome-video-effects-extra"
|
||||
]
|
||||
},
|
||||
"externalBin": [],
|
||||
"longDescription": "",
|
||||
"resources": [],
|
||||
"shortDescription": "",
|
||||
"targets": [
|
||||
"deb"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,34 @@
|
||||
{
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"icon": ["png/weread_512.png"],
|
||||
"identifier": "com.tw93.weread",
|
||||
"active": true,
|
||||
"category": "DeveloperTool",
|
||||
"copyright": "",
|
||||
"deb": {
|
||||
"depends": [
|
||||
"libwebkit2gtk-4.0-dev",
|
||||
"build-essential",
|
||||
"curl",
|
||||
"wget",
|
||||
"libssl-dev",
|
||||
"libgtk-3-dev",
|
||||
"libayatana-appindicator3-dev",
|
||||
"librsvg2-dev",
|
||||
"gnome-video-effects",
|
||||
"gnome-video-effects-extra"
|
||||
],
|
||||
"files": {"/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"}
|
||||
},
|
||||
"externalBin": [],
|
||||
"longDescription": "",
|
||||
"resources": [],
|
||||
"shortDescription": "",
|
||||
"targets": ["deb", "appimage"]
|
||||
}
|
||||
}
|
||||
}
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"icon": [
|
||||
"/home/tlntin/data/code/rust_study/pake-tw93/Pake/src-tauri/png/icon_512.png"
|
||||
],
|
||||
"identifier": "pake-f9751d",
|
||||
"active": true,
|
||||
"category": "DeveloperTool",
|
||||
"copyright": "",
|
||||
"deb": {
|
||||
"depends": [
|
||||
"libwebkit2gtk-4.0-dev",
|
||||
"build-essential",
|
||||
"curl",
|
||||
"wget",
|
||||
"libssl-dev",
|
||||
"libgtk-3-dev",
|
||||
"libayatana-appindicator3-dev",
|
||||
"librsvg2-dev",
|
||||
"gnome-video-effects",
|
||||
"gnome-video-effects-extra"
|
||||
]
|
||||
},
|
||||
"externalBin": [],
|
||||
"longDescription": "",
|
||||
"resources": [],
|
||||
"shortDescription": "",
|
||||
"targets": [
|
||||
"deb"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user