feat(cli): Enhance type checking in CLI by adding default file pattern handling
This commit is contained in:
@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-05-15 - 2.5.0 - feat(cli)
|
||||||
|
Enhance type checking in CLI by adding default file pattern handling
|
||||||
|
|
||||||
|
- When no TypeScript file or glob pattern is provided, the CLI now performs a default type checking sequence.
|
||||||
|
- First checks 'ts/**/*' files with standard options, then checks 'test/**/*' files with skiplibcheck enabled.
|
||||||
|
- Improved logging to indicate file discovery and check results, ensuring clear feedback for users.
|
||||||
|
|
||||||
## 2025-05-15 - 2.4.1 - fix(cli)
|
## 2025-05-15 - 2.4.1 - fix(cli)
|
||||||
Improve TS folder compilation order display in CLI
|
Improve TS folder compilation order display in CLI
|
||||||
|
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tsbuild',
|
name: '@git.zone/tsbuild',
|
||||||
version: '2.4.1',
|
version: '2.5.0',
|
||||||
description: 'A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.'
|
description: 'A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.'
|
||||||
}
|
}
|
||||||
|
@ -190,12 +190,67 @@ export const runCli = async () => {
|
|||||||
tsbuildCli.addCommand('check').subscribe(async (argvArg) => {
|
tsbuildCli.addCommand('check').subscribe(async (argvArg) => {
|
||||||
const patterns = argvArg._.slice(1); // Remove the first element which is 'check'
|
const patterns = argvArg._.slice(1); // Remove the first element which is 'check'
|
||||||
|
|
||||||
|
// If no patterns provided, default to checking ts/**/* and then test/**/*
|
||||||
if (patterns.length === 0) {
|
if (patterns.length === 0) {
|
||||||
console.error('\n❌ Error: Please provide at least one TypeScript file path or glob pattern');
|
console.log('\n🔬 Running default type checking sequence...\n');
|
||||||
console.error(' Usage: tsbuild check <file_or_glob_pattern> [additional_patterns ...]\n');
|
|
||||||
console.error(' Example: tsbuild check "src/**/*.ts" "test/**/*.ts"\n');
|
// First check ts/**/* without skiplibcheck
|
||||||
|
console.log('📂 Checking ts/**/* files...');
|
||||||
|
const tsFiles = await plugins.smartfile.fs.listFileTree(process.cwd(), 'ts/**/*.ts');
|
||||||
|
const tsTsFiles = Array.isArray(tsFiles)
|
||||||
|
? tsFiles.filter((item): item is string => typeof item === 'string')
|
||||||
|
: [];
|
||||||
|
|
||||||
|
if (tsTsFiles.length > 0) {
|
||||||
|
console.log(` Found ${tsTsFiles.length} TypeScript files in ts/`);
|
||||||
|
const tsAbsoluteFiles = plugins.smartpath.transform.toAbsolute(
|
||||||
|
tsTsFiles,
|
||||||
|
process.cwd()
|
||||||
|
) as string[];
|
||||||
|
|
||||||
|
const tsCompilerOptions = tsbuild.mergeCompilerOptions({}, argvArg);
|
||||||
|
const tsSuccess = await tsbuild.checkTypes(tsAbsoluteFiles, tsCompilerOptions, argvArg);
|
||||||
|
|
||||||
|
if (!tsSuccess) {
|
||||||
|
console.error('❌ Type checking failed for ts/**/*');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
console.log('✅ Type checking passed for ts/**/*\n');
|
||||||
|
} else {
|
||||||
|
console.log(' No TypeScript files found in ts/\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then check test/**/* with skiplibcheck
|
||||||
|
console.log('📂 Checking test/**/* files with --skiplibcheck...');
|
||||||
|
const testFiles = await plugins.smartfile.fs.listFileTree(process.cwd(), 'test/**/*.ts');
|
||||||
|
const testTsFiles = Array.isArray(testFiles)
|
||||||
|
? testFiles.filter((item): item is string => typeof item === 'string')
|
||||||
|
: [];
|
||||||
|
|
||||||
|
if (testTsFiles.length > 0) {
|
||||||
|
console.log(` Found ${testTsFiles.length} TypeScript files in test/`);
|
||||||
|
const testAbsoluteFiles = plugins.smartpath.transform.toAbsolute(
|
||||||
|
testTsFiles,
|
||||||
|
process.cwd()
|
||||||
|
) as string[];
|
||||||
|
|
||||||
|
// Create new argvArg with skiplibcheck for test files
|
||||||
|
const testArgvArg = { ...argvArg, skiplibcheck: true };
|
||||||
|
const testCompilerOptions = tsbuild.mergeCompilerOptions({}, testArgvArg);
|
||||||
|
const testSuccess = await tsbuild.checkTypes(testAbsoluteFiles, testCompilerOptions, testArgvArg);
|
||||||
|
|
||||||
|
if (!testSuccess) {
|
||||||
|
console.error('❌ Type checking failed for test/**/*');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
console.log('✅ Type checking passed for test/**/*\n');
|
||||||
|
} else {
|
||||||
|
console.log(' No TypeScript files found in test/\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('✅ All default type checks passed!\n');
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
const cwd = process.cwd();
|
const cwd = process.cwd();
|
||||||
let allFiles: string[] = [];
|
let allFiles: string[] = [];
|
||||||
|
Reference in New Issue
Block a user