packkit upgrade — keep a scaffolded project current - #23
Merged
Conversation
The headline follow-up both reviews independently landed on, and the reason 2.9 added the packkit.json provenance file. A project scaffolded by Packkit now has a durable relationship with the tool: it can be pulled up to the current templates instead of drifting. npx create-packkit upgrade # dry run — what changed since scaffold npx create-packkit upgrade --apply # add new files, bump deps, keep edits npx create-packkit upgrade --force # also overwrite files that differ How it works: reads packkit.json (preset + settings) and the name from package.json, regenerates the current recommended output in memory through the embedded API, and diffs it against disk. Reconstruction is faithful — verified byte-for-byte across every preset type. It classifies: - new files Packkit now generates, - added and bumped dependencies (per section), - new and changed scripts, - files that differ (a template change or the user's own edit — can't tell without a stored baseline, so surfaced for review, never auto-overwritten). --apply brings in the safe changes and merges package.json so bumps and new deps/scripts land while the user's own deps, scripts, and field order survive. packkit.json is refreshed to the new version. Files that differ are listed and left untouched unless --force. The decision logic (planUpgrade / buildUpgradeWrite / isUpgradeEmpty) is a pure, exported part of the embedded API and is unit-tested; the CLI reads disk and formats the report. 94 tests pass (5 new), verified end to end: deleted file re-added, removed dep restored, tsup ^7→^8 bumped, a user script preserved, an edited README left alone (then overwritten under --force). Follow-up noted in the roadmap: per-file baseline hashes in packkit.json would let it tell "user edited" from "template changed" precisely. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
The headline both reviews independently landed on, and the reason 2.9 shipped the
packkit.jsonprovenance file. A scaffolded project now has a durable relationship with Packkit: it can be pulled up to the current templates instead of drifting.How it works
Reads
packkit.json(preset + settings) and the name frompackage.json, regenerates the current recommended output in memory through the embedded API, and diffs it against disk. Reconstruction is faithful — verified byte-for-byte across every preset type (ts-lib, node-service, react-app, oss, fullstack).It classifies each difference:
--applybrings in the safe changes and mergespackage.jsonso bumps and new deps/scripts land while the user's own deps, scripts, and field ordering survive.packkit.jsonis refreshed. Differing files are left untouched unless--force.Layering
The decision logic —
planUpgrade,buildUpgradeWrite,isUpgradeEmpty— is a pure, exported part of the embedded API and is unit-tested. The CLI just reads disk and formats the report. Consistent with the architecture: the engine is shared, the CLI is an adapter.Verified end to end
Scaffolded a project, then simulated drift — deleted
.editorconfig, removedvitest, downgradedtsupto^7, added a custom script, edited the README:--apply: file restored, dep re-added, tsup bumped, the custom script preserved, the edited README left alone;packkit.jsonrefreshed to 3.0.0.--forcethen overwrites the README.94 tests pass (5 new). No core change, so the web bundle is untouched.
Follow-up (roadmap): per-file baseline hashes in
packkit.jsonwould let it distinguish "user edited" from "template changed" precisely, instead of surfacing all differing files for review.🤖 Generated with Claude Code