Mixed line endings (Windows CRLF problem) (#1222)
Co-authored-by: lukasz.krysik <lukasz.krysik@effem.com>
This commit is contained in:
parent
8b92e5ee59
commit
8699d7d968
|
|
@ -10,9 +10,15 @@ const ui = new UI();
|
||||||
module.exports = {
|
module.exports = {
|
||||||
command: 'install',
|
command: 'install',
|
||||||
description: 'Install BMAD Core agents and tools',
|
description: 'Install BMAD Core agents and tools',
|
||||||
options: [],
|
options: [['-d, --debug', 'Enable debug output for manifest generation']],
|
||||||
action: async (options) => {
|
action: async (options) => {
|
||||||
try {
|
try {
|
||||||
|
// Set debug flag as environment variable for all components
|
||||||
|
if (options.debug) {
|
||||||
|
process.env.BMAD_DEBUG_MANIFEST = 'true';
|
||||||
|
console.log(chalk.cyan('Debug mode enabled\n'));
|
||||||
|
}
|
||||||
|
|
||||||
const config = await ui.promptInstall();
|
const config = await ui.promptInstall();
|
||||||
|
|
||||||
// Handle cancel
|
// Handle cancel
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,16 @@ class ManifestGenerator {
|
||||||
async getWorkflowsFromPath(basePath, moduleName) {
|
async getWorkflowsFromPath(basePath, moduleName) {
|
||||||
const workflows = [];
|
const workflows = [];
|
||||||
const workflowsPath = path.join(basePath, 'workflows');
|
const workflowsPath = path.join(basePath, 'workflows');
|
||||||
|
const debug = process.env.BMAD_DEBUG_MANIFEST === 'true';
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
console.log(`[DEBUG] Scanning workflows in: ${workflowsPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(await fs.pathExists(workflowsPath))) {
|
if (!(await fs.pathExists(workflowsPath))) {
|
||||||
|
if (debug) {
|
||||||
|
console.log(`[DEBUG] Workflows path does not exist: ${workflowsPath}`);
|
||||||
|
}
|
||||||
return workflows;
|
return workflows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,8 +147,13 @@ class ManifestGenerator {
|
||||||
await findWorkflows(fullPath, newRelativePath);
|
await findWorkflows(fullPath, newRelativePath);
|
||||||
} else if (entry.name === 'workflow.yaml' || entry.name === 'workflow.md') {
|
} else if (entry.name === 'workflow.yaml' || entry.name === 'workflow.md') {
|
||||||
// Parse workflow file (both YAML and MD formats)
|
// Parse workflow file (both YAML and MD formats)
|
||||||
|
if (debug) {
|
||||||
|
console.log(`[DEBUG] Found workflow file: ${fullPath}`);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const content = await fs.readFile(fullPath, 'utf8');
|
// Read and normalize line endings (fix Windows CRLF issues)
|
||||||
|
const rawContent = await fs.readFile(fullPath, 'utf8');
|
||||||
|
const content = rawContent.replaceAll('\r\n', '\n').replaceAll('\r', '\n');
|
||||||
|
|
||||||
let workflow;
|
let workflow;
|
||||||
if (entry.name === 'workflow.yaml') {
|
if (entry.name === 'workflow.yaml') {
|
||||||
|
|
@ -150,13 +163,23 @@ class ManifestGenerator {
|
||||||
// Parse MD workflow with YAML frontmatter
|
// Parse MD workflow with YAML frontmatter
|
||||||
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
||||||
if (!frontmatterMatch) {
|
if (!frontmatterMatch) {
|
||||||
|
if (debug) {
|
||||||
|
console.log(`[DEBUG] Skipped (no frontmatter): ${fullPath}`);
|
||||||
|
}
|
||||||
continue; // Skip MD files without frontmatter
|
continue; // Skip MD files without frontmatter
|
||||||
}
|
}
|
||||||
workflow = yaml.parse(frontmatterMatch[1]);
|
workflow = yaml.parse(frontmatterMatch[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
console.log(`[DEBUG] Parsed: name="${workflow.name}", description=${workflow.description ? 'OK' : 'MISSING'}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Skip template workflows (those with placeholder values)
|
// Skip template workflows (those with placeholder values)
|
||||||
if (workflow.name && workflow.name.includes('{') && workflow.name.includes('}')) {
|
if (workflow.name && workflow.name.includes('{') && workflow.name.includes('}')) {
|
||||||
|
if (debug) {
|
||||||
|
console.log(`[DEBUG] Skipped (template placeholder): ${workflow.name}`);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,6 +205,14 @@ class ManifestGenerator {
|
||||||
module: moduleName,
|
module: moduleName,
|
||||||
path: installPath,
|
path: installPath,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
console.log(`[DEBUG] ✓ Added workflow: ${workflow.name} (${moduleName})`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (debug) {
|
||||||
|
console.log(`[DEBUG] Skipped (missing name or description): ${fullPath}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(`Warning: Failed to parse workflow at ${fullPath}: ${error.message}`);
|
console.warn(`Warning: Failed to parse workflow at ${fullPath}: ${error.message}`);
|
||||||
|
|
@ -191,6 +222,11 @@ class ManifestGenerator {
|
||||||
};
|
};
|
||||||
|
|
||||||
await findWorkflows(workflowsPath);
|
await findWorkflows(workflowsPath);
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
console.log(`[DEBUG] Total workflows found in ${moduleName}: ${workflows.length}`);
|
||||||
|
}
|
||||||
|
|
||||||
return workflows;
|
return workflows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue