Skip to content

Commit

Permalink
Merge pull request rauchg#124 from jpoon/master
Browse files Browse the repository at this point in the history
Deploy to Azure button
  • Loading branch information
rauchg committed Jan 6, 2016
2 parents 3260d48 + 51887b2 commit 90863ac
Show file tree
Hide file tree
Showing 12 changed files with 419 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
23 changes: 0 additions & 23 deletions Makefile

This file was deleted.

8 changes: 6 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Read more about the [motivations and history](http://rauchg.com/slackin) behind

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/rauchg/slackin/tree/0.7.3)

#### Azure

[![Deploy to Azure](http://azuredeploy.net/deploybutton.svg)](https://azuredeploy.net/)

#### OpenShift

[Follow these instructions.](https://github.com/rauchg/slackin/wiki/OpenShift)
Expand Down Expand Up @@ -137,8 +141,8 @@ install the prerequisite node libraries with npm:
$ npm install
```

After the libraries install, the postinstall script will run make to invoke
babel on the source. It is important to run make manually after updating any
After the libraries install, the postinstall script will run `gulp` to invoke
babel on the source. It is important to run `gulp` manually after updating any
files in lib/ to update the versions in node/.

## Credits
Expand Down
130 changes: 130 additions & 0 deletions azuredeploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"siteName": {
"type": "string",
"metadata": {
"description": "The name of the web app that you wish to create."
}
},
"hostingPlanName": {
"type": "string",
"metadata": {
"description": "The name of the App Service plan to use for hosting the web app."
}
},
"siteLocation": {
"type": "string",
"defaultValue": "West US",
"metadata": {
"description": "The location to use for creating the web app and hosting plan. It must be one of the Azure locations that support web apps."
}
},
"repoURL": {
"type": "string"
},
"branch": {
"type": "string"
},
"slackTeamId" : {
"type": "string",
"metadata": {
"description": "Slack Team ID. (e.g. https://{this}.slack.com)"
}
},
"slackApiToken" : {
"type": "string",
"metadata": {
"description": "Slack API token (find it on https://api.slack.com/web)"
}
},
"slackinRelease" : {
"type": "string",
"allowedValues": [
"stable",
"latest"
],
"defaultValue": "stable",
"metadata": {
"description": "Slackin Release to Deploy (stable/latest)"
}
}
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "[parameters('hostingPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[parameters('siteLocation')]",
"properties": {
},
"sku": {
"name": "F1"
}
},
{
"apiVersion": "2015-08-01",
"name": "[parameters('siteName')]",
"type": "Microsoft.Web/sites",
"location": "[parameters('siteLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
],
"properties": {
"serverFarmId": "[parameters('hostingPlanName')]"
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "web",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
],
"properties": {
"siteProperties": {
"webSocketsEnabled": true
}
}
},
{
"apiVersion": "2015-08-01",
"name": "appsettings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
],
"properties": {
"SLACK_SUBDOMAIN": "[parameters('slackTeamId')]",
"SLACK_API_TOKEN": "[parameters('slackApiToken')]",
"SLACKIN_RELEASE": "[parameters('slackinRelease')]",
"WEBSITE_NPM_DEFAULT_VERSION": "3.3.12",
"WEBSITE_NODE_DEFAULT_VERSION": "5.1.1",
"command": "bash scripts/azuredeploy.sh"
}
},
{
"apiVersion": "2015-08-01",
"name": "web",
"type": "sourcecontrols",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]",
"[concat('Microsoft.Web/Sites/', parameters('siteName'), '/config/web')]"
],
"properties": {
"RepoUrl": "[parameters('repoURL')]",
"branch": "[parameters('branch')]",
"IsManualIntegration": true
}
}
]
}
],
"outputs": {
"siteUri": {
"type": "string",
"value": "[concat('https://',reference(resourceId('Microsoft.Web/sites', parameters('siteName'))).hostNames[0])]"
}
}
}
17 changes: 10 additions & 7 deletions bin/slackin
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env node

var pkg = require('../package');
var pkg = require('./../package');
var program = require('commander');
var slackin = require('../node');
var slackin = require('./../node').default;

program
.version(pkg.version)
.usage('[options] <team-id> <api-token>')
.option('-p, --port <port>', 'Port to listen on [$PORT or 3000]', require('hostenv').PORT || 3000)
.option('-h, --hostname <hostname>', 'Hostname to listen on [$HOSTNAME or 0.0.0.0]', require('hostenv').HOSTNAME || '0.0.0.0')
.option('-p, --port <port>', 'Port to listen on [$PORT or 3000]', require('hostenv').PORT || process.env.PORT || 3000)
.option('-h, --hostname <hostname>', 'Hostname to listen on [$HOSTNAME or 0.0.0.0]', require('hostenv').HOSTNAME || process.env.WEBSITE_HOSTNAME || '0.0.0.0')
.option('-c, --channels [<chan>]', 'One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS]', process.env.SLACK_CHANNELS)
.option('-c, --channel <chan>', 'Single channel guest invite (deprecated) [$SLACK_CHANNEL]', process.env.SLACK_CHANNEL)
.option('-i, --interval <int>', 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 5000]', process.env.SLACK_INTERVAL || 5000)
Expand All @@ -18,11 +18,14 @@ program
.option('-c, --css <file>', 'Full URL to a custom CSS file to use on the main page')
.parse(process.argv);

if (program.args.length != 2) {
var org = program.args[0] || process.env.SLACK_SUBDOMAIN;
var token = program.args[1] || process.env.SLACK_API_TOKEN;

if (!org || !token) {
program.help();
} else {
program.org = program.args[0];
program.token = program.args[1];
program.org = org;
program.token = token;
}

// support deprecated option
Expand Down
30 changes: 30 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

import gulp from 'gulp';
import babel from 'gulp-babel';
import rimraf from 'gulp-rimraf';

const paths = {
in_js: "lib/*.js",
in_assets: "lib/assets/*",
out_js: "node",
out_assets: "node/assets",
};

gulp.task('es6to5', () => {
return gulp.src(paths.in_js)
.pipe(babel())
.pipe(gulp.dest(paths.out_js));
});

gulp.task('copyassets', () => {
return gulp.src(paths.in_assets)
.pipe(gulp.dest(paths.out_assets));
});

gulp.task('clean', () => {
return gulp.src(paths.out_js, { read: false })
.pipe(rimraf());
});

gulp.task('default', ['es6to5', 'copyassets']);
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// es6 runtime requirements
require('babel/polyfill');
require('babel-polyfill');

// their code
import express from 'express';
Expand Down
5 changes: 4 additions & 1 deletion lib/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ export default function log(slack, silent){
}

function out(...args){
if (args) {
args[0] = `${new Date}${args[0]}`;
}

if (silent) return debug(...args);
args[0] = `${new Date}${args[0]}`;
console.log(...args);
}
}
1 change: 1 addition & 0 deletions lib/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { EventEmitter } from 'events';
export default class SlackData extends EventEmitter {

constructor({ token, interval, org: host }){
super();
this.host = host;
this.token = token;
this.interval = interval;
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
"version": "0.7.3",
"description": "",
"dependencies": {
"babel": "4.7.1",
"babel-core": "6.3.26",
"babel-preset-es2015": "6.3.13",
"babel-polyfill": "6.3.14",
"body-parser": "1.10.2",
"commander": "2.6.0",
"debug": "2.1.1",
"email-regex": "1.0.0",
"express": "4.11.0",
"gulp": "3.9.0",
"gulp-babel": "6.1.1",
"gulp-rimraf": "0.2.0",
"hostenv": "1.0.1",
"opentype.js": "0.4.4",
"socket.io": "1.3.6",
Expand All @@ -29,7 +34,7 @@
},
"scripts": {
"test": "mocha",
"postinstall": "make",
"start": "./bin/slackin $SLACK_SUBDOMAIN $SLACK_API_TOKEN"
"postinstall": "gulp",
"start": "node ./bin/slackin"
}
}
Loading

0 comments on commit 90863ac

Please sign in to comment.