Compare commits

...

2 Commits

Author SHA1 Message Date
samanhappy
91698a50e3 fix: use specified environment setting path when available (#359) 2025-10-11 23:44:23 +08:00
samanhappy
a5d5045832 fix: add groups handling in mergeSettings method (#362) 2025-10-11 23:29:59 +08:00
3 changed files with 22 additions and 9 deletions

View File

@@ -39,6 +39,7 @@ export class DataServicex implements DataService {
const result = { ...all };
result.users = newSettings.users;
result.systemConfig = newSettings.systemConfig;
result.groups = newSettings.groups;
return result;
} else {
const result = JSON.parse(JSON.stringify(all));

View File

@@ -43,7 +43,6 @@ export function registerService<T>(key: string, entry: Service<T>) {
}
}
console.log(`Service registered: ${key} with entry:`, entry);
registry.set(key, entry);
}

View File

@@ -12,15 +12,28 @@ const rootDir = process.cwd();
* @returns The path to the file
*/
export const getConfigFilePath = (filename: string, description = 'Configuration'): string => {
const envPath = process.env.MCPHUB_SETTING_PATH;
if (filename === 'mcp_settings.json') {
const envPath = process.env.MCPHUB_SETTING_PATH;
if (envPath) {
// check envPath is file or directory
const stats = fs.statSync(envPath);
if (stats.isFile()) {
return envPath;
}
// if directory, return path under that directory
return path.resolve(envPath, filename);
}
}
const potentialPaths = [
...(envPath ? [envPath] : []),
// Prioritize process.cwd() as the first location to check
path.resolve(process.cwd(), filename),
// Use path relative to the root directory
path.join(rootDir, filename),
// If installed with npx, may need to look one level up
path.join(dirname(rootDir), filename),
...[
// Prioritize process.cwd() as the first location to check
path.resolve(process.cwd(), filename),
// Use path relative to the root directory
path.join(rootDir, filename),
// If installed with npx, may need to look one level up
path.join(dirname(rootDir), filename),
],
];
for (const filePath of potentialPaths) {