-
Notifications
You must be signed in to change notification settings - Fork 19
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
JavaScript #4
base: master
Are you sure you want to change the base?
JavaScript #4
Conversation
_drafts/javascript.md
Outdated
- [ ] Convert test files from CoffeeScript to JavaScript. | ||
- [ ] update package.json | ||
- [ ] add script for JavaScript linting | ||
- [ ] Update documentation |
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.
Everything in hubotio/hubot#1327 should also be in this list, especially https://github.com/github/generator-hubot
_drafts/javascript.md
Outdated
### Convert source files from CoffeeScript to JavaScript | ||
|
||
Convert all source files from CoffeeScript to JavaScript with a tool like [espresso](https://github.com/HipsterBrown/espresso). | ||
|
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 author of decaffeinate
uses hubot code base for his tests of achievement, it's worth citing https://github.com/decaffeinate/decaffeinate#status and the hubotio/hubot#1138 issue.
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.
good timing, I just found out about it and am looking into it right now. It looks like the better option for us. I’ll keep you posted
_drafts/javascript.md
Outdated
|
||
The Node Foundation has tried to get Debian to adapt modern Node versions like "[pretty much every other repository for packages takes modern versions.](https://twitter.com/mikeal/status/869646796888330240)" but could not succeed. | ||
|
||
See more responses to my question regarding old Node versions at https://twitter.com/gr2m/status/869305267464306689 |
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.
Debian users that need modern node version have 2 main easy options:
- turning to nvm
- getting packages from nodesource
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.
good point, we could document these options as part of our breaking changes documentation / changelogs
… JavaScript conversion cc @mose
…ce async/await support would have no immediate effect
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 a great writeup, thanks for putting it together!
I have tons of questions and feedback 😁 It is mostly from experience with working on hubot, and also to make this specific enough that it can be implemented by someone that isn't @gr2m
_drafts/javascript.md
Outdated
|
||
## Motivation | ||
|
||
This evolution proposal is part of point 3 of the Hubot 3.0 milestone: |
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.
Could you link to this?
_drafts/javascript.md
Outdated
|
||
## Detailed process | ||
|
||
The steps of the conversation will be |
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 the intent to do each of these as a PR per item? One big PRs? Some combination?
_drafts/javascript.md
Outdated
|
||
Make sure the existing tests (still written in CoffeeScript) run against the new JavaScript. | ||
|
||
Now go trough each file and improve the code readability by hand as needed. From my experiences with converting Hoodie from CoffeeScript to JavaScript quite a lot of manual work will be required. |
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.
s/trough/through/
_drafts/javascript.md
Outdated
|
||
Make sure the existing tests (still written in CoffeeScript) run against the new JavaScript. | ||
|
||
Now go trough each file and improve the code readability by hand as needed. From my experiences with converting Hoodie from CoffeeScript to JavaScript quite a lot of manual work will be required. |
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.
To be clear, this is improving internal readability, and is leaving the external API in-tact?
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.
correct
_drafts/javascript.md
Outdated
|
||
Same as the previous steps only for the tests files this time. | ||
|
||
When finished, create a separate branch with with the tests written in JavaScript but the source code still in CoffeeScript to assure integrity. |
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 sounds like a great way to build confidence in the conversion.
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.
There is a with with
duplication in that paragraph.
|
||
### Add script for JavaScript linting | ||
|
||
The only tool I would like to introduce as part of this proposal is a linting tool which will be run as part of `npm test`. |
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.
Could we make sure to update (or create?) contributor documentation around using the linter? I've had times where I've started on new process, with CI running linter, and the feedback process is relatively slow until you actually start getting it running locally, if not as part of your editor setup.
|
||
The only tool I would like to introduce as part of this proposal is a linting tool which will be run as part of `npm test`. | ||
|
||
I suggest [standard](https://standardjs.com/). We’ve been using it in all our projects at Hoodie and Neighbourhoodie since 2+ years and never looked back. It's a zero-configuration JavaScript linter. |
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.
👍 from me for standard. I've only used it a couple times, but I like that it is zero config, and the style it encourages is pretty light on line-noise (ie no semi-colons).
|
||
Node versions smaller than v4 are no longer maintained and have known security vulnerabilities. The only major operating system which distributes a no longer maintained Node version by default is Debian, and there are alternative ways to install a recent Node version, see [Debian and Ubuntu based Linux distributions](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions). | ||
|
||
Mikeal Rogers (Node Foundation) says about Debian’s official Node packages: |
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 there a relevant link for this, ie tweet, documentation, etc?
|
||
More importantly, we would make it much harder for existing users to upgrade to the new Hubot version. Hubot is a widely used project and having a clear upgrade plan with a reasonable pace is critical. If we only drop support for versions which are no longer maintained we can align with Node’s [LTS schedule](https://github.com/nodejs/LTS#readme) so we can avoid a recurring discussion of when to drop support for what versions once and for all. | ||
|
||
Besides, the current Hubot does not use a single promise in its core implementation at this 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.
cc hubotio/hubot#1338 which is talking about adding it
|
||
Node 7.6 introduced native support for async/await. For asynchronous code like much of Hubot is, this is a very nice feature. It makes the code more readable and hence more accessible for contributors which is a main objective of the Hubot community. | ||
|
||
The reason we decided against it is that the complexity of Hubot core is not too high, the code can be made very readable even when using Promises. Once the one-time conversion from CoffeeScript to JavaScript is done, only smaller parts of the code base will be touched, the effect of async/await vs. promises will be limited. |
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 really like this sentiment.
I'm not familiar enough with async/await yet, but would it possible to still take advantage of these support in the core? That is, can hubot users use it even if the core wasn't specifically written for it?
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.
Yes, Hubot user can take full advantage for the Node version they run their own Hubot instance in. If Hubot core adds Promise-based APIs then users which run their Hubot in Node 7.6+ can use async/await as these are sugar APIs to work with Promises. At the same time the core would continue to work with Node v4, so we don’t break Hubot instances that require this older Node version. Does that answer your question?
Problem is that es6 classes break `hubot-mock-adapter` because it does a custom inheritance workaround which does not call the Adapter class with the `new` keyword
I’m running into a bit of a blocker: when using the MyAdapter.__super__.constructor.apply(this, arguments); which fails with I’m still thinking about how to find the best balance between readable, easy to contribute/maintain code on the one and as few breaking changes on the other side. Let me know if you have any thoughts on this :) |
I did a search for this error (ie
Initially, I'd be most concerned with interoperability with existing code, unless we are committing to updating all the existing adapters as part of this work. I suspect less readable, harder to contribute to code can be confined to specific parts of the code base. Combine generous amounts of code comments about what it is trying to achieve, I think that is a good compromise. That said, another approach is to figure out the most readable/maintainable thing, and then go back to add those bits to ensure better interop. And one last thought: it should be possible to write tests cases that work on master, but fail in this case. That could help us know when the problem is fixed. |
I’ve to log off for today, just want to share what I’m looking into right now. I haven’t fully tested it yet, but I think if we add sth like this to the footer before we return the classes that others inherit from, we should be fine: const inherits = require('util').inherits
const EventEmitter = require('events').EventEmitter
class Adapter extends EventEmitter {
// implementation of Adapter
}
function AdapterCompatibleWithCoffeeScript () {
return new (Function.prototype.bind.apply(Adapter, [ null ].concat([].slice.call(arguments))))
}
inherits(AdapterCompatibleWithCoffeeScript, Adapter)
module.exports = AdapterCompatibleWithCoffeeScript It’s not very pretty, but it might be a good compromise for the time being, so we can move forward with JavaScript implementation while remaining compatibility with existing adapters. |
clarification of detailed process ping @technicalpickles re: #4 (comment)
@gr2m I just tried out
I recall that there were some issues with hubot-test-helper related to inheritence and how it uses classes. I think this might be common enough of a module to make sure it works with hubot 3 & javascript. |
I’m removing Do you have an app which is using it right now with passing tests? |
I don't, but could get it running in hubot-for-hubot pretty easily. |
from my experience, it’s better to keep tests less "magical" and more verbose. The |
I think I missed that we were using the hubot-mock-adapter before now. I see hubotio/hubot-mock-adapter#7 that is being used there, and that https://www.npmjs.com/package/hubot-mock-adapter-v3 was released using that. Would you mind moving the fork of hubot-mock-adapter to the hubotio org? There is documentation that recommends using hubot-test-helper, so we'll want to update that too: https://github.com/hubotio/hubot/blob/master/docs/scripting.md#testing-hubot-scripts |
@gr2m was asking for folks to test the new release. I just ran through it without any problem:
I tested a few scripts I knew existed (ping, help, the rules), and they responded. Only thing of note I saw was a message the first time launching |
This will be fixed once we remove the bin/hubot from the generator and replace it with a |
Ping. |
I’m no longer working on Hubot I’m afraid. I cannot help I’m afraid |
Can I maintain it? |
This evolution proposal is part of point 3 of the Hubot 3.0 milestone:
Read the proposal 👀
Open todos / follow ups
require('hubot/es2015.js')
(add tests for require(hubot/es2015) hubot#1359)src/
tolib/
when everything else is done