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

Wire login and identify #13

Merged
merged 5 commits into from
Sep 6, 2019

Conversation

jonallured
Copy link
Member

This PR wires together the login and identify commands. All I'm doing here is writing the token to disk and then reading it back in.

Copy link
Contributor

@pepopowitz pepopowitz left a comment

Choose a reason for hiding this comment

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

Nice and simple. 👍

@@ -23,6 +25,8 @@ export default class Login extends Command {
password,
})

const path = `${os.homedir()}/.config/artsy`
fs.writeFileSync(path, result.access_token)
Copy link

Choose a reason for hiding this comment

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

Perhaps consider ~/.netrc ? There’s probably libs for that too.

Copy link

Choose a reason for hiding this comment

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

(Also can’t assume .config exists.)

Copy link
Contributor

@pepopowitz pepopowitz Sep 6, 2019

Choose a reason for hiding this comment

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

Re: .netrc, we have a ticket for that: https://github.com/artsy/artsy-cli/projects/1#card-24981275. I think stuffing it into .config is an iteration toward that goal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this PR was intentionally naive, but then I got spec failures and now I'm sorta changing my mind. I've got some work locally where I used testdouble.js to mock out fs and os, but then I run specs and everything blows up, haha. I should have seen this coming, but when you mock those out, they are mocked for all the code, not just the SUT. I learned this lesson before with pear but then forgot.

https://github.com/jonallured/pear/blob/master/test/pear-data.test.ts

With pear I actually extracted some units that wrap fs and os and are under my control that I could then safely mock. Going to take a step back and work on that so that how we persist does not matter to this test. We could use ~/.netrc or a config file or whatever.

Copy link

Choose a reason for hiding this comment

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

With something like https://www.npmjs.com/package/netrc you only need to mock that API, FS tests are already done by the lib.

This is about as DIY as it gets, but is really all we need in order to
mock out the config layer. If/when we add a proper mocking library it
would probably be good to migrate this over too.
@jonallured
Copy link
Member Author

Ok this ended up needing more hand-holding than I expected, but I was able to get a bunch of stuff done here:

  • have login write the token to a file on disk
  • have identify read that token from a file on disk
  • create a Config object to wrap these operations so that it could be mocked in tests
  • update our CI config so that linting, prettier and testing tasks all run as expected
  • add an .env.example file so that it's more clear what needs to be done there

Going to merge this for now and then would be happy to keep iterating on this stuff!

@jonallured jonallured merged commit 1d0e3c7 into artsy:master Sep 6, 2019
@artsyit
Copy link
Contributor

artsyit commented Sep 6, 2019

🚀 PR was released in v0.0.5 🚀

1 similar comment
@artsyit
Copy link
Contributor

artsyit commented Sep 6, 2019

🚀 PR was released in v0.0.5 🚀

@artsyit
Copy link
Contributor

artsyit commented Sep 6, 2019

🚀 PR was released in v0.0.5 🚀

2 similar comments
@artsyit
Copy link
Contributor

artsyit commented Sep 6, 2019

🚀 PR was released in v0.0.5 🚀

@artsyit
Copy link
Contributor

artsyit commented Sep 6, 2019

🚀 PR was released in v0.0.5 🚀

This pull request was closed.
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.

4 participants