fix: clean up service configuration startup and development commands
This commit is contained in:
parent
4ddffa6b67
commit
805a9f8fd4
36 changed files with 627 additions and 596 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { existsSync, readFileSync, mkdtempSync, writeFileSync, chmodSync, rmSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { dirname, join, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
|
|
@ -48,6 +49,47 @@ describe('workspace verification', () => {
|
|||
expect(planned.has('@stock-bot/stock-app#build')).toBe(false);
|
||||
});
|
||||
|
||||
it('research development selects only the API, worker and web application', () => {
|
||||
const result = Bun.spawnSync([process.execPath, 'run', 'dev:research', '--dry=json'], {
|
||||
cwd: root, env: { ...process.env, TURBO_TELEMETRY_DISABLED: '1' },
|
||||
});
|
||||
expect(result.exitCode).toBe(0);
|
||||
const plan = JSON.parse(new TextDecoder().decode(result.stdout));
|
||||
expect(plan.tasks.filter((task: { task: string }) => task.task === 'dev')
|
||||
.map((task: { taskId: string }) => task.taskId).sort()).toEqual([
|
||||
'@stock-bot/orchestrator#dev', '@stock-bot/web-api#dev', '@stock-bot/web-app#dev',
|
||||
]);
|
||||
expect(plan.tasks.every((task: { task: string }) => ['build', 'dev'].includes(task.task))).toBe(true);
|
||||
});
|
||||
|
||||
it('root file-based commands point to existing scripts', () => {
|
||||
for (const command of Object.values(manifest.scripts) as string[]) {
|
||||
const target = command.match(/^(?:bun run |)(\.?\/?(?:scripts|database|apps)\/[^ ]+)/)?.[1];
|
||||
if (target) expect(existsSync(join(root, target))).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('infrastructure aliases use the same stores and propagate Compose failures', () => {
|
||||
expect(manifest.scripts['infra:up']).toBe(manifest.scripts['docker:start']);
|
||||
const temporary = mkdtempSync(join(tmpdir(), 'stock-bot-compose-test-'));
|
||||
try {
|
||||
const docker = join(temporary, 'docker');
|
||||
writeFileSync(docker, '#!/bin/sh\nprintf "%s\\n" "$@"\nexit "${COMPOSE_TEST_EXIT:-0}"\n');
|
||||
chmodSync(docker, 0o755);
|
||||
const invoke = (code: string) => Bun.spawnSync(['bash', 'scripts/docker.sh', 'start'], {
|
||||
cwd: root, env: { ...process.env, PATH: `${temporary}:${process.env.PATH}`, COMPOSE_TEST_EXIT: code },
|
||||
});
|
||||
const success = invoke('0');
|
||||
expect(success.exitCode).toBe(0);
|
||||
const output = new TextDecoder().decode(success.stdout);
|
||||
expect(output).toContain('compose\n-f\ndocker-compose.yml\nup\n-d\ndragonfly\npostgres\nquestdb\nmongodb');
|
||||
expect(output).not.toContain('down');
|
||||
const failed = invoke('23');
|
||||
expect(failed.exitCode).toBe(23);
|
||||
expect(new TextDecoder().decode(failed.stdout)).not.toContain('Infrastructure started!');
|
||||
} finally { rmSync(temporary, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
it('each TypeScript workspace has source inputs covered by the root type check', () => {
|
||||
const checked = new Set(
|
||||
config(join(root, 'tsconfig.check.json')).fileNames.map(file => resolve(file))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue