Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "app-installer-builder",
"version": "0.1.0",
"description": "Wrap an existing website or Node project as a desktop app with Electron and electron-builder: detects a static site (dist/ with index.html) or a Node server, generates desktop/ with the Electron shell (static sites served at app:// with SPA routes; Node servers started with Electron's own Node on a free port), electron-builder.yml for macOS dmg and Windows nsis (plus Linux AppImage), an icon and a README. Shows which targets this computer can build and runs the build with a live log. Signing is optional and only uses a certificate you provide; otherwise builds are unsigned and the README says so.",
"description_i18n": {
"en": "Wrap an existing website or Node project as a desktop app with Electron and electron-builder: detects a static site (dist/ with index.html) or a Node server, generates desktop/ with the Electron shell (static sites served at app:// with SPA routes; Node servers started with Electron's own Node on a free port), electron-builder.yml for macOS dmg and Windows nsis (plus Linux AppImage), an icon and a README. Shows which targets this computer can build and runs the build with a live log. Signing is optional and only uses a certificate you provide; otherwise builds are unsigned and the README says so.",
"zh-CN": "用 Electron + electron-builder 把现有网站或 Node 项目包装成桌面应用:自动识别静态网站(含 index.html 的 dist/)或 Node 服务,在项目里生成 desktop/ 目录——Electron 外壳(静态站点通过 app:// 加载并支持前端路由;Node 服务用 Electron 自带的 Node 在空闲端口启动)、面向 macOS dmg 和 Windows nsis(另含 Linux AppImage)的 electron-builder.yml、图标和说明。面板显示本机能打哪些安装包,并实时显示打包日志。签名可选,只使用你自己提供的证书;没有证书就不签名,并在说明里写明。"
},
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"keywords": [
"electron",
"electron-builder",
"desktop app",
"installer",
"dmg",
"nsis",
"appimage",
"package",
"桌面应用",
"安装包",
"打包",
"网站转应用"
],
"skills": "skills",
"mcpServers": {
"app-installer-builder": {
"type": "stdio",
"command": "node",
"args": [
"${ZCODE_PLUGIN_ROOT}/dist/server.mjs"
],
"cwd": "${ZCODE_PROJECT_DIR}",
"timeoutMs": 900000,
"env": {
"ZCODE_WORKSPACE_ROOT": "${ZCODE_PROJECT_DIR}"
}
}
},
"ui": {
"surfaces": [
{
"id": "editor",
"title": {
"zh-CN": "应用安装包制作",
"en-US": "App Installer Builder"
},
"icon": "package",
"server": "app-installer-builder",
"resourceUri": "ui://app-installer-builder/panel.html",
"availability": "session"
}
]
}
}
21 changes: 21 additions & 0 deletions external_plugins/app-installer-builder/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Penova

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
64 changes: 64 additions & 0 deletions external_plugins/app-installer-builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# App Installer Builder

Wrap an existing **website or Node project** as a desktop app with **Electron + electron-builder**. The plugin detects the project, generates a `desktop/` folder next to it, shows which installers this computer can build, and runs the build with a live log.

## Defaults (v0.1)

- **Tooling**: electron-builder (MIT) packages an Electron shell. Both are installed into `desktop/` with `npm install` on the first build, which downloads Electron (about 150 MB).
- **Targets**: macOS **dmg** and Windows **nsis** by default. Linux AppImage and an unpacked "dir" build (for testing) are also available.
- dmg can only be built on macOS.
- nsis needs Windows, or Wine on macOS/Linux.
- The panel shows what this computer can build. The generated config can be copied to another computer, where you run the README command.
- **Signing**: optional, and **only with a certificate you provide**.
- macOS: the name of a keychain identity ("Developer ID Application: …").
- Windows: a `.pfx` file path. The password is read from the `WIN_CSC_KEY_PASSWORD` environment variable and is never stored.
- Without a certificate the builds are **unsigned**, and the README explains what users will see (macOS right-click → Open; Windows SmartScreen → Run anyway).
- No Apple notarization.

## Features

- **Detect** (`app_scan`):
- Static site: a folder with `index.html` such as dist/, build/ or out/.
- Node server: the start script or entry calls `listen()`. The plugin also checks whether it reads `process.env.PORT`.
- Name, version and author from package.json, and square PNG icon candidates.
- **Generate** (`app_setup`) creates `desktop/` containing:
- `main.cjs`:
- Static sites are served at `app://local/`, so absolute `/assets/…` paths and client-side routes work (SPA fallback).
- Node servers are started with Electron's own Node (no Node install needed) on a free port. They get `APP_DATA_DIR` for data and log to `server.log`.
- Single instance, external links open in the browser, and sandboxed renderer.
- `package.json` with pinned electron and electron-builder.
- `electron-builder.yml`: appId, productName, dmg, nsis (assisted installer with shortcuts), AppImage, and the website or server copied as extra resources.
- `build/icon.png`: your PNG (≥512 px square) or a generated icon.
- `README.md` with build commands and the signing status.
- **Check** (`app_check`): config validation and a per-target "can build here" matrix.
- Validation covers reverse-DNS appId, semver version, web folder or entry present, icon size, fixed-port warning and certificate file present.
- **Build** (`app_build` / `app_status`): `npm install` the first time, then `electron-builder --publish never`. The log streams to the panel, and outputs in `desktop/release/` are listed.

## Usage

Ask the agent in ZCode Desktop:

- "Turn this web app into a Mac and Windows desktop app"
- "Package my Node server as a desktop app"
- "Which installers can I build on this computer?"

## Tools

| Tool | Purpose |
|---|---|
| `app_scan` | Detect the project type, entry, port and icons |
| `app_setup` | Generate / update `desktop/` (shell, electron-builder.yml, icon, README) |
| `app_check` | Validate the config; which targets this computer can build |
| `app_build` | Run electron-builder for one target |
| `app_status` | Build progress and log |

## Scope (v0.1)

- No auto-update server, no app store submission, and no notarization (it needs an Apple account).
- Server-rendered Next/Nuxt apps are not supported; use a static export. Servers must start with `node <entry>`.
- For Node servers, the whole project folder, including `node_modules`, is packaged.

## Privacy, network and files

- No API keys and no accounts. The only network use is `npm install` in `desktop/` during the first build, which downloads Electron and electron-builder from npm and GitHub.
- Writes `<project>/desktop/` and `.app-installer/state.json`. Certificate passwords are never written to disk.
64 changes: 64 additions & 0 deletions external_plugins/app-installer-builder/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 应用安装包制作

用 **Electron + electron-builder** 把现有的**网站或 Node 项目**包装成桌面应用。插件会识别项目,在项目旁生成 `desktop/` 目录,显示本机能打哪些安装包,并带着实时日志完成打包。

## 默认设定(v0.1)

- **工具**:electron-builder(MIT)打包 Electron 外壳。两者在第一次打包时通过 `npm install` 装进 `desktop/`,会下载 Electron(约 150 MB)。
- **目标**:默认是 macOS **dmg** 和 Windows **nsis**;另外可选 Linux AppImage 和本机免安装目录(dir,测试用)。
- dmg 只能在 macOS 上打。
- nsis 需要 Windows,或者在 macOS/Linux 上装 Wine。
- 面板会显示本机能打哪些目标。生成的配置可以拿到对应的电脑上,按 README 里的命令运行。
- **签名**:可选,**只使用你自己提供的证书**。
- macOS:填钥匙串里的证书名称(“Developer ID Application: …”)。
- Windows:填 `.pfx` 证书文件路径。密码从环境变量 `WIN_CSC_KEY_PASSWORD` 读取,插件不保存。
- 没有证书就**不签名**。README 会写明用户第一次打开时会看到什么(macOS:右键 → 打开;Windows:SmartScreen → 仍要运行)。
- 不做 Apple 公证。

## 功能

- **识别项目**(`app_scan`):
- 静态网站:含 `index.html` 的目录,例如 dist/、build/、out/。
- Node 服务:start 脚本或入口文件调用了 `listen()`。同时检查它是否读取 `process.env.PORT`。
- 从 package.json 读取名称、版本和作者,并找出可用作图标的正方形 PNG。
- **生成配置**(`app_setup`):在项目里生成 `desktop/`,包括:
- `main.cjs`:
- 静态网站通过 `app://local/` 加载,绝对路径 `/assets/…` 和前端路由都能用(找不到的路径回退到 index.html)。
- Node 服务用 Electron 自带的 Node 在空闲端口启动,不需要另装 Node;数据目录通过 `APP_DATA_DIR` 传入,日志写到 `server.log`。
- 只允许运行一个实例;外部链接用浏览器打开;渲染进程开启沙箱。
- `package.json`:固定 electron 和 electron-builder 的版本。
- `electron-builder.yml`:appId、产品名、dmg、nsis(可选安装目录,创建快捷方式)、AppImage,网站或服务代码作为附加资源打进安装包。
- `build/icon.png`:你的 PNG(至少 512 px 的正方形),或自动生成的图标。
- `README.md`:打包命令和签名状态。
- **检查**(`app_check`):校验配置,并显示每个目标能否在本机打包。
- 校验内容:appId 必须是反向域名格式;版本必须是 semver;网页目录或入口文件要存在;图标尺寸;使用固定端口时给出提醒;证书文件要存在。
- **打包**(`app_build` / `app_status`):第一次先 `npm install`,然后运行 `electron-builder --publish never`。面板实时显示日志,并列出 `desktop/release/` 里的产物。

## 用法

在 ZCode Desktop 里对 Agent 说:

- “把这个网站做成 Mac 和 Windows 桌面应用”
- “把我的 Node 服务打包成桌面应用”
- “这台电脑能打哪些安装包?”

## 工具

| 工具 | 作用 |
|---|---|
| `app_scan` | 识别项目类型、入口、端口和图标 |
| `app_setup` | 生成或更新 `desktop/`(外壳、electron-builder.yml、图标、README) |
| `app_check` | 校验配置,查看本机能打哪些目标 |
| `app_build` | 运行 electron-builder 打包一个目标 |
| `app_status` | 查看打包进度和日志 |

## 范围(v0.1)

- 不做自动更新服务器、应用商店上架和 Apple 公证(公证需要 Apple 账号)。
- 不支持 Next/Nuxt 服务端渲染,请改用静态导出。Node 服务必须能用 `node <入口>` 启动。
- Node 服务会把整个项目目录(包括 `node_modules`)打进安装包。

## 隐私、网络和文件

- 不需要 API 密钥,也不需要账号。只有第一次打包时会在 `desktop/` 里运行 `npm install`,从 npm 和 GitHub 下载 Electron 和 electron-builder。
- 只写 `<项目>/desktop/` 和 `.app-installer/state.json`。证书密码不会写入磁盘。
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: app-installer-builder
description: 用 Electron + electron-builder 把现有网站或 Node 项目打包成桌面应用(macOS dmg、Windows nsis、Linux AppImage):识别项目、生成 desktop/ 外壳与 electron-builder.yml、显示本机能打哪些安装包、实际打包。用户提到“做成桌面应用 / 安装包 / exe / dmg / Electron 打包”时使用。签名只用用户自己提供的证书。
---

# 应用安装包制作(electron-builder)

1. 先用 `app_scan(dir)` 识别项目:
- 静态网站:需要有构建好的 index.html。没有的话,先让用户运行 `npm run build`,或者由你来运行。
- Node 服务:最好读取 `process.env.PORT`。如果用的是固定端口,提醒用户改成读取 `process.env.PORT`。
- Next/Nuxt 服务端渲染不支持,请改用静态导出。
2. 用 `app_setup(dir, name, appId, version, targets)` 生成配置:
- appId 用反向域名,例如 `com.公司.应用`,不要保留 `com.example`。
- 默认目标是 `["dmg","nsis"]`。
- 图标用正方形 PNG,至少 512 px;没有的话插件会自动生成。
3. 签名:只有用户明确提供了证书才填。
- macOS:`macIdentity` 填钥匙串里的证书名称。
- Windows:`winCertificateFile` 填 .pfx 证书路径。
- **不要索取、也不要传入证书密码**。请用户自己把密码设到环境变量 `WIN_CSC_KEY_PASSWORD`。
- 没有证书就不签名,并告诉用户首次打开时会出现的提示。
4. 用 `app_check()` 查看本机能打哪些安装包:dmg 只能在 Mac 上打;nsis 需要 Windows,或者安装了 Wine。
5. 用 `app_build(target)` 打包:
- 第一次打包会下载 Electron(约 150 MB)。
- 如果返回时还在打包,就继续调用 `app_status()`,直到完成。
- 本机不能打的目标:告诉用户把项目带到对应的电脑上,在 desktop/ 里运行 README 中的命令。
6. 完成后告诉用户:安装包在 `desktop/release/` 里,以及是否已签名。
50 changes: 50 additions & 0 deletions marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,56 @@
"把上一个 Hi3D 任务生成的模型按角色拆分成部件"
]
}
},
{
"name": "app-installer-builder",
"componentTypes": [
"ui"
],
"source": "./external_plugins/app-installer-builder",
"displayName": "App Installer Builder",
"displayName_i18n": {
"en": "App Installer Builder",
"zh-CN": "应用安装包制作"
},
"description": "Wrap an existing website or Node project as a desktop app with Electron and electron-builder: detects a static site (dist/ with index.html) or a Node server, generates desktop/ with the Electron shell (static sites served at app:// with SPA routes; Node servers started with Electron's own Node on a free port), electron-builder.yml for macOS dmg and Windows nsis (plus Linux AppImage), an icon and a README. Shows which targets this computer can build and runs the build with a live log. Signing is optional and only uses a certificate you provide; otherwise builds are unsigned and the README says so.",
"description_i18n": {
"en": "Wrap an existing website or Node project as a desktop app with Electron and electron-builder: detects a static site (dist/ with index.html) or a Node server, generates desktop/ with the Electron shell (static sites served at app:// with SPA routes; Node servers started with Electron's own Node on a free port), electron-builder.yml for macOS dmg and Windows nsis (plus Linux AppImage), an icon and a README. Shows which targets this computer can build and runs the build with a live log. Signing is optional and only uses a certificate you provide; otherwise builds are unsigned and the README says so.",
"zh-CN": "用 Electron + electron-builder 把现有网站或 Node 项目包装成桌面应用:自动识别静态网站(含 index.html 的 dist/)或 Node 服务,在项目里生成 desktop/ 目录——Electron 外壳(静态站点通过 app:// 加载并支持前端路由;Node 服务用 Electron 自带的 Node 在空闲端口启动)、面向 macOS dmg 和 Windows nsis(另含 Linux AppImage)的 electron-builder.yml、图标和说明。面板显示本机能打哪些安装包,并实时显示打包日志。签名可选,只使用你自己提供的证书;没有证书就不签名,并在说明里写明。"
},
"version": "0.1.0",
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"category": "developer-tools",
"keywords": [
"electron",
"electron-builder",
"desktop app",
"installer",
"dmg",
"nsis",
"appimage",
"package",
"桌面应用",
"安装包",
"打包",
"网站转应用"
],
"examplePrompts": [
"Turn this web app into a Mac and Windows desktop app",
"Package my Node server as a desktop app",
"Which installers can I build on this computer?"
],
"examplePrompts_i18n": {
"zh-CN": [
"把这个网站做成 Mac 和 Windows 桌面应用",
"把我的 Node 服务打包成桌面应用",
"这台电脑能打哪些安装包?"
]
}
}
]
}
Loading