Skip to content

Commit 4455030

Browse files
marcusgollclaude
andcommitted
feat: include GitHub workflows in npx spec-flow init and update
- Added installWorkflows() function to copy .github/workflows/ directory - Workflows now install during both init and update commands - Uses same conflict resolution strategy as other files (merge by default) - Respects --strategy flag (merge|backup|skip|force) - Skips existing workflow files during update to preserve customizations Fixes issue where workflows were only installed via postinstall, not via CLI commands 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2d8e238 commit 4455030

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

bin/install.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,43 @@ async function installDocs({ packageRoot, targetDir, conflictStrategy, verbose }
109109
return actions;
110110
}
111111

112+
/** Copy GitHub workflows with conflict resolution; collect actions */
113+
async function installWorkflows({ packageRoot, targetDir, conflictStrategy, verbose }) {
114+
const actions = [];
115+
const sourceWorkflowsDir = path.join(packageRoot, '.github', 'workflows');
116+
const targetWorkflowsDir = path.join(targetDir, '.github', 'workflows');
117+
118+
// Check if source workflows exist
119+
if (!await fs.pathExists(sourceWorkflowsDir)) {
120+
return actions; // No workflows to install
121+
}
122+
123+
await withSpinner('Installing GitHub workflows...', async (setText) => {
124+
// Ensure target directory exists
125+
await fs.ensureDir(targetWorkflowsDir);
126+
127+
// Get all workflow files
128+
const files = await fs.readdir(sourceWorkflowsDir);
129+
const workflowFiles = files.filter(f => f.endsWith('.yml') || f.endsWith('.yaml'));
130+
131+
for (const file of workflowFiles) {
132+
const source = path.join(sourceWorkflowsDir, file);
133+
const dest = path.join(targetWorkflowsDir, file);
134+
135+
const action = await resolveConflict({
136+
sourcePath: source,
137+
targetPath: dest,
138+
strategy: conflictStrategy,
139+
fileName: file
140+
});
141+
actions.push(action);
142+
if (verbose) setText(`.github/workflows/${file}: ${action.action}`);
143+
}
144+
}, { enabled: process.env.CI !== 'true' });
145+
146+
return actions;
147+
}
148+
112149
/**
113150
* Install spec-flow to target directory
114151
* @param {Object} options
@@ -195,6 +232,10 @@ async function install(options) {
195232
const docActions = await installDocs({ packageRoot, targetDir, conflictStrategy, verbose });
196233
conflictActions.push(...docActions);
197234

235+
// 4) GitHub workflows
236+
const workflowActions = await installWorkflows({ packageRoot, targetDir, conflictStrategy, verbose });
237+
conflictActions.push(...workflowActions);
238+
198239
printSuccess('\nInstallation complete!');
199240
return { success: true, error: null, conflictActions };
200241
} catch (error) {

0 commit comments

Comments
 (0)