feat/file-migrations#241
Merged
Merged
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #241 +/- ##
==========================================
- Coverage 91.28% 89.86% -1.43%
==========================================
Files 32 45 +13
Lines 574 730 +156
Branches 65 81 +16
==========================================
+ Hits 524 656 +132
- Misses 50 74 +24 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a file migration system so model changes that alter JSON shape no longer break loading of existing
~/.ptah/resources (settings, shows, programs). Files are stamped with the app version; on load the repository runs an app-version-keyed migration chain over the raw JSON, backs up the original under~/.ptah/.backups/, writes the upgraded file back, then validates with the existing Zod model. Ships the first real migration, fixing program loading broken by thetargetIntput → targetInputedge-field rename in #218.Type of Change
Changes Made
packages/lib-shared/src/migrations/): purerunMigrations(raw, chain, {from, to})applying migrations in(from, to]ascending semver order + re-stamping; smallsemver.tscomparator (no new dep).BASELINE_VERSION+getCurrentAppVersion()inlib-models; optionalversionfield on the show & program models;createSettingsstamps the current version.repositories/migrate-resource.ts(loadAndMigrate) wired into the show, program, and settings repositories; saves stamp the current version. Backups land at~/.ptah/.backups/<resource>/<name>.<oldversion>.json.targetIntput → targetInputfor programs (idempotent), keyed to0.3.0so it runs on legacy/baseline files (feat/tests-and-bugs #218).app,lib-models,lib-shared,lib-domains) →0.3.0, matching the migration's target version.AGENTS.md; design + plan underdocs/superpowers/.Testing
Added 26 lib-shared tests (semver, engine, program migration,
loadAndMigrate, and per-repository temp-dir integration covering legacy migration, version stamping, and backup behavior) plus model/domain test updates.pnpm allcheckpasses (10/10 tasks: format → lint → typecheck → build → test).Checklist
Related Issues
Fixes the program-loading regression introduced by #218 (
targetIntput → targetInput).Additional Notes
AGENTS.md): when a model change breaks an old file, add one{ version, up }entry to that resource's chain inlib-shared/src/migrations/, writeupagainst plain JSON and make it idempotent, add a fixture test, and bump the app version via changeset. Migrations only run for files stamped older than the currentAPP_VERSION.pnpm iaborts on themidipackage's native rebuild (node-gypmissing locally); it does not affect build/test (pnpm allcheckis green) sinceservice-midimocks the binding in tests.