Skip to content

fix(publish): include dist/ in npm tarball + add publish-guard CI - #2

Merged
nicourrutia98 merged 1 commit into
masterfrom
fix/publish-include-dist
Jun 21, 2026
Merged

nicourrutia98 merged 1 commit into
masterfrom
fix/publish-include-dist

Conversation

@nicourrutia98

Copy link
Copy Markdown
Contributor

Bug

@opita/ocais@2.0.0 published WITHOUT dist/ directory in the npm tarball. Verified via local npm pack: only 3 files (LICENSE, README.md, package.json). Downstream consumers (e.g., Sociedad Opita api/src/api.ts line 15: import { streamText, openai, createSSEWriter } from "@opita/ocais") fail at runtime.

Root cause

Maintainer's package.json had prepublishOnly: "npm run clean && npm run build" but no prepack hook, no tests in prepublishOnly, no CI guard, and clean used Unix-only rm -rf dist (breaks on Windows).

Fix

  • prepack script (NEW): npm run clean && npm run build — fires on npm pack AND npm publish
  • prepublishOnly: now npm test && npm run prepack — gated with tests
  • clean: cross-platform node:fs.rmSync (no more rm -rf Windows bug)
  • publish-guard.yml (NEW): CI workflow runs ci + build + test + pack on every v* tag and PR touching package.json; fails if any of dist/index.js, dist/index.d.ts, dist/lambda/sse-writer.js, or dist/providers/openai-compatible.js missing from tarball

Verification

local pack pre-fix:  3 files (no dist/)
local pack post-fix: 35 files including dist/index.js + .d.ts + 8 dist modules
tests:               17/17 pass via Node 24 test runner

Impact

  • v2.0.1 will be the first release with proper dist/ in the tarball
  • Downstream consumers can pnpm install cleanly without manual workarounds
  • CI catches the bug if it ever recurs

Migration

- "@opita/ocais": "github:Opita-Code/ocais#v2.0.0"
+ "@opita/ocais": "^2.0.1"

Test plan

  1. Merge this PR
  2. git tag v2.0.1 && git push --tags
  3. publish-guard workflow validates v2.0.1 tarball on the tag push
  4. Update downstream consumers (Sociedad Opita PR #9 will use ^2.0.1)

- Add prepack script (clean + build) so npm pack + npm publish both emit dist/
- Tighten prepublishOnly to run tests before prepack
- Make clean cross-platform (node:fs.rmSync instead of rm -rf)
- Add publish-guard workflow: pack on tag/PR, fail if dist/ missing
- Verifies dist/index.js, index.d.ts, lambda/sse-writer.js, providers/openai-compatible.js

v2.0.0 was published without dist/ because prepublishOnly did not run during
npm pack, and the clean script was not cross-platform. v2.0.1 will include it.

Downstream consumer (Sociedad Opita PR #9) needs
\import { streamText } from '@opita/ocais'\ to work after fresh install.
@nicourrutia98
nicourrutia98 merged commit ff3f1bb into master Jun 21, 2026
1 check passed
@nicourrutia98
nicourrutia98 deleted the fix/publish-include-dist branch June 21, 2026 02:00
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