feat(create-medusa-app): support more environment variables + fixes (#7533)
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import chalk from "chalk"
|
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { Ora } from "ora"
|
import { Ora } from "ora"
|
||||||
@@ -10,6 +9,10 @@ import { clearProject } from "./clear-project.js"
|
|||||||
import type { Client } from "pg"
|
import type { Client } from "pg"
|
||||||
|
|
||||||
const ADMIN_EMAIL = "admin@medusa-test.com"
|
const ADMIN_EMAIL = "admin@medusa-test.com"
|
||||||
|
// TODO remove preview links once we move to main docs
|
||||||
|
const STORE_CORS = "http://localhost:8000,https://docs.medusajs.com,https://medusa-docs-v2-git-docs-v2-medusajs.vercel.app,https://medusa-resources-git-docs-v2-medusajs.vercel.app"
|
||||||
|
const ADMIN_CORS = "http://localhost:7000,http://localhost:7001,https://docs.medusajs.com,https://medusa-docs-v2-git-docs-v2-medusajs.vercel.app,https://medusa-resources-git-docs-v2-medusajs.vercel.app"
|
||||||
|
const DEFAULT_REDIS_URL = "redis://localhost:6379"
|
||||||
|
|
||||||
type PrepareOptions = {
|
type PrepareOptions = {
|
||||||
directory: string
|
directory: string
|
||||||
@@ -68,15 +71,19 @@ export default async ({
|
|||||||
// initialize the invite token to return
|
// initialize the invite token to return
|
||||||
let inviteToken: string | undefined = undefined
|
let inviteToken: string | undefined = undefined
|
||||||
|
|
||||||
|
// add environment variables
|
||||||
|
let env = `MEDUSA_ADMIN_ONBOARDING_TYPE=${onboardingType}${EOL}STORE_CORS=${STORE_CORS}${EOL}ADMIN_CORS=${ADMIN_CORS}${EOL}REDIS_URL=${DEFAULT_REDIS_URL}${EOL}JWT_SECRET=supersecret${EOL}COOKIE_SECRET=supersecret`
|
||||||
|
|
||||||
if (!skipDb) {
|
if (!skipDb) {
|
||||||
let env = `DATABASE_TYPE=postgres${EOL}DATABASE_URL=${dbConnectionString}${EOL}MEDUSA_ADMIN_ONBOARDING_TYPE=${onboardingType}${EOL}STORE_CORS=http://localhost:8000,http://localhost:7001${EOL}POSTGRES_URL=${dbConnectionString}`
|
env += `${EOL}DATABASE_URL=${dbConnectionString}${EOL}POSTGRES_URL=${dbConnectionString}`
|
||||||
if (nextjsDirectory) {
|
|
||||||
env += `${EOL}MEDUSA_ADMIN_ONBOARDING_NEXTJS_DIRECTORY=${nextjsDirectory}`
|
|
||||||
}
|
|
||||||
// add connection string to project
|
|
||||||
fs.appendFileSync(path.join(directory, `.env`), env)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nextjsDirectory) {
|
||||||
|
env += `${EOL}MEDUSA_ADMIN_ONBOARDING_NEXTJS_DIRECTORY=${nextjsDirectory}`
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.appendFileSync(path.join(directory, `.env`), env)
|
||||||
|
|
||||||
factBoxOptions.interval = displayFactBox({
|
factBoxOptions.interval = displayFactBox({
|
||||||
...factBoxOptions,
|
...factBoxOptions,
|
||||||
spinner,
|
spinner,
|
||||||
|
|||||||
Reference in New Issue
Block a user