Files
claude-ms-todo/scripts/build-plugin.sh

30 lines
1.3 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
# Build ms-todo.plugin (the Cowork/Claude Code plugin bundle).
#
# The plugin uploader rejects zip entries containing "@" (npm scope directories
# like node_modules/@modelcontextprotocol), so we don't ship node_modules at
# all: esbuild bundles the server and its dependencies into a single ESM file.
# Output: ./ms-todo.plugin with contents at the archive root, as the plugin
# format requires.
set -euo pipefail
cd "$(dirname "$0")/.."
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
cp -R plugin/.claude-plugin "$STAGE/.claude-plugin"
cp plugin/.mcp.json plugin/README.md "$STAGE/"
mkdir -p "$STAGE/server"
# Sync the canonical core client into the extension, then install prod deps.
(cd mcp-extension && npm run sync --silent && npm ci --omit=dev --silent)
# The require() shim is for CJS dependencies inside the ESM bundle.
npx -y esbuild mcp-extension/server/index.mjs \
--bundle --platform=node --format=esm --target=node18 \
--banner:js="import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);" \
--outfile="$STAGE/server/index.mjs" --log-level=warning
rm -f ms-todo.plugin
(cd "$STAGE" && zip -qr - . -x "*.DS_Store") > ms-todo.plugin
echo "Built $(pwd)/ms-todo.plugin ($(du -h ms-todo.plugin | cut -f1 | tr -d ' '))"