Convert to Packagable Syntax
parent
6b8b9d85d3
commit
9c566644a1
|
@ -11,3 +11,4 @@ dbdata
|
|||
npm-debug.log
|
||||
shinobi.sqlite
|
||||
package-lock.json
|
||||
dist
|
||||
|
|
78
camera.js
78
camera.js
|
@ -9,82 +9,78 @@
|
|||
// PayPal : paypal@m03.ca
|
||||
//
|
||||
var io = new (require('socket.io'))()
|
||||
//library loader
|
||||
var loadLib = function(lib){
|
||||
return require(__dirname+'/libs/'+lib+'.js')
|
||||
}
|
||||
//process handlers
|
||||
var s = loadLib('process')(process,__dirname)
|
||||
var s = require('./libs/process.js')(process,__dirname)
|
||||
//load extender functions
|
||||
loadLib('extenders')(s)
|
||||
require('./libs/extenders.js')(s)
|
||||
//configuration loader
|
||||
var config = loadLib('config')(s)
|
||||
var config = require('./libs/config.js')(s)
|
||||
//basic functions
|
||||
loadLib('basic')(s,config)
|
||||
require('./libs/basic.js')(s,config)
|
||||
//language loader
|
||||
var lang = loadLib('language')(s,config)
|
||||
var lang = require('./libs/language.js')(s,config)
|
||||
//working directories : videos, streams, fileBin..
|
||||
loadLib('folders')(s,config,lang)
|
||||
require('./libs/folders.js')(s,config,lang)
|
||||
//code test module
|
||||
loadLib('codeTester')(s,config,lang)
|
||||
require('./libs/codeTester.js')(s,config,lang)
|
||||
//get version
|
||||
loadLib('version')(s,config,lang)
|
||||
require('./libs/version.js')(s,config,lang)
|
||||
//video processing engine
|
||||
loadLib('ffmpeg')(s,config,lang,function(ffmpeg){
|
||||
require('./libs/ffmpeg.js')(s,config,lang,function(ffmpeg){
|
||||
//ffmpeg coProcessor
|
||||
loadLib('ffmpegCoProcessor')(s,config,lang,ffmpeg)
|
||||
require('./libs/ffmpegCoProcessor.js')(s,config,lang,ffmpeg)
|
||||
//database connection : mysql, sqlite3..
|
||||
loadLib('sql')(s,config)
|
||||
require('./libs/sql.js')(s,config)
|
||||
//authenticator functions : API, dashboard login..
|
||||
loadLib('auth')(s,config,lang)
|
||||
require('./libs/auth.js')(s,config,lang)
|
||||
//express web server with ejs
|
||||
var app = loadLib('webServer')(s,config,lang,io)
|
||||
var app = require('./libs/webServer.js')(s,config,lang,io)
|
||||
//web server routes : page handling..
|
||||
loadLib('webServerPaths')(s,config,lang,app,io)
|
||||
require('./libs/webServerPaths.js')(s,config,lang,app,io)
|
||||
//web server routes for streams : streams..
|
||||
loadLib('webServerStreamPaths')(s,config,lang,app,io)
|
||||
require('./libs/webServerStreamPaths.js')(s,config,lang,app,io)
|
||||
//web server admin routes : create sub accounts, share monitors, share videos
|
||||
loadLib('webServerAdminPaths')(s,config,lang,app,io)
|
||||
require('./libs/webServerAdminPaths.js')(s,config,lang,app,io)
|
||||
//web server superuser routes : create admin accounts and manage system functions
|
||||
loadLib('webServerSuperPaths')(s,config,lang,app,io)
|
||||
require('./libs/webServerSuperPaths.js')(s,config,lang,app,io)
|
||||
//websocket connection handlers : login and streams..
|
||||
loadLib('socketio')(s,config,lang,io)
|
||||
require('./libs/socketio.js')(s,config,lang,io)
|
||||
//user and group functions
|
||||
loadLib('user')(s,config,lang)
|
||||
require('./libs/user.js')(s,config,lang)
|
||||
//timelapse functions
|
||||
loadLib('timelapse')(s,config,lang,app,io)
|
||||
require('./libs/timelapse.js')(s,config,lang,app,io)
|
||||
//fileBin functions
|
||||
loadLib('fileBin')(s,config,lang,app,io)
|
||||
require('./libs/fileBin.js')(s,config,lang,app,io)
|
||||
//monitor/camera handlers
|
||||
loadLib('monitor')(s,config,lang)
|
||||
require('./libs/monitor.js')(s,config,lang)
|
||||
//event functions : motion, object matrix handler
|
||||
loadLib('events')(s,config,lang)
|
||||
require('./libs/events.js')(s,config,lang)
|
||||
//recording functions
|
||||
loadLib('videos')(s,config,lang)
|
||||
require('./libs/videos.js')(s,config,lang)
|
||||
//branding functions and config defaults
|
||||
loadLib('videoDropInServer')(s,config,lang,app,io)
|
||||
require('./libs/videoDropInServer.js')(s,config,lang,app,io)
|
||||
//plugins : websocket connected services..
|
||||
loadLib('plugins')(s,config,lang,io)
|
||||
require('./libs/plugins.js')(s,config,lang,io)
|
||||
//health : cpu and ram trackers..
|
||||
loadLib('health')(s,config,lang,io)
|
||||
require('./libs/health.js')(s,config,lang,io)
|
||||
//cluster module
|
||||
loadLib('childNode')(s,config,lang,app,io)
|
||||
require('./libs/childNode.js')(s,config,lang,app,io)
|
||||
//cloud uploaders : amazon s3, webdav, backblaze b2..
|
||||
loadLib('uploaders')(s,config,lang)
|
||||
require('./libs/uploaders.js')(s,config,lang)
|
||||
//notifiers : discord..
|
||||
loadLib('notification')(s,config,lang)
|
||||
require('./libs/notification.js')(s,config,lang)
|
||||
//notifiers : discord..
|
||||
loadLib('rtmpserver')(s,config,lang)
|
||||
require('./libs/rtmpserver.js')(s,config,lang)
|
||||
//dropInEvents server (file manipulation to create event trigger)
|
||||
loadLib('dropInEvents')(s,config,lang,app,io)
|
||||
require('./libs/dropInEvents.js')(s,config,lang,app,io)
|
||||
//form fields to drive the internals
|
||||
loadLib('definitions')(s,config,lang,app,io)
|
||||
require('./libs/definitions.js')(s,config,lang,app,io)
|
||||
//branding functions and config defaults
|
||||
loadLib('branding')(s,config,lang,app,io)
|
||||
require('./libs/branding.js')(s,config,lang,app,io)
|
||||
//custom module loader
|
||||
loadLib('customAutoLoad')(s,config,lang,app,io)
|
||||
require('./libs/customAutoLoad.js')(s,config,lang,app,io)
|
||||
//scheduling engine
|
||||
loadLib('scheduler')(s,config,lang,app,io)
|
||||
require('./libs/scheduler.js')(s,config,lang,app,io)
|
||||
//on-start actions, daemon(s) starter
|
||||
loadLib('startup')(s,config,lang)
|
||||
require('./libs/startup.js')(s,config,lang)
|
||||
})
|
||||
|
|
|
@ -46,7 +46,7 @@ module.exports = function(s,config,lang){
|
|||
}
|
||||
],null,3))
|
||||
setTimeout(function(){
|
||||
require(s.mainDirectory + '/test/run.js')(s,config,lang,io)
|
||||
require('../test/run.js')(s,config,lang,io)
|
||||
},500)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,11 @@ module.exports = function(s){
|
|||
config : s.mainDirectory+'/conf.json',
|
||||
languages : s.mainDirectory+'/languages'
|
||||
}
|
||||
var config = require(s.location.config);
|
||||
try{
|
||||
var config = require(s.location.config)
|
||||
}catch(err){
|
||||
var config = {}
|
||||
}
|
||||
if(!config.productType){
|
||||
config.productType = 'CE'
|
||||
}
|
||||
|
|
|
@ -1034,7 +1034,7 @@ module.exports = function(s,config,lang,onFinish){
|
|||
}
|
||||
},null,3),'utf8')
|
||||
var cameraCommandParams = [
|
||||
s.mainDirectory + '/libs/cameraThread/singleCamera.js',
|
||||
'./libs/cameraThread/singleCamera.js',
|
||||
config.ffmpegDir,
|
||||
e.sdir + 'cmd.txt'
|
||||
]
|
||||
|
|
|
@ -31,7 +31,7 @@ module.exports = function(process,__dirname){
|
|||
//UTC Offset
|
||||
utcOffset : require('moment')().utcOffset(),
|
||||
//directory path for this file
|
||||
mainDirectory : __dirname
|
||||
mainDirectory : process.cwd()
|
||||
}
|
||||
s.packageJson = packageJson
|
||||
if(packageJson.mainDirectory){
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
module.exports = function(s,config,lang){
|
||||
s.uploaderFields = []
|
||||
var loadLib = function(lib){
|
||||
var uploadersFolder = __dirname + '/uploaders/'
|
||||
var libraryPath = uploadersFolder + lib + '.js'
|
||||
var loadedLib = require(libraryPath)(s,config,lang)
|
||||
if(lib !== 'loader'){
|
||||
loadedLib.isFormGroupGroup = true
|
||||
s.uploaderFields.push(loadedLib)
|
||||
}
|
||||
return loadedLib
|
||||
require('./uploaders/loader.js')(s,config,lang)
|
||||
const loadedLibraries = {
|
||||
//cloud storage
|
||||
s3based: require('./uploaders/s3based.js'),
|
||||
backblazeB2: require('./uploaders/backblazeB2.js'),
|
||||
amazonS3: require('./uploaders/amazonS3.js'),
|
||||
webdav: require('./uploaders/webdav.js'),
|
||||
//simple storage
|
||||
sftp: require('./uploaders/sftp.js'),
|
||||
}
|
||||
loadLib('loader')
|
||||
//cloud storage
|
||||
loadLib('s3based')
|
||||
loadLib('backblazeB2')
|
||||
loadLib('amazonS3')
|
||||
loadLib('webdav')
|
||||
//simple storage
|
||||
loadLib('sftp')
|
||||
Object.keys(loadedLibraries).forEach((key) => {
|
||||
var loadedLib = loadedLibraries[key](s,config,lang)
|
||||
loadedLib.isFormGroupGroup = true
|
||||
s.uploaderFields.push(loadedLib)
|
||||
})
|
||||
}
|
||||
|
|
45
package.json
45
package.json
|
@ -4,12 +4,6 @@
|
|||
"version": "2.0.0",
|
||||
"description": "CCTV and NVR in Node.js",
|
||||
"main": "camera.js",
|
||||
"bin": "camera.js",
|
||||
"scripts": {
|
||||
"dev": "nodemon --inspect camera.js",
|
||||
"test": "node camera.js test",
|
||||
"start": "chmod +x INSTALL/start.sh && INSTALL/start.sh"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://gitlab.com/Shinobi-Systems/Shinobi.git"
|
||||
|
@ -18,18 +12,6 @@
|
|||
"bugs": {
|
||||
"url": "https://gitlab.com/Shinobi-Systems/Shinobi/issues"
|
||||
},
|
||||
"pkg": {
|
||||
"assets": [
|
||||
"libs/**/*",
|
||||
"libs/**/**/*",
|
||||
"libs/**/**/**/*",
|
||||
"libs/**/**/**/**/*",
|
||||
"languages/*",
|
||||
"web/*",
|
||||
"node_modules/ffmpeg-static/*",
|
||||
"definitions/*"
|
||||
]
|
||||
},
|
||||
"homepage": "https://gitlab.com/Shinobi-Systems/Shinobi#readme",
|
||||
"dependencies": {
|
||||
"async": "^3.1.0",
|
||||
|
@ -65,10 +47,29 @@
|
|||
"express-fileupload": "^1.1.6-alpha.6",
|
||||
"tree-kill":"1.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^1.19.1"
|
||||
"devDependencies": {},
|
||||
"bin": "camera.js",
|
||||
"scripts": {
|
||||
"test": "node camera.js test",
|
||||
"start": "chmod +x INSTALL/start.sh && INSTALL/start.sh",
|
||||
"package": "pkg package.json -t linux,macos,win --out-path dist",
|
||||
"package-x64": "pkg package.json -t linux-x64,macos-x64,win-x64 --out-path dist/x64",
|
||||
"package-x86": "pkg package.json -t linux-x86,macos-x86,win-x86 --out-path dist/x86",
|
||||
"package-armv6": "pkg package.json -t linux-armv6,macos-armv6,win-armv6 --out-path dist/armv6",
|
||||
"package-armv7": "pkg package.json -t linux-armv7,macos-armv7,win-armv7 --out-path dist/armv7",
|
||||
"package-all": "npm run package && npm run package-x64 && npm run package-x86 && npm run package-armv6 && npm run package-armv7"
|
||||
},
|
||||
"nodemonConfig": {
|
||||
"ignore": ["plugins/*"]
|
||||
"pkg": {
|
||||
"targets": [
|
||||
"node12"
|
||||
],
|
||||
"scripts": [
|
||||
],
|
||||
"assets": [
|
||||
"definitions/*",
|
||||
"languages/*",
|
||||
"web/*",
|
||||
"test/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue