diff --git a/.changeset/grumpy-papayas-call.md b/.changeset/grumpy-papayas-call.md new file mode 100644 index 0000000000..006bf5df67 --- /dev/null +++ b/.changeset/grumpy-papayas-call.md @@ -0,0 +1,6 @@ +--- +"@medusajs/medusa": patch +"@medusajs/cli": patch +--- + +feat(cli): Add plugin:publish and plugin:add commands support diff --git a/packages/cli/medusa-cli/src/create-cli.ts b/packages/cli/medusa-cli/src/create-cli.ts index 5329a1d561..2f3a1b42e2 100644 --- a/packages/cli/medusa-cli/src/create-cli.ts +++ b/packages/cli/medusa-cli/src/create-cli.ts @@ -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.`, diff --git a/packages/medusa/src/commands/plugin/add.ts b/packages/medusa/src/commands/plugin/add.ts new file mode 100644 index 0000000000..a391f2dfdd --- /dev/null +++ b/packages/medusa/src/commands/plugin/add.ts @@ -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, + }) +} diff --git a/packages/medusa/src/commands/plugin/publish.ts b/packages/medusa/src/commands/plugin/publish.ts new file mode 100644 index 0000000000..598297ab76 --- /dev/null +++ b/packages/medusa/src/commands/plugin/publish.ts @@ -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, + }) +}