CheckerCli
Runs an external CLI command within the generator’s unified pipeline, with cwd: rootDir. The command runs synchronously through spawnSync. Standard output from successful runs is not included in the logs. If the command fails, its output, exit code, signal, and other available information are logged.
ts | The checker name used in logs |
ts | A function that returns an array whose first element is the command and whose remaining elements are its arguments. Returning
|
Example: Vitest runs related tests
All tests run during full generation and after files are deleted; incremental generation runs only tests related to changed files
new CheckerCli({
name: 'vitest',
getCommand({ changedFiles, deletedFiles, isFullGeneration }) {
const vitest = path.resolve(process.cwd(), 'node_modules/.bin/vitest');
if (isFullGeneration || deletedFiles.length > 0) return [vitest, 'run'];
if (changedFiles.length === 0) return false;
return [vitest, 'related', '--run', ...changedFiles.map(({ relativePath }) => relativePath)];
},
}),
Run Sandbox
export const sum = (a: number, b: number) => a + b;
export const double = (value: number) => value * 2;
export const obsolete = true;
import { expect, it } from 'vitest';
import { sum } from '../src/sum';
it('adds two numbers', () => {
expect(sum(2, 3)).toBe(5);
});
import { expect, it } from 'vitest';
import { double } from '../src/double';
it('doubles a number', () => {
expect(double(3)).toBe(6);
});
[ARFA-GEN] finished in 0ms
Example: Biome checks only changed files
If no files were changed (for example, if files were only deleted), the check is skipped
new CheckerCli({
name: 'biome',
getCommand({ changedFiles }) {
if (changedFiles.length === 0) return false;
return [
path.resolve(process.cwd(), 'node_modules/.bin/biome'),
'check',
'--no-errors-on-unmatched',
...changedFiles.map(({ relativePath }) => relativePath),
];
},
}),
Run Sandbox
{
"formatter": {
"indentStyle": "space",
"indentWidth": 2
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
}
}
export const answer = 42;
[ARFA-GEN] finished in 0ms
Example: Type checking with tsc
In this example, tsc runs for the entire project, even if files were only deleted
new CheckerCli({
name: 'tsc',
getCommand: () => [path.resolve(process.cwd(), 'node_modules/.bin/tsc')],
}),
Run Sandbox
{
"include": ["src"],
"compilerOptions": {
"target": "ES2023",
"module": "ESNext",
"moduleResolution": "bundler",
"noEmit": true,
"strict": true,
"types": []
}
}
export const count: number = 1;
[ARFA-GEN] finished in 0ms