Documentation
¶
Overview ¶
Package migrate provides migration helpers for legacy nSelf project layouts. The v1→v2 migration lives in internal/migration. This package handles the older v0.9.9 Bash-era migration path (--from-bash).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoMigrateResult ¶
type AutoMigrateResult struct {
// BackupDir is the path where the backup was written, or empty if skipped.
BackupDir string
// ActionsPerformed lists the steps that were executed.
ActionsPerformed []string
// Skipped lists steps that were skipped (already done or not auto-migratable).
Skipped []string
}
AutoMigrateResult summarises what RunAuto accomplished.
func RunAuto ¶
func RunAuto(projectDir string, result BashDetectResult) (*AutoMigrateResult, error)
RunAuto performs the automatable migration steps for a v0.9.9 Bash-era project. It only acts on artifacts marked AutoMigratable=true in the detection result.
RunAuto is idempotent: re-running on an already-migrated project detects no artifacts and returns immediately with nothing done.
The caller is responsible for prompting the operator for confirmation before calling RunAuto. RunAuto itself does not prompt.
type BashDetectResult ¶
type BashDetectResult struct {
// Artifacts is the list of v0.9.9 artifacts found. Empty means clean.
Artifacts []BashEraArtifact
// AlreadyMigrated is true when the project directory shows no Bash-era
// artifacts at all — the project is already on the Go-based CLI.
AlreadyMigrated bool
}
BashDetectResult holds the outcome of DetectBashEra.
func DetectBashEra ¶
func DetectBashEra(projectDir string) BashDetectResult
DetectBashEra scans projectDir for v0.9.9 Bash-era artifacts. It does not modify anything — detection is always read-only.
The function returns BashDetectResult. When AlreadyMigrated is true and Artifacts is empty, the project is clean and nothing needs to be done.
False positives are avoided by requiring the artifact to be unambiguously Bash-era (e.g. .nself/config.sh must contain NSELF_VERSION= with a 0.9.x value, not just any shell file named config.sh).
type BashEraArtifact ¶
type BashEraArtifact struct {
// Path is the path relative to the project directory where the artifact
// was found.
Path string
// Description is a human-readable description of what the artifact is.
Description string
// Action is the exact step the operator must take to resolve it.
Action string
// AutoMigratable is true when RunAuto can handle this artifact without
// operator input beyond the initial confirmation.
AutoMigratable bool
}
BashEraArtifact describes a v0.9.9 Bash-era artifact found in a project directory. Each artifact carries the action the operator must take.
type MigrationStep ¶
type MigrationStep struct {
// Number is the 1-based step index.
Number int
// Title is a short description of the step.
Title string
// Commands are the exact shell commands to run, ready to copy-paste.
Commands []string
// Notes is optional additional context.
Notes string
// P98Scope marks steps that are deferred to P98 automated migration.
P98Scope bool
}
MigrationStep is a step in the printed migration checklist.
func MigrationChecklist ¶
func MigrationChecklist(projectDir string) []MigrationStep
MigrationChecklist returns the full ordered list of steps to migrate a v0.9.9 Bash-era project to the current nSelf CLI.
Steps are always returned in full, regardless of which artifacts were detected. The caller should present them to the operator even when some steps are already complete — idempotency is noted per step.
type V099DetectResult ¶
type V099DetectResult struct {
// LegacyDir is the absolute path to ~/.nself/v099-state/ (whether or not
// it exists).
LegacyDir string
// Found is the list of recognised legacy entries that exist on disk.
Found []V099HomeState
// Present is true if the legacy directory exists on disk at all.
Present bool
}
V099DetectResult holds the outcome of DetectV099Home.
func DetectV099Home ¶
func DetectV099Home(homeDir string) V099DetectResult
DetectV099Home returns a read-only summary of legacy v0.9.9 home-level state. It does not modify anything.
homeDir is normally os.UserHomeDir(); tests inject a temp directory.
type V099HomeState ¶
type V099HomeState struct {
// LegacyPath is the path inside ~/.nself/v099-state/.
LegacyPath string
// Description is a human-readable label used in the report.
Description string
// NewPath is where the v1.x CLI expects the equivalent data, or empty
// when there is no automatic destination (operator must re-enter
// manually).
NewPath string
// Action is a short instruction printed alongside the entry.
Action string
}
V099HomeState describes one entity inside ~/.nself/v099-state/ that the shim recognises and knows how to migrate.
type V099MigrationResult ¶
type V099MigrationResult struct {
// BackupDir is the timestamped backup directory the shim wrote.
BackupDir string
// Migrated lists entries that were successfully copied/moved to v1.x
// destinations.
Migrated []string
// Backed lists entries that were backed up but had no v1.x destination
// (user must re-enter manually).
Backed []string
// Warnings are non-fatal issues encountered during migration.
Warnings []string
}
V099MigrationResult summarises what RunV099Migration accomplished.
func RunV099Migration ¶
func RunV099Migration(homeDir string) (*V099MigrationResult, error)
RunV099Migration performs the home-level shim migration. It is opt-in and idempotent: running it twice does nothing the second time (the legacy directory is moved aside on first success).
homeDir is normally os.UserHomeDir(); tests inject a temp directory.
On success the legacy ~/.nself/v099-state/ is renamed to ~/.nself/v099-state.migrated.<ts>/ so the operator still has the original data if they need it, but DetectV099Home no longer reports it.