UNPKG

neex

Version:

Neex - Modern Fullstack Framework Built on Express and Next.js. Fast to Start, Easy to Build, Ready to Deploy

60 lines (59 loc) 2.79 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadConfig = void 0; const path_1 = __importDefault(require("path")); const fs_1 = __importDefault(require("fs")); const chalk_1 = __importDefault(require("chalk")); async function loadConfig(configPath) { const defaultConfigPath = path_1.default.resolve(process.cwd(), 'neex.config.js'); const finalConfigPath = configPath ? path_1.default.resolve(process.cwd(), configPath) : defaultConfigPath; if (!fs_1.default.existsSync(finalConfigPath)) { console.error(chalk_1.default.red(`Configuration file not found at: ${finalConfigPath}`)); process.exit(1); } try { // Use a dynamic import to load the config file. // The 'file://' protocol is important for ensuring correct module resolution on all platforms. const configModule = await (_a = `file://${finalConfigPath}`, Promise.resolve().then(() => __importStar(require(_a)))); // The config can be the default export or the entire module. const config = configModule.default || configModule; // Basic validation to ensure the config has the expected structure. if (!config.commands || !Array.isArray(config.commands)) { console.error(chalk_1.default.red('Invalid configuration: \'commands\' array is missing or not an array.')); process.exit(1); } return config; } catch (error) { console.error(chalk_1.default.red(`Error loading configuration file: ${error.message}`)); process.exit(1); } } exports.loadConfig = loadConfig;