* feat(testing): add Playwright E2E infrastructure and stabilize test suite - Add Playwright E2E configuration and ui-navigation / plugin-system tests - Add GitHub Actions workflow for Playwright CI tests - Add test helpers and fixtures (e2e-mock-plugin) - fix(testing): resolve UnverifiedPluginBatchDialog UI blocking issue in E2E tests - fix(testing): limit Playwright to 2 workers locally to avoid Next.js/Prisma exhaustion - fix(api): replace deprecated processAuthCodeResponse with authorizationCodeGrant - test(ui): add data-testid to PanelToggleArrows and AppShell * Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix(ci): restrict GITHUB_TOKEN permissions to read contents * docs(e2e): document Playwright infrastructure and mock plugin lifecycle * fix(e2e): explicitly load .env in teardown and fix dev command pathing * fix(ci): resolve playwright environment setup and database initialization Changes: - Patch: Added pnpm run setup step to .github/workflows/playwright.yml to generate .env in CI - Patch: Added explicit loadEnv() helper to ests/global.setup.ts and ests/global.teardown.ts to ensure database credentials are fresh - Patch: Hardened scripts/safe-db-push.mjs to detect missing DATABASE_URL and explicitly prompt for pnpm run setup rather than assuming production - Patch: Updated scripts/dev.mjs to execute pnpm exec next dev instead of raw ext dev to resolve pathing issues - Patch: Bumped version in package.json to 2.14.4 --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
87 lines
2.3 KiB
JavaScript
87 lines
2.3 KiB
JavaScript
/**
|
|
* @file dev.mjs
|
|
* @description Orchestrator for the local development environment.
|
|
* Replaces direct usage of 'concurrently' via CLI to allow for optional,
|
|
* cross-platform graceful teardown of the Docker database on exit.
|
|
* @module scripts
|
|
*/
|
|
|
|
import concurrently from 'concurrently';
|
|
import kill from 'tree-kill/index.js';
|
|
import { execSync } from 'child_process';
|
|
import fs from 'fs';
|
|
import process from 'process';
|
|
|
|
// Manually parse .env to avoid external dependencies early in the boot process
|
|
const loadEnv = (file) => {
|
|
try {
|
|
if (fs.existsSync(file)) {
|
|
const content = fs.readFileSync(file, 'utf8');
|
|
content.split('\n').forEach(line => {
|
|
const match = line.match(/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/);
|
|
if (match) {
|
|
const key = match[1];
|
|
let value = match[2] || '';
|
|
if (value.startsWith('"') && value.endsWith('"')) value = value.slice(1, -1);
|
|
if (value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
|
|
process.env[key] = value;
|
|
}
|
|
});
|
|
}
|
|
} catch (e) {
|
|
// Ignore read errors
|
|
}
|
|
};
|
|
|
|
loadEnv('.env');
|
|
|
|
const teardownDbOnExit = process.env.WWV_TEARDOWN_DB_ON_EXIT === 'true' || process.env.WWV_TEARDOWN_DB_ON_EXIT === '1';
|
|
|
|
const { result, commands } = concurrently(
|
|
[
|
|
{ command: 'pnpm run dev:plugins', name: 'plugins', prefixColor: 'magenta' },
|
|
{ command: 'pnpm exec next dev', name: 'next', prefixColor: 'blue' }
|
|
],
|
|
{
|
|
prefix: 'name',
|
|
killOthers: ['failure', 'success']
|
|
}
|
|
);
|
|
|
|
let isShuttingDown = false;
|
|
|
|
const shutdown = () => {
|
|
if (isShuttingDown) return;
|
|
isShuttingDown = true;
|
|
|
|
console.log('\n🛑 Shutting down dev servers...');
|
|
|
|
// Forcefully kill the process tree of each command cross-platform
|
|
commands.forEach(cmd => {
|
|
if (cmd.pid) {
|
|
kill(cmd.pid, 'SIGKILL');
|
|
}
|
|
});
|
|
|
|
if (teardownDbOnExit) {
|
|
console.log('📦 Tearing down local PostgreSQL database...');
|
|
try {
|
|
execSync('docker compose stop db', { stdio: 'inherit' });
|
|
console.log('✅ Local database stopped.');
|
|
} catch (e) {
|
|
console.error('⚠️ Failed to stop database container.');
|
|
}
|
|
}
|
|
|
|
process.exit(0);
|
|
};
|
|
|
|
// Listen for termination signals
|
|
process.on('SIGINT', shutdown);
|
|
process.on('SIGTERM', shutdown);
|
|
|
|
result.then(
|
|
() => process.exit(0),
|
|
() => process.exit(1)
|
|
);
|