diff --git a/.changeset/grumpy-bees-laugh.md b/.changeset/grumpy-bees-laugh.md new file mode 100644 index 0000000000000..9737edbb2ab6c --- /dev/null +++ b/.changeset/grumpy-bees-laugh.md @@ -0,0 +1,6 @@ +--- +"@medusajs/medusa": patch +"@medusajs/admin": patch +--- + +feat(medusa): add monorepo support command develop diff --git a/packages/admin/package.json b/packages/admin/package.json index 6e97932d6b8f7..3f5133d5f97d5 100644 --- a/packages/admin/package.json +++ b/packages/admin/package.json @@ -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", diff --git a/packages/medusa/src/commands/develop.js b/packages/medusa/src/commands/develop.js index e34ef27574a27..48d8a15f86c47 100644 --- a/packages/medusa/src/commands/develop.js +++ b/packages/medusa/src/commands/develop.js @@ -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, @@ -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" ) @@ -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}` diff --git a/packages/medusa/src/commands/utils/resolve-admin-cli.ts b/packages/medusa/src/commands/utils/resolve-admin-cli.ts index a845bfe4e3102..daedb2eaa9a8f 100644 --- a/packages/medusa/src/commands/utils/resolve-admin-cli.ts +++ b/packages/medusa/src/commands/utils/resolve-admin-cli.ts @@ -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" )