Skip to content

Commit

Permalink
Merge branch 'master' of github.com:linemanjs/lineman
Browse files Browse the repository at this point in the history
  • Loading branch information
searls committed Apr 11, 2015
2 parents 1c3488c + 992b3cd commit 6967860
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
1 change: 1 addition & 0 deletions archetype/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npm run production
12 changes: 6 additions & 6 deletions archetype/config/application.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* Exports a function which returns an object that overrides the default &
* plugin grunt configuration object.
*
* You can familiarize yourself with Lineman's defaults by checking out:
* You can familiarize yourself with Lineman's defaults by looking at:
*
* - https://github.com/linemanjs/lineman/blob/master/config/application.coffee
* - https://github.com/linemanjs/lineman/blob/master/config/plugins
*
* You can also ask Lineman's about config from the command line:
* You can also ask about Lineman's config from the command line:
*
* $ lineman config #=> to print the entire config
* $ lineman config concat_sourcemap.js #=> to see the JS config for the concat task.
Expand All @@ -28,23 +28,23 @@ module.exports = function(lineman) {
// host: 'localhost',
// port: 3000
// }
// }
// },

// Sass
//
// Lineman supports Sass via grunt-contrib-sass, which requires you first
// have Ruby installed as well as the `sass` gem. To enable it, comment out the
// have Ruby installed as well as the `sass` gem. To enable it, uncomment the
// following line:
//
// enableSass: true
// enableSass: true,

// Asset Fingerprints
//
// Lineman can fingerprint your static assets by appending a hash to the filename
// and logging a manifest of logical-to-hashed filenames in dist/assets.json
// via grunt-asset-fingerprint
//
// enableAssetFingerprint: true
// enableAssetFingerprint: true,

// LiveReload
//
Expand Down
3 changes: 2 additions & 1 deletion archetype/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"scripts": {
"start": "lineman run",
"test": "lineman spec-ci"
"test": "lineman spec-ci",
"production": "lineman clean build && npm i express@3 && node -e \"var e = require('express'), a = e(); a.use(e.static('dist/')); a.listen(process.env.PORT)\""
}
}
1 change: 1 addition & 0 deletions config/plugins/server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = (lineman) ->
changeOrigin: true
host: "localhost"
port: 3000
useSsl: false

liveReload:
enabled: false
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lineman",
"description": "A grunt-based project scaffold for HTML/CSS/JS apps",
"version": "0.34.2",
"version": "0.36.0",
"homepage": "http://linemanjs.com",
"author": {
"name": "Justin Searls",
Expand All @@ -26,26 +26,26 @@
"connect-livereload": "^0.4.0",
"express": "3.4.0",
"fetcher": "~0.2.0",
"grunt": "0.4.1",
"grunt": "0.4.5",
"grunt-asset-fingerprint": "~0.2.0",
"grunt-concat-sourcemap": "~0.4.0",
"grunt-contrib-clean": "0.5.0",
"grunt-contrib-coffee": "0.7.0",
"grunt-contrib-copy": "0.4.1",
"grunt-contrib-cssmin": "0.6.1",
"grunt-contrib-handlebars": "0.8.0",
"grunt-contrib-jshint": "0.6.4",
"grunt-contrib-jshint": "0.11.0",
"grunt-contrib-jst": "0.5.1",
"grunt-contrib-sass": "0.5.0",
"grunt-contrib-uglify": "0.2.4",
"grunt-watch-nospawn": "0.0.8",
"http-proxy": "0.10.3",
"js2coffee": "~0.2.7",
"js2coffee": "0.3.3",
"lodash": "~0.9.0",
"normalize-package-data": "~0.2.9",
"resolve": "~0.6.1",
"semver": "2.1.0",
"testem": "0.6.15",
"testem": "0.7.6",
"underscore.string": "~2.3.3",
"watch_r-structr-lock": "0.0.1"
},
Expand Down
16 changes: 9 additions & 7 deletions tasks/server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Contributor: @davemo, @searls
Configuration:
"base" - the path from which to serve static assets from (this should almost always be left to the default value of "generated")
"web.port" - the port from which to run the development server (defaults to 8000, can be overridden with ENV variable WEB_PORT)
"apiProxy.port" - the port of the server running an API we want to proxy (does not proxy be default, can be overridden with ENV variable API_PORT)
"apiProxy.port" - the port of the server running an API we want to proxy (does not proxy by default, can be overridden with ENV variable API_PORT)
"apiProxy.useSsl" - Whether SSL/TLS should be used to connect to the API server (defaults to false)
"apiProxy.enabled" - set to true to enable API proxying; if Lineman can't respond to a request, it will forward it to the API proxy
"apiProxy.host" - the host to which API requests should be proxy, defaults to `localhost`)"
"apiProxy.prefix" - an api prefix, to be used in conjunction with server.pushState to correctly identify requests that should go to the apiProxy"
Expand All @@ -28,6 +29,7 @@ module.exports = (grunt) ->
apiProxyPrefix = grunt.config.get("server.apiProxy.prefix") || undefined
apiProxyHost = grunt.config.get("server.apiProxy.host") || "localhost"
apiProxyChangeOrigin = grunt.config.get("server.apiProxy.changeOrigin")
apiProxyUseSsl = grunt.config.get("server.apiProxy.useSsl") || false
webPort = process.env.WEB_PORT || grunt.config.get("server.web.port") || 8000
webRoot = grunt.config.get("server.base") || "generated"
staticRoutes = grunt.config.get("server.staticRoutes")
Expand All @@ -53,10 +55,10 @@ module.exports = (grunt) ->
if apiProxyEnabled
if pushStateEnabled
grunt.log.writeln("Proxying API requests prefixed with '#{apiProxyPrefix}' to #{apiProxyHost}:#{apiPort}")
app.use(prefixMatchingApiProxy(apiProxyPrefix, apiProxyHost, apiPort, apiProxyChangeOrigin, relativeUrlRoot, new httpProxy.RoutingProxy()))
app.use(prefixMatchingApiProxy(apiProxyPrefix, apiProxyHost, apiPort, apiProxyUseSsl, apiProxyChangeOrigin, relativeUrlRoot, new httpProxy.RoutingProxy()))
else
grunt.log.writeln("Proxying API requests to #{apiProxyHost}:#{apiPort}")
app.use(apiProxy(apiProxyHost, apiPort, apiProxyChangeOrigin, relativeUrlRoot, new httpProxy.RoutingProxy()))
app.use(apiProxy(apiProxyHost, apiPort, apiProxyUseSsl, apiProxyChangeOrigin, relativeUrlRoot, new httpProxy.RoutingProxy()))

app.use(express.bodyParser())
app.use(express.errorHandler())
Expand Down Expand Up @@ -98,24 +100,24 @@ module.exports = (grunt) ->
res.write("API Proxying to `#{req.url}` failed with: `#{err.toString()}`")
res.end()

prefixMatchingApiProxy = (prefix, host, port, changeOrigin, relativeUrlRoot = "", proxy) ->
prefixMatchingApiProxy = (prefix, host, port, useSsl, changeOrigin, relativeUrlRoot = "", proxy) ->
prefixMatcher = new RegExp(prefix)

proxy.on "proxyError", handleProxyError

return (req, res, next) ->
if prefix and prefixMatcher.exec(req.path)
req.url = relativeUrlRoot + req.url
proxy.proxyRequest(req, res, {host, port, changeOrigin})
proxy.proxyRequest(req, res, {host, port, changeOrigin, target: { https: useSsl }})
else
next()

apiProxy = (host, port, changeOrigin, relativeUrlRoot = "", proxy) ->
apiProxy = (host, port, useSsl, changeOrigin, relativeUrlRoot = "", proxy) ->
proxy.on "proxyError", handleProxyError

return (req, res, next) ->
req.url = relativeUrlRoot + req.url
proxy.proxyRequest(req, res, {host, port, changeOrigin})
proxy.proxyRequest(req, res, {host, port, changeOrigin, target: { https: useSsl }})

addBodyParserCallbackToRoutes = (app) ->
bodyParser = express.bodyParser()
Expand Down

0 comments on commit 6967860

Please sign in to comment.