code-porter
一个纯本地运行的代码库导入导出工具。它会在当前机器上扫描项目,优先将 Git 仓库导出为 git bundle,将非 Git 项目导出为 zip;导出完成后,可在另一台机器上基于 manifest 批量导入。
设计文档见 docs/(产品设计 · 技术架构)。局部变更计划放在 docs/changes/。
快速开始
普通用户:包管理器安装(推荐)
前置条件: 本机需已安装 Git 并加入 PATH(导出 / 导入 bundle 会调用系统 git)。
Scoop(Windows)
scoop bucket add star-plan https://github.com/star-plan/scoop
scoop install code-porter
code-porter --help
Homebrew(macOS / Linux)
brew tap star-plan/tap
brew install code-porter
code-porter --help
普通用户:下载预编译二进制
不需要安装 Python 或 uv。打开 GitHub Releases,按系统下载对应文件:
| 平台 | 文件 |
|---|---|
| Windows (x64) | code-porter-windows-amd64.exe |
| Linux (x64) | code-porter-linux-amd64 |
| macOS (Intel) | code-porter-macos-amd64 |
| macOS (Apple Silicon) | code-porter-macos-arm64 |
# Linux / macOS
chmod +x code-porter-linux-amd64 # 或对应的 macOS 文件名
./code-porter-linux-amd64 --help
# Windows(PowerShell / cmd)
.\code-porter-windows-amd64.exe --help
可用 Release 中的 SHA256SUMS 校验下载文件。Windows SmartScreen 或 macOS Gatekeeper 可能拦截未签名程序:Windows 选「更多信息 → 仍要运行」;macOS 可右键 → 打开。
开发者:uvx 一行运行
无需手动装依赖,一行命令即可运行:
# 查看帮助
uvx code-porter --help
用法
扫描本地目录
# 默认:紧凑表格 + 汇总(适合人读)
uvx code-porter scan ~/code ~/lab
# 需要落盘时再写 JSON 文件
uvx code-porter scan ~/code ~/lab --json-output reports/local-scan.json
# 脚本/管道:只输出 JSON
uvx code-porter scan ~/code ~/lab --json
# 查看完整列(remote / clean / 大目录 / 完整原因)
uvx code-porter scan ~/code ~/lab --verbose
# 只看脏工作区项目(可重复 --status / -s,OR 关系)
uvx code-porter scan ~/code --status dirty
uvx code-porter scan ~/code -s dirty -s no-remote
# 按体积从大到小排序(可再加 --reverse / -r 反转)
uvx code-porter scan ~/code --sort size
uvx code-porter scan ~/code -S name -r
默认终端输出包括:
- 项目名称、类型、Git 状态(是否仓库 / remote / clean)
- 目录大小、推荐打包策略、是否值得导出
- 简短 Note,以及一行汇总(各策略数量、值得导出数量)
使用 --verbose 可额外看到 remote、clean、大目录、忽略目录与完整原因;使用 --json / --json-output 获取完整机器可读结果(含路径、remote URL 等)。
--status / -s 可选值:dirty、clean、git、not-git、remote、no-remote、exportable、skip、bundle、overlay、zip。
--sort / -S 可选值:path、name、size(默认大→小)、type、package、export(值得导出优先)。加 --reverse / -r 可反转该字段的自然方向。筛选(--status)先于排序。
导出 bundle/zip 归档
uvx code-porter export ~/code ~/lab ./exports/local-backup
导入归档
uvx code-porter import ./exports/local-backup/manifest.json ~/code/imported
清理可重建垃圾目录
# 默认 dry-run:列出 deps / cache / build 候选及体积
uvx code-porter clean ~/code
# 按可回收体积从大到小排序
uvx code-porter clean ~/code --sort size
uvx code-porter clean ~/code -S project
# 交互终端会弹出 checkbox 勾选 profile,并询问是否立刻删除
# 非交互 / 脚本用法:
uvx code-porter clean ~/code -p deps --apply --yes
uvx code-porter clean ~/code -p deps -p cache --apply --yes
uvx code-porter clean ~/code -p all --apply --yes
Profile 说明:
deps:node_modules、.venv、venv、.uv-cache/uv-cache、gomodcache等可重装依赖(推荐)cache:.next、.cache、__pycache__、gocache等各类工具缓存build:dist、build、target等构建产物(风险更高,需有意选择)all:以上全部(仍永远不会删除.git)
匹配按目录名(basename),因此 .tmp/uv-cache、.tmp/gocache 这类嵌套缓存也会被识别;不会整目录删除可能混有业务文件的 .tmp。
默认只预览不删除;必须显式 --apply 才会动手。非交互模式下 --apply 还需要 -p/--profile 与 -y/--yes。
默认列表顺序为 profile(deps → cache → build),同 profile 内按体积从大到小。可用 --sort / -S 改为 size、project、name、path 等;--reverse / -r 反转自然方向。
命令
| 命令 | 作用 |
|---|---|
| scan | 扫描本地目录,分析项目结构 |
| clean | 预览/删除可重建垃圾目录(node_modules、.venv 等) |
| export | 扫描并输出 bundle/zip 归档,以及 manifest.json |
| import | 根据 manifest.json 将归档导入到目标目录 |
当前打包策略
- 干净 Git 仓库:导出 git bundle
- 脏 Git 仓库:导出 git bundle,并额外导出工作区 overlay zip
- 非 Git 项目:导出 zip
说明
- 默认会排除 node_modules、.venv、dist、build、target、.next、.cache、.git
- scan 与 export 支持
--large-dir-threshold-mb调整大目录阈值 - scan 默认只输出紧凑表格与汇总;
--json纯 JSON,--json-output写文件,-v/--verbose显示完整列,-s/--status按状态筛选 - clean 默认 dry-run;交互终端可用 checkbox 勾选 profile;
--apply真删,非交互需-p+-y - scan、export、import 会在终端显示进度条,减少长任务等待焦虑
- 导出 zip 时会读取项目根目录的 .gitignore,并叠加默认排除目录
- bundle 导入后如果存在 overlay zip,会在 clone 后覆盖工作区文件,以保留未提交改动
- import 遇到已存在目录时默认跳过,可用
--on-existing replace覆盖
开发者
# 克隆仓库后,使用 uv 同步依赖
git clone https://github.com/deali/code-porter
cd code-porter
uv sync
# 运行
uv run code-porter --help
发布
# 本地构建并上传到 PyPI
uv build
uv publish
打 v*.*.* 标签推送后,GitHub Actions 会:
- 运行测试并发布 wheel/sdist 到 PyPI
- 在 Windows / Linux / macOS 上用 PyInstaller 构建 standalone 二进制
- 创建 GitHub Release,附带各平台二进制与
SHA256SUMS - (可选)若配置了
PACKAGING_TOKEN,通知 star-plan/scoop 与 star-plan/homebrew-tap 立即同步;否则对方按 cron 自动拉取 Release 本地预览二进制(需 dev 依赖):
uv sync --group dev
uv run pyinstaller --noconfirm --clean packaging/code-porter.spec
# 产物:dist/code-porter 或 dist/code-porter.exe
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code_porter-0.5.5.tar.gz.
File metadata
- Download URL: code_porter-0.5.5.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad535855324c7f8663fd5ff7f61ab6894f7e16dbc230efb83d88a796316bb9a9
|
|
| MD5 |
f6af165879ba982f93fc3a84a04ecc4f
|
|
| BLAKE2b-256 |
a6bf5ad7841add9376847172ebc4fbee568cb2c8fab7f8417e2cdd2be00f859f
|
Provenance
The following attestation bundles were made for code_porter-0.5.5.tar.gz:
Publisher:
publish.yml on star-plan/code-porter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code_porter-0.5.5.tar.gz -
Subject digest:
ad535855324c7f8663fd5ff7f61ab6894f7e16dbc230efb83d88a796316bb9a9 - Sigstore transparency entry: 2438085332
- Sigstore integration time:
-
Permalink:
star-plan/code-porter@0c4829e7f907735171cb258e7d9adbdfdd3ad2ce -
Branch / Tag:
refs/tags/v0.5.5 - Owner: https://github.com/star-plan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0c4829e7f907735171cb258e7d9adbdfdd3ad2ce -
Trigger Event:
push
-
Statement type:
File details
Details for the file code_porter-0.5.5-py3-none-any.whl.
File metadata
- Download URL: code_porter-0.5.5-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d76d1b91485e8bcd43439b3578d2d267c6944539e566be6321ef7bb69334da7
|
|
| MD5 |
964d604ddd8bb08b2f6ef1aca9eefa47
|
|
| BLAKE2b-256 |
91724f6af05d892dedc7db09f0dd27475564bdd7b9e60cc34c37ab32bf549bb4
|
Provenance
The following attestation bundles were made for code_porter-0.5.5-py3-none-any.whl:
Publisher:
publish.yml on star-plan/code-porter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code_porter-0.5.5-py3-none-any.whl -
Subject digest:
5d76d1b91485e8bcd43439b3578d2d267c6944539e566be6321ef7bb69334da7 - Sigstore transparency entry: 2438085376
- Sigstore integration time:
-
Permalink:
star-plan/code-porter@0c4829e7f907735171cb258e7d9adbdfdd3ad2ce -
Branch / Tag:
refs/tags/v0.5.5 - Owner: https://github.com/star-plan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0c4829e7f907735171cb258e7d9adbdfdd3ad2ce -
Trigger Event:
push
-
Statement type: