Permalink
Browse files

Switch to args, lint code and clean up (#200)

* Hide npm warnings

* Use args instead of commander

* Consitant naming

* Ignore stuff

* Put babel config into package.json

* Lint code

* Adjust code to get linted

* npm does this by default

* Proper task naming

* Proper name for build output

* Pin dependencies

* Updated eslint-config-default
  • Loading branch information...
leo authored and rauchg committed Jun 17, 2016
1 parent 4ea80c4 commit c54b6786ea71edc25af36335bcbc6c5c6fbb57e7
Showing with 1,174 additions and 1,166 deletions.
  1. +0 −3 .babelrc
  2. +7 −1 .gitignore
  3. +0 −1 .npmignore
  4. 0 History.md → HISTORY.md
  5. 0 LICENSE → LICENSE.md
  6. +4 −6 Readme.md → README.md
  7. +23 −27 bin/slackin
  8. +27 −23 gulpfile.babel.js
  9. +152 −152 lib/assets/badge.js
  10. +59 −61 lib/assets/client.js
  11. +52 −52 lib/assets/iframe.js
  12. +567 −570 lib/assets/superagent.js
  13. +15 −16 lib/badge.js
  14. +17 −18 lib/iframe.js
  15. +77 −78 lib/index.js
  16. +25 −23 lib/log.js
  17. +18 −19 lib/slack-invite.js
  18. +52 −53 lib/slack.js
  19. +58 −59 lib/splash.js
  20. +21 −4 package.json

This file was deleted.

Oops, something went wrong.
@@ -1,2 +1,8 @@
node
# build output
dist
# dependencies
node_modules
# logs
npm-debug.log

This file was deleted.

Oops, something went wrong.
File renamed without changes.
File renamed without changes.
@@ -1,8 +1,6 @@
# slackin
A little server that enables public access
to a Slack server. Like Freenode, but on Slack.
A little server that enables public access to a Slack server. Like Freenode, but on Slack.
It provides
@@ -136,16 +134,16 @@ By default logging is enabled.
## Developing
Slackin's server side code is written in ES6. It uses babel to transpile the
ES6 code to a format node understands. After cloning Slackin, you should
Slackin's server side code is written in ES6. It uses babel to transpile the
ES6 code to a format node understands. After cloning Slackin, you should
install the prerequisite node libraries with npm:
```bash
$ npm install
```
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
babel on the source. It is important to run `gulp` manually after updating any
files in lib/ to update the versions in node/.
## Credits
@@ -1,41 +1,37 @@
#!/usr/bin/env node
var pkg = require('./../package');
var program = require('commander');
var args = require('args');
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 || 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)
.option('-P, --path <path>', 'Path to serve slackin under', '/')
.option('-s, --silent', 'Do not print out warns or errors')
.option('-C, --coc <coc>', 'Full URL to a CoC that needs to be agreed to')
.option('-c, --css <file>', 'Full URL to a custom CSS file to use on the main page')
.parse(process.argv);
args
.option(['p', 'port'], 'Port to listen on [$PORT or 3000]', require('hostenv').PORT || process.env.PORT || 3000)
.option(['h', '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'], 'One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS]', process.env.SLACK_CHANNELS)
.option(['i', 'interval'], 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 5000]', process.env.SLACK_INTERVAL || 5000)
.option(['P', 'path'], 'Path to serve slackin under', '/')
.option(['s', 'silent'], 'Do not print out warns or errors')
.option(['C', 'coc'], 'Full URL to a CoC that needs to be agreed to')
.option(['S', 'css'], 'Full URL to a custom CSS file to use on the main page');
var org = program.args[0] || process.env.SLACK_SUBDOMAIN;
var token = program.args[1] || process.env.SLACK_API_TOKEN;
var flags = args.parse(process.argv, {
value: '<team-id> <api-token>'
});
var org = args.sub[0] || process.env.SLACK_SUBDOMAIN;
var token = args.sub[1] || process.env.SLACK_API_TOKEN;
if (!org || !token) {
program.help();
args.showHelp();
} else {
program.org = org;
program.token = token;
flags.org = org;
flags.token = token;
}
// support deprecated option
if (!program.channels && program.channel) {
program.channels = program.channel;
}
var port = flags.port;
var hostname = flags.hostname;
var port = program.port;
var hostname = program.hostname;
slackin(program).listen(port, hostname, function(err){
slackin(flags).listen(port, hostname, function(err){
if (err) throw err;
if (!program.silent) console.log('%s – listening on %s:%d', new Date, hostname, port);
if (!flags.silent) console.log('%s – listening on %s:%d', new Date, hostname, port);
});
@@ -1,30 +1,34 @@
'use strict';
import gulp from 'gulp';
import babel from 'gulp-babel';
import rimraf from 'gulp-rimraf';
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",
};
in: {
js: 'lib/*.js',
assets: 'lib/assets/*'
},
out: {
js: 'dist',
assets: 'dist/assets'
}
}
gulp.task('es6to5', () => {
return gulp.src(paths.in_js)
.pipe(babel())
.pipe(gulp.dest(paths.out_js));
});
gulp.task('transpile', () => {
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('assets', () => {
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());
});
return gulp.src(paths.out.js, {
read: false
})
.pipe(rimraf())
})
gulp.task('default', ['es6to5', 'copyassets']);
gulp.task('default', ['transpile', 'assets'])
Oops, something went wrong.

0 comments on commit c54b678

Please sign in to comment.