gulpfile.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* jshint browser: false, node: true, strict: true */
  6. 'use strict';
  7. const gulp = require( 'gulp' );
  8. const runSequence = require( 'run-sequence' );
  9. const config = {
  10. ROOT_DIR: '.',
  11. BUILD_DIR: 'build',
  12. BUNDLE_DIR: 'bundle',
  13. WORKSPACE_DIR: '..',
  14. // Files ignored by jshint and jscs tasks. Files from .gitignore will be added automatically during tasks execution.
  15. IGNORED_FILES: [
  16. 'src/lib/**'
  17. ]
  18. };
  19. require( './dev/tasks/bundle/tasks' )( config ).register();
  20. require( './dev/tasks/test/tasks' )( config ).register();
  21. require( './dev/tasks/docs/tasks' )( config ).register();
  22. // Lint tasks.
  23. const ckeditor5Lint = require( 'ckeditor5-dev-lint' )( config );
  24. gulp.task( 'lint', ckeditor5Lint.lint );
  25. gulp.task( 'lint-staged', ckeditor5Lint.lintStaged );
  26. gulp.task( 'default', [ 'build' ] );
  27. gulp.task( 'pre-commit', [ 'lint-staged' ] );
  28. // Development environment tasks.
  29. const ckeditor5DevEnv = require( 'ckeditor5-dev-env' )( config );
  30. gulp.task( 'init', ckeditor5DevEnv.initRepository );
  31. gulp.task( 'create-package', ckeditor5DevEnv.createPackage );
  32. gulp.task( 'update', ckeditor5DevEnv.updateRepositories );
  33. gulp.task( 'pull', ckeditor5DevEnv.updateRepositories );
  34. gulp.task( 'status', ckeditor5DevEnv.checkStatus );
  35. gulp.task( 'st', ckeditor5DevEnv.checkStatus );
  36. gulp.task( 'relink', ckeditor5DevEnv.relink );
  37. gulp.task( 'install', ckeditor5DevEnv.installPackage );
  38. gulp.task( 'exec', ckeditor5DevEnv.execOnRepositories );
  39. // Build tasks.
  40. const ckeditor5DevBuilder = require( 'ckeditor5-dev-builder' )( config );
  41. gulp.task( 'build', callback => {
  42. runSequence( 'build:clean:all', 'build:themes', 'build:js', callback );
  43. } );
  44. gulp.task( 'build:clean:all', ckeditor5DevBuilder.clean.all );
  45. gulp.task( 'build:clean:themes', ckeditor5DevBuilder.clean.themes );
  46. gulp.task( 'build:clean:js', () => ckeditor5DevBuilder.clean.js() );
  47. gulp.task( 'build:themes', ( callback ) => {
  48. runSequence( 'build:clean:themes', 'build:icons', 'build:sass', callback );
  49. } );
  50. gulp.task( 'build:sass', () => ckeditor5DevBuilder.build.sass() );
  51. gulp.task( 'build:icons', () => ckeditor5DevBuilder.build.icons() );
  52. gulp.task( 'build:js', [ 'build:clean:js' ], () => ckeditor5DevBuilder.build.js() );
  53. // Tasks specific for preparing build with unmodified source files. Uses by `gulp docs` or `gulp bundle`.
  54. gulp.task( 'build:clean:js:esnext', () => ckeditor5DevBuilder.clean.js( { formats: [ 'esnext' ] } ) );
  55. gulp.task( 'build:clean:themes:esnext', () => ckeditor5DevBuilder.clean.themes( { formats: [ 'esnext' ] } ) );
  56. gulp.task( 'build:sass:esnext', () => ckeditor5DevBuilder.build.sass( { formats: [ 'esnext' ] } ) );
  57. gulp.task( 'build:icons:esnext', () => ckeditor5DevBuilder.build.icons( { formats: [ 'esnext' ] } ) );
  58. gulp.task( 'build:js:esnext', [ 'build:clean:js:esnext' ], () => ckeditor5DevBuilder.build.js( { formats: [ 'esnext' ] } ) );
  59. gulp.task( 'build:themes:esnext', ( callback ) => {
  60. runSequence( 'build:clean:themes:esnext', 'build:icons:esnext', 'build:sass:esnext', callback );
  61. } );
  62. // Tasks specific for testing under node.
  63. gulp.task( 'build:clean:js:cjs', () => ckeditor5DevBuilder.clean.js( { formats: [ 'cjs' ] } ) );
  64. gulp.task( 'build:js:cjs', [ 'build:clean:js:cjs' ], () => ckeditor5DevBuilder.build.js( { formats: [ 'cjs' ] } ) );