Registry / devops / medusajs-launch-utils

medusajs-launch-utils

JSON →
library0.0.19jsnpmunverified

medusajs-launch-utils is a JavaScript package engineered to streamline the setup, build, and launch processes for Medusa.js 2.0 monorepository projects. It automates critical tasks such as backend initialization, encompassing database migrations, one-time seeding, and admin user creation. The utility also features robust health checks (`await-backend`) to ensure the Medusa backend is fully operational before proceeding with storefront builds or deployments. Additionally, it facilitates storefront launching (`launch-storefront`) with automatic Medusa publishable API key fetching and integrated Meilisearch configuration management. Currently at version 0.0.19, the package appears to be in active development, offering specific solutions for orchestrating complex Medusa environments by effectively managing environment variables, particularly for sensitive Meilisearch keys, and incorporating resilient retry mechanisms for API operations. Its key differentiator lies in its focused automation of multi-service Medusa setups, significantly reducing manual configuration effort and mitigating potential errors in development and CI/CD workflows.

npm install medusajs-launch-utils
INSTALL
IMPORT
SIG · MEDUSAJS-LAUNCH-UT
M
medusajs-launch-utils
devopsjavascriptv0.0.19
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

initBackend
import { initBackend } from 'medusajs-launch-utils';
While primarily exposed and used as a CLI command (`init-backend`) within package.json scripts, the underlying functionality is assumed to be programmatically accessible through a named export. Direct programmatic import examples are not provided in the README excerpt.
awaitBackend
import { awaitBackend } from 'medusajs-launch-utils';
This utility is predominantly consumed as a CLI command (`await-backend`) to introduce a pause in build processes until the Medusa backend is responsive. Its programmatic availability as a named export is an inference based on typical utility package structures.
launchStorefront
import { launchStorefront } from 'medusajs-launch-utils';
The primary interface for this utility is via the `launch-storefront` CLI command, used to start, build, or develop Medusa storefronts. Programmatic import is inferred, but the documented usage focuses on command-line execution.
retry
import { retry } from 'medusajs-launch-utils';
Explicitly mentioned as a 'Shared Utility' with an 'Automatic retry for API operations' within the package features. This strongly suggests it's intended for programmatic import and reuse in custom scripts or functions.

Demonstrates typical integration of `medusajs-launch-utils` into a Medusa.js monorepo's `package.json` scripts. It illustrates how `init-backend` orchestrates backend setup (migrations, seeding), `await-backend` ensures backend readiness, and `launch-storefront` handles storefront deployment for `dev`, `build`, and `start` commands.

{ "name": "my-medusa-monorepo", "version": "1.0.0", "description": "Example package.json scripts for a Medusa.js 2.0 monorepo", "scripts": { "// -- Backend Package Scripts (e.g., in packages/backend/package.json) --": "", "backend:build": "init-backend && medusa build", "backend:dev": "init-backend && medusa develop", "backend:start": "init-backend && medusa start", "// -- Storefront Package Scripts (e.g., in packages/storefront/package.json) --": "", "storefront:wait": "await-backend", "storefront:launcher": "launch-storefront", "storefront:dev": "npm run storefront:wait && npm run storefront:launcher dev", "storefront:build": "npm run storefront:wait && npm run storefront:launcher build", "storefront:start": "npm run storefront:launcher start" }, "dependencies": { "medusajs-launch-utils": "^0.0.19" } }
Debug
Known issues
gotchaThis package is currently in version `0.0.19`, indicating it's pre-stable. APIs and functionality may change rapidly and potentially without adhering to semantic versioning for minor/patch changes. Use in production environments requires careful monitoring.
fix
To ensure consistent behavior, it is advisable to pin exact versions of the package in your `package.json` (e.g., `"medusajs-launch-utils": "0.0.19"`). Regularly check the GitHub repository for updates and breaking changes before upgrading.
affects: >=0.0.1
gotchaThe `init-backend` utility can automatically fetch and persist the `MEILISEARCH_ADMIN_KEY` to your `.env` file using the `MEILISEARCH_MASTER_KEY`. This can pose a security risk if your `.env` file is not properly secured or is inadvertently committed to version control.
fix
Ensure `.env` is added to your `.gitignore` file and is never publicly exposed. For production deployments, prioritize providing `MEILISEARCH_ADMIN_KEY` directly via secure environment variables (e.g., Kubernetes secrets, Docker secrets) instead of relying on file-based persistence.
affects: >=0.0.1
gotchaAccurate configuration of `MEILISEARCH_HOST` and `MEILISEARCH_MASTER_KEY` is critical for `init-backend`'s Meilisearch integration. Incorrect values or network issues can prevent automatic admin key fetching and halt the backend initialization process.
fix
Verify that `MEILISEARCH_HOST` correctly points to your running Meilisearch instance and that `MEILISEARCH_MASTER_KEY` is valid and has the necessary permissions. Test Meilisearch connectivity independently before executing `init-backend`.
affects: >=0.0.1
gotchaThe `await-backend` command is designed to repeatedly check for backend readiness. If the Medusa backend fails to start, crashes, or becomes unresponsive, `await-backend` may enter an indefinite retry loop or exhaust its retry attempts, blocking the subsequent storefront build or launch.
fix
Monitor Medusa backend logs for startup errors when `await-backend` is stalling. Implement robust error handling or timeout configurations in your CI/CD pipelines to prevent indefinite waits. Ensure the backend's health check endpoint is correctly configured and functioning.
affects: >=0.0.1
Errors
Common errors & fixes
Backend is not ready, retrying...
The `await-backend` utility cannot successfully connect to and receive a healthy response from the Medusa backend's health endpoint.
fix
Check that your Medusa backend service is running, accessible, and listening on the `MEDUSA_BACKEND_URL` specified in your environment. Examine backend logs for any startup errors or network configuration issues. Ensure no firewalls are blocking communication between services.
Meilisearch: Master key missing or invalid
The `init-backend` command failed to connect to the Meilisearch instance or authenticate with the provided `MEILISEARCH_MASTER_KEY` during the attempt to fetch the admin key.
fix
Verify that `MEILISEARCH_HOST` in your `.env` is correct and Meilisearch is running. Double-check `MEILISEARCH_MASTER_KEY` for typos and confirm it has the necessary permissions to manage API keys within Meilisearch. Consider regenerating the master key if unsure.
Error: Database migrations failed
The `init-backend` command initiated database migrations, but the process terminated with an error, typically due to issues with the database connection, schema conflicts, or invalid migration scripts.
fix
Review the detailed error messages in your Medusa backend logs for specific database-related issues. Confirm your database connection string and credentials in `.env` are accurate. Ensure the database server is running and accessible. For development, consider cleaning or reinitializing the database if data persistence is not critical.
Upgrade
Version history
0.0.19latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
2
Resources
medusajs-launch-utils — npm install medusajs-launch-utils · libregistry