Merge remote-tracking branch 'origin/main' into ralph/chore/update.from.main
This commit is contained in:
@@ -100,17 +100,13 @@ describe('Roo Files Inclusion in Package', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('source Roo files exist in public/assets directory', () => {
|
||||
test('source Roo files exist in assets directory', () => {
|
||||
// Verify that the source files for Roo integration exist
|
||||
expect(
|
||||
fs.existsSync(
|
||||
path.join(process.cwd(), 'public', 'assets', 'roocode', '.roo')
|
||||
)
|
||||
fs.existsSync(path.join(process.cwd(), 'assets', 'roocode', '.roo'))
|
||||
).toBe(true);
|
||||
expect(
|
||||
fs.existsSync(
|
||||
path.join(process.cwd(), 'public', 'assets', 'roocode', '.roomodes')
|
||||
)
|
||||
fs.existsSync(path.join(process.cwd(), 'assets', 'roocode', '.roomodes'))
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,9 +16,9 @@ describe('Rules Files Inclusion in Package', () => {
|
||||
expect(packageJson.files).toContain('dist/**');
|
||||
});
|
||||
|
||||
test('source rules files exist in public/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(), 'public', 'assets', 'rules');
|
||||
const rulesDir = path.join(process.cwd(), 'assets', 'rules');
|
||||
expect(fs.existsSync(rulesDir)).toBe(true);
|
||||
|
||||
// Check for the 4 files that currently exist
|
||||
@@ -86,17 +86,13 @@ describe('Rules Files Inclusion in Package', () => {
|
||||
expect(rooJsContent.includes('${mode}-rules')).toBe(true);
|
||||
});
|
||||
|
||||
test('source Roo files exist in public/assets directory', () => {
|
||||
test('source Roo files exist in assets directory', () => {
|
||||
// Verify that the source files for Roo integration exist
|
||||
expect(
|
||||
fs.existsSync(
|
||||
path.join(process.cwd(), 'public', 'assets', 'roocode', '.roo')
|
||||
)
|
||||
fs.existsSync(path.join(process.cwd(), 'assets', 'roocode', '.roo'))
|
||||
).toBe(true);
|
||||
expect(
|
||||
fs.existsSync(
|
||||
path.join(process.cwd(), 'public', 'assets', 'roocode', '.roomodes')
|
||||
)
|
||||
fs.existsSync(path.join(process.cwd(), 'assets', 'roocode', '.roomodes'))
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -96,11 +96,10 @@ import {
|
||||
RULES_SETUP_ACTION,
|
||||
RULES_ACTIONS
|
||||
} from '../../src/constants/rules-actions.js';
|
||||
import { compareVersions } from '@tm/cli';
|
||||
|
||||
describe('Commands Module - CLI Setup and Integration', () => {
|
||||
const mockExistsSync = jest.spyOn(fs, 'existsSync');
|
||||
const mockReadFileSync = jest.spyOn(fs, 'readFileSync');
|
||||
const mockJoin = jest.spyOn(path, 'join');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
@@ -115,55 +114,42 @@ describe('Commands Module - CLI Setup and Integration', () => {
|
||||
test('should return Commander program instance', () => {
|
||||
const program = setupCLI();
|
||||
expect(program).toBeDefined();
|
||||
expect(program.name()).toBe('dev');
|
||||
expect(program.name()).toBe('task-master');
|
||||
});
|
||||
|
||||
test('should read version from package.json when available', () => {
|
||||
mockExistsSync.mockReturnValue(true);
|
||||
mockReadFileSync.mockReturnValue('{"version": "1.0.0"}');
|
||||
mockJoin.mockReturnValue('package.json');
|
||||
test('should return version that matches package.json when TM_PUBLIC_VERSION is set', () => {
|
||||
// Read actual version from package.json
|
||||
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
||||
const expectedVersion = packageJson.version;
|
||||
|
||||
// Set environment variable to match package.json
|
||||
const originalEnv = process.env.TM_PUBLIC_VERSION;
|
||||
process.env.TM_PUBLIC_VERSION = expectedVersion;
|
||||
|
||||
const program = setupCLI();
|
||||
const version = program._version();
|
||||
expect(mockReadFileSync).toHaveBeenCalledWith('package.json', 'utf8');
|
||||
expect(version).toBe('1.0.0');
|
||||
const version = program.version();
|
||||
expect(version).toBe(expectedVersion);
|
||||
|
||||
// Restore original environment
|
||||
if (originalEnv !== undefined) {
|
||||
process.env.TM_PUBLIC_VERSION = originalEnv;
|
||||
} else {
|
||||
delete process.env.TM_PUBLIC_VERSION;
|
||||
}
|
||||
});
|
||||
|
||||
test('should use default version when package.json is not available', () => {
|
||||
mockExistsSync.mockReturnValue(false);
|
||||
test('should use default version when TM_PUBLIC_VERSION is not available', () => {
|
||||
const originalEnv = process.env.TM_PUBLIC_VERSION;
|
||||
delete process.env.TM_PUBLIC_VERSION;
|
||||
|
||||
const program = setupCLI();
|
||||
const version = program._version();
|
||||
expect(mockReadFileSync).not.toHaveBeenCalled();
|
||||
expect(version).toBe('unknown');
|
||||
});
|
||||
|
||||
test('should use default version when package.json reading throws an error', () => {
|
||||
mockExistsSync.mockReturnValue(true);
|
||||
mockReadFileSync.mockImplementation(() => {
|
||||
throw new Error('Read error');
|
||||
});
|
||||
|
||||
// Mock console methods to prevent chalk formatting conflicts
|
||||
const consoleErrorSpy = jest
|
||||
.spyOn(console, 'error')
|
||||
.mockImplementation(() => {});
|
||||
const consoleLogSpy = jest
|
||||
.spyOn(console, 'log')
|
||||
.mockImplementation(() => {});
|
||||
const consoleWarnSpy = jest
|
||||
.spyOn(console, 'warn')
|
||||
.mockImplementation(() => {});
|
||||
|
||||
const program = setupCLI();
|
||||
const version = program._version();
|
||||
expect(mockReadFileSync).toHaveBeenCalled();
|
||||
const version = program.version();
|
||||
expect(version).toBe('unknown');
|
||||
|
||||
// Restore console methods
|
||||
consoleErrorSpy.mockRestore();
|
||||
consoleLogSpy.mockRestore();
|
||||
consoleWarnSpy.mockRestore();
|
||||
// Restore original environment
|
||||
if (originalEnv !== undefined) {
|
||||
process.env.TM_PUBLIC_VERSION = originalEnv;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -277,31 +263,6 @@ describe('Commands Module - CLI Setup and Integration', () => {
|
||||
|
||||
// Test utility functions that commands rely on
|
||||
describe('Version comparison utility', () => {
|
||||
let compareVersions;
|
||||
|
||||
beforeAll(async () => {
|
||||
// Import from @tm/cli instead of commands.js
|
||||
const { compareVersions: cv } = await import(
|
||||
'../../apps/cli/src/utils/auto-update.js'
|
||||
);
|
||||
|
||||
// Create a local compareVersions function for testing
|
||||
compareVersions = (v1, v2) => {
|
||||
const v1Parts = v1.split('.').map((p) => parseInt(p, 10));
|
||||
const v2Parts = v2.split('.').map((p) => parseInt(p, 10));
|
||||
|
||||
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
||||
const v1Part = v1Parts[i] || 0;
|
||||
const v2Part = v2Parts[i] || 0;
|
||||
|
||||
if (v1Part < v2Part) return -1;
|
||||
if (v1Part > v2Part) return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
});
|
||||
|
||||
test('compareVersions correctly compares semantic versions', () => {
|
||||
expect(compareVersions('1.0.0', '1.0.0')).toBe(0);
|
||||
expect(compareVersions('1.0.0', '1.0.1')).toBe(-1);
|
||||
|
||||
Reference in New Issue
Block a user