Compare commits

..

2 Commits

Author SHA1 Message Date
Ralph Khreish
455cd1ca3a fix: resolve release issue 2025-09-22 22:15:47 +02:00
Ralph Khreish
f8ede8886a chore: fix CI failing to release 2025-09-22 21:33:12 +02:00
98 changed files with 170 additions and 170 deletions

View File

@@ -0,0 +1,5 @@
---
"task-master-ai": patch
---
Fix module not found for new 0.27.0 release

View File

@@ -1,26 +1,5 @@
# task-master-ai # task-master-ai
## 0.27.1
### Patch Changes
- [#1232](https://github.com/eyaltoledano/claude-task-master/pull/1232) [`f487736`](https://github.com/eyaltoledano/claude-task-master/commit/f487736670ef8c484059f676293777eabb249c9e) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - Fix module not found for new 0.27.0 release
- [#1233](https://github.com/eyaltoledano/claude-task-master/pull/1233) [`c911608`](https://github.com/eyaltoledano/claude-task-master/commit/c911608f60454253f4e024b57ca84e5a5a53f65c) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - Fix Zed MCP configuration by adding required "source" property
- Add "source": "custom" property to task-master-ai server in Zed settings.json
## 0.27.1-rc.1
### Patch Changes
- [#1233](https://github.com/eyaltoledano/claude-task-master/pull/1233) [`1a18794`](https://github.com/eyaltoledano/claude-task-master/commit/1a1879483b86c118a4e46c02cbf4acebfcf6bcf9) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - One last testing final final
## 0.27.1-rc.0
### Patch Changes
- [#1232](https://github.com/eyaltoledano/claude-task-master/pull/1232) [`f487736`](https://github.com/eyaltoledano/claude-task-master/commit/f487736670ef8c484059f676293777eabb249c9e) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - Fix module not found for new 0.27.0 release
## 0.27.0 ## 0.27.0
### Minor Changes ### Minor Changes

View File

@@ -1,12 +1,5 @@
# @tm/cli # @tm/cli
## null
### Patch Changes
- Updated dependencies []:
- @tm/core@null
## 0.27.0 ## 0.27.0
### Patch Changes ### Patch Changes

View File

@@ -18,8 +18,7 @@ export * as ui from './utils/ui.js';
export { export {
checkForUpdate, checkForUpdate,
performAutoUpdate, performAutoUpdate,
displayUpgradeNotification, displayUpgradeNotification
compareVersions
} from './utils/auto-update.js'; } from './utils/auto-update.js';
// Re-export commonly used types from tm-core // Re-export commonly used types from tm-core

View File

@@ -7,6 +7,7 @@ import https from 'https';
import chalk from 'chalk'; import chalk from 'chalk';
import ora from 'ora'; import ora from 'ora';
import boxen from 'boxen'; import boxen from 'boxen';
import packageJson from '../../../../package.json' with { type: 'json' };
export interface UpdateInfo { export interface UpdateInfo {
currentVersion: string; currentVersion: string;
@@ -15,18 +16,15 @@ export interface UpdateInfo {
} }
/** /**
* Get current version from build-time injected environment variable * Get current version from package.json
*/ */
function getCurrentVersion(): string { function getCurrentVersion(): string {
// Version is injected at build time via TM_PUBLIC_VERSION try {
const version = process.env.TM_PUBLIC_VERSION; return packageJson.version;
if (version && version !== 'unknown') { } catch (error) {
return version; console.warn('Could not read package.json for version info');
}
// Fallback for development or if injection failed
console.warn('Could not read version from TM_PUBLIC_VERSION, using fallback');
return '0.0.0'; return '0.0.0';
}
} }
/** /**
@@ -35,7 +33,7 @@ function getCurrentVersion(): string {
* @param v2 - Second version * @param v2 - Second version
* @returns -1 if v1 < v2, 0 if v1 = v2, 1 if v1 > v2 * @returns -1 if v1 < v2, 0 if v1 = v2, 1 if v1 > v2
*/ */
export function compareVersions(v1: string, v2: string): number { function compareVersions(v1: string, v2: string): number {
const toParts = (v: string) => { const toParts = (v: string) => {
const [core, pre = ''] = v.split('-', 2); const [core, pre = ''] = v.split('-', 2);
const nums = core.split('.').map((n) => Number.parseInt(n, 10) || 0); const nums = core.split('.').map((n) => Number.parseInt(n, 10) || 0);

View File

@@ -1,7 +1,5 @@
# docs # docs
## 0.0.4
## 0.0.3 ## 0.0.3
## 0.0.2 ## 0.0.2

View File

@@ -1,6 +1,6 @@
{ {
"name": "docs", "name": "docs",
"version": "0.0.4", "version": "0.0.3",
"private": true, "private": true,
"description": "Task Master documentation powered by Mintlify", "description": "Task Master documentation powered by Mintlify",
"scripts": { "scripts": {

View File

@@ -1,26 +1,5 @@
# Change Log # Change Log
## 0.25.2
### Patch Changes
- Updated dependencies [[`f487736`](https://github.com/eyaltoledano/claude-task-master/commit/f487736670ef8c484059f676293777eabb249c9e), [`c911608`](https://github.com/eyaltoledano/claude-task-master/commit/c911608f60454253f4e024b57ca84e5a5a53f65c), [`1a18794`](https://github.com/eyaltoledano/claude-task-master/commit/1a1879483b86c118a4e46c02cbf4acebfcf6bcf9)]:
- task-master-ai@0.27.1
## 0.25.2-rc.1
### Patch Changes
- Updated dependencies [[`1a18794`](https://github.com/eyaltoledano/claude-task-master/commit/1a1879483b86c118a4e46c02cbf4acebfcf6bcf9)]:
- task-master-ai@0.27.1-rc.1
## 0.25.2-rc.0
### Patch Changes
- Updated dependencies [[`f487736`](https://github.com/eyaltoledano/claude-task-master/commit/f487736670ef8c484059f676293777eabb249c9e)]:
- task-master-ai@0.27.1-rc.0
## 0.25.0 ## 0.25.0
### Minor Changes ### Minor Changes

View File

@@ -3,7 +3,7 @@
"private": true, "private": true,
"displayName": "TaskMaster", "displayName": "TaskMaster",
"description": "A visual Kanban board interface for TaskMaster projects in VS Code", "description": "A visual Kanban board interface for TaskMaster projects in VS Code",
"version": "0.25.2", "version": "0.25.1",
"publisher": "Hamster", "publisher": "Hamster",
"icon": "assets/icon.png", "icon": "assets/icon.png",
"engines": { "engines": {
@@ -240,7 +240,7 @@
"check-types": "tsc --noEmit" "check-types": "tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"task-master-ai": "0.27.1" "task-master-ai": "*"
}, },
"devDependencies": { "devDependencies": {
"@dnd-kit/core": "^6.3.1", "@dnd-kit/core": "^6.3.1",

55
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "task-master-ai", "name": "task-master-ai",
"version": "0.27.1", "version": "0.27.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "task-master-ai", "name": "task-master-ai",
"version": "0.27.1", "version": "0.27.0",
"license": "MIT WITH Commons-Clause", "license": "MIT WITH Commons-Clause",
"workspaces": [ "workspaces": [
"apps/*", "apps/*",
@@ -29,7 +29,7 @@
"@inquirer/search": "^3.0.15", "@inquirer/search": "^3.0.15",
"@openrouter/ai-sdk-provider": "^0.4.5", "@openrouter/ai-sdk-provider": "^0.4.5",
"@streamparser/json": "^0.0.22", "@streamparser/json": "^0.0.22",
"@supabase/supabase-js": "^2.57.4", "@supabase/supabase-js": "^2.48.0",
"ai": "^4.3.10", "ai": "^4.3.10",
"ajv": "^8.17.1", "ajv": "^8.17.1",
"ajv-formats": "^3.0.1", "ajv-formats": "^3.0.1",
@@ -38,7 +38,7 @@
"cli-highlight": "^2.1.11", "cli-highlight": "^2.1.11",
"cli-progress": "^3.12.0", "cli-progress": "^3.12.0",
"cli-table3": "^0.6.5", "cli-table3": "^0.6.5",
"commander": "^12.1.0", "commander": "^11.1.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"express": "^4.21.2", "express": "^4.21.2",
@@ -86,9 +86,9 @@
"supertest": "^7.1.0", "supertest": "^7.1.0",
"ts-jest": "^29.4.2", "ts-jest": "^29.4.2",
"tsdown": "^0.15.2", "tsdown": "^0.15.2",
"tsx": "^4.20.4", "tsx": "^4.16.2",
"turbo": "^2.5.6", "turbo": "^2.5.6",
"typescript": "^5.7.3" "typescript": "^5.9.2"
}, },
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"
@@ -104,12 +104,12 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@tm/core": "*", "@tm/core": "*",
"boxen": "^8.0.1", "boxen": "^7.1.1",
"chalk": "5.6.2", "chalk": "5.6.2",
"cli-table3": "^0.6.5", "cli-table3": "^0.6.5",
"commander": "^12.1.0", "commander": "^12.1.0",
"inquirer": "^12.5.0", "inquirer": "^9.2.10",
"ora": "^8.2.0" "ora": "^8.1.0"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^1.9.4", "@biomejs/biome": "^1.9.4",
@@ -190,6 +190,15 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"license": "MIT" "license": "MIT"
}, },
"apps/cli/node_modules/commander": {
"version": "12.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
"integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"apps/cli/node_modules/emoji-regex": { "apps/cli/node_modules/emoji-regex": {
"version": "8.0.0", "version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
@@ -351,15 +360,15 @@
} }
}, },
"apps/docs": { "apps/docs": {
"version": "0.0.4", "version": "0.0.3",
"devDependencies": { "devDependencies": {
"mintlify": "^4.2.111" "mintlify": "^4.2.111"
} }
}, },
"apps/extension": { "apps/extension": {
"version": "0.25.2", "version": "0.25.1",
"dependencies": { "dependencies": {
"task-master-ai": "0.27.1" "task-master-ai": "*"
}, },
"devDependencies": { "devDependencies": {
"@dnd-kit/core": "^6.3.1", "@dnd-kit/core": "^6.3.1",
@@ -375,7 +384,7 @@
"@tailwindcss/postcss": "^4.1.11", "@tailwindcss/postcss": "^4.1.11",
"@tanstack/react-query": "^5.83.0", "@tanstack/react-query": "^5.83.0",
"@types/mocha": "^10.0.10", "@types/mocha": "^10.0.10",
"@types/node": "^22.10.5", "@types/node": "20.x",
"@types/react": "19.1.8", "@types/react": "19.1.8",
"@types/react-dom": "19.1.6", "@types/react-dom": "19.1.6",
"@types/vscode": "^1.101.0", "@types/vscode": "^1.101.0",
@@ -395,7 +404,7 @@
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"tailwind-merge": "^3.3.1", "tailwind-merge": "^3.3.1",
"tailwindcss": "4.1.11", "tailwindcss": "4.1.11",
"typescript": "^5.7.3" "typescript": "^5.8.3"
}, },
"engines": { "engines": {
"vscode": "^1.93.0" "vscode": "^1.93.0"
@@ -14304,12 +14313,12 @@
} }
}, },
"node_modules/commander": { "node_modules/commander": {
"version": "12.1.0", "version": "11.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
"integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=18" "node": ">=16"
} }
}, },
"node_modules/component-emitter": { "node_modules/component-emitter": {
@@ -32169,18 +32178,18 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@supabase/supabase-js": "^2.57.4", "@supabase/supabase-js": "^2.57.4",
"zod": "^3.23.8" "zod": "^3.22.4"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^1.9.4", "@biomejs/biome": "^1.9.4",
"@tm/build-config": "*", "@tm/build-config": "*",
"@types/node": "^22.10.5", "@types/node": "^20.11.30",
"@vitest/coverage-v8": "^2.0.5", "@vitest/coverage-v8": "^2.0.5",
"dotenv-mono": "^1.5.1", "dotenv-mono": "^1.3.14",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"tsup": "^8.5.0", "tsup": "^8.5.0",
"typescript": "^5.7.3", "typescript": "^5.4.3",
"vitest": "^2.1.8" "vitest": "^2.0.5"
}, },
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"

View File

@@ -1,6 +1,6 @@
{ {
"name": "task-master-ai", "name": "task-master-ai",
"version": "0.27.1", "version": "0.27.0",
"description": "A task management system for ambitious AI-driven development that doesn't overwhelm and confuse Cursor.", "description": "A task management system for ambitious AI-driven development that doesn't overwhelm and confuse Cursor.",
"main": "index.js", "main": "index.js",
"type": "module", "type": "module",

View File

@@ -1,5 +1,3 @@
# @tm/build-config # @tm/build-config
## null
## 1.0.1 ## 1.0.1

View File

@@ -1,7 +1,5 @@
# Changelog # Changelog
## null
## 0.26.1 ## 0.26.1
All notable changes to the @task-master/tm-core package will be documented in this file. All notable changes to the @task-master/tm-core package will be documented in this file.

View File

@@ -16,6 +16,8 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import readline from 'readline'; import readline from 'readline';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import chalk from 'chalk'; import chalk from 'chalk';
import figlet from 'figlet'; import figlet from 'figlet';
import boxen from 'boxen'; import boxen from 'boxen';
@@ -47,6 +49,9 @@ import {
GITIGNORE_FILE GITIGNORE_FILE
} from '../src/constants/paths.js'; } from '../src/constants/paths.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Define log levels // Define log levels
const LOG_LEVELS = { const LOG_LEVELS = {
debug: 0, debug: 0,
@@ -614,7 +619,13 @@ function createProjectStructure(
// Copy .gitignore with GitTasks preference // Copy .gitignore with GitTasks preference
try { try {
const templateContent = readAsset('gitignore', 'utf8'); const gitignoreTemplatePath = path.join(
__dirname,
'..',
'assets',
'gitignore'
);
const templateContent = fs.readFileSync(gitignoreTemplatePath, 'utf8');
manageGitignoreFile( manageGitignoreFile(
path.join(targetDir, GITIGNORE_FILE), path.join(targetDir, GITIGNORE_FILE),
templateContent, templateContent,

View File

@@ -3,7 +3,7 @@
* Command-line interface for the Task Master CLI * Command-line interface for the Task Master CLI
*/ */
import { Command } from 'commander'; import { program } from 'commander';
import path from 'path'; import path from 'path';
import chalk from 'chalk'; import chalk from 'chalk';
import boxen from 'boxen'; import boxen from 'boxen';
@@ -5076,10 +5076,28 @@ Examples:
*/ */
function setupCLI() { function setupCLI() {
// Create a new program instance // Create a new program instance
const programInstance = new Command() const programInstance = program
.name('task-master') .name('dev')
.description('AI-driven development task management') .description('AI-driven development task management')
.version(process.env.TM_PUBLIC_VERSION || 'unknown') .version(() => {
// Read version directly from package.json ONLY
try {
const packageJsonPath = path.join(process.cwd(), 'package.json');
if (fs.existsSync(packageJsonPath)) {
const packageJson = JSON.parse(
fs.readFileSync(packageJsonPath, 'utf8')
);
return packageJson.version;
}
} catch (error) {
// Silently fall back to 'unknown'
log(
'warn',
'Could not read package.json for version info in .version()'
);
}
return 'unknown'; // Default fallback if package.json fails
})
.helpOption('-h, --help', 'Display help') .helpOption('-h, --help', 'Display help')
.addHelpCommand(false); // Disable default help command .addHelpCommand(false); // Disable default help command
@@ -5108,9 +5126,8 @@ function setupCLI() {
*/ */
async function runCLI(argv = process.argv) { async function runCLI(argv = process.argv) {
try { try {
// Display banner if not in a pipe (except for init command which has its own banner) // Display banner if not in a pipe
const isInitCommand = argv.includes('init'); if (process.stdout.isTTY) {
if (process.stdout.isTTY && !isInitCommand) {
displayBanner(); displayBanner();
} }

View File

@@ -142,14 +142,6 @@ function onPostConvertRulesProfile(targetDir, assetsDir) {
// Transform to Zed format // Transform to Zed format
const zedConfig = transformToZedFormat(mcpConfig); const zedConfig = transformToZedFormat(mcpConfig);
// Add "source": "custom" to task-master-ai server for Zed
if (
zedConfig['context_servers'] &&
zedConfig['context_servers']['task-master-ai']
) {
zedConfig['context_servers']['task-master-ai'].source = 'custom';
}
// Write back the transformed config with proper formatting // Write back the transformed config with proper formatting
fs.writeFileSync( fs.writeFileSync(
mcpConfigPath, mcpConfigPath,

View File

@@ -463,17 +463,6 @@ export function findConfigPath(explicitPath = null, args = null, log = null) {
} }
} }
// Only warn once per command execution to prevent spam during init
const warningKey = `config_warning_${projectRoot}`;
if (!global._tmConfigWarningsThisRun) {
global._tmConfigWarningsThisRun = new Set();
}
if (!global._tmConfigWarningsThisRun.has(warningKey)) {
global._tmConfigWarningsThisRun.add(warningKey);
logger.warn?.(`No configuration file found in project: ${projectRoot}`); logger.warn?.(`No configuration file found in project: ${projectRoot}`);
}
return null; return null;
} }

View File

@@ -100,13 +100,17 @@ describe('Roo Files Inclusion in Package', () => {
}); });
}); });
test('source Roo files exist in assets directory', () => { test('source Roo files exist in public/assets directory', () => {
// Verify that the source files for Roo integration exist // Verify that the source files for Roo integration exist
expect( expect(
fs.existsSync(path.join(process.cwd(), 'assets', 'roocode', '.roo')) fs.existsSync(
path.join(process.cwd(), 'public', 'assets', 'roocode', '.roo')
)
).toBe(true); ).toBe(true);
expect( expect(
fs.existsSync(path.join(process.cwd(), 'assets', 'roocode', '.roomodes')) fs.existsSync(
path.join(process.cwd(), 'public', 'assets', 'roocode', '.roomodes')
)
).toBe(true); ).toBe(true);
}); });
}); });

View File

@@ -16,9 +16,9 @@ describe('Rules Files Inclusion in Package', () => {
expect(packageJson.files).toContain('dist/**'); expect(packageJson.files).toContain('dist/**');
}); });
test('source rules files exist in assets/rules directory', () => { test('source rules files exist in public/assets/rules directory', () => {
// Verify that the actual rules files exist // Verify that the actual rules files exist
const rulesDir = path.join(process.cwd(), 'assets', 'rules'); const rulesDir = path.join(process.cwd(), 'public', 'assets', 'rules');
expect(fs.existsSync(rulesDir)).toBe(true); expect(fs.existsSync(rulesDir)).toBe(true);
// Check for the 4 files that currently exist // Check for the 4 files that currently exist
@@ -86,13 +86,17 @@ describe('Rules Files Inclusion in Package', () => {
expect(rooJsContent.includes('${mode}-rules')).toBe(true); expect(rooJsContent.includes('${mode}-rules')).toBe(true);
}); });
test('source Roo files exist in assets directory', () => { test('source Roo files exist in public/assets directory', () => {
// Verify that the source files for Roo integration exist // Verify that the source files for Roo integration exist
expect( expect(
fs.existsSync(path.join(process.cwd(), 'assets', 'roocode', '.roo')) fs.existsSync(
path.join(process.cwd(), 'public', 'assets', 'roocode', '.roo')
)
).toBe(true); ).toBe(true);
expect( expect(
fs.existsSync(path.join(process.cwd(), 'assets', 'roocode', '.roomodes')) fs.existsSync(
path.join(process.cwd(), 'public', 'assets', 'roocode', '.roomodes')
)
).toBe(true); ).toBe(true);
}); });
}); });

View File

@@ -96,10 +96,11 @@ import {
RULES_SETUP_ACTION, RULES_SETUP_ACTION,
RULES_ACTIONS RULES_ACTIONS
} from '../../src/constants/rules-actions.js'; } from '../../src/constants/rules-actions.js';
import { compareVersions } from '@tm/cli';
describe('Commands Module - CLI Setup and Integration', () => { describe('Commands Module - CLI Setup and Integration', () => {
const mockExistsSync = jest.spyOn(fs, 'existsSync'); const mockExistsSync = jest.spyOn(fs, 'existsSync');
const mockReadFileSync = jest.spyOn(fs, 'readFileSync');
const mockJoin = jest.spyOn(path, 'join');
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
@@ -114,42 +115,55 @@ describe('Commands Module - CLI Setup and Integration', () => {
test('should return Commander program instance', () => { test('should return Commander program instance', () => {
const program = setupCLI(); const program = setupCLI();
expect(program).toBeDefined(); expect(program).toBeDefined();
expect(program.name()).toBe('task-master'); expect(program.name()).toBe('dev');
}); });
test('should return version that matches package.json when TM_PUBLIC_VERSION is set', () => { test('should read version from package.json when available', () => {
// Read actual version from package.json mockExistsSync.mockReturnValue(true);
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8')); mockReadFileSync.mockReturnValue('{"version": "1.0.0"}');
const expectedVersion = packageJson.version; mockJoin.mockReturnValue('package.json');
// Set environment variable to match package.json
const originalEnv = process.env.TM_PUBLIC_VERSION;
process.env.TM_PUBLIC_VERSION = expectedVersion;
const program = setupCLI(); const program = setupCLI();
const version = program.version(); const version = program._version();
expect(version).toBe(expectedVersion); expect(mockReadFileSync).toHaveBeenCalledWith('package.json', 'utf8');
expect(version).toBe('1.0.0');
// 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 TM_PUBLIC_VERSION is not available', () => { test('should use default version when package.json is not available', () => {
const originalEnv = process.env.TM_PUBLIC_VERSION; mockExistsSync.mockReturnValue(false);
delete process.env.TM_PUBLIC_VERSION;
const program = setupCLI(); const program = setupCLI();
const version = program.version(); 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();
expect(version).toBe('unknown'); expect(version).toBe('unknown');
// Restore original environment // Restore console methods
if (originalEnv !== undefined) { consoleErrorSpy.mockRestore();
process.env.TM_PUBLIC_VERSION = originalEnv; consoleLogSpy.mockRestore();
} consoleWarnSpy.mockRestore();
}); });
}); });
@@ -263,6 +277,31 @@ describe('Commands Module - CLI Setup and Integration', () => {
// Test utility functions that commands rely on // Test utility functions that commands rely on
describe('Version comparison utility', () => { 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', () => { test('compareVersions correctly compares semantic versions', () => {
expect(compareVersions('1.0.0', '1.0.0')).toBe(0); expect(compareVersions('1.0.0', '1.0.0')).toBe(0);
expect(compareVersions('1.0.0', '1.0.1')).toBe(-1); expect(compareVersions('1.0.0', '1.0.1')).toBe(-1);

View File

@@ -7,18 +7,6 @@ dotenvLoad();
// Get all TM_PUBLIC_* env variables for build-time injection // Get all TM_PUBLIC_* env variables for build-time injection
const getBuildTimeEnvs = () => { const getBuildTimeEnvs = () => {
const envs: Record<string, string> = {}; const envs: Record<string, string> = {};
// Inject package.json version at build time
try {
const packageJson = JSON.parse(
require('fs').readFileSync('package.json', 'utf8')
);
envs['TM_PUBLIC_VERSION'] = packageJson.version || 'unknown';
} catch (error) {
console.warn('Could not read package.json version during build:', error);
envs['TM_PUBLIC_VERSION'] = 'unknown';
}
for (const [key, value] of Object.entries(process.env)) { for (const [key, value] of Object.entries(process.env)) {
if (key.startsWith('TM_PUBLIC_')) { if (key.startsWith('TM_PUBLIC_')) {
// Return the actual value, not JSON.stringify'd // Return the actual value, not JSON.stringify'd
@@ -35,7 +23,7 @@ export default defineConfig(
'mcp-server': 'mcp-server/server.js' 'mcp-server': 'mcp-server/server.js'
}, },
outDir: 'dist', outDir: 'dist',
copy: ['assets'], copy: ['public'],
ignoreWatch: ['node_modules', 'dist', 'tests', 'apps/extension'], ignoreWatch: ['node_modules', 'dist', 'tests', 'apps/extension'],
// Bundle only our workspace packages, keep npm dependencies external // Bundle only our workspace packages, keep npm dependencies external
noExternal: [/^@tm\//], noExternal: [/^@tm\//],