Skip to content

Commit

Permalink
feat(cli): Add plugin:publish and plugin:add commands support (medusa…
Browse files Browse the repository at this point in the history
…js#10938)

RESOLVES FRMW-2864
RESOLVES FRMW-2868

**What**
Add support for the following cli commands:
- `plugin:publish`
- `plugin:add`
  • Loading branch information
adrien2p authored Jan 13, 2025
1 parent c895ed8 commit b7a3759
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/grumpy-papayas-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/medusa": patch
"@medusajs/cli": patch
---

feat(cli): Add plugin:publish and plugin:add commands support
29 changes: 29 additions & 0 deletions packages/cli/medusa-cli/src/create-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,35 @@ function buildLocalCommands(cli, isLocalProject) {
})
),
})
.command({
command: "plugin:publish",
desc: "Publish the plugin to the local packages registry",
handler: handlerP(
getCommandHandler("plugin/publish", (args, cmd) => {
process.env.NODE_ENV = process.env.NODE_ENV || `development`
cmd(args)
return new Promise(() => {})
})
),
})
.command({
command: "plugin:add [plugin_names...]",
desc: "Add the specified plugin to the project from the local packages registry",
builder: {
plugin_names: {
type: "array",
description: "The name of the plugins to add",
demand: true,
},
},
handler: handlerP(
getCommandHandler("plugin/add", (args, cmd) => {
process.env.NODE_ENV = process.env.NODE_ENV || `development`
cmd(args)
return new Promise(() => {})
})
),
})
.command({
command: `telemetry`,
describe: `Enable or disable collection of anonymous usage data.`,
Expand Down
17 changes: 17 additions & 0 deletions packages/medusa/src/commands/plugin/add.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as yalc from "yalc"

/**
* Add the specified plugins to the project from the local packages registry
*/
export default async function localAddPlugin({
directory,
plugin_names,
}: {
directory: string
plugin_names: string[]
}) {
await yalc.addPackages(plugin_names, {
workingDir: directory,
replace: true,
})
}
17 changes: 17 additions & 0 deletions packages/medusa/src/commands/plugin/publish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as yalc from "yalc"

/**
* Publish the plugin to the local packages registry
*/
export default async function localPublishPlugin({
directory,
}: {
directory: string
}) {
await yalc.publishPackage({
push: true,
workingDir: directory,
changed: true,
replace: true,
})
}

0 comments on commit b7a3759

Please sign in to comment.