| 
									
										
										
										
											2013-11-15 07:07:14 +08:00
										 |  |  | // Lint and build CSS
 | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  | module.exports = function(grunt) { | 
					
						
							| 
									
										
										
										
											2015-09-10 17:26:40 +08:00
										 |  |  |   'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |   // prettier-ignore
 | 
					
						
							| 
									
										
										
										
											2015-09-10 17:26:40 +08:00
										 |  |  |   grunt.registerTask('default', [ | 
					
						
							| 
									
										
										
										
											2017-10-02 02:02:25 +08:00
										 |  |  |     'clean:build', | 
					
						
							|  |  |  |     'phantomjs', | 
					
						
							|  |  |  |   ]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |   // prettier-ignore
 | 
					
						
							| 
									
										
										
										
											2017-10-02 02:02:25 +08:00
										 |  |  |   grunt.registerTask('test', [ | 
					
						
							|  |  |  |     'sasslint', | 
					
						
							| 
									
										
										
										
											2018-12-21 21:37:38 +08:00
										 |  |  |     'tslint', | 
					
						
							|  |  |  |     'typecheck', | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |     'exec:jest', | 
					
						
							|  |  |  |     'no-only-tests', | 
					
						
							|  |  |  |     'no-focus-convey-tests' | 
					
						
							| 
									
										
										
										
											2015-09-10 17:26:40 +08:00
										 |  |  |   ]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |   // prettier-ignore
 | 
					
						
							| 
									
										
										
										
											2018-12-21 21:23:32 +08:00
										 |  |  |   grunt.registerTask('tslint', [ | 
					
						
							|  |  |  |     'newer:exec:tslintPackages', | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |     'newer:exec:tslintRoot' | 
					
						
							| 
									
										
										
										
											2018-12-21 21:23:32 +08:00
										 |  |  |   ]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |   // prettier-ignore
 | 
					
						
							| 
									
										
										
										
											2018-12-21 21:23:32 +08:00
										 |  |  |   grunt.registerTask('typecheck', [ | 
					
						
							|  |  |  |     'newer:exec:typecheckPackages', | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |     'newer:exec:typecheckRoot' | 
					
						
							| 
									
										
										
										
											2018-12-21 21:23:32 +08:00
										 |  |  |   ]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |   grunt.registerTask('no-only-tests', function() { | 
					
						
							| 
									
										
										
										
											2019-03-18 17:39:14 +08:00
										 |  |  |     var files = grunt.file.expand( | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |       'public/**/*@(_specs|.test).@(ts|js|tsx|jsx)', | 
					
						
							| 
									
										
										
										
											2019-06-18 23:17:27 +08:00
										 |  |  |       'packages/grafana-data/**/*@(_specs|.test).@(ts|js|tsx|jsx)', | 
					
						
							|  |  |  |       'packages/**/*@(_specs|.test).@(ts|js|tsx|jsx)' | 
					
						
							| 
									
										
										
										
											2019-03-18 17:39:14 +08:00
										 |  |  |     ); | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |     grepFiles(files, '.only(', 'found only statement in test: '); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   grunt.registerTask('no-focus-convey-tests', function() { | 
					
						
							|  |  |  |     var files = grunt.file.expand('pkg/**/*_test.go'); | 
					
						
							|  |  |  |     grepFiles(files, 'FocusConvey(', 'found FocusConvey statement in test: '); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2016-04-18 23:12:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |   function grepFiles(files, pattern, errorMessage) { | 
					
						
							|  |  |  |     files.forEach(function(spec) { | 
					
						
							| 
									
										
										
										
											2016-04-18 23:12:53 +08:00
										 |  |  |       var rows = grunt.file.read(spec).split('\n'); | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |       rows.forEach(function(row) { | 
					
						
							|  |  |  |         if (row.indexOf(pattern) > 0) { | 
					
						
							| 
									
										
										
										
											2016-04-18 23:12:53 +08:00
										 |  |  |           grunt.log.errorlns(row); | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |           grunt.fail.warn(errorMessage + spec); | 
					
						
							| 
									
										
										
										
											2016-04-18 23:12:53 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2019-04-04 20:48:11 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2014-05-31 13:46:39 +08:00
										 |  |  | }; |