|
| 1 | +import { describe, it, expect } from '@jest/globals'; |
| 2 | +import { createRequire } from 'module'; |
| 3 | + |
| 4 | +const require = createRequire(import.meta.url); |
| 5 | + |
| 6 | +describe('CLI version consistency', () => { |
| 7 | + it('should have consistent version across package.json and CLI', () => { |
| 8 | + const packageJson = require('../../package.json'); |
| 9 | + expect(packageJson.version).toBeDefined(); |
| 10 | + expect(typeof packageJson.version).toBe('string'); |
| 11 | + // Version should be a valid semver |
| 12 | + expect(packageJson.version).toMatch(/^\d+\.\d+\.\d+/); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should use the framework version for created projects', async () => { |
| 16 | + // Read the create.ts source to verify it references frameworkPackageJson.version |
| 17 | + const { readFileSync } = await import('fs'); |
| 18 | + const createSource = readFileSync('src/cli/project/create.ts', 'utf-8'); |
| 19 | + |
| 20 | + // Should NOT contain hardcoded mcp-framework version |
| 21 | + expect(createSource).not.toMatch(/'mcp-framework':\s*'\^0\.2\.2'/); |
| 22 | + // Should reference frameworkPackageJson.version dynamically |
| 23 | + expect(createSource).toContain('frameworkPackageJson.version'); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should use dynamic version in CLI program definition', async () => { |
| 27 | + const { readFileSync } = await import('fs'); |
| 28 | + const cliSource = readFileSync('src/cli/index.ts', 'utf-8'); |
| 29 | + |
| 30 | + // Should NOT contain hardcoded version |
| 31 | + expect(cliSource).not.toMatch(/\.version\(['"]0\.2\.\d+['"]\)/); |
| 32 | + // Should reference frameworkPackageJson.version |
| 33 | + expect(cliSource).toContain('frameworkPackageJson.version'); |
| 34 | + }); |
| 35 | +}); |
0 commit comments