35 lines
957 B
TypeScript
35 lines
957 B
TypeScript
import * as Logger from 'log4js'
|
|
import { Plugin } from "frontblock-generic/Plugin"
|
|
|
|
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:[NPMPkgName, NPMVersion][] = [['sqlite3', '4.1.0'], ['knex', '0.19.2']]
|
|
const deps = npmPkgs.map(tuple => tuple.join('@') ).join(" ")
|
|
logger.info("Installing plaform dependencies: "+deps)
|
|
|
|
exec("npm i --prefix ./plugins " + deps).then(process => {
|
|
|
|
logger.debug(process.stdout)
|
|
const Admin = require("./Admin").FrontblockAdmin
|
|
new Admin(plugins)
|
|
})
|
|
|
|
} |