PSA/scripts/guard-ce-workflows-next-build.mjs
Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

89 lines
2.3 KiB
JavaScript

import { spawnSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const repoRoot = path.resolve(__dirname, '..');
const serverDir = path.join(repoRoot, 'server');
const nextDir = path.join(serverDir, '.next');
const nextServerDir = path.join(nextDir, 'server');
const nextStaticDir = path.join(nextDir, 'static');
const needle = 'Workflow designer requires Enterprise Edition. Please upgrade to access this feature.';
const needleBytes = Buffer.from(needle, 'utf8');
function walkFiles(rootDir) {
const stack = [rootDir];
const files = [];
while (stack.length) {
const current = stack.pop();
const entries = fs.readdirSync(current, { withFileTypes: true });
for (const entry of entries) {
const entryPath = path.join(current, entry.name);
if (entry.isDirectory()) {
stack.push(entryPath);
} else if (entry.isFile()) {
files.push(entryPath);
}
}
}
return files;
}
function scanForNeedle(targetDir) {
if (!fs.existsSync(targetDir)) {
return [];
}
const matches = [];
const files = walkFiles(targetDir);
for (const filePath of files) {
const contents = fs.readFileSync(filePath);
if (contents.includes(needleBytes)) {
matches.push(filePath);
}
}
return matches;
}
const args = new Set(process.argv.slice(2));
const skipBuild = args.has('--skip-build');
if (!skipBuild) {
fs.rmSync(nextDir, { recursive: true, force: true });
const build = spawnSync('npm', ['-w', 'server', 'run', 'build'], {
cwd: repoRoot,
stdio: 'inherit',
env: {
...process.env,
EDITION: 'community',
NEXT_PUBLIC_EDITION: 'community',
},
});
if (typeof build.status === 'number' && build.status !== 0) {
process.exit(build.status);
}
if (build.error) {
throw build.error;
}
}
const hits = [...scanForNeedle(nextServerDir), ...scanForNeedle(nextStaticDir)];
if (!hits.length) {
console.error(`\n[guard-ce-workflows-next-build] FAIL: did not find workflows CE stub string in CE build output under ${nextDir}\n`);
process.exit(1);
}
console.log(`[guard-ce-workflows-next-build] OK: found workflows CE stub string in CE build output (${hits.length} file(s))`);