49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Build Assets & Upload to FTP
|
|
* 1. npm install (if needed)
|
|
* 2. npm run build
|
|
* 3. Upload public/ to remote server
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { exec } = require('child_process');
|
|
|
|
const PROJECT_DIR = __dirname;
|
|
const BUILD_DIR = path.join(PROJECT_DIR, 'public');
|
|
|
|
console.log('=== ASSET BUILD & UPLOAD SCRIPT ===\n');
|
|
|
|
// Check if node_modules exists
|
|
if (!fs.existsSync(path.join(PROJECT_DIR, 'node_modules'))) {
|
|
console.log('📦 Installing dependencies...');
|
|
exec('npm install', { cwd: PROJECT_DIR }, (err, stdout, stderr) => {
|
|
if (err) {
|
|
console.error('❌ npm install failed:', err);
|
|
process.exit(1);
|
|
}
|
|
console.log('✅ Dependencies installed\n');
|
|
runBuild();
|
|
});
|
|
} else {
|
|
runBuild();
|
|
}
|
|
|
|
function runBuild() {
|
|
console.log('🔨 Building assets with Vite...');
|
|
exec('npm run build', { cwd: PROJECT_DIR }, (err, stdout, stderr) => {
|
|
if (err) {
|
|
console.error('❌ Build failed:', err);
|
|
process.exit(1);
|
|
}
|
|
console.log(stdout);
|
|
console.log('✅ Assets built successfully!\n');
|
|
console.log('📁 Built files are in:', BUILD_DIR);
|
|
console.log('\n📋 Next steps:');
|
|
console.log('1. Upload public/ folder to remote server via FTP');
|
|
console.log('2. Import tamyhost_E31231762.sql via phpMyAdmin');
|
|
console.log('3. Test site at https://ta.myhost.id/E31231762/\n');
|
|
});
|
|
}
|