fix file extension transformations
This commit is contained in:
@@ -219,8 +219,17 @@ function convertAllRulesToBrandRules(projectDir, profile) {
|
|||||||
if (file.endsWith('.mdc')) {
|
if (file.endsWith('.mdc')) {
|
||||||
const sourcePath = path.join(cursorRulesDir, file);
|
const sourcePath = path.join(cursorRulesDir, file);
|
||||||
|
|
||||||
// Determine target file name (either from mapping or by replacing extension)
|
// Determine target file name
|
||||||
const targetFilename = fileMap[file] || file;
|
let targetFilename;
|
||||||
|
if (fileMap[file]) { // If an explicit mapping exists, use it
|
||||||
|
targetFilename = fileMap[file];
|
||||||
|
} else if (brandName === 'Roo' || brandName === 'Windsurf') {
|
||||||
|
// For Roo and Windsurf, change .mdc to .md if not in fileMap
|
||||||
|
targetFilename = file.replace(/\.mdc$/, '.md');
|
||||||
|
} else {
|
||||||
|
// For Cursor (and potentially others), keep original if not in fileMap
|
||||||
|
targetFilename = file;
|
||||||
|
}
|
||||||
const targetPath = path.join(brandRulesDir, targetFilename);
|
const targetPath = path.join(brandRulesDir, targetFilename);
|
||||||
|
|
||||||
// Convert the file
|
// Convert the file
|
||||||
|
|||||||
@@ -122,8 +122,7 @@ const conversionConfig = {
|
|||||||
|
|
||||||
export function onAddBrandRules(targetDir) {
|
export function onAddBrandRules(targetDir) {
|
||||||
const sourceDir = path.resolve(__dirname, '../../assets/roocode');
|
const sourceDir = path.resolve(__dirname, '../../assets/roocode');
|
||||||
const rulesDir = path.join(sourceDir, '.roo', 'rules');
|
copyRecursiveSync(sourceDir, targetDir);
|
||||||
copyRecursiveSync(sourceDir, targetDir, rulesDir, fileMap);
|
|
||||||
|
|
||||||
const rooModesDir = path.join(sourceDir, '.roo');
|
const rooModesDir = path.join(sourceDir, '.roo');
|
||||||
const rooModes = ['architect', 'ask', 'boomerang', 'code', 'debug', 'test'];
|
const rooModes = ['architect', 'ask', 'boomerang', 'code', 'debug', 'test'];
|
||||||
@@ -160,26 +159,17 @@ export function onAddBrandRules(targetDir) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyRecursiveSync(src, dest, rulesDir = null, fileMap = {}) {
|
function copyRecursiveSync(src, dest) {
|
||||||
const exists = fs.existsSync(src);
|
const exists = fs.existsSync(src);
|
||||||
const stats = exists && fs.statSync(src);
|
const stats = exists && fs.statSync(src);
|
||||||
const isDirectory = exists && stats.isDirectory();
|
const isDirectory = exists && stats.isDirectory();
|
||||||
if (isDirectory) {
|
if (isDirectory) {
|
||||||
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
||||||
fs.readdirSync(src).forEach((childItemName) => {
|
fs.readdirSync(src).forEach((childItemName) => {
|
||||||
const childSrc = path.join(src, childItemName);
|
copyRecursiveSync(
|
||||||
let childDest = path.join(dest, childItemName);
|
path.join(src, childItemName),
|
||||||
|
path.join(dest, childItemName)
|
||||||
// If we're under the rules directory, apply .mdc -> .md renaming
|
);
|
||||||
if (rulesDir && childSrc.includes(rulesDir)) {
|
|
||||||
const mapped = fileMap[childItemName];
|
|
||||||
if (mapped) {
|
|
||||||
childDest = path.join(dest, mapped);
|
|
||||||
} else if (childItemName.endsWith('.mdc')) {
|
|
||||||
childDest = path.join(dest, childItemName.replace(/\.mdc$/, '.md'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
copyRecursiveSync(childSrc, childDest, rulesDir, fileMap);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
fs.copyFileSync(src, dest);
|
fs.copyFileSync(src, dest);
|
||||||
|
|||||||
Reference in New Issue
Block a user