✨ Refactoring with documentation
This commit is contained in:
20
docs/README.md
Normal file
20
docs/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Pake Documentation
|
||||
|
||||
Welcome to Pake documentation! Here you'll find comprehensive guides and documentation to help you start working with Pake as quickly as possible.
|
||||
|
||||
## User Guides
|
||||
|
||||
- **[CLI Usage](cli-usage.md)** ([中文](cli-usage_CN.md)) - Command-line interface reference
|
||||
- **[GitHub Actions](github-actions-usage.md)** ([中文](github-actions-usage_CN.md)) - Build apps online without local setup
|
||||
|
||||
## Developer Guides
|
||||
|
||||
- **[Advanced Usage](advanced-usage.md)** ([中文](advanced-usage_CN.md)) - Customization, development, and advanced features
|
||||
- **[Contributing](../CONTRIBUTING.md)** - How to contribute to Pake development
|
||||
|
||||
## Quick Links
|
||||
|
||||
- [Main Repository](https://github.com/tw93/Pake)
|
||||
- [Releases](https://github.com/tw93/Pake/releases)
|
||||
- [Discussions](https://github.com/tw93/Pake/discussions)
|
||||
- [Issues](https://github.com/tw93/Pake/issues)
|
||||
174
docs/advanced-usage.md
Normal file
174
docs/advanced-usage.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# Advanced Usage
|
||||
|
||||
Customize Pake apps with style modifications, JavaScript injection, and container communication.
|
||||
|
||||
## Style Customization
|
||||
|
||||
Remove ads or customize appearance by modifying CSS.
|
||||
|
||||
**Quick Process:**
|
||||
|
||||
1. Run `pnpm run dev` for development
|
||||
2. Use DevTools to find elements to modify
|
||||
3. Edit `src-tauri/src/inject/style.js`:
|
||||
|
||||
```javascript
|
||||
const css = `
|
||||
.ads-banner { display: none !important; }
|
||||
.header { background: #1a1a1a !important; }
|
||||
`;
|
||||
```
|
||||
|
||||
## JavaScript Injection
|
||||
|
||||
Add custom functionality like keyboard shortcuts.
|
||||
|
||||
**Implementation:**
|
||||
|
||||
1. Edit `src-tauri/src/inject/event.js`
|
||||
2. Add event listeners:
|
||||
|
||||
```javascript
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.ctrlKey && e.key === "k") {
|
||||
// Custom action
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Container Communication
|
||||
|
||||
Send messages between web content and Pake container.
|
||||
|
||||
**Web Side (JavaScript):**
|
||||
|
||||
```javascript
|
||||
window.__TAURI__.invoke("handle_scroll", {
|
||||
scrollY: window.scrollY,
|
||||
scrollX: window.scrollX,
|
||||
});
|
||||
```
|
||||
|
||||
**Container Side (Rust):**
|
||||
|
||||
```rust
|
||||
#[tauri::command]
|
||||
fn handle_scroll(scroll_y: f64, scroll_x: f64) {
|
||||
println!("Scroll: {}, {}", scroll_x, scroll_y);
|
||||
}
|
||||
```
|
||||
|
||||
## Window Configuration
|
||||
|
||||
Configure window properties in `pake.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"windows": {
|
||||
"width": 1200,
|
||||
"height": 780,
|
||||
"fullscreen": false,
|
||||
"resizable": true
|
||||
},
|
||||
"hideTitleBar": true
|
||||
}
|
||||
```
|
||||
|
||||
## Static File Packaging
|
||||
|
||||
Package local HTML/CSS/JS files:
|
||||
|
||||
```bash
|
||||
pake ./my-app/index.html --name my-static-app --use-local-file
|
||||
```
|
||||
|
||||
Requirements: Pake CLI >= 3.0.0
|
||||
|
||||
## Project Structure
|
||||
|
||||
Understanding Pake's codebase structure will help you navigate and contribute effectively:
|
||||
|
||||
```tree
|
||||
├── bin/ # CLI source code (TypeScript)
|
||||
│ ├── builders/ # Platform-specific builders
|
||||
│ ├── helpers/ # Utility functions
|
||||
│ └── options/ # CLI option processing
|
||||
├── docs/ # Project documentation
|
||||
├── src-tauri/ # Tauri application core
|
||||
│ ├── src/
|
||||
│ │ ├── app/ # Core modules (window, tray, shortcuts)
|
||||
│ │ ├── inject/ # Web page injection logic
|
||||
│ │ └── lib.rs # Application entry point
|
||||
│ ├── icons/ # macOS icons (.icns)
|
||||
│ ├── png/ # Windows/Linux icons (.ico, .png)
|
||||
│ ├── pake.json # App configuration
|
||||
│ └── tauri.*.conf.json # Platform-specific configs
|
||||
├── scripts/ # Build and utility scripts
|
||||
└── tests/ # Test suites
|
||||
```
|
||||
|
||||
### Key Components
|
||||
|
||||
- **CLI Tool** (`bin/`): TypeScript-based command interface for packaging apps
|
||||
- **Tauri App** (`src-tauri/`): Rust-based desktop framework
|
||||
- **Injection System** (`src-tauri/src/inject/`): Custom CSS/JS injection for webpages
|
||||
- **Configuration**: Multi-platform app settings and build configurations
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Node.js ≥22.0.0 (recommended LTS, older versions ≥16.0.0 may work)
|
||||
- Rust ≥1.89.0 (recommended stable, older versions ≥1.78.0 may work)
|
||||
- Platform-specific build tools:
|
||||
- **macOS**: Xcode Command Line Tools (`xcode-select --install`)
|
||||
- **Windows**: Visual Studio Build Tools with MSVC
|
||||
- **Linux**: `build-essential`, `libwebkit2gtk`, system dependencies
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/tw93/Pake.git
|
||||
cd Pake
|
||||
|
||||
# Install dependencies
|
||||
pnpm install
|
||||
|
||||
# Start development
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
### Development Commands
|
||||
|
||||
1. **CLI Changes**: Edit files in `bin/`, then run `pnpm run cli:build`
|
||||
2. **Core App Changes**: Edit files in `src-tauri/src/`, then run `pnpm run dev`
|
||||
3. **Injection Logic**: Modify files in `src-tauri/src/inject/` for web customizations
|
||||
4. **Testing**: Run `pnpm test` for comprehensive validation
|
||||
|
||||
- **Dev mode**: `pnpm run dev` (hot reload)
|
||||
- **Build**: `pnpm run build`
|
||||
- **Debug build**: `pnpm run build:debug`
|
||||
- **CLI build**: `pnpm run cli:build`
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Run all tests (unit + integration + builder)
|
||||
pnpm test
|
||||
|
||||
# Build CLI for testing
|
||||
pnpm run cli:build
|
||||
```
|
||||
|
||||
### Common Build Issues
|
||||
|
||||
- **Rust compilation errors**: Run `cargo clean` in `src-tauri/` directory
|
||||
- **Node dependency issues**: Delete `node_modules` and run `pnpm install`
|
||||
- **Permission errors on macOS**: Run `sudo xcode-select --reset`
|
||||
|
||||
## Links
|
||||
|
||||
- [CLI Documentation](cli-usage.md)
|
||||
- [Testing Guide](testing.md)
|
||||
- [GitHub Discussions](https://github.com/tw93/Pake/discussions)
|
||||
174
docs/advanced-usage_CN.md
Normal file
174
docs/advanced-usage_CN.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# 高级用法
|
||||
|
||||
通过样式修改、JavaScript 注入和容器通信等方式自定义 Pake 应用。
|
||||
|
||||
## 样式自定义
|
||||
|
||||
通过修改 CSS 移除广告或自定义外观。
|
||||
|
||||
**快速流程:**
|
||||
|
||||
1. 运行 `pnpm run dev` 进入开发模式
|
||||
2. 使用开发者工具找到要修改的元素
|
||||
3. 编辑 `src-tauri/src/inject/style.js`:
|
||||
|
||||
```javascript
|
||||
const css = `
|
||||
.ads-banner { display: none !important; }
|
||||
.header { background: #1a1a1a !important; }
|
||||
`;
|
||||
```
|
||||
|
||||
## JavaScript 注入
|
||||
|
||||
添加自定义功能,如键盘快捷键。
|
||||
|
||||
**实现方式:**
|
||||
|
||||
1. 编辑 `src-tauri/src/inject/event.js`
|
||||
2. 添加事件监听器:
|
||||
|
||||
```javascript
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.ctrlKey && e.key === "k") {
|
||||
// 自定义操作
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## 容器通信
|
||||
|
||||
在网页内容和 Pake 容器之间发送消息。
|
||||
|
||||
**网页端(JavaScript):**
|
||||
|
||||
```javascript
|
||||
window.__TAURI__.invoke("handle_scroll", {
|
||||
scrollY: window.scrollY,
|
||||
scrollX: window.scrollX,
|
||||
});
|
||||
```
|
||||
|
||||
**容器端(Rust):**
|
||||
|
||||
```rust
|
||||
#[tauri::command]
|
||||
fn handle_scroll(scroll_y: f64, scroll_x: f64) {
|
||||
println!("滚动位置: {}, {}", scroll_x, scroll_y);
|
||||
}
|
||||
```
|
||||
|
||||
## 窗口配置
|
||||
|
||||
在 `pake.json` 中配置窗口属性:
|
||||
|
||||
```json
|
||||
{
|
||||
"windows": {
|
||||
"width": 1200,
|
||||
"height": 780,
|
||||
"fullscreen": false,
|
||||
"resizable": true
|
||||
},
|
||||
"hideTitleBar": true
|
||||
}
|
||||
```
|
||||
|
||||
## 静态文件打包
|
||||
|
||||
打包本地 HTML/CSS/JS 文件:
|
||||
|
||||
```bash
|
||||
pake ./my-app/index.html --name my-static-app --use-local-file
|
||||
```
|
||||
|
||||
要求:Pake CLI >= 3.0.0
|
||||
|
||||
## 项目结构
|
||||
|
||||
了解 Pake 的代码库结构将帮助您有效地进行导航和贡献:
|
||||
|
||||
```tree
|
||||
├── bin/ # CLI 源代码 (TypeScript)
|
||||
│ ├── builders/ # 平台特定的构建器
|
||||
│ ├── helpers/ # 实用函数
|
||||
│ └── options/ # CLI 选项处理
|
||||
├── docs/ # 项目文档
|
||||
├── src-tauri/ # Tauri 应用核心
|
||||
│ ├── src/
|
||||
│ │ ├── app/ # 核心模块(窗口、托盘、快捷键)
|
||||
│ │ ├── inject/ # 网页注入逻辑
|
||||
│ │ └── lib.rs # 应用程序入口点
|
||||
│ ├── icons/ # macOS 图标 (.icns)
|
||||
│ ├── png/ # Windows/Linux 图标 (.ico, .png)
|
||||
│ ├── pake.json # 应用配置
|
||||
│ └── tauri.*.conf.json # 平台特定配置
|
||||
├── scripts/ # 构建和实用脚本
|
||||
└── tests/ # 测试套件
|
||||
```
|
||||
|
||||
### 关键组件
|
||||
|
||||
- **CLI 工具** (`bin/`): 基于 TypeScript 的命令接口,用于打包应用
|
||||
- **Tauri 应用** (`src-tauri/`): 基于 Rust 的桌面框架
|
||||
- **注入系统** (`src-tauri/src/inject/`): 用于网页的自定义 CSS/JS 注入
|
||||
- **配置**: 多平台应用设置和构建配置
|
||||
|
||||
## 开发工作流
|
||||
|
||||
### 前置条件
|
||||
|
||||
- Node.js ≥22.0.0 (推荐 LTS,较旧版本 ≥16.0.0 可能可用)
|
||||
- Rust ≥1.89.0 (推荐稳定版,较旧版本 ≥1.78.0 可能可用)
|
||||
- 平台特定构建工具:
|
||||
- **macOS**: Xcode 命令行工具 (`xcode-select --install`)
|
||||
- **Windows**: Visual Studio 构建工具与 MSVC
|
||||
- **Linux**: `build-essential`、`libwebkit2gtk`、系统依赖
|
||||
|
||||
### 安装
|
||||
|
||||
```bash
|
||||
# 克隆仓库
|
||||
git clone https://github.com/tw93/Pake.git
|
||||
cd Pake
|
||||
|
||||
# 安装依赖
|
||||
pnpm install
|
||||
|
||||
# 开始开发
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
### 开发命令
|
||||
|
||||
1. **CLI 更改**: 编辑 `bin/` 中的文件,然后运行 `pnpm run cli:build`
|
||||
2. **核心应用更改**: 编辑 `src-tauri/src/` 中的文件,然后运行 `pnpm run dev`
|
||||
3. **注入逻辑**: 修改 `src-tauri/src/inject/` 中的文件以进行网页自定义
|
||||
4. **测试**: 运行 `pnpm test` 进行综合验证
|
||||
|
||||
- **开发模式**:`pnpm run dev`(热重载)
|
||||
- **构建**:`pnpm run build`
|
||||
- **调试构建**:`pnpm run build:debug`
|
||||
- **CLI 构建**:`pnpm run cli:build`
|
||||
|
||||
### 测试
|
||||
|
||||
```bash
|
||||
# 运行所有测试(单元 + 集成 + 构建器)
|
||||
pnpm test
|
||||
|
||||
# 构建 CLI 以供测试
|
||||
pnpm run cli:build
|
||||
```
|
||||
|
||||
### 常见构建问题
|
||||
|
||||
- **Rust 编译错误**: 在 `src-tauri/` 目录中运行 `cargo clean`
|
||||
- **Node 依赖问题**: 删除 `node_modules` 并运行 `pnpm install`
|
||||
- **macOS 权限错误**: 运行 `sudo xcode-select --reset`
|
||||
|
||||
## 链接
|
||||
|
||||
- [CLI 文档](cli-usage_CN.md)
|
||||
- [测试指南](testing.md)
|
||||
- [GitHub 讨论区](https://github.com/tw93/Pake/discussions)
|
||||
427
docs/cli-usage.md
Normal file
427
docs/cli-usage.md
Normal file
@@ -0,0 +1,427 @@
|
||||
<h4 align="right"><strong>English</strong> | <a href="cli-usage_CN.md">简体中文</a></h4>
|
||||
|
||||
## Installation
|
||||
|
||||
Ensure that your Node.js version is 22.0 or higher (e.g., 22.11.0). _Note: Older versions ≥18.0.0 may also work._
|
||||
|
||||
**Recommended (pnpm):**
|
||||
|
||||
```bash
|
||||
pnpm install -g pake-cli
|
||||
```
|
||||
|
||||
**Alternative (npm):**
|
||||
|
||||
```bash
|
||||
npm install -g pake-cli
|
||||
```
|
||||
|
||||
**If you encounter permission issues:**
|
||||
|
||||
```bash
|
||||
# Use npx to run without global installation
|
||||
npx pake-cli [url] [options]
|
||||
|
||||
# Or fix npm permissions permanently
|
||||
npm config set prefix ~/.npm-global
|
||||
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary><strong>Considerations for Windows & Linux Users</strong></summary>
|
||||
|
||||
- **CRITICAL**: Consult [Tauri prerequisites](https://tauri.app/start/prerequisites/) before proceeding.
|
||||
- For Windows users (ensure that `Win10 SDK (10.0.19041.0)` and `Visual Studio build tool 2022 (>=17.2)` are installed), additional installations are required:
|
||||
1. Microsoft Visual C++ 2015-2022 Redistributable (x64)
|
||||
2. Microsoft Visual C++ 2015-2022 Redistributable (x86)
|
||||
3. Microsoft Visual C++ 2012 Redistributable (x86) (optional)
|
||||
4. Microsoft Visual C++ 2013 Redistributable (x86) (optional)
|
||||
5. Microsoft Visual C++ 2008 Redistributable (x86) (optional)
|
||||
|
||||
**For Windows on ARM (ARM64) support**: Install the C++ ARM64 build tools in Visual Studio Installer under "Individual Components" → "MSVC v143 - VS 2022 C++ ARM64 build tools". The system will automatically detect ARM64 architecture and build native ARM64 binaries.
|
||||
|
||||
- For Ubuntu users, execute the following commands to install the required libraries before compiling:
|
||||
|
||||
```bash
|
||||
sudo apt install libdbus-1-dev \
|
||||
libsoup-3.0-dev \
|
||||
libjavascriptcoregtk-4.1-dev \
|
||||
libwebkit2gtk-4.1-dev \
|
||||
build-essential \
|
||||
curl \
|
||||
wget \
|
||||
libssl-dev \
|
||||
libgtk-3-dev \
|
||||
libayatana-appindicator3-dev \
|
||||
librsvg2-dev \
|
||||
gnome-video-effects \
|
||||
gnome-video-effects-extra
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Basic usage - just provide a URL
|
||||
pake https://weekly.tw93.fun --name "Weekly"
|
||||
|
||||
# With custom icon and window size (macOS example)
|
||||
pake https://weekly.tw93.fun --name "Weekly" --icon https://cdn.tw93.fun/pake/weekly.icns --width 1200 --height 800
|
||||
|
||||
# macOS immersive experience
|
||||
pake https://weekly.tw93.fun --name "Weekly" --hide-title-bar
|
||||
```
|
||||
|
||||
## CLI Usage
|
||||
|
||||
```bash
|
||||
pake [url] [options]
|
||||
```
|
||||
|
||||
The packaged application will be located in the current working directory by default. The first packaging might take some time due to environment configuration. Please be patient.
|
||||
|
||||
> **macOS Output**: On macOS, Pake creates DMG installers by default. To create `.app` bundles for testing (to avoid user interaction), set the environment variable `PAKE_CREATE_APP=1`.
|
||||
>
|
||||
> **Note**: Packaging requires the Rust environment. If Rust is not installed, you will be prompted for installation confirmation. In case of installation failure or timeout, you can [install it manually](https://www.rust-lang.org/tools/install).
|
||||
|
||||
### [url]
|
||||
|
||||
The URL is the link to the web page you want to package or the path to a local HTML file. This is mandatory.
|
||||
|
||||
### [options]
|
||||
|
||||
Various options are available for customization. Here are the most commonly used ones:
|
||||
|
||||
| Option | Description | Example |
|
||||
| ------------------ | ------------------------------ | ---------------------------------------------- |
|
||||
| `--name` | Application name | `--name "Weekly"` |
|
||||
| `--icon` | Application icon | `--icon https://cdn.tw93.fun/pake/weekly.icns` |
|
||||
| `--width` | Window width (default: 1200px) | `--width 1400` |
|
||||
| `--height` | Window height (default: 780px) | `--height 900` |
|
||||
| `--hide-title-bar` | Immersive header (macOS only) | `--hide-title-bar` |
|
||||
| `--debug` | Enable development tools | `--debug` |
|
||||
|
||||
For complete options, see detailed sections below.
|
||||
|
||||
#### [name]
|
||||
|
||||
Specify the application name. If not provided, you will be prompted to enter it. It is recommended to use English.
|
||||
|
||||
**Note**: Also supports multiple words with automatic platform-specific handling:
|
||||
|
||||
- **Windows/macOS**: Preserves spaces and case (e.g., `"Google Translate"`)
|
||||
- **Linux**: Converts to lowercase with hyphens (e.g., `"google-translate"`)
|
||||
|
||||
```shell
|
||||
--name <string>
|
||||
--name MyApp
|
||||
|
||||
# Multiple words (if needed):
|
||||
--name "Google Translate"
|
||||
```
|
||||
|
||||
#### [icon]
|
||||
|
||||
Specify the application icon. Supports both local and remote files. If not provided, Pake will intelligently fetch the website's icon. For custom icons, visit [icon-icons](https://icon-icons.com) or [macOSicons](https://macosicons.com/#/).
|
||||
|
||||
- For macOS, use `.icns` format.
|
||||
- For Windows, use `.ico` format.
|
||||
- For Linux, use `.png` format.
|
||||
|
||||
```shell
|
||||
--icon <path>
|
||||
|
||||
# Examples:
|
||||
--icon ./my-icon.png
|
||||
--icon https://cdn.tw93.fun/pake/weekly.icns # Remote icon (.icns for macOS)
|
||||
```
|
||||
|
||||
#### [height]
|
||||
|
||||
Set the height of the application window. Default is `780px`.
|
||||
|
||||
```shell
|
||||
--height <number>
|
||||
```
|
||||
|
||||
#### [width]
|
||||
|
||||
Set the width of the application window. Default is `1200px`.
|
||||
|
||||
```shell
|
||||
--width <number>
|
||||
```
|
||||
|
||||
#### [hide-title-bar]
|
||||
|
||||
Enable or disable immersive header. Default is `false`. Use the following command to enable this feature, macOS only.
|
||||
|
||||
```shell
|
||||
--hide-title-bar
|
||||
```
|
||||
|
||||
#### [fullscreen]
|
||||
|
||||
Determine whether the application launches in full screen. Default is `false`. Use the following command to enable full
|
||||
screen.
|
||||
|
||||
```shell
|
||||
--fullscreen
|
||||
```
|
||||
|
||||
#### [activation-shortcut]
|
||||
|
||||
Set the activation shortcut for the application. Default is empty, so it does not take effect. You can customize the activation shortcut with the following commands, e.g. `CmdOrControl+Shift+P`. Usage can refer to [available-modifiers](https://www.electronjs.org/docs/latest/api/accelerator#available-modifiers).
|
||||
|
||||
```shell
|
||||
--activation-shortcut <string>
|
||||
```
|
||||
|
||||
#### [always-on-top]
|
||||
|
||||
Sets whether the window is always at the top level, defaults to `false`.
|
||||
|
||||
```shell
|
||||
--always-on-top
|
||||
```
|
||||
|
||||
#### [app-version]
|
||||
|
||||
Set the version number of the packaged application to be consistent with the naming format of version in package.json, defaulting to `1.0.0`.
|
||||
|
||||
```shell
|
||||
--app-version <string>
|
||||
```
|
||||
|
||||
#### [dark-mode]
|
||||
|
||||
Force Mac to package applications using dark mode, default is `false`.
|
||||
|
||||
```shell
|
||||
--dark-mode
|
||||
```
|
||||
|
||||
#### [disabled-web-shortcuts]
|
||||
|
||||
Sets whether to disable web shortcuts in the original Pake container, defaults to `false`.
|
||||
|
||||
```shell
|
||||
--disabled-web-shortcuts
|
||||
```
|
||||
|
||||
#### [multi-arch]
|
||||
|
||||
Package the application to support both Intel and M1 chips, exclusively for macOS. Default is `false`.
|
||||
|
||||
##### Prerequisites
|
||||
|
||||
- Note: After enabling this option, Rust must be installed using rustup from the official Rust website. Installation via brew is not supported.
|
||||
- For Intel chip users, install the arm64 cross-platform package to support M1 chips using the following command:
|
||||
|
||||
```shell
|
||||
rustup target add aarch64-apple-darwin
|
||||
```
|
||||
|
||||
- For M1 chip users, install the x86 cross-platform package to support Intel chips using the following command:
|
||||
|
||||
```shell
|
||||
rustup target add x86_64-apple-darwin
|
||||
```
|
||||
|
||||
##### Usage
|
||||
|
||||
```shell
|
||||
--multi-arch
|
||||
```
|
||||
|
||||
#### [targets]
|
||||
|
||||
Specify the build target architecture or format:
|
||||
|
||||
- **Linux**: `deb`, `appimage`, `deb-arm64`, `appimage-arm64` (default: `deb`)
|
||||
- **Windows**: `x64`, `arm64` (auto-detects if not specified)
|
||||
- **macOS**: `intel`, `apple`, `universal` (auto-detects if not specified)
|
||||
|
||||
```shell
|
||||
--targets <target>
|
||||
|
||||
# Examples:
|
||||
--targets arm64 # Windows ARM64
|
||||
--targets x64 # Windows x64
|
||||
--targets universal # macOS Universal (Intel + Apple Silicon)
|
||||
--targets apple # macOS Apple Silicon only
|
||||
--targets intel # macOS Intel only
|
||||
--targets deb # Linux DEB package (x64)
|
||||
--targets rpm # Linux RPM package (x64)
|
||||
--targets appimage # Linux AppImage (x64)
|
||||
--targets deb-arm64 # Linux DEB package (ARM64)
|
||||
--targets rpm-arm64 # Linux RPM package (ARM64)
|
||||
--targets appimage-arm64 # Linux AppImage (ARM64)
|
||||
```
|
||||
|
||||
**Note for Linux ARM64**:
|
||||
|
||||
- Cross-compilation requires additional setup. Install `gcc-aarch64-linux-gnu` and configure environment variables for cross-compilation.
|
||||
- ARM64 support enables Pake apps to run on ARM-based Linux devices, including Linux phones (postmarketOS, Ubuntu Touch), Raspberry Pi, and other ARM64 Linux systems.
|
||||
- Use `--target appimage-arm64` for portable ARM64 applications that work across different ARM64 Linux distributions.
|
||||
|
||||
#### [user-agent]
|
||||
|
||||
Customize the browser user agent. Default is empty.
|
||||
|
||||
```shell
|
||||
--user-agent <string>
|
||||
```
|
||||
|
||||
#### [show-system-tray]
|
||||
|
||||
Display the application in system tray. Default is `false`.
|
||||
|
||||
```shell
|
||||
--show-system-tray
|
||||
```
|
||||
|
||||
#### [system-tray-icon]
|
||||
|
||||
Specify the system tray icon. This is only effective when the system tray is enabled. The icon must be in `.ico` or `.png` format and should be an image with dimensions ranging from 32x32 to 256x256 pixels.
|
||||
|
||||
```shell
|
||||
--system-tray-icon <path>
|
||||
```
|
||||
|
||||
#### [hide-on-close]
|
||||
|
||||
Hide window instead of closing the application when clicking close button. Default is `true`.
|
||||
|
||||
```shell
|
||||
--hide-on-close
|
||||
```
|
||||
|
||||
#### [title]
|
||||
|
||||
Set the window title bar text. If not specified, the window title will be empty.
|
||||
|
||||
```shell
|
||||
--title <string>
|
||||
|
||||
# Examples:
|
||||
--title "My Application"
|
||||
--title "Google Translate"
|
||||
```
|
||||
|
||||
#### [incognito]
|
||||
|
||||
Launch the application in incognito/private browsing mode. Default is `false`. When enabled, the webview will run in private mode, which means it won't store cookies, local storage, or browsing history. This is useful for privacy-sensitive applications.
|
||||
|
||||
```shell
|
||||
--incognito
|
||||
```
|
||||
|
||||
#### [wasm]
|
||||
|
||||
Enable WebAssembly support with cross-origin isolation headers. Required for Flutter Web applications and other web applications that use WebAssembly modules like `sqlite3.wasm`, `canvaskit.wasm`. Default is `false`.
|
||||
|
||||
This option adds necessary HTTP headers (`Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`) and browser flags to enable SharedArrayBuffer and WebAssembly features.
|
||||
|
||||
```shell
|
||||
--wasm
|
||||
|
||||
# Example: Package a Flutter Web app with WASM support
|
||||
pake https://flutter.dev --name FlutterApp --wasm
|
||||
```
|
||||
|
||||
#### [installer-language]
|
||||
|
||||
Set the Windows Installer language. Options include `zh-CN`, `ja-JP`, More at [Tauri Document](https://tauri.app/distribute/windows-installer/#internationalization). Default is `en-US`.
|
||||
|
||||
```shell
|
||||
--installer-language <language>
|
||||
```
|
||||
|
||||
#### [use-local-file]
|
||||
|
||||
Enable recursive copying. When the URL is a local file path, enabling this option will copy the folder containing the file specified in the URL, as well as all sub-files, to the Pake static folder. This is disabled by default.
|
||||
|
||||
```shell
|
||||
--use-local-file
|
||||
|
||||
# Basic static file packaging
|
||||
pake ./my-app/index.html --name "my-app" --use-local-file
|
||||
```
|
||||
|
||||
#### [inject]
|
||||
|
||||
Using `inject`, you can inject local absolute and relative path `css` and `js` files into the page you specify the `url` to customize it. For example, an adblock script that can be applied to any web page, or a `css` that optimizes the `UI` of a page, you can write it once to customize it. would only need to write the `app` once to generalize it to any other page.
|
||||
|
||||
Supports both comma-separated and multiple option formats:
|
||||
|
||||
```shell
|
||||
# Comma-separated (recommended)
|
||||
--inject ./tools/style.css,./tools/hotkey.js
|
||||
|
||||
# Multiple options
|
||||
--inject ./tools/style.css --inject ./tools/hotkey.js
|
||||
|
||||
# Single file
|
||||
--inject ./tools/style.css
|
||||
```
|
||||
|
||||
#### [proxy-url]
|
||||
|
||||
Set proxy server for all network requests. Supports HTTP, HTTPS, and SOCKS5. Available on Windows and Linux. On macOS, requires macOS 14+.
|
||||
|
||||
```shell
|
||||
--proxy-url http://127.0.0.1:7890
|
||||
--proxy-url socks5://127.0.0.1:7891
|
||||
```
|
||||
|
||||
#### [debug]
|
||||
|
||||
Enable developer tools and detailed logging for debugging.
|
||||
|
||||
```shell
|
||||
--debug
|
||||
```
|
||||
|
||||
### Packaging Complete
|
||||
|
||||
After completing the above steps, your application should be successfully packaged. Please note that the packaging process may take some time depending on your system configuration and network conditions. Be patient, and once the packaging is complete, you can find the application installer in the specified directory.
|
||||
|
||||
## Development
|
||||
|
||||
The `DEFAULT_DEV_PAKE_OPTIONS` configuration in `bin/defaults.ts` can be modified at development time to match the `pake-cli` configuration description.
|
||||
|
||||
```typescript
|
||||
export const DEFAULT_DEV_PAKE_OPTIONS: PakeCliOptions & { url: string } = {
|
||||
...DEFAULT_PAKE_OPTIONS,
|
||||
url: "https://weekly.tw93.fun/",
|
||||
name: "Weekly",
|
||||
};
|
||||
```
|
||||
|
||||
then
|
||||
|
||||
```bash
|
||||
pnpm run cli:dev
|
||||
```
|
||||
|
||||
The script will read the above configuration and packages the specified `app` using `watch` mode, and changes to the `pake-cli` code and `pake` are hot updated in real time.
|
||||
|
||||
## Docker
|
||||
|
||||
```shell
|
||||
# On Linux, you can run the Pake CLI via Docker
|
||||
docker run -it --rm \ # Run interactively, remove container after exit
|
||||
-v YOUR_DIR:/output \ # Files from container's /output will be in YOU_DIR
|
||||
ghcr.io/tw93/pake \
|
||||
<arguments>
|
||||
|
||||
# For example:
|
||||
docker run -it --rm \
|
||||
-v ./packages:/output \
|
||||
ghcr.io/tw93/pake \
|
||||
https://example.com --name myapp --icon ./icon.png
|
||||
|
||||
```
|
||||
426
docs/cli-usage_CN.md
Normal file
426
docs/cli-usage_CN.md
Normal file
@@ -0,0 +1,426 @@
|
||||
<h4 align="right"><strong><a href="cli-usage.md">English</a></strong> | 简体中文</h4>
|
||||
|
||||
## 安装
|
||||
|
||||
请确保您的 Node.js 版本为 22 或更高版本(例如 22.11.0)。_注意:较旧的版本 ≥18.0.0 也可能可以工作。_
|
||||
|
||||
**推荐方式 (pnpm):**
|
||||
|
||||
```bash
|
||||
pnpm install -g pake-cli
|
||||
```
|
||||
|
||||
**备选方式 (npm):**
|
||||
|
||||
```bash
|
||||
npm install -g pake-cli
|
||||
```
|
||||
|
||||
**如果遇到权限问题:**
|
||||
|
||||
```bash
|
||||
# 使用 npx 运行,无需全局安装
|
||||
npx pake-cli [url] [选项]
|
||||
|
||||
# 或者永久修复 npm 权限
|
||||
npm config set prefix ~/.npm-global
|
||||
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary><strong>Windows/Linux 注意事项</strong></summary>
|
||||
|
||||
- **非常重要**:请参阅 Tauri 的 [依赖项指南](https://tauri.app/start/prerequisites/)。
|
||||
- 对于 Windows 用户,请确保至少安装了 `Win10 SDK(10.0.19041.0)` 和 `Visual Studio Build Tools 2022(版本 17.2 或更高)`,此外还需要安装以下组件:
|
||||
1. Microsoft Visual C++ 2015-2022 Redistributable (x64)
|
||||
2. Microsoft Visual C++ 2015-2022 Redistributable (x86)
|
||||
3. Microsoft Visual C++ 2012 Redistributable (x86)(可选)
|
||||
4. Microsoft Visual C++ 2013 Redistributable (x86)(可选)
|
||||
5. Microsoft Visual C++ 2008 Redistributable (x86)(可选)
|
||||
|
||||
**Windows ARM(ARM64)支持**:在 Visual Studio Installer 中的"单个组件"下安装"MSVC v143 - VS 2022 C++ ARM64 构建工具"。系统会自动检测 ARM64 架构并构建原生 ARM64 二进制文件。
|
||||
|
||||
- 对于 Ubuntu 用户,在开始之前,建议运行以下命令以安装所需的依赖项:
|
||||
|
||||
```bash
|
||||
sudo apt install libdbus-1-dev \
|
||||
libsoup-3.0-dev \
|
||||
libjavascriptcoregtk-4.1-dev \
|
||||
libwebkit2gtk-4.1-dev \
|
||||
build-essential \
|
||||
curl \
|
||||
wget \
|
||||
libssl-dev \
|
||||
libgtk-3-dev \
|
||||
libayatana-appindicator3-dev \
|
||||
librsvg2-dev \
|
||||
gnome-video-effects \
|
||||
gnome-video-effects-extra
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## 快速开始
|
||||
|
||||
```bash
|
||||
# 基础用法 - 只需要提供URL
|
||||
pake https://weekly.tw93.fun --name "Weekly"
|
||||
|
||||
# 自定义图标和窗口大小(macOS示例)
|
||||
pake https://weekly.tw93.fun --name "Weekly" --icon https://cdn.tw93.fun/pake/weekly.icns --width 1200 --height 800
|
||||
|
||||
# macOS 沉浸式体验
|
||||
pake https://weekly.tw93.fun --name "Weekly" --hide-title-bar
|
||||
```
|
||||
|
||||
## 命令行使用
|
||||
|
||||
```bash
|
||||
pake [url] [options]
|
||||
```
|
||||
|
||||
应用程序的打包结果将默认保存在当前工作目录。由于首次打包需要配置环境,这可能需要一些时间,请耐心等待。
|
||||
|
||||
> **macOS 输出**:在 macOS 上,Pake 默认创建 DMG 安装程序。如需创建 `.app` 包进行测试(避免用户交互),请设置环境变量 `PAKE_CREATE_APP=1`。
|
||||
>
|
||||
> **注意**:打包过程需要使用 `Rust` 环境。如果您没有安装 `Rust`,系统会提示您是否要安装。如果遇到安装失败或超时的问题,您可以 [手动安装](https://www.rust-lang.org/tools/install)。
|
||||
|
||||
### [url]
|
||||
|
||||
`url` 是您需要打包的网页链接 🔗 或本地 HTML 文件的路径,此参数为必填。
|
||||
|
||||
### [options]
|
||||
|
||||
您可以通过传递以下选项来定制打包过程。以下是最常用的选项:
|
||||
|
||||
| 选项 | 描述 | 示例 |
|
||||
| ------------------ | ------------------------ | ---------------------------------------------- |
|
||||
| `--name` | 应用程序名称 | `--name "Weekly"` |
|
||||
| `--icon` | 应用程序图标 | `--icon https://cdn.tw93.fun/pake/weekly.icns` |
|
||||
| `--width` | 窗口宽度(默认:1200px) | `--width 1400` |
|
||||
| `--height` | 窗口高度(默认:780px) | `--height 900` |
|
||||
| `--hide-title-bar` | 沉浸式标题栏(仅macOS) | `--hide-title-bar` |
|
||||
| `--debug` | 启用开发者工具 | `--debug` |
|
||||
|
||||
完整选项请参见下面的详细说明:
|
||||
|
||||
#### [name]
|
||||
|
||||
指定应用程序的名称,如果未指定,系统会提示您输入,建议使用英文单词。
|
||||
|
||||
**注意**: 支持带空格的名称,会自动处理不同平台的命名规范:
|
||||
|
||||
- **Windows/macOS**: 保持空格和大小写(如 `"Google Translate"`)
|
||||
- **Linux**: 自动转换为小写并用连字符连接(如 `"google-translate"`)
|
||||
|
||||
```shell
|
||||
--name <string>
|
||||
--name MyApp
|
||||
|
||||
# 带空格的名称:
|
||||
--name "Google Translate"
|
||||
```
|
||||
|
||||
#### [icon]
|
||||
|
||||
指定应用程序的图标,支持本地或远程文件,不传此参数时,Pake 会智能获取网站图标。自定义图标可访问 [icon-icons](https://icon-icons.com) 或 [macOSicons](https://macosicons.com/#/) 下载。
|
||||
|
||||
- macOS 要求使用 `.icns` 格式。
|
||||
- Windows 要求使用 `.ico` 格式。
|
||||
- Linux 要求使用 `.png` 格式。
|
||||
|
||||
```shell
|
||||
--icon <path>
|
||||
|
||||
# 示例:
|
||||
--icon ./my-icon.png
|
||||
--icon https://cdn.tw93.fun/pake/weekly.icns # 远程图标(.icns适用于macOS)
|
||||
```
|
||||
|
||||
#### [height]
|
||||
|
||||
设置应用窗口的高度,默认为 `780px`。
|
||||
|
||||
```shell
|
||||
--height <number>
|
||||
```
|
||||
|
||||
#### [width]
|
||||
|
||||
设置应用窗口的宽度,默认为 `1200px`。
|
||||
|
||||
```shell
|
||||
--width <number>
|
||||
```
|
||||
|
||||
#### [hide-title-bar]
|
||||
|
||||
设置是否启用沉浸式头部,默认为 `false`(不启用)。当前只对 macOS 上有效。
|
||||
|
||||
```shell
|
||||
--hide-title-bar
|
||||
```
|
||||
|
||||
#### [fullscreen]
|
||||
|
||||
设置应用程序是否在启动时自动全屏,默认为 `false`。使用以下命令可以设置应用程序启动时自动全屏。
|
||||
|
||||
```shell
|
||||
--fullscreen
|
||||
```
|
||||
|
||||
#### [activation-shortcut]
|
||||
|
||||
设置应用程序的激活快捷键。默认为空,不生效,可以使用以下命令自定义激活快捷键,例如 `CmdOrControl+Shift+P`,使用可参考 [available-modifiers](https://www.electronjs.org/docs/latest/api/accelerator#available-modifiers)。
|
||||
|
||||
```shell
|
||||
--activation-shortcut <string>
|
||||
```
|
||||
|
||||
#### [always-on-top]
|
||||
|
||||
设置是否窗口一直在最顶层,默认为 `false`。
|
||||
|
||||
```shell
|
||||
--always-on-top
|
||||
```
|
||||
|
||||
#### [app-version]
|
||||
|
||||
设置打包应用的版本号,和 package.json 里面 version 命名格式一致,默认为 `1.0.0`。
|
||||
|
||||
```shell
|
||||
--app-version <string>
|
||||
```
|
||||
|
||||
#### [dark-mode]
|
||||
|
||||
强制 Mac 打包应用使用黑暗模式,默认为 `false`。
|
||||
|
||||
```shell
|
||||
--dark-mode
|
||||
```
|
||||
|
||||
#### [disabled-web-shortcuts]
|
||||
|
||||
设置是否禁用原有 Pake 容器里面的网页操作快捷键,默认为 `false`。
|
||||
|
||||
```shell
|
||||
--disabled-web-shortcuts
|
||||
```
|
||||
|
||||
#### [multi-arch]
|
||||
|
||||
设置打包结果同时支持 Intel 和 M1 芯片,仅适用于 macOS,默认为 `false`。
|
||||
|
||||
##### 准备工作
|
||||
|
||||
- 注意:启用此选项后,需要使用 rust 官网的 rustup 安装 rust,不支持通过 brew 安装。
|
||||
- 对于 Intel 芯片用户,需要安装 arm64 跨平台包,以使安装包支持 M1 芯片。使用以下命令安装:
|
||||
|
||||
```shell
|
||||
rustup target add aarch64-apple-darwin
|
||||
```
|
||||
|
||||
- 对于 M1 芯片用户,需要安装 x86 跨平台包,以使安装包支持 Intel 芯片。使用以下命令安装:
|
||||
|
||||
```shell
|
||||
rustup target add x86_64-apple-darwin
|
||||
```
|
||||
|
||||
##### 使用方法
|
||||
|
||||
```shell
|
||||
--multi-arch
|
||||
```
|
||||
|
||||
#### [targets]
|
||||
|
||||
指定构建目标架构或格式:
|
||||
|
||||
- **Linux**: `deb`, `appimage`, `deb-arm64`, `appimage-arm64`(默认:`deb`)
|
||||
- **Windows**: `x64`, `arm64`(未指定时自动检测)
|
||||
- **macOS**: `intel`, `apple`, `universal`(未指定时自动检测)
|
||||
|
||||
```shell
|
||||
--targets <target>
|
||||
|
||||
# 示例:
|
||||
--targets arm64 # Windows ARM64
|
||||
--targets x64 # Windows x64
|
||||
--targets universal # macOS 通用版本(Intel + Apple Silicon)
|
||||
--targets apple # 仅 macOS Apple Silicon
|
||||
--targets intel # 仅 macOS Intel
|
||||
--targets deb # Linux DEB 包(x64)
|
||||
--targets rpm # Linux RPM 包(x64)
|
||||
--targets appimage # Linux AppImage(x64)
|
||||
--targets deb-arm64 # Linux DEB 包(ARM64)
|
||||
--targets rpm-arm64 # Linux RPM 包(ARM64)
|
||||
--targets appimage-arm64 # Linux AppImage(ARM64)
|
||||
```
|
||||
|
||||
**Linux ARM64 注意事项**:
|
||||
|
||||
- 交叉编译需要额外设置。需要安装 `gcc-aarch64-linux-gnu` 并配置交叉编译环境变量。
|
||||
- ARM64 支持让 Pake 应用可以在基于 ARM 的 Linux 设备上运行,包括 Linux 手机(postmarketOS、Ubuntu Touch)、树莓派和其他 ARM64 Linux 系统。
|
||||
- 使用 `--target appimage-arm64` 可以创建便携式 ARM64 应用,在不同的 ARM64 Linux 发行版上运行。
|
||||
|
||||
#### [user-agent]
|
||||
|
||||
自定义浏览器的用户代理请求头,默认为空。
|
||||
|
||||
```shell
|
||||
--user-agent <string>
|
||||
```
|
||||
|
||||
#### [show-system-tray]
|
||||
|
||||
设置应用程序显示在系统托盘,默认为 `false`。
|
||||
|
||||
```shell
|
||||
--show-system-tray
|
||||
```
|
||||
|
||||
#### [system-tray-icon]
|
||||
|
||||
设置通知栏托盘图标,仅在启用通知栏托盘时有效。图标必须为 `.ico` 或 `.png` 格式,分辨率为 32x32 到 256x256 像素。
|
||||
|
||||
```shell
|
||||
--system-tray-icon <path>
|
||||
```
|
||||
|
||||
#### [hide-on-close]
|
||||
|
||||
点击关闭按钮时隐藏窗口而不是退出应用程序。默认为 `true`。
|
||||
|
||||
```shell
|
||||
--hide-on-close
|
||||
```
|
||||
|
||||
#### [incognito]
|
||||
|
||||
以隐私/隐身浏览模式启动应用程序。默认为 `false`。启用后,webview 将在隐私模式下运行,这意味着它不会存储 cookie、本地存储或浏览历史记录。这对于注重隐私的应用程序很有用。
|
||||
|
||||
```shell
|
||||
--incognito
|
||||
```
|
||||
|
||||
#### [wasm]
|
||||
|
||||
启用 WebAssembly 支持,添加跨域隔离头部,适用于 Flutter Web 应用以及其他使用 WebAssembly 模块(如 `sqlite3.wasm`、`canvaskit.wasm`)的 Web 应用,默认为 `false`。
|
||||
|
||||
此选项会添加必要的 HTTP 头部(`Cross-Origin-Opener-Policy: same-origin` 和 `Cross-Origin-Embedder-Policy: require-corp`)以及浏览器标志,以启用 SharedArrayBuffer 和 WebAssembly 功能。
|
||||
|
||||
```shell
|
||||
--wasm
|
||||
|
||||
# 示例:打包支持 WASM 的 Flutter Web 应用
|
||||
pake https://flutter.dev --name FlutterApp --wasm
|
||||
```
|
||||
|
||||
#### [title]
|
||||
|
||||
设置窗口标题栏文本。如果未指定,窗口标题将为空。
|
||||
|
||||
```shell
|
||||
--title <string>
|
||||
|
||||
# 示例:
|
||||
--title "我的应用"
|
||||
--title "音乐播放器"
|
||||
```
|
||||
|
||||
#### [installer-language]
|
||||
|
||||
设置 Windows 安装包语言。支持 `zh-CN`、`ja-JP`,更多在 [Tauri 文档](https://tauri.app/distribute/windows-installer/#internationalization)。默认为 `en-US`。
|
||||
|
||||
```shell
|
||||
--installer-language <language>
|
||||
```
|
||||
|
||||
#### [use-local-file]
|
||||
|
||||
当 `url` 为本地文件路径时,如果启用此选项,则会递归地将 `url` 路径文件所在的文件夹及其所有子文件复制到 Pake 的静态文件夹。默认不启用。
|
||||
|
||||
```shell
|
||||
--use-local-file
|
||||
|
||||
# 基础静态文件打包
|
||||
pake ./my-app/index.html --name "my-app" --use-local-file
|
||||
```
|
||||
|
||||
#### [inject]
|
||||
|
||||
使用 `inject` 可以通过本地的绝对、相对路径的 `css` `js` 文件注入到你所指定 `url` 的页面中,从而为其做定制化改造。举个例子:一段可以通用到任何网页的广告屏蔽脚本,或者是优化页面 `UI` 展示的 `css`,你只需要书写一次可以将其通用到任何其他网页打包的 `app`。
|
||||
|
||||
支持逗号分隔和多个选项两种格式:
|
||||
|
||||
```shell
|
||||
# 逗号分隔(推荐)
|
||||
--inject ./tools/style.css,./tools/hotkey.js
|
||||
|
||||
# 多个选项
|
||||
--inject ./tools/style.css --inject ./tools/hotkey.js
|
||||
|
||||
# 单个文件
|
||||
--inject ./tools/style.css
|
||||
```
|
||||
|
||||
#### [proxy-url]
|
||||
|
||||
为所有网络请求设置代理服务器。支持 HTTP、HTTPS 和 SOCKS5。在 Windows 和 Linux 上可用。在 macOS 上需要 macOS 14+。
|
||||
|
||||
```shell
|
||||
--proxy-url http://127.0.0.1:7890
|
||||
--proxy-url socks5://127.0.0.1:7891
|
||||
```
|
||||
|
||||
#### [debug]
|
||||
|
||||
启用开发者工具和详细日志输出,用于调试。
|
||||
|
||||
```shell
|
||||
--debug
|
||||
```
|
||||
|
||||
### 打包完成
|
||||
|
||||
完成上述步骤后,您的应用程序应该已经成功打包。请注意,根据您的系统配置和网络状况,打包过程可能需要一些时间。请耐心等待,一旦打包完成,您就可以在指定的目录中找到应用程序安装包。
|
||||
|
||||
## 开发调试
|
||||
|
||||
开发时可以修改 `bin/defaults.ts` 中 `DEFAULT_DEV_PAKE_OPTIONS` 配置,配置项和 `pake-cli` 配置说明保持一致
|
||||
|
||||
```typescript
|
||||
export const DEFAULT_DEV_PAKE_OPTIONS: PakeCliOptions & { url: string } = {
|
||||
...DEFAULT_PAKE_OPTIONS,
|
||||
url: "https://weekly.tw93.fun/",
|
||||
name: "Weekly",
|
||||
};
|
||||
```
|
||||
|
||||
之后运行
|
||||
|
||||
```bash
|
||||
pnpm run cli:dev
|
||||
```
|
||||
|
||||
脚本会读取上述配置并使用 `watch` 模式打包指定的 `app`,对 `pake-cli` 代码和 `pake` 的修改都会实时热更新。
|
||||
|
||||
## Docker 使用
|
||||
|
||||
```shell
|
||||
# 在Linux上,您可以通过 Docker 运行 Pake CLI。
|
||||
docker run -it --rm \ # Run interactively, remove container after exit
|
||||
-v YOUR_DIR:/output \ # Files from container's /output will be in YOU_DIR
|
||||
ghcr.io/tw93/pake \
|
||||
<arguments>
|
||||
|
||||
# For example:
|
||||
docker run -it --rm \
|
||||
-v ./packages:/output \
|
||||
ghcr.io/tw93/pake \
|
||||
https://example.com --name myapp --icon ./icon.png
|
||||
|
||||
```
|
||||
97
docs/github-action.md
Normal file
97
docs/github-action.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# Pake GitHub Action
|
||||
|
||||
Transform any webpage into a lightweight desktop app with a single GitHub Actions step.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```yaml
|
||||
- name: Build Pake App
|
||||
uses: tw93/Pake@v3
|
||||
with:
|
||||
url: "https://example.com"
|
||||
name: "MyApp"
|
||||
```
|
||||
|
||||
## Inputs
|
||||
|
||||
| Parameter | Description | Required | Default |
|
||||
| ------------ | ------------------------ | -------- | ------- |
|
||||
| `url` | Target URL to package | ✅ | |
|
||||
| `name` | Application name | ✅ | |
|
||||
| `output-dir` | Output directory | | `dist` |
|
||||
| `icon` | Custom app icon URL/path | | |
|
||||
| `width` | Window width | | `1200` |
|
||||
| `height` | Window height | | `780` |
|
||||
| `debug` | Enable debug mode | | `false` |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Output | Description |
|
||||
| -------------- | ----------------------------- |
|
||||
| `package-path` | Path to the generated package |
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```yaml
|
||||
name: Build Web App
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: tw93/Pake@v3
|
||||
with:
|
||||
url: "https://weekly.tw93.fun"
|
||||
name: "WeeklyApp"
|
||||
```
|
||||
|
||||
### With Custom Icon
|
||||
|
||||
```yaml
|
||||
- uses: tw93/Pake@v3
|
||||
with:
|
||||
url: "https://example.com"
|
||||
name: "MyApp"
|
||||
icon: "https://example.com/icon.png"
|
||||
width: 1400
|
||||
height: 900
|
||||
```
|
||||
|
||||
### Multi-Platform Build
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: tw93/Pake@v3
|
||||
with:
|
||||
url: "https://example.com"
|
||||
name: "CrossPlatformApp"
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
1. **Auto Setup**: Installs Rust, Node.js dependencies, builds Pake CLI
|
||||
2. **Build App**: Runs `pake` command with your parameters
|
||||
3. **Package Output**: Finds and moves the generated package to output directory
|
||||
|
||||
## Supported Platforms
|
||||
|
||||
- **Linux**: `.deb` packages (Ubuntu runners)
|
||||
- **macOS**: `.app` and `.dmg` packages (macOS runners)
|
||||
- **Windows**: `.exe` and `.msi` packages (Windows runners)
|
||||
|
||||
Use GitHub's matrix strategy to build for multiple platforms simultaneously.
|
||||
|
||||
## Testing
|
||||
|
||||
Try the action with our test workflow: [test-action.yml](.github/workflows/test-action.yml)
|
||||
43
docs/github-actions-usage.md
Normal file
43
docs/github-actions-usage.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# GitHub Actions Usage Guide
|
||||
|
||||
Build Pake apps online without installing development tools locally.
|
||||
|
||||
## Quick Steps
|
||||
|
||||
### 1. Fork Repository
|
||||
|
||||
[Fork this project](https://github.com/tw93/Pake/fork)
|
||||
|
||||
### 2. Run Workflow
|
||||
|
||||
1. Go to Actions tab in your forked repository
|
||||
2. Select `Build App With Pake CLI`
|
||||
3. Fill in the form (same parameters as [CLI options](cli-usage.md))
|
||||
4. Click `Run Workflow`
|
||||
|
||||

|
||||
|
||||
### 3. Download App
|
||||
|
||||
- Green checkmark = build success
|
||||
- Click the workflow name to view details
|
||||
- Find `Artifacts` section and download your app
|
||||
|
||||

|
||||
|
||||
### 4. Build Times
|
||||
|
||||
- **First run**: ~10-15 minutes (sets up cache)
|
||||
- **Subsequent runs**: ~5 minutes (uses cache)
|
||||
- Cache size: 400-600MB when complete
|
||||
|
||||
## Tips
|
||||
|
||||
- Be patient on first run - let cache build completely
|
||||
- Stable network connection recommended
|
||||
- If build fails, delete cache and retry
|
||||
|
||||
## Links
|
||||
|
||||
- [CLI Documentation](cli-usage.md)
|
||||
- [Advanced Usage](advanced-usage.md)
|
||||
43
docs/github-actions-usage_CN.md
Normal file
43
docs/github-actions-usage_CN.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# GitHub Actions 使用指南
|
||||
|
||||
无需本地安装开发工具,在线构建 Pake 应用。
|
||||
|
||||
## 快速步骤
|
||||
|
||||
### 1. Fork 仓库
|
||||
|
||||
[Fork 此项目](https://github.com/tw93/Pake/fork)
|
||||
|
||||
### 2. 运行工作流
|
||||
|
||||
1. 前往你 Fork 的仓库的 Actions 页面
|
||||
2. 选择 `Build App With Pake CLI`
|
||||
3. 填写表单(参数与 [CLI 选项](cli-usage_CN.md) 相同)
|
||||
4. 点击 `Run Workflow`
|
||||
|
||||

|
||||
|
||||
### 3. 下载应用
|
||||
|
||||
- 绿色勾号 = 构建成功
|
||||
- 点击工作流名称查看详情
|
||||
- 在 `Artifacts` 部分下载应用
|
||||
|
||||

|
||||
|
||||
### 4. 构建时间
|
||||
|
||||
- **首次运行**:约 10-15 分钟(建立缓存)
|
||||
- **后续运行**:约 5 分钟(使用缓存)
|
||||
- 缓存大小:完成时为 400-600MB
|
||||
|
||||
## 提示
|
||||
|
||||
- 首次运行需要耐心等待,让缓存完全建立
|
||||
- 建议网络连接稳定
|
||||
- 如果构建失败,删除缓存后重试
|
||||
|
||||
## 链接
|
||||
|
||||
- [CLI 文档](cli-usage_CN.md)
|
||||
- [高级用法](advanced-usage_CN.md)
|
||||
98
docs/testing.md
Normal file
98
docs/testing.md
Normal file
@@ -0,0 +1,98 @@
|
||||
# Pake CLI 测试
|
||||
|
||||
统一的 CLI 构建测试套件,用于验证多平台打包功能。
|
||||
|
||||
## 运行测试
|
||||
|
||||
```bash
|
||||
# 完整测试套件(推荐)
|
||||
pnpm test # 运行完整测试套件,包含真实构建测试(8-12分钟)
|
||||
|
||||
# 开发时快速测试
|
||||
pnpm test -- --no-build # 跳过构建测试,仅验证核心功能(30秒)
|
||||
```
|
||||
|
||||
### 🚀 完整测试套件包含
|
||||
|
||||
- ✅ **单元测试**:CLI命令、参数验证、响应时间
|
||||
- ✅ **集成测试**:进程管理、文件权限、依赖解析
|
||||
- ✅ **构建器测试**:平台检测、架构检测、文件命名
|
||||
- ✅ **真实构建测试**:完整的GitHub.com应用打包验证
|
||||
|
||||
## 测试内容
|
||||
|
||||
### 单元测试(6个)
|
||||
|
||||
- 版本命令 (`--version`)
|
||||
- 帮助命令 (`--help`)
|
||||
- URL 验证(有效/无效链接)
|
||||
- 参数验证(数字类型检查)
|
||||
- CLI 响应时间(<2秒)
|
||||
- Weekly URL 可访问性
|
||||
|
||||
### 集成测试(3个)
|
||||
|
||||
- 进程生成和管理
|
||||
- 文件系统权限检查
|
||||
- 依赖包解析验证
|
||||
|
||||
### 构建测试(3个)
|
||||
|
||||
- 平台检测(macOS/Windows/Linux)
|
||||
- 架构检测(Intel/ARM64)
|
||||
- 文件命名模式验证
|
||||
|
||||
### 真实构建测试(重点)
|
||||
|
||||
**macOS**: 🔥 多架构构建(通用二进制)
|
||||
|
||||
- 编译 Intel + Apple Silicon 双架构
|
||||
- 检测 `.app` 文件生成:`GitHubMultiArch.app`
|
||||
- 备用检测:`src-tauri/target/universal-apple-darwin/release/bundle/macos/`
|
||||
- 验证通用二进制:`file` 命令检查架构
|
||||
|
||||
**Windows**: 单架构构建
|
||||
|
||||
- 检测 EXE 文件:`src-tauri/target/x86_64-pc-windows-msvc/release/pake.exe`
|
||||
- 检测 MSI 安装包:`src-tauri/target/x86_64-pc-windows-msvc/release/bundle/msi/*.msi`
|
||||
|
||||
**Linux**: 单架构构建
|
||||
|
||||
- 检测 DEB 包:`src-tauri/target/release/bundle/deb/*.deb`
|
||||
- 检测 AppImage:`src-tauri/target/release/bundle/appimage/*.AppImage`
|
||||
|
||||
## 为什么重点测试多架构?
|
||||
|
||||
多架构构建是最复杂、最容易出错的环节:
|
||||
|
||||
- 需要同时编译两个架构(x86_64 + aarch64)
|
||||
- 生成通用二进制文件技术复杂
|
||||
- 架构兼容性问题频发
|
||||
- Apple Silicon 迁移期关键功能
|
||||
|
||||
## 测试结果
|
||||
|
||||
总计:**13 个测试**,全部通过表示 CLI 功能正常。
|
||||
|
||||
## 故障排除
|
||||
|
||||
**CLI 文件不存在**:运行 `pnpm run cli:build`
|
||||
|
||||
**测试超时**:构建测试需要较长时间完成
|
||||
|
||||
**构建失败**:检查 Rust 工具链 `rustup update`
|
||||
|
||||
**权限错误**:确保有写入权限
|
||||
|
||||
## 发布构建测试
|
||||
|
||||
```bash
|
||||
# 实际构建测试(固定测试 weread + twitter 两个应用)
|
||||
node ./tests/release.js
|
||||
```
|
||||
|
||||
真实构建2个应用包,验证完整的打包流程和 release.yml 逻辑是否正常工作。
|
||||
|
||||
## 开发建议
|
||||
|
||||
提交代码前建议运行 `pnpm test` 确保所有平台构建正常。
|
||||
Reference in New Issue
Block a user