Update myTemplateGenerator to version 0.0.5. Introduced new configuration options, added support for additional case modifiers using the change-case-all package, and improved the webview for template selection and variable input. Updated package.json and package-lock.json accordingly. Added localization support for configuration settings and enhanced README with usage instructions.
This commit is contained in:
38
src/core/config.ts
Normal file
38
src/core/config.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
// Работа с конфигом расширения
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export interface MyTemplateGeneratorConfig {
|
||||
templatesPath: string;
|
||||
overwriteFiles: boolean;
|
||||
inputMode: 'webview' | 'inputBox';
|
||||
language?: string;
|
||||
}
|
||||
|
||||
export function getConfigPath(): string | undefined {
|
||||
const folders = vscode.workspace.workspaceFolders;
|
||||
if (!folders || folders.length === 0) return undefined;
|
||||
return path.join(folders[0].uri.fsPath, 'mycodegenerate.json');
|
||||
}
|
||||
|
||||
export function readConfig(): MyTemplateGeneratorConfig {
|
||||
const configPath = getConfigPath();
|
||||
if (configPath && fs.existsSync(configPath)) {
|
||||
const raw = fs.readFileSync(configPath, 'utf8');
|
||||
return JSON.parse(raw);
|
||||
}
|
||||
// Значения по умолчанию
|
||||
return {
|
||||
templatesPath: 'templates',
|
||||
overwriteFiles: false,
|
||||
inputMode: 'inputBox',
|
||||
language: 'en',
|
||||
};
|
||||
}
|
||||
|
||||
export function writeConfig(config: MyTemplateGeneratorConfig) {
|
||||
const configPath = getConfigPath();
|
||||
if (!configPath) return;
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf8');
|
||||
}
|
||||
Reference in New Issue
Block a user