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

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tsview',
version: '1.12.1',
version: '1.12.2',
description: 'A CLI tool for viewing S3 and MongoDB data with a web UI'
}

File diff suppressed because one or more lines are too long

View File

@@ -29,9 +29,9 @@ export interface ITsViewConfig {
}
/**
* Configuration from npmextra.json for @git.zone/tsview
* Configuration from smartconfig.json for @git.zone/tsview
*/
export interface INpmextraConfig {
export interface ISmartconfigConfig {
port?: number; // Fixed port to use (optional)
killIfBusy?: boolean; // Kill process on port if busy (default: false)
openBrowser?: boolean; // Open browser on start (default: true)

View File

@@ -6,7 +6,7 @@ export { path };
import * as early from '@push.rocks/early';
early.start('tsview');
import * as npmextra from '@push.rocks/npmextra';
import * as smartconfig from '@push.rocks/smartconfig';
import * as smartbucket from '@push.rocks/smartbucket';
import * as smartcli from '@push.rocks/smartcli';
import * as smartdata from '@push.rocks/smartdata';
@@ -21,7 +21,7 @@ import * as smartrx from '@push.rocks/smartrx';
export {
early,
npmextra,
smartconfig,
smartbucket,
smartcli,
smartdata,

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}`);