chore: Enable draft order plugin by default (#13314)
* wip * fix * fix tests * update lockfile * fix deps * Enable draft order plugin by default * remove double negation * support merging modules
This commit is contained in:
7
.changeset/good-panthers-shave.md
Normal file
7
.changeset/good-panthers-shave.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
"@medusajs/draft-order": patch
|
||||||
|
"@medusajs/utils": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore: Enable draft order plugin by default
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,6 +13,8 @@ packages/**/.yarn/*
|
|||||||
integration-tests/**/.yarn/*
|
integration-tests/**/.yarn/*
|
||||||
www/**/.yarn/*
|
www/**/.yarn/*
|
||||||
|
|
||||||
|
packages/**/plugins/**/.medusa/
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
|||||||
@@ -131,7 +131,12 @@ describe("defineConfig", function () {
|
|||||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [
|
||||||
|
{
|
||||||
|
"options": {},
|
||||||
|
"resolve": "@medusajs/draft-order",
|
||||||
|
},
|
||||||
|
],
|
||||||
"projectConfig": {
|
"projectConfig": {
|
||||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||||
"http": {
|
"http": {
|
||||||
@@ -298,7 +303,12 @@ describe("defineConfig", function () {
|
|||||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [
|
||||||
|
{
|
||||||
|
"options": {},
|
||||||
|
"resolve": "@medusajs/draft-order",
|
||||||
|
},
|
||||||
|
],
|
||||||
"projectConfig": {
|
"projectConfig": {
|
||||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||||
"http": {
|
"http": {
|
||||||
@@ -473,7 +483,12 @@ describe("defineConfig", function () {
|
|||||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [
|
||||||
|
{
|
||||||
|
"options": {},
|
||||||
|
"resolve": "@medusajs/draft-order",
|
||||||
|
},
|
||||||
|
],
|
||||||
"projectConfig": {
|
"projectConfig": {
|
||||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||||
"http": {
|
"http": {
|
||||||
@@ -649,7 +664,12 @@ describe("defineConfig", function () {
|
|||||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [
|
||||||
|
{
|
||||||
|
"options": {},
|
||||||
|
"resolve": "@medusajs/draft-order",
|
||||||
|
},
|
||||||
|
],
|
||||||
"projectConfig": {
|
"projectConfig": {
|
||||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||||
"http": {
|
"http": {
|
||||||
@@ -813,7 +833,12 @@ describe("defineConfig", function () {
|
|||||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [
|
||||||
|
{
|
||||||
|
"options": {},
|
||||||
|
"resolve": "@medusajs/draft-order",
|
||||||
|
},
|
||||||
|
],
|
||||||
"projectConfig": {
|
"projectConfig": {
|
||||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||||
"http": {
|
"http": {
|
||||||
@@ -980,7 +1005,12 @@ describe("defineConfig", function () {
|
|||||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [
|
||||||
|
{
|
||||||
|
"options": {},
|
||||||
|
"resolve": "@medusajs/draft-order",
|
||||||
|
},
|
||||||
|
],
|
||||||
"projectConfig": {
|
"projectConfig": {
|
||||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||||
"http": {
|
"http": {
|
||||||
@@ -1180,7 +1210,12 @@ describe("defineConfig", function () {
|
|||||||
"resolve": "@medusajs/medusa/workflow-engine-redis",
|
"resolve": "@medusajs/medusa/workflow-engine-redis",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [
|
||||||
|
{
|
||||||
|
"options": {},
|
||||||
|
"resolve": "@medusajs/draft-order",
|
||||||
|
},
|
||||||
|
],
|
||||||
"projectConfig": {
|
"projectConfig": {
|
||||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||||
"http": {
|
"http": {
|
||||||
@@ -1382,7 +1417,12 @@ describe("defineConfig", function () {
|
|||||||
"resolve": "@medusajs/medusa/workflow-engine-redis",
|
"resolve": "@medusajs/medusa/workflow-engine-redis",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [
|
||||||
|
{
|
||||||
|
"options": {},
|
||||||
|
"resolve": "@medusajs/draft-order",
|
||||||
|
},
|
||||||
|
],
|
||||||
"projectConfig": {
|
"projectConfig": {
|
||||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||||
"http": {
|
"http": {
|
||||||
@@ -1600,7 +1640,12 @@ describe("defineConfig", function () {
|
|||||||
"resolve": "@medusajs/medusa/workflow-engine-redis",
|
"resolve": "@medusajs/medusa/workflow-engine-redis",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [
|
||||||
|
{
|
||||||
|
"options": {},
|
||||||
|
"resolve": "@medusajs/draft-order",
|
||||||
|
},
|
||||||
|
],
|
||||||
"projectConfig": {
|
"projectConfig": {
|
||||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||||
"http": {
|
"http": {
|
||||||
@@ -1638,6 +1683,88 @@ describe("defineConfig", function () {
|
|||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should include default plugins", function () {
|
||||||
|
const config = defineConfig()
|
||||||
|
expect(config.plugins).toEqual([
|
||||||
|
{ resolve: "@medusajs/draft-order", options: {} },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should append custom plugins to defaults", function () {
|
||||||
|
const config = defineConfig({
|
||||||
|
plugins: [
|
||||||
|
{ resolve: "@medusajs/custom-plugin", options: { key: "value" } },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
expect(config.plugins).toEqual([
|
||||||
|
{ resolve: "@medusajs/draft-order", options: {} },
|
||||||
|
{ resolve: "@medusajs/custom-plugin", options: { key: "value" } },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should handle multiple custom plugins", function () {
|
||||||
|
const config = defineConfig({
|
||||||
|
plugins: [
|
||||||
|
{ resolve: "@medusajs/plugin-one", options: { setting: "a" } },
|
||||||
|
{ resolve: "@medusajs/plugin-two", options: { setting: "b" } },
|
||||||
|
{ resolve: "./local-plugin", options: {} },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
expect(config.plugins).toEqual([
|
||||||
|
{ resolve: "@medusajs/draft-order", options: {} },
|
||||||
|
{ resolve: "@medusajs/plugin-one", options: { setting: "a" } },
|
||||||
|
{ resolve: "@medusajs/plugin-two", options: { setting: "b" } },
|
||||||
|
{ resolve: "./local-plugin", options: {} },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should merge plugins", function () {
|
||||||
|
const config = defineConfig({
|
||||||
|
plugins: [
|
||||||
|
{ resolve: "@medusajs/draft-order", options: { setting: "a" } },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
expect(config.plugins).toEqual([
|
||||||
|
{ resolve: "@medusajs/draft-order", options: { setting: "a" } },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should include plugins in cloud environment", function () {
|
||||||
|
const originalEnv = { ...process.env }
|
||||||
|
process.env.EXECUTION_CONTEXT = "medusa-cloud"
|
||||||
|
|
||||||
|
const config = defineConfig({
|
||||||
|
plugins: [
|
||||||
|
{ resolve: "@medusajs/cloud-plugin", options: { cloud: true } },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
process.env = { ...originalEnv }
|
||||||
|
|
||||||
|
expect(config.plugins).toEqual([
|
||||||
|
{ resolve: "@medusajs/draft-order", options: {} },
|
||||||
|
{ resolve: "@medusajs/cloud-plugin", options: { cloud: true } },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should handle empty plugins array", function () {
|
||||||
|
const config = defineConfig({
|
||||||
|
plugins: [],
|
||||||
|
})
|
||||||
|
expect(config.plugins).toEqual([
|
||||||
|
{ resolve: "@medusajs/draft-order", options: {} },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should handle undefined plugins", function () {
|
||||||
|
const config = defineConfig({
|
||||||
|
modules: {},
|
||||||
|
})
|
||||||
|
expect(config.plugins).toEqual([
|
||||||
|
{ resolve: "@medusajs/draft-order", options: {} },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
it("should allow custom dynamodb config", function () {
|
it("should allow custom dynamodb config", function () {
|
||||||
expect(
|
expect(
|
||||||
defineConfig({
|
defineConfig({
|
||||||
@@ -1785,7 +1912,12 @@ describe("defineConfig", function () {
|
|||||||
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
"resolve": "@medusajs/medusa/workflow-engine-inmemory",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"plugins": [],
|
"plugins": [
|
||||||
|
{
|
||||||
|
"options": {},
|
||||||
|
"resolve": "@medusajs/draft-order",
|
||||||
|
},
|
||||||
|
],
|
||||||
"projectConfig": {
|
"projectConfig": {
|
||||||
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
"databaseUrl": "postgres://localhost/medusa-starter-default",
|
||||||
"http": {
|
"http": {
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ afterEach(async () => {
|
|||||||
|
|
||||||
describe("getResolvedPlugins | relative paths", () => {
|
describe("getResolvedPlugins | relative paths", () => {
|
||||||
test("resolve configured plugins", async () => {
|
test("resolve configured plugins", async () => {
|
||||||
|
await fs.createJson("node_modules/@medusajs/draft-order/package.json", {
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
version: "1.0.0",
|
||||||
|
})
|
||||||
|
|
||||||
await fs.createJson("plugins/dummy/package.json", {
|
await fs.createJson("plugins/dummy/package.json", {
|
||||||
name: "my-dummy-plugin",
|
name: "my-dummy-plugin",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
@@ -27,25 +32,46 @@ describe("getResolvedPlugins | relative paths", () => {
|
|||||||
apiKey: "asecret",
|
apiKey: "asecret",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resolve: "@medusajs/draft-order",
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(plugins).toEqual([
|
expect(plugins).toEqual(
|
||||||
{
|
expect.arrayContaining([
|
||||||
resolve: path.join(fs.basePath, "./plugins/dummy/.medusa/server/src"),
|
{
|
||||||
admin: undefined,
|
id: "@medusajs/draft-order",
|
||||||
name: "my-dummy-plugin",
|
modules: [],
|
||||||
id: "my-dummy-plugin",
|
name: "@medusajs/draft-order",
|
||||||
options: { apiKey: "asecret" },
|
options: {},
|
||||||
version: "1.0.0",
|
resolve: path.join(
|
||||||
modules: [],
|
fs.basePath,
|
||||||
},
|
"node_modules/@medusajs/draft-order/.medusa/server/src"
|
||||||
])
|
),
|
||||||
|
version: "1.0.0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
resolve: path.join(fs.basePath, "./plugins/dummy/.medusa/server/src"),
|
||||||
|
admin: undefined,
|
||||||
|
name: "my-dummy-plugin",
|
||||||
|
id: "my-dummy-plugin",
|
||||||
|
options: { apiKey: "asecret" },
|
||||||
|
version: "1.0.0",
|
||||||
|
modules: [],
|
||||||
|
},
|
||||||
|
])
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("scan plugin modules", async () => {
|
test("scan plugin modules", async () => {
|
||||||
|
await fs.createJson("node_modules/@medusajs/draft-order/package.json", {
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
version: "1.0.0",
|
||||||
|
})
|
||||||
await fs.createJson("plugins/dummy/package.json", {
|
await fs.createJson("plugins/dummy/package.json", {
|
||||||
name: "my-dummy-plugin",
|
name: "my-dummy-plugin",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
@@ -70,7 +96,7 @@ describe("getResolvedPlugins | relative paths", () => {
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(plugins).toEqual([
|
expect(plugins).toEqual(expect.arrayContaining([
|
||||||
{
|
{
|
||||||
resolve: path.join(fs.basePath, "./plugins/dummy/.medusa/server/src"),
|
resolve: path.join(fs.basePath, "./plugins/dummy/.medusa/server/src"),
|
||||||
admin: undefined,
|
admin: undefined,
|
||||||
@@ -87,10 +113,26 @@ describe("getResolvedPlugins | relative paths", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
])
|
{
|
||||||
|
id: "@medusajs/draft-order",
|
||||||
|
modules: [],
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
options: {},
|
||||||
|
resolve: path.join(
|
||||||
|
fs.basePath,
|
||||||
|
"node_modules/@medusajs/draft-order/.medusa/server/src"
|
||||||
|
),
|
||||||
|
version: "1.0.0",
|
||||||
|
},
|
||||||
|
]))
|
||||||
})
|
})
|
||||||
|
|
||||||
test("throw error when package.json file is missing", async () => {
|
test("throw error when package.json file is missing", async () => {
|
||||||
|
await fs.createJson("node_modules/@medusajs/draft-order/package.json", {
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
version: "1.0.0",
|
||||||
|
})
|
||||||
|
|
||||||
const resolvePlugins = async () =>
|
const resolvePlugins = async () =>
|
||||||
getResolvedPlugins(
|
getResolvedPlugins(
|
||||||
fs.basePath,
|
fs.basePath,
|
||||||
@@ -113,6 +155,10 @@ describe("getResolvedPlugins | relative paths", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test("resolve admin source from medusa-plugin-options file", async () => {
|
test("resolve admin source from medusa-plugin-options file", async () => {
|
||||||
|
await fs.createJson("node_modules/@medusajs/draft-order/package.json", {
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
version: "1.0.0",
|
||||||
|
})
|
||||||
await fs.createJson("plugins/dummy/package.json", {
|
await fs.createJson("plugins/dummy/package.json", {
|
||||||
name: "my-dummy-plugin",
|
name: "my-dummy-plugin",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
@@ -138,12 +184,16 @@ describe("getResolvedPlugins | relative paths", () => {
|
|||||||
apiKey: "asecret",
|
apiKey: "asecret",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resolve: "@medusajs/draft-order",
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(plugins).toEqual([
|
expect(plugins).toEqual(expect.arrayContaining([
|
||||||
{
|
{
|
||||||
resolve: path.join(fs.basePath, "./plugins/dummy/.medusa/server/src"),
|
resolve: path.join(fs.basePath, "./plugins/dummy/.medusa/server/src"),
|
||||||
admin: {
|
admin: {
|
||||||
@@ -163,12 +213,27 @@ describe("getResolvedPlugins | relative paths", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
])
|
{
|
||||||
|
id: "@medusajs/draft-order",
|
||||||
|
modules: [],
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
options: {},
|
||||||
|
resolve: path.join(
|
||||||
|
fs.basePath,
|
||||||
|
"node_modules/@medusajs/draft-order/.medusa/server/src"
|
||||||
|
),
|
||||||
|
version: "1.0.0",
|
||||||
|
},
|
||||||
|
]))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("getResolvedPlugins | package reference", () => {
|
describe("getResolvedPlugins | package reference", () => {
|
||||||
test("resolve configured plugins", async () => {
|
test("resolve configured plugins", async () => {
|
||||||
|
await fs.createJson("node_modules/@medusajs/draft-order/package.json", {
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
version: "1.0.0",
|
||||||
|
})
|
||||||
await fs.createJson("package.json", {})
|
await fs.createJson("package.json", {})
|
||||||
await fs.createJson("node_modules/@plugins/dummy/package.json", {
|
await fs.createJson("node_modules/@plugins/dummy/package.json", {
|
||||||
name: "my-dummy-plugin",
|
name: "my-dummy-plugin",
|
||||||
@@ -190,7 +255,7 @@ describe("getResolvedPlugins | package reference", () => {
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(plugins).toEqual([
|
expect(plugins).toEqual(expect.arrayContaining([
|
||||||
{
|
{
|
||||||
resolve: path.join(
|
resolve: path.join(
|
||||||
fs.basePath,
|
fs.basePath,
|
||||||
@@ -203,10 +268,25 @@ describe("getResolvedPlugins | package reference", () => {
|
|||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
modules: [],
|
modules: [],
|
||||||
},
|
},
|
||||||
])
|
{
|
||||||
|
id: "@medusajs/draft-order",
|
||||||
|
modules: [],
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
options: {},
|
||||||
|
resolve: path.join(
|
||||||
|
fs.basePath,
|
||||||
|
"node_modules/@medusajs/draft-order/.medusa/server/src"
|
||||||
|
),
|
||||||
|
version: "1.0.0",
|
||||||
|
},
|
||||||
|
]))
|
||||||
})
|
})
|
||||||
|
|
||||||
test("scan plugin modules", async () => {
|
test("scan plugin modules", async () => {
|
||||||
|
await fs.createJson("node_modules/@medusajs/draft-order/package.json", {
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
version: "1.0.0",
|
||||||
|
})
|
||||||
await fs.createJson("package.json", {})
|
await fs.createJson("package.json", {})
|
||||||
await fs.createJson("node_modules/@plugins/dummy/package.json", {
|
await fs.createJson("node_modules/@plugins/dummy/package.json", {
|
||||||
name: "my-dummy-plugin",
|
name: "my-dummy-plugin",
|
||||||
@@ -232,7 +312,7 @@ describe("getResolvedPlugins | package reference", () => {
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(plugins).toEqual([
|
expect(plugins).toEqual(expect.arrayContaining([
|
||||||
{
|
{
|
||||||
resolve: path.join(
|
resolve: path.join(
|
||||||
fs.basePath,
|
fs.basePath,
|
||||||
@@ -252,10 +332,25 @@ describe("getResolvedPlugins | package reference", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
])
|
{
|
||||||
|
id: "@medusajs/draft-order",
|
||||||
|
modules: [],
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
options: {},
|
||||||
|
resolve: path.join(
|
||||||
|
fs.basePath,
|
||||||
|
"node_modules/@medusajs/draft-order/.medusa/server/src"
|
||||||
|
),
|
||||||
|
version: "1.0.0",
|
||||||
|
},
|
||||||
|
]))
|
||||||
})
|
})
|
||||||
|
|
||||||
test("throw error when package.json file is missing", async () => {
|
test("throw error when package.json file is missing", async () => {
|
||||||
|
await fs.createJson("node_modules/@medusajs/draft-order/package.json", {
|
||||||
|
name: "@medusajs/draft-order",
|
||||||
|
version: "1.0.0",
|
||||||
|
})
|
||||||
const resolvePlugins = async () =>
|
const resolvePlugins = async () =>
|
||||||
getResolvedPlugins(
|
getResolvedPlugins(
|
||||||
fs.basePath,
|
fs.basePath,
|
||||||
@@ -267,6 +362,10 @@ describe("getResolvedPlugins | package reference", () => {
|
|||||||
apiKey: "asecret",
|
apiKey: "asecret",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resolve: "@medusajs/draft-order",
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import {
|
|||||||
} from "../modules-sdk"
|
} from "../modules-sdk"
|
||||||
import { isObject } from "./is-object"
|
import { isObject } from "./is-object"
|
||||||
import { isString } from "./is-string"
|
import { isString } from "./is-string"
|
||||||
import { tryConvertToNumber } from "./try-convert-to-number"
|
|
||||||
import { normalizeImportPathWithSource } from "./normalize-import-path-with-source"
|
import { normalizeImportPathWithSource } from "./normalize-import-path-with-source"
|
||||||
import { resolveExports } from "./resolve-exports"
|
import { resolveExports } from "./resolve-exports"
|
||||||
|
import { tryConvertToNumber } from "./try-convert-to-number"
|
||||||
|
|
||||||
const MEDUSA_CLOUD_EXECUTION_CONTEXT = "medusa-cloud"
|
const MEDUSA_CLOUD_EXECUTION_CONTEXT = "medusa-cloud"
|
||||||
const DEFAULT_SECRET = "supersecret"
|
const DEFAULT_SECRET = "supersecret"
|
||||||
@@ -49,13 +49,14 @@ export function defineConfig(config: InputConfig = {}): ConfigModule {
|
|||||||
const projectConfig = normalizeProjectConfig(config.projectConfig, options)
|
const projectConfig = normalizeProjectConfig(config.projectConfig, options)
|
||||||
const adminConfig = normalizeAdminConfig(config.admin)
|
const adminConfig = normalizeAdminConfig(config.admin)
|
||||||
const modules = resolveModules(config.modules, options, config.projectConfig)
|
const modules = resolveModules(config.modules, options, config.projectConfig)
|
||||||
|
const plugins = resolvePlugins(config.plugins, options)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
projectConfig,
|
projectConfig,
|
||||||
featureFlags: (config.featureFlags ?? {}) as ConfigModule["featureFlags"],
|
featureFlags: (config.featureFlags ?? {}) as ConfigModule["featureFlags"],
|
||||||
plugins: config.plugins || [],
|
|
||||||
admin: adminConfig,
|
admin: adminConfig,
|
||||||
modules: modules,
|
modules: modules,
|
||||||
|
plugins,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +125,33 @@ export function transformModules(
|
|||||||
return remappedModules as Exclude<ConfigModule["modules"], undefined>
|
return remappedModules as Exclude<ConfigModule["modules"], undefined>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolvePlugins(
|
||||||
|
configPlugins: InputConfig["plugins"],
|
||||||
|
{ isCloud }: { isCloud: boolean }
|
||||||
|
): ConfigModule["plugins"] {
|
||||||
|
const defaultPlugins: Map<string, ConfigModule["plugins"][number]> = new Map([
|
||||||
|
[
|
||||||
|
"@medusajs/draft-order",
|
||||||
|
{ resolve: "@medusajs/draft-order", options: {} },
|
||||||
|
],
|
||||||
|
])
|
||||||
|
|
||||||
|
if (configPlugins?.length) {
|
||||||
|
configPlugins.forEach((plugin) => {
|
||||||
|
if (typeof plugin === "string") {
|
||||||
|
defaultPlugins.set(plugin, { resolve: plugin, options: {} })
|
||||||
|
} else {
|
||||||
|
defaultPlugins.set(plugin.resolve, plugin)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't have any cloud plugins yet, but we might in the future
|
||||||
|
const cloudPlugins = [...Array.from(defaultPlugins.values())]
|
||||||
|
|
||||||
|
return isCloud ? cloudPlugins : Array.from(defaultPlugins.values())
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user API allow to use array of modules configuration. This method manage the loading of the
|
* The user API allow to use array of modules configuration. This method manage the loading of the
|
||||||
* user modules along side the default modules and re map them to an object.
|
* user modules along side the default modules and re map them to an object.
|
||||||
|
|||||||
@@ -84,6 +84,7 @@
|
|||||||
"@medusajs/core-flows": "2.9.0",
|
"@medusajs/core-flows": "2.9.0",
|
||||||
"@medusajs/currency": "2.9.0",
|
"@medusajs/currency": "2.9.0",
|
||||||
"@medusajs/customer": "2.9.0",
|
"@medusajs/customer": "2.9.0",
|
||||||
|
"@medusajs/draft-order": "2.9.0",
|
||||||
"@medusajs/event-bus-local": "2.9.0",
|
"@medusajs/event-bus-local": "2.9.0",
|
||||||
"@medusajs/event-bus-redis": "2.9.0",
|
"@medusajs/event-bus-redis": "2.9.0",
|
||||||
"@medusajs/file": "2.9.0",
|
"@medusajs/file": "2.9.0",
|
||||||
|
|||||||
@@ -49,7 +49,6 @@
|
|||||||
"@medusajs/cli": "2.9.0",
|
"@medusajs/cli": "2.9.0",
|
||||||
"@medusajs/framework": "2.9.0",
|
"@medusajs/framework": "2.9.0",
|
||||||
"@medusajs/icons": "2.9.0",
|
"@medusajs/icons": "2.9.0",
|
||||||
"@medusajs/medusa": "2.9.0",
|
|
||||||
"@medusajs/test-utils": "2.9.0",
|
"@medusajs/test-utils": "2.9.0",
|
||||||
"@medusajs/types": "2.9.0",
|
"@medusajs/types": "2.9.0",
|
||||||
"@medusajs/ui": "4.0.19",
|
"@medusajs/ui": "4.0.19",
|
||||||
@@ -81,7 +80,6 @@
|
|||||||
"@medusajs/cli": "2.9.0",
|
"@medusajs/cli": "2.9.0",
|
||||||
"@medusajs/framework": "2.9.0",
|
"@medusajs/framework": "2.9.0",
|
||||||
"@medusajs/icons": "2.9.0",
|
"@medusajs/icons": "2.9.0",
|
||||||
"@medusajs/medusa": "2.9.0",
|
|
||||||
"@medusajs/test-utils": "2.9.0",
|
"@medusajs/test-utils": "2.9.0",
|
||||||
"@medusajs/ui": "4.0.19",
|
"@medusajs/ui": "4.0.19",
|
||||||
"@mikro-orm/cli": "6.4.3",
|
"@mikro-orm/cli": "6.4.3",
|
||||||
|
|||||||
@@ -6391,7 +6391,7 @@ __metadata:
|
|||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|
||||||
"@medusajs/draft-order@workspace:packages/plugins/draft-order":
|
"@medusajs/draft-order@2.9.0, @medusajs/draft-order@workspace:packages/plugins/draft-order":
|
||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@medusajs/draft-order@workspace:packages/plugins/draft-order"
|
resolution: "@medusajs/draft-order@workspace:packages/plugins/draft-order"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -6402,7 +6402,6 @@ __metadata:
|
|||||||
"@medusajs/framework": 2.9.0
|
"@medusajs/framework": 2.9.0
|
||||||
"@medusajs/icons": 2.9.0
|
"@medusajs/icons": 2.9.0
|
||||||
"@medusajs/js-sdk": 2.9.0
|
"@medusajs/js-sdk": 2.9.0
|
||||||
"@medusajs/medusa": 2.9.0
|
|
||||||
"@medusajs/test-utils": 2.9.0
|
"@medusajs/test-utils": 2.9.0
|
||||||
"@medusajs/types": 2.9.0
|
"@medusajs/types": 2.9.0
|
||||||
"@medusajs/ui": 4.0.19
|
"@medusajs/ui": 4.0.19
|
||||||
@@ -6439,7 +6438,6 @@ __metadata:
|
|||||||
"@medusajs/cli": 2.9.0
|
"@medusajs/cli": 2.9.0
|
||||||
"@medusajs/framework": 2.9.0
|
"@medusajs/framework": 2.9.0
|
||||||
"@medusajs/icons": 2.9.0
|
"@medusajs/icons": 2.9.0
|
||||||
"@medusajs/medusa": 2.9.0
|
|
||||||
"@medusajs/test-utils": 2.9.0
|
"@medusajs/test-utils": 2.9.0
|
||||||
"@medusajs/ui": 4.0.19
|
"@medusajs/ui": 4.0.19
|
||||||
"@mikro-orm/cli": 6.4.3
|
"@mikro-orm/cli": 6.4.3
|
||||||
@@ -6895,6 +6893,7 @@ __metadata:
|
|||||||
"@medusajs/core-flows": 2.9.0
|
"@medusajs/core-flows": 2.9.0
|
||||||
"@medusajs/currency": 2.9.0
|
"@medusajs/currency": 2.9.0
|
||||||
"@medusajs/customer": 2.9.0
|
"@medusajs/customer": 2.9.0
|
||||||
|
"@medusajs/draft-order": 2.9.0
|
||||||
"@medusajs/event-bus-local": 2.9.0
|
"@medusajs/event-bus-local": 2.9.0
|
||||||
"@medusajs/event-bus-redis": 2.9.0
|
"@medusajs/event-bus-redis": 2.9.0
|
||||||
"@medusajs/file": 2.9.0
|
"@medusajs/file": 2.9.0
|
||||||
|
|||||||
Reference in New Issue
Block a user