Auto-include built JS in releases — no manual list updates per bundle#93
Merged
Auto-include built JS in releases — no manual list updates per bundle#93
Conversation
Adding a new Vite-built bundle previously required editing two files: - .gitignore (so the build output stays out of git) - bin/package.sh (so the build output gets spliced into the release zip) Both were manual lists that drift the moment someone forgets a step. Now both work from a wildcard: - .gitignore ignores `/assets/js/*.js` and explicitly re-includes the two hand-written tracked files (admin-bar.js, media-library-enhanced.js). Adding a new bundle in vite.config.js no longer requires touching this file. - bin/package.sh derives its splice list from `git ls-files --others --ignored --exclude-standard -- 'assets/js/*.js'`, which lists every gitignored .js that exists on disk. Empty result = the build wasn't run, same error case as before. New bundles are picked up automatically. The sync-to-wp-develop script already rsyncs the whole assets/ tree, so no change is needed there.
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
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.
Summary
Adding a new Vite-built bundle previously required editing two files:
.gitignore— to keep the build output out of git.bin/package.sh— to splice the build output into the plugin zip.Both were hand-maintained lists that drift the first time anyone forgets a step. Concretely,
assets/js/sw.jsandassets/js/sw.min.jsrecently appeared in the worktree as new build output but with no entries in either list.This PR collapses both spots to a wildcard.
.gitignoreAnything new built into
assets/js/is gitignored automatically; the two hand-written tracked files are explicitly re-included.bin/package.shThe hard-coded
builtarray is replaced with:git ls-files --others --ignoredonly returns files that exist on disk, so:Sync script
bin/sync-to-wp-develop.shalready rsyncs the entireassets/directory, so no change is needed there. Same allow-list philosophy, different mechanism.Verification
Local zip after this change:
sw.js/sw.min.jsare picked up without any explicit listing in the script.git check-ignoreconfirms the right files are ignored:Test plan
npm run build && npm run packageproduces a zip with all 8 built bundles + the 2 hand-written tracked ones.rm -rf assets/js/*.js && npm run packageerrors with the "build first" message instead of producing an empty zip.git statusafter runningnpm run buildshows nothing underassets/js/(all built files correctly ignored).build:fooscript that emitsassets/js/foo.jsandfoo.min.js, then re-runningnpm run package, includes both files in the zip with no edits to.gitignoreorbin/package.sh.