Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
charset = utf-8
max_line_length = 120
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules/
/npm-debug.log
/se-edu-bot-*.tgz
/dist/
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js

node_js:
- "7"

script: npm run all build lint
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2017 seedu-bot contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npm start
124 changes: 124 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
= se-edu-bot
:toc: preamble
:toc-title:
:sectnums:
ifdef::env-github[]
:tip-caption: :bulb:
:note-caption: :information_source:
endif::[]
ifdef::env-github,env-browser[:outfilesuffix: .adoc]

Helps out with managing SE-EDU projects.

== Local development setup

=== Prerequisites

. Node `7.9.0` or later.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Need to specify required npm version as well.

. An editor with Typescript language service support is strongly recommended.
(e.g. https://code.visualstudio.com/[VS Code])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe add a Recommended editors section.

Note that for VSCode, the editorconfig plugin must be installed for it to respect .editorconfig files.

. https://ngrok.com/[ngrok]

=== Cloning the repo

. Fork this repo, and clone the fork to your computer.
. `cd` into the project directory.
. Run `npm install` to install dependencies.

=== Setting up ngrok

We use https://ngrok.com/[ngrok] to expose our local server to the internet for Webhook testing.
Run

----
ngrok http 5000
----

You should see a line like this:

----
Forwarding https://abcdefg123.ngrok.io -> localhost:5000
----

This is your temporary ngrok URL which exposes your local server to the internet.
It is valid until the `ngrok` process terminates.
Take note of it, we'll use it in later steps.

=== Building the project

* Build the project once.
+
[source,shell]
----
npm run build
----

* Do a clean build.
+
[source,shell]
----
npm run all clean build
----

=== Running the server

The project must be built first (`npm run build`).

* Run the server
+
[source,shell]
----
npm start
----

* Run the server and watch for changes,
incrementally rebuilding the project and restarting the server whenever source files change.
+
[source,shell]
----
npm run watch
----

The server should be accessible via your ngrok address which you got in <<Setting up ngrok>>.

=== Linting

[source,shell]
----
npm run lint
----

=== Cleaning build products

[source,shell]
----
npm run clean
----

== Deploying to Heroku

This repository is setup to automatically deploy to Heroku whenever new commits are pushed to `master`.
As such, there is no need for any manual deployment.

Below is a guide for setting up the Heroku application from scratch should there be any need to (e.g. for testing).

=== Setting up the Heroku application from scratch

. Go to the https://dashboard.heroku.com[Heroku dashboard] and login.
. `New` -> `Create new App`.
. Enter the app name (i.e. `se-edu-bot`) and click `Create App`.
. Under `Deployment method`, select `Github`.
. If Heroku Dashboard does not have access to your GitHub account,
it will display a single `Connect to GitHub` button.
Click on it, and then authorize the Heroku Dashboard to access your GitHub account and `se-edu` organization.
. Follow the instructions to connect the Heroku app to the `se-edu/se-edu-bot` repo.
. Ensure the `Wait for CI to pass before deploy` checkbox is checked, and then click `Enable Automatic Deploys`.
. Go to `Settings` -> `Config Variables`, and set `NPM_CONFIG_PRODUCTION` to `false`.

== Coding standard

We follow the oss-generic coding standard.

== License

MIT License
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "se-edu-bot",
"description": "Helps out with SE-EDU tasks",
"license": "MIT",
"private": true,
"engines": {
"node": ">=7.9.0"
},
"files": [
"dist"
],
"scripts": {
"all": "npm-run-all",
"build": "tsc",
"postinstall": "npm run build",
"start": "node dist/server.js",
"watch:tsc": "tsc -w",
"watch:server": "nodemon --watch dist dist/server.js",
"watch": "npm-run-all --parallel \"watch:*\"",
"clean": "rimraf dist",
"lint": "tslint -p tsconfig.json --type-check"
},
"devDependencies": {
"@types/node": "^7.0.31",
"nodemon": "^1.11.0",
"npm-run-all": "^4.0.2",
"rimraf": "^2.6.1",
"tslint": "^5.4.3",
"tslint-language-service": "^0.9.6",
"typescript": "^2.3.4"
}
}
3 changes: 3 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (require.main === module) {
console.log('Hello world!');
}
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"newLine": "LF",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "dist",
"plugins": [
{"name": "tslint-language-service"}
],
"pretty": true,
"sourceMap": true,
"strict": true,
"target": "ES2017"
}
}
81 changes: 81 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"defaultSeverity": "error",
"lintOptions": {
"typeCheck": true
},
"rules": {
"adjacent-overload-signatures": true,
"await-promise": true,
"class-name": true,
"comment-format": [true, "check-space"],
"curly": true,
"eofline": true,
"indent": [true, "spaces", 4],
"linebreak-style": [true, "LF"],
"max-line-length": [true, 120],
"member-access": [true, "no-public"],
"member-ordering": [true, {
"order": [
"public-static-field",
"protected-static-field",
"private-static-field",
"public-instance-field",
"protected-instance-field",
"private-instance-field",
"constructor",
"public-static-method",
"protected-static-method",
"private-static-method",
"public-instance-method",
"protected-instance-method",
"private-instance-method"
]
}],
"no-consecutive-blank-lines": true,
"no-floating-promises": true,
"no-inferrable-types": [true, "ignore-params", "ignore-properties"],
"no-trailing-whitespace": true,
"no-var-keyword": true,
"object-literal-sort-keys": true,
"only-arrow-functions": [true, "allow-declarations"],
"ordered-imports": true,
"prefer-const": true,
"prefer-template": [true, "allow-single-concat"],
"promise-function-async": true,
"quotemark": [true, "single"],
"semicolon": [true, "always"],
"space-before-function-paren": [ true, {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}],
"trailing-comma": [true, {"multiline": "always", "singleline": "never"}],
"triple-equals": true,
"typedef": [true, "call-signature", "parameter", "property-declaration"],
"typedef-whitespace": [true, {
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}, {
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-type",
"check-typecast",
"check-preblock"
]
},
"rulesDirectory": []
}