source-launch.compat.spec.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { fileURLToPath } from 'node:url'
  2. import { execa } from 'execa'
  3. import { describe, expect, it } from 'vitest'
  4. /**
  5. * Keyless smoke for the SOURCE `dsh` launcher: run `apps/cli/src/bin.ts`
  6. * with the exact production launch vector (`node --import tsx/esm`, the same
  7. * shape as `bin/dsh` and the root `dsh`/`demo:web` scripts) and assert the
  8. * required-config diagnostic. The Node compatibility matrix runs this
  9. * WHOLE file, so a Node release changing module hooks or TypeScript handling
  10. * breaks this gate instead of every developer's `pnpm dsh`; the built-bin
  11. * suite covers the published `lib/` entry, not this source chain.
  12. */
  13. const repoRoot = fileURLToPath(new URL('../../../', import.meta.url))
  14. const dshSourceBin = 'apps/cli/src/bin.ts'
  15. describe('dsh SOURCE launcher (node --import tsx/esm)', () => {
  16. it('boots the source entry and requires a profile', async () => {
  17. const result = await execa(process.execPath, ['--import', 'tsx/esm', dshSourceBin], {
  18. cwd: repoRoot,
  19. input: '',
  20. timeout: 25_000,
  21. killSignal: 'SIGKILL',
  22. reject: false,
  23. })
  24. if (result.timedOut) {
  25. throw new Error(`dsh source launch did not exit within 25s. stdout:\n${result.stdout}\nstderr:\n${result.stderr}`)
  26. }
  27. expect(result.exitCode).not.toBe(0)
  28. expect(result.stderr).toContain('--profile <name> is required')
  29. expect(result.stdout).toBe('')
  30. }, 30_000)
  31. })