An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.
JavaScript aicursorcursor-aicursorailovablelovable-devroocodetask-managertaskstasks-listwindsurfwindsurf-ai
refactor: implement DRY approach for template files
Eyal Toledano163f47260ad6
diff --git a/package.json b/package.jsonindex b6ca96ee..cbdd81ad 100644--- a/package.json+++ b/package.json@@ -9,7 +9,8 @@},"scripts": {"test": "echo \"Error: no test specified\" && exit 1",- "prepare-package": "node scripts/prepare-package.js"+ "prepare-package": "node scripts/prepare-package.js",+ "prepublishOnly": "npm run prepare-package"},"keywords": ["claude",diff --git a/scripts/prepare-package.js b/scripts/prepare-package.jsindex 86a9aa50..8967f29c 100755--- a/scripts/prepare-package.js+++ b/scripts/prepare-package.js@@ -56,11 +56,57 @@ function ensureExecutable(filePath) {return true;}+// Function to sync files from source to templates+function syncTemplateFiles() {+ // Define files to sync in format: [source, target]+ const filesToSync = [+ // Scripts+ ['scripts/dev.js', 'templates/dev.js'],++ // Documentation files+ ['README.md', 'templates/README.md'],+ ['scripts/README.md', 'templates/scripts_README.md'],++ // Other files that might need syncing+ // Add more files here as needed+ ];++ let allSynced = true;+ const rootDir = path.join(__dirname, '..');++ for (const [source, target] of filesToSync) {+ const sourcePath = path.join(rootDir, source);+ const targetPath = path.join(rootDir, target);++ try {+ if (fileExists(sourcePath)) {+ log('info', `Syncing ${source} to ${target}...`);+ fs.copyFileSync(sourcePath, targetPath);+ log('success', `Successfully synced ${source} to ${target}`);+ } else {+ log('error', `Source file ${source} does not exist`);+ allSynced = false;+ }+ } catch (error) {+ log('error', `Failed to sync ${source} to ${target}:`, error.message);+ allSynced = false;+ }+ }++ return allSynced;+}+// Main function to prepare the packagefunction preparePackage() {const rootDir = path.join(__dirname, '..');log('info', `Preparing package in ${rootDir}`);+ // Sync template files to ensure templates have the latest versions+ log('info', 'Syncing template files...');+ if (!syncTemplateFiles()) {+ log('warn', 'Some template files could not be synced. Continuing with preparation...');+ }+// Check for required filesconst requiredFiles = ['package.json',