Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(medusa-cli): add monorepo support command develop #5723

Merged
6 changes: 6 additions & 0 deletions .changeset/grumpy-bees-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/medusa": patch
"@medusajs/admin": patch
---

feat(medusa): add monorepo support command develop
2 changes: 1 addition & 1 deletion packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"bin": {
"medusa-admin": "./bin/medusa-admin.js"
},
"main": "index.js",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"bin",
Expand Down
18 changes: 10 additions & 8 deletions packages/medusa/src/commands/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ export default async function ({ port, directory }) {
process.exit(0)
})

const babelPath = path.join(directory, "node_modules", ".bin", "babel")
const babelPath = path.resolve(
require.resolve("@babel/cli"),
"../",
"bin",
"babel.js"
)

execSync(`"${babelPath}" src -d dist --ignore "src/admin/**"`, {
cwd: directory,
Expand All @@ -58,12 +63,9 @@ export default async function ({ port, directory }) {
COMMAND_INITIATED_BY: "develop",
}

const cliPath = path.join(
directory,
"node_modules",
"@medusajs",
"medusa",
"dist",
const cliPath = path.resolve(
require.resolve("@medusajs/medusa"),
"../",
"bin",
"medusa.js"
)
Expand All @@ -78,7 +80,7 @@ export default async function ({ port, directory }) {
process.exit(1)
})

const { cli, binExists } = resolveAdminCLI(directory)
const { cli, binExists } = resolveAdminCLI()

if (binExists) {
const backendUrl = `http://localhost:${port}`
Expand Down
10 changes: 4 additions & 6 deletions packages/medusa/src/commands/utils/resolve-admin-cli.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import fs from "fs-extra"
import path from "path"

export function resolveAdminCLI(directory: string) {
const cli = path.join(
directory,
"node_modules",
"@medusajs",
"admin",
export function resolveAdminCLI() {
const cli = path.resolve(
require.resolve("@medusajs/admin"),
"../../",
"bin",
"medusa-admin.js"
)
Expand Down