rename function and add boxen
This commit is contained in:
@@ -29,7 +29,7 @@ import {
|
|||||||
convertAllRulesToProfileRules,
|
convertAllRulesToProfileRules,
|
||||||
getRulesProfile
|
getRulesProfile
|
||||||
} from '../src/utils/rule-transformer.js';
|
} from '../src/utils/rule-transformer.js';
|
||||||
import { runInteractiveRulesSetup } from '../src/utils/profiles.js';
|
import { runInteractiveProfilesSetup } from '../src/utils/profiles.js';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
@@ -309,7 +309,7 @@ async function initializeProject(options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const skipPrompts = options.yes || (options.name && options.description);
|
const skipPrompts = options.yes || (options.name && options.description);
|
||||||
let selectedRulesProfiles =
|
let selectedRuleProfiles =
|
||||||
options.rules && Array.isArray(options.rules) && options.rules.length > 0
|
options.rules && Array.isArray(options.rules) && options.rules.length > 0
|
||||||
? options.rules
|
? options.rules
|
||||||
: RULE_PROFILES; // Default to all profiles
|
: RULE_PROFILES; // Default to all profiles
|
||||||
@@ -335,7 +335,7 @@ async function initializeProject(options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
createProjectStructure(addAliases, dryRun, selectedRulesProfiles);
|
createProjectStructure(addAliases, dryRun, selectedRuleProfiles);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log('error', `Error during initialization process: ${error.message}`);
|
log('error', `Error during initialization process: ${error.message}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
@@ -384,10 +384,10 @@ async function initializeProject(options = {}) {
|
|||||||
if (options.rulesExplicitlyProvided) {
|
if (options.rulesExplicitlyProvided) {
|
||||||
log(
|
log(
|
||||||
'info',
|
'info',
|
||||||
`Using rule profiles provided via command line: ${selectedRulesProfiles.join(', ')}`
|
`Using rule profiles provided via command line: ${selectedRuleProfiles.join(', ')}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
selectedRulesProfiles = await runInteractiveRulesSetup();
|
selectedRuleProfiles = await runInteractiveProfilesSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
const dryRun = options.dryRun || false;
|
const dryRun = options.dryRun || false;
|
||||||
@@ -405,7 +405,7 @@ async function initializeProject(options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create structure using only necessary values
|
// Create structure using only necessary values
|
||||||
createProjectStructure(addAliasesPrompted, dryRun, selectedRulesProfiles);
|
createProjectStructure(addAliasesPrompted, dryRun, selectedRuleProfiles);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
rl.close();
|
rl.close();
|
||||||
log('error', `Error during initialization process: ${error.message}`);
|
log('error', `Error during initialization process: ${error.message}`);
|
||||||
@@ -427,7 +427,7 @@ function promptQuestion(rl, question) {
|
|||||||
function createProjectStructure(
|
function createProjectStructure(
|
||||||
addAliases,
|
addAliases,
|
||||||
dryRun,
|
dryRun,
|
||||||
selectedRulesProfiles = RULE_PROFILES // Default to all rule profiles
|
selectedRuleProfiles = RULE_PROFILES // Default to all rule profiles
|
||||||
) {
|
) {
|
||||||
const targetDir = process.cwd();
|
const targetDir = process.cwd();
|
||||||
log('info', `Initializing project in ${targetDir}`);
|
log('info', `Initializing project in ${targetDir}`);
|
||||||
@@ -490,7 +490,7 @@ function createProjectStructure(
|
|||||||
|
|
||||||
// Generate profile rules from assets/rules
|
// Generate profile rules from assets/rules
|
||||||
log('info', 'Generating profile rules from assets/rules...');
|
log('info', 'Generating profile rules from assets/rules...');
|
||||||
for (const profileName of selectedRulesProfiles) {
|
for (const profileName of selectedRuleProfiles) {
|
||||||
_processSingleProfile(profileName);
|
_processSingleProfile(profileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ import {
|
|||||||
getRulesProfile
|
getRulesProfile
|
||||||
} from '../../src/utils/rule-transformer.js';
|
} from '../../src/utils/rule-transformer.js';
|
||||||
import {
|
import {
|
||||||
runInteractiveRulesSetup,
|
runInteractiveProfilesSetup,
|
||||||
generateProfileSummary,
|
generateProfileSummary,
|
||||||
categorizeProfileResults,
|
categorizeProfileResults,
|
||||||
generateProfileRemovalSummary,
|
generateProfileRemovalSummary,
|
||||||
@@ -2703,8 +2703,8 @@ Examples:
|
|||||||
*/
|
*/
|
||||||
if (action === RULES_SETUP_ACTION) {
|
if (action === RULES_SETUP_ACTION) {
|
||||||
// Run interactive rules setup ONLY (no project init)
|
// Run interactive rules setup ONLY (no project init)
|
||||||
const selectedRulesProfiles = await runInteractiveRulesSetup();
|
const selectedRuleProfiles = await runInteractiveProfilesSetup();
|
||||||
for (const profile of selectedRulesProfiles) {
|
for (const profile of selectedRuleProfiles) {
|
||||||
if (!isValidProfile(profile)) {
|
if (!isValidProfile(profile)) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`Rule profile for "${profile}" not found. Valid profiles: ${RULE_PROFILES.join(', ')}. Skipping.`
|
`Rule profile for "${profile}" not found. Valid profiles: ${RULE_PROFILES.join(', ')}. Skipping.`
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import path from 'path';
|
|||||||
import readline from 'readline';
|
import readline from 'readline';
|
||||||
import inquirer from 'inquirer';
|
import inquirer from 'inquirer';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
import boxen from 'boxen';
|
||||||
import { log } from '../../scripts/modules/utils.js';
|
import { log } from '../../scripts/modules/utils.js';
|
||||||
import { getRulesProfile } from './rule-transformer.js';
|
import { getRulesProfile } from './rule-transformer.js';
|
||||||
import { RULE_PROFILES } from '../constants/profiles.js';
|
import { RULE_PROFILES } from '../constants/profiles.js';
|
||||||
@@ -86,21 +87,73 @@ const availableRulesProfiles = RULE_PROFILES.map((name) => {
|
|||||||
*
|
*
|
||||||
* @returns {Promise<string[]>} Array of selected profile names (e.g., ['cursor', 'windsurf'])
|
* @returns {Promise<string[]>} Array of selected profile names (e.g., ['cursor', 'windsurf'])
|
||||||
*/
|
*/
|
||||||
export async function runInteractiveRulesSetup() {
|
export async function runInteractiveProfilesSetup() {
|
||||||
|
// Generate the profile list dynamically with proper display names, alphabetized
|
||||||
|
const profileDescriptions = RULE_PROFILES.map((profileName) => {
|
||||||
|
const displayName = getProfileDisplayName(profileName);
|
||||||
|
const profile = getRulesProfile(profileName);
|
||||||
|
|
||||||
|
// Determine description based on profile type
|
||||||
|
let description;
|
||||||
|
if (Object.keys(profile.fileMap).length === 0) {
|
||||||
|
// Simple profiles (Claude, Codex) - specify the target file
|
||||||
|
const targetFileName =
|
||||||
|
profileName === 'claude' ? 'CLAUDE.md' : 'AGENTS.md';
|
||||||
|
description = `Integration guide for ${displayName} (${targetFileName})`;
|
||||||
|
} else {
|
||||||
|
// Full profiles with rules - check if they have MCP config
|
||||||
|
const hasMcpConfig = profile.mcpConfig === true;
|
||||||
|
if (hasMcpConfig) {
|
||||||
|
description = `Rule profile and MCP config for ${displayName}`;
|
||||||
|
} else {
|
||||||
|
description = `Rule profile for ${displayName}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
displayName,
|
||||||
|
description
|
||||||
|
};
|
||||||
|
}).sort((a, b) => a.displayName.localeCompare(b.displayName)); // Alphabetize by display name
|
||||||
|
|
||||||
|
const profileListText = profileDescriptions
|
||||||
|
.map(
|
||||||
|
({ displayName, description }) =>
|
||||||
|
chalk.white('• ') +
|
||||||
|
chalk.yellow(displayName) +
|
||||||
|
chalk.white(` - ${description}`)
|
||||||
|
)
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
chalk.cyan(
|
boxen(
|
||||||
'\nRule profiles help enforce best practices and conventions for Task Master.'
|
chalk.white.bold('Rule Profiles Setup') +
|
||||||
|
'\n\n' +
|
||||||
|
chalk.white(
|
||||||
|
'Rule profiles help enforce best practices and conventions for Task Master.\n' +
|
||||||
|
'Each profile provides coding guidelines tailored for specific AI coding environments.\n\n'
|
||||||
|
) +
|
||||||
|
chalk.cyan('Available Profiles:') +
|
||||||
|
'\n' +
|
||||||
|
profileListText,
|
||||||
|
{
|
||||||
|
padding: 1,
|
||||||
|
borderColor: 'blue',
|
||||||
|
borderStyle: 'round',
|
||||||
|
margin: { top: 1, bottom: 1 }
|
||||||
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
const rulesProfilesQuestion = {
|
|
||||||
|
const ruleProfilesQuestion = {
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
name: 'rulesProfiles',
|
name: 'ruleProfiles',
|
||||||
message: 'Which tools would you like rule profiles included for?',
|
message: 'Which rule profiles would you like to add to your project?',
|
||||||
choices: availableRulesProfiles,
|
choices: availableRulesProfiles,
|
||||||
validate: (input) => input.length > 0 || 'You must select at least one.'
|
validate: (input) => input.length > 0 || 'You must select at least one.'
|
||||||
};
|
};
|
||||||
const { rulesProfiles } = await inquirer.prompt([rulesProfilesQuestion]);
|
const { ruleProfiles } = await inquirer.prompt([ruleProfilesQuestion]);
|
||||||
return rulesProfiles;
|
return ruleProfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user