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

Improve interactive AWS creds flow #6449

Merged
merged 5 commits into from Aug 8, 2019
Merged

Improve interactive AWS creds flow #6449

merged 5 commits into from Aug 8, 2019

Conversation

dschep
Copy link
Contributor

@dschep dschep commented Jul 25, 2019

What did you implement:

closes PLAT-1341

How did you implement it:

implemented by asking if the user has an account, if not, open browser to sign up
and then open browser (in new or existing acct case) to create an admin user for
user with serverless.

added open as a dependency to open the browser

How can we verify it:

npm i -g serverless/serverless#nicer-aws-creds-flow
mv ~/.aws ~/.awsbak
sls

Todos:

Note: Run npm run test-ci to run all validation checks on proposed changes

  • Write tests and confirm existing functionality is not broken.
    Validate via npm test
  • Write documentation
  • Ensure there are no lint errors.
    Validate via npm run lint-updated
    Note: Some reported issues can be automatically fixed by running npm run lint:fix
  • Ensure introduced changes match Prettier formatting.
    Validate via npm run prettier-check-updated
    Note: All reported issues can be automatically fixed by running npm run prettify-updated
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: NO
Is it a breaking change?: NO

closes PLAT-1341

implemented by asking if the user has an account, if not, open browser to sign up
and then open browser (in new or existing acct case) to create an admin user for
user with serverless.

added open as a dependency to open the browser
@dschep
Copy link
Contributor Author

dschep commented Jul 25, 2019

Uggh... open>=6 depends on node >= 8 but open<6 fails npm audit. Any ideas?

@pmuens pmuens changed the title Imporove interactive AWS creds flow Imporve interactive AWS creds flow Jul 26, 2019
Copy link
Contributor

@pmuens pmuens left a comment

Choose a reason for hiding this comment

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

Uggh... open>=6 depends on node >= 8 but open<6 fails npm audit. Any ideas?

I looked for alternatives, but apparently there are no up-to-date packages out there.

🤔 Maybe we can to fork open it and fix the dependency issue for version 6 on our own?

console.log('---------------------------');
const errMsg = err ? `\nError: ${err.message}` : '';
const msg = `Unable to open browser automatically${errMsg}`;
console.log(`🙈 ${chalk.red(msg)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

While cute I'm unsure if we want to go the "emotification of all the CLIs" route in an enterprise-facing project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copy and pasted this out of platform-sdk 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(as to why i copied, it.. didn't want to add sdk as a direct dep, which is the only way to guarantee it's availability with things like yarn, and now also the fact it requires newer versions of node)

Copy link
Contributor

Choose a reason for hiding this comment

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

now also the fact it requires newer versions of node

But SDK Is dependency of a plugin.. so if SDK was updated to not work in v6, then through Plugin it'll also break SLS (?)

@pmuens pmuens changed the title Imporve interactive AWS creds flow Improve interactive AWS creds flow Jul 26, 2019
@dschep
Copy link
Contributor Author

dschep commented Jul 26, 2019

🤔 Maybe we can to fork open it and fix the dependency issue for version 6 on our own?

Yeah.. It's a single file AFAICT https://github.com/sindresorhus/open/blob/master/index.js So i'll do that.

@dschep dschep marked this pull request as ready for review July 30, 2019 12:39
@dschep dschep requested a review from pmuens July 30, 2019 12:39
Copy link
Contributor

@pmuens pmuens left a comment

Choose a reason for hiding this comment

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

This looks really good.

The only issue I ran into was that the focus was switched to my browser when I answered the question "Serverless: Do you want to set them up now? Yes". The problem is that there was no website opened. Only the browser was focused. The steps after that opened the browser URLs correctly.

Here are the logs:

[~/Desktop/code.nosync/serverless/tmp]$ ../bin/serverless

Serverless: No project detected. Do you want to create a new one? Yes
Serverless: What do you want to make? AWS Node.js
Serverless: What do you want to call this project? foo

Project successfully created in 'foo' folder.

No AWS credentials were found on your computer, you need these to host your application.

Serverless: Do you want to set them up now? Yes
Serverless: Do you have an AWS account? No
Serverless: Press Enter to continue after creating an AWS account 
Serverless: Press Enter to continue after creating an AWS user with access keys 
Serverless: AWS Access Key Id: 

Safari is my primary browser.

Copy link
Member

@skierkowski skierkowski left a comment

Choose a reason for hiding this comment

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

This is such a slick experience.

Copy link
Contributor

@pmuens pmuens left a comment

Choose a reason for hiding this comment

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

Just tested this again to see if it's a glitch but I can consistently reproduce the problem that the default Broswer (Safari in my case) is opened without opening a new tab / window (see comment above).

@medikoo can you take this for a spin and see if you're also facing the same problems? I'm wondering if it's just Safari which has problems here.

@pmuens pmuens requested a review from medikoo August 8, 2019 10:34
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

Looks like really good improvement. Just minor remarks.


function displayManualOpenMessage(url, err) {
// https://github.com/sindresorhus/log-symbols
console.log('---------------------------');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we do not rely here on serverless logger? Even if we don't like to use cli.log we may rel on cli.consoleLog.

It'll clearly indicate the intention of generating user facing CLI output.

Direct use of console.log is more for temporary debug output (which we prevent from committing in via lint rules)

console.log('---------------------------');
const errMsg = err ? `\nError: ${err.message}` : '';
const msg = `Unable to open browser automatically${errMsg}`;
console.log(`🙈 ${chalk.red(msg)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

now also the fact it requires newer versions of node

But SDK Is dependency of a plugin.. so if SDK was updated to not work in v6, then through Plugin it'll also break SLS (?)

@dschep dschep merged commit f9c25db into master Aug 8, 2019
@dschep dschep deleted the nicer-aws-creds-flow branch August 8, 2019 14:05
@medikoo medikoo added this to the 1.50.0 milestone Aug 14, 2019
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.

None yet

4 participants