Add root folder selection to installer

- Users can now choose between design-process/, docs/, or deliverables/
- Removes folder auto-detection logic that caused duplicate folders
- Installer creates folders at user's chosen location
- Prevents conflict with project setup workflow

Fixes issue where both design-process/ and docs/ were created.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mårten Angner 2026-02-23 13:15:36 +01:00
parent 74f4aeee21
commit 0cb415afbf
2 changed files with 28 additions and 39 deletions

View File

@ -25,7 +25,7 @@ class Installer {
* @param {Object} config - Configuration from UI prompts * @param {Object} config - Configuration from UI prompts
*/ */
async install(config) { async install(config) {
const { projectDir, wdsFolder, ides, project_type, design_experience } = config; const { projectDir, wdsFolder, ides, project_type, design_experience, root_folder } = config;
const wdsDir = path.join(projectDir, wdsFolder); const wdsDir = path.join(projectDir, wdsFolder);
// Check if already installed // Check if already installed
@ -101,24 +101,22 @@ class Installer {
throw error; throw error;
} }
// Step 4: Create docs folder structure // Step 4: Create work products folder structure
const docsSpinner = ora('Creating project folders...').start(); const rootFolder = root_folder || 'design-process';
let detectedOutputFolder = 'docs'; const docsSpinner = ora(`Creating project folders in ${rootFolder}/...`).start();
try { try {
detectedOutputFolder = await this.createDocsFolders(projectDir, config); await this.createDocsFolders(projectDir, rootFolder, config);
docsSpinner.succeed(`Project folders created in ${detectedOutputFolder}/`); docsSpinner.succeed(`Project folders created in ${rootFolder}/`);
} catch (error) { } catch (error) {
docsSpinner.fail('Failed to create project folders'); docsSpinner.fail('Failed to create project folders');
throw error; throw error;
} }
// Update config.yaml with detected output folder (if different from default) // Update config.yaml with root folder
if (detectedOutputFolder !== 'docs') { const configPath = path.join(wdsDir, 'config.yaml');
const configPath = path.join(wdsDir, 'config.yaml'); let configContent = await fs.readFile(configPath, 'utf8');
let configContent = await fs.readFile(configPath, 'utf8'); configContent = configContent.replace(/output_folder:\s*docs/, `output_folder: ${rootFolder}`);
configContent = configContent.replace(/output_folder:\s*docs/, `output_folder: ${detectedOutputFolder}`); await fs.writeFile(configPath, configContent, 'utf8');
await fs.writeFile(configPath, configContent, 'utf8');
}
// Step 5: Set up IDEs // Step 5: Set up IDEs
const ideList = ides || (config.ide ? [config.ide] : []); const ideList = ides || (config.ide ? [config.ide] : []);
@ -242,30 +240,13 @@ class Installer {
} }
/** /**
* Create the WDS docs folder structure * Create the WDS work products folder structure
* FIXED: Detects existing folders, doesn't overwrite files * @param {string} projectDir - Project root directory
* @param {string} rootFolder - Root folder name (design-process, docs, deliverables, etc.)
* @param {Object} config - Configuration object
*/ */
async createDocsFolders(projectDir, config) { async createDocsFolders(projectDir, rootFolder, config) {
// Check if user already has a deliverables folder with WDS content const docsPath = path.join(projectDir, rootFolder);
const possibleFolders = ['design-process', 'docs', 'deliverables', 'wds-deliverables'];
let existingFolder = null;
for (const folderName of possibleFolders) {
const folderPath = path.join(projectDir, folderName);
if (await fs.pathExists(folderPath)) {
// Check if it has WDS structure (A-Product-Brief, B-Trigger-Map, etc.)
const hasProductBrief = await fs.pathExists(path.join(folderPath, 'A-Product-Brief'));
const hasTriggerMap = await fs.pathExists(path.join(folderPath, 'B-Trigger-Map'));
if (hasProductBrief || hasTriggerMap) {
existingFolder = folderName;
break;
}
}
}
// Use existing folder if found, otherwise default to 'docs'
const outputFolder = existingFolder || 'docs';
const docsPath = path.join(projectDir, outputFolder);
const folders = [ const folders = [
'A-Product-Brief', 'A-Product-Brief',
@ -296,9 +277,6 @@ class Installer {
// Create 00 guide files in each folder (if they don't exist) // Create 00 guide files in each folder (if they don't exist)
await this.createFolderGuides(docsPath, config); await this.createFolderGuides(docsPath, config);
// Return the detected/used folder name so config.yaml can be updated
return outputFolder;
} }
/** /**

View File

@ -78,6 +78,17 @@ class UI {
], ],
default: 'intermediate', default: 'intermediate',
}, },
{
type: 'list',
name: 'root_folder',
message: 'Where should design work products be stored?',
choices: [
{ name: 'design-process/ - Recommended for clarity', value: 'design-process' },
{ name: 'docs/ - Standard documentation folder', value: 'docs' },
{ name: 'deliverables/ - Alternative naming', value: 'deliverables' },
],
default: 'design-process',
},
{ {
type: 'confirm', type: 'confirm',
name: 'include_learning', name: 'include_learning',