fix(check-publish): only fail on workspace: specs the publish step cannot resolve - #18
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Review complete. 🟡 2 medium 💬 Inline comments (2)
This PR introduces a new
Reviewed commit: c423c42 |
There was a problem hiding this comment.
Adds a checkPublish command that detects unresolved workspace: dependency specs in package manifests and rejects them, with an opt-in --strict mode.
Key findings
- 🟡
--strictdoes not reject allworkspace:specs — checkPublish.ts:45 - 🟡 Non-pnpm workspaces get empty version map — checkPublish.ts:115
| const versions = strict ? new Map<string, string>() : await readWorkspaceVersions(process.cwd()); | ||
| const resolved = leaks.map((leak) => ({ | ||
| ...leak, | ||
| resolvedVersion: resolveWorkspaceSpec(leak.value, versions.get(leak.name)), | ||
| })); | ||
| const unresolved = resolved.filter((leak) => !leak.resolvedVersion); |
There was a problem hiding this comment.
🟡 bug · medium
--strict does not reject all workspace: specs
The --strict flag documented in packages/makage/src/cli.ts:76 as "rejects all" only empties the versions map (checkPublish.ts:45), but resolveWorkspaceSpec returns explicit ranges like workspace:^1.2.3 verbatim (checkPublish.ts:105) even when no workspace version is available, so those specs still resolve and pass strict mode. Only star/bare/caret/tilde specs are rejected, contradicting the documented contract and the flag's intent.
📋 Prompt for AI Agents
In packages/makage/src/commands/checkPublish.ts around lines 45-50, make --strict reject every workspace: spec: when strict is true, mark all leaks as unresolved (set resolvedVersion to undefined for every leak) instead of relying only on the empty versions map, since resolveWorkspaceSpec (line 105) returns explicit ranges verbatim even with no workspace version. This aligns behavior with the --strict rejects all contract documented in packages/makage/src/cli.ts:76-77.
| const raw = await fs.readFile(path.join(root, WORKSPACE_FILE), 'utf8'); | ||
| patterns = parseYaml(raw)?.packages ?? []; | ||
| } catch { | ||
| return versions; | ||
| } |
There was a problem hiding this comment.
🟡 bug · medium
Non-pnpm workspaces get empty version map
readWorkspaceVersions (packages/makage/src/commands/checkPublish.ts:115) reads only pnpm-workspace.yaml, yet findWorkspaceRoot (packages/makage/src/commands/workspace.ts:6) also recognizes lerna.json and a package.json workspaces field as workspace markers. When the root is found through those other markers the YAML read throws and the catch returns an empty version map, so every workspace:*, workspace:^, and workspace:~ spec is reported unresolvable and runCheckPublish falsely exits 1 on a package that would publish fine.
📋 Prompt for AI Agents
In packages/makage/src/commands/checkPublish.ts readWorkspaceVersions (lines 108-131), the function reads only pnpm-workspace.yaml, but findWorkspaceRoot (packages/makage/src/commands/workspace.ts) can return a root detected via lerna.json or a package.json workspaces field. For those workspace types the YAML read throws and the function returns an empty version map, causing runCheckPublish to falsely report every workspace:*/^/~ spec as unresolvable and exit(1). Make version discovery honor the marker that identified the root: when pnpm-workspace.yaml is absent, parse lerna.json packages or the root package.json workspaces array and resolve manifests from there so versions are populated for lerna/npm workspaces too.
Summary
check-publishfailed on anyworkspace:spec indist/package.json, which rejects the normal monorepo layout: pnpm/lerna rewrite those specs to concrete versions at publish time (@agentic-kit/anthropic@1.16.0ships"@agentic-kit/protocol": "1.16.0"). Sincemakage buildruns the check, that made 0.7 unadoptable in workspaces that useworkspace:*internal deps.The check now resolves each spec against the workspace's own package versions and only fails when nothing in the workspace provides the dependency — i.e. when the publish step genuinely cannot substitute a version:
Workspace versions come from
pnpm-workspace.yamlvia the existingfindWorkspacePackageFileshelper.--strictrestores the old behavior (reject everyworkspace:spec).Link to Devin session: https://app.devin.ai/sessions/bb89d57636c84c7383305191a303b1d4
Open in Devin Desktop: https://app.devin.ai/desktop/session/bb89d57636c84c7383305191a303b1d4?variant=devin
Requested by: @pyramation