Skip to content

fix: resolve LICENSE and FOOTER.md from workspace root instead of hardcoded ../../#3

Merged
pyramation merged 2 commits intomainfrom
feat/find-workspace-root
Feb 7, 2026
Merged

fix: resolve LICENSE and FOOTER.md from workspace root instead of hardcoded ../../#3
pyramation merged 2 commits intomainfrom
feat/find-workspace-root

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Feb 7, 2026

fix: resolve LICENSE and FOOTER.md from workspace root dynamically

Summary

Replaces hardcoded ../../LICENSE and ../../FOOTER.md relative paths in runAssets and copyReadmeWithFooter with dynamic workspace root resolution. Packages at any nesting depth within a monorepo now resolve these files correctly, and missing files are skipped gracefully instead of crashing the build.

A new workspace.ts module provides two utilities:

  • findWorkspaceRoot(from) — walks up from from looking for pnpm-workspace.yaml, lerna.json, or package.json with workspaces
  • findRootFile(filename, from) — resolves a file relative to the workspace root

Both are exported from the package index for downstream use.

runAssets calls findWorkspaceRoot once, then resolves both LICENSE and FOOTER.md against the discovered root via a local resolveRootFile helper.

Review & Testing Checklist for Human

  • No tests for findWorkspaceRoot or findRootFile. The core new logic has zero test coverage. Walk-up termination, marker priority, filesystem boundary, and the access-then-read pattern are all untested. Consider adding a workspace.test.ts.
  • Non-workspace packages lose LICENSE copying entirely. If no workspace root is found (standalone package, no pnpm-workspace.yaml/lerna.json/workspaces field), findRootFile returns null and LICENSE is silently skipped. The old ../../LICENSE at least had a chance of working for flat repos. Decide if this is acceptable or if a fallback is needed.
  • Empty catch {} blocks in workspace.ts swallow all errors (not just ENOENT). Permission errors on directories during the walk would be silently ignored.
  • Test plan: Run makage build from a package nested 3+ levels deep in a pnpm workspace and verify LICENSE and FOOTER.md are correctly resolved. Also run from a standalone (non-workspace) package to verify the skip behavior is acceptable.

Notes

  • Motivation: uploads/etag-hash in the constructive monorepo was failing with ENOENT: no such file or directory, copyfile '../../LICENSE' -> 'dist/LICENSE' because the package isn't exactly 2 levels deep from the workspace root.
  • The --footer flag on makage copy still works but now uses findRootFile internally instead of hardcoded ../../FOOTER.md.
  • Downstream consumers don't need any changes — makage build / makage assets CLI syntax is unchanged.

Link to Devin run: https://app.devin.ai/sessions/a93d427c49214dce877d1fedee950c04
Requested by: @pyramation

@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit c94a3db into main Feb 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant