mirror of
https://github.com/bmad-code-org/BMAD-METHOD.git
synced 2026-09-19 08:11:52 +08:00
ea99b7ece5
* chore(installer): remove dead code across installer modules
Delete 3 entirely dead files (agent-command-generator, bmad-artifacts,
module-injections) and remove ~50 unused exports from manifest.js,
cli-utils.js, prompts.js, path-utils.js, official-modules.js,
external-manager.js, custom-module-manager.js, and registry-client.js.
Removes corresponding dead tests.
* fix(installer): restore currentProjectDir writes for placeholder expansion
The previous commit removed the three assignments to
OfficialModules.currentProjectDir as dead code, but buildQuestion()
still reads the property to resolve {directory_name} placeholders in
module config defaults during interactive collection. Without the
writes, any module default containing {directory_name} would surface
the literal placeholder to users.
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
const https = require('node:https');
|
|
const yaml = require('yaml');
|
|
|
|
/**
|
|
* Shared HTTP client for fetching registry data from GitHub.
|
|
* Used by ExternalModuleManager, CommunityModuleManager, and CustomModuleManager.
|
|
*/
|
|
class RegistryClient {
|
|
constructor(options = {}) {
|
|
this.timeout = options.timeout || 10_000;
|
|
}
|
|
|
|
/**
|
|
* Fetch a URL and return the response body as a string.
|
|
* Follows one redirect (GitHub sometimes 301s).
|
|
* @param {string} url - URL to fetch
|
|
* @param {number} [timeout] - Timeout in ms (overrides default)
|
|
* @returns {Promise<string>} Response body
|
|
*/
|
|
fetch(url, timeout) {
|
|
const timeoutMs = timeout || this.timeout;
|
|
return new Promise((resolve, reject) => {
|
|
const req = https
|
|
.get(url, { timeout: timeoutMs }, (res) => {
|
|
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
return this.fetch(res.headers.location, timeoutMs).then(resolve, reject);
|
|
}
|
|
if (res.statusCode !== 200) {
|
|
return reject(new Error(`HTTP ${res.statusCode}`));
|
|
}
|
|
let data = '';
|
|
res.on('data', (chunk) => (data += chunk));
|
|
res.on('end', () => resolve(data));
|
|
})
|
|
.on('error', reject)
|
|
.on('timeout', () => {
|
|
req.destroy();
|
|
reject(new Error('Request timed out'));
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Fetch a URL and parse the response as YAML.
|
|
* @param {string} url - URL to fetch
|
|
* @param {number} [timeout] - Timeout in ms
|
|
* @returns {Promise<Object>} Parsed YAML content
|
|
*/
|
|
async fetchYaml(url, timeout) {
|
|
const content = await this.fetch(url, timeout);
|
|
return yaml.parse(content);
|
|
}
|
|
}
|
|
|
|
module.exports = { RegistryClient };
|