8
0

tasks.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. module.exports = ( config ) => {
  15. const ckeditor5Path = process.cwd();
  16. const packageJSON = require( '../../../package.json' );
  17. const tasks = {
  18. updateRepositories() {
  19. const options = minimist( process.argv.slice( 2 ), {
  20. boolean: [ 'npm-update' ],
  21. default: {
  22. 'npm-update': false
  23. }
  24. } );
  25. return updateTask( installTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, options[ 'npm-update' ] );
  26. },
  27. checkStatus() {
  28. return statusTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR );
  29. },
  30. initRepository() {
  31. return initTask( installTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR );
  32. },
  33. createPackage( done ) {
  34. pluginCreateTask( ckeditor5Path, config.WORKSPACE_DIR )
  35. .then( done )
  36. .catch( ( error ) => done( error ) );
  37. },
  38. relink() {
  39. return relinkTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR );
  40. },
  41. installPackage() {
  42. const options = minimist( process.argv.slice( 2 ), {
  43. string: [ 'package' ],
  44. default: {
  45. plugin: ''
  46. }
  47. } );
  48. if ( options.package ) {
  49. return installTask( ckeditor5Path, config.WORKSPACE_DIR, options.package );
  50. } else {
  51. throw new Error( 'Please provide a package to install: gulp dev-install --plugin <path|GitHub URL|name>' );
  52. }
  53. },
  54. register() {
  55. gulp.task( 'init', tasks.initRepository );
  56. gulp.task( 'create-package', tasks.createPackage );
  57. gulp.task( 'update', tasks.updateRepositories );
  58. gulp.task( 'pull', tasks.updateRepositories );
  59. gulp.task( 'status', tasks.checkStatus );
  60. gulp.task( 'st', tasks.checkStatus );
  61. gulp.task( 'relink', tasks.relink );
  62. gulp.task( 'install', tasks.installPackage );
  63. }
  64. };
  65. return tasks;
  66. };