🎨 Update files structure
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"debug": false,
|
||||
"port": 1571,
|
||||
"maxFileSize": 99999,
|
||||
"exclude":
|
||||
[
|
||||
"**/.DS_Store",
|
||||
"node_modules/**",
|
||||
"vendor/**",
|
||||
".git"
|
||||
]
|
||||
}
|
||||
+2
-2
@@ -2,5 +2,5 @@
|
||||
|
||||
'use strict'
|
||||
|
||||
const Keppler = require('./keppler.class.js')
|
||||
const keppler = new Keppler()
|
||||
const App = require('../lib/app')
|
||||
const app = new App()
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
// Depedencies
|
||||
const ip = require('ip')
|
||||
const Site = require('../site/site.class.js')
|
||||
const Watcher = require('../watcher/watcher.class.js')
|
||||
const defaultConfig = require('./config.default.json')
|
||||
|
||||
/**
|
||||
* Keppler class
|
||||
*/
|
||||
class Keppler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
constructor(_options)
|
||||
{
|
||||
this.setArguments()
|
||||
this.setOptions(_options)
|
||||
this.setSite()
|
||||
this.setWatcher()
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options
|
||||
*/
|
||||
setOptions(_options)
|
||||
{
|
||||
const options = typeof _options === 'object' ? _options : {}
|
||||
|
||||
// Defaults
|
||||
if(typeof options.debug === 'undefined')
|
||||
{
|
||||
if(this.arguments.length > 1)
|
||||
{
|
||||
options.debug = this.arguments[ this.arguments.length - 1 ] === 'true'
|
||||
}
|
||||
else
|
||||
{
|
||||
options.debug = defaultConfig.debug
|
||||
}
|
||||
}
|
||||
|
||||
if(typeof options.port === 'undefined')
|
||||
{
|
||||
options.port = defaultConfig.port
|
||||
}
|
||||
|
||||
if(typeof options.domain === 'undefined')
|
||||
{
|
||||
options.domain = `http://${ip.address()}:${options.port}`
|
||||
}
|
||||
|
||||
if(typeof options.maxFileSize === 'undefined')
|
||||
{
|
||||
options.maxFileSize = defaultConfig.maxFileSize
|
||||
}
|
||||
|
||||
if(typeof options.exclude === 'undefined')
|
||||
{
|
||||
options.exclude = defaultConfig.exclude
|
||||
}
|
||||
|
||||
// Save
|
||||
this.options = options
|
||||
}
|
||||
|
||||
/**
|
||||
* Set arguments
|
||||
* Retrieve arguments and test if missing
|
||||
*/
|
||||
setArguments()
|
||||
{
|
||||
// Set up
|
||||
this.arguments = process.argv.slice(2)
|
||||
|
||||
// Missing project name
|
||||
if(this.arguments.length === 0)
|
||||
{
|
||||
// Stop process
|
||||
throw new Error('Missing arguments: first argument should be the projet name'.red)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set site
|
||||
* Instantiate site
|
||||
*/
|
||||
setSite()
|
||||
{
|
||||
this.site = new Site({
|
||||
port : this.options.port,
|
||||
domain: this.options.domain,
|
||||
debug : this.options.debug
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Set watcher
|
||||
* Instantiate watcher
|
||||
*/
|
||||
setWatcher()
|
||||
{
|
||||
this.watcher = new Watcher({
|
||||
port : this.options.port,
|
||||
domain : this.options.domain,
|
||||
debug : this.options.debug,
|
||||
maxFileSize: this.options.maxFileSize,
|
||||
exclude : this.options.exclude,
|
||||
name : this.arguments[ 0 ]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Keppler
|
||||
Reference in New Issue
Block a user