Skip to main content

Git-first workspace migration planner for remote or local code archives

Project description

code-porter

PyPI - Python Version PyPI Version CI License

一个纯本地运行的代码库导入导出工具。它会在当前机器上扫描项目,优先将 Git 仓库导出为 git bundle,将非 Git 项目导出为 zip;导出完成后,可在另一台机器上基于 manifest 批量导入。

快速开始

无需安装任何 Python 环境或依赖,一行命令即可运行:

# 查看帮助
uvx code-porter --help

uvxuv 自带的命令,如果尚未安装 uv,可参考 uv 官方安装指南

用法

扫描本地目录

uvx code-porter scan ~/code ~/lab --json-output reports/local-scan.json

输出内容包括:

  • 项目名称与路径
  • 项目类型(Python / Node / Go / Rust / .NET)
  • 是否 Git 仓库
  • 是否存在 Git remote
  • 首个 Git remote 名称与 URL
  • work tree 是否干净
  • 目录大小
  • 是否值得导出与原因
  • 大目录命中情况
  • 默认忽略目录命中情况
  • 推荐打包策略与原因

导出 bundle/zip 归档

uvx code-porter export ~/code ~/lab ./exports/local-backup

导入归档

uvx code-porter import ./exports/local-backup/manifest.json ~/code/imported

命令

命令 作用
scan 扫描本地目录,分析项目结构
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、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

发布

uv build
uv publish

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

code_porter-0.3.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_porter-0.3.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file code_porter-0.3.0.tar.gz.

File metadata

  • Download URL: code_porter-0.3.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for code_porter-0.3.0.tar.gz
Algorithm Hash digest
SHA256 eeddaf8af419dde4764c9fdb4f154731ea67ce96adb5a59d7e877a7c93a34a34
MD5 186e05ee4faa5dd5f8e4139b1e65edc0
BLAKE2b-256 b116fe14cecd7507149ddc0758d4fcbf21a35a022d82e10558263c76203ae77a

See more details on using hashes here.

Provenance

The following attestation bundles were made for code_porter-0.3.0.tar.gz:

Publisher: publish.yml on star-plan/code-porter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file code_porter-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: code_porter-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for code_porter-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7585d1cee6cd4e6f327d08763c769db94deb922cd5bfdbf59d4c201de7ff5fe6
MD5 a5d84c534bdfb6f7878dd115d3dfb636
BLAKE2b-256 646eb5645623b3576c9e7dd4d6e803b9b101b3da876c62f43a6e98fbf90b7d5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for code_porter-0.3.0-py3-none-any.whl:

Publisher: publish.yml on star-plan/code-porter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page