| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- /* eslint-env node */
- 'use strict';
- const path = require( 'path' );
- const gulp = require( 'gulp' );
- // Tests. ---------------------------------------------------------------------
- gulp.task( 'test', () => {
- return require( '@ckeditor/ckeditor5-dev-tests' )
- .runAutomatedTests( getTestOptions() );
- } );
- gulp.task( 'test:manual', () => {
- return require( '@ckeditor/ckeditor5-dev-tests' )
- .runManualTests( getTestOptions() );
- } );
- function getTestOptions() {
- return require( '@ckeditor/ckeditor5-dev-tests' )
- .parseArguments( process.argv.slice( 2 ) );
- }
- // Documentation. -------------------------------------------------------------
- gulp.task( 'docs', () => {
- const skipLiveSnippets = process.argv.includes( '--skip-snippets' );
- const skipApi = process.argv.includes( '--skip-api' );
- const production = process.argv.includes( '--production' );
- if ( skipApi ) {
- const fs = require( 'fs' );
- const apiJsonPath = './docs/api/output.json';
- if ( fs.existsSync( apiJsonPath ) ) {
- fs.unlinkSync( apiJsonPath );
- }
- return runUmberto( {
- skipLiveSnippets,
- skipApi,
- production
- } );
- }
- // Simple way to reuse existing api/output.json:
- // return Promise.resolve()
- return buildApiDocs()
- .then( () => {
- return runUmberto( {
- skipLiveSnippets,
- production
- } );
- } );
- } );
- gulp.task( 'docs:api', buildApiDocs );
- function buildApiDocs() {
- assertIsInstalled( '@ckeditor/ckeditor5-dev-docs' );
- const ckeditor5Docs = require( '@ckeditor/ckeditor5-dev-docs' );
- return ckeditor5Docs
- .build( {
- readmePath: path.join( process.cwd(), 'README.md' ),
- sourceFiles: [
- process.cwd() + '/packages/ckeditor5-*/src/**/*.@(js|jsdoc)',
- '!' + process.cwd() + '/packages/ckeditor5-*/src/lib/**/*.js',
- '!' + process.cwd() + '/packages/ckeditor5-build-*/src/**/*.js'
- ],
- validateOnly: process.argv[ 3 ] == '--validate-only'
- } );
- }
- function runUmberto( options ) {
- assertIsInstalled( 'umberto' );
- const umberto = require( 'umberto' );
- return umberto.buildSingleProject( {
- configDir: 'docs',
- clean: true,
- skipLiveSnippets: options.skipLiveSnippets,
- snippetOptions: {
- production: options.production
- },
- skipApi: options.skipApi
- } );
- }
- // Translations. --------------------------------------------------------------
- gulp.task( 'translations:collect', () => {
- assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
- return require( '@ckeditor/ckeditor5-dev-env' ).collectTranslations();
- } );
- gulp.task( 'translations:upload', () => {
- assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
- return require( '@ckeditor/ckeditor5-dev-env' ).uploadTranslations();
- } );
- gulp.task( 'translations:download', () => {
- assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
- return require( '@ckeditor/ckeditor5-dev-env' ).downloadTranslations();
- } );
- // Releasing. -----------------------------------------------------------------
- gulp.task( 'changelog', () => {
- assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
- const devEnv = require( '@ckeditor/ckeditor5-dev-env' );
- const commonOptions = {
- cwd: process.cwd(),
- packages: 'packages'
- };
- const editorBuildsGlob = '@ckeditor/ckeditor5-build-*';
- const optionsForDependencies = Object.assign( {}, commonOptions, {
- skipPackages: editorBuildsGlob
- } );
- const optionsForBuilds = Object.assign( {}, commonOptions, {
- scope: editorBuildsGlob
- } );
- return Promise.resolve()
- .then( () => devEnv.generateChangelogForSubRepositories( optionsForDependencies ) )
- .then( () => devEnv.generateSummaryChangelog( optionsForBuilds ) );
- } );
- gulp.task( 'release:dependencies', () => {
- assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
- return require( '@ckeditor/ckeditor5-dev-env' )
- .releaseSubRepositories( {
- cwd: process.cwd(),
- packages: 'packages'
- } );
- } );
- // Utils. ---------------------------------------------------------------------
- function assertIsInstalled( packageName ) {
- try {
- require( packageName + '/package.json' );
- } catch ( err ) {
- console.error( `Error: Cannot find package '${ packageName }'.\n` );
- console.error( 'You need to install optional dependencies.' );
- console.error( 'Run: \'npm run install-optional-dependencies\'.' );
- process.exit( 1 );
- }
- }
|