@mockingbird_konwlage_cli/cli 1.2.6 → 1.2.7
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/index.js +35 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -29,6 +29,41 @@ program
|
|
|
29
29
|
// Configuration discovery logic
|
|
30
30
|
let apiBaseUrl = process.env.MOCKINGBIRD_API_URL;
|
|
31
31
|
|
|
32
|
+
if (!apiBaseUrl) {
|
|
33
|
+
// Priority 1: .mockingbirdrc
|
|
34
|
+
const rcPath = path.join(process.cwd(), '.mockingbirdrc');
|
|
35
|
+
if (fs.existsSync(rcPath)) {
|
|
36
|
+
try {
|
|
37
|
+
const rc = JSON.parse(fs.readFileSync(rcPath, 'utf8'));
|
|
38
|
+
apiBaseUrl = isRemote ? rc.RemoteApiBaseUrl : rc.ApiBaseUrl;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.warn(chalk.yellow(`[Warning] Failed to parse .mockingbirdrc: ${e.message}`));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!apiBaseUrl) {
|
|
46
|
+
// Priority 2: appsettings.Production.json (useful for server environments)
|
|
47
|
+
const prodSettingsPath = path.join(process.cwd(), 'appsettings.Production.json');
|
|
48
|
+
if (fs.existsSync(prodSettingsPath)) {
|
|
49
|
+
try {
|
|
50
|
+
const settings = JSON.parse(fs.readFileSync(prodSettingsPath, 'utf8'));
|
|
51
|
+
apiBaseUrl = settings.ApiBaseUrl;
|
|
52
|
+
} catch (e) { }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!apiBaseUrl) {
|
|
57
|
+
// Priority 3: appsettings.json
|
|
58
|
+
const appSettingsPath = path.join(process.cwd(), 'appsettings.json');
|
|
59
|
+
if (fs.existsSync(appSettingsPath)) {
|
|
60
|
+
try {
|
|
61
|
+
const settings = JSON.parse(fs.readFileSync(appSettingsPath, 'utf8'));
|
|
62
|
+
apiBaseUrl = settings.ApiBaseUrl;
|
|
63
|
+
} catch (e) { }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
32
67
|
// Final fallback to production API
|
|
33
68
|
const API_BASE_URL = apiBaseUrl || 'https://api.aigcclub.com.cn';
|
|
34
69
|
const apiUrl = `${API_BASE_URL}/api/public/skills/raw/${slug}`;
|