8
0

tasks.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. const gulp = require( 'gulp' );
  7. const minimist = require( 'minimist' );
  8. const statusTask = require( './tasks/status' );
  9. const initTask = require( './tasks/init' );
  10. const installTask = require( './tasks/install' );
  11. const pluginCreateTask = require( './tasks/create-package' );
  12. const updateTask = require( './tasks/update' );
  13. const relinkTask = require( './tasks/relink' );
  14. const log = require( './utils/log' );
  15. const gutil = require( 'gulp-util' );
  16. module.exports = ( config ) => {
  17. const ckeditor5Path = process.cwd();
  18. const packageJSON = require( '../../../package.json' );
  19. // Configure logging.
  20. log.configure(
  21. ( msg ) => gutil.log( msg ),
  22. ( msg ) => gutil.log( gutil.colors.red( msg ) )
  23. );
  24. gulp.task( 'init', () => {
  25. initTask( installTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR );
  26. } );
  27. gulp.task( 'create-package', ( done ) => {
  28. pluginCreateTask( ckeditor5Path, config.WORKSPACE_DIR )
  29. .then( done )
  30. .catch( ( error ) => done( error ) );
  31. } );
  32. gulp.task( 'update', () => {
  33. const options = minimist( process.argv.slice( 2 ), {
  34. boolean: [ 'npm-update' ],
  35. default: {
  36. 'npm-update': false
  37. }
  38. } );
  39. updateTask( installTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, options[ 'npm-update' ] );
  40. } );
  41. gulp.task( 'status', () => {
  42. statusTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR );
  43. } );
  44. gulp.task( 'relink', () => {
  45. relinkTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR );
  46. } );
  47. gulp.task( 'install', () => {
  48. const options = minimist( process.argv.slice( 2 ), {
  49. string: [ 'package' ],
  50. default: {
  51. plugin: ''
  52. }
  53. } );
  54. if ( options.package ) {
  55. installTask( ckeditor5Path, config.WORKSPACE_DIR, options.package );
  56. } else {
  57. throw new Error( 'Please provide a package to install: gulp dev-install --plugin <path|GitHub URL|name>' );
  58. }
  59. } );
  60. };