mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-04 22:51:08 +00:00
feat(insight): enhance template loading logic and add insight templates copying
This commit is contained in:
parent
338387f93a
commit
7e21ba4983
3 changed files with 62 additions and 43 deletions
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import fs from 'fs/promises';
|
||||
import { existsSync } from 'fs';
|
||||
import path, { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import type { InsightData } from '../types/StaticInsightTypes.js';
|
||||
|
|
@ -15,7 +16,24 @@ export class TemplateRenderer {
|
|||
constructor() {
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
this.templateDir = path.join(__dirname, '..', 'templates');
|
||||
|
||||
// In bundled version (dist/cli.js), __dirname is dist/, templates at dist/templates/
|
||||
// In development (dist/src/services/insight/generators/), templates at dist/src/services/insight/templates/
|
||||
const bundledTemplatePath = path.join(__dirname, 'templates');
|
||||
const devTemplatePath = path.join(__dirname, '..', 'templates');
|
||||
|
||||
// Try bundled path first (for production), fall back to dev path
|
||||
try {
|
||||
// Check if bundled templates exist
|
||||
if (existsSync(bundledTemplatePath)) {
|
||||
this.templateDir = bundledTemplatePath;
|
||||
} else {
|
||||
this.templateDir = devTemplatePath;
|
||||
}
|
||||
} catch {
|
||||
// If check fails, use dev path as fallback
|
||||
this.templateDir = devTemplatePath;
|
||||
}
|
||||
}
|
||||
|
||||
// Load template files
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue