feat: create tm-core and apps/cli (#1093)

- add typescript
- add npm workspaces
This commit is contained in:
Ralph Khreish
2025-09-01 21:44:43 +02:00
parent e81040def5
commit dc811eb45e
162 changed files with 22235 additions and 706 deletions

View File

@@ -32,6 +32,9 @@ import {
} from '../src/utils/rule-transformer.js';
import { updateConfigMaxTokens } from './modules/update-config-tokens.js';
// Import asset resolver
import { assetExists, readAsset } from '../src/utils/asset-resolver.js';
import { execSync } from 'child_process';
import {
EXAMPLE_PRD_FILE,
@@ -222,32 +225,14 @@ function createInitialStateFile(targetDir) {
// Function to copy a file from the package to the target directory
function copyTemplateFile(templateName, targetPath, replacements = {}) {
// Get the file content from the appropriate source directory
let sourcePath;
// Map template names to their actual source paths
switch (templateName) {
// case 'scripts_README.md':
// sourcePath = path.join(__dirname, '..', 'assets', 'scripts_README.md');
// break;
// case 'README-task-master.md':
// sourcePath = path.join(__dirname, '..', 'README-task-master.md');
// break;
default:
// For other files like env.example, gitignore, etc. that don't have direct equivalents
sourcePath = path.join(__dirname, '..', 'assets', templateName);
// Check if the asset exists
if (!assetExists(templateName)) {
log('error', `Source file not found: ${templateName}`);
return;
}
// Check if the source file exists
if (!fs.existsSync(sourcePath)) {
// Fall back to templates directory for files that might not have been moved yet
sourcePath = path.join(__dirname, '..', 'assets', templateName);
if (!fs.existsSync(sourcePath)) {
log('error', `Source file not found: ${sourcePath}`);
return;
}
}
let content = fs.readFileSync(sourcePath, 'utf8');
// Read the asset content using the resolver
let content = readAsset(templateName, 'utf8');
// Replace placeholders with actual values
Object.entries(replacements).forEach(([key, value]) => {