From 8cd2135fd3f9be7ccae62d9cefcb0185c2272982 Mon Sep 17 00:00:00 2001 From: Aleix Soler Date: Thu, 8 May 2025 13:09:41 +0200 Subject: [PATCH] chore: generate test vault without statuses --- scripts/README.md | 1 + scripts/generate-test-vault.ts | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/README.md b/scripts/README.md index adf2988..593ff7e 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -20,6 +20,7 @@ - `--tag-prefix` or `-t`: Status tag prefix (default: obsidian-note-status) - `--depth` or `-d`: Maximum folder depth (default: 5) - `--max-per-folder` or `-m`: Maximum files per folder (default: 200) +- `--no-status` or `-n`: Generate notes without status tags (default: false) ## Performance Considerations The script creates a realistic vault structure with: diff --git a/scripts/generate-test-vault.ts b/scripts/generate-test-vault.ts index cf7abbc..1f98b44 100644 --- a/scripts/generate-test-vault.ts +++ b/scripts/generate-test-vault.ts @@ -20,6 +20,7 @@ program .option('-t, --tag-prefix ', 'Status tag prefix', 'obsidian-note-status') .option('-d, --depth ', 'Maximum folder depth', '5') .option('-m, --max-per-folder ', 'Maximum files per folder', '200') + .option('-n, --no-status', 'Generate notes without status tags') .parse(process.argv); const options = program.opts(); @@ -30,6 +31,7 @@ const outputDir = options.output; const tagPrefix = options.tagPrefix; const maxDepth = parseInt(options.depth, 10); const maxPerFolder = parseInt(options.maxPerFolder, 10); +const includeStatus = options.status !== false; // true by default, false if --no-status is used if (isNaN(noteCount) || noteCount <= 0) { console.error('Error: Note count must be a positive number'); @@ -109,21 +111,25 @@ function generateContent(): string { return content; } -// Create a note with frontmatter containing status +// Create a note with optional frontmatter containing status function createNote(title: string, folderPath: string): void { const safeName = title.replace(/[^a-zA-Z0-9 ]/g, '').replace(/\s+/g, ' '); const fileName = `${safeName}.md`; const filePath = path.join(folderPath, fileName); - // Create frontmatter with random status - const status = getRandomStatus(); - const frontmatter = `---\n${tagPrefix}: ${status}\n---\n\n`; + let fileContent = ''; + + if (includeStatus) { + // Create frontmatter with random status + const status = getRandomStatus(); + fileContent = `---\n${tagPrefix}: ${status}\n---\n\n`; + } // Create content - const content = `# ${title}\n\n${generateContent()}`; + fileContent += `# ${title}\n\n${generateContent()}`; // Write file - fs.writeFileSync(filePath, frontmatter + content); + fs.writeFileSync(filePath, fileContent); } // Generate a folder structure and notes @@ -225,7 +231,7 @@ function createObsidianConfig(baseDir: string): void { } // Main execution -console.log(`Generating ${noteCount} notes in ${outputDir} with tag prefix '${tagPrefix}'`); +console.log(`Generating ${noteCount} notes in ${outputDir}${includeStatus ? ` with tag prefix '${tagPrefix}'` : ' without status tags'}`); console.time('Generation completed in'); // Create test vault