gulpfile.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. // Lint tasks.
  22. const ckeditor5Lint = require( 'ckeditor5-dev-lint' )( config );
  23. gulp.task( 'lint', ckeditor5Lint.lint );
  24. gulp.task( 'lint-staged', ckeditor5Lint.lintStaged );
  25. gulp.task( 'default', [ 'build' ] );
  26. gulp.task( 'pre-commit', [ 'lint-staged' ] );
  27. // Development environment tasks.
  28. const ckeditor5DevEnv = require( 'ckeditor5-dev-env' )( config );
  29. gulp.task( 'init', ckeditor5DevEnv.initRepository );
  30. gulp.task( 'create-package', ckeditor5DevEnv.createPackage );
  31. gulp.task( 'update', ckeditor5DevEnv.updateRepositories );
  32. gulp.task( 'pull', ckeditor5DevEnv.updateRepositories );
  33. gulp.task( 'status', ckeditor5DevEnv.checkStatus );
  34. gulp.task( 'st', ckeditor5DevEnv.checkStatus );
  35. gulp.task( 'relink', ckeditor5DevEnv.relink );
  36. gulp.task( 'install', ckeditor5DevEnv.installPackage );
  37. gulp.task( 'exec', ckeditor5DevEnv.execOnRepositories );
  38. // Build tasks.
  39. const ckeditor5DevBuilder = require( 'ckeditor5-dev-builder' )( config );
  40. const builder = ckeditor5DevBuilder.builder;
  41. gulp.task( 'build', callback => {
  42. runSequence( 'build:clean:all', 'build:themes', 'build:js', callback );
  43. } );
  44. gulp.task( 'build:clean:all', builder.clean.all );
  45. gulp.task( 'build:clean:themes', builder.clean.themes );
  46. gulp.task( 'build:clean:js', () => builder.clean.js() );
  47. gulp.task( 'build:themes', ( callback ) => {
  48. runSequence( 'build:clean:themes', 'build:icons', 'build:sass', callback );
  49. } );
  50. gulp.task( 'build:sass', () => builder.build.sass() );
  51. gulp.task( 'build:icons', () => builder.build.icons() );
  52. gulp.task( 'build:js', [ 'build:clean:js' ], () => builder.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', () => builder.clean.js( { formats: [ 'esnext' ] } ) );
  55. gulp.task( 'build:clean:themes:esnext', () => builder.clean.themes( { formats: [ 'esnext' ] } ) );
  56. gulp.task( 'build:sass:esnext', () => builder.build.sass( { formats: [ 'esnext' ] } ) );
  57. gulp.task( 'build:icons:esnext', () => builder.build.icons( { formats: [ 'esnext' ] } ) );
  58. gulp.task( 'build:js:esnext', [ 'build:clean:js:esnext' ], () => builder.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', () => builder.clean.js( { formats: [ 'cjs' ] } ) );
  64. gulp.task( 'build:js:cjs', [ 'build:clean:js:cjs' ], () => builder.build.js( { formats: [ 'cjs' ] } ) );
  65. // Docs.
  66. const docsBuilder = ckeditor5DevBuilder.docs;
  67. gulp.task( 'docs', [ 'build:js:esnext' ], docsBuilder.buildDocs );