Git-first workspace migration planner for remote or local code archives
Project description
code-porter
一个纯本地运行的代码库导入导出工具。它会在当前机器上扫描项目,优先将 Git 仓库导出为 git bundle,将非 Git 项目导出为 zip;导出完成后,可在另一台机器上基于 manifest 批量导入。
发布到 PyPI 后,用户可以直接运行:
uvx code-porter --help
技术选型
- 使用 uv 管理 Python 环境与依赖
- 使用 typer 构建 CLI
- 使用 rich 输出表格与 JSON
- 使用 pathspec 解析 .gitignore 规则
安装
uv sync
或直接从 PyPI 临时运行:
uvx code-porter scan ~/code ~/lab --json-output reports/local-scan.json
用法
扫描本地目录:
uvx code-porter scan ~/code ~/lab --json-output reports/local-scan.json
导出 bundle/zip 归档:
uvx code-porter export ~/code ~/lab ./exports/local-backup
导入归档:
uvx code-porter import ./exports/local-backup/manifest.json ~/code/imported
本地开发时也可以继续使用:
uv run code-porter --help
输出内容包括:
- 项目名称与路径
- 项目类型(Python / Node / Go / Rust / .NET)
- 是否 Git 仓库
- 是否存在 Git remote
- 首个 Git remote 名称与 URL
- work tree 是否干净
- 目录大小
- 是否值得导出与原因
- 大目录命中情况
- 默认忽略目录命中情况
- 推荐打包策略与原因
当前打包策略
- 干净 Git 仓库:导出 git bundle
- 脏 Git 仓库:导出 git bundle,并额外导出工作区 overlay zip
- 非 Git 项目:导出 zip
命令
- scan:扫描本地目录
- export:扫描并输出 bundle/zip 归档,以及 manifest.json
- import:根据 manifest.json 将归档导入到目标目录
说明
- 默认会排除 node_modules、.venv、dist、build、target、.next、.cache、.git
- scan 与 export 支持
--large-dir-threshold-mb调整大目录阈值 - 导出 zip 时会读取项目根目录的 .gitignore,并叠加默认排除目录
- bundle 导入后如果存在 overlay zip,会在 clone 后覆盖工作区文件,以保留未提交改动
- import 遇到已存在目录时默认跳过,可用
--on-existing replace覆盖
发布到 PyPI
uv build
uv publish
发布完成后,终端里直接执行 uvx code-porter 即可按需下载并运行。
Project details
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.1.0.tar.gz.
File metadata
- Download URL: code_porter-0.1.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcf3cad92c792d7485c53795d3b13dfbc1e43cf92e6aa3624be25816e315a26a
|
|
| MD5 |
a16c4ea614469d028a3a12afbf0e45a6
|
|
| BLAKE2b-256 |
3d78c7f05cfad0480a1fc0b2bd473e9e8b25b26f84d65f2c7afa0a186ba291fe
|
Provenance
The following attestation bundles were made for code_porter-0.1.0.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.1.0.tar.gz -
Subject digest:
bcf3cad92c792d7485c53795d3b13dfbc1e43cf92e6aa3624be25816e315a26a - Sigstore transparency entry: 1589737277
- Sigstore integration time:
-
Permalink:
star-plan/code-porter@f045c83994c3222188171de98660ff1eb0a25d97 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/star-plan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f045c83994c3222188171de98660ff1eb0a25d97 -
Trigger Event:
push
-
Statement type:
File details
Details for the file code_porter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: code_porter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a3addd71e32f37ddd14ac79443a92836a42ff660645b91bff8c426d3678da93
|
|
| MD5 |
a780603426f5e33900c9d88bd430c9b0
|
|
| BLAKE2b-256 |
8858ebe6266100d10778f6e51651490f76f4a44fcaa57159af106b41ecb93f4b
|
Provenance
The following attestation bundles were made for code_porter-0.1.0-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.1.0-py3-none-any.whl -
Subject digest:
5a3addd71e32f37ddd14ac79443a92836a42ff660645b91bff8c426d3678da93 - Sigstore transparency entry: 1589737320
- Sigstore integration time:
-
Permalink:
star-plan/code-porter@f045c83994c3222188171de98660ff1eb0a25d97 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/star-plan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f045c83994c3222188171de98660ff1eb0a25d97 -
Trigger Event:
push
-
Statement type: