update semantics and terminology from 'brand rules' to 'rules profiles'
This commit is contained in:
@@ -14,8 +14,8 @@ describe('Cursor Profile Initialization Functionality', () => {
|
||||
cursorProfileContent = fs.readFileSync(cursorJsPath, 'utf8');
|
||||
});
|
||||
|
||||
test('cursor.js exports correct brandName and rulesDir', () => {
|
||||
expect(cursorProfileContent).toContain("const brandName = 'Cursor'");
|
||||
test('cursor.js exports correct profileName and rulesDir', () => {
|
||||
expect(cursorProfileContent).toContain("const profileName = 'Cursor'");
|
||||
expect(cursorProfileContent).toContain("const rulesDir = '.cursor/rules'");
|
||||
});
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('Roo Files Inclusion in Package', () => {
|
||||
const rooJsContent = fs.readFileSync(rooJsPath, 'utf8');
|
||||
|
||||
// Check for the main handler function
|
||||
expect(rooJsContent.includes('onAddBrandRules(targetDir)')).toBe(true);
|
||||
expect(rooJsContent.includes('onAddRulesProfile(targetDir)')).toBe(true);
|
||||
|
||||
// Check for general recursive copy of assets/roocode
|
||||
expect(
|
||||
|
||||
@@ -11,36 +11,31 @@ describe('Roo Profile Initialization Functionality', () => {
|
||||
rooProfileContent = fs.readFileSync(rooJsPath, 'utf8');
|
||||
});
|
||||
|
||||
test('roo.js profile ensures Roo directory structure via onAddBrandRules', () => {
|
||||
// Check if onAddBrandRules function exists
|
||||
expect(rooProfileContent).toContain('onAddBrandRules(targetDir)');
|
||||
test('roo.js profile ensures Roo directory structure via onAddRulesProfile', () => {
|
||||
// Check if onAddRulesProfile function exists
|
||||
expect(rooProfileContent).toContain('onAddRulesProfile(targetDir)');
|
||||
|
||||
// Check for the general copy of assets/roocode which includes .roo base structure
|
||||
expect(rooProfileContent).toContain(
|
||||
'copyRecursiveSync(sourceDir, targetDir)'
|
||||
"const sourceDir = path.resolve(__dirname, '../../assets/roocode');"
|
||||
);
|
||||
expect(rooProfileContent).toContain(
|
||||
"path.resolve(__dirname, '../../assets/roocode')"
|
||||
); // Verifies sourceDir definition
|
||||
|
||||
// Check for the loop that processes rooModes
|
||||
expect(rooProfileContent).toContain('for (const mode of rooModes)');
|
||||
|
||||
// Check for creation of mode-specific rule directories (e.g., .roo/rules-architect)
|
||||
// This is the line: if (!fs.existsSync(destDir)) fs.mkdirSync(destDir, { recursive: true });
|
||||
expect(rooProfileContent).toContain(
|
||||
'fs.mkdirSync(destDir, { recursive: true });'
|
||||
'copyRecursiveSync(sourceDir, targetDir);'
|
||||
);
|
||||
|
||||
// Check for the specific .roo modes directory handling
|
||||
expect(rooProfileContent).toContain(
|
||||
"const rooModesDir = path.join(sourceDir, '.roo');"
|
||||
);
|
||||
expect(rooProfileContent).toContain(
|
||||
"const rooModes = ['architect', 'ask', 'boomerang', 'code', 'debug', 'test'];"
|
||||
);
|
||||
expect(rooProfileContent).toContain('const destDir = path.dirname(dest);'); // part of the same logic block
|
||||
});
|
||||
|
||||
test('roo.js profile copies .roomodes file via onAddBrandRules', () => {
|
||||
expect(rooProfileContent).toContain('onAddBrandRules(targetDir)');
|
||||
test('roo.js profile copies .roomodes file via onAddRulesProfile', () => {
|
||||
expect(rooProfileContent).toContain('onAddRulesProfile(targetDir)');
|
||||
|
||||
// Check for the specific .roomodes copy logic
|
||||
expect(rooProfileContent).toContain(
|
||||
'fs.copyFileSync(roomodesSrc, roomodesDest);'
|
||||
);
|
||||
expect(rooProfileContent).toContain(
|
||||
"const roomodesSrc = path.join(sourceDir, '.roomodes');"
|
||||
);
|
||||
@@ -48,27 +43,20 @@ describe('Roo Profile Initialization Functionality', () => {
|
||||
"const roomodesDest = path.join(targetDir, '.roomodes');"
|
||||
);
|
||||
expect(rooProfileContent).toContain(
|
||||
"path.resolve(__dirname, '../../assets/roocode')"
|
||||
); // sourceDir for roomodesSrc
|
||||
'fs.copyFileSync(roomodesSrc, roomodesDest);'
|
||||
);
|
||||
});
|
||||
|
||||
test('roo.js profile copies mode-specific rule files via onAddBrandRules', () => {
|
||||
expect(rooProfileContent).toContain('onAddBrandRules(targetDir)');
|
||||
test('roo.js profile copies mode-specific rule files via onAddRulesProfile', () => {
|
||||
expect(rooProfileContent).toContain('onAddRulesProfile(targetDir)');
|
||||
expect(rooProfileContent).toContain('for (const mode of rooModes)');
|
||||
|
||||
// Check for the specific mode rule file copy logic
|
||||
expect(rooProfileContent).toContain('fs.copyFileSync(src, dest);');
|
||||
|
||||
// Check source path construction for mode rules
|
||||
expect(rooProfileContent).toContain(
|
||||
'const src = path.join(rooModesDir, `rules-${mode}`, `${mode}-rules`);'
|
||||
);
|
||||
// Check destination path construction for mode rules
|
||||
expect(rooProfileContent).toContain(
|
||||
"const dest = path.join(targetDir, '.roo', `rules-${mode}`, `${mode}-rules`);"
|
||||
);
|
||||
expect(rooProfileContent).toContain(
|
||||
"const rooModesDir = path.join(sourceDir, '.roo');"
|
||||
); // part of src path
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,42 +1,95 @@
|
||||
import { jest } from '@jest/globals';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
describe('Rules Files Inclusion in Package', () => {
|
||||
test('package.json includes assets/** in the "files" array for rules files', () => {
|
||||
// This test verifies that the required rules files are included in the final package
|
||||
|
||||
test('package.json includes assets/** in the "files" array for rules source files', () => {
|
||||
// Read the package.json file
|
||||
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
|
||||
// Check if assets/** is included in the files array (which contains rules files)
|
||||
expect(packageJson.files).toContain('assets/**');
|
||||
});
|
||||
|
||||
test('all rules files exist in assets/rules directory', () => {
|
||||
test('source rules files exist in assets/rules directory', () => {
|
||||
// Verify that the actual rules files exist
|
||||
const rulesDir = path.join(process.cwd(), 'assets', 'rules');
|
||||
expect(fs.existsSync(rulesDir)).toBe(true);
|
||||
|
||||
// Check for the 4 files that currently exist
|
||||
const expectedFiles = [
|
||||
'ai_providers.mdc',
|
||||
'ai_services.mdc',
|
||||
'architecture.mdc',
|
||||
'changeset.mdc',
|
||||
'commands.mdc',
|
||||
'cursor_rules.mdc',
|
||||
'dependencies.mdc',
|
||||
'dev_workflow.mdc',
|
||||
'glossary.mdc',
|
||||
'mcp.mdc',
|
||||
'new_features.mdc',
|
||||
'self_improve.mdc',
|
||||
'taskmaster.mdc',
|
||||
'tasks.mdc',
|
||||
'tests.mdc',
|
||||
'ui.mdc',
|
||||
'utilities.mdc'
|
||||
'self_improve.mdc',
|
||||
'cursor_rules.mdc'
|
||||
];
|
||||
for (const file of expectedFiles) {
|
||||
expect(fs.existsSync(path.join(rulesDir, file))).toBe(true);
|
||||
|
||||
expectedFiles.forEach((file) => {
|
||||
const filePath = path.join(rulesDir, file);
|
||||
expect(fs.existsSync(filePath)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
test('roo.js profile contains logic for Roo directory creation and file copying', () => {
|
||||
// Read the roo.js profile file
|
||||
const rooJsPath = path.join(process.cwd(), 'scripts', 'profiles', 'roo.js');
|
||||
const rooJsContent = fs.readFileSync(rooJsPath, 'utf8');
|
||||
|
||||
// Check for the main handler function
|
||||
expect(rooJsContent.includes('onAddRulesProfile(targetDir)')).toBe(true);
|
||||
|
||||
// Check for general recursive copy of assets/roocode
|
||||
expect(
|
||||
rooJsContent.includes('copyRecursiveSync(sourceDir, targetDir)')
|
||||
).toBe(true);
|
||||
|
||||
// Check for .roomodes file copying logic (source and destination paths)
|
||||
expect(rooJsContent.includes("path.join(sourceDir, '.roomodes')")).toBe(
|
||||
true
|
||||
);
|
||||
expect(rooJsContent.includes("path.join(targetDir, '.roomodes')")).toBe(
|
||||
true
|
||||
);
|
||||
|
||||
// Check for mode-specific rule file copying logic
|
||||
expect(rooJsContent.includes('for (const mode of rooModes)')).toBe(true);
|
||||
expect(
|
||||
rooJsContent.includes(
|
||||
'path.join(rooModesDir, `rules-${mode}`, `${mode}-rules`)'
|
||||
)
|
||||
).toBe(true);
|
||||
expect(
|
||||
rooJsContent.includes(
|
||||
"path.join(targetDir, '.roo', `rules-${mode}`, `${mode}-rules`)"
|
||||
)
|
||||
).toBe(true);
|
||||
|
||||
// Check for definition of rooModes array and all modes
|
||||
const rooModesArrayRegex = /const rooModes\s*=\s*\[([^\]]+)\]\s*;?/;
|
||||
const rooModesMatch = rooJsContent.match(rooModesArrayRegex);
|
||||
expect(rooModesMatch).not.toBeNull();
|
||||
if (rooModesMatch) {
|
||||
expect(rooModesMatch[1].includes('architect')).toBe(true);
|
||||
expect(rooModesMatch[1].includes('ask')).toBe(true);
|
||||
expect(rooModesMatch[1].includes('boomerang')).toBe(true);
|
||||
expect(rooModesMatch[1].includes('code')).toBe(true);
|
||||
expect(rooModesMatch[1].includes('debug')).toBe(true);
|
||||
expect(rooModesMatch[1].includes('test')).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test('assets/rules directory is not empty', () => {
|
||||
const rulesDir = path.join(process.cwd(), 'assets', 'rules');
|
||||
const files = fs.readdirSync(rulesDir).filter((f) => !f.startsWith('.'));
|
||||
expect(files.length).toBeGreaterThan(0);
|
||||
test('source Roo files exist in assets directory', () => {
|
||||
// Verify that the source files for Roo integration exist
|
||||
expect(
|
||||
fs.existsSync(path.join(process.cwd(), 'assets', 'roocode', '.roo'))
|
||||
).toBe(true);
|
||||
expect(
|
||||
fs.existsSync(path.join(process.cwd(), 'assets', 'roocode', '.roomodes'))
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,8 +14,8 @@ describe('Windsurf Profile Initialization Functionality', () => {
|
||||
windsurfProfileContent = fs.readFileSync(windsurfJsPath, 'utf8');
|
||||
});
|
||||
|
||||
test('windsurf.js exports correct brandName and rulesDir', () => {
|
||||
expect(windsurfProfileContent).toContain("const brandName = 'Windsurf'");
|
||||
test('windsurf.js exports correct profileName and rulesDir', () => {
|
||||
expect(windsurfProfileContent).toContain("const profileName = 'Windsurf'");
|
||||
expect(windsurfProfileContent).toContain(
|
||||
"const rulesDir = '.windsurf/rules'"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user