fix(extension): address PR review comments and improve implementation

- Fixed InternalError class definition in errorHandler.ts
- Updated extension configuration and CI workflows
- Improved error handling and type safety
- Enhanced build and release automation
- Updated documentation and changelogs

Addresses review feedback on PR #997
This commit is contained in:
DavidMaliglowka
2025-07-23 12:27:54 -05:00
parent 14bd559bd6
commit a79fd29036
18 changed files with 610 additions and 200 deletions

91
scripts/release.sh Executable file
View File

@@ -0,0 +1,91 @@
#!/bin/bash
set -e
echo "🚀 Starting release process..."
# Ensure we're in the project root
cd "$(dirname "$0")/.."
echo "📦 Building and packaging extension..."
# Navigate to extension directory and build
cd apps/extension
# Install dependencies (in case they're not cached)
echo "📥 Installing extension dependencies..."
pnpm install --frozen-lockfile
# Run quality checks first (same as CI)
echo "🔍 Running lint checks..."
pnpm run lint
echo "🔍 Running type checks..."
pnpm run check-types
# Build the extension
echo "🔨 Building extension..."
pnpm run build
# Create clean package
echo "📦 Creating clean package..."
pnpm run package
# Verify package contents (same as CI)
echo "🔍 Verifying package contents..."
echo "Checking vsix-build contents..."
ls -la vsix-build/
echo "Checking dist contents..."
ls -la vsix-build/dist/
echo "Checking package.json exists..."
test -f vsix-build/package.json
# Create VSIX package
echo "📦 Creating VSIX package..."
cd vsix-build
pnpm exec vsce package --no-dependencies --out "$PWD"
# Run tests before publishing
echo "🧪 Running extension tests..."
cd ..
# Note: Tests run with xvfb-run in CI, but in release context we'll skip or handle differently
echo "⚠️ Skipping tests in release context (run in CI validation)"
# Go back to project root for tagging and changeset operations
cd ../..
echo "🏷️ Checking extension tag..."
node scripts/tag-extension.mjs
echo "📝 Publishing packages with changesets..."
# Let changesets handle all the npm publishing first
npx changeset publish
echo "🌐 Publishing extension to VS Code Marketplace..."
# Find the generated VSIX file
VSIX_FILE=$(find apps/extension/vsix-build -name "*.vsix" | head -n 1)
if [ -n "$VSIX_FILE" ]; then
echo "Found VSIX file: $VSIX_FILE"
# Publish to VS Code Marketplace
if [ -n "$VSCE_PAT" ]; then
echo "Publishing to VS Code Marketplace..."
npx vsce publish --packagePath "$VSIX_FILE"
else
echo "⚠️ VSCE_PAT not set, skipping VS Code Marketplace publish"
fi
# Publish to Open VSX Registry
if [ -n "$OVSX_PAT" ]; then
echo "Publishing to Open VSX Registry..."
npx ovsx publish --packagePath "$VSIX_FILE"
else
echo "⚠️ OVSX_PAT not set, skipping Open VSX publish"
fi
else
echo "❌ No VSIX file found!"
exit 1
fi
echo "✅ Release process completed!"

52
scripts/tag-extension.mjs Normal file
View File

@@ -0,0 +1,52 @@
#!/usr/bin/env node
import assert from 'node:assert/strict'
import { spawnSync } from 'node:child_process'
import { readFileSync } from 'node:fs'
import { join, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
// Read the extension's publishing package.json for accurate version/name
const extensionDir = join(__dirname, '..', 'apps', 'extension')
const publishPkgPath = join(extensionDir, 'package.publish.json')
let pkg
try {
const pkgContent = readFileSync(publishPkgPath, 'utf8')
pkg = JSON.parse(pkgContent)
} catch (error) {
console.error('Failed to read package.publish.json:', error.message)
process.exit(1)
}
// Ensure we have required fields
assert(pkg.name, 'package.publish.json must have a name field')
assert(pkg.version, 'package.publish.json must have a version field')
assert(pkg.repository, 'package.publish.json must have a repository field')
const tag = `${pkg.name}@${pkg.version}`
// Get repository URL - handle both string and object format
const repoUrl = typeof pkg.repository === 'string'
? pkg.repository
: pkg.repository.url
assert(repoUrl, 'Repository URL not found in package.publish.json')
const { status, stdout, error } = spawnSync('git', [
'ls-remote',
repoUrl,
tag
])
assert.equal(status, 0, error)
const exists = String(stdout).trim() !== ''
if (!exists) {
console.log(`\nNew extension tag: ${tag}`)
} else {
console.log(`\nExtension tag already exists: ${tag}`)
}