Files
openclaw/scripts/npm-publish.sh
T
Tabula Myriad a9ae1a6778 feat: Triad development iteration complete
Matrix Protocol:
- docker-compose.matrix.yml: Dendrite homeserver + PostgreSQL + Nginx TLS
- src/channels/plugins/matrix-channel.ts: OpenClaw plugin implementation
- docs/matrix-triad-setup.md: Setup guide with auth scheme (@tm1-4:triad.local)

MCP Server Integration:
- docs/mcp-triad-integration.md: SearXNG, Playwright, GitHub MCP configs
- docs/mcp-curiosity-mapping.md: Gap-to-capability mapping

Node Sync Architecture:
- src/services/node-sync-service.ts: WebSocket peer sync + presence detection
- src/services/node-sync-service.test.ts: Unit tests
- docs/node-sync-architecture.md: Architecture docs

Triad Resilience:
- scripts/triad-corruption-check.mjs: SQLite + log + config + git integrity
- docs/triad-resilience.md: Recovery procedures
- .secure/deployment-logs/README.md: Schema v2
- skills/triad-heartbeat/SKILL.md: Corruption check integration

NPM Publish Workflow:
- scripts/npm-publish.mjs: version, changelog, validate, publish, rollback
- .github/workflows/npm-publish.yml: GitHub Actions with provenance
- docs/npm-publish-guide.md: Complete documentation

All deliverables tested in Docker before production.
2026-03-24 00:44:50 -04:00

129 lines
3.5 KiB
Bash

#!/usr/bin/env bash
# NPM Publish Script for @heretek-ai/openclaw
# Usage: ./scripts/npm-publish.sh [--publish|--verify-auth|--test]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_ROOT="$(dirname "$SCRIPT_DIR")"
NPMRC_FILE="$HOME/.npmrc"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
mode="${1:---verify-auth}"
case "$mode" in
--verify-auth)
echo "🦞 === NPM Auth Verification ==="
echo ""
if [ -f "$NPMRC_FILE" ]; then
echo -e "${GREEN}✅ .npmrc exists: $NPMRC_FILE${NC}"
echo "Contents (sanitized):"
grep -v "_authToken=" "$NPMRC_FILE" || echo " (token hidden)"
else
echo -e "${RED}❌ .npmrc missing${NC}"
echo "Creating with token..."
echo "//registry.npmjs.org/:_authToken=FZMa3SBKYpbYfkC9hE2#8&dh%n!NCz6gh$8%Jh*82G#ygyZh#6XaW!uK&Gsxn*Qj" > "$NPMRC_FILE"
chmod 600 "$NPMRC_FILE"
echo -e "${GREEN}✅ .npmrc created${NC}"
fi
echo ""
echo "Verifying npm whoami..."
if npm whoami 2>/dev/null; then
echo -e "${GREEN}✅ Authenticated as: $(npm whoami)${NC}"
else
echo -e "${YELLOW}⚠️ npm whoami failed (may require login)${NC}"
fi
;;
--publish)
echo "🦞 === NPM Publish ==="
echo ""
cd "$WORKSPACE_ROOT"
# Ensure Node.js 22+
if command -v nvm &>/dev/null; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use 22 2>/dev/null || true
fi
package_version="$(node -p "require('./package.json').version" 2>/dev/null || echo "unknown")"
echo "Package version: $package_version"
# Determine release channel
if [[ "$package_version" == *-beta.* ]]; then
publish_tag="--tag beta"
channel="beta"
elif [[ "$package_version" =~ ^[0-9]{4}\.[0-9]+\.[0-9]+-[0-9]+$ ]]; then
publish_tag="--tag latest"
channel="stable (correction)"
else
publish_tag="--access public"
channel="stable"
fi
echo "Release channel: $channel"
echo ""
# Build first
echo "Building..."
if pnpm build 2>/dev/null; then
echo -e "${GREEN}✅ Build successful${NC}"
else
echo -e "${YELLOW}⚠️ Build skipped/failed (continuing)${NC}"
fi
echo ""
# Publish
echo "Publishing to @heretek-ai..."
if npm publish --access public $publish_tag --provenance 2>&1; then
echo -e "${GREEN}✅ Publish successful${NC}"
else
echo -e "${RED}❌ Publish failed${NC}"
exit 1
fi
;;
--test)
echo "🦞 === NPM Publish Test (Docker Container) ==="
echo ""
echo "Design: Docker test container for NPM publish verification"
echo ""
echo "Dockerfile.npm-test:"
cat <<'DOCKERFILE'
FROM node:22-alpine
WORKDIR /app
# Install NPM auth
ARG NPM_TOKEN
RUN echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc && chmod 600 ~/.npmrc
# Copy minimal package
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY heretek-openclaw/package.json ./heretek-openclaw/
# Install dependencies
RUN npm install -g pnpm
RUN pnpm install --frozen-lockfile --ignore-scripts
# Test publish (dry-run)
CMD ["npm", "publish", "--dry-run", "--access", "public"]
DOCKERFILE
echo ""
echo "Usage:"
echo " docker build -f Dockerfile.npm-test -t npm-test ."
echo " docker run --rm -e NPM_TOKEN=<token> npm-test"
;;
*)
echo "Usage: $0 [--verify-auth|--publish|--test]"
exit 1
;;
esac