-
-
Notifications
You must be signed in to change notification settings - Fork 42
[DO NOT MERGE] add HackMD integration #92
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Creates a callback function which accepts an issue `body` argument. | ||
* `body` will be used in a new GitHub issue containing meeting information. | ||
*/ | ||
exports.createGithubIssueCallback = (title, meetingProperties, done) => (err, body) => { | ||
if (err) { | ||
err.message = `Failed to upload minutes file:\n${err.message}`; | ||
return done(err); | ||
} | ||
github.issues.create({ | ||
owner: meetingProperties.USER.replace(/"/g, ''), | ||
repo: meetingProperties.REPO.replace(/"/g, ''), | ||
title: title, | ||
body, | ||
assignee: 'mhdawson', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol @mhdawson There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah @mhdawson is the only one who can run this script 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I'm the only one who could, but the setup required is non-trivial to do the first time. |
||
}); | ||
done(); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
|
||
const gdriveWrapper = require('google-drive-wrapper'); | ||
|
||
/** | ||
* Creates a new Google doc from the meeting template. | ||
* Calls `done(err, body)` with the body of a to-be-created GitHub issue. | ||
*/ | ||
exports.upload = ( | ||
minutesDocName, | ||
{title, googleAuthToken, googleApi, newIssue} = {}, | ||
done | ||
) => { | ||
const wrapper = new gdriveWrapper(googleAuthToken, googleApi, 'dummy'); | ||
wrapper.getMetaForFilename('/nodejs-meetings', function (err, parentMeta) { | ||
if (err !== null) { | ||
return done( | ||
new Error('Directory called "nodejs-meetings" does not exist, exiting') | ||
); | ||
} | ||
|
||
wrapper.uploadFile( | ||
title, | ||
minutesDocName, | ||
{ | ||
parent: parentMeta.id, | ||
compress: false, | ||
encrypt: false, | ||
convert: true, | ||
mimeType: 'application/vnd.google-apps.document', | ||
}, | ||
(meta) => { | ||
newIssue = newIssue | ||
.toString() | ||
.replace( | ||
/\* \*\*Minutes Google Doc\*\*: <>/, | ||
'* Minutes Google Doc: <https://docs.google.com/document/d/' + | ||
meta.id + | ||
'/edit>' | ||
) | ||
.replace(/\* _Previous Minutes Google Doc: <>_/, ''); | ||
done(null, newIssue); | ||
} | ||
); | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
|
||
const {execSync, spawnSync} = require('child_process'); | ||
|
||
/** | ||
* Creates a new HackMD doc from the meeting template. | ||
* Calls `done(err, body)` with the body of a to-be-created GitHub issue. | ||
* | ||
* For this to work, `process.env` must contain `CMD_CLI_ID=<email>` where `<email>` is | ||
* a HackMD username, and `CMD_CLI_PASSWORD=<password>` where `<password>` is the HackMD | ||
* user's password. | ||
* | ||
* @see https://npm.im/@hackmd/codimd-cli | ||
*/ | ||
exports.upload = (filepath, {newIssue: body} = {}, done) => { | ||
console.log('Logging in to HackMD...'); | ||
try { | ||
// this places a token in ~/.codimd/cookies.json | ||
spawnSync('node', ['node_modules/.bin/codimd-cli', 'login']); | ||
} catch (err) { | ||
return done(err); | ||
} | ||
console.log('Importing minutes doc...'); | ||
try { | ||
const result = execSync( | ||
`cat "${filepath}" | node_modules/.bin/codimd-cli` | ||
).toString('utf8'); | ||
// the result will be a string containing a URL. grab it | ||
const url = result.match(/(https:.+?)[\s\S]/)[1]; | ||
if (!url) { | ||
return done(new Error(`Could not parse URL from codimd-cli result:\n${result}`)); | ||
} | ||
body = body | ||
.toString() | ||
.replace( | ||
/\* \*\*Minutes(?:[\s\S]+?)Doc\*\*: <>/, | ||
`* Minutes HackMD Doc: ${url}` | ||
) | ||
.replace(/\* _Previous Minutes(?:[\s\S]+?)Doc: <>_/, ''); | ||
done(null, body); | ||
} catch (err) { | ||
done(err); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
USE_HACKMD=1 | ||
|
||
# $TITLE$ | ||
|
||
## Links | ||
|
||
* **Recording**: | ||
* **Recording**: $RECORDING_URL$ | ||
* **GitHub Issue**: $GITHUB_ISSUE$ | ||
* **Minutes Google Doc**: $MINUTES_DOC$ | ||
* **Minutes Doc**: $MINUTES_DOC$ | ||
|
||
## Present | ||
|
||
$INVITED$ | ||
$OBSERVERS$ | ||
|
||
## Agenda | ||
|
||
## Announcements | ||
|
||
*Extracted from **tooling-agenda** labelled issues and pull requests from the **nodejs org** prior to the meeting. | ||
> Extracted from issues labeled `tooling-agenda` in the [Node.js Tooling Group issue tracker](https://github.com/nodejs/tooling/issues) prior to the meeting. | ||
|
||
$AGENDA_CONTENT$ | ||
|
||
## Q&A, Other | ||
|
||
## Upcoming Meetings | ||
|
||
* **Node.js Foundation Calendar**: https://nodejs.org/calendar | ||
Node.js Tooling Group meetings occur every two (2) weeks. | ||
|
||
* See the [Node.js Foundation Calendar](https://nodejs.org/calendar) | ||
|
||
Click `+GoogleCalendar` at the bottom right to add to your own Google calendar. | ||
|
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.
Does removing the gcal integration remove the auto generation based on google calendar events?
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.
no,
gcal
was just unused