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

Add login and logout commands #1022

Merged
merged 22 commits into from
Jun 28, 2023
Merged

Add login and logout commands #1022

merged 22 commits into from
Jun 28, 2023

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Jun 22, 2023

Closes https://github.com/Shopify/core-issues/issues/56397

WHY are these changes introduced?

We are refactoring how CLI login works. For that, we are introducing h2 login and h2 logout, as well as removing --shop flags from certain commands.

WHAT is this pull request doing?

  • Implements h2 login and h2 logout commands.
  • Removes --shop flag from other commands.
  • Given the required changes for the previous 2 features, I've refactored some modules in the CLI related with auth and admin requests, and added some extra tests.
  • I'm muting the logs related to "Shopify Partners" since that's quite confusing.
  • Start using getCliCommand where possible.

HOW to test your changes?

Play with different permutations of the related commands:

  • h2 logout
  • h2 login
  • h2 link
  • h2 unlink
  • h2 env list
  • h2 env pull

When not logged in, they should prompt to login. When not linked, they should ask to run h2 link (env list/pull).

💡 I think it would be better to check the code commit by commit.

❓ Should we mark this as a major bump for the CLI package? It's deprecating flags we just introduced in the last release.

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

@frandiox frandiox requested review from graygilmore and a team June 22, 2023 08:01
@frandiox frandiox changed the title Fd login command Add login and logout commands Jun 22, 2023
@github-actions

This comment has been minimized.

Copy link
Contributor

@graygilmore graygilmore left a comment

Choose a reason for hiding this comment

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

Everything in here is looking great! I'm running into some errors when testing out the branch due to a platform error that we're fixing. Once that's resolved I'll come back and finish testing!

[
'Run',
{command: `${cliCommand} link`},
'to link your store to this project.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'to link your store to this project.',
'to link a Hydrogen storefront to this project.',

maybe clearer?

@@ -21,14 +21,6 @@ export const commonFlags = {
env: 'SHOPIFY_HYDROGEN_FLAG_FORCE',
char: 'f',
}),
shop: Flags.string({
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉 so much better

message: outputContent`Run ${outputToken.genericShellCommand(
`npx shopify hydrogen link`,
)}?`.value,
message: ['Run', {command: `${cliCommand} link`}, '?'],
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for fixing this formatting ❤️

[
([first]) =>
typeof first === 'string' &&
(first.includes('Shopify Partners') || first.includes('Logged in')),
Copy link
Contributor

Choose a reason for hiding this comment

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

It showing "Shopify Partners" has annoyed me, too. I wonder if we should fix this upstream in cli-kit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's just that it's hardcoded in a deep function so I think it would be hard for them to make it flexible -- I assume "Shopify Partners" is correct for most of the other CLIs 🤔

Copy link
Contributor

@graygilmore graygilmore left a comment

Choose a reason for hiding this comment

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

Was able to test this on a different shop. Everything looks good to me!

Copy link
Contributor

@graygilmore graygilmore left a comment

Choose a reason for hiding this comment

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

One little thing that I'd love to get confirmation on but otherwise the changes look good.

packages/cli/src/commands/hydrogen/link.ts Show resolved Hide resolved
@frandiox frandiox merged commit 5530d98 into 2023-04 Jun 28, 2023
@frandiox frandiox deleted the fd-login-command branch June 28, 2023 05:00
juanpprieto pushed a commit that referenced this pull request Jul 10, 2023
* Add login and logout commands

* Refactor graphql client and requests, add unit tests

* Update shopify-config methods and tests

* Update renderErrors to use cli Command

* Rework env-pull to call login and remove silent param

* Rework link command to call login and remove --shop flag

* Update list command to call login and remove --shop flag

* Update env-list command to call login and remove --shop flag

* Oclif manifest

* Cleanup

* Rework log replacer

* Mute cli-kit auth logs

* Fix mock

* Merge main branch

* Fix tests

* Minor changes

* Update package-lock

* Skip writing config when no directory is passed to login

* Improve unit tests

* Changesets
FrcPpe pushed a commit to FrcPpe/hydrogen that referenced this pull request Aug 13, 2023
* Add login and logout commands

* Refactor graphql client and requests, add unit tests

* Update shopify-config methods and tests

* Update renderErrors to use cli Command

* Rework env-pull to call login and remove silent param

* Rework link command to call login and remove --shop flag

* Update list command to call login and remove --shop flag

* Update env-list command to call login and remove --shop flag

* Oclif manifest

* Cleanup

* Rework log replacer

* Mute cli-kit auth logs

* Fix mock

* Merge main branch

* Fix tests

* Minor changes

* Update package-lock

* Skip writing config when no directory is passed to login

* Improve unit tests

* Changesets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants