| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | |
| 5 | usage() { |
| 6 | cat <<'EOF' |
| 7 | Usage: |
| 8 | bash ./publish.sh package |
| 9 | bash ./publish.sh publish [vsce-args...] |
| 10 | |
| 11 | Examples: |
| 12 | bash ./publish.sh package |
| 13 | bash ./publish.sh publish |
| 14 | bash ./publish.sh publish patch |
| 15 | |
| 16 | Notes: |
| 17 | - Run this from WSL or another Unix-like shell. |
| 18 | - Export VSCE_PAT before publish. |
| 19 | - The script uses npm/npx and skips vsce dependency scanning because |
| 20 | this extension ships the bundled dist output, not node_modules. |
| 21 | EOF |
| 22 | } |
| 23 | |
| 24 | require_command() { |
| 25 | if ! command -v "$1" >/dev/null 2>&1; then |
| 26 | echo "Missing required command: $1" >&2 |
| 27 | exit 1 |
| 28 | fi |
| 29 | } |
| 30 | |
| 31 | main() { |
| 32 | local action="${1:-}" |
| 33 | if [[ -z "$action" ]]; then |
| 34 | usage |
| 35 | exit 1 |
| 36 | fi |
| 37 | shift || true |
| 38 | |
| 39 | require_command npm |
| 40 | require_command npx |
| 41 | |
| 42 | cd "$(dirname "$0")" |
| 43 | |
| 44 | rm -rf node_modules package-lock.json |
| 45 | npm install --include=dev |
| 46 | npm run package |
| 47 | |
| 48 | case "$action" in |
| 49 | package) |
| 50 | npx @vscode/vsce package --no-dependencies "$@" |
| 51 | ;; |
| 52 | publish) |
| 53 | if [[ -z "${VSCE_PAT:-}" ]]; then |
| 54 | echo "VSCE_PAT is required for publish." >&2 |
| 55 | exit 1 |
| 56 | fi |
| 57 | npx @vscode/vsce publish --no-dependencies "$@" |
| 58 | ;; |
| 59 | *) |
| 60 | usage |
| 61 | exit 1 |
| 62 | ;; |
| 63 | esac |
| 64 | } |
| 65 | |
| 66 | main "$@" |