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,medusa-cli): Added an invite option to the create user command, and allow seeding publishable api keys #4192

Merged
merged 9 commits into from
Jun 7, 2023

Conversation

shahednasser
Copy link
Member

@shahednasser shahednasser commented May 29, 2023

What

  • Adds an --invite option to the medusa user command that creates an invite instead of a new user.
  • Allow seeding publishable api keys

Why

This is useful for the npx/onboarding flow


Testing

User Command

You can test the command by passing the --invite option without a password:

medusa user -e [email protected] --invite

Or to avoid having to use the dev-cli tool, you can try using NPX and the snapshot:

npx -y @medusajs/[email protected] user -e [email protected] --invite

Seed command

  1. In the monorepo run yarn build
  2. In a medusa backend (with no seeded data, so that you don't run into duplicates error) run medusa-dev
  3. After the files are copied in the previous command, add in data/seed.json the following:
{
   //...
   "publishable_api_keys": [
    {
      "title": "test key"
    }
  ]
}
  1. Run the command yarn seed in the Medusa backend directory. => No errors should occur.
  2. Start the backend and check the publishable API key either through the admin dashbord or the admin endpoints. The publishable API key added in the seed file should be available there.

@shahednasser shahednasser requested a review from a team as a code owner May 29, 2023 07:41
@changeset-bot
Copy link

changeset-bot bot commented May 29, 2023

🦋 Changeset detected

Latest commit: ee7b024

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@medusajs/medusa-cli Patch
@medusajs/medusa Patch
@medusajs/admin-ui Patch
@medusajs/admin Patch
@medusajs/medusa-js Patch
medusa-payment-paypal Patch
medusa-payment-stripe Patch
medusa-plugin-mailchimp Patch
medusa-plugin-restock-notification Patch
medusa-react Patch
@medusajs/medusa-oas-cli Patch
@medusajs/oas-github-ci Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented May 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
medusa-api-ref ⬜️ Ignored (Inspect) Jun 7, 2023 11:50am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Jun 7, 2023 11:50am

@shahednasser
Copy link
Member Author

/snapshot-this

@shahednasser
Copy link
Member Author

/snapshot-this

Copy link
Member

@adrien2p adrien2p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, why did we needed that?

@shahednasser
Copy link
Member Author

LGTM, why did we needed that?

@adrien2p we need this for the new npx command. Basically, we want to create an invite instead of creating a user and allow the user to set their details through the admin

@adrien2p
Copy link
Member

LGTM, why did we needed that?

@adrien2p we need this for the new npx command. Basically, we want to create an invite instead of creating a user and allow the user to set their details through the admin

Makes complete sense, that is a nice addition 🚀

@shahednasser
Copy link
Member Author

/snapshot-this

@vercel vercel bot temporarily deployed to Preview – medusa-docs May 30, 2023 12:14 Inactive
@github-actions
Copy link
Contributor

🚀 A snapshot release has been made for this PR

Test the snapshots by updating your package.json with the newly published versions:

yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]

Latest commit: d61d0d4

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with a suggestion :)

await userService.create({ id, email }, password)
if (invite) {
const inviteService = container.resolve("inviteService")
await inviteService.create(email, "admin")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Handle user already exist error more elegantly with an explanatory server message:
CleanShot 2023-06-05 at 11 10 27@2x

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sames goes for when --invite is not used

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this is not relevant for when --invite is passed. We already print a nice one here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I handled this in the UserService, let me know if I should move the handling into the command instead.

@shahednasser
Copy link
Member Author

/snapshot-this

@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2023

🚀 A snapshot release has been made for this PR

Test the snapshots by updating your package.json with the newly published versions:

yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]

Latest commit: d76ba0c

@shahednasser shahednasser changed the title feat(medusa,medusa-cli): Added an invite option to the create user co… feat(medusa,medusa-cli): Added an invite option to the create user command, and allow seeding publishable api keys Jun 7, 2023
@shahednasser
Copy link
Member Author

/snapshot-this

@shahednasser shahednasser reopened this Jun 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2023

🚀 A snapshot release has been made for this PR

Test the snapshots by updating your package.json with the newly published versions:

yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]

Latest commit: 854022d

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@olivermrbl
Copy link
Contributor

Just need tests to pass 💪

@olivermrbl olivermrbl merged commit 8676ee7 into develop Jun 7, 2023
@olivermrbl olivermrbl deleted the feat/cli-invite-option branch June 7, 2023 18:34
@github-actions github-actions bot mentioned this pull request Jun 7, 2023
olivermrbl pushed a commit that referenced this pull request Jun 14, 2023
…mmand, and allow seeding publishable api keys (#4192)

* feat(medusa,medusa-cli): Added an invite option to the create user command

* ensure process exits for invites

* addressed PR comments

* allow seeding publishable api keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants