refactor(address-book): consolidate publish source list to one place#1330
refactor(address-book): consolidate publish source list to one place#1330RembrandtK wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors @graphprotocol/address-book publishing to avoid duplicated “which address sources exist” lists and reduce drift between package.json exports and the publish/restore scripts.
Changes:
- Introduces a single
SOURCESlist (scripts/sources.js) consumed by both publish-time copy and postpublish symlink restore scripts. - Switches
package.json#exportsto a subpath pattern so the exports map no longer enumerates each source explicitly. - Makes publish/restore scripts more resilient by creating
src/<name>/as needed, usingrmSync({ force: true }), and adding a drift check to fail ifsrc/contains unexpected source dirs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/address-book/scripts/sources.js | Centralizes the exported address source list. |
| packages/address-book/scripts/restore-symlinks.js | Restores symlinks based on SOURCES and ensures directories exist. |
| packages/address-book/scripts/copy-addresses-for-publish.js | Copies real addresses.json files based on SOURCES and checks for drift under src/. |
| packages/address-book/package.json | Replaces enumerated exports with a wildcard subpath pattern. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1330 +/- ##
=======================================
Coverage 88.62% 88.62%
=======================================
Files 75 75
Lines 4615 4615
Branches 823 823
=======================================
Hits 4090 4090
Misses 504 504
Partials 21 21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The set of packages exported by @graphprotocol/address-book was duplicated
three times: the exports map in package.json, FILES_TO_COPY in
copy-addresses-for-publish.js, and SYMLINKS_TO_RESTORE in restore-symlinks.js.
Drift had already crept in -- issuance was referenced everywhere but
src/issuance/ was missing on disk, which would break prepublishOnly.
Collapse to a single SOURCES array in scripts/sources.js consumed by both
scripts. Use a subpath pattern in package.json exports
("./*/addresses.json": "./src/*/addresses.json") so the exports map no
longer enumerates names.
Both scripts now mkdir src/<name>/ recursively and use rmSync({ force: true })
in place of the existsSync/unlinkSync dance, so a missing dir or stale entry
is handled silently. The copy step ends with a drift check that catches
src/<name>/ dirs not listed in SOURCES (stale leftovers from removed entries).
Verified end-to-end: pnpm pack produces a tarball containing real files
under src/{horizon,issuance,subgraph-service}/addresses.json, and
restore-symlinks puts the symlinks back at the original relative targets.
f7a72f1 to
5014957
Compare
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
The set of packages exported by @graphprotocol/address-book was duplicated three times: the exports map in package.json, FILES_TO_COPY in copy-addresses-for-publish.js, and SYMLINKS_TO_RESTORE in restore-symlinks.js. Drift had already crept in -- issuance was referenced everywhere but src/issuance/ was missing on disk, which would break prepublishOnly.
Collapse to a single SOURCES array in scripts/sources.js consumed by both scripts. Use a subpath pattern in package.json exports (".//addresses.json": "./src//addresses.json") so the exports map no longer enumerates names.
Both scripts now mkdir src// recursively and use rmSync({ force: true }) in place of the existsSync/unlinkSync dance, so a missing dir or stale entry is handled silently. The copy step ends with a drift check that catches src// dirs not listed in SOURCES (stale leftovers from removed entries).
Verified end-to-end: pnpm pack produces a tarball containing real files under src/{horizon,issuance,subgraph-service}/addresses.json, and restore-symlinks puts the symlinks back at the original relative targets.