Skip to content

A tool to snapshot and reproduce development environments across machines.

License

Notifications You must be signed in to change notification settings

BaseMax/go-dev-snapshot

Repository files navigation

go-dev-snapshot

A tool to snapshot and reproduce development environments across machines.

Overview

go-dev-snapshot is a CLI tool that inspects your system and captures information about installed development tools, versions, environment variables, and configuration files. It supports exporting snapshots in both YAML and JSON formats and includes adapters for common development ecosystems (Go, Node.js, Python, Docker).

Features

  • System Inspection: Automatically detects installed development tools and their versions
  • Environment Capture: Records relevant environment variables (PATH, GOPATH, etc.)
  • Ecosystem Adapters: Deep inspection of Go, Node.js, Python, and Docker environments
  • Multiple Formats: Export snapshots as YAML or JSON
  • Compare Mode: Compare two snapshots to see what changed
  • Restore Mode: Generate restoration instructions from a snapshot
  • Configuration Tracking: Track presence and metadata of common config files

Installation

Build from Source

git clone https://github.com/BaseMax/go-dev-snapshot.git
cd go-dev-snapshot
go build -o go-dev-snapshot

Install

go install github.com/BaseMax/go-dev-snapshot@latest

Usage

Create a Snapshot

Capture the current development environment:

# Create a YAML snapshot (default)
./go-dev-snapshot snapshot --output my-env.yaml

# Create a JSON snapshot
./go-dev-snapshot snapshot --output my-env.json --format json

Compare Snapshots

Compare two snapshots to see what changed:

# Compare and print to stdout
./go-dev-snapshot compare --old old-env.yaml --new new-env.yaml

# Save comparison to file
./go-dev-snapshot compare --old old-env.yaml --new new-env.yaml --output diff.yaml

Restore from Snapshot

Get instructions for restoring a development environment:

# Show restoration guide
./go-dev-snapshot restore --input my-env.yaml

# Attempt automatic restoration (experimental)
./go-dev-snapshot restore --input my-env.yaml --auto --dry-run=false

Snapshot Contents

A snapshot includes:

  • System Info: Hostname, OS, architecture, timestamp
  • Tools: Detected development tools with versions and paths
    • Go, Node.js, Python, Docker, Git, Make, GCC, Rust, Java, Ruby, etc.
  • Environment Variables: Important environment variables like PATH, GOPATH, etc.
  • Configuration Files: Presence and metadata of common config files
  • Ecosystem Details: Deep inspection of installed ecosystems:
    • Go: Version, GOPATH, GOROOT, module settings
    • Node.js: Version, npm version, global packages
    • Python: Version, pip version, installed packages
    • Docker: Version, Compose version, available images

Example Snapshot (YAML)

timestamp: 2025-12-19T17:30:05Z
hostname: dev-machine
os: linux
arch: amd64
tools:
  - name: go
    version: go version go1.21.0 linux/amd64
    path: /usr/bin/go
  - name: node
    version: v20.0.0
    path: /usr/local/bin/node
environment:
  PATH: /usr/local/bin:/usr/bin:/bin
  GOPATH: /home/user/go
  HOME: /home/user
ecosystems:
  go:
    version: go version go1.21.0 linux/amd64
    metadata:
      GOPATH: /home/user/go
      GOROOT: /usr/lib/go
  nodejs:
    version: v20.0.0
    metadata:
      npm_version: 10.0.0

Commands

snapshot

Create a snapshot of the current development environment.

Options:

  • --output - Output file path (default: snapshot.yaml)
  • --format - Output format: yaml or json (default: yaml)

compare

Compare two snapshots and show differences.

Options:

  • --old - Old snapshot file (required)
  • --new - New snapshot file (required)
  • --format - Snapshot format: yaml or json (auto-detected from file extension)
  • --output - Output file for diff (optional, prints to stdout if not specified)

restore

Show instructions to restore a snapshot or attempt automatic restoration.

Options:

  • --input - Snapshot file to restore from (required)
  • --format - Snapshot format: yaml or json (auto-detected from file extension)
  • --dry-run - Dry run mode (default: true)
  • --auto - Attempt automatic restoration (experimental)

version

Show version information.

help

Show help message.

Use Cases

Setting up a new development machine

  1. Create a snapshot on your current machine:

    ./go-dev-snapshot snapshot --output dev-env.yaml
  2. Transfer the snapshot to the new machine

  3. Generate restoration instructions:

    ./go-dev-snapshot restore --input dev-env.yaml

Tracking environment changes

  1. Create a baseline snapshot:

    ./go-dev-snapshot snapshot --output baseline.yaml
  2. Make changes to your environment (install tools, update versions, etc.)

  3. Create a new snapshot:

    ./go-dev-snapshot snapshot --output current.yaml
  4. Compare to see what changed:

    ./go-dev-snapshot compare --old baseline.yaml --new current.yaml

Team environment standardization

  1. Share a team snapshot file via version control

  2. Team members can compare their local environment:

    ./go-dev-snapshot snapshot --output my-env.yaml
    ./go-dev-snapshot compare --old team-standard.yaml --new my-env.yaml
  3. Use restore to align environment:

    ./go-dev-snapshot restore --input team-standard.yaml

Architecture

The tool is built with a modular architecture:

  • Inspector: Core system inspection engine
  • Adapters: Pluggable ecosystem-specific inspectors
    • GoAdapter: Go ecosystem inspection
    • NodeAdapter: Node.js/npm ecosystem inspection
    • PythonAdapter: Python/pip ecosystem inspection
    • DockerAdapter: Docker container ecosystem inspection
  • Serialization: YAML and JSON export/import via gopkg.in/yaml.v3
  • Comparison: Diff engine for snapshot comparison
  • Restoration: Guide generation for environment recreation

Contributing

Contributions are welcome! To add support for a new ecosystem:

  1. Implement the Adapter interface
  2. Add your adapter to the NewInspector() function
  3. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Created by BaseMax

About

A tool to snapshot and reproduce development environments across machines.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages