Skip to content
Permalink
Browse files

fix(option): remove options angular.exclude.files and spa.exclude, re…

…place with the exclude option
  • Loading branch information
jyounce committed Jul 2, 2015
1 parent b56dace commit 4904685d54ba155acc191538323723f8fe032867
@@ -118,15 +118,12 @@ gulp rapid-build:prod
# angular.httpBackend.dir = (string) defaults to 'mocks' = directory inside your client scripts directory
# angular.templateCache.dev = (boolean) defaults to false = use template cache when running default and dev task
# angular.templateCache.useAbsolutePaths = (boolean) defaults to false = prefix template urls with a '/'
# angular.exclude.files = (boolean) defaults to false = set to true to exclude angular files (lib and modules)
# spa.title = (string) defaults to package.json name or 'Application' = html title tag value
# spa.description = (string) defaults to package.json description = html meta description tag value
# spa.src.file = (string) defaults to 'spa.html' = set if you want to use your own spa file and not the build system's (file must be located in your client src directory)
# spa.src.dir = (string) defaults to null = set if you are using your own spa file and that file is located in a directory in your client src directory
# spa.dist.file = (string) defaults to spa.src.file or 'spa.html' = provide if you want the dist spa file to be named differently, example: 'index.html'
# spa.placeholders = (array of strings) = set to retain spa file placeholders, optional values are: ['scripts', 'styles', 'description', 'moduleName', 'title'] or ['all']
# spa.exclude.scripts = (array of strings) = file paths: exclude files from automatically being generated in the spa.html and scripts.min.js file
# spa.exclude.styles = (array of strings) = file paths: exclude files from automatically being generated in the spa.html and styles.min.css file
# minify.css.styles = (boolean) defaults to true = for prod build, minify the css
# minify.css.splitMinFile = (boolean) defaults to true = for prod build, task for ie9 and below, split styles.min.css into multiple files if selector count > 4,095
# minify.html.views = (boolean) defaults to true = for prod build, minify the html
@@ -135,6 +132,8 @@ gulp rapid-build:prod
# minify.js.mangle = (boolean) defaults to true = for prod build, mangle the names in the js
# minify.spa.file = (boolean) defaults to true = for prod build, minify the spa.html file
# minify.cacheBust = (boolean) defaults to true = for prod build, ensures the user always receives the latest files, adds an md5 checksum to the client files before their extension
# exclude.angular.files = (boolean) defaults to false = set to true to exclude the angular files that come with rapid-build from dist (lib and modules)
# exclude[scripts|styles].from.spaFile = (array of strings) = file paths: exclude script or style files from automatically being generated in the spa.html file
# ========================================================================================================================================================================================================================
```

@@ -18,6 +18,7 @@ module.exports = (rbDir, options) ->
config = require("#{config.req.config}/config-dist-and-src") config, options
config = require("#{config.req.config}/config-angular") config, options
config = require("#{config.req.config}/config-spa") config, options
config = require("#{config.req.config}/config-exclude") config, options
config = require("#{config.req.config}/config-templates") config
config = require("#{config.req.config}/config-temp") config
config = require("#{config.req.config}/config-node_modules") config
@@ -34,11 +34,6 @@ module.exports = (config, options) ->
# ===========
angular.moduleName = options.angular.moduleName or 'app'

# exclude
# =======
angular.exclude = {}
angular.exclude.files = options.angular.exclude.files or false

# template cache
# ==============
angular.templateCache = {}
@@ -0,0 +1,78 @@
module.exports = (config, options) ->
path = require 'path'
log = require "#{config.req.helpers}/log"
isType = require "#{config.req.helpers}/isType"
pathHelp = require "#{config.req.helpers}/path"
test = require("#{config.req.helpers}/test")()

# options helpers
# ===============
get =
opt:
deep2: (type, opt, defaultVal) ->
opt = options.exclude[type][opt]
return defaultVal if isType.null opt
opt
deep3: (type, opt, defaultVal) ->
opt = options.exclude[type].from[opt]
return defaultVal if isType.null opt
opt

# init exclude
# ============
exclude =
angular:
files: get.opt.deep2 'angular', 'files', false
rb:
scripts:
from:
minFile: []
spaFile: []
styles:
from:
minFile: []
spaFile: []
app:
scripts:
from:
minFile: get.opt.deep3 'scripts', 'minFile', []
spaFile: get.opt.deep3 'scripts', 'spaFile', []
styles:
from:
minFile: get.opt.deep3 'styles', 'minFile', []
spaFile: get.opt.deep3 'styles', 'spaFile', []

# format options
# ==============
formatFilesFrom = (type, opt) -> # prepend dist path to values then prepend '!'
for appOrRb in ['app','rb']
_paths = exclude[appOrRb][type].from[opt]
continue if not _paths.length
_paths = (pathHelp.makeRelative _path for _path in _paths)
_paths = (path.join config.dist[appOrRb].client.dir, _path for _path in _paths)
_paths = ("!#{_path}" for _path in _paths)
# log.json _paths
exclude[appOrRb][type].from[opt] = _paths

formatFilesFrom 'scripts', 'minFile'
formatFilesFrom 'scripts', 'spaFile'
formatFilesFrom 'styles', 'minFile'
formatFilesFrom 'styles', 'spaFile'

# add exclude to config
# =====================
config.exclude = exclude

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

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

# return
# ======
config


@@ -5,20 +5,43 @@ module.exports = (config) ->
pathHelp = require "#{config.req.helpers}/path"
test = require("#{config.req.helpers}/test")()

# defaults
# ========
# exts
# ====
exts =
coffee: 'coffee'
css: 'css'
es6: 'es6'
fonts: 'eot,svg,ttf,woff,woff2' # not used
html: 'html'
images: 'gif,jpg,jpeg,png'
js: 'js'
less: 'less'
sass: 'sass' # not used yet

getExts = (_exts) -> # _exts = string array
_exts = _exts.split ','
_exts = (ext.trim() for ext in _exts)
combined = ''
total = _exts.length - 1
for ext, i in _exts
combined += exts[ext]
combined += ',' if i isnt total
combined

# langs
# =====
lang =
all: '/**'
coffee: '/**/*.coffee'
css: '/**/*.css'
es6: '/**/*.es6'
html: '/**/*.html'
images: '/**/*.{gif,jpg,jpeg,png}'
js: '/**/*.js'
less: '/**/*.less'
sass: '/**/*.sass'
bustFiles: '/**/*.{css,js,gif,jpg,jpeg,png}'
bustRefs: '/**/*.{html,css,js}'
coffee: "/**/*.#{exts.coffee}"
css: "/**/*.#{exts.css}"
es6: "/**/*.#{exts.es6}"
html: "/**/*.#{exts.html}"
images: "/**/*.{#{exts.images}}"
js: "/**/*.#{exts.js}"
less: "/**/*.#{exts.less}"
sass: "/**/*.#{exts.sass}"
bustFiles: "/**/*.{#{getExts 'css,js,images'}}"
bustRefs: "/**/*.{#{getExts 'html,css,js'}}"

# helpers
# =======
@@ -23,15 +23,12 @@
# angular.httpBackend.dir = (string) defaults to 'mocks'
# angular.templateCache.dev = (boolean) defaults to false
# angular.templateCache.useAbsolutePaths = (boolean) defaults to false
# angular.exclude.files = (boolean) defaults to false
# spa.title = (string) defaults to package.json name
# spa.description = (string) defaults to package.json description
# spa.src.file = (string) defaults to 'spa.html'
# spa.src.dir = (string) defaults to null
# spa.dist.file = (string) defaults to spa.src.file or 'spa.html'
# spa.placeholders = (array of strings) = optionals: ['scripts', 'styles', 'description', 'moduleName', 'title'] or ['all']
# spa.exclude.scripts = (array of strings) = file paths: exclude files from automatically being generated in the spa.html and scripts.min.js file
# spa.exclude.styles = (array of strings) = file paths: exclude files from automatically being generated in the spa.html and styles.min.css file
# minify.css.styles = (boolean) defaults to true
# minify.css.splitMinFile = (boolean) defaults to true
# minify.html.views = (boolean) defaults to true
@@ -40,7 +37,10 @@
# minify.js.mangle = (boolean) defaults to true
# minify.spa.file = (boolean) defaults to true
# minify.cacheBust = (boolean) defaults to true
# =========================================================================================================================================================================
# exclude.angular.files = (boolean) defaults to false
# exclude[scripts|styles].from.spaFile = (array of strings) = file paths: exclude script or style files from automatically being generated in the spa.html file
# exclude[scripts|styles].from.minFile = (array of strings) = file paths: exclude script or style files from automatically being generated in the scripts.min.js or styles.min.css file
# =============================================================================================================================================================================================
module.exports = (config, options) ->
log = require "#{config.req.helpers}/log"
isType = require "#{config.req.helpers}/isType"
@@ -83,8 +83,6 @@ module.exports = (config, options) ->
options.angular.modules = null if not isType.array options.angular.modules
options.angular.version = null if not isType.string options.angular.version
options.angular.moduleName = null if not isType.string options.angular.moduleName
options.angular.exclude = {} if not isType.object options.angular.exclude
options.angular.exclude.files = null if not isType.boolean options.angular.exclude.files
options.angular.httpBackend = {} if not isType.object options.angular.httpBackend
options.angular.httpBackend.dev = null if not isType.boolean options.angular.httpBackend.dev
options.angular.httpBackend.prod = null if not isType.boolean options.angular.httpBackend.prod
@@ -103,9 +101,6 @@ module.exports = (config, options) ->
options.spa.dist = {} if not isType.object options.spa.dist
options.spa.dist.file = null if not isType.string options.spa.dist.file
options.spa.placeholders = null if not isType.array options.spa.placeholders
options.spa.exclude = {} if not isType.object options.spa.exclude
options.spa.exclude.scripts = null if not isType.array options.spa.exclude.scripts
options.spa.exclude.styles = null if not isType.array options.spa.exclude.styles

minifyOptions = ->
options.minify = {} if not isType.object options.minify
@@ -122,6 +117,19 @@ module.exports = (config, options) ->
options.minify.js.mangle = null if not isType.boolean options.minify.js.mangle
options.minify.spa.file = null if not isType.boolean options.minify.spa.file

excludeOptions = ->
options.exclude = {} if not isType.object options.exclude
options.exclude.angular = {} if not isType.object options.exclude.angular
options.exclude.scripts = {} if not isType.object options.exclude.scripts
options.exclude.styles = {} if not isType.object options.exclude.styles
options.exclude.scripts.from = {} if not isType.object options.exclude.scripts.from
options.exclude.styles.from = {} if not isType.object options.exclude.styles.from
options.exclude.angular.files = null if not isType.boolean options.exclude.angular.files
options.exclude.scripts.from.minFile = null if not isType.array options.exclude.scripts.from.minFile
options.exclude.scripts.from.spaFile = null if not isType.array options.exclude.scripts.from.spaFile
options.exclude.styles.from.minFile = null if not isType.array options.exclude.styles.from.minFile
options.exclude.styles.from.spaFile = null if not isType.array options.exclude.styles.from.spaFile

# init
# ====
distAndSrcOptions() # must be first
@@ -131,6 +139,7 @@ module.exports = (config, options) ->
angularOptions()
spaOptions()
minifyOptions()
excludeOptions()

# logs
# ====
@@ -56,7 +56,7 @@ module.exports = (config, options) ->
# rb order
# ========
files = []
files = files.concat rb.files.angular if not options.angular.exclude.files
files = files.concat rb.files.angular if not config.exclude.angular.files
order.rb.scripts.first = files.concat rb.files.rb

# methods
@@ -48,26 +48,6 @@ module.exports = (config, options) ->
# ============
spa.placeholders = options.spa.placeholders or []

# exclude
# =======
spa.exclude =
rb:
scripts: []
styles: []
app:
scripts: options.spa.exclude.scripts or []
styles: options.spa.exclude.styles or []

formatExcludes = ->
for own k1, v1 of spa.exclude
for own k2, v2 of v1
continue if not v2.length
v2.forEach (v3, i) ->
v2[i] = path.join config.dist[k1].client.dir, v3
v2[i] = "!#{v2[i]}"

formatExcludes()

# add spa to config
# =================
config.spa = spa
@@ -32,3 +32,9 @@ module.exports =
v.forEach (path, i) ->
paths[k].push v[i].replace partial, ''
paths

makeRelative: (path) ->
return path if path[0] isnt '/'
path.substr 1


@@ -23,8 +23,9 @@ module.exports = (gulp, config) ->
# globs
# =====
getExcludes = (appOrRb, type, glob) ->
return glob if not config.spa.exclude[appOrRb][type].length
glob = glob.concat config.spa.exclude[appOrRb][type]
spaExcludes = config.exclude[appOrRb][type].from.spaFile
return glob if not spaExcludes.length
glob = glob.concat spaExcludes
glob

getGlob = (type, lang) ->
@@ -38,8 +38,9 @@ module.exports = (gulp, config) ->
# globs
# =====
getExcludes = (appOrRb, type, glob) ->
return glob if not config.spa.exclude[appOrRb][type].length
glob = glob.concat config.spa.exclude[appOrRb][type]
spaExcludes = config.exclude[appOrRb][type].from.spaFile
return glob if not spaExcludes.length
glob = glob.concat spaExcludes
# log.json glob, "#{appOrRb} #{type}"
glob

0 comments on commit 4904685

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