feat: implement @repo/brand package for centralized asset management and automated distribution to consuming apps
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
// Resolve the source directory (packages/brand/public)
|
||||
const brandPublicDir = path.resolve(__dirname, '../public');
|
||||
|
||||
// Resolve the destination directory (public/brand folder in the calling app)
|
||||
// process.cwd() points to the app folder (e.g., apps/web) when the script is executed
|
||||
const destDir = path.resolve(process.cwd(), 'public', 'brand');
|
||||
|
||||
// Ensure the destination folder exists
|
||||
if (!fs.existsSync(destDir)) {
|
||||
fs.mkdirSync(destDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Copy files using fs.cpSync (Available in Node.js 16.7+)
|
||||
try {
|
||||
fs.cpSync(brandPublicDir, destDir, {
|
||||
recursive: true,
|
||||
force: true, // Overwrite files if they already exist
|
||||
filter: (src) => {
|
||||
const filename = path.basename(src);
|
||||
// Exclude unwanted files
|
||||
return !['.gitkeep', 'README.md'].includes(filename);
|
||||
},
|
||||
});
|
||||
console.log(`✓ Brand assets successfully copied to ${destDir}`);
|
||||
} catch (error) {
|
||||
console.error(`❌ Failed to copy brand assets:`, error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user