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

JavaScript #4

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6dcd2f4
Start proposal for CoffeeScript to JavaScript conversion
gr2m May 31, 2017
7d3b514
bullet points styling
gr2m May 31, 2017
fbc1e10
style: bold
gr2m May 31, 2017
cf16911
removed double mention of standardjs
gr2m May 31, 2017
93ada84
decaffeinate is a better suited tool helping with the CoffeeScript to…
gr2m May 31, 2017
6bbe7a5
add examples
gr2m May 31, 2017
3d3fd6a
add note that Hubot core does not use any promises at this point, hen…
gr2m May 31, 2017
d499b70
_drafts/
gr2m Jun 1, 2017
7ce6add
typo
gr2m Jun 1, 2017
5575a5f
add checklist for updating docs in officially supported projects
gr2m Jun 2, 2017
f87f365
todo to add note for Debian/Ubuntu users
gr2m Jun 2, 2017
853491d
_drafts/
gr2m Jun 2, 2017
1008fa7
_drafts/
gr2m Jun 2, 2017
1d91ad8
typo
gr2m Jun 2, 2017
cbd1fc2
_drafts/
gr2m Jun 2, 2017
837bd2f
typo
gr2m Jun 3, 2017
0556920
_drafts/
gr2m Jun 7, 2017
df32778
add instructions to test a 3rd party adapter with the hubot PR
gr2m Jun 7, 2017
b0655b9
state: In Progress -> In Review
gr2m Jun 7, 2017
a400b15
_drafts/
gr2m Jun 8, 2017
a8dee2d
add plan for releasing `hubot@3`
gr2m Jun 14, 2017
3d3c579
update links to PRs updating peerDependencies
gr2m Jun 26, 2017
10e2a51
update list of peerDependencies PRs & add list for patch releases of …
gr2m Jun 26, 2017
d2d3938
remove deprecated scripts from the default install using yeoman gener…
gr2m Jun 26, 2017
6fbb8af
added video tutorial to convert CoffeeScript to JavaScript
gr2m Jun 27, 2017
114937e
allow `0.0.0-development` as hubot version
gr2m Jun 27, 2017
908a971
update initial PR status for `hubotio/hubot-redis-brain`
gr2m Jun 27, 2017
f693a59
✓ Update hubot’s version range `peerDependencies` of default scripts
gr2m Jun 27, 2017
6d19dcd
✓ release patch versions for standard scripts
gr2m Jun 27, 2017
824481b
add status for `hubot-maps` script
gr2m Jun 28, 2017
b21b7a0
✓ hubot-maps patch release with peerDependencies update
gr2m Jun 28, 2017
f6cc3ba
✓ hubot@next release
gr2m Jun 28, 2017
be1550c
add link to PR for JavaScript conversion of hubot-rules
gr2m Jun 28, 2017
fc03570
updating progress for hubot generator
gr2m Jun 29, 2017
8a77fec
update laste node@8 stable version for testing
gr2m Jun 29, 2017
ebf1bfe
_drafts/
gr2m Jun 29, 2017
f1a9cfe
_drafts/
gr2m Jun 29, 2017
25e0c30
move documentation todos from issue
gr2m Jul 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add examples
gr2m committed May 31, 2017
commit 6bbe7a5f1360b2a708e67b6e9bbbdba034ae4a39
190 changes: 188 additions & 2 deletions _drafts/javascript.md
Original file line number Diff line number Diff line change
@@ -29,8 +29,6 @@ Converting of all CoffeeScript to JavaScript which can run natively on Node 4 ([

## Detailed process

**TODO:** make one or two sample CoffeeScript to JavaScript conversions (I’m working on it right now and will make it part of the proposal PR for the evolution repository)

The steps of the conversation will be
Copy link
Member

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?


- [ ] Convert source files from CoffeeScript to JavaScript.
@@ -39,6 +37,8 @@ The steps of the conversation will be
- [ ] add script for JavaScript linting
- [ ] Update documentation
Copy link
Contributor

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

Copy link
Member

Choose a reason for hiding this comment

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

The documentation should be updated before the release. I want to make sure that the files that are packaged include updated documentation with how to use the Javascript support.


See also [examples](#examples) below

### Convert source files from CoffeeScript to JavaScript

Convert all source files from CoffeeScript to JavaScript with a tool like [decaffeinate](https://github.com/decaffeinate/decaffeinate), see also [github/hubot#1138](https://github.com/github/hubot/issues/1138).
@@ -104,3 +104,189 @@ Only breaking change is dropping support of Node 0.10 and 0.12.
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.

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.

<a name="examples"></a>
## Examples

- [`index.coffee`](#example1)
- [`src/robot.coffee`](#example2)

<a name="example1"></a>
### `index.coffee`

Original CoffeeScript

```coffeescript
User = require './src/user'
Brain = require './src/brain'
Robot = require './src/robot'
Adapter = require './src/adapter'
Response = require './src/response'
{Listener,TextListener} = require './src/listener'
{Message,TextMessage,EnterMessage,LeaveMessage,TopicMessage,CatchAllMessage} = require './src/message'

module.exports = {
User
Brain
Robot
Adapter
Response
Listener
TextListener
Message
TextMessage
EnterMessage
LeaveMessage
TopicMessage
CatchAllMessage
}

module.exports.loadBot = (adapterPath, adapterName, enableHttpd, botName, botAlias) ->
new Robot adapterPath, adapterName, enableHttpd, botName, botAlias
```

JavaScript compatible with Node 4

```javascript
'use strict'

const User = require('./src/user')
const Brain = require('./src/brain')
const Robot = require('./src/robot')
const Adapter = require('./src/adapter')
const Response = require('./src/response')
const Listener = require('./src/listener')
const Message = require('./src/message')

module.exports = {
User,
Brain,
Robot,
Adapter,
Response,
Listener: Listener.Listener,
TextListener: Listener.TextListener,
Message: Message.Message,
TextMessage: Message.TextMessage,
EnterMessage: Message.EnterMessage,
LeaveMessage: Message.LeaveMessage,
TopicMessage: Message.TopicMessage,
CatchAllMessage: Message.CatchAllMessage,

loadBot (adapterPath, adapterName, enableHttpd, botName, botAlias) {
return new Robot(adapterPath, adapterName, enableHttpd, botName, botAlias)
}
}

module.exports.loadBot = function loadBot (adapterPath, adapterName, enableHttpd, botName, botAlias) {
return new Robot(adapterPath, adapterName, enableHttpd, botName, botAlias)
}
```

JavaScript compatible with Node 7.6+

```js
const User = require('./src/user')
const Brain = require('./src/brain')
const Robot = require('./src/robot')
const Adapter = require('./src/adapter')
const Response = require('./src/response')
const {Listener, TextListener} = require('./src/listener')
const {Message, TextMessage, EnterMessage, LeaveMessage, TopicMessage, CatchAllMessage} = require('./src/message')

module.exports = {
User,
Brain,
Robot,
Adapter,
Response,
Listener,
TextListener,
Message,
TextMessage,
EnterMessage,
LeaveMessage,
TopicMessage,
CatchAllMessage,

loadBot (adapterPath, adapterName, enableHttpd, botName, botAlias) {
return new Robot(adapterPath, adapterName, enableHttpd, botName, botAlias)
}
}
```

<a name="example2"></a>
### `src/robot.coffee` (excerpt)

Original

```coffeescript
class Robot

constructor: (adapterPath, adapter, httpd, name = 'Hubot', alias = false) ->
@adapterPath ?= Path.join __dirname, "adapters"

@name = name

@on 'error', (err, res) =>
@invokeErrorHandlers(err, res)
@onUncaughtException = (err) =>
@emit 'error', err
process.on 'uncaughtException', @onUncaughtException

send: (envelope, strings...) ->
@adapter.send envelope, strings...
```

JavaScript compatible with Node 4

```javascript
'use strict'

class Robot {
constructor (adapterPath, adapter, httpd, name, alias) {
if (name == null) { name = 'Hubot' }
if (alias == null) { alias = false }

this.name = name

this.on('error', (err, res) => {
return this.invokeErrorHandlers(err, res)
})
this.onUncaughtException = err => {
return this.emit('error', err)
}
process.on('uncaughtException', this.onUncaughtException)
}

send (envelope /*, ...strings */) {
const strings = [].slice.call(arguments, 1)
return this.adapter.send(envelope, strings)
}
}
```

JavaScript compatible with Node 7.6+

```javascript
class Robot {
constructor (adapterPath, adapter, httpd, name, alias) {
if (name == null) { name = 'Hubot' }
if (alias == null) { alias = false }

this.name = name

this.on('error', (err, res) => {
return this.invokeErrorHandlers(err, res)
})
this.onUncaughtException = err => {
return this.emit('error', err)
}
process.on('uncaughtException', this.onUncaughtException)
}

send (envelope, ...strings) {
return this.adapter.send(envelope, ...Array.from(strings))
}
}
```