Skip to content
Permalink
Browse files

feat(rapid-build): v0.1.0

  • Loading branch information
Judd Younce
Judd Younce committed May 27, 2015
0 parents commit 31a966929ee22b9d11928e426a922390eedad357
Showing with 2,599 additions and 0 deletions.
  1. +12 −0 .gitignore
  2. +3 −0 .npmignore
  3. +22 −0 LICENSE
  4. +39 −0 README.md
  5. +16 −0 bootstrap.coffee
  6. +11 −0 bower.json
  7. +43 −0 config.coffee
  8. +32 −0 config/config-app.coffee
  9. +183 −0 config/config-dist-and-src.coffee
  10. +30 −0 config/config-env.coffee
  11. +143 −0 config/config-globs.coffee
  12. +52 −0 config/config-json.coffee
  13. +42 −0 config/config-node_modules.coffee
  14. +57 −0 config/config-options.coffee
  15. +76 −0 config/config-order.coffee
  16. +42 −0 config/config-rb.coffee
  17. +58 −0 config/config-temp.coffee
  18. +1 −0 config/config.tpl
  19. BIN docs/shake-and-bake.jpg
  20. +1 −0 files/files.tpl
  21. +12 −0 gulpfile.coffee
  22. +5 −0 gulpfile.js
  23. +158 −0 helpers/bower.coffee
  24. +26 −0 helpers/isType.coffee
  25. +9 −0 helpers/log.coffee
  26. +6 −0 helpers/module.coffee
  27. +33 −0 helpers/path.coffee
  28. +23 −0 helpers/tasks.coffee
  29. +29 −0 helpers/test.coffee
  30. +45 −0 init/rapid.coffee
  31. +71 −0 init/tasks.coffee
  32. +60 −0 package.json
  33. 0 src/client/images/.gitkeep
  34. +1 −0 src/client/scripts/app.coffee
  35. +26 −0 src/client/spa.html
  36. 0 src/client/styles/.gitkeep
  37. 0 src/client/views/.gitkeep
  38. +28 −0 src/server/server.coffee
  39. +25 −0 tasks/browser/browser-sync.coffee
  40. +12 −0 tasks/browser/open.coffee
  41. +23 −0 tasks/build/build-config.coffee
  42. +72 −0 tasks/build/build-files-prod.coffee
  43. +97 −0 tasks/build/build-files.coffee
  44. +30 −0 tasks/build/build-spa.coffee
  45. +15 −0 tasks/clean/clean-config.coffee
  46. +19 −0 tasks/clean/clean-dist.coffee
  47. +15 −0 tasks/clean/clean-files.coffee
  48. +49 −0 tasks/clean/cleanup-client.coffee
  49. +29 −0 tasks/common.coffee
  50. +28 −0 tasks/compile/coffee.coffee
  51. +28 −0 tasks/compile/es6.coffee
  52. +28 −0 tasks/compile/less.coffee
  53. +26 −0 tasks/copy/copy-css.coffee
  54. +26 −0 tasks/copy/copy-html.coffee
  55. +26 −0 tasks/copy/copy-images.coffee
  56. +26 −0 tasks/copy/copy-js.coffee
  57. +28 −0 tasks/copy/copy-libs.coffee
  58. +17 −0 tasks/copy/server/copy-config.coffee
  59. +25 −0 tasks/copy/server/copy-node_modules.coffee
  60. +28 −0 tasks/manage/bower.coffee
  61. +64 −0 tasks/minify/concat-all-files.coffee
  62. +41 −0 tasks/minify/concat-app-files.coffee
  63. +20 −0 tasks/minify/minify-client.coffee
  64. +22 −0 tasks/minify/minify-css.coffee
  65. +77 −0 tasks/minify/minify-html.coffee
  66. +22 −0 tasks/minify/minify-images.coffee
  67. +23 −0 tasks/minify/minify-js.coffee
  68. +39 −0 tasks/minify/minify-server.coffee
  69. +24 −0 tasks/minify/minify-spa.coffee
  70. +24 −0 tasks/server/nodemon.coffee
  71. +11 −0 tasks/server/server.coffee
  72. +13 −0 tasks/watch/watch-build-spa.coffee
  73. +144 −0 tasks/watch/watch.coffee
  74. +8 −0 todo.md
@@ -0,0 +1,12 @@
.DS_Store
temp/
bower_components/
src/client/libs/
dist/
public/
node_modules/
npm-debug.log
phantomjsdriver.log
test-results.xml
config/config.json
files/files.json
@@ -0,0 +1,3 @@
todo.md
config/config.json
docs/
22 LICENSE
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Judd Younce

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@@ -0,0 +1,39 @@
# rapid-build

**Under Development (not for use yet)**

Rapid build system utilizing Node.js,
Express and AngularJS.

## Installation
```bash
$ npm install rapid-build
```

## Information
rapid-build depends on [npm](http://npmjs.org/) and [Node.js](http://nodejs.org/) version >= 0.10.0

## More documentation coming real soon!
This will get you started:

```javascript
var config = {} // config documentation coming soon
var rapid = require('rapid-build')(config) // init to pass in config options
// rapid returns a promise and has 2 available params 'dev' and 'prod'
rapid().then(function() {
console.log('whatever you want')
})
```
OR

```javascript
// if you are running gulp there are 3 available tasks
var config = {} // config documentation coming soon
require('rapid-build')(config)
gulp 'rapid-build'
gulp 'rapid-build:dev'
gulp 'rapid-build:prod'
```
#### Develop Rapidly!
![Shake and Bake!](docs/shake-and-bake.jpg)
@@ -0,0 +1,16 @@
# rapid bootstrap
# ===============
module.exports = ->
colors = require 'colors'
colors.setTheme
silly: 'rainbow'
input: 'grey'
verbose: 'cyan'
prompt: 'grey'
info: 'green'
data: 'grey'
help: 'cyan'
warn: 'yellow'
debug: 'blue'
error: 'red'
colors
@@ -0,0 +1,11 @@
{
"name": "rapid-build",
"version": "0.0.0",
"dependencies": {
"angular": "1.4.x",
"angular-animate": "1.4.x",
"angular-resource": "1.4.x",
"angular-route": "1.4.x",
"angular-sanitize": "1.4.x"
}
}
@@ -0,0 +1,43 @@
# rapid config
# ============
module.exports = (rbDir, options) ->
# init config
# ===========
config = {}
config.env = {} # declare here so it will show up first

# require
# =======
req =
rb: rbDir
config: "#{rbDir}/config"
files: "#{rbDir}/files"
helpers: "#{rbDir}/helpers"
init: "#{rbDir}/init"
tasks: "#{rbDir}/tasks"

config.req = req

# get config in order
# ===================
options = require("#{config.req.config}/config-options") config, options
config = require("#{config.req.config}/config-env") config
config = require("#{config.req.config}/config-rb") config, rbDir
config = require("#{config.req.config}/config-app") config, options
config = require("#{config.req.config}/config-dist-and-src") config, options
config = require("#{config.req.config}/config-temp") config
config = require("#{config.req.config}/config-node_modules") config
config = require("#{config.req.config}/config-order") config, options
config = require("#{config.req.config}/config-globs") config
config = require("#{config.req.config}/config-json") config

# format
# ======
delete config.req # so req will show up last
config.req = req

# return
# ======
config


@@ -0,0 +1,32 @@
module.exports = (config, options) ->
log = require "#{config.req.helpers}/log"
test = require("#{config.req.helpers}/test")()

# init app
# ========
app = {}
app.dir = process.cwd()

# ports
# =====
app.ports = {}
app.ports.server = options.ports.server or 3000
app.ports.reload = options.ports.reload or 3001

# add app to config
# =================
config.app = app

# logs
# ====
# log.json app, 'app ='

# tests
# =====
test.log 'true', config.app, 'add app to config'

# return
# ======
config


@@ -0,0 +1,183 @@
module.exports = (config, options) ->
path = require 'path'
log = require "#{config.req.helpers}/log"

# defaults
# ========
dir =
dist: 'dist'
src: 'src'
client: 'client'
images: 'images'
libs: 'libs' # things like bower_components
server: 'server'
scripts: 'scripts'
styles: 'styles'
views: 'views'

file =
spa: 'spa.html'
appServer: 'routes' # app server dist entry file
rbServer: 'server' # rb server dist bootstrap file

# dirs
# ====
getDirs = (loc, isApp) ->
o = {}
if loc is 'dist' or isApp
o.dir = options[loc].dir
if isApp
o.clientDir = options[loc].client.dir
o.clientImages = options[loc].client.images.dir
o.clientLibs = options[loc].client.libs.dir
o.clientScripts = options[loc].client.scripts.dir
o.clientStyles = options[loc].client.styles.dir
o.clientViews = options[loc].client.views.dir
o.serverDir = options[loc].server.dir

dir: o.dir or dir[loc]
client:
dir: o.clientDir or dir.client
images:
dir: o.clientImages or dir.images
libs:
dir: o.clientLibs or dir.libs
scripts:
dir: o.clientScripts or dir.scripts
styles:
dir: o.clientStyles or dir.styles
views:
dir: o.clientViews or dir.views
server:
dir: o.serverDir or dir.server # gets deleted, see removeServerDir
scripts:
dir: o.serverDir or dir.scripts

# dist
# ====
config.dist = {}
config.dist.dir = options.dist.dir or dir.dist # only one dist.dir
config.dist.rb = getDirs 'dist'
config.dist.app = getDirs 'dist', true

# src
# ===
config.src = {}
config.src.rb = getDirs 'src'
config.src.app = getDirs 'src', true

# format config
# =============
formatConfig = (loc, src) ->
cwd = ''
isSrc = loc is 'src'
isDist = loc is 'dist'
if isSrc
cwd = config.rb.dir if src is 'rb'
cwd = config.app.dir if src is 'app'
loc = config[loc][src]
for own k1, v1 of loc
if k1 is 'dir'
loc.dir = path.join cwd, v1
continue
for own k2, v2 of v1
if k2 is 'dir'
if isDist and src is 'rb'
v1.dir = path.join loc.dir, v2, config.rb.prefix.distDir
else
v1.dir = path.join loc.dir, v2
else
v1[k2].dir = path.join v1.dir, v2.dir

formatConfig 'dist', 'rb'
formatConfig 'dist', 'app'
formatConfig 'src', 'rb'
formatConfig 'src', 'app'

# add dirName
# ===========
addDirName = (loc) ->
for own k1, v1 of config[loc]
continue if k1 is 'dir'
for own k2, v2 of v1
continue if k2 is 'dir'
continue if k2 is 'server'
for own k3, v3 of v2
continue if k3 is 'dir'
if k1 is 'app'
v3.dirName = options[loc].client[k3].dir or dir[k3]
else
v3.dirName = dir[k3]
addDirName 'dist'

# add spa
# =======
getDistSpa = ->
spaFile = options.dist.client.spa.file or file.spa
path.join config.dist.app.client.dir, spaFile

getSrcSpa = ->
path.join config.src.rb.client.dir, file.spa

config.dist.app.client.spa =
file: options.dist.client.spa.file or file.spa
path: getDistSpa()

config.src.rb.client.spa =
file: file.spa
path: getSrcSpa()

# relative paths (old sauce)
# ==========================
addAppRelative = (loc, loc2, type) ->
a = options[loc].dir or dir[loc]
b = options[loc][loc2].dir or dir[loc2]
c = options[loc][loc2][type].dir or dir[type]
path.join a, b, c

# config.src.rb.client.libs.relative = path.join dir.src, dir.client, dir.libs
# config.src.app.client.libs.relative = addAppRelative 'src', 'client', 'libs'

# server
# ======
removeServerDir = ->
['dist', 'src'].forEach (v1) ->
['app', 'rb'].forEach (v2) ->
config[v1][v2].server.scripts.dir = config[v1][v2].server.dir
delete config[v1][v2].server.dir

addToServerAppDist = ->
config.dist.app.server.scripts.file = # app server dist entry file
options.dist.server.file or file.appServer

config.dist.app.server.scripts.path = # absolute path
path.join config.app.dir, config.dist.app.server.scripts.dir

removeServerDir() # server dir is server.scripts.dir
addToServerAppDist() # add file and path
config.dist.rb.server.scripts.file = file.rbServer # rb server dist bootstrap file

# final touch-ups
# ===============
formatDist = ->
['app', 'rb'].forEach (v) ->
delete config.dist[v].dir

formatDist() # only one dist.dir

# logs
# ====
# log.json config.dist, 'config.dist ='
# log.json config.src, 'config.src ='
# log.json config, 'config ='

# return
# ======
config







0 comments on commit 31a9669

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