UNPKG

fast-deployment

Version:

A lightweight Node.js package for rapid deployment of Vue.js, Next.js, and Nuxt.js applications

47 lines (46 loc) 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildApplication = buildApplication; const child_process_1 = require("child_process"); /** * Builds the application based on its type * @param config The deployment configuration * @returns A promise that resolves when the build is complete */ function buildApplication(config) { return new Promise((resolve, reject) => { const buildCommand = getBuildCommand(config.appType); console.log(`Building ${config.appType} application...`); const process = (0, child_process_1.spawn)('npm', ['run', buildCommand], { stdio: 'inherit', shell: true }); process.on('exit', (code) => { if (code === 0) { console.log('Build completed successfully.'); resolve(); } else { reject(new Error(`Build failed with exit code ${code}`)); } }); process.on('error', (err) => { reject(new Error(`Failed to start build process: ${err.message}`)); }); }); } /** * Gets the appropriate build command based on the application type * @param appType The type of application (vue, next, or nuxt) * @returns The build command to use */ function getBuildCommand(appType) { switch (appType) { case 'vue': case 'next': case 'nuxt': return 'build'; default: throw new Error(`Unsupported application type: ${appType}`); } }