fix(config): switch configuration loading and saving from npmextra.json to smartconfig.json

This commit is contained in:
2026-03-24 15:09:42 +00:00
parent 6a3de7dba8
commit 37da233ddf
9 changed files with 50 additions and 24 deletions

View File

@@ -119,28 +119,28 @@ const presets: Record<string, interfaces.ITswatchConfig> = {
* Handles loading and managing tswatch configuration
*/
export class ConfigHandler {
private npmextra: plugins.npmextra.Npmextra;
private smartconfig: plugins.smartconfig.Smartconfig;
private cwd: string;
constructor(cwdArg?: string) {
this.cwd = cwdArg || paths.cwd;
this.npmextra = new plugins.npmextra.Npmextra(this.cwd);
this.smartconfig = new plugins.smartconfig.Smartconfig(this.cwd);
}
/**
* Check if a tswatch configuration exists
*/
public hasConfig(): boolean {
const config = this.npmextra.dataFor<interfaces.ITswatchConfig>(CONFIG_KEY, null);
const config = this.smartconfig.dataFor<interfaces.ITswatchConfig>(CONFIG_KEY, null);
return config !== null;
}
/**
* Load configuration from npmextra.json
* Load configuration from smartconfig.json
* If a preset is specified, merge preset defaults with user overrides
*/
public loadConfig(): interfaces.ITswatchConfig | null {
const config = this.npmextra.dataFor<interfaces.ITswatchConfig>(CONFIG_KEY, null);
const config = this.smartconfig.dataFor<interfaces.ITswatchConfig>(CONFIG_KEY, null);
if (!config) {
return null;
@@ -177,7 +177,7 @@ export class ConfigHandler {
}
/**
* Get the config key for npmextra.json
* Get the config key for smartconfig.json
*/
public getConfigKey(): string {
return CONFIG_KEY;