diff --git a/.github/workflows/publish-npm.yaml b/.github/workflows/publish-npm.yaml index 9a66bf4..592a33a 100644 --- a/.github/workflows/publish-npm.yaml +++ b/.github/workflows/publish-npm.yaml @@ -59,6 +59,21 @@ jobs: - name: Clean and Build run: npm run build + - name: Verify package contents + run: | + if [ ! -f lib/index.js ]; then + echo "Error: lib/index.js missing after build. Refusing to publish." + exit 1 + fi + + # Ensure the tarball includes the compiled entrypoint and excludes TypeScript sources + PACK_LIST=$(npm pack --dry-run 2>&1) + echo "$PACK_LIST" + echo "$PACK_LIST" | grep -q 'lib/index.js' || { echo "Error: lib/index.js not in package tarball."; exit 1; } + echo "$PACK_LIST" | grep -q 'src/' && { echo "Error: TypeScript src/ must not be published."; exit 1; } || true + echo "$PACK_LIST" | grep -q 'contracts/' || { echo "Error: contracts/ missing from package tarball."; exit 1; } + echo "Package contents look correct ✅" + - name: Publish Package env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index d58148a..ed5b3d4 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,19 @@ "bin": { "wire-cli": "lib/index.js" }, + "files": [ + "lib", + "contracts", + "blockproducer", + "chain-api", + "bp-relay" + ], "scripts": { "test": "jest", - "start": "tsc && node bin/index.js", + "start": "tsc && node lib/index.js", "build": "tsc", - "watch": "tsc -w" + "watch": "tsc -w", + "prepublishOnly": "npm run build" }, "keywords": [], "author": "Svetla Syrimis",