Socket
Socket
Sign inDemoInstall

brickyard3

Package Overview
Dependencies
144
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

34

base/brickyard-cli.js

@@ -8,5 +8,2 @@ #!/usr/bin/env node

const packageInfo = require('../package.json')
const butil = require('../lib/util')
const logger = require('../lib/logger')
const _ = require('lodash')

@@ -32,14 +29,2 @@ boot(require('minimist')(process.argv.slice(2)))

if (argv.backlog) {
let logPath = _.isBoolean(argv.backlog) ? 'logs/build.log' : argv.backlog
logger.configure({
appenders: [
{ type: 'console' },
{ type: 'file', filename: logPath, maxLogSize: 1000000, backups: 10 }
],
replaceConsole: true
})
}
app.launch({

@@ -50,2 +35,6 @@ configPath: argv.config

if (argv.backlog) {
brickyard.logger.backlogFile(argv.backlog)
}
if (argv.verbose) {

@@ -59,15 +48,4 @@ brickyard.setLogLevel('debug')

brickyard.cli.load(rootCmd, env.configPath ? require(env.configPath).commands : null)
.spread((cmdName, options) => {
const cmdOptions = butil.assignWithValid({}, options, rootCmd.opts())
const targetCmd = brickyard.cli.commands[cmdName]
brickyard.cli.load(rootCmd, env)
brickyard.load(env.configPath, targetCmd.config)
targetCmd.run(brickyard.hatchRuntime(cmdOptions))
})
.catch((e) => {
throw e
})
rootCmd.parse(process.argv)

@@ -93,3 +71,3 @@ })

.option('--no-color', 'output without color')
.option('--backlog [dir]', 'output without color')
.option('--backlog [dir]', 'output without color. If not dir specified, will use default dir name.')
.option('--loglevel <level>', 'output log verbosity. Available levels are: trace,debug,info,warn,error,fatal')

@@ -96,0 +74,0 @@ .option('-V, --verbose', 'output log verbosely. Same as debug level. Prior to loglevel argument', Boolean, false)

11

CHANGELOG.md

@@ -5,2 +5,13 @@ # Change Log

<a name="2.2.0"></a>
# [2.2.0](https://github.com/draykcirb/brickyard3/compare/v2.1.0...v2.2.0) (2016-09-26)
### Features
* multi improvement ([3456172](https://github.com/draykcirb/brickyard3/commit/3456172))
* remove sealing for module exports ([4efaab8](https://github.com/draykcirb/brickyard3/commit/4efaab8))
<a name="2.1.0"></a>

@@ -7,0 +18,0 @@ # [2.1.0](https://github.com/draykcirb/brickyard3/compare/v2.0.0...v2.1.0) (2016-09-21)

@@ -9,3 +9,2 @@ /**

const butil = require('./util')
const logging = require('./logger')

@@ -23,5 +22,7 @@ const configLoader = require('./configLoader')

this.config = {}
this.logger = logging
logging.setGlobalLogLevel('info')
logger.trace('init brickyard instance')
}

@@ -35,5 +36,7 @@

*/
load(configPath, extraDefaultConfig) {
this.config = configLoader.run(configPath, extraDefaultConfig)
load(extraDefaultConfig) {
this.defaultconfig = configLoader.loadDefaultConfig(extraDefaultConfig)
this.config = configLoader.mergeConfig(this.defaultconfig, this.userConfig)
this.programs = programLoader.getAllPrograms(this.config.programStore, this.config.allowNoPrograms)

@@ -58,9 +61,9 @@

*/
hatchRuntime(cmdOptions) {
hatchRuntime() {
logger.trace('hatching the runtime object')
const mergePrograms = compoundPrograms(this.programs, cmdOptions.program)
const mergePrograms = compoundPrograms(this.programs, this.cmdOptions.program)
// 将所有 config 合并到 this.config, 有效值会按顺序 左->右 被覆盖
butil.mergeWithValid(this.config, mergePrograms.config, cmdOptions)
this.config = configLoader.mergeConfig(this.config, mergePrograms.config, this.cmdOptions)

@@ -73,8 +76,6 @@ // 动态构建输出目录名

this.config.outputBase = path.resolve(process.cwd(), this.config.dest)
this.config.outputAssetsPath = path.join(this.config.outputBase, this.config.destPostfix)
const plugins = pluginLoader.getTargetPlugins(this.config.pluginStore, mergePrograms.plugins)
const plugins = _.pick(this.plugins, mergePrograms.plugins)
// 限制 brickyard 对象的修改
Object.seal(this)
return {

@@ -87,6 +88,6 @@ config: this.config,

module.exports = new Brickyard()
Brickyard.prototype.cli = require('./cli')
module.exports = new Brickyard()
// ==========================================================================

@@ -93,0 +94,0 @@

@@ -8,3 +8,2 @@ /* eslint no-underscore-dangle:0 */

const _ = require('lodash')
const packageLoader = require('./packageLoader')
const path = require('path')

@@ -14,6 +13,13 @@ const logger = require('log4js').getLogger('CLI')

const brickyard = require('./brickyard')
const packageLoader = require('./packageLoader')
const butil = require('../lib/util')
const cli = {
commands: {}
commands: {},
load
}
module.exports = cli
/**

@@ -26,10 +32,31 @@ * load all the target command modules,

* @param {Command} rootCmd
* @param {Array} userCommands
* @param {Object} env
* @returns {Promise}
*/
cli.load = function (rootCmd, userCommands) {
return new Promise(resolve => loadCommands(rootCmd, userCommands, resolve))
function load(rootCmd, env) {
brickyard.userConfig = loadUserConfig(env.configPath)
return new Promise(resolve => loadCommands(rootCmd, getUserSpecifiedCommands(brickyard.userConfig), resolve))
.spread((cmdName, options) => {
const targetCmd = brickyard.cli.commands[cmdName]
brickyard.cmdOptions = butil.assignWithValid({}, options, rootCmd.opts())
brickyard.load(targetCmd.config)
targetCmd.run(brickyard.hatchRuntime())
})
.catch((e) => {
throw e
})
}
module.exports = Object.seal(cli)
function getUserSpecifiedCommands(userConfig) {
return userConfig ? userConfig.commands : null
}
function loadUserConfig(confPath) {
return confPath ? require(confPath) : null
}
function loadCommands(rootCmd, userCommands, resolve) {

@@ -36,0 +63,0 @@ logger.trace('batch register commands')

@@ -10,34 +10,32 @@ /**

const logger = require('log4js').getLogger('ConfigLoader')
const butil = require('./util')
const frameworkDefaultConfigPath = path.resolve(__dirname, '../config/default.js')
module.exports = Object.seal({
run: loadConfig
})
module.exports = {
loadDefaultConfig,
mergeConfig
}
/**
* 获取默认配置文件与指定配置文件,并返回合并配置
* 合并配置
*
* @param {String} [configPath]
* @param {Object} [extraDefaultConfig]
* @param configs
* @returns {Object}
*/
function loadConfig(configPath, extraDefaultConfig) {
const configPathQueue = [configPath, extraDefaultConfig, frameworkDefaultConfigPath]
function mergeConfig(...configs) {
logger.trace('merge all config')
logger.debug('the config path queue is: ', configPathQueue)
return butil.assignWithValid({}, ...configs)
}
return configPathQueue.reduceRight(function (configObject, pathOrConfig) {
if (_.isString(pathOrConfig)) {
const resolvedPath = path.resolve(process.cwd(), pathOrConfig)
_.assignIn(configObject, require(resolvedPath))
}
if (_.isPlainObject(pathOrConfig)) {
_.assignIn(configObject, pathOrConfig)
}
return configObject
}, {})
/**
* load the default configuration
* @param defaultConfPath
* @param extraDefaultConfig
*/
function loadDefaultConfig(extraDefaultConfig, defaultConfPath = frameworkDefaultConfigPath) {
logger.trace('load the default configuration')
const defaultConf = require(defaultConfPath)
return _.assignIn({}, defaultConf, extraDefaultConfig)
}

@@ -7,5 +7,17 @@ /**

const log4js = require('log4js')
const _ = require('lodash')
// log4js.replaceConsole()
log4js.backlogFile = function (backlogPath) {
let logPath = _.isBoolean(backlogPath) ? 'logs/build.log' : backlogPath
log4js.configure({
appenders: [
{ type: 'console' },
{ type: 'file', filename: logPath, maxLogSize: 1000000, backups: 10 }
],
replaceConsole: true
})
}
module.exports = log4js

@@ -11,5 +11,5 @@ /**

module.exports = Object.seal({
module.exports = {
getPackages
})
}

@@ -16,0 +16,0 @@ /**

@@ -18,6 +18,6 @@ /**

module.exports = Object.seal({
module.exports = {
getTargetPlugins: getTargetPlugins,
getAllPlugins: getAllPlugins
})
}

@@ -24,0 +24,0 @@ /**

@@ -13,7 +13,7 @@ /* eslint max-len: 0 */

module.exports = Object.seal({
module.exports = {
getTargetPrograms,
getTargetProgramsFromContext,
getAllPrograms: getAvailableProgramRecipes
})
}

@@ -20,0 +20,0 @@ /**

{
"name": "brickyard3",
"author": "e-cloud",
"version": "2.1.0",
"version": "2.2.0",
"description": "plugin framework for building extendable and flexible web apps or back-end services.",

@@ -28,3 +28,2 @@ "main": "index.js",

"devDependencies": {
"brickyard-command-init": "*",
"chai": "^3.5.0",

@@ -77,3 +76,6 @@ "eslint": "^3.5.0",

}
},
"engines": {
"node": ">=6.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc