migration

package
v1.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DetectionThreshold = 2

DetectionThreshold is the minimum number of v0.9 artifacts required to trigger a hard failure in start/build/up. A single artifact causes a warning but proceeds; two or more artifacts block the command until migrated. This prevents false positives from projects that happen to share one artifact name.

Variables

This section is empty.

Functions

func CheckLegacyProject added in v1.0.11

func CheckLegacyProject(projectDir string) (count int, names []string)

CheckLegacyProject inspects the given directory and returns (count, artifact names). If count >= DetectionThreshold the caller should fail; if count == 1 it should warn. If count == 0 the project is clean. Reuses Detect() internals.

func Rollback

func Rollback(ctx context.Context, projectDir, backupTimestamp string) error

Rollback restores a project from a backup created by Run. If backupTimestamp is empty, the most recent backup is used.

func Run

func Run(ctx context.Context, projectDir string) error

Run performs a full v1 → v2 migration. It is idempotent: running on an already-migrated project prints a message and exits cleanly.

Types

type BackupFileEntry

type BackupFileEntry struct {
	// Source is the path relative to the project directory.
	Source string `json:"source"`
	// Dest is the path relative to the backup directory.
	Dest string `json:"dest"`
}

BackupFileEntry describes a single backed-up file or directory.

type BackupInfo

type BackupInfo struct {
	Timestamp string
	Dir       string
	// Size is the total size of all files in the backup directory, in bytes.
	Size int64
}

BackupInfo describes an available backup for listing.

func ListBackups

func ListBackups(projectDir string) ([]BackupInfo, error)

ListBackups returns all available backups sorted newest-first. Returns an empty slice (not an error) when no backups exist.

type BackupManifest

type BackupManifest struct {
	Timestamp  string            `json:"timestamp"`
	ProjectDir string            `json:"project_dir"`
	Files      []BackupFileEntry `json:"files"`
}

BackupManifest records what was backed up during a migration.

type LegacyArtifact

type LegacyArtifact struct {
	Path        string
	Description string
	Action      string // what the user should do
}

LegacyArtifact describes a v1 artifact found in a project directory.

func Detect

func Detect(projectDir string) []LegacyArtifact

Detect scans the given directory for v0.9 artifacts. Returns an empty slice if no artifacts are found (clean v2 project or new project). No os.Exit calls — errors from file reads are treated as absent artifacts.

type LegacyGlobalArtifact added in v1.0.11

type LegacyGlobalArtifact struct {
	// Path is the absolute path where the artifact was found.
	Path string
	// Kind describes what the artifact is (e.g. "plugin directory", "config cache").
	Kind string
	// Hint is the exact shell command the user should run to clean it up.
	Hint string
}

LegacyGlobalArtifact describes a stale v0.9 path found on the host system outside of any specific project directory.

func ScanLegacyPaths added in v1.0.11

func ScanLegacyPaths() []LegacyGlobalArtifact

ScanLegacyPaths scans the host for v0.9 global artifacts and returns a slice describing every stale path found. Returns an empty slice on a clean install.

Errors from permission-denied paths are recorded as warnings (Kind="permission denied"), not fatal — the caller receives a best-effort result.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL