Skip to content
Permalink
Browse files

feat(installation): add support for global installs, eliminating the …

…need to install the build multiple times
  • Loading branch information
jyounce committed Feb 10, 2016
1 parent 064769b commit 4fa26ef8b0b051eb91f170286e1273f1d542df44
Showing with 260 additions and 223 deletions.
  1. +3 −4 .gitignore
  2. +3 −5 .npmignore
  3. +1 −0 README.md
  4. +1 −0 config.coffee
  5. +6 −1 config/config-app.coffee
  6. +1 −1 config/config-bower.coffee
  7. +1 −1 config/config-dist-and-src.coffee
  8. +48 −0 config/config-generated.coffee
  9. +5 −3 config/config-rb.coffee
  10. +0 −1 config/config-req.coffee
  11. +1 −1 config/config-spa.coffee
  12. +0 −15 config/config-templates.coffee
  13. 0 {files → generated}/.gitkeep
  14. +1 −1 helpers/config.coffee
  15. +6 −3 init/tasks.coffee
  16. +0 −3 package.json
  17. +0 −21 scripts/helpers/log-msg.js
  18. +0 −28 scripts/prepublish.js
  19. +14 −22 tasks/build/build-bower-json.coffee
  20. +10 −19 tasks/build/build-files.coffee
  21. +8 −16 tasks/build/build-prod-files-blueprint.coffee
  22. +8 −16 tasks/build/build-prod-files.coffee
  23. +2 −2 tasks/build/build-spa.coffee
  24. +2 −1 tasks/clean/clean-config.coffee
  25. +1 −1 tasks/clean/clean-files.coffee
  26. +1 −1 tasks/clean/cleanup-client.coffee
  27. +1 −0 tasks/common/common-client.coffee
  28. +1 −0 tasks/common/common.coffee
  29. +1 −1 tasks/copy/copy-server-config.coffee
  30. +104 −0 tasks/generate/generate-pkg.coffee
  31. +2 −2 tasks/minify/cache-bust.coffee
  32. +1 −1 tasks/minify/concat-scripts-and-styles.coffee
  33. +8 −16 tasks/minify/css-file-split.coffee
  34. +14 −22 tasks/test/client/build-client-test-files.coffee
  35. +1 −1 tasks/test/client/build-inject-angular-mocks.coffee
  36. +3 −1 tasks/test/client/copy-client-tests.coffee
  37. +1 −1 tasks/test/client/run-client-tests.coffee
  38. +0 −7 templates/bower-json.tpl
  39. +0 −1 templates/config.tpl
  40. +0 −1 templates/files.tpl
  41. +0 −1 templates/prod-files-blueprint.tpl
  42. +0 −1 templates/prod-files.tpl
  43. +0 −1 templates/test-files.tpl
@@ -24,21 +24,20 @@ node_modules/

# root files
# ==========
/bower.json
/*.tgz # npm package

# folder files
# ============
config/config.json
test/css/selectors.css

# files
# =====
files/**/*.*
generated/**/*
src/client/**/*.*

# retain empty folder via .gitkeep
# ================================
!files/.gitkeep
!generated/.gitkeep
!src/client/**/.gitkeep

# file negation
@@ -1,6 +1,6 @@
# folders
# =======
bower_components/ # also see scripts/prepublish.js
bower_components/
dist/

# dot files
@@ -22,20 +22,18 @@ dist/

# root files
# ==========
/bower.json

# folder files
# ============
config/config.json

# files
# =====
files/**/*.*
generated/**/*
src/client/**/*.*

# retain empty folder via .gitkeep
# ================================
!files/.gitkeep
!generated/.gitkeep
!src/client/**/.gitkeep

# file negation
@@ -5,6 +5,7 @@ Releases are documented here [changelog](https://github.com/jyounce/rapid-build/
More and better documentation *coming real soon*!

## Installation
If installed globally you may need to set your [NODE_PATH](https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders).
```bash
$ npm install rapid-build
```
@@ -13,6 +13,7 @@ module.exports = (rbDir, 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-generated") config
config = require("#{config.req.config}/config-build") config, options
config = require("#{config.req.config}/config-ports") config, options
config = require("#{config.req.config}/config-browser") config, options
@@ -1,11 +1,16 @@
module.exports = (config, options) ->
path = require 'path'
log = require "#{config.req.helpers}/log"
test = require("#{config.req.helpers}/test")()
pkg = require "#{config.req.app}/package.json"

# init app
# ========
app = {}
app.dir = config.req.app
app.name = pkg.name
app.version = pkg.version
app.dir = config.req.app
app.name = path.basename app.dir unless app.name # incase no package.json

# add app to config
# =================
@@ -19,7 +19,7 @@ module.exports = (config, options) ->
addInfo = ->
['app', 'rb'].forEach (v) ->
bower[v].file = defaults.file
bower[v].dir = config[v].dir
bower[v].dir = if v is 'rb' then config.generated.pkg.path else config[v].dir
bower[v].path = path.join bower[v].dir, bower[v].file
addInfo()

@@ -102,7 +102,7 @@ module.exports = (config, options) ->
isSrc = loc is 'src'
isDist = loc is 'dist'
if isSrc
cwd = config.rb.dir if src is 'rb'
cwd = config.generated.pkg.path if src is 'rb' # was config.rb.dir
cwd = config.app.dir if src is 'app'
loc = config[loc][src]
for own k1, v1 of loc
@@ -0,0 +1,48 @@
module.exports = (config) ->
path = require 'path'
log = require "#{config.req.helpers}/log"
test = require("#{config.req.helpers}/test")()

# helpers
# =======
join = (p1, p2) ->
path.join p1, p2

# init generated
# ==============
generated = {}
generated.dir = 'generated'
generated.path = join config.rb.dir, generated.dir
generated.pkg = {}
generated.pkg.dir = config.app.name
generated.pkg.path = join generated.path, generated.pkg.dir
generated.pkg.bower = join generated.pkg.path, 'bower.json'
generated.pkg.config = join generated.pkg.path, 'config.json'
generated.pkg.files = {}
generated.pkg.src = {}
generated.pkg.files.dir = 'files'
generated.pkg.files.path = join generated.pkg.path, generated.pkg.files.dir
generated.pkg.files.files = join generated.pkg.files.path, 'files.json'
generated.pkg.files.testFiles = join generated.pkg.files.path, 'test-files.json'
generated.pkg.files.prodFiles = join generated.pkg.files.path, 'prod-files.json'
generated.pkg.files.prodFilesBlueprint = join generated.pkg.files.path, 'prod-files-blueprint.json'
generated.pkg.src.dir = 'src'
generated.pkg.src.path = join generated.pkg.path, generated.pkg.src.dir

# add generated to config
# =======================
config.generated = generated

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

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

# return
# ======
config


@@ -15,9 +15,11 @@ module.exports = (config, rbDir) ->
# is symlink - determine if it has been installed via npm link
# ==========
getIsSymlink = ->
dir = path.join config.req.app, 'node_modules', rb.name
isSymlink = fs.lstatSync(dir).isSymbolicLink()
isSymlink
dir = path.join config.req.app, 'node_modules', rb.name
try
isSymlink = fs.lstatSync(dir).isSymbolicLink()
catch e # globally installed
isSymlink = false

rb.isSymlink = getIsSymlink()

@@ -5,7 +5,6 @@ module.exports = (config, rbDir) ->
rb: rbDir
app: process.cwd()
config: "#{rbDir}/config"
files: "#{rbDir}/files"
plugins: "#{rbDir}/plugins"
helpers: "#{rbDir}/helpers"
init: "#{rbDir}/init"
@@ -33,7 +33,7 @@ module.exports = (config, options) ->

# placeholders
# ============
spa.title = options.spa.title or pkg.name or 'Application'
spa.title = options.spa.title or config.app.name or 'Application'
spa.description = options.spa.description or pkg.description or null

# dist
@@ -22,26 +22,11 @@ module.exports = (config) ->

# set templates info
# ==================
templates.config = getInfo(
'config.tpl'
'config.json'
path.join config.rb.dir, 'config'
)
templates.files = getInfo(
'files.tpl'
'files.json'
path.join config.rb.dir, 'files'
)
templates.angularModules = getInfo(
'angular-modules.tpl'
'app.coffee'
config.src.rb.client.scripts.dir
)
templates.bowerJson = getInfo(
'bower-json.tpl'
'bower.json'
config.rb.dir
)

# add templates to config
# =======================
File renamed without changes.
@@ -8,7 +8,7 @@ module.exports = (config) ->
msg = 'rebuilt' if msg isnt 'built'
defer = q.defer()
format = spaces: '\t'
configFile = config.templates.config.dest.path
configFile = config.generated.pkg.config
fse.writeJson configFile, config, format, (e) ->
console.log "#{msg} config.json".yellow
defer.resolve()
@@ -13,7 +13,7 @@ module.exports = (gulp, config) ->
# =====
taskHelp.addTask 'build-angular-modules', '/build/build-angular-modules'
taskHelp.addTask 'build-bower-json', '/build/build-bower-json'
taskHelp.addTask 'build-config', '/build/build-config', deps: ['clean-config']
taskHelp.addTask 'build-config', '/build/build-config'
taskHelp.addTask 'build-files', '/build/build-files', deps: ['clean-files']
taskHelp.addTask 'build-prod-files', '/build/build-prod-files'
taskHelp.addTask 'build-prod-files-blueprint', '/build/build-prod-files-blueprint'
@@ -22,7 +22,6 @@ module.exports = (gulp, config) ->

# clean
# =====
taskHelp.addTask 'clean-config', '/clean/clean-config'
taskHelp.addTask 'clean-dist', '/clean/clean-dist'
taskHelp.addTask 'clean-files', '/clean/clean-files'
taskHelp.addTask 'clean-rb-client', '/clean/clean-rb-client'
@@ -79,9 +78,13 @@ module.exports = (gulp, config) ->
# ======
taskHelp.addTask 'absolute-css-urls', '/format/absolute-css-urls'

# generate
# ========
taskHelp.addTask 'generate-pkg', '/generate/generate-pkg'

# manage
# ======
taskHelp.addTask 'bower', '/manage/bower', deps:['build-bower-json']
taskHelp.addTask 'bower', '/manage/bower'

# minify
# ======
@@ -21,9 +21,6 @@
"node": ">=0.10.0"
},
"main": "gulpfile.js",
"scripts": {
"prepublish": "npm update colors && npm update fs-extra && npm update q && node scripts/prepublish"
},
"devDependencies": {
"conventional-changelog": "0.5.3",
"prepend-file": "1.3.0"

This file was deleted.

This file was deleted.

@@ -1,37 +1,29 @@
module.exports = (config, gulp) ->
q = require 'q'
rename = require 'gulp-rename'
template = require 'gulp-template'
q = require 'q'
fse = require 'fs-extra'

# helpers
# =======
getData = ->
version = '0.0.0'
name = config.rb.name
deps = config.angular.bowerDeps
total = Object.keys(deps).length
data = { name, version, deps, total }
version = '0.0.0'
name = config.rb.name
dependencies = config.angular.bowerDeps
{ name, version, dependencies }

# API
# ===
api =
runTask: (src, dest, file) ->
defer = q.defer()
data = getData()
gulp.src src
.pipe rename file
.pipe template data
.pipe gulp.dest dest
.on 'end', ->
# console.log 'bower.json built'.yellow
defer.resolve()
defer = q.defer()
format = spaces: '\t'
json = getData()
jsonFile = config.generated.pkg.bower
fse.writeJson jsonFile, json, format, (e) ->
console.log 'built bower.json'.yellow
defer.resolve()
defer.promise

# return
# ======
api.runTask(
config.templates.bowerJson.src.path
config.templates.bowerJson.dest.dir
config.templates.bowerJson.dest.file
)
api.runTask()

0 comments on commit 4fa26ef

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