Merge pull request #579 from lbryio/560-ip-address
added node-ip and updated CLI
This commit is contained in:
commit
89f6ad9bce
9 changed files with 61 additions and 14 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -15,8 +15,7 @@ client_custom/src/pages
|
|||
devConfig/sequelizeCliConfig.js
|
||||
devConfig/testingConfig.js
|
||||
|
||||
config/mysqlConfig.json
|
||||
config/siteConfig.json
|
||||
config/
|
||||
|
||||
public/bundle/bundle.js
|
||||
public/bundle/bundle.js.map
|
||||
|
|
|
@ -34,8 +34,6 @@ $ npm install
|
|||
$ npm run configure
|
||||
```
|
||||
|
||||
Add your ip address in `config/siteConfig.json`
|
||||
|
||||
#### Build & start the app
|
||||
|
||||
_note: make sure lbry is running in the background before proceeding_
|
||||
|
|
|
@ -2,6 +2,7 @@ const inquirer = require('inquirer');
|
|||
const fs = require('fs');
|
||||
const Path = require('path');
|
||||
const axios = require('axios');
|
||||
const ip = require('ip');
|
||||
|
||||
const mysqlQuestions = require(Path.resolve(__dirname, 'questions/mysqlQuestions.js'));
|
||||
const siteQuestions = require(Path.resolve(__dirname, 'questions/siteQuestions.js'));
|
||||
|
@ -11,6 +12,14 @@ let thumbnailChannelDefault = '@thumbnails';
|
|||
let thumbnailChannel = '';
|
||||
let thumbnailChannelId = '';
|
||||
|
||||
const createConfigFile = (fileName, configObject) => { // siteConfig.json , siteConfig
|
||||
const fileLocation = Path.resolve(__dirname, `../config/${fileName}`);
|
||||
const fileContents = JSON.stringify(configObject, null, 2);
|
||||
fs.writeFileSync(fileLocation, fileContents, 'utf-8');
|
||||
console.log(`Successfully created /config/${fileName}\n`);
|
||||
};
|
||||
|
||||
// import existing configs or import the defaults
|
||||
let mysqlConfig;
|
||||
try {
|
||||
mysqlConfig = require('../config/mysqlConfig.json');
|
||||
|
@ -36,14 +45,33 @@ const {
|
|||
},
|
||||
} = siteConfig;
|
||||
|
||||
let lbryConfig;
|
||||
try {
|
||||
lbryConfig = require('../config/lbryConfig.json');
|
||||
} catch (error) {
|
||||
lbryConfig = require('./defaults/lbryConfig.json');
|
||||
}
|
||||
|
||||
let loggerConfig;
|
||||
try {
|
||||
loggerConfig = require('../config/loggerConfig.json');
|
||||
} catch (error) {
|
||||
loggerConfig = require('./defaults/loggerConfig.json');
|
||||
}
|
||||
|
||||
let slackConfig;
|
||||
try {
|
||||
slackConfig = require('../config/slackConfig.json');
|
||||
} catch (error) {
|
||||
slackConfig = require('./defaults/slackConfig.json');
|
||||
}
|
||||
|
||||
// ask user questions and create config files
|
||||
inquirer
|
||||
.prompt(mysqlQuestions(mysqlDatabase, mysqlUsername, mysqlPassword))
|
||||
.then(results => {
|
||||
console.log('\nCreating mysql config file...');
|
||||
const fileLocation = Path.resolve(__dirname, '../config/mysqlConfig.json');
|
||||
const fileContents = JSON.stringify(results, null, 2);
|
||||
fs.writeFileSync(fileLocation, fileContents, 'utf-8');
|
||||
console.log('Successfully created /config/mysqlConfig.json!\n');
|
||||
createConfigFile('mysqlConfig.json', results);
|
||||
})
|
||||
.then(() => {
|
||||
// check for lbrynet connection & retrieve a default address
|
||||
|
@ -158,15 +186,19 @@ inquirer
|
|||
siteConfig['details']['port'] = results.port;
|
||||
siteConfig['details']['title'] = results.title;
|
||||
siteConfig['details']['host'] = results.host;
|
||||
siteConfig['details']['ipAddress'] = ip.address();
|
||||
siteConfig['publishing']['uploadDirectory'] = results.uploadDirectory;
|
||||
const fileLocation = Path.resolve(__dirname, '../config/siteConfig.json');
|
||||
const fileContents = JSON.stringify(siteConfig, null, 2);
|
||||
fs.writeFileSync(fileLocation, fileContents, 'utf-8');
|
||||
console.log('Successfully created /config/siteConfig.json\n');
|
||||
})
|
||||
.then(() => {
|
||||
// create the config files
|
||||
createConfigFile('siteConfig.json', siteConfig);
|
||||
createConfigFile('lbryConfig.json', lbryConfig);
|
||||
createConfigFile('loggerConfig.json', loggerConfig);
|
||||
createConfigFile('slackConfig.json', slackConfig);
|
||||
})
|
||||
.then(() => {
|
||||
console.log('\nYou\'re all done!');
|
||||
console.log('Next step: run "npm run build" to build your server, then "npm run start" to start your server!');
|
||||
console.log('Next step: run "npm run start" to build and start your server!');
|
||||
console.log('If you want to change any settings, you can edit the files in the "/config" folder.');
|
||||
process.exit(0);
|
||||
})
|
||||
|
|
5
cli/defaults/lbryConfig.json
Normal file
5
cli/defaults/lbryConfig.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"apiHost": "localhost",
|
||||
"apiPort": "5279",
|
||||
"getTimeout": 30
|
||||
}
|
3
cli/defaults/loggerConfig.json
Normal file
3
cli/defaults/loggerConfig.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"logLevel": "verbose"
|
||||
}
|
5
cli/defaults/slackConfig.json
Normal file
5
cli/defaults/slackConfig.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"slackWebHook": false,
|
||||
"slackErrorChannel": false,
|
||||
"slackInfoChannel": false
|
||||
}
|
|
@ -131,7 +131,6 @@ Check your site configs
|
|||
$ cd config/
|
||||
$ nano siteConfig.json
|
||||
```
|
||||
add your ip address in `config/siteConfig.json`
|
||||
|
||||
### Build & run
|
||||
|
||||
|
|
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -6677,6 +6677,11 @@
|
|||
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",
|
||||
"integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY="
|
||||
},
|
||||
"ip": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
|
||||
"integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo="
|
||||
},
|
||||
"ip-regex": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz",
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
"helmet": "^3.13.0",
|
||||
"image-size": "^0.6.3",
|
||||
"inquirer": "^5.2.0",
|
||||
"ip": "^1.1.5",
|
||||
"make-dir": "^1.3.0",
|
||||
"module-alias": "^2.1.0",
|
||||
"mysql2": "^1.6.1",
|
||||
|
|
Loading…
Reference in a new issue