chore: typescript fixes and quality of life improvements and formatting
This commit is contained in:
@@ -3,15 +3,13 @@
|
||||
"version": "1.0.0",
|
||||
"description": "Core library for Task Master - TypeScript task management system",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"main": "./dist/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"development": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"types": "./src/index.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
"require": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -196,14 +196,14 @@ export class ConfigManager {
|
||||
* Get the currently active tag
|
||||
*/
|
||||
getActiveTag(): string {
|
||||
return this.stateManager.getActiveTag();
|
||||
return this.stateManager.getCurrentTag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the active tag
|
||||
*/
|
||||
async setActiveTag(tag: string): Promise<void> {
|
||||
await this.stateManager.setActiveTag(tag);
|
||||
await this.stateManager.setCurrentTag(tag);
|
||||
}
|
||||
|
||||
// ==================== Configuration Updates ====================
|
||||
|
||||
@@ -16,7 +16,7 @@ import { DEFAULT_CONFIG_VALUES } from '../../interfaces/configuration.interface.
|
||||
*/
|
||||
export interface RuntimeState {
|
||||
/** Currently active tag */
|
||||
activeTag: string;
|
||||
currentTag: string;
|
||||
/** Last updated timestamp */
|
||||
lastUpdated?: string;
|
||||
/** Additional metadata */
|
||||
@@ -34,7 +34,7 @@ export class RuntimeStateManager {
|
||||
constructor(projectRoot: string) {
|
||||
this.stateFilePath = path.join(projectRoot, '.taskmaster', 'state.json');
|
||||
this.currentState = {
|
||||
activeTag: DEFAULT_CONFIG_VALUES.TAGS.DEFAULT_TAG
|
||||
currentTag: DEFAULT_CONFIG_VALUES.TAGS.DEFAULT_TAG
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,11 +44,21 @@ export class RuntimeStateManager {
|
||||
async loadState(): Promise<RuntimeState> {
|
||||
try {
|
||||
const stateData = await fs.readFile(this.stateFilePath, 'utf-8');
|
||||
const state = JSON.parse(stateData);
|
||||
const rawState = JSON.parse(stateData);
|
||||
|
||||
// Apply environment variable override for active tag
|
||||
// Map legacy field names to current interface
|
||||
const state: RuntimeState = {
|
||||
currentTag:
|
||||
rawState.currentTag ||
|
||||
rawState.activeTag ||
|
||||
DEFAULT_CONFIG_VALUES.TAGS.DEFAULT_TAG,
|
||||
lastUpdated: rawState.lastUpdated,
|
||||
metadata: rawState.metadata
|
||||
};
|
||||
|
||||
// Apply environment variable override for current tag
|
||||
if (process.env.TASKMASTER_TAG) {
|
||||
state.activeTag = process.env.TASKMASTER_TAG;
|
||||
state.currentTag = process.env.TASKMASTER_TAG;
|
||||
}
|
||||
|
||||
this.currentState = state;
|
||||
@@ -60,7 +70,7 @@ export class RuntimeStateManager {
|
||||
|
||||
// Check environment variable
|
||||
if (process.env.TASKMASTER_TAG) {
|
||||
this.currentState.activeTag = process.env.TASKMASTER_TAG;
|
||||
this.currentState.currentTag = process.env.TASKMASTER_TAG;
|
||||
}
|
||||
|
||||
return this.currentState;
|
||||
@@ -103,15 +113,15 @@ export class RuntimeStateManager {
|
||||
/**
|
||||
* Get the currently active tag
|
||||
*/
|
||||
getActiveTag(): string {
|
||||
return this.currentState.activeTag;
|
||||
getCurrentTag(): string {
|
||||
return this.currentState.currentTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the active tag
|
||||
* Set the current tag
|
||||
*/
|
||||
async setActiveTag(tag: string): Promise<void> {
|
||||
this.currentState.activeTag = tag;
|
||||
async setCurrentTag(tag: string): Promise<void> {
|
||||
this.currentState.currentTag = tag;
|
||||
await this.saveState();
|
||||
}
|
||||
|
||||
@@ -145,7 +155,7 @@ export class RuntimeStateManager {
|
||||
}
|
||||
}
|
||||
this.currentState = {
|
||||
activeTag: DEFAULT_CONFIG_VALUES.TAGS.DEFAULT_TAG
|
||||
currentTag: DEFAULT_CONFIG_VALUES.TAGS.DEFAULT_TAG
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,15 +128,16 @@ export class FileStorage implements IStorage {
|
||||
await this.ensureDirectoryExists();
|
||||
|
||||
// Normalize task IDs to strings (force string IDs everywhere)
|
||||
const normalizedTasks = tasks.map(task => ({
|
||||
const normalizedTasks = tasks.map((task) => ({
|
||||
...task,
|
||||
id: String(task.id), // Force ID to string
|
||||
dependencies: task.dependencies?.map(dep => String(dep)) || [],
|
||||
subtasks: task.subtasks?.map(subtask => ({
|
||||
...subtask,
|
||||
id: String(subtask.id),
|
||||
parentId: String(subtask.parentId)
|
||||
})) || []
|
||||
dependencies: task.dependencies?.map((dep) => String(dep)) || [],
|
||||
subtasks:
|
||||
task.subtasks?.map((subtask) => ({
|
||||
...subtask,
|
||||
id: String(subtask.id),
|
||||
parentId: String(subtask.parentId)
|
||||
})) || []
|
||||
}));
|
||||
|
||||
// Check if we need to use legacy format
|
||||
@@ -157,7 +158,8 @@ export class FileStorage implements IStorage {
|
||||
version: '1.0.0',
|
||||
lastModified: new Date().toISOString(),
|
||||
taskCount: normalizedTasks.length,
|
||||
completedCount: normalizedTasks.filter((t) => t.status === 'done').length,
|
||||
completedCount: normalizedTasks.filter((t) => t.status === 'done')
|
||||
.length,
|
||||
tags: [resolvedTag]
|
||||
}
|
||||
}
|
||||
@@ -170,7 +172,8 @@ export class FileStorage implements IStorage {
|
||||
version: '1.0.0',
|
||||
lastModified: new Date().toISOString(),
|
||||
taskCount: normalizedTasks.length,
|
||||
completedCount: normalizedTasks.filter((t) => t.status === 'done').length,
|
||||
completedCount: normalizedTasks.filter((t) => t.status === 'done')
|
||||
.length,
|
||||
tags: tag ? [tag] : []
|
||||
}
|
||||
};
|
||||
@@ -183,7 +186,8 @@ export class FileStorage implements IStorage {
|
||||
version: '1.0.0',
|
||||
lastModified: new Date().toISOString(),
|
||||
taskCount: normalizedTasks.length,
|
||||
completedCount: normalizedTasks.filter((t) => t.status === 'done').length,
|
||||
completedCount: normalizedTasks.filter((t) => t.status === 'done')
|
||||
.length,
|
||||
tags: tag ? [tag] : []
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user