Added prod convenience invocation

In order to facilitate UI testing, ttx asked for a convenient way to
run the webUI against the production API. This commit modifies the
proxy settings inside of grunt to allow this. To use, execute
tox -egrunt_no_api server:prod

Change-Id: Icc5432382a254825030b295d248d0d4b7efb9065
This commit is contained in:
Michael Krotscheck 2014-03-24 11:13:02 -07:00
parent 359297afab
commit 5751ac7eb9

View File

@ -48,6 +48,24 @@ module.exports = function (grunt) {
bower: './bower_components' bower: './bower_components'
}; };
var proxies = {
localhost: {
context: '/api/v1',
host: 'localhost',
port: 8080,
https: false,
rewrite: {
'^/api/v1': '/v1'
}
},
production: {
context: '/api/v1',
host: 'storyboard.openstack.org',
port: 443,
https: true
}
};
// load all grunt tasks // load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
@ -404,17 +422,6 @@ module.exports = function (grunt) {
options: { options: {
hostname: 'localhost' hostname: 'localhost'
}, },
proxies: [
{
context: '/api/v1',
host: 'localhost',
port: 8080,
https: false,
rewrite: {
'^/api/v1': '/v1'
}
}
],
livereload: { livereload: {
options: { options: {
port: 9000, port: 9000,
@ -425,7 +432,8 @@ module.exports = function (grunt) {
proxySnippet proxySnippet
]; ];
} }
} },
proxies: [proxies.localhost]
}, },
dist: { dist: {
options: { options: {
@ -437,7 +445,8 @@ module.exports = function (grunt) {
proxySnippet proxySnippet
]; ];
} }
} },
proxies: [proxies.localhost]
}, },
test: { test: {
options: { options: {
@ -448,7 +457,21 @@ module.exports = function (grunt) {
proxySnippet proxySnippet
]; ];
} }
},
proxies: [proxies.localhost]
},
prod: {
options: {
port: 9000,
keepalive: true,
middleware: function (connect) {
return [
mountFolder(connect, dir.output),
proxySnippet
];
} }
},
proxies: [proxies.production]
} }
}, },
@ -540,10 +563,25 @@ module.exports = function (grunt) {
'compile', 'compile',
'package', 'package',
'open', 'open',
'configureProxies:server', 'configureProxies:dist',
'connect:dist' 'connect:dist'
]); ]);
/**
* This task is identical to 'server:dist', with the exception that it
* will proxy the API requests against the production API.
*
* USE WITH CAUTION
*/
grunt.registerTask('server:prod', [
'clean',
'compile',
'package',
'open',
'configureProxies:prod',
'connect:prod'
]);
/** /**
* Development server - runs a build and sets up concurrent watchers that * Development server - runs a build and sets up concurrent watchers that
* will automatically lint, test, and refresh * will automatically lint, test, and refresh
@ -552,7 +590,7 @@ module.exports = function (grunt) {
grunt.registerTask('server', [ grunt.registerTask('server', [
'clean', 'clean',
'compile', 'compile',
'configureProxies:server', 'configureProxies:livereload',
'connect:livereload', 'connect:livereload',
'open', 'open',
'watch' 'watch'