🎨 Clean up code formatting and improve readability in deployment script

This commit is contained in:
2026-01-28 05:24:11 +00:00
parent 2206191fd9
commit 02c5a9a9c1

View File

@@ -217,30 +217,30 @@ async function deploy() {
console.log('\n🔨 Building Vue 3 application...');
console.log(` Source: ${SOURCE_DIR}`);
console.log(` Output: ${DIST_DIR}`);
const { execSync } = await import('child_process');
try {
// Check if node_modules exists
if (!fs.existsSync(path.join(SOURCE_DIR, 'node_modules'))) {
console.log(' 📦 Installing dependencies...');
execSync('npm install', {
cwd: SOURCE_DIR,
stdio: 'inherit'
execSync('npm install', {
cwd: SOURCE_DIR,
stdio: 'inherit'
});
}
// Build the application
console.log(' ⚙️ Running build...');
execSync('npm run build', {
cwd: SOURCE_DIR,
stdio: 'inherit'
execSync('npm run build', {
cwd: SOURCE_DIR,
stdio: 'inherit'
});
// Verify dist directory exists
if (!fs.existsSync(DIST_DIR)) {
throw new Error('Build failed - dist directory not found');
}
console.log(' ✅ Build completed successfully');
} catch (error) {
throw new Error(`Build failed: ${error.message}`);
@@ -292,11 +292,11 @@ async function deploy() {
// Transfer files
console.log('\n📤 Transferring files...');
// First transfer the dist directory
console.log(' 📦 Transferring dist directory...');
const distFiles = [];
function getDistFiles(dir, baseDir = DIST_DIR) {
const files = fs.readdirSync(dir, { withFileTypes: true });
for (const file of files) {
@@ -312,13 +312,13 @@ async function deploy() {
}
}
}
getDistFiles(DIST_DIR);
console.log(` Found ${distFiles.length} files in dist/`);
// Create dist directory on remote
await ssh.execCommand(`mkdir -p ${REMOTE_PATH}/dist`);
// Transfer dist files
let transferred = 0;
for (const file of distFiles) {
@@ -329,14 +329,18 @@ async function deploy() {
await ssh.putFile(file.local, file.remote);
transferred++;
if (transferred % 10 === 0) {
console.log(` 📁 Transferred ${transferred}/${distFiles.length} files...`);
console.log(
` 📁 Transferred ${transferred}/${distFiles.length} files...`
);
}
} catch (error) {
console.log(` ⚠️ Failed to transfer ${path.relative(DIST_DIR, file.local)}: ${error.message}`);
console.log(
` ⚠️ Failed to transfer ${path.relative(DIST_DIR, file.local)}: ${error.message}`
);
}
}
console.log(` ✅ Transferred ${transferred} files from dist/`);
// Now transfer config files
const filesToTransfer = [
{