Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
No EOL
1.5 KiB
Text
37 lines
No EOL
1.5 KiB
Text
import { existsSync, readFileSync } from 'fs';
|
|
import path from 'path';
|
|
import { recursiveReadDir } from '../recursive-readdir';
|
|
export async function getTypeScriptIntent(baseDir, intentDirs, tsconfigPath) {
|
|
const resolvedTsConfigPath = path.join(baseDir, tsconfigPath);
|
|
// The integration turns on if we find a `tsconfig.json` in the user's
|
|
// project.
|
|
const hasTypeScriptConfiguration = existsSync(resolvedTsConfigPath);
|
|
if (hasTypeScriptConfiguration) {
|
|
const content = readFileSync(resolvedTsConfigPath, {
|
|
encoding: 'utf8'
|
|
}).trim();
|
|
return {
|
|
firstTimeSetup: content === '' || content === '{}'
|
|
};
|
|
}
|
|
// Next.js also offers a friendly setup mode that bootstraps a TypeScript
|
|
// project for the user when we detect TypeScript files. So, we need to check
|
|
// the `pages/` directory for a TypeScript file.
|
|
// Checking all directories is too slow, so this is a happy medium.
|
|
const tsFilesRegex = /.*\.(ts|tsx)$/;
|
|
const excludedRegex = /(node_modules|.*\.d\.ts$)/;
|
|
for (const dir of intentDirs){
|
|
const typescriptFiles = await recursiveReadDir(dir, {
|
|
pathnameFilter: (name)=>tsFilesRegex.test(name),
|
|
ignoreFilter: (name)=>excludedRegex.test(name)
|
|
});
|
|
if (typescriptFiles.length) {
|
|
return {
|
|
firstTimeSetup: true
|
|
};
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//# sourceMappingURL=getTypeScriptIntent.js.map |