|
1 | | -import type { Task } from '../task'; |
2 | | -import { ROOT_DIRECTORY } from '../utils/constants'; |
3 | | -import { exec } from '../utils/exec'; |
4 | | -import { maxConcurrentTasks } from '../utils/maxConcurrentTasks'; |
5 | | - |
6 | | -// The amount of VCPUs for the check task on CI is 4 (large resource) |
| 1 | +import { join } from 'node:path'; |
7 | 2 |
|
8 | | -const parallel = process.env.CI ? '' : `--parallel=${maxConcurrentTasks}`; |
| 3 | +// eslint-disable-next-line depend/ban-dependencies |
| 4 | +import { execaCommand } from 'execa'; |
9 | 5 |
|
10 | | -const linkCommand = `yarn nx run-many -t check ${parallel}`; |
11 | | -const nolinkCommand = `yarn nx run-many -t check -c production ${parallel}`; |
| 6 | +import type { Task } from '../task'; |
| 7 | +import { CODE_DIRECTORY, ROOT_DIRECTORY } from '../utils/constants'; |
| 8 | +import { getCodeWorkspaces } from '../utils/workspace'; |
12 | 9 |
|
13 | 10 | export const check: Task = { |
14 | 11 | description: 'Typecheck the source code of the monorepo', |
15 | 12 | async ready() { |
16 | 13 | return false; |
17 | 14 | }, |
18 | | - async run(_, { dryRun, debug, link, skipCache }) { |
19 | | - const command = link ? linkCommand : nolinkCommand; |
20 | | - return exec( |
21 | | - `${command} ${skipCache || process.env.CI ? '--skip-nx-cache' : ''}`, |
22 | | - { cwd: ROOT_DIRECTORY }, |
23 | | - { |
24 | | - startMessage: '🥾 Checking for TS errors', |
25 | | - errorMessage: '❌ TS errors detected', |
26 | | - dryRun, |
27 | | - debug, |
| 15 | + async run(_, {}) { |
| 16 | + const failed: string[] = []; |
| 17 | + // const command = link ? linkCommand : nolinkCommand; |
| 18 | + const workspaces = await getCodeWorkspaces(); |
| 19 | + |
| 20 | + for (const workspace of workspaces) { |
| 21 | + if (workspace.location === '.') { |
| 22 | + continue; // skip root directory |
| 23 | + } |
| 24 | + const cwd = join(CODE_DIRECTORY, workspace.location); |
| 25 | + console.log(''); |
| 26 | + console.log('Checking ' + workspace.name + ' at ' + cwd); |
| 27 | + |
| 28 | + let command = ''; |
| 29 | + if (workspace.name === '@storybook/vue3') { |
| 30 | + command = `npx vue-tsc --noEmit --project ${join(cwd, 'tsconfig.json')}`; |
| 31 | + } else if (workspace.name === '@storybook/svelte') { |
| 32 | + command = `npx svelte-check`; |
| 33 | + } else { |
| 34 | + const script = join(ROOT_DIRECTORY, 'scripts', 'check', 'check-package.ts'); |
| 35 | + command = `yarn exec jiti ${script} --cwd ${cwd}`; |
| 36 | + // command = `npx tsc --noEmit --project ${join(cwd, 'tsconfig.json')}`; |
28 | 37 | } |
29 | | - ); |
| 38 | + |
| 39 | + const sub = execaCommand(`${command}`, { |
| 40 | + cwd, |
| 41 | + env: { |
| 42 | + NODE_ENV: 'production', |
| 43 | + }, |
| 44 | + }); |
| 45 | + |
| 46 | + sub.stdout?.on('data', (data) => { |
| 47 | + process.stdout.write(data); |
| 48 | + }); |
| 49 | + sub.stderr?.on('data', (data) => { |
| 50 | + process.stderr.write(data); |
| 51 | + }); |
| 52 | + |
| 53 | + await sub.catch((error) => { |
| 54 | + failed.push(workspace.name); |
| 55 | + }); |
| 56 | + } |
| 57 | + |
| 58 | + if (failed.length > 0) { |
| 59 | + throw new Error(`Failed to check ${failed.join(', ')}`); |
| 60 | + } |
30 | 61 | }, |
31 | 62 | }; |
0 commit comments