PSA/scripts/temporal-worker-dist-import-smoke.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

117 lines
3.7 KiB
JavaScript

#!/usr/bin/env node
import fs from 'node:fs';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { spawnSync } from 'node:child_process';
const REPO_ROOT = process.cwd();
function run(command, args, options = {}) {
const result = spawnSync(command, args, {
cwd: REPO_ROOT,
stdio: 'inherit',
...options,
});
if (result.status !== 0) {
throw new Error(`Command failed: ${command} ${args.join(' ')}`);
}
}
function findExistingPath(candidates) {
for (const relPath of candidates) {
const absPath = path.join(REPO_ROOT, relPath);
if (fs.existsSync(absPath)) return absPath;
}
return null;
}
function ensureEventSchemasDistBuilt() {
const distIndex = path.join(REPO_ROOT, 'packages/event-schemas/dist/index.js');
if (fs.existsSync(distIndex)) {
return;
}
console.log('Building packages/event-schemas for dist import smoke test...');
run('npm', ['--prefix', 'packages/event-schemas', 'run', 'build']);
}
function buildWorkspaceIfScriptExists(relPath) {
const pkgPath = path.join(REPO_ROOT, relPath, 'package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
if (!pkg.scripts?.build) {
return;
}
console.log(`Building ${relPath} for dist import smoke test...`);
run('npm', ['--prefix', relPath, 'run', 'build']);
}
async function importModule(absPath) {
await import(pathToFileURL(absPath).href);
}
async function main() {
for (const relPath of [
'packages/core',
'packages/types',
'packages/event-bus',
'packages/validation',
'packages/db',
// shared/workflow/runtime/actions/businessOperations/crm.ts imports
// @alga-psa/authorization/{kernel,bundles/service}; the smoke test
// resolves these from packages/authorization/dist at runtime, so build
// it before shared.
'packages/authorization',
]) {
buildWorkspaceIfScriptExists(relPath);
}
console.log('Building shared for dist import smoke test...');
run('npm', ['--prefix', 'shared', 'run', 'build']);
console.log('Building ee/packages/workflows for dist import smoke test...');
run('npm', ['--prefix', 'ee/packages/workflows', 'run', 'build']);
console.log('Building ee/temporal-workflows for dist import smoke test...');
run('npm', ['--prefix', 'ee/temporal-workflows', 'run', 'build']);
ensureEventSchemasDistBuilt();
const workerEntry = findExistingPath([
'ee/temporal-workflows/dist/worker.js',
'ee/temporal-workflows/dist/src/worker.js',
'ee/temporal-workflows/dist/ee/temporal-workflows/src/worker.js',
]);
const activitiesEntry = findExistingPath([
'ee/temporal-workflows/dist/activities/index.js',
'ee/temporal-workflows/dist/src/activities/index.js',
'ee/temporal-workflows/dist/ee/temporal-workflows/src/activities/index.js',
]);
const workflowsEntry = findExistingPath([
'ee/temporal-workflows/dist/workflows/index.js',
'ee/temporal-workflows/dist/src/workflows/index.js',
'ee/temporal-workflows/dist/ee/temporal-workflows/src/workflows/index.js',
]);
const required = [
['worker', workerEntry],
['activities', activitiesEntry],
['workflows', workflowsEntry],
];
for (const [label, modulePath] of required) {
if (!modulePath) {
throw new Error(`Could not locate built ${label} entry in dist output`);
}
}
console.log('Importing built worker modules...');
await importModule(workerEntry);
await importModule(activitiesEntry);
await importModule(workflowsEntry);
console.log('Temporal worker dist import smoke check passed.');
}
main().catch((error) => {
console.error('\nTemporal worker dist import smoke check failed.\n');
console.error(error instanceof Error ? error.message : error);
process.exit(1);
});