mirror of
https://github.com/devonthesofa/obsidian-note-status.git
synced 2026-07-22 12:30:24 +00:00
chore: generate test vault without statuses
This commit is contained in:
parent
cc46b0790f
commit
8cd2135fd3
2 changed files with 14 additions and 7 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ program
|
|||
.option('-t, --tag-prefix <string>', 'Status tag prefix', 'obsidian-note-status')
|
||||
.option('-d, --depth <number>', 'Maximum folder depth', '5')
|
||||
.option('-m, --max-per-folder <number>', '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
|
||||
|
|
|
|||
Loading…
Reference in a new issue