1 Star 1 Fork 4

Zam Lam/web-console

forked from jzy99/web-console 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Gruntfile.js 21.64 KB
一键复制 编辑 原始数据 按行查看 历史
jzy99 提交于 2017-03-07 15:56 . commit 20170307
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
// Generated on 2014-09-12 using generator-angular 0.9.8
'use strict';
/* jshint unused: false */
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
var modRewrite = require('connect-modrewrite');
var serveStatic = require('serve-static');
module.exports = function (grunt) {
var contextRoot = grunt.option('contextRoot') || "dev-console";
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt, {
pattern: ['grunt-*', '!grunt-template-jasmine-istanbul']
});
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Configurable paths for the application
var appConfig = {
app: require('./bower.json').appPath || 'app',
dist: 'dist'
};
// Define the configuration for all the tasks
grunt.initConfig({
// Project settings
yeoman: appConfig,
// Watches files for changes and runs tasks based on the changed files
watch: {
bower: {
files: ['bower.json'],
tasks: ['wiredep']
},
js: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['newer:jshint:all'],
options: {
livereload: grunt.option('disable-live-reload') ? false : {
key: grunt.file.read('tls/tls.key'),
cert: grunt.file.read('tls/tls.crt')
}
}
},
jsTest: {
files: ['test/spec/{,*/}*.js'],
tasks: ['newer:jshint:test', 'karma']
},
css: {
files: '<%= yeoman.app %>/styles/*.less',
tasks: ['less:development']
},
html: {
files: '<%= yeoman.app %>/views/{,*/}*.html',
options: {
livereload: grunt.option('disable-live-reload') ? false : {
key: grunt.file.read('tls/tls.key'),
cert: grunt.file.read('tls/tls.crt')
}
}
},
extensions: {
files: ['extensions/extensions.js', 'extensions/extensions.css'],
tasks: ['copy:extensions']
},
index: {
files: ['<%= yeoman.app %>/index.html'],
tasks: ['replace:index']
},
localConfig: {
files: ['<%= yeoman.app %>/config.local.js'],
tasks: ['copy:localConfig']
},
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
options: {
livereload: grunt.option('disable-live-reload') ? false : '<%= connect.options.livereload %>'
},
files: [
'<%= yeoman.app %>/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'.tmp/config.js',
'.tmp/scripts/extensions.js',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
// The actual grunt server settings
connect: {
options: {
protocol: grunt.option('scheme') || 'https',
port: grunt.option('port') || 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: grunt.option('hostname') || 'localhost',
key: grunt.file.read('tls/tls.key'),
cert: grunt.file.read('tls/tls.crt'),
livereload: grunt.option('disable-live-reload') ? false : 35729
},
livereload: {
options: {
open: true,
middleware: function (connect) {
return [
modRewrite([
'^/$ /' + contextRoot + '/ [R=302]',
'^/' + contextRoot + '(.*)$ $1',
'!^/(config.js|(java|bower_components|scripts|images|styles|views)(/.*)?)$ /index.html [L]'
]),
serveStatic('.tmp'),
connect().use(
'/java',
serveStatic('./openshift-jvm')
),
connect().use(
'/bower_components',
serveStatic('./bower_components')
),
serveStatic(appConfig.app)
];
}
}
},
test: {
options: {
middleware: function (connect) {
return [
modRewrite([
'^/$ /' + contextRoot + '/ [R=302]',
'^/' + contextRoot + '(.*)$ $1',
'!^/(config.js|(bower_components|scripts|images|styles|views)(/.*)?)$ /index.html [L]'
]),
serveStatic('.tmp'),
serveStatic('test'),
connect().use(
'/bower_components',
serveStatic('./bower_components')
),
serveStatic(appConfig.app)
];
}
}
},
dist: {
options: {
open: true,
base: '<%= yeoman.dist %>'
}
}
},
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: {
src: [
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js'
]
},
test: {
options: {
jshintrc: 'test/.jshintrc'
},
src: ['test/spec/{,*/}*.js','test/integration/**/*.js']
}
},
// Empties folders to start fresh
clean: {
dist: {
files: [{
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/{,*/}*',
'!<%= yeoman.dist %>/.git*',
'<%= yeoman.dist %>.java/{,*/}*',
'!<%= yeoman.dist %>.java/.git*'
]
}]
},
server: '.tmp'
},
// Add vendor prefixed styles
autoprefixer: {
options: {
browsers: ['last 1 version']
},
dist: {
files: [{
expand: true,
cwd: '.tmp/styles/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
}]
}
},
// Automatically inject Bower components into the app
wiredep: {
app: {
src: ['<%= yeoman.app %>/index.html'],
ignorePath: /\.\.\//,
exclude: [
// choosing uri.js over urijs
'bower_components/uri.js/src/IPv6.js',
'bower_components/uri.js/src/SecondLevelDomains.js',
'bower_components/uri.js/src/punycode.js',
'bower_components/uri.js/src/URI.min.js',
'bower_components/uri.js/src/jquery.URI.min.js',
'bower_components/uri.js/src/URI.fragmentQuery.js',
// bower registration error? we get 2x versions of uri.js/urijs
'bower_components/urijs/',
'bower_components/messenger/build/css/messenger.css',
'bower_components/messenger/build/css/messenger-theme-future.css',
'bower_components/messenger/build/css/messenger-theme-block.css',
'bower_components/messenger/build/css/messenger-theme-air.css',
'bower_components/messenger/build/css/messenger-theme-ice.css',
'bower_components/messenger/build/js/messenger-theme-future.js',
'bower_components/moment-timezone/builds/moment-timezone-with-data-2010-2020.js',
'bower_components/fontawesome/css/font-awesome.css',
'bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.css',
'bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css',
'bower_components/bootstrap-select/dist/css/bootstrap-select.css',
'bower_components/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.css',
'bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.css',
'bower_components/bootstrap-touchspin/src/jquery.bootstrap-touchspin.css',
'bower_components/c3/c3.css',
'bower_components/datatables/media/css/jquery.dataTables.css',
'bower_components/datatables-colreorder/css/dataTables.colReorder.css',
'bower_components/datatables-colvis/css/dataTables.colVis.css',
'bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
'bower_components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
'bower_components/font-awesome/css/font-awesome.css',
'bower_components/google-code-prettify/bin/prettify.min.js',
'bower_components/google-code-prettify/bin/prettify.min.css',
'bower_components/patternfly/dist/css/patternfly.css',
'bower_components/patternfly/dist/css/patternfly-additions.css',
'bower_components/patternfly-bootstrap-combobox/css/bootstrap-combobox.css'
]
}
},
less: {
development: {
files: {
'.tmp/styles/main.css': '<%= yeoman.app %>/styles/main.less'
},
options: {
paths: ['<%= yeoman.app %>/styles', 'bower_components/'],
sourceMap: true,
sourceMapFilename: '.tmp/styles/main.css.map',
sourceMapURL: 'main.css.map',
outputSourceFiles: true
}
},
production: {
files: {
'dist/styles/main.css': '<%= yeoman.app %>/styles/main.less'
},
options: {
cleancss: true,
paths: ['<%= yeoman.app %>/styles', 'bower_components/']
}
}
},
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
html: '<%= yeoman.app %>/index.html',
options: {
dest: '<%= yeoman.dist %>',
flow: {
html: {
steps: {
js: ['concat', 'uglifyjs'],
css: ['cssmin']
},
post: {
css: [{
name:'cssmin',
createConfig: function(context, block) {
var generated = context.options.generated;
generated.options = {
keepBreaks: true,
compatibility: {
properties: {
zeroUnits: false
}
}
};
}
}],
js: [{
name:'uglify',
createConfig: function(context, block) {
var generated = context.options.generated;
generated.options = {
compress: {},
mangle: {},
beautify: {
beautify: true,
indent_level: 0, // Don't waste characters indenting
space_colon: false, // Don't waste characters
width: 1000
},
};
}
}]
}
}
}
}
},
// Performs rewrites based on filerev and the useminPrepare configuration
usemin: {
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images']
}
},
// The following *-min tasks will produce minified files in the dist folder
// By default, your `index.html`'s <!-- Usemin block --> will take care of
// minification. These next options are pre-configured if you do not wish
// to use the Usemin blocks.
// cssmin: {
// dist: {
// files: {
// '<%= yeoman.dist %>/styles/main.css': [
// '.tmp/styles/{,*/}*.css'
// ]
// }
// }
// },
// uglify: {
// dist: {
// files: {
// '<%= yeoman.dist %>/scripts/scripts.js': [
// '<%= yeoman.dist %>/scripts/scripts.js'
// ]
// }
// }
// },
// concat: {
// dist: {}
// },
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg,gif}',
dest: '<%= yeoman.dist %>/images'
}]
}
},
svgmin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.svg',
dest: '<%= yeoman.dist %>/images'
}]
}
},
htmlhint: {
html: {
options: {
'tag-pair': true,
'attr-no-duplication': true
},
src: ['app/**/*.html']
}
},
htmlmin: {
dist: {
options: {
preserveLineBreaks: true,
collapseWhitespace: true,
conservativeCollapse: false,
collapseBooleanAttributes: false,
removeComments: true,
removeCommentsFromCDATA: true,
removeOptionalTags: false,
keepClosingSlash: true
},
files: [{
expand: true,
cwd: '<%= yeoman.dist %>',
src: ['*.html', 'views/{,*/}*.html'],
dest: '<%= yeoman.dist %>'
}]
}
},
// ng-annotate tries to make the code safe for minification automatically
// by using the Angular long form for dependency injection.
ngAnnotate: {
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: ['*.js', '!oldieshim.js'],
dest: '.tmp/concat/scripts'
}]
}
},
ngtemplates: {
dist: {
cwd: '<%= yeoman.app %>',
src: 'views/**/*.html',
dest: 'dist/scripts/templates.js',
options: {
module: 'openshiftConsoleTemplates',
standalone: true,
htmlmin: '<%= htmlmin.dist.options %>'
}
}
},
// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,png,txt}',
'.htaccess',
'*.html',
'images/{,*/}*.{ico,png,jpg,jpeg,gif}',
'images/{,*/}*.{webp}',
'fonts/*',
'styles/fonts/*'
]
}, {
expand: true,
cwd: '.tmp/images',
dest: '<%= yeoman.dist %>/images',
src: ['generated/*']
}, {
expand: true,
cwd: 'bower_components/patternfly/dist',
src: 'fonts/*',
dest: '<%= yeoman.dist %>/styles'
}, {
expand: true,
cwd: 'bower_components/font-awesome',
src: 'fonts/*',
dest: '<%= yeoman.dist %>/styles'
},
// Copy separate components
{
expand: true,
cwd: 'openshift-jvm',
src: '**/*',
// Copy to a separate "dist.*" directory for go-bindata
// Make the folder structure inside the dist.* directory match the desired path
dest: '<%= yeoman.dist %>.java/java'
}]
},
styles: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/styles',
dest: '.tmp/styles/',
src: '{,*/}*.css'
}, {
expand: true,
cwd: 'bower_components/patternfly/dist',
src: 'fonts/*',
dest: '.tmp/styles'
}, {
expand: true,
cwd: 'bower_components/font-awesome',
src: 'fonts/*',
dest: '.tmp/styles'
}]
},
// Copy files in the extensions dir for development, but not distribution.
extensions: {
files: [{
expand: true,
cwd: 'extensions',
src: 'extensions.js',
dest: '.tmp/scripts'
}, {
expand: true,
cwd: 'extensions',
src: 'extensions.css',
dest: '.tmp/styles'
}]
},
// config.local.js is for local customizations if it exists.
localConfig: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>',
src: 'config.local.js',
dest: '.tmp',
rename: function(path, name) {
return path + '/config.js';
}
}]
}
},
replace: {
index: {
options: {
patterns: [
{
match: /<base href="\/">/,
replacement: '<base href="/' + contextRoot + '/">'
}
]
},
files: [
{expand: true, flatten: true, src: ['<%= yeoman.app %>/index.html'], dest: '.tmp/'}
]
}
},
// Run some tasks in parallel to speed up the build process
concurrent: {
server: [
'less:development',
'copy:styles',
'copy:extensions',
'copy:localConfig',
'replace:index'
],
test: [
'less:development'
],
dist: [
'less:production',
// remove imagemin from build, since it doesn't tend to behave well cross-platform
// 'imagemin',
'svgmin',
// Also do everything we do in concurrent server so that you can leave grunt server running while doing a build
'concurrent:server'
]
},
// Test settings
karma: {
unit: {
configFile: 'test/karma.conf.js',
singleRun: true,
// default in karma.conf.js is Firefox, however, Chrome has much better
// error messages when writing tests. Call like this:
// grunt test
// grunt test --browsers=Chrome
// grunt test --browsers=Chrome,Firefox,Safari (be sure karma-<browser_name>-launcher is installed)
browsers: grunt.option('browsers') ?
grunt.option('browsers').split(',') :
['Firefox']
}
},
protractor: {
options: {
configFile: "test/protractor.conf.js", // Default config file
keepAlive: false, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
args: {
// Arguments passed to the command
suite: grunt.option('suite') || 'full',
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/")
}
},
default: {
options: {
configFile: "test/protractor.conf.js", // Target-specific config file
args: {
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
browser: grunt.option('browser') || "firefox"
} // Target-specific arguments
}
},
mac: {
options: {
configFile: "test/protractor-mac.conf.js", // Target-specific config file
args: {
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
browser: grunt.option('browser') || "firefox"
} // Target-specific arguments
}
}
},
// Settings for grunt-istanbul-coverage
// NOTE: coverage task is currently not in use
coverage: {
options: {
thresholds: {
'statements': 90,
'branches': 90,
'lines': 90,
'functions': 90
},
dir: 'coverage',
root: 'test'
}
}
});
grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
}
grunt.task.run([
'clean:server',
'wiredep',
'concurrent:server',
'autoprefixer',
'connect:livereload',
'watch'
]);
});
grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
grunt.task.run(['serve:' + target]);
});
grunt.registerTask('add-redirect-uri', "Add a redirectURI for openshift-web-console", function(target){
var opts = {
cmd: "oc",
args: [
"--server",
(grunt.option('masterUrl') || "https://localhost:8443"),
"patch",
"oauthclient/openshift-web-console",
"-p",
'{"redirectURIs":["' + (grunt.option('baseUrl') || "https://localhost:9000/") + '"]}'
]
};
var done = this.async();
grunt.log.writeln(opts.cmd + " " + opts.args.join(" "));
grunt.util.spawn(opts, function(error, result, code){
if (error) {
grunt.log.error(error);
} else if (code && result) {
grunt.log.error(result);
} else if (code) {
grunt.log.error("unexpected exit code: " + code);
} else {
grunt.log.writeln(result);
}
done();
});
});
// Loads the coverage task which enforces the minimum coverage thresholds
grunt.loadNpmTasks('grunt-istanbul-coverage');
grunt.loadNpmTasks('grunt-htmlhint');
grunt.loadNpmTasks('grunt-angular-templates');
// karma must run prior to coverage since karma will generate the coverage results
grunt.registerTask('test', [
'clean:server',
'concurrent:test',
'autoprefixer',
'connect:test',
'karma'
// 'coverage' - add back if we want to enforce coverage percentages
]);
grunt.registerTask('test-integration',
grunt.option('baseUrl') ?
[grunt.option('mac') ? 'protractor:mac' : 'protractor:default'] : // if a baseUrl is defined assume we dont want to run the local grunt server
[
'clean:server',
'concurrent:server',
'autoprefixer',
'connect:test',
'add-redirect-uri',
(grunt.option('mac') ? 'protractor:mac' : 'protractor:default'),
'clean:server'
]
);
grunt.registerTask('build', [
'clean:dist',
'newer:jshint',
'htmlhint',
'wiredep',
'useminPrepare',
'ngtemplates',
'concurrent:dist',
'autoprefixer',
'concat',
'ngAnnotate',
'copy:dist',
'less',
'cssmin',
'uglify',
'usemin',
'htmlmin'
]);
grunt.registerTask('default', [
'newer:jshint',
'test',
'build'
]);
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/zamlam/web-console.git
[email protected]:zamlam/web-console.git
zamlam
web-console
web-console
master

搜索帮助