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

BREAKING CHANGE(cli): Port Logout Command #60

Merged
merged 4 commits into from
Aug 30, 2019
Merged

BREAKING CHANGE(cli): Port Logout Command #60

merged 4 commits into from
Aug 30, 2019

Conversation

xavdid
Copy link
Contributor

@xavdid xavdid commented Aug 30, 2019

Add new logout command. Given that it includes the changes made in zapier/zapier-platform-cli#422, it's technically major since it changes logout behavior.

I don't anticipate people wanting the old "kill all keys" behavior back, but if they do, they'll be able to do the same thing in the UI. if we need to add it back here, we can add a flag.

Testing wise, I may try and do it with a bunch of mocks and just validate that a bad server response is fine and that an auth file is deleted (or ignored silently).

@xavdid xavdid requested a review from eliangcs as a code owner August 30, 2019 03:19
const cleanedBody = {};
for (const k in requestBody) {
if (k.includes('zip_file')) {
cleanedBody[k] = replacementStr;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

now this won't add "zip removed" to requests without zip files in the first place.

const deleteFile = fileName => {
return new Promise(resolve => {
try {
fse.unlinkSync(fileName);
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'm not sure why we were wrapping a sync method in a promise (instead of using the async version or no promise at all). Went ahead and did "just plain sync".

Copy link
Member

@eliangcs eliangcs left a comment

Choose a reason for hiding this comment

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

I have a suggestion on the error handling. Feel free to merge once addressed.

} catch (e) {
this.warn(
'Deletion API request failed. If this is unexpected, rerun this command with `--debug` for more info.'
);
Copy link
Member

@eliangcs eliangcs Aug 30, 2019

Choose a reason for hiding this comment

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

When the server fails to delete the key and returns an error, should we just exit? I know this follows the original implementation, but maybe it makes more sense not to continue if an error happens.

Another issue I found is when I tested zapier logout with .zapierrc absent, the output formatting is off:

I think adding a this.endSpinner() before printing the warning message should fix the formatting issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

used a finally! good catch.

@xavdid xavdid merged commit 43044f1 into master Aug 30, 2019
@xavdid xavdid deleted the logout-command branch August 30, 2019 21:14
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