8
0

tasks.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. gulp.task( 'init', () => {
  18. initTask( installTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log );
  19. } );
  20. gulp.task( 'create-package', ( done ) => {
  21. pluginCreateTask( ckeditor5Path, config.WORKSPACE_DIR, console.log )
  22. .then( done )
  23. .catch( ( error ) => done( error ) );
  24. } );
  25. gulp.task( 'update', () => {
  26. const options = minimist( process.argv.slice( 2 ), {
  27. boolean: [ 'npm-update' ],
  28. default: {
  29. 'npm-update': false
  30. }
  31. } );
  32. updateTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log, options[ 'npm-update' ] );
  33. } );
  34. gulp.task( 'status', () => {
  35. statusTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log, console.error );
  36. } );
  37. gulp.task( 'relink', () => {
  38. relinkTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log, console.error );
  39. } );
  40. gulp.task( 'install', () => {
  41. const options = minimist( process.argv.slice( 2 ), {
  42. string: [ 'package' ],
  43. default: {
  44. plugin: ''
  45. }
  46. } );
  47. if ( options.package ) {
  48. installTask( ckeditor5Path, config.WORKSPACE_DIR, options.package, console.log );
  49. } else {
  50. throw new Error( 'Please provide a package to install: gulp dev-install --plugin <path|GitHub URL|name>' );
  51. }
  52. } );
  53. };