-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- bump major version - multicast can now be installed as a global NPM package (addresses #9) - added explanation when run with no arguments - added config interface for initial setup - check if cast is defined before referencing in client.js
- Loading branch information
1 parent
f0c62e8
commit b8dd8c7
Showing
5 changed files
with
169 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
'use strict'; | ||
|
||
const path = require('path') | ||
const fs = require('fs') | ||
const readline = require('readline') | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}) | ||
|
||
const configFile = path.resolve(__dirname, '..', '.config') | ||
|
||
var ask = prompt => { | ||
return new Promise(resolve => { | ||
rl.question(prompt + ' ', res => resolve(res)) | ||
}) | ||
} | ||
|
||
var demand = (prompt, validate) => { | ||
return new Promise(resolve => { | ||
rl.question(prompt + ' ', res => { | ||
if (res != '') { | ||
if (!validate) resolve(res) | ||
else { | ||
if (validate.test(res)) resolve(res) | ||
else demand(prompt, validate).then(res => resolve(res)) | ||
} | ||
} else demand(prompt, validate).then(res => resolve(res)) | ||
}) | ||
}) | ||
} | ||
|
||
var saveOpts = (opts, callback) => { | ||
fs.writeFile(configFile, JSON.stringify(opts, null, 2), callback) | ||
} | ||
|
||
var startConfig = () => { | ||
var opts = {} | ||
|
||
ask('Mongo host? (localhost)').then(res => { | ||
opts.mongoHost = res || 'localhost' | ||
}).then(() => ask('Mongo port? (27017)')).then(res => { | ||
opts.mongoPort = res || 27017 | ||
}).then(() => ask('Mongo username? (none)')).then(res => { | ||
opts.mongoUsername = res || '' | ||
}).then(() => ask('Mongo password? (none)')).then(res => { | ||
opts.mongoPassword = res || '' | ||
}).then(() => ask('Mongo auth DB? (admin)')).then(res => { | ||
opts.mongoAuthDB = res || 'admin' | ||
}).then(() => { | ||
console.log('') | ||
console.log('Now we\'ll configure Chromecast integration.') | ||
}).then(() => demand('Application ID?')).then(res => { | ||
opts.appId = res | ||
}).then(() => { | ||
console.log('') | ||
console.log('Does this look right?') | ||
console.log('') | ||
console.log(opts) | ||
console.log('') | ||
}).then(() => demand('(y/N)', /[yn]/i)).then(res => { | ||
if(/y/i.test(res)) { | ||
saveOpts(opts, () => { | ||
console.log('') | ||
console.log('Configuration updated! To get started, just run\n' + | ||
'\n' + | ||
' multicast start') | ||
}) | ||
rl.close() | ||
} else { | ||
console.log('') | ||
console.log('Alright, let\'s start over.') | ||
console.log('') | ||
startConfig() | ||
} | ||
}) | ||
} | ||
|
||
/* Let's get started! */ | ||
|
||
/* credit to ASCII art goes to patorjk.com/software/taag/ */ | ||
console.log('') | ||
console.log(' W E L C O M E T O') | ||
console.log(` | ||
███╗ ███╗██╗ ██╗██╗ ████████╗██╗ ██████╗ █████╗ ███████╗████████╗ | ||
████╗ ████║██║ ██║██║ ╚══██╔══╝██║██╔════╝██╔══██╗██╔════╝╚══██╔══╝ | ||
██╔████╔██║██║ ██║██║ ██║ ██║██║ ███████║███████╗ ██║ | ||
██║╚██╔╝██║██║ ██║██║ ██║ ██║██║ ██╔══██║╚════██║ ██║ | ||
██║ ╚═╝ ██║╚██████╔╝███████╗██║ ██║╚██████╗██║ ██║███████║ ██║ | ||
╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝ `) | ||
console.log('') | ||
console.log('We\'ll start off by configuring database options. Just press [ENTER] after each.') | ||
|
||
startConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
#!/usr/bin/env node | ||
require('./app/main.js') | ||
if (process.argv.length == 2) { // run with no arguments, display help | ||
console.log('Multicast is a persistent solution to presenting content across multiple Chromecast devices.') | ||
console.log('') | ||
console.log('USAGE: multicast <command> (--flags)') | ||
console.log('') | ||
console.log('Commands:') | ||
console.log(' config run this first to set up Multicast') | ||
console.log(' start start Multicast as a foreground process') | ||
console.log('') | ||
console.log('Flags:') | ||
console.log(' --serve-only do not run the mDNS server (won\'t interrupt existing receivers)') | ||
} else { | ||
if (process.argv.find(arg => arg == 'config')) require('./app/config.js') // run configuration | ||
else require('./app/main.js') // start application | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters