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

@@ -56,10 +56,10 @@ export class TswatchInit {
config = { ...preset, preset: template as interfaces.ITswatchConfig['preset'] };
}
// Save to npmextra.json
// Save to smartconfig.json
await this.saveConfig(config);
console.log('\nConfiguration saved to npmextra.json');
console.log('\nConfiguration saved to smartconfig.json');
console.log('Run "tswatch" to start watching.\n');
return config;
@@ -166,16 +166,16 @@ export class TswatchInit {
}
/**
* Save configuration to npmextra.json
* Save configuration to smartconfig.json
*/
private async saveConfig(config: interfaces.ITswatchConfig): Promise<void> {
const npmextraPath = plugins.path.join(paths.cwd, 'npmextra.json');
const smartconfigPath = plugins.path.join(paths.cwd, 'smartconfig.json');
// Read existing npmextra.json if it exists
// Read existing smartconfig.json if it exists
let existingConfig: Record<string, any> = {};
try {
const smartfsInstance = new plugins.smartfs.SmartFs(new plugins.smartfs.SmartFsProviderNode());
const content = await smartfsInstance.file(npmextraPath).encoding('utf8').read() as string;
const content = await smartfsInstance.file(smartconfigPath).encoding('utf8').read() as string;
existingConfig = JSON.parse(content);
} catch {
// File doesn't exist or is invalid, start fresh
@@ -186,7 +186,7 @@ export class TswatchInit {
// Write back
const smartfsInstance = new plugins.smartfs.SmartFs(new plugins.smartfs.SmartFsProviderNode());
await smartfsInstance.file(npmextraPath).encoding('utf8').write(JSON.stringify(existingConfig, null, 2));
await smartfsInstance.file(smartconfigPath).encoding('utf8').write(JSON.stringify(existingConfig, null, 2));
}
}