mirror of
https://github.com/aljazceru/dvmcp.git
synced 2025-12-17 05:14:24 +01:00
fix: paths
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bun
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'path';
|
||||
import { join, resolve } from 'path';
|
||||
import {
|
||||
ConfigGenerator,
|
||||
type FieldConfig,
|
||||
@@ -13,14 +13,16 @@ import {
|
||||
} from '@dvmcp/commons/config-generator';
|
||||
import { argv } from 'process';
|
||||
import type { Config } from './src/types';
|
||||
import { setConfigPath } from './src/config.js';
|
||||
|
||||
const defaultConfigPath = join(process.cwd(), 'config.dvmcp.yml');
|
||||
let configPath = defaultConfigPath;
|
||||
|
||||
const configPathArgIndex = argv.indexOf('--config-path');
|
||||
if (configPathArgIndex !== -1 && argv[configPathArgIndex + 1]) {
|
||||
configPath = argv[configPathArgIndex + 1];
|
||||
console.log(configPath);
|
||||
configPath = resolve(argv[configPathArgIndex + 1]);
|
||||
console.log(`Using config path: ${configPath}`);
|
||||
setConfigPath(configPath);
|
||||
}
|
||||
|
||||
const configFields: Record<string, FieldConfig> = {
|
||||
@@ -120,7 +122,7 @@ const cliMain = async () => {
|
||||
if (argv.includes('--configure')) {
|
||||
await configure();
|
||||
}
|
||||
console.log('1', configPath);
|
||||
|
||||
if (!existsSync(configPath)) {
|
||||
console.log(
|
||||
`${CONFIG_EMOJIS.INFO} No configuration file found. Starting setup...`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@dvmcp/bridge",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.18",
|
||||
"description": "Bridge connecting MCP servers to Nostr's DVM ecosystem",
|
||||
"module": "index.ts",
|
||||
"type": "module",
|
||||
|
||||
@@ -4,7 +4,11 @@ import { existsSync, readFileSync } from 'fs';
|
||||
import { HEX_KEYS_REGEX } from '@dvmcp/commons/constants';
|
||||
import type { Config, MCPServerConfig } from './types';
|
||||
|
||||
const CONFIG_PATH = join(process.cwd(), 'config.dvmcp.yml');
|
||||
let CONFIG_PATH = join(process.cwd(), 'config.dvmcp.yml');
|
||||
|
||||
export function setConfigPath(path: string) {
|
||||
CONFIG_PATH = path.startsWith('/') ? path : join(process.cwd(), path);
|
||||
}
|
||||
|
||||
const TEST_CONFIG: Config = {
|
||||
nostr: {
|
||||
@@ -87,7 +91,7 @@ function loadConfig(): Config {
|
||||
|
||||
if (!existsSync(CONFIG_PATH)) {
|
||||
throw new Error(
|
||||
'No config.dvmcp.yml file found. Please create one based on config.example.yml'
|
||||
`No config file found at ${CONFIG_PATH}. Please create one based on config.example.yml`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -137,8 +141,17 @@ function loadConfig(): Config {
|
||||
|
||||
return config;
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to load config: ${error}`);
|
||||
throw new Error(`Failed to load config from ${CONFIG_PATH}: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const CONFIG = loadConfig();
|
||||
let cachedConfig: Config | null = null;
|
||||
export function getConfig(): Config {
|
||||
if (!cachedConfig) {
|
||||
cachedConfig = loadConfig();
|
||||
}
|
||||
return cachedConfig;
|
||||
}
|
||||
|
||||
// For backward compatibility
|
||||
export const CONFIG = getConfig();
|
||||
|
||||
@@ -7,17 +7,20 @@ import {
|
||||
validateHexKey,
|
||||
validateRelayUrl,
|
||||
} from '@dvmcp/commons/config-generator';
|
||||
import { join } from 'path';
|
||||
import { join, resolve } from 'path';
|
||||
import type { Config } from './src/config.js';
|
||||
import { argv } from 'process';
|
||||
import { existsSync } from 'fs';
|
||||
import { setConfigPath } from './src/config.js';
|
||||
|
||||
const defaultConfigPath = join(process.cwd(), 'config.dvmcp.yml');
|
||||
let configPath = defaultConfigPath;
|
||||
|
||||
const configPathArgIndex = argv.indexOf('--config-path');
|
||||
if (configPathArgIndex !== -1 && argv[configPathArgIndex + 1]) {
|
||||
configPath = argv[configPathArgIndex + 1];
|
||||
configPath = resolve(argv[configPathArgIndex + 1]);
|
||||
console.log(`Using config path: ${configPath}`);
|
||||
setConfigPath(configPath);
|
||||
}
|
||||
|
||||
const configFields: Record<string, FieldConfig> = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@dvmcp/discovery",
|
||||
"version": "0.1.12",
|
||||
"version": "0.1.13",
|
||||
"description": "Discovery service for MCP tools in the Nostr DVM ecosystem",
|
||||
"module": "index.ts",
|
||||
"type": "module",
|
||||
|
||||
@@ -18,7 +18,11 @@ export interface Config {
|
||||
};
|
||||
}
|
||||
|
||||
const CONFIG_PATH = join(process.cwd(), 'config.dvmcp.yml');
|
||||
let CONFIG_PATH = join(process.cwd(), 'config.dvmcp.yml');
|
||||
|
||||
export function setConfigPath(path: string) {
|
||||
CONFIG_PATH = path.startsWith('/') ? path : join(process.cwd(), path);
|
||||
}
|
||||
|
||||
const TEST_CONFIG: Config = {
|
||||
nostr: {
|
||||
|
||||
Reference in New Issue
Block a user