Skip to content
Permalink
Browse files

feat(rapid-build cli): create the rapid-build cli, build.js is no lon…

…ger required instead run rapid-build from the terminal
  • Loading branch information
jyounce committed Jun 21, 2016
1 parent f76e17a commit 16322a75ae99a4c7c41877aee9dedca88c72cf09
Showing with 165 additions and 1 deletion.
  1. +83 −0 bin/build.js
  2. +75 −0 docs/rapid-build.cson
  3. +7 −1 package.json
@@ -0,0 +1,83 @@
#! /usr/bin/env node
// process.env.RB_LIB = 'src'

/* Requires
***********/
var path = require('path'),
CSON = require('cson'),
merge = require('deepmerge');

/* Constants
************/
const APP_PATH = process.cwd();
const BUILD_PATH = path.join(__dirname, '..');
const BUILD_PKG = require(path.join(BUILD_PATH, 'package.json'));
const APP_OPTS = path.join(APP_PATH, BUILD_PKG.name);

/* Helpers
**********/
var help = {
isEmptyObj: obj => {
return Object.keys(obj).length === 0 && obj.constructor === Object;
},
getBuildType: type => {
if (typeof type !== 'string') return 'default';
type = type.trim().toLowerCase();
if (/^(test|dev|prod)/i.test(type) === false) return 'default';
return type;
},
getBuildTypeOpts: (type, extraOpts) => {
var types = ['common'],
bType = type.split(':')[0], // base type
isDev = /^(default|test|dev)/i.test(bType),
start = bType == 'default' && extraOpts[2] != 'default' ? 2 : 3;

extraOpts = extraOpts.slice(start);
if (isDev) types.push('dev');
if (bType == 'test') types.push(bType);
if (type.indexOf(':test') != -1) types.push('test');
if (bType == 'prod') types.push(bType);
types = types.concat(extraOpts);
return types;
},
getBuildOpts: () => {
try { return CSON.requireFile(`${APP_OPTS}.cson`); }
catch(e) {
try { return require(`${APP_OPTS}.json`); }
catch(e) {
try { return require(`${APP_OPTS}.js`); }
catch(e) { return {}; }
}
}
},
mergeBuildOpts: (opts, typeOpts) => {
if (help.isEmptyObj(opts)) return {};
var mergedOpts = {},
optKeys = Object.keys(opts);
for (var type of typeOpts) {
if (optKeys.indexOf(type) == -1) continue;
mergedOpts = merge(mergedOpts, opts[type]);
}
return mergedOpts;
}
}

/* Setup
********/
var build = {};
build.buildType = help.getBuildType(process.argv[2]);
build.buildTypeOpts = help.getBuildTypeOpts(build.buildType, process.argv);
build.buildOpts = help.getBuildOpts();
build.buildOpts = help.mergeBuildOpts(build.buildOpts, build.buildTypeOpts);
build.execute = require(BUILD_PATH)(build.buildOpts);

/**
* Run Build - in the console type one of the following:
* node build
* node build test | test:client | test:server
* node build dev | dev:test | dev:test:client | dev:test:server
* node build prod | prod:test | prod:test:client | prod:test:server | prod:server
*******************************************************************************/
build.execute(build.buildType).then(() => {
console.log('Build Complete!')
})
@@ -0,0 +1,75 @@
common:
# browser: open: false
spa:
src:
filePath: 'spa.html'
minify:
spa:
file: false
css:
splitMinFile: false
html:
options:
ignoreCustomFragments: [
/<rb:code(\s*?.*?)*?rb:code>/gi
/<rb:pre(\s*?.*?)*?rb:pre>/gi
/\s?<rb:icon\s|<\/rb:icon>\s?/gi
]
angular:
moduleName: 'rapid-build'
modules: ['angular-bind-html-compile', 'duScroll', 'hljs', 'ngclipboard']
templateCache:
dev: true
useAbsolutePaths: true
order:
scripts:
first: [
'scripts/prototypes/*.*'
'libs/highlight/highlight.pack.js'
]
exclude:
from:
dist:
client: [
'libs/bootstrap/bootstrap.less'
'bower_components/jquery/**'
'bower_components/font-awesome/less/**'
'bower_components/font-awesome/scss/**'
'bower_components/bootstrap/less/**'
'bower_components/bootstrap/dist/js/**'
]
extra:
copy:
client: [
'bower_components/Ionicons/fonts/**'
'bower_components/font-awesome/fonts/**'
'bower_components/bootstrap/dist/fonts/**'
]
compile:
client:
less: [
'libs/bootstrap/bootstrap.less'
]
minify:
client:
css: [
'libs/bootstrap/bootstrap.css'
]

dev:
extra:
copy:
client: [
'bower_components/font-awesome/css/font-awesome.css'
]

prod:
extra:
copy:
client: [
'bower_components/font-awesome/css/font-awesome.min.css'
]




@@ -3,7 +3,7 @@
"version": "0.61.2",
"tasksPrefix": "rb-",
"description": "Rapid build system utilizing Node.js, Express and AngularJS.",
"homepage": "https://github.com/jyounce/rapid-build",
"homepage": "http://rapid-build.io/",
"author": {
"name": "Judd Younce",
"email": "jyounce@yahoo.com",
@@ -20,7 +20,11 @@
"engines": {
"node": ">=4.0.0"
},
"preferGlobal": true,
"main": "./",
"bin": {
"rapid-build": "bin/build.js"
},
"directories": {
"lib": "./lib",
"src": "./src",
@@ -49,6 +53,8 @@
"browser-sync": "2.13.0",
"coffee-script": "1.10.0",
"colors": "1.1.2",
"cson": "3.0.2",
"deepmerge": "0.2.10",
"del": "2.2.0",
"event-stream": "3.3.3",
"express": "4.14.0",

0 comments on commit 16322a7

Please sign in to comment.
You can’t perform that action at this time.