Skip to content

Update README to remove 'v3' version prefix reference #54

Update README to remove 'v3' version prefix reference

Update README to remove 'v3' version prefix reference #54

Workflow file for this run

name: CI
on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 21]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Type check
run: npm run type-check
- name: Build
run: npm run build
- name: Verify build outputs
run: |
echo "Checking build outputs..."
test -f dist/index.js || (echo "Missing dist/index.js" && exit 1)
test -f dist/index.mjs || (echo "Missing dist/index.mjs" && exit 1)
test -f dist/index.d.ts || (echo "Missing dist/index.d.ts" && exit 1)
echo "Testing CommonJS import..."
node -e "
const lib = require('./dist/index.js');
console.log('CommonJS import successful');
console.log('Exports:', Object.keys(lib));
"
echo "Testing ES Module import..."
node -e "
import('./dist/index.mjs').then(lib => {
console.log('ES Module import successful');
console.log('Exports:', Object.keys(lib));
}).catch(err => {
console.error('ES Module import failed:', err);
process.exit(1);
});
"
- name: Test package installation
run: |
# Create a temporary directory and test package installation
mkdir -p /tmp/test-install
cd /tmp/test-install
npm init -y
npm install ${{ github.workspace }}
# Test that the package can be imported
node -e "
const lib = require('cached-middleware-fetch-next');
console.log('Package installation test successful');
"
- name: Check package size
run: |
npm pack --dry-run
PACKAGE_SIZE=$(npm pack --dry-run 2>/dev/null | grep "package size" | grep -o "[0-9.]*[kMG]*B" || echo "unknown")
echo "Package size: $PACKAGE_SIZE"
# Check if package is too large (warn if > 100KB)
if [ -f "cached-middleware-fetch-next-*.tgz" ]; then
SIZE_BYTES=$(stat -c%s cached-middleware-fetch-next-*.tgz 2>/dev/null || stat -f%z cached-middleware-fetch-next-*.tgz)
if [ "$SIZE_BYTES" -gt 102400 ]; then
echo "⚠️ Warning: Package size is larger than 100KB ($SIZE_BYTES bytes)"
else
echo "✅ Package size is acceptable ($SIZE_BYTES bytes)"
fi
fi
lint:
name: Lint & Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check TypeScript compilation
run: npm run type-check
- name: Check for unused dependencies
run: |
# Basic check for unused dependencies (can be enhanced with tools like depcheck)
echo "Checking for potential issues in package.json..."
# Verify all peer dependencies are reasonable
node -e "
const pkg = require('./package.json');
console.log('Peer dependencies:', pkg.peerDependencies);
console.log('Dev dependencies:', Object.keys(pkg.devDependencies || {}));
// Check if build script exists
if (!pkg.scripts.build) {
console.error('❌ Missing build script');
process.exit(1);
}
// Check if prepublishOnly script exists
if (!pkg.scripts.prepublishOnly) {
console.error('❌ Missing prepublishOnly script');
process.exit(1);
}
console.log('✅ Package.json validation passed');
"
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run security audit
run: |
# Run npm audit but don't fail on low/moderate issues in dev dependencies
npm audit --audit-level=high --production || echo "Security audit completed with warnings"
- name: Check for known vulnerabilities
run: |
# Additional security checks can be added here
echo "Checking for common security issues..."
# Check if package.json has proper security settings
node -e "
const pkg = require('./package.json');
// Check if package is properly configured for public publishing
if (pkg.publishConfig && pkg.publishConfig.access !== 'public') {
console.warn('⚠️ Package may not be configured for public publishing');
}
// Check for proper license
if (!pkg.license) {
console.error('❌ Missing license field');
process.exit(1);
}
console.log('✅ Security checks passed');
"
compatibility:
name: Compatibility Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Check Node.js compatibility
run: |
echo "Checking Node.js compatibility..."
# Check if built files are compatible with target Node version
node -e "
const fs = require('fs');
const path = require('path');
// Check if ES modules are properly configured
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
if (!pkg.main) {
console.error('❌ Missing main field in package.json');
process.exit(1);
}
if (!pkg.module) {
console.error('❌ Missing module field in package.json');
process.exit(1);
}
if (!pkg.types) {
console.error('❌ Missing types field in package.json');
process.exit(1);
}
// Verify files exist
if (!fs.existsSync(pkg.main)) {
console.error('❌ Main file does not exist:', pkg.main);
process.exit(1);
}
if (!fs.existsSync(pkg.module)) {
console.error('❌ Module file does not exist:', pkg.module);
process.exit(1);
}
if (!fs.existsSync(pkg.types)) {
console.error('❌ Types file does not exist:', pkg.types);
process.exit(1);
}
console.log('✅ Compatibility checks passed');
"
# Summary job that depends on all other jobs
ci-success:
name: CI Success
runs-on: ubuntu-latest
needs: [test, lint, security, compatibility]
if: always()
steps:
- name: Check all jobs
run: |
if [[ "${{ needs.test.result }}" == "success" &&
"${{ needs.lint.result }}" == "success" &&
"${{ needs.security.result }}" == "success" &&
"${{ needs.compatibility.result }}" == "success" ]]; then
echo "✅ All CI checks passed!"
else
echo "❌ Some CI checks failed:"
echo "Test: ${{ needs.test.result }}"
echo "Lint: ${{ needs.lint.result }}"
echo "Security: ${{ needs.security.result }}"
echo "Compatibility: ${{ needs.compatibility.result }}"
exit 1
fi