Build MerchantFlow onboarding CRM foundation

This commit is contained in:
Oleksandr Prokhorenko
2026-09-24 16:43:22 +03:00
commit 3aa47d825f
78 changed files with 10739 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import { spawn } from 'node:child_process';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
// Stop both processes together, including when Turbo or Playwright stops this task.
const children = [
spawn(
process.execPath,
[require.resolve('typescript/bin/tsc'), '--watch', '--preserveWatchOutput'],
{ stdio: 'inherit' },
),
spawn(process.execPath, ['--watch', 'dist/main.js'], { stdio: 'inherit' }),
];
let stopping = false;
function stop(code = 0) {
if (stopping) return;
stopping = true;
for (const child of children) child.kill('SIGTERM');
process.exitCode = code;
}
process.on('SIGINT', () => stop());
process.on('SIGTERM', () => stop());
for (const child of children) {
child.on('error', (error) => {
console.error(error.message);
stop(1);
});
child.on('exit', (code) => {
if (!stopping) stop(code ?? 1);
});
}
+32
View File
@@ -0,0 +1,32 @@
import { spawn } from 'node:child_process';
import { createRequire } from 'node:module';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
// Tests use prebuilt API code, without starting persistent compiler/Turbo watchers.
const root = fileURLToPath(new URL('../', import.meta.url));
const web = resolve(root, 'apps/web');
const require = createRequire(resolve(web, 'package.json'));
const vite = resolve(dirname(require.resolve('vite/package.json')), 'bin/vite.js');
const children = [
spawn(process.execPath, [resolve(root, 'apps/api/dist/main.js')], { stdio: 'inherit' }),
spawn(process.execPath, [vite, '--host', '127.0.0.1'], { cwd: web, stdio: 'inherit' }),
];
let stopping = false;
function stop(code = 0) {
if (stopping) return;
stopping = true;
for (const child of children) child.kill('SIGTERM');
process.exitCode = code;
}
process.on('SIGINT', () => stop());
process.on('SIGTERM', () => stop());
for (const child of children) {
child.on('error', (error) => {
console.error(error.message);
stop(1);
});
child.on('exit', (code) => {
if (!stopping) stop(code ?? 1);
});
}
+22
View File
@@ -0,0 +1,22 @@
import { spawnSync } from 'node:child_process';
const mode = process.argv[2];
if (!['integration', 'browser'].includes(mode)) throw new Error('Choose integration or browser');
// This dedicated service is intentionally independent of the development database.
const env = {
...process.env,
DATABASE_URL: 'postgresql://merchantflow:merchantflow_local@localhost:55441/merchantflow_test',
API_PORT: '3002',
WEB_PORT: '5174',
APP_ORIGIN: 'http://127.0.0.1:5174',
};
function run(command, args) {
const result = spawnSync(command, args, { stdio: 'inherit', env });
if (result.error) throw result.error;
if (result.status !== 0) process.exit(result.status ?? 1);
}
run('docker', ['compose', '--profile', 'test', 'up', '-d', '--wait', 'db-test']);
run('pnpm', ['exec', 'turbo', 'run', 'build']);
run('pnpm', ['--filter', '@merchantflow/database', 'migrate']);
run('pnpm', ['--filter', '@merchantflow/database', 'seed']);
if (mode === 'integration') run('node', ['--test', 'apps/api/test/integration.test.mjs']);
else run('pnpm', ['exec', 'playwright', 'test']);