fix(config): migrate runtime configuration loading from npmextra to smartconfig

This commit is contained in:
2026-03-24 15:08:13 +00:00
parent 7f4528bdab
commit 02b3a79d99
10 changed files with 50 additions and 22 deletions

View File

@@ -103,11 +103,11 @@ export class TsView {
}
/**
* Load configuration from npmextra.json
* Load configuration from smartconfig.json
*/
private loadNpmextraConfig(cwd?: string): interfaces.INpmextraConfig {
const npmextra = new plugins.npmextra.Npmextra(cwd || process.cwd());
const config = npmextra.dataFor<interfaces.INpmextraConfig>('@git.zone/tsview', {});
private loadSmartconfigConfig(cwd?: string): interfaces.ISmartconfigConfig {
const smartconfigInstance = new plugins.smartconfig.Smartconfig(cwd || process.cwd());
const config = smartconfigInstance.dataFor<interfaces.ISmartconfigConfig>('@git.zone/tsview', {});
return config || {};
}
@@ -135,7 +135,7 @@ export class TsView {
* @param cliPort - Optional port number from CLI (highest priority)
*/
public async start(cliPort?: number): Promise<number> {
const npmextraConfig = await this.loadNpmextraConfig();
const smartconfigConfig = await this.loadSmartconfigConfig();
let port: number;
let portWasExplicitlySet = false;
@@ -144,9 +144,9 @@ export class TsView {
// CLI has highest priority
port = cliPort;
portWasExplicitlySet = true;
} else if (npmextraConfig.port) {
} else if (smartconfigConfig.port) {
// Config port specified
port = npmextraConfig.port;
port = smartconfigConfig.port;
portWasExplicitlySet = true;
} else {
// Auto-find free port
@@ -158,11 +158,11 @@ export class TsView {
const isFree = await network.isLocalPortUnused(port);
if (!isFree) {
if (npmextraConfig.killIfBusy) {
if (smartconfigConfig.killIfBusy) {
console.log(`Port ${port} is busy. Killing existing process...`);
await this.killProcessOnPort(port);
} else if (portWasExplicitlySet) {
throw new Error(`Port ${port} is busy. Set "killIfBusy": true in npmextra.json to auto-kill, or use a different port.`);
throw new Error(`Port ${port} is busy. Set "killIfBusy": true in smartconfig.json to auto-kill, or use a different port.`);
} else {
// Auto port was already free, shouldn't happen, but fallback
port = await this.findFreePort(port + 1);
@@ -175,7 +175,7 @@ export class TsView {
console.log(`TsView server started on http://localhost:${port}`);
// Open browser (default: true, can be disabled via config)
const shouldOpenBrowser = npmextraConfig.openBrowser !== false;
const shouldOpenBrowser = smartconfigConfig.openBrowser !== false;
if (shouldOpenBrowser) {
try {
await plugins.smartopen.openUrl(`http://localhost:${port}`);