chasevida/blum

语言: JavaScript

git: https://github.com/chasevida/blum

Blum是一个配置文档生成器,用于使用Confidence创建清单json文件。
Blum is a configuration document generator used to create manifest json files using Confidence.
README.md (中文)

百隆

Blum是一个配置文档生成器,用于使用Confidence创建Hapi清单json文件。它通过一个npm预启动脚本创建一个manifest.config.json文件,该脚本可以通过rejoice -c manifest.config.json在命令行上使用Rejoice(Hapi CLI)。

这可以用于高级别的快速A / B测试,也可以用于基于环境的服务器配置等简单事物。

虽然这是为了与Hapi一起使用而开发的,但它可以在任何地方用于根据Confidence样式标准自动生成configuration.json。

Version npm
Build Status
Coveralls branch
Dependencies


命令行

Blum采用以下标志选项:

  • -c - 置信度使用的criteria.js的必需文件路径。
  • -m - 由信任编辑并由Hapi使用的manifest.js的必需文件路径。
  • -f - 可选的输出文件名/路径,默认为./manifest.config.json

直接从命令行使用它:

$ blum -c criteria.js -m manifest.js -f manifest.config.json

在调用Hapi之前将它用作package.json中的脚本:

"prestart":  "blum -c config/criteria.js -m config/manifest.js -f config.json"
"start":     "rejoice -c manifest.config.json"

更多例子

有一个示例目录,其中包含一个mock package.json文件。从该文件夹开始运行$ npm将根据从package.json文件传递的详细信息生成清单配置文件。创建它之后,它将通过Rejoice CLI运行Hapi服务器。

您可以根据需要修改这些设置。如果在调用之前添加环境变量,您将看到生成的其他清单配置文件,这就是Confidence的神奇之处。

Criteria&Manifest文件

确保您的criteria.js和manifest.js文件都导出可由Confidence使用的有效对象。请查看他们的文档以获取更多详细信息。

示例Criteria.js

module.exports = {
    env: process.env.ENVIRONMENT
};

示例Manifest.js

下面的示例默认情况下对jade html进行了修饰,但是在生产环境中运行时,html会缩小。

module.exports = {
    connections: [
        {
            port: 3000,
            labels: [
                'http'
            ]
        }
    ],
    server: {},
    plugins: {
        vision: {
            engines: {
                jade: 'jade'
            },
            path: './views',
            compileOptions: {
                $filter: 'env',
                production: {
                    pretty: false
                },
                $default: {
                    pretty: true
                }
            }
        }
    }
};

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

Blum

Blum is a configuration document generator used to create Hapi manifest json files using Confidence. It creates a manifest.config.json file through an npm prestart script that Rejoice (the Hapi CLI) can consume on the command line with rejoice -c manifest.config.json.

This could be used for quick A/B testing at a high level or for simple things such as environment based server configuration.

While this was developed to be used in conjunction with a Hapi it can be used anywhere to auto generate a configuration.json based on the Confidence style criteria.

Version npm
Build Status
Coveralls branch
Dependencies


Command Line

Blum takes the following flag options:

  • -c - a required file path for criteria.js to be used by confidence.
  • -m - a required file path for manifest.js to be edited by confidence and consumed by Hapi.
  • -f - an optional output file name/path, defaults to ./manifest.config.json

Example

Use it straight from the command line:

$ blum -c criteria.js -m manifest.js -f manifest.config.json

Use it as a script in your package.json before calling Hapi:

"prestart":  "blum -c config/criteria.js -m config/manifest.js -f config.json"
"start":     "rejoice -c manifest.config.json"

More examples

There is an example directory which contains a mock package.json file. Running $ npm start from within this folder will generate a manifest config file based on the details being passed from the package.json file. After it's created it will then run a Hapi server via the Rejoice CLI.

You can modify these settings as you like. If you add an environment variable before the call you will see a different manifest config file generated, this is the magic of Confidence.

Criteria & Manifest files

Ensure that your criteria.js and manifest.js files both export a valid object that can be consumed by Confidence. Please check their docs for more details on this.

Example Criteria.js

module.exports = {
    env: process.env.ENVIRONMENT
};

Example Manifest.js

The below example prettifies the jade html by default but when run in a production environment the html is minified.

module.exports = {
    connections: [
        {
            port: 3000,
            labels: [
                'http'
            ]
        }
    ],
    server: {},
    plugins: {
        vision: {
            engines: {
                jade: 'jade'
            },
            path: './views',
            compileOptions: {
                $filter: 'env',
                production: {
                    pretty: false
                },
                $default: {
                    pretty: true
                }
            }
        }
    }
};