@monodog/backend 1.3.8 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-loader.js +2 -41
- package/package.json +1 -1
- package/src/config-loader.ts +2 -45
package/dist/config-loader.js
CHANGED
|
@@ -52,12 +52,11 @@ function loadConfig() {
|
|
|
52
52
|
// or that we can navigate up to the root from the current file's location.
|
|
53
53
|
let rootPath = path.resolve(process.cwd()); // Adjust based on your workspace folder depth from root if needed
|
|
54
54
|
let configPath = path.resolve(rootPath, 'monodog-conf.json');
|
|
55
|
-
// createConfigFileIfMissing(rootPath);
|
|
56
55
|
if (!fs.existsSync(configPath)) {
|
|
57
|
-
|
|
56
|
+
console.error(`ERROR1: Configuration file not found at ${configPath}`);
|
|
58
57
|
configPath = path.resolve(path.resolve('../../'), 'monodog-conf.json'); //get root config, Adjust based on your workspace folder depth from root if needed
|
|
59
58
|
if (!fs.existsSync(configPath)) {
|
|
60
|
-
console.error(`
|
|
59
|
+
console.error(`ERROR2: Configuration file not found at ${configPath}`);
|
|
61
60
|
configPath = path.resolve(rootPath, 'monodog-conf.json');
|
|
62
61
|
process.exit(1);
|
|
63
62
|
}
|
|
@@ -78,44 +77,6 @@ function loadConfig() {
|
|
|
78
77
|
process.exit(1);
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
|
-
function createConfigFileIfMissing(rootPath) {
|
|
82
|
-
// --- CONFIGURATION ---
|
|
83
|
-
const configFileName = 'monodog-conf.json';
|
|
84
|
-
const configFilePath = path.resolve(rootPath, configFileName);
|
|
85
|
-
// The default content for the configuration file
|
|
86
|
-
const defaultContent = {
|
|
87
|
-
"workspace": {
|
|
88
|
-
"root_dir": "./", // Relative to where the config file is located
|
|
89
|
-
"install_path": "packages" // Where to install monodog packages
|
|
90
|
-
},
|
|
91
|
-
"database": {
|
|
92
|
-
"path": "file:./monodog.db" // SQLite database file path, relative to prisma schema location
|
|
93
|
-
},
|
|
94
|
-
"server": {
|
|
95
|
-
"host": "0.0.0.0", // Default host for the API server
|
|
96
|
-
"port": 4000 // Default port for the API server
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const contentString = JSON.stringify(defaultContent, null, 2);
|
|
100
|
-
// ---------------------
|
|
101
|
-
console.log(`\n[monodog] Checking for ${configFileName}...`);
|
|
102
|
-
if (fs.existsSync(configFilePath)) {
|
|
103
|
-
console.log(`[monodog] ${configFileName} already exists. Skipping creation.`);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
try {
|
|
107
|
-
// Write the default content to the file
|
|
108
|
-
fs.writeFileSync(configFilePath, contentString, 'utf-8');
|
|
109
|
-
console.log(`[monodog] Successfully generated default ${configFileName} in the workspace root.`);
|
|
110
|
-
console.log('[monodog] Please review and update settings like "host" and "port".');
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
114
|
-
console.error(`[monodog Error] Failed to generate ${configFileName}:`, message);
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
80
|
// --- Example Usage ---
|
|
120
81
|
// In your main application file (e.g., packages/backend/src/index.ts):
|
|
121
82
|
/*
|
package/package.json
CHANGED
package/src/config-loader.ts
CHANGED
|
@@ -38,13 +38,12 @@ export function loadConfig(): MonodogConfig {
|
|
|
38
38
|
// or that we can navigate up to the root from the current file's location.
|
|
39
39
|
let rootPath = path.resolve(process.cwd()); // Adjust based on your workspace folder depth from root if needed
|
|
40
40
|
let configPath = path.resolve(rootPath, 'monodog-conf.json');
|
|
41
|
-
// createConfigFileIfMissing(rootPath);
|
|
42
41
|
|
|
43
42
|
if (!fs.existsSync(configPath)) {
|
|
44
|
-
|
|
43
|
+
console.error(`ERROR1: Configuration file not found at ${configPath}`);
|
|
45
44
|
configPath = path.resolve(path.resolve('../../'), 'monodog-conf.json'); //get root config, Adjust based on your workspace folder depth from root if needed
|
|
46
45
|
if (!fs.existsSync(configPath)) {
|
|
47
|
-
console.error(`
|
|
46
|
+
console.error(`ERROR2: Configuration file not found at ${configPath}`);
|
|
48
47
|
configPath = path.resolve(rootPath, 'monodog-conf.json');
|
|
49
48
|
process.exit(1);
|
|
50
49
|
}
|
|
@@ -69,48 +68,6 @@ export function loadConfig(): MonodogConfig {
|
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
function createConfigFileIfMissing(rootPath: string): void {
|
|
74
|
-
// --- CONFIGURATION ---
|
|
75
|
-
const configFileName = 'monodog-conf.json';
|
|
76
|
-
const configFilePath = path.resolve(rootPath, configFileName);
|
|
77
|
-
|
|
78
|
-
// The default content for the configuration file
|
|
79
|
-
const defaultContent = {
|
|
80
|
-
"workspace": {
|
|
81
|
-
"root_dir": "./", // Relative to where the config file is located
|
|
82
|
-
"install_path":"packages" // Where to install monodog packages
|
|
83
|
-
},
|
|
84
|
-
"database": {
|
|
85
|
-
"path": "file:./monodog.db" // SQLite database file path, relative to prisma schema location
|
|
86
|
-
},
|
|
87
|
-
"server": {
|
|
88
|
-
"host": "0.0.0.0", // Default host for the API server
|
|
89
|
-
"port": 4000 // Default port for the API server
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const contentString = JSON.stringify(defaultContent, null, 2);
|
|
94
|
-
// ---------------------
|
|
95
|
-
|
|
96
|
-
console.log(`\n[monodog] Checking for ${configFileName}...`);
|
|
97
|
-
|
|
98
|
-
if (fs.existsSync(configFilePath)) {
|
|
99
|
-
console.log(`[monodog] ${configFileName} already exists. Skipping creation.`);
|
|
100
|
-
} else {
|
|
101
|
-
try {
|
|
102
|
-
// Write the default content to the file
|
|
103
|
-
fs.writeFileSync(configFilePath, contentString, 'utf-8');
|
|
104
|
-
console.log(`[monodog] Successfully generated default ${configFileName} in the workspace root.`);
|
|
105
|
-
console.log('[monodog] Please review and update settings like "host" and "port".');
|
|
106
|
-
} catch (err: unknown) {
|
|
107
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
108
|
-
console.error(`[monodog Error] Failed to generate ${configFileName}:`, message);
|
|
109
|
-
process.exit(1);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
71
|
// --- Example Usage ---
|
|
115
72
|
|
|
116
73
|
// In your main application file (e.g., packages/backend/src/index.ts):
|