Skip to content

Commit 202954d

Browse files
committed
Merge branch 'dev'
2 parents 5258165 + fcf807a commit 202954d

31 files changed

+1671
-553
lines changed

CLAUDE.md

Lines changed: 43 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
99
- **Clear intent over clever code**: Prioritize readability and maintainability
1010
- **Simple over complex**: Keep all implementations simple and straightforward - prioritize solving problems and ease of maintenance over complex solutions
1111

12+
## Claude Code Eight Honors and Eight Shames
13+
14+
- **Shame** in guessing APIs, **Honor** in careful research
15+
- **Shame** in vague execution, **Honor** in seeking confirmation
16+
- **Shame** in assuming business logic, **Honor** in human verification
17+
- **Shame** in creating interfaces, **Honor** in reusing existing ones
18+
- **Shame** in skipping validation, **Honor** in proactive testing
19+
- **Shame** in breaking architecture, **Honor** in following specifications
20+
- **Shame** in pretending to understand, **Honor** in honest ignorance
21+
- **Shame** in blind modification, **Honor** in careful refactoring
22+
1223
## Project Overview
1324

1425
Pake transforms any webpage into a lightweight desktop app using Rust and Tauri. It's significantly lighter than Electron (~5M vs ~100M+) with better performance.
@@ -21,146 +32,43 @@ Pake transforms any webpage into a lightweight desktop app using Rust and Tauri.
2132

2233
## Development Workflow
2334

24-
### 1. Planning Phase
25-
26-
Break complex work into 3-5 stages:
35+
1. **Understand**: Study existing patterns in codebase
36+
2. **Plan**: Break complex work into 3-5 stages
37+
3. **Test**: Write tests first (when applicable)
38+
4. **Implement**: Minimal working solution
39+
5. **Refactor**: Optimize and clean up
2740

28-
1. Understand existing patterns in codebase
29-
2. Plan implementation approach
30-
3. Write tests first (when applicable)
31-
4. Implement minimal working solution
32-
5. Refactor and optimize
33-
34-
### 2. Implementation Flow
35-
36-
**Understanding First:**
41+
**Key Commands:**
3742

3843
```bash
39-
# Explore codebase structure
40-
find src-tauri/src -name "*.rs" | head -10
41-
grep -r "window_config" src-tauri/src/
44+
pnpm test # Run comprehensive test suite
45+
pnpm run cli:build # Build CLI for testing
46+
pnpm run dev # Development with hot reload
4247
```
4348

44-
**Development Commands:**
45-
46-
```bash
47-
# Install dependencies
48-
pnpm i
49-
50-
# Development with hot reload (for testing app functionality)
51-
pnpm run dev
52-
53-
# CLI development
54-
pnpm run cli:dev
55-
56-
# Production build
57-
pnpm run build
58-
```
59-
60-
### 3. Testing and Validation
61-
62-
**Key Testing Commands:**
63-
64-
```bash
65-
# Run comprehensive test suite (unit + integration + builder)
66-
pnpm test
67-
68-
# Build CLI for testing
69-
pnpm run cli:build
70-
71-
# Debug build for development
72-
pnpm run build:debug
73-
74-
# Multi-platform testing
75-
pnpm run build:mac # macOS universal build
76-
```
77-
78-
**Testing Checklist:**
79-
80-
- [ ] Run `npm test` for comprehensive validation (35 tests)
81-
- [ ] Test on target platforms
82-
- [ ] Verify injection system works
83-
- [ ] Check system tray integration
84-
- [ ] Validate window behavior
85-
- [ ] Test with weekly.tw93.fun URL
86-
- [ ] Verify remote icon functionality (https://cdn.tw93.fun/pake/weekly.icns)
49+
**Testing:**
8750

88-
**Testing Notes:**
89-
90-
- Do NOT use `PAKE_NO_CONFIG_OVERWRITE=1` - this environment variable is not implemented
51+
- Always run `pnpm test` before committing
9152
- For CLI testing: `node dist/cli.js https://example.com --name TestApp --debug`
92-
- **For app functionality testing**: Use `pnpm run dev` to start development server with hot reload. This allows real-time testing of injected JavaScript changes without rebuilding the entire app.
93-
- The dev server automatically reloads when you modify files in `src-tauri/src/inject/` directory
53+
- For app functionality testing: Use `pnpm run dev` for hot reload
9454

9555
## Core Components
9656

97-
### CLI Tool (`bin/`)
98-
99-
- `bin/cli.ts` - Main entry point with Commander.js
100-
- `bin/builders/` - Platform-specific builders (Mac, Windows, Linux)
101-
- `bin/options/` - CLI option processing and validation
102-
- `bin/helpers/merge.ts` - Configuration merging (name setting at line 55)
103-
104-
### Tauri Application (`src-tauri/`)
105-
106-
- `src/lib.rs` - Application entry point
107-
- `src/app/` - Core modules (window, tray, shortcuts)
108-
- `src/inject/` - Web page injection logic
57+
- **CLI Tool** (`bin/`): Main entry point, builders, options processing
58+
- **Tauri App** (`src-tauri/`): Rust application, window/tray management, injection logic
59+
- **Config Files**: `pake.json`, `tauri.conf.json`, platform-specific configs
10960

11061
## Documentation Guidelines
11162

112-
- **Main README**: Only include common, frequently-used parameters to avoid clutter
113-
- **CLI Documentation** (`docs/cli-usage.md`): Include ALL parameters with detailed usage examples
114-
- **Rare/Advanced Parameters**: Should have full documentation in CLI docs but minimal/no mention in main README
115-
- **Examples of rare parameters**: `--title`, `--incognito`, `--system-tray-icon`, etc.
116-
117-
### Key Configuration Files
118-
119-
- `pake.json` - App configuration
120-
- `tauri.conf.json` - Tauri settings
121-
- Platform configs: `tauri.{macos,windows,linux}.conf.json`
122-
123-
## Problem-Solving Approach
124-
125-
**When stuck:**
126-
127-
1. **Limit attempts to 3** before stopping to reassess
128-
2. **Document what doesn't work** and why
129-
3. **Research alternative approaches** in similar projects
130-
4. **Question assumptions** - is there a simpler way?
131-
132-
**Example debugging flow:**
133-
134-
```bash
135-
# 1. Check logs
136-
pnpm run dev 2>&1 | grep -i error
137-
138-
# 2. Verify dependencies
139-
cargo check --manifest-path=src-tauri/Cargo.toml
140-
141-
# 3. Test minimal reproduction
142-
# Create simple test case isolating the issue
143-
```
144-
145-
## Platform-Specific Development
146-
147-
### macOS
148-
149-
- Universal builds: `--multi-arch` flag
150-
- Uses `.icns` icons
151-
- Title bar customization available
152-
153-
### Windows
154-
155-
- Requires Visual Studio Build Tools
156-
- Uses `.ico` icons
157-
- MSI installer support
63+
- **Main README**: Common parameters only
64+
- **CLI Documentation** (`docs/cli-usage.md`): ALL parameters with examples
65+
- **Rare parameters**: Full docs in CLI usage, minimal in main README
15866

159-
### Linux
67+
## Platform Specifics
16068

161-
- Multiple formats: deb, AppImage, rpm
162-
- Requires `libwebkit2gtk` and dependencies
163-
- Uses `.png` icons
69+
- **macOS**: `.icns` icons, universal builds with `--multi-arch`
70+
- **Windows**: `.ico` icons, requires Visual Studio Build Tools
71+
- **Linux**: `.png` icons, multiple formats (deb, AppImage, rpm)
16472

16573
## Quality Standards
16674

@@ -170,15 +78,15 @@ cargo check --manifest-path=src-tauri/Cargo.toml
17078
- Use explicit types over implicit
17179
- Write self-documenting code
17280
- Follow existing patterns consistently
81+
- **NO Chinese comments** - Use English only
82+
- **NO unnecessary comments** - For simple, obvious code, let the code speak for itself
17383

174-
**Git and Commit Guidelines:**
84+
**Git Guidelines:**
17585

176-
- **NEVER commit code automatically** - User handles all git operations
177-
- **NEVER generate commit messages** - User writes their own commit messages
178-
- **NEVER run npm publish automatically** - Always remind user to run it manually
179-
- **NEVER execute git tag or push operations** - User handles all tag creation and GitHub pushes
180-
- Only make code changes, user decides when and how to commit
181-
- Test before user commits
86+
- **NEVER commit automatically** - User handles all git operations
87+
- **NEVER generate commit messages** - User writes their own
88+
- Only make code changes, user decides when/how to commit
89+
- Always test before user commits
18290

18391
## Branch Strategy
18492

@@ -187,6 +95,6 @@ cargo check --manifest-path=src-tauri/Cargo.toml
18795

18896
## Prerequisites
18997

190-
- Node.js ≥22.0.0 (recommended LTS, older versions ≥18.0.0 may work)
191-
- Rust ≥1.89.0 (recommended stable, older versions ≥1.78.0 may work)
192-
- Platform build tools (see CONTRIBUTING.md for details)
98+
- Node.js ≥22.0.0 (≥18.0.0 may work)
99+
- Rust ≥1.89.0 (≥1.78.0 may work)
100+
- Platform build tools (see CONTRIBUTING.md)

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,18 @@ If you're running macOS 26 Beta and encounter compilation errors related to `mac
7070
[env]
7171
# Fix for macOS 26 Beta compatibility issues
7272
# Forces use of compatible SDK when building on macOS 26 Beta
73-
MACOSX_DEPLOYMENT_TARGET = "15.5"
74-
SDKROOT = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk"
73+
MACOSX_DEPLOYMENT_TARGET = "15.0"
74+
SDKROOT = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
7575
```
7676

7777
This file is already in `.gitignore` and should not be committed to the repository.
7878

79-
**Root Cause**: macOS 26 Beta uses newer system frameworks that aren't yet supported by the current Xcode SDK (15.5). This configuration forces the build to use the compatible SDK version.
79+
**Root Cause**: macOS 26 Beta uses newer system frameworks that aren't yet fully compatible with Tauri's dependencies. This configuration uses the universal SDK symlink which automatically points to your system's available SDK version.
8080

8181
### Common Build Issues
8282

8383
- **Rust compilation errors**: Run `cargo clean` in `src-tauri/` directory
84+
- **`cargo` command not found after installation**: Pake CLI now reloads the Rust environment automatically, but if the issue persists reopen your terminal or run `source ~/.cargo/env` (macOS/Linux) / `call %USERPROFILE%\.cargo\env` (Windows) before retrying
8485
- **Node dependency issues**: Delete `node_modules` and run `pnpm install`
8586
- **Permission errors on macOS**: Run `sudo xcode-select --reset`
8687

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- **Beginners**: Download ready-made [Popular Packages](#popular-packages) or use [Online Building](docs/github-actions-usage.md) with no environment setup required
3030
- **Developers**: Install [CLI Tool](docs/cli-usage.md) for one-command packaging of any website with customizable icons, window settings, and more
3131
- **Advanced Users**: Clone the project locally for [Custom Development](#development), or check [Advanced Usage](docs/advanced-usage.md) for style customization and feature enhancement
32+
- **Troubleshooting**: Check [FAQ](docs/faq.md) for common issues and solutions
3233

3334
## Popular Packages
3435

README_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- **新手用户**:直接下载现成的 [常用包](#常用包下载),或通过 [在线构建](docs/github-actions-usage_CN.md) 无需环境配置即可打包
3030
- **开发者**:安装 [CLI 工具](docs/cli-usage_CN.md) 后一行命令打包任意网站,支持自定义图标、窗口等参数
3131
- **高级用户**:本地克隆项目进行 [定制开发](#定制开发),或查看 [高级用法](docs/advanced-usage_CN.md) 实现样式定制、功能增强
32+
- **遇到问题**:查看 [常见问题](docs/faq_CN.md) 获取常见问题的解决方案
3233

3334
## 常用包下载
3435

bin/builders/BaseBuilder.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import chalk from 'chalk';
44
import prompts from 'prompts';
55

66
import { PakeAppOptions } from '@/types';
7-
import { checkRustInstalled, installRust } from '@/helpers/rust';
7+
import { checkRustInstalled, ensureRustEnv, installRust } from '@/helpers/rust';
88
import { mergeConfig } from '@/helpers/merge';
99
import tauriConfig from '@/helpers/tauriConfig';
10+
import { generateIdentifierSafeName } from '@/utils/name';
1011
import { npmDirectory } from '@/utils/dir';
1112
import { getSpinner } from '@/utils/info';
1213
import { shellExec } from '@/utils/shell';
@@ -76,6 +77,8 @@ export default abstract class BaseBuilder {
7677
logger.warn('✼ See more in https://tauri.app/start/prerequisites/.');
7778
}
7879

80+
ensureRustEnv();
81+
7982
if (!checkRustInstalled()) {
8083
const res = await prompts({
8184
type: 'confirm',
@@ -117,15 +120,17 @@ export default abstract class BaseBuilder {
117120
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
118121
await fsExtra.copy(projectCnConf, projectConf);
119122
await shellExec(
120-
`cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption} --silent`,
123+
`cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption}`,
121124
timeout,
122125
buildEnv,
126+
this.options.debug,
123127
);
124128
} else {
125129
await shellExec(
126-
`cd "${npmDirectory}" && ${packageManager} install${peerDepsOption} --silent`,
130+
`cd "${npmDirectory}" && ${packageManager} install${peerDepsOption}`,
127131
timeout,
128132
buildEnv,
133+
this.options.debug,
129134
);
130135
}
131136
spinner.succeed(chalk.green('Package installed!'));
@@ -159,12 +164,16 @@ export default abstract class BaseBuilder {
159164
// Show static message to keep the status visible
160165
logger.warn('✸ Building app...');
161166

162-
const buildEnv = this.getBuildEnvironment();
167+
const buildEnv = {
168+
...this.getBuildEnvironment(),
169+
...(process.env.NO_STRIP && { NO_STRIP: process.env.NO_STRIP }),
170+
};
163171

164172
await shellExec(
165173
`cd "${npmDirectory}" && ${this.getBuildCommand(packageManager)}`,
166174
this.getBuildTimeout(),
167175
buildEnv,
176+
this.options.debug,
168177
);
169178

170179
// Copy app
@@ -409,7 +418,7 @@ export default abstract class BaseBuilder {
409418

410419
// Linux uses the unique binary name we set in merge.ts
411420
if (process.platform === 'linux') {
412-
return `pake-${appName.toLowerCase()}${extension}`;
421+
return `pake-${generateIdentifierSafeName(appName)}${extension}`;
413422
}
414423

415424
// Windows and macOS use 'pake' as binary name

bin/cli.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
2424
program
2525
.addHelpText('beforeAll', logo)
2626
.usage(`[url] [options]`)
27-
.showHelpAfterError()
28-
.helpOption(false);
27+
.showHelpAfterError();
2928

3029
program
3130
.argument('[url]', 'The web URL you want to package', validateUrlInput)
@@ -127,10 +126,16 @@ program
127126
)
128127
.addOption(
129128
new Option(
130-
'--hide-on-close',
129+
'--hide-on-close [boolean]',
131130
'Hide window on close instead of exiting (default: true for macOS, false for others)',
132131
)
133132
.default(DEFAULT.hideOnClose)
133+
.argParser((value) => {
134+
if (value === undefined) return true; // --hide-on-close without value
135+
if (value === 'true') return true;
136+
if (value === 'false') return false;
137+
throw new Error('--hide-on-close must be true or false');
138+
})
134139
.hideHelp(),
135140
)
136141
.addOption(new Option('--title <string>', 'Window title').hideHelp())
@@ -154,6 +159,11 @@ program
154159
.default(DEFAULT.keepBinary)
155160
.hideHelp(),
156161
)
162+
.addOption(
163+
new Option('--multi-instance', 'Allow multiple app instances')
164+
.default(DEFAULT.multiInstance)
165+
.hideHelp(),
166+
)
157167
.addOption(
158168
new Option('--installer-language <string>', 'Installer language')
159169
.default(DEFAULT.installerLanguage)
@@ -163,11 +173,13 @@ program
163173
.configureHelp({
164174
sortSubcommands: true,
165175
optionTerm: (option) => {
166-
if (option.flags === '-v, --version') return '';
176+
if (option.flags === '-v, --version' || option.flags === '-h, --help')
177+
return '';
167178
return option.flags;
168179
},
169180
optionDescription: (option) => {
170-
if (option.flags === '-v, --version') return '';
181+
if (option.flags === '-v, --version' || option.flags === '-h, --help')
182+
return '';
171183
return option.description;
172184
},
173185
})

bin/defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
2727
wasm: false,
2828
enableDragDrop: false,
2929
keepBinary: false,
30+
multiInstance: false,
3031
};
3132

3233
// Just for cli development

0 commit comments

Comments
 (0)