import { execFile } from 'node:child_process'; import { mkdtemp, writeFile, rm } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { promisify } from 'node:util'; const exec = promisify(execFile); const cli = join(process.cwd(), 'dist', 'index.js'); const binary = join(process.cwd(), 'dist', process.platform === 'win32' ? 'nlc.exe' : 'nlc'); const dir = await mkdtemp(join(tmpdir(), 'nlc-smoke-')); try { const config = join(dir, 'config.yaml'); await writeFile( config, `gmail: folder: Newsletters output: name: Smoke Catalog excel: enabled: true path: ${JSON.stringify(join(dir, 'catalog.xlsx'))} state_file: ${JSON.stringify(join(dir, 'state.json'))} ` ); await exec('node', [cli, '--help']); await exec(binary, ['--help']); await exec('node', [cli, 'init', '--help']); await exec('node', [cli, 'run', '--help']); await exec('node', [cli, 'serve', '--help']); await exec('node', [cli, 'run', '--config', config, '--dry-run'], { env: { ...process.env, NLC_FIXTURE: '1' } }); console.log('Smoke checks passed'); } finally { await rm(dir, { force: true, recursive: true }); }