@@ -17,6 +17,11 @@ import { createInterface } from 'node:readline';
1717
1818import type { CliContext } from '../index.js' ;
1919
20+ import {
21+ DEFAULT_BENCHMARK_DIR ,
22+ DEFAULT_OUTPUT_DIR ,
23+ SITE_URL ,
24+ } from '../../constants.js' ;
2025import {
2126 InvalidArgumentError ,
2227 UnsupportedConfigFormatError ,
@@ -43,40 +48,44 @@ const PROJECT_TEMPLATES = {
4348 advanced : {
4449 configOptions : {
4550 iterations : 1000 ,
46- outputDir : '.modestbench' ,
47- pattern : 'bench /**/*.bench.{js,ts}' ,
51+ outputDir : DEFAULT_OUTPUT_DIR ,
52+ pattern : ` ${ DEFAULT_BENCHMARK_DIR } /**/*.bench.{js,ts}` ,
4853 reporters : [ 'human' , 'json' ] ,
4954 time : 10000 ,
5055 warmup : 50 ,
5156 } ,
5257 description : 'Feature-rich setup with multiple reporters and configuration' ,
53- directories : [ 'bench' , '.modestbench' ] ,
58+ directories : [ DEFAULT_BENCHMARK_DIR , DEFAULT_OUTPUT_DIR ] ,
5459 name : 'Advanced Project' ,
5560 } ,
5661 basic : {
5762 configOptions : {
5863 iterations : 100 ,
59- outputDir : '.modestbench' ,
60- pattern : 'bench /**/*.bench.{js,ts}' ,
64+ outputDir : DEFAULT_OUTPUT_DIR ,
65+ pattern : ` ${ DEFAULT_BENCHMARK_DIR } /**/*.bench.{js,ts}` ,
6166 reporters : [ 'human' ] ,
6267 time : 5000 ,
6368 } ,
6469 description : 'Simple benchmark setup for small projects' ,
65- directories : [ 'bench' , '.modestbench' ] ,
70+ directories : [ DEFAULT_BENCHMARK_DIR , DEFAULT_OUTPUT_DIR ] ,
6671 name : 'Basic Project' ,
6772 } ,
6873 library : {
6974 configOptions : {
7075 bail : false ,
7176 iterations : 5000 ,
72- outputDir : '.modestbench' ,
73- pattern : 'bench /**/*.bench.{js,ts}' ,
77+ outputDir : DEFAULT_OUTPUT_DIR ,
78+ pattern : ` ${ DEFAULT_BENCHMARK_DIR } /**/*.bench.{js,ts}` ,
7479 reporters : [ 'human' , 'json' ] ,
7580 time : 15000 ,
7681 warmup : 100 ,
7782 } ,
7883 description : 'Optimized for library performance testing' ,
79- directories : [ 'bench' , 'bench/suites' , '.modestbench' ] ,
84+ directories : [
85+ DEFAULT_BENCHMARK_DIR ,
86+ `${ DEFAULT_BENCHMARK_DIR } /suites` ,
87+ DEFAULT_OUTPUT_DIR ,
88+ ] ,
8089 name : 'Library Project' ,
8190 } ,
8291} as const ;
@@ -375,7 +384,7 @@ const createAdditionalFiles = async (
375384 // Create README.md
376385 const readmeContent = `# Benchmark Project
377386
378- This project uses [ModestBench](https://github.com/your-org/modestbench ) for performance testing.
387+ This project uses [ModestBench](${ SITE_URL } ) for performance testing.
379388
380389## Getting Started
381390
@@ -386,7 +395,7 @@ modestbench run
386395
387396Run specific benchmarks:
388397\`\`\`bash
389- modestbench run "bench /array-*.bench.js"
398+ modestbench run "${ DEFAULT_BENCHMARK_DIR } /array-*.bench.js"
390399\`\`\`
391400
392401View benchmark history:
@@ -400,7 +409,7 @@ See \`modestbench.config.*\` for benchmark configuration options.
400409
401410## Writing Benchmarks
402411
403- Create new benchmark files in the \`bench /\` directory. See the examples for the expected format.
412+ Create new benchmark files in the \`${ DEFAULT_BENCHMARK_DIR } /\` directory. See the examples for the expected format.
404413` ;
405414
406415 try {
@@ -423,7 +432,7 @@ const createOrUpdateGitignore = async (
423432 options ?: { quiet ?: boolean ; yes ?: boolean } ,
424433) : Promise < void > => {
425434 const gitignorePath = resolve ( cwd , '.gitignore' ) ;
426- const modestbenchEntry = '.modestbench/' ;
435+ const modestbenchEntry = ` ${ DEFAULT_OUTPUT_DIR } /` ;
427436 const modestbenchSection = `\n# ModestBench history\n${ modestbenchEntry } \n` ;
428437
429438 try {
@@ -436,13 +445,13 @@ const createOrUpdateGitignore = async (
436445 }
437446
438447 if ( existingContent ) {
439- // File exists, check if .modestbench / is already present
448+ // File exists, check if ${DEFAULT_OUTPUT_DIR} / is already present
440449 if ( existingContent . includes ( modestbenchEntry ) ) {
441450 // Already present, nothing to do
442451 return ;
443452 }
444453
445- // Append .modestbench/ entry (--yes or --quiet means auto-accept)
454+ // Append default output dir entry (--yes or --quiet means auto-accept)
446455 if ( options ?. yes || options ?. quiet ) {
447456 // Ensure content ends with newline
448457 const contentToAppend = existingContent . endsWith ( '\n' )
@@ -464,7 +473,6 @@ build/
464473coverage/
465474
466475# Benchmark output
467- benchmark-results/
468476${ modestbenchSection } `;
469477 await writeFile ( gitignorePath , newContent , 'utf8' ) ;
470478 }
@@ -550,7 +558,7 @@ const createDirectories = async (
550558 * Create example benchmark files
551559 */
552560const createExampleBenchmarks = async ( cwd : string ) : Promise < void > => {
553- const benchmarksDir = resolve ( cwd , 'bench' ) ;
561+ const benchmarksDir = resolve ( cwd , DEFAULT_BENCHMARK_DIR ) ;
554562
555563 for ( const [ name , example ] of Object . entries ( EXAMPLE_BENCHMARKS ) ) {
556564 const filePath = join ( benchmarksDir , example . filename ) ;
0 commit comments