@monodog/backend 1.3.7 → 1.3.8
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/cli.js +39 -0
- package/dist/config-loader.js +1 -1
- package/package.json +1 -1
- package/src/cli.ts +42 -0
- package/src/config-loader.ts +1 -1
package/dist/cli.js
CHANGED
|
@@ -117,6 +117,7 @@ if (serve) {
|
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
119
119
|
console.log(`\nInitializing Configurations...`);
|
|
120
|
+
createConfigFileIfMissing(rootPath ?? process.cwd());
|
|
120
121
|
copyPackageToWorkspace(rootPath);
|
|
121
122
|
console.log(`Monodog CLI: No operation specified. Use --serve to start the API or -h for help. Ex: pnpm monodog-cli @monodog/dashboard --serve --root .`);
|
|
122
123
|
}
|
|
@@ -189,3 +190,41 @@ function copyPackageToWorkspace(rootDir) {
|
|
|
189
190
|
process.exit(1);
|
|
190
191
|
}
|
|
191
192
|
}
|
|
193
|
+
function createConfigFileIfMissing(rootPath) {
|
|
194
|
+
// --- CONFIGURATION ---
|
|
195
|
+
const configFileName = 'monodog-conf.json';
|
|
196
|
+
const configFilePath = path.resolve(rootPath, configFileName);
|
|
197
|
+
// The default content for the configuration file
|
|
198
|
+
const defaultContent = {
|
|
199
|
+
"workspace": {
|
|
200
|
+
"root_dir": "./", // Relative to where the config file is located
|
|
201
|
+
"install_path": "packages" // Where to install monodog packages
|
|
202
|
+
},
|
|
203
|
+
"database": {
|
|
204
|
+
"path": "./monodog.db" // SQLite database file path, relative to prisma schema location
|
|
205
|
+
},
|
|
206
|
+
"server": {
|
|
207
|
+
"host": "0.0.0.0", // Default host for the API server
|
|
208
|
+
"port": 4000 // Default port for the API server
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const contentString = JSON.stringify(defaultContent, null, 2);
|
|
212
|
+
// ---------------------
|
|
213
|
+
console.log(`\n[monodog] Checking for ${configFileName}...`);
|
|
214
|
+
if (fs.existsSync(configFilePath)) {
|
|
215
|
+
console.log(`[monodog] ${configFileName} already exists. Skipping creation.`);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
try {
|
|
219
|
+
// Write the default content to the file
|
|
220
|
+
fs.writeFileSync(configFilePath, contentString, 'utf-8');
|
|
221
|
+
console.log(`[monodog] Successfully generated default ${configFileName} in the workspace root.`);
|
|
222
|
+
console.log('[monodog] Please review and update settings like "host" and "port".');
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
226
|
+
console.error(`[monodog Error] Failed to generate ${configFileName}:`, message);
|
|
227
|
+
process.exit(1);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
package/dist/config-loader.js
CHANGED
|
@@ -52,7 +52,7 @@ 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);
|
|
55
|
+
// createConfigFileIfMissing(rootPath);
|
|
56
56
|
if (!fs.existsSync(configPath)) {
|
|
57
57
|
// console.error(`ERRORu: Configuration file not found at ${configPath}`);
|
|
58
58
|
configPath = path.resolve(path.resolve('../../'), 'monodog-conf.json'); //get root config, Adjust based on your workspace folder depth from root if needed
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -89,6 +89,8 @@ if (serve) {
|
|
|
89
89
|
startServer(rootPath, port, host);
|
|
90
90
|
} else {
|
|
91
91
|
console.log(`\nInitializing Configurations...`);
|
|
92
|
+
|
|
93
|
+
createConfigFileIfMissing(rootPath ?? process.cwd());
|
|
92
94
|
copyPackageToWorkspace(rootPath);
|
|
93
95
|
|
|
94
96
|
console.log(`Monodog CLI: No operation specified. Use --serve to start the API or -h for help. Ex: pnpm monodog-cli @monodog/dashboard --serve --root .`);
|
|
@@ -176,4 +178,44 @@ function copyPackageToWorkspace(rootDir: string): void {
|
|
|
176
178
|
}
|
|
177
179
|
}
|
|
178
180
|
|
|
181
|
+
function createConfigFileIfMissing(rootPath: string): void {
|
|
182
|
+
// --- CONFIGURATION ---
|
|
183
|
+
const configFileName = 'monodog-conf.json';
|
|
184
|
+
const configFilePath = path.resolve(rootPath, configFileName);
|
|
185
|
+
|
|
186
|
+
// The default content for the configuration file
|
|
187
|
+
const defaultContent = {
|
|
188
|
+
"workspace": {
|
|
189
|
+
"root_dir": "./", // Relative to where the config file is located
|
|
190
|
+
"install_path":"packages" // Where to install monodog packages
|
|
191
|
+
},
|
|
192
|
+
"database": {
|
|
193
|
+
"path": "./monodog.db" // SQLite database file path, relative to prisma schema location
|
|
194
|
+
},
|
|
195
|
+
"server": {
|
|
196
|
+
"host": "0.0.0.0", // Default host for the API server
|
|
197
|
+
"port": 4000 // Default port for the API server
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const contentString = JSON.stringify(defaultContent, null, 2);
|
|
202
|
+
// ---------------------
|
|
203
|
+
|
|
204
|
+
console.log(`\n[monodog] Checking for ${configFileName}...`);
|
|
205
|
+
|
|
206
|
+
if (fs.existsSync(configFilePath)) {
|
|
207
|
+
console.log(`[monodog] ${configFileName} already exists. Skipping creation.`);
|
|
208
|
+
} else {
|
|
209
|
+
try {
|
|
210
|
+
// Write the default content to the file
|
|
211
|
+
fs.writeFileSync(configFilePath, contentString, 'utf-8');
|
|
212
|
+
console.log(`[monodog] Successfully generated default ${configFileName} in the workspace root.`);
|
|
213
|
+
console.log('[monodog] Please review and update settings like "host" and "port".');
|
|
214
|
+
} catch (err: unknown) {
|
|
215
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
216
|
+
console.error(`[monodog Error] Failed to generate ${configFileName}:`, message);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
179
221
|
|
package/src/config-loader.ts
CHANGED
|
@@ -38,7 +38,7 @@ 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);
|
|
41
|
+
// createConfigFileIfMissing(rootPath);
|
|
42
42
|
|
|
43
43
|
if (!fs.existsSync(configPath)) {
|
|
44
44
|
// console.error(`ERRORu: Configuration file not found at ${configPath}`);
|