source-launch.compat.spec.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { fileURLToPath } from 'node:url'
  2. import { execa } from 'execa'
  3. import { describe, expect, it } from 'vitest'
  4. /**
  5. * Keyless smoke for SOURCE `dsh` execution: run `apps/cli/src/bin.ts`
  6. * with the exact production runtime vector (`node --import tsx/esm`, the
  7. * vector the root `dsh` script invokes after building) 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('builds without mixing build logs into CLI stdout', async () => {
  17. const result = await execa('pnpm', ['dsh', '--help'], {
  18. cwd: repoRoot,
  19. timeout: 120_000,
  20. killSignal: 'SIGKILL',
  21. reject: false,
  22. })
  23. if (result.timedOut) {
  24. throw new Error(`pnpm dsh --help did not exit within 120s. stdout:\n${result.stdout}\nstderr:\n${result.stderr}`)
  25. }
  26. expect(result.exitCode).toBe(0)
  27. expect(result.stdout).toMatch(/^Usage: dsh /)
  28. expect(result.stdout).not.toContain('tsdown')
  29. expect(result.stdout).not.toContain('build:lib')
  30. }, 125_000)
  31. it('boots the source entry and requires a profile', async () => {
  32. const result = await execa(process.execPath, ['--import', 'tsx/esm', dshSourceBin], {
  33. cwd: repoRoot,
  34. input: '',
  35. timeout: 25_000,
  36. killSignal: 'SIGKILL',
  37. reject: false,
  38. })
  39. if (result.timedOut) {
  40. throw new Error(`dsh source launch did not exit within 25s. stdout:\n${result.stdout}\nstderr:\n${result.stderr}`)
  41. }
  42. expect(result.exitCode).not.toBe(0)
  43. expect(result.stderr).toContain('--profile <name> is required')
  44. expect(result.stdout).toBe('')
  45. }, 30_000)
  46. })