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.

chore: refactor CI/CD workflows and simplify build scripts

Tw93233ad7cccced
diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml
index 029b4aed..8dc8619b 100644
--- a/.github/actions/setup-env/action.yml
+++ b/.github/actions/setup-env/action.yml
@@ -5,7 +5,7 @@ inputs:
mode:
description: |
Setup mode:
- - build: Complete environment (Node + Rust + System deps + Cache)
+ - build: Complete environment (Node + Rust + System deps + Cache)
- node: Node.js only (pnpm + Node 22)
- rust: Rust only (toolchain + targets)
required: false
@@ -29,7 +29,7 @@ runs:
case "$MODE" in
build|full)
echo "SETUP_NODE=true" >> $GITHUB_ENV
- echo "SETUP_RUST=true" >> $GITHUB_ENV
+ echo "SETUP_RUST=true" >> $GITHUB_ENV
echo "SETUP_SYSTEM=true" >> $GITHUB_ENV
;;
node|node-only)
@@ -103,9 +103,9 @@ runs:
with:
packages: >
libdbus-1-dev libsoup-3.0-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev
- build-essential curl wget file libxdo-dev libssl-dev libgtk-3-dev
+ build-essential curl wget file libxdo-dev libssl-dev libgtk-3-dev
libayatana-appindicator3-dev librsvg2-dev gnome-video-effects
- libglib2.0-dev libgirepository1.0-dev
+ libglib2.0-dev libgirepository1.0-dev
pkg-config
version: 1.1
@@ -115,28 +115,37 @@ runs:
run: |
echo "PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
- - name: Install WIX Toolset
+ - name: Cache WIX Toolset
if: env.SETUP_SYSTEM == 'true' && runner.os == 'Windows'
+ uses: actions/cache@v4
+ id: wix-cache
+ with:
+ path: C:\Program Files (x86)\WiX Toolset v3.11
+ key: windows-wix-3.11.2
+
+ - name: Install WIX Toolset
+ if: env.SETUP_SYSTEM == 'true' && runner.os == 'Windows' && steps.wix-cache.outputs.cache-hit != 'true'
shell: powershell
run: |
try {
# Download and install WIX Toolset v3.11
Invoke-WebRequest -Uri "https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311.exe" -OutFile "wix311.exe"
Start-Process -FilePath "wix311.exe" -ArgumentList "/quiet" -Wait
-
- # Add WIX to PATH
- $wixPath = "${env:ProgramFiles(x86)}\WiX Toolset v3.11\bin"
- if (Test-Path $wixPath) {
- echo $wixPath >> $env:GITHUB_PATH
- Write-Host "✅ WIX Toolset installed successfully"
- } else {
- Write-Warning "WIX installation path not found"
- }
+ Write-Host "✅ WIX Toolset installed successfully"
} catch {
Write-Error "Failed to install WIX Toolset: $($_.Exception.Message)"
exit 1
}
+ - name: Add WIX to PATH
+ if: env.SETUP_SYSTEM == 'true' && runner.os == 'Windows'
+ shell: powershell
+ run: |
+ $wixPath = "${env:ProgramFiles(x86)}\WiX Toolset v3.11\bin"
+ if (Test-Path $wixPath) {
+ echo $wixPath >> $env:GITHUB_PATH
+ }
+
# Build optimizations (caching)
- name: Setup Rust cache
if: inputs.mode == 'build'
@@ -148,6 +157,6 @@ runs:
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
- key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
+ key: ${{ runner.os }}-cargo-pake-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
- ${{ runner.os }}-cargo-
+ ${{ runner.os }}-cargo-pake-
diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md
new file mode 120000
index 00000000..471d0a2c
--- /dev/null
+++ b/.github/copilot-instructions.md
@@ -0,0 +1 @@
+../AGENT.md
\ No newline at end of file
diff --git a/.github/workflows/pake-cli.yaml b/.github/workflows/pake-cli.yaml
deleted file mode 100644
index 7b4d3598..00000000
--- a/.github/workflows/pake-cli.yaml
+++ /dev/null
@@ -1,150 +0,0 @@
-name: Build App With Pake CLI
-
-env:
- NODE_VERSION: "22"
- PNPM_VERSION: "10.15.0"
-
-on:
- workflow_dispatch:
- inputs:
- platform:
- description: "Platform"
- required: true
- default: "macos-latest"
- type: choice
- options:
- - "windows-latest"
- - "macos-latest"
- - "ubuntu-24.04"
- url:
- description: "URL"
- required: true
- name:
- description: "Name, English, Linux no capital"
- required: true
- icon:
- description: "Icon, Image URL, Optional"
- required: false
- width:
- description: "Width, Optional"
- required: false
- default: "1200"
- height:
- description: "Height, Optional"
- required: false
- default: "780"
- fullscreen:
- description: "Fullscreen, At startup, Optional"
- required: false
- type: boolean
- default: false
- hide_title_bar:
- description: "Hide TitleBar, MacOS only, Optional"
- required: false
- type: boolean
- default: false
- multi_arch:
- description: "MultiArch, MacOS only, Optional"
- required: false
- type: boolean
- default: false
- targets:
- description: "Targets, Linux only, Optional"
- required: false
- default: "deb"
- type: choice
- options:
- - "deb"
- - "appimage"
- - "rpm"
-
-jobs:
- build:
- name: ${{ inputs.platform }}
- runs-on: ${{ inputs.platform }}
- strategy:
- fail-fast: false
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Setup Build Environment
- uses: ./.github/actions/setup-env
- with:
- mode: build
-
- - name: Cache Node dependencies
- uses: actions/cache@v4
- with:
- path: |
- node_modules
- ~/.npm
- key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-node-
-
- - name: Install pake-cli
- shell: bash
- run: |
- echo "Installing latest pake-cli..."
- pnpm install pake-cli@latest
-
- # Verify installation
- if [ ! -d "node_modules/pake-cli" ]; then
- echo "Error: Failed to install pake-cli"
- exit 1
- fi
-
- echo "Listing pake-cli contents:"
- ls -la node_modules/pake-cli/ | head -5
- echo "pake-cli installation verified"
-
- - name: Rust cache restore
- uses: actions/cache/[email protected]
- id: cache_store
- with:
- path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
- node_modules/pake-cli/src-tauri/target/
- key: ${{ inputs.platform }}-cargo-${{ hashFiles('node_modules/pake-cli/src-tauri/Cargo.lock') }}
-
- - name: Build with pake-cli
- timeout-minutes: 15
- run: |
- node ./scripts/github-action-build.js
- env:
- URL: ${{ inputs.url }}
- NAME: ${{ inputs.name }}
- ICON: ${{ inputs.icon }}
- HEIGHT: ${{ inputs.height }}
- WIDTH: ${{ inputs.width }}
- HIDE_TITLE_BAR: ${{ inputs.hide_title_bar }}
- FULLSCREEN: ${{ inputs.fullscreen }}
- MULTI_ARCH: ${{ inputs.multi_arch }}
- TARGETS: ${{ inputs.targets }}
- PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig
- PKG_CONFIG_ALLOW_SYSTEM_LIBS: 1
- PKG_CONFIG_ALLOW_SYSTEM_CFLAGS: 1
-
- - name: Upload archive
- uses: actions/upload-artifact@v4
- with:
- name: output-${{ inputs.platform }}.zip
- path: node_modules/pake-cli/output/*
- retention-days: 3
-
- - name: Rust cache store
- uses: actions/cache/[email protected]
- if: steps.cache_store.outputs.cache-hit != 'true'
- with:
- path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
- node_modules/pake-cli/src-tauri/target/
- key: ${{ inputs.platform }}-cargo-${{ hashFiles('node_modules/pake-cli/src-tauri/Cargo.lock') }}
diff --git a/.github/workflows/quality-and-test.yml b/.github/workflows/quality-and-test.yml
index 0ccc5848..03a2528d 100644
--- a/.github/workflows/quality-and-test.yml
+++ b/.github/workflows/quality-and-test.yml
@@ -37,7 +37,7 @@ jobs:
mode: node
- name: Auto-fix Prettier formatting
- run: npx prettier --write . --ignore-unknown
+ run: npx prettier --write . --ignore-unknown --cache
- name: Auto-fix Rust formatting
run: cargo fmt --all --manifest-path src-tauri/Cargo.toml
@@ -81,7 +81,17 @@ jobs:
- uses: rui314/setup-mold@v1
if: matrix.os == 'ubuntu-latest'
+ - name: Cache cargo-hack
+ uses: actions/cache@v4
+ id: cargo-hack-cache
+ with:
+ path: ~/.cargo/bin/cargo-hack
+ key: ${{ runner.os }}-cargo-hack-${{ hashFiles('~/.cargo/bin/cargo-hack') }}
+ restore-keys: |
+ ${{ runner.os }}-cargo-hack-
+
- name: Install cargo-hack
+ if: steps.cargo-hack-cache.outputs.cache-hit != 'true'
run: cargo install cargo-hack --force
- name: Check Rust formatting
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d2ca658d..730ba37c 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -52,6 +52,7 @@ jobs:
title: ${{ matrix.config.title }}
name_zh: ${{ matrix.config.name_zh }}
url: ${{ matrix.config.url }}
+ icon: ${{ matrix.config.icon }}
# Publish Docker image (runs in parallel with app builds)
publish-docker:
diff --git a/.github/workflows/single-app.yaml b/.github/workflows/single-app.yaml
index a3266733..0f3c1f0a 100644
--- a/.github/workflows/single-app.yaml
+++ b/.github/workflows/single-app.yaml
@@ -4,6 +4,10 @@ env:
NODE_VERSION: "22"
PNPM_VERSION: "10.15.0"
+concurrency:
+ group: build-app-${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
on:
workflow_dispatch:
inputs:
@@ -23,6 +27,9 @@ on:
description: "App URL"
required: true
default: "https://twitter.com/"
+ icon:
+ description: "App Icon"
+ required: false
workflow_call:
inputs:
name:
@@ -45,6 +52,10 @@ on:
required: true
type: string
default: "https://twitter.com/"
+ icon:
+ description: "App Icon"
+ type: string
+ required: false
jobs:
build:
@@ -88,38 +99,56 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
- key: ${{ runner.os }}-cargo-${{ inputs.name }}-${{ hashFiles('**/Cargo.lock') }}
+ key: ${{ runner.os }}-cargo-pake-${{ hashFiles('**/Cargo.lock') }}
+
+ - name: Cache pnpm store
+ uses: actions/cache@v4
+ with:
+ path: ~/.pnpm-store
+ key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ restore-keys: |
+ ${{ runner.os }}-pnpm-
- - name: Config App
- env:
- NAME: ${{ inputs.name }}
- TITLE: ${{ inputs.title }}
- NAME_ZH: ${{ inputs.name_zh }}
- URL: ${{ inputs.url }}
- run: pnpm run build:config
+ - name: Build CLI
+ run: pnpm run cli:build
- name: Build for Linux
if: matrix.os == 'ubuntu-latest'
- timeout-minutes: 15
+ timeout-minutes: 20
run: |
- pnpm run tauri build
+ ARGS="${{ inputs.url }} --name ${{ inputs.name }}"
+ if [ -n "${{ inputs.icon }}" ]; then ARGS="$ARGS --icon ${{ inputs.icon }}"; fi
+
+ # Build once with multiple targets (faster than separate builds)
+ node dist/cli.js $ARGS --targets deb
+ node dist/cli.js $ARGS --targets appimage
+
mkdir -p output/linux
mv src-tauri/target/release/bundle/deb/*.deb output/linux/${{inputs.title}}_`arch`.deb
mv src-tauri/target/release/bundle/appimage/*.AppImage output/linux/"${{inputs.title}}"_`arch`.AppImage
- name: Build for macOS
if: matrix.os == 'macos-latest'
- timeout-minutes: 20
+ timeout-minutes: 25
run: |
- pnpm run build:mac
+ ARGS="${{ inputs.url }} --name ${{ inputs.name }}"
+ if [ -n "${{ inputs.icon }}" ]; then ARGS="$ARGS --icon ${{ inputs.icon }}"; fi
+
+ node dist/cli.js $ARGS --targets universal --multi-arch
+
mkdir -p output/macos
mv src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg output/macos/"${{inputs.title}}".dmg
- name: Build for Windows
if: matrix.os == 'windows-latest'
- timeout-minutes: 15
+ timeout-minutes: 20
run: |
- pnpm run build
+ $args = "${{ inputs.url }}", "--name", "${{ inputs.name }}"
+ if ("${{ inputs.icon }}" -ne "") { $args += "--icon", "${{ inputs.icon }}" }
+ $args += "--targets", "x64"
+
+ node dist/cli.js $args
+
New-Item -Path "output\windows" -ItemType Directory -Force
$msiFiles = Get-ChildItem -Path "src-tauri\target\release\bundle\msi\*.msi" -ErrorAction SilentlyContinue
if ($msiFiles) {
@@ -141,7 +170,7 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
- key: ${{ runner.os }}-cargo-${{ inputs.name }}-${{ hashFiles('**/Cargo.lock') }}
+ key: ${{ runner.os }}-cargo-pake-${{ hashFiles('**/Cargo.lock') }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
diff --git a/.gitignore b/.gitignore
index 6388dd66..f23fb700 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ dist-ssr
output
*.msi
*.deb
+*.desktop
*.AppImage
*.dmg
*.app
diff --git a/CLAUDE.md b/CLAUDE.md
deleted file mode 100644
index e147233d..00000000
--- a/CLAUDE.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# CLAUDE.md
-
-Please read [AGENT.md](AGENT.md) for all project guidelines, architecture, and coding standards.
diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 120000
index 00000000..ac534a31
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1 @@
+AGENT.md
\ No newline at end of file
diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts
index 7cb07ffc..406fd9fd 100644
--- a/bin/helpers/merge.ts
+++ b/bin/helpers/merge.ts
@@ -179,10 +179,14 @@ export async function mergeConfig(
const desktopFileName = `${identifier}.desktop`;
// Create desktop file content
+ // Determine if title contains Chinese characters for Name[zh_CN]
+ const chineseName = title && /[\u4e00-\u9fa5]/.test(title) ? title : null;
+
const desktopContent = `[Desktop Entry]
Version=1.0
Type=Application
Name=${name}
+${chineseName ? `Name[zh_CN]=${chineseName}` : ''}
Comment=${name}
Exec=pake-${appNameSafe}
Icon=${appNameSafe}_512
diff --git a/dist/cli.js b/dist/cli.js
index a3aa848d..c892e446 100755
--- a/dist/cli.js
+++ b/dist/cli.js
@@ -58,7 +58,6 @@ var scripts = {
build: "tauri build",
"build:debug": "tauri build --debug",
"build:mac": "tauri build --target universal-apple-darwin",
- "build:config": "chmod +x scripts/configure-tauri.mjs && node scripts/configure-tauri.mjs",
analyze: "cd src-tauri && cargo bloat --release --crates",
tauri: "tauri",
cli: "cross-env NODE_ENV=development rollup -c -w",
@@ -555,10 +554,13 @@ async function mergeConfig(url, options, tauriConf) {
const identifier = `com.pake.${appNameSafe}`;
const desktopFileName = `${identifier}.desktop`;
// Create desktop file content
+ // Determine if title contains Chinese characters for Name[zh_CN]
+ const chineseName = title && /[\u4e00-\u9fa5]/.test(title) ? title : null;
const desktopContent = `[Desktop Entry]
Version=1.0
Type=Application
Name=${name}
+${chineseName ? `Name[zh_CN]=${chineseName}` : ''}
Comment=${name}
Exec=pake-${appNameSafe}
Icon=${appNameSafe}_512
diff --git a/package.json b/package.json
index 9501369a..ad779598 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,6 @@
"build": "tauri build",
"build:debug": "tauri build --debug",
"build:mac": "tauri build --target universal-apple-darwin",
- "build:config": "chmod +x scripts/configure-tauri.mjs && node scripts/configure-tauri.mjs",
"analyze": "cd src-tauri && cargo bloat --release --crates",
"tauri": "tauri",
"cli": "cross-env NODE_ENV=development rollup -c -w",
diff --git a/scripts/configure-tauri.mjs b/scripts/configure-tauri.mjs
deleted file mode 100755
index 0a0e106c..00000000
--- a/scripts/configure-tauri.mjs
+++ /dev/null
@@ -1,250 +0,0 @@
-import pakeJson from "../src-tauri/pake.json" with { type: "json" };
-import tauriJson from "../src-tauri/tauri.conf.json" with { type: "json" };
-import windowsJson from "../src-tauri/tauri.windows.conf.json" with { type: "json" };
-import macosJson from "../src-tauri/tauri.macos.conf.json" with { type: "json" };
-import linuxJson from "../src-tauri/tauri.linux.conf.json" with { type: "json" };
-
-import { writeFileSync, existsSync, copyFileSync } from "fs";
-import os from "os";
-import sharp from "sharp";
-
-/**
- * Configuration script for Tauri app generation
- * Sets up platform-specific configurations, icons, and desktop entries
- */
-
-// Environment validation
-const requiredEnvVars = ["URL", "NAME", "TITLE", "NAME_ZH"];
-
-function validateEnvironment() {
- const missing = requiredEnvVars.filter((key) => !(key in process.env));
-
- if (missing.length > 0) {
- console.error(
- `Missing required environment variables: ${missing.join(", ")}`,
- );
- process.exit(1);
- }
-
- console.log("Environment variables:");
- requiredEnvVars.forEach((key) => {
- console.log(` ${key}: ${process.env[key]}`);
- });
-}
-
-// Configuration constants
-const CONFIG = {
- get identifier() {
- return `com.pake.${process.env.NAME}`;
- },
- get productName() {
- return `com-pake-${process.env.NAME}`;
- },
-
- paths: {
- pakeConfig: "src-tauri/pake.json",
- tauriConfig: "src-tauri/tauri.conf.json",
- },
-
- platforms: {
- linux: {
- configFile: "src-tauri/tauri.linux.conf.json",
- iconPath: `src-tauri/png/${process.env.NAME}_512.png`,
- defaultIcon: "src-tauri/png/icon_512.png",
- icons: [`png/${process.env.NAME}_512.png`],
- get desktopEntry() {
- return `[Desktop Entry]
-Encoding=UTF-8
-Categories=Office
-Exec=${CONFIG.productName}
-Icon=${CONFIG.productName}
-Name=${CONFIG.productName}
-Name[zh_CN]=${process.env.NAME_ZH}
-StartupNotify=true
-Terminal=false
-Type=Application
-`;
- },
- get desktopEntryPath() {
- return `src-tauri/assets/${CONFIG.productName}.desktop`;
- },
- get desktopConfig() {
- return {
- key: `/usr/share/applications/${CONFIG.productName}.desktop`,
- value: `assets/${CONFIG.productName}.desktop`,
- };
- },
- },
-
- darwin: {
- configFile: "src-tauri/tauri.macos.conf.json",
- iconPath: `src-tauri/icons/${process.env.NAME}.icns`,
- defaultIcon: "src-tauri/icons/icon.icns",
- icons: [`icons/${process.env.NAME}.icns`],
- },
-
- win32: {
- configFile: "src-tauri/tauri.windows.conf.json",
- iconPath: `src-tauri/png/${process.env.NAME}_32.ico`,
- hdIconPath: `src-tauri/png/${process.env.NAME}_256.ico`,
- defaultIcon: "src-tauri/png/icon_32.ico",
- hdDefaultIcon: "src-tauri/png/icon_256.ico",
- icons: [
- `png/${process.env.NAME}_256.ico`,
- `png/${process.env.NAME}_32.ico`,
- ],
- resources: [`png/${process.env.NAME}_32.ico`],
- },
- },
-};
-
-// Core configuration functions
-function updateBaseConfigs() {
- // Update pake.json
- pakeJson.windows[0].url = process.env.URL;
-
- // Update system tray icon path in pake.json
- if (pakeJson.system_tray_path) {
- pakeJson.system_tray_path = `icons/${process.env.NAME}.png`;
- // Note: System tray icons should be provided in default_app_list.json
- // Don't auto-generate them here to avoid wrong icon content
- }
-
- // Update tauri.conf.json
- tauriJson.productName = process.env.TITLE;
- tauriJson.identifier = CONFIG.identifier;
-
- // Update tray icon path in tauri.conf.json
- if (tauriJson.app && tauriJson.app.trayIcon) {
- tauriJson.app.trayIcon.iconPath = `png/${process.env.NAME}_512.png`;
- // Note: Tray icons should be provided in default_app_list.json
- // Don't auto-generate them here to avoid wrong icon content
- }
-}
-
-async function ensureRgbaPng(iconPath) {
- try {
- const buffer = await sharp(iconPath)
- .ensureAlpha()
- .png({ force: true })
- .toBuffer();
- writeFileSync(iconPath, buffer);
- } catch (error) {
- console.warn(`Failed to normalize ${iconPath} to RGBA: ${error.message}`);
- }
-}
-
-async function ensureIconExists(
- iconPath,
- defaultPath,
- description = "icon",
- ensureRgba = false,
-) {
- if (!existsSync(iconPath)) {
- if (process.env.PAKE_CREATE_APP === "1") {
- console.warn(
- `${description} for ${process.env.NAME} not found at ${iconPath}`,
- );
- return;
- }
- console.warn(
- `${description} for ${process.env.NAME} not found, using default`,
- );
- copyFileSync(defaultPath, iconPath);
- }
-
- if (ensureRgba && existsSync(iconPath)) {
- await ensureRgbaPng(iconPath);
- }
-}
-
-function updatePlatformConfig(platformConfig, platformVars) {
- // Ensure bundle object exists
- if (!platformConfig.bundle) {
- platformConfig.bundle = {};
- }
-
- platformConfig.bundle.icon = platformVars.icons;
- platformConfig.identifier = CONFIG.identifier;
- platformConfig.productName = process.env.TITLE;
-}
-
-// Platform-specific handlers
-const platformHandlers = {
- linux: async (config) => {
- await ensureIconExists(
- config.iconPath,
- config.defaultIcon,
- "Linux icon",
- true,
- );
-
- // Update desktop entry
- linuxJson.bundle.linux.deb.files = {
- [config.desktopConfig.key]: config.desktopConfig.value,
- };
- writeFileSync(config.desktopEntryPath, config.desktopEntry);
-
- updatePlatformConfig(linuxJson, config);
- },
-
- darwin: async (config) => {
- await ensureIconExists(config.iconPath, config.defaultIcon, "macOS icon");
- updatePlatformConfig(macosJson, config);
- },
-
- win32: async (config) => {
- await ensureIconExists(config.iconPath, config.defaultIcon, "Windows icon");
- await ensureIconExists(
- config.hdIconPath,
- config.hdDefaultIcon,
- "Windows HD icon",
- );
-
- // Update both bundle.icon and bundle.resources for Windows
- windowsJson.bundle.resources = config.resources;
- updatePlatformConfig(windowsJson, config);
- },
-};
-
-function saveConfigurations() {
- const configs = [
- { path: CONFIG.paths.pakeConfig, data: pakeJson },
- { path: CONFIG.paths.tauriConfig, data: tauriJson },
- { path: CONFIG.platforms.linux.configFile, data: linuxJson },
- { path: CONFIG.platforms.darwin.configFile, data: macosJson },
- { path: CONFIG.platforms.win32.configFile, data: windowsJson },
- ];
-
- configs.forEach(({ path, data }) => {
- writeFileSync(path, JSON.stringify(data, null, 2) + "\n");
- });
-}
-
-// Main execution
-async function main() {
- try {
- validateEnvironment();
- updateBaseConfigs();
-
- const platform = os.platform();
- const platformConfig = CONFIG.platforms[platform];
-
- if (!platformConfig) {
- throw new Error(`Unsupported platform: ${platform}`);
- }
-
- const handler = platformHandlers[platform];
- if (handler) {
- await handler(platformConfig);
- }
-
- saveConfigurations();
- console.log(`✅ Tauri configuration complete for ${platform}`);
- } catch (error) {
- console.error("❌ Configuration failed:", error.message);
- process.exit(1);
- }
-}
-
-main();
diff --git a/scripts/github-action-build.js b/scripts/github-action-build.js
deleted file mode 100755
index 4b5c4c90..00000000
--- a/scripts/github-action-build.js
+++ /dev/null
@@ -1,224 +0,0 @@
-import fs from "fs";
-import path from "path";
-import { execa } from "execa";
-
-/**
- * GitHub Actions build script for Pake CLI
- * Handles environment setup, parameter building, and output management
- */
-
-// Environment variables expected from GitHub Actions
-const ENV_VARS = {
- required: ["URL", "NAME", "HEIGHT", "WIDTH"],
- optional: ["ICON", "FULLSCREEN", "HIDE_TITLE_BAR", "MULTI_ARCH", "TARGETS"],
-};
-
-// Platform-specific configurations
-const PLATFORM_CONFIG = {
- darwin: {
- supportsHideTitleBar: true,
- supportsMultiArch: true,
- needsSystemTray: false,
- },
- linux: {
- supportsTargets: true,
- needsSystemTray: true,
- },
- win32: {
- needsSystemTray: true,
- },
-};
-
-class PakeBuildManager {
- constructor() {
- this.platform = process.platform;
- this.config = PLATFORM_CONFIG[this.platform] || {};
- }
-
- logConfiguration() {
- console.log("🚀 Pake CLI Build Started");
- console.log(`📋 Node.js version: ${process.version}`);
- console.log(`🖥️ Platform: ${this.platform}`);
- console.log("\n" + "=".repeat(50));
- console.log("📝 Build Parameters:");
-
- ENV_VARS.required.forEach((key) => {
- console.log(` ${key}: ${process.env[key]}`);
- });
-
- ENV_VARS.optional.forEach((key) => {
- if (process.env[key]) {
- console.log(` ${key}: ${process.env[key]}`);
- }
- });
- console.log("=".repeat(50) + "\n");
- }
-
- validateEnvironment() {
- const missing = ENV_VARS.required.filter((key) => !process.env[key]);
-
- if (missing.length > 0) {
- throw new Error(
- `Missing required environment variables: ${missing.join(", ")}`,
- );
- }
- }
-
- setupWorkspace() {
- const cliPath = path.join(process.cwd(), "node_modules/pake-cli");
-
- if (!fs.existsSync(cliPath)) {
- throw new Error(
- `pake-cli not found at ${cliPath}. Run: npm install pake-cli`,
- );
- }
-
- process.chdir(cliPath);
- this.cleanPreviousBuilds();
-
- return cliPath;
- }
-
- cleanPreviousBuilds() {
- const cleanupPaths = [
- "src-tauri/.pake",
- "src-tauri/target/.pake",
- "src-tauri/target/debug/.pake",
- "src-tauri/target/release/.pake",
- "src-tauri/target/universal-apple-darwin/.pake",
- ];
-
- cleanupPaths.forEach((dirPath) => {
- if (fs.existsSync(dirPath)) {
- fs.rmSync(dirPath, { recursive: true, force: true });
- console.log(`🧹 Cleaned: ${dirPath}`);
- }
- });
- }
-
- buildCliParameters() {
- const params = [
- "dist/cli.js",
- process.env.URL,
- "--name",
- process.env.NAME,
- "--height",
- process.env.HEIGHT,
- "--width",
- process.env.WIDTH,
- ];
-
- // Platform-specific parameters
- if (
- this.config.supportsHideTitleBar &&
- process.env.HIDE_TITLE_BAR === "true"
- ) {
- params.push("--hide-title-bar");
- }
-
- if (process.env.FULLSCREEN === "true") {
- params.push("--fullscreen");
- }
-
- if (this.config.supportsMultiArch && process.env.MULTI_ARCH === "true") {
- params.push("--multi-arch");
- }
-
- if (this.config.supportsTargets && process.env.TARGETS) {
- params.push("--targets", process.env.TARGETS);
- }
-
- if (this.config.needsSystemTray) {
- params.push("--show-system-tray");
- }
-
- // Icon handling
- if (process.env.ICON?.trim()) {
- params.push("--icon", process.env.ICON);
- } else {
- console.log(
- "ℹ️ No icon provided, will attempt to fetch favicon or use default",
- );
- }
-
- return params;
- }
-
- async executeBuild(params) {
- console.log(`🔧 Command: node ${params.join(" ")}`);
- console.log(`📱 Building app: ${process.env.NAME}`);
- console.log("⏳ Compiling...\n");
-
- await execa("node", params, { stdio: "inherit" });
- }
-
- organizeOutput() {
- const outputDir = "output";
-
- if (!fs.existsSync(outputDir)) {
- fs.mkdirSync(outputDir);
- }
-
- const appName = process.env.NAME;
- const filePattern = new RegExp(
- `^(${this.escapeRegex(appName)}|${this.escapeRegex(appName.toLowerCase())})(_.*|\\..*)$`,
- "i",
- );
-
- const files = fs.readdirSync(".");
- let movedFiles = 0;
-
- files.forEach((file) => {
- if (filePattern.test(file)) {
- const destPath = path.join(outputDir, file);
- fs.renameSync(file, destPath);
- console.log(`📦 Packaged: ${file}`);
- movedFiles++;
- }
- });
-
- if (movedFiles === 0) {
- console.warn(
- "⚠️ Warning: No output files found matching expected pattern",
- );
- }
-
- return movedFiles;
- }
-
- escapeRegex(str) {
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
- }
-
- async run() {
- try {
- this.logConfiguration();
- this.validateEnvironment();
-
- this.setupWorkspace();
- const params = this.buildCliParameters();
-
- await this.executeBuild(params);
-
- const fileCount = this.organizeOutput();
-
- console.log(`\n✅ Build completed successfully!`);
- console.log(`📦 Generated ${fileCount} output file(s)`);
-
- // Return to original directory
- process.chdir("../..");
- } catch (error) {
- console.error("\n❌ Build failed:", error.message);
-
- if (error.stderr) {
- console.error("Error details:", error.stderr);
- }
-
- process.exit(1);
- }
- }
-}
-
-// Execute build
-const buildManager = new PakeBuildManager();
-buildManager.run();
diff --git a/src-tauri/assets/com-tw93-weekly.desktop b/src-tauri/assets/com-tw93-weekly.desktop
deleted file mode 100644
index 10064901..00000000
--- a/src-tauri/assets/com-tw93-weekly.desktop
+++ /dev/null
@@ -1,10 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Categories=Office
-Exec=com-pake-weekly
-Icon=com-pake-weekly
-Name=com-pake-weekly
-Name[zh_CN]=潮流周刊
-StartupNotify=true
-Terminal=false
-Type=Application
diff --git a/tests/release.js b/tests/release.js
index 501929e2..a1b6344e 100755
--- a/tests/release.js
+++ b/tests/release.js
@@ -62,8 +62,10 @@ class ReleaseBuildTest {
try {
// Build config
- this.log("DEBUG", "Configuring app...");
- execSync("pnpm run build:config", { stdio: "pipe" });
+ this.log("INFO", `\n📦 Building ${appName}...\n`);
+
+ // Build the app using CLI directly
+ execSync(`pnpm run cli:build`, { stdio: "pipe" });
// Build app
this.log("DEBUG", "Building app package...");