Permalink
Please sign in to comment.
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...
Showing
with
1,174 additions
and 1,166 deletions.
- +0 −3 .babelrc
- +7 −1 .gitignore
- +0 −1 .npmignore
- 0 History.md → HISTORY.md
- 0 LICENSE → LICENSE.md
- +4 −6 Readme.md → README.md
- +23 −27 bin/slackin
- +27 −23 gulpfile.babel.js
- +152 −152 lib/assets/badge.js
- +59 −61 lib/assets/client.js
- +52 −52 lib/assets/iframe.js
- +567 −570 lib/assets/superagent.js
- +15 −16 lib/badge.js
- +17 −18 lib/iframe.js
- +77 −78 lib/index.js
- +25 −23 lib/log.js
- +18 −19 lib/slack-invite.js
- +52 −53 lib/slack.js
- +58 −59 lib/splash.js
- +21 −4 package.json
| @@ -1,2 +1,8 @@ | ||
| -node | ||
| +# build output | ||
| +dist | ||
| + | ||
| +# dependencies | ||
| node_modules | ||
| + | ||
| +# logs | ||
| +npm-debug.log |
| @@ -1 +0,0 @@ | ||
| -.gitignore |
File renamed without changes.
File renamed without changes.
50
bin/slackin
| @@ -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