gulpfile.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* eslint-env node */
  6. 'use strict';
  7. const path = require( 'path' );
  8. const gulp = require( 'gulp' );
  9. // Lint tasks. ---------------------------------------------------------------
  10. const ckeditor5Lint = require( '@ckeditor/ckeditor5-dev-lint' );
  11. gulp.task( 'lint', () => ckeditor5Lint.lint() );
  12. gulp.task( 'lint-staged', () => ckeditor5Lint.lintStaged() );
  13. gulp.task( 'pre-commit', [ 'lint-staged' ] );
  14. // Tests. ---------------------------------------------------------------------
  15. gulp.task( 'test', () => {
  16. return require( '@ckeditor/ckeditor5-dev-tests' )
  17. .runAutomatedTests( getTestOptions() );
  18. } );
  19. gulp.task( 'test:manual', () => {
  20. return require( '@ckeditor/ckeditor5-dev-tests' )
  21. .runManualTests( getTestOptions() );
  22. } );
  23. function getTestOptions() {
  24. return require( '@ckeditor/ckeditor5-dev-tests' )
  25. .parseArguments( process.argv.slice( 2 ) );
  26. }
  27. // Documentation. -------------------------------------------------------------
  28. gulp.task( 'docs', () => {
  29. assertIsInstalled( '@ckeditor/ckeditor5-dev-docs' );
  30. assertIsInstalled( 'umberto' );
  31. const umberto = require( 'umberto' );
  32. const ckeditor5Docs = require( '@ckeditor/ckeditor5-dev-docs' );
  33. if ( process.argv[ 3 ] == '--no-api' ) {
  34. return runUmberto();
  35. }
  36. return ckeditor5Docs
  37. .build( {
  38. readmePath: path.join( process.cwd(), 'README.md' ),
  39. sourceFiles: [
  40. process.cwd() + '/packages/ckeditor5-*/src/**/*.@(js|jsdoc)',
  41. '!' + process.cwd() + '/packages/ckeditor5-*/src/lib/**/*.js'
  42. ]
  43. } )
  44. .then( runUmberto );
  45. function runUmberto() {
  46. return umberto.buildSingleProject( {
  47. configDir: 'docs',
  48. clean: true
  49. } );
  50. }
  51. } );
  52. // Translations. --------------------------------------------------------------
  53. gulp.task( 'translations:collect', () => {
  54. assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
  55. return require( '@ckeditor/ckeditor5-dev-env' ).collectTranslations();
  56. } );
  57. gulp.task( 'translations:upload', () => {
  58. assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
  59. return require( '@ckeditor/ckeditor5-dev-env' ).uploadTranslations();
  60. } );
  61. gulp.task( 'translations:download', () => {
  62. assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
  63. return require( '@ckeditor/ckeditor5-dev-env' ).downloadTranslations();
  64. } );
  65. // Releasing. -----------------------------------------------------------------
  66. gulp.task( 'changelog:dependencies', () => {
  67. assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
  68. return require( '@ckeditor/ckeditor5-dev-env' )
  69. .generateChangelogForSubRepositories( {
  70. cwd: process.cwd(),
  71. packages: 'packages'
  72. } );
  73. } );
  74. gulp.task( 'release:dependencies', () => {
  75. assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
  76. return require( '@ckeditor/ckeditor5-dev-env' )
  77. .releaseSubRepositories( {
  78. cwd: process.cwd(),
  79. packages: 'packages'
  80. } );
  81. } );
  82. // Utils. ---------------------------------------------------------------------
  83. function assertIsInstalled( packageName ) {
  84. try {
  85. require( packageName + '/package.json' );
  86. } catch ( err ) {
  87. console.error( `Error: Cannot find package '${ packageName }'.\n` );
  88. console.error( 'You need to install optional dependencies.' );
  89. console.error( 'Run: \'npm run install-optional-dependencies\'.' );
  90. process.exit( 1 );
  91. }
  92. }