Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

feat: add --no-bundle to skip Linux packaging and output the raw binary

Tw933f2501de7482
diff --git a/bin/builders/BaseBuilder.ts b/bin/builders/BaseBuilder.ts
index 130eb7af..e8864ca7 100644
--- a/bin/builders/BaseBuilder.ts
+++ b/bin/builders/BaseBuilder.ts
@@ -221,6 +221,20 @@ export default abstract class BaseBuilder {
}
}
+ // With --no-bundle there is no installer to copy; surface the raw
+ // executable the build produced instead.
+ if (this.options.bundle === false) {
+ await this.copyRawBinary(npmDirectory, name);
+ if (logSuccess) {
+ logger.success('✔ Build success!');
+ logger.success(
+ '✔ Raw binary located in',
+ path.resolve(this.getRawBinaryPath(name)),
+ );
+ }
+ return;
+ }
+
// Copy app
const fileName = this.getFileName();
const fileType = this.getFileType(target);
diff --git a/bin/builders/LinuxBuilder.ts b/bin/builders/LinuxBuilder.ts
index b38b0111..d3064c51 100644
--- a/bin/builders/LinuxBuilder.ts
+++ b/bin/builders/LinuxBuilder.ts
@@ -64,6 +64,12 @@ export default class LinuxBuilder extends BaseBuilder {
}
async build(url: string) {
+ // --no-bundle: build the executable once with no per-format packaging loop.
+ if (this.options.bundle === false) {
+ await this.buildAndCopy(url, 'deb');
+ return;
+ }
+
const targets = filterLinuxTargets(this.options.targets);
if (targets.length === 0) {
throw new Error(
@@ -269,6 +275,12 @@ post_remove() {
buildTarget,
);
+ // --no-bundle: build the executable only, skipping .deb/.rpm/.appimage
+ // packaging entirely (e.g. RPM-based distros where the bundler aborts).
+ if (this.options.bundle === false) {
+ return `${fullCommand} --no-bundle`;
+ }
+
if (this.currentBuildType) {
fullCommand += ` --bundles ${this.currentBuildType}`;
}
diff --git a/bin/defaults.ts b/bin/defaults.ts
index a9539d9a..3629d60a 100644
--- a/bin/defaults.ts
+++ b/bin/defaults.ts
@@ -39,6 +39,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
incognito: false,
wasm: false,
enableDragDrop: false,
+ bundle: true,
keepBinary: false,
multiInstance: false,
multiWindow: false,
diff --git a/bin/helpers/cli-program.ts b/bin/helpers/cli-program.ts
index 5e00f1f7..35024f69 100644
--- a/bin/helpers/cli-program.ts
+++ b/bin/helpers/cli-program.ts
@@ -165,6 +165,14 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
.default(DEFAULT.keepBinary)
.hideHelp(),
)
+ .addOption(
+ new Option(
+ '--no-bundle',
+ 'Skip packaging, output only the raw executable (Linux; for RPM distros where the bundler aborts)',
+ )
+ .default(DEFAULT.bundle)
+ .hideHelp(),
+ )
.addOption(
new Option('--multi-instance', 'Allow multiple app instances')
.default(DEFAULT.multiInstance)
diff --git a/bin/options/index.ts b/bin/options/index.ts
index 73fb4955..f499bfd6 100644
--- a/bin/options/index.ts
+++ b/bin/options/index.ts
@@ -91,6 +91,12 @@ export default async function handleOptions(
appOptions.internalUrlRegex = safeDomainsToRegex(options.safeDomain);
}
+ // --no-bundle is Linux-only; keep normal packaging on other platforms.
+ if (appOptions.bundle === false && platform !== 'linux') {
+ logger.warn('✼ --no-bundle is only supported on Linux; ignoring it.');
+ appOptions.bundle = true;
+ }
+
const iconPath = await handleIcon(appOptions, url);
appOptions.icon = iconPath || '';
diff --git a/bin/types.ts b/bin/types.ts
index b6318be4..ed7399f9 100644
--- a/bin/types.ts
+++ b/bin/types.ts
@@ -90,6 +90,10 @@ export interface PakeCliOptions {
// Enable drag and drop functionality, default false
enableDragDrop: boolean;
+ // Build the executable without packaging it into an installer (Linux only),
+ // default true. Set false via --no-bundle for RPM distros where the bundler aborts.
+ bundle: boolean;
+
// Keep raw binary file alongside installer, default false
keepBinary: boolean;
diff --git a/dist/cli.js b/dist/cli.js
index 33dac95b..a90a44ab 100644
--- a/dist/cli.js
+++ b/dist/cli.js
@@ -1141,6 +1141,16 @@ class BaseBuilder {
throw retryError;
}
}
+ // With --no-bundle there is no installer to copy; surface the raw
+ // executable the build produced instead.
+ if (this.options.bundle === false) {
+ await this.copyRawBinary(npmDirectory, name);
+ if (logSuccess) {
+ logger.success('✔ Build success!');
+ logger.success('✔ Raw binary located in', path.resolve(this.getRawBinaryPath(name)));
+ }
+ return;
+ }
// Copy app
const fileName = this.getFileName();
const fileType = this.getFileType(target);
@@ -1526,6 +1536,11 @@ class LinuxBuilder extends BaseBuilder {
return `${name}_${version}_${arch}`;
}
async build(url) {
+ // --no-bundle: build the executable once with no per-format packaging loop.
+ if (this.options.bundle === false) {
+ await this.buildAndCopy(url, 'deb');
+ return;
+ }
const targets = filterLinuxTargets(this.options.targets);
if (targets.length === 0) {
throw new Error(`No valid Linux target in "${this.options.targets}". Valid targets: ${LINUX_TARGET_TYPES.join(', ')}.`);
@@ -1684,6 +1699,11 @@ post_remove() {
? (this.getTauriTarget(this.buildArch, 'linux') ?? undefined)
: undefined;
let fullCommand = this.buildBaseCommand(packageManager, configPath, buildTarget);
+ // --no-bundle: build the executable only, skipping .deb/.rpm/.appimage
+ // packaging entirely (e.g. RPM-based distros where the bundler aborts).
+ if (this.options.bundle === false) {
+ return `${fullCommand} --no-bundle`;
+ }
if (this.currentBuildType) {
fullCommand += ` --bundles ${this.currentBuildType}`;
}
@@ -2660,6 +2680,11 @@ async function handleOptions(options, url) {
if (!options.internalUrlRegex && options.safeDomain) {
appOptions.internalUrlRegex = safeDomainsToRegex(options.safeDomain);
}
+ // --no-bundle is Linux-only; keep normal packaging on other platforms.
+ if (appOptions.bundle === false && platform !== 'linux') {
+ logger.warn('✼ --no-bundle is only supported on Linux; ignoring it.');
+ appOptions.bundle = true;
+ }
const iconPath = await handleIcon(appOptions, url);
appOptions.icon = iconPath || '';
return appOptions;
@@ -2702,6 +2727,7 @@ const DEFAULT_PAKE_OPTIONS = {
incognito: false,
wasm: false,
enableDragDrop: false,
+ bundle: true,
keepBinary: false,
multiInstance: false,
multiWindow: false,
@@ -2841,6 +2867,9 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
.addOption(new Option('--keep-binary', 'Keep raw binary file alongside installer')
.default(DEFAULT_PAKE_OPTIONS.keepBinary)
.hideHelp())
+ .addOption(new Option('--no-bundle', 'Skip packaging, output only the raw executable (Linux; for RPM distros where the bundler aborts)')
+ .default(DEFAULT_PAKE_OPTIONS.bundle)
+ .hideHelp())
.addOption(new Option('--multi-instance', 'Allow multiple app instances')
.default(DEFAULT_PAKE_OPTIONS.multiInstance)
.hideHelp())
diff --git a/docs/cli-usage.md b/docs/cli-usage.md
index e53641d5..62c1799f 100644
--- a/docs/cli-usage.md
+++ b/docs/cli-usage.md
@@ -338,6 +338,16 @@ Specify the build target architecture or format:
- Use `--target appimage-arm64` for portable ARM64 applications that work across different ARM64 Linux distributions.
- Use `--targets zst` on Arch Linux based distributions to produce a `.pkg.tar.zst` package directly. Pake follows Tauri's AUR packaging guidance by building the Linux package payload first, then emitting Arch package metadata and zstd-compressed output. Requires `binutils` (for `ar`) and `libarchive` (for `bsdtar`).
+#### [no-bundle]
+
+Skip packaging and output only the compiled executable. Linux only. Useful on RPM-based distros (Fedora, RHEL, Oracle Linux, etc.) where the native bundler can abort during the packaging stage, so you still get a runnable binary.
+
+```shell
+pake https://github.com --name GitHub --no-bundle
+```
+
+The raw executable is copied to the current directory as `<name>-binary`. On platforms other than Linux this flag is ignored.
+
#### [user-agent]
Customize the browser user agent. Default is empty.
diff --git a/docs/cli-usage_CN.md b/docs/cli-usage_CN.md
index d013e2d3..ecd6eb93 100644
--- a/docs/cli-usage_CN.md
+++ b/docs/cli-usage_CN.md
@@ -336,6 +336,16 @@ pake https://github.com --name GitHub
- 使用 `--target appimage-arm64` 可以创建便携式 ARM64 应用,在不同的 ARM64 Linux 发行版上运行。
- 在基于 Arch Linux 的发行版上使用 `--targets zst` 可直接生成 `.pkg.tar.zst` 包。Pake 会按 Tauri 的 AUR 打包说明先生成 Linux 包内容,再写入 Arch 包元数据并输出 zstd 压缩包。需要预先安装 `binutils`(提供 `ar`)和 `libarchive`(提供 `bsdtar`)。
+#### [no-bundle]
+
+跳过打包,只输出编译好的可执行文件。仅 Linux 可用。适用于 Fedora、RHEL、Oracle Linux 等 RPM 系发行版,这些系统上原生打包器可能在打包阶段中止,用此选项仍能拿到可运行的二进制。
+
+```shell
+pake https://github.com --name GitHub --no-bundle
+```
+
+裸可执行文件会复制到当前目录,命名为 `<name>-binary`。在非 Linux 平台此选项会被忽略。
+
#### [user-agent]
自定义浏览器的用户代理请求头,默认为空。
diff --git a/tests/unit/no-bundle.test.ts b/tests/unit/no-bundle.test.ts
new file mode 100644
index 00000000..1db01d8f
--- /dev/null
+++ b/tests/unit/no-bundle.test.ts
@@ -0,0 +1,28 @@
+import path from 'path';
+import { describe, it, expect, vi } from 'vitest';
+
+// tauriConfig.ts reads pake.json at module load, keyed off npmDirectory.
+// Point it at the repo root so the import chain resolves under vitest.
+vi.mock('@/utils/dir', () => ({
+ npmDirectory: process.cwd(),
+ tauriConfigDirectory: path.join(process.cwd(), 'src-tauri', '.pake'),
+}));
+
+import LinuxBuilder from '@/builders/LinuxBuilder';
+import { PakeAppOptions } from '@/types';
+
+const makeBuilder = (bundle: boolean) =>
+ new LinuxBuilder({ name: 'demo', targets: 'deb', bundle } as PakeAppOptions);
+
+describe('LinuxBuilder --no-bundle', () => {
+ it('appends --no-bundle and skips --bundles when bundle is false', () => {
+ const cmd = (makeBuilder(false) as any).getBuildCommand('pnpm');
+ expect(cmd).toContain('--no-bundle');
+ expect(cmd).not.toContain('--bundles');
+ });
+
+ it('does not append --no-bundle when bundle is true (default)', () => {
+ const cmd = (makeBuilder(true) as any).getBuildCommand('pnpm');
+ expect(cmd).not.toContain('--no-bundle');
+ });
+});