@eventcatalogtest/studio
Version:
A drag and drop UI for distributed systems that keeps your diagrams where they belong – in your repo
48 lines (38 loc) • 1.28 kB
JavaScript
import fs from 'fs/promises';
import path from 'path';
import fg from 'fast-glob';
async function copyTemplates() {
try {
const sourceDir = path.join(process.cwd(), 'templates');
const buildDir = path.join(process.cwd(), '.next', 'templates');
// Find all .ectemplate files
const templateFiles = await fg(['**/*.ectemplate'], {
cwd: sourceDir,
absolute: true,
});
if (templateFiles.length === 0) {
console.log('No .ectemplate files found to copy');
return;
}
// Ensure the build templates directory exists
await fs.mkdir(buildDir, { recursive: true });
// Copy each template file
for (const sourceFile of templateFiles) {
const fileName = path.basename(sourceFile);
const destFile = path.join(buildDir, fileName);
try {
await fs.copyFile(sourceFile, destFile);
console.log(`Copied template: ${fileName}`);
} catch (error) {
console.error(`Error copying ${fileName}:`, error);
}
}
console.log(`Successfully copied ${templateFiles.length} template files to build directory`);
} catch (error) {
console.error('Error copying templates:', error);
process.exit(1);
}
}
// Run the script
copyTemplates();