34 lines
891 B
TypeScript
34 lines
891 B
TypeScript
import * as Logger from 'log4js'
|
|
|
|
var exec = require('child-process-promise').exec;
|
|
|
|
Logger.configure({
|
|
appenders:
|
|
{
|
|
"installer": { type: 'stdout' },
|
|
//app: { type: 'file', filename: 'application.log' }
|
|
},
|
|
categories:
|
|
{
|
|
default: { appenders: [ 'installer' ], level: 'debug' }
|
|
}
|
|
})
|
|
const logger = Logger.getLogger("installer")
|
|
|
|
export type NPMPkgName = string
|
|
export type NPMVersion = string
|
|
|
|
export const install = (plugins: Plugin[] = []) => {
|
|
|
|
const npmPkgs = [['sqlite3', '4.1.0'], ['knex', '0.19.2']]
|
|
const deps = npmPkgs.map((pkg) => {return pkg[0] + '@' + pkg[1]} )
|
|
logger.info("Checking npm dependencies..." + deps)
|
|
|
|
exec("npm i --prefix ./plugins " + deps.join(' ')).then(process => {
|
|
|
|
logger.debug(process.stdout)
|
|
const Admin = require("./Admin").FrontblockAdmin
|
|
new Admin(plugins)
|
|
})
|
|
|
|
} |