-
Notifications
You must be signed in to change notification settings - Fork 662
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
Introduce a @slack/cli-hooks
package that implements Slack CLI hooks
#1714
Conversation
- feat: introduce shared linter configurations - fix: fix common linting errors - refactor: update checking for the check update hook - build: add a build step to transpile typescript
packages/hooks/src/check-update.js
Outdated
return version; | ||
}); | ||
return { | ||
name: 'the Slack SDK', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how correct it is, but it matches the Deno hooks implementation and makes some sense to me. This field "corresponds to the overall package/library, in which individual component releases are bundled" and I'm not sure of better naming for it since both @slack/bolt
and @slack/hooks
might be included. Open to any suggestions though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've always disliked what we chose for the Deno one since it feels so general. No harm though in staying the course: let's keep it for now!
packages/hooks/src/check-update.js
Outdated
name: 'the Slack SDK', | ||
message: '', | ||
releases, | ||
url: 'https://api.slack.com/automation/changelog', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, is this what we would want to point them to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Not sure of a better place at the moment... It does seem strange since CLI release notes are displayed separately from this and the automation changelog is mostly CLI and Deno. I'm open to changing this whenever!
For reference here are example update logs
$ slack update
🌱 A new version of the Slack CLI is available:
v1.0.0 → 2.15.0
You can read the release notes at:
https://api.slack.com/automation/changelog
To manually update, visit the download page:
https://api.slack.com/automation/cli/install
? 🚀 Do you want to auto-update to the latest version now? No
🛠️ An update from the Slack SDK is available:
› @slack/hooks
0.0.5 → 0.0.6
Learn more at:
https://github.com/slackapi/node-slack-sdk/releases/tag/@slack/[email protected]
For more information about this update, visit:
https://api.slack.com/automation/changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for the visual! That's helpful. I guess my question is will the hooks
package update be present in the Changelog with everything else? If so, it makes sense. If not, we probably need to tweak the CLI logic at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to future changes in the CLI since I don't think these hooks
will be included in the changelog / follow the same release cycle. Maybe we do align these releases though?
For now I think this is alright to leave but will add it to the backlog!
Co-authored-by: Alissa Renz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@misscoded Really appreciate the review! Going to follow up with a few updates to the README and an update to get-manifest
but will hold off on changes to naming and removal of Deno for right now. Definitely open to making these changes soon though!
packages/hooks/src/check-update.js
Outdated
return version; | ||
}); | ||
return { | ||
name: 'the Slack SDK', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how correct it is, but it matches the Deno hooks implementation and makes some sense to me. This field "corresponds to the overall package/library, in which individual component releases are bundled" and I'm not sure of better naming for it since both @slack/bolt
and @slack/hooks
might be included. Open to any suggestions though!
packages/hooks/src/check-update.js
Outdated
name: 'the Slack SDK', | ||
message: '', | ||
releases, | ||
url: 'https://api.slack.com/automation/changelog', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Not sure of a better place at the moment... It does seem strange since CLI release notes are displayed separately from this and the automation changelog is mostly CLI and Deno. I'm open to changing this whenever!
For reference here are example update logs
$ slack update
🌱 A new version of the Slack CLI is available:
v1.0.0 → 2.15.0
You can read the release notes at:
https://api.slack.com/automation/changelog
To manually update, visit the download page:
https://api.slack.com/automation/cli/install
? 🚀 Do you want to auto-update to the latest version now? No
🛠️ An update from the Slack SDK is available:
› @slack/hooks
0.0.5 → 0.0.6
Learn more at:
https://github.com/slackapi/node-slack-sdk/releases/tag/@slack/[email protected]
For more information about this update, visit:
https://api.slack.com/automation/changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great 💯 I left a few suggestions and NITs
Should the start hook default file be app.js or index.js?
Our templates and samples use app.js
defaulting to it makes sense
Is the install-update hook alright to implement as a follow up?
I say go for it but I think there is also value in implementing the message boundary protocol
Gonna start my review now, but re: your questions in your original comment:
slack.dev getting started instructions use
100% |
@zimeg one thing I noticed: I have the sample up and running, but I can't add the function bundled in the app to WFB when I deploy it to my test workspace. I think because the output of |
@misscoded @WilliamBergamin @filmaj A few patches later and I believe this is ready for re-review! I've updated the steps to review to hopefully be easier (everything should be working right away) but you will need a dev build of the CLI to handle automagic tokens. Please let me know if there's anything more that needs updating! Or just changing! 🙏 |
Two paper-cut style issues I just encountered (feel free to file somewhere and move on if you think this is something worth addressing at some point):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, very close to being ready I think!
|
||
/** | ||
* Standardized communication format between the SDK and CLI regarding hooks. | ||
* @typedef SDKInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job documenting these
'sdk-managed-connection-enabled': true, | ||
}, | ||
runtime: 'node', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cleanliness of this implementation gives me the warm n fuzzies
packages/cli-hooks/src/get-hooks.js
Outdated
'.', | ||
], | ||
}, | ||
'protocol-version': ['message-boundaries', 'default'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we pull these protocol names from the protocol source file in this package? The reason I bring this up is that protocol.js
defines a SUPPORTED_NAMED_PROTOCOLS
array that only includes the message boundary protocol, but by returning this line in get-hooks, we're telling the CLI that either of the two named protocols is fine to use (with a preference for message-boundaries). We should decide on one approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally in favor of using SUPPORTED_NAMED_PROTOCOLS
- good call. Making the update now to use that exported array with only message-boundaries
for now. Open to also including default
in the export, but I lean towards including just the message-boundaries
in this hook.
}); | ||
}); | ||
|
||
describe('message boundary protocol', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome 💯 just left some nits take them or leave them
@filmaj @WilliamBergamin appreciate another round of reviews and pointers on polish! I think I've addressed all of the comments and suggestions (or added more polish-related CLI-things to our backlog) so I think this is ready for another round of review. I've tested this on Node v18.19.0 and v20.8.0 for macOS and Node v18.19.0 and v20.11.0 for Windows. Everything is working as hoped! There is a problem forming the actual web socket connection on Windows, but I think this is a problem with the virtual environment I'm using and not the hooks (the app is stuck trying to authenticate the Socket Mode request) 😬 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filmaj :excited: 🚀 let's goooooo!! Do we want to start this at |
Your call big guy! |
@filmaj The time feels right for a 1.0.0 😎 |
@filmaj @WilliamBergamin @misscoded Really appreciate all of the reviews on this! Thanks a ton! 🚢 💨 |
Summary
This PR introduces a standalone package that implements hooks for the Slack CLI, meant for use in Bolt for JavaScript apps.
Early versions of this package are published to NPM here: https://www.npmjs.com/package/@slack/cli-hooks
Reviewers
Update a new Bolt app with the latest version of the CLI and the following commands:
Notes
A few quick questions rose during development:
Should the👍start
hook default file beapp.js
orindex.js
?Is the👍install-update
hook alright to implement as a follow up?Some tasks remain as TODOs as well: #1714 (comment)👍Requirements