medusajs-launch-utils
Version:
Build and launch utilities for Medusajs monorepo projects
31 lines (25 loc) • 1 kB
JavaScript
const path = require('path');
const dotenv = require('dotenv');
const { launchStorefront } = require('../src/storefrontLauncher');
// Load environment variables from .env.local if it exists
dotenv.config({ path: path.resolve(process.cwd(), '.env.local') });
// Load environment variables from .env if it exists
dotenv.config();
const command = process.argv[2];
const config = {
backendUrl: process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL || 'http://localhost:9000',
port: process.env.PORT || '8000',
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
searchConfig: {
apiKey: process.env.MEILISEARCH_API_KEY,
endpoint: process.env.NEXT_PUBLIC_SEARCH_ENDPOINT,
searchKey: process.env.NEXT_PUBLIC_SEARCH_API_KEY
}
};
launchStorefront(command, config)
.then(() => console.log('Storefront launched successfully'))
.catch((error) => {
console.error('Error launching storefront:', error);
process.exit(1);
});