8
0
Piotrek Koszuliński 9 лет назад
Родитель
Сommit
f9817ddf45
2 измененных файлов с 42 добавлено и 42 удалено
  1. 25 28
      dev/tasks/bundle/tasks.js
  2. 17 14
      dev/tasks/bundle/utils.js

+ 25 - 28
dev/tasks/bundle/tasks.js

@@ -26,40 +26,41 @@ module.exports = ( config ) => {
 
 
 	const tasks = {
 	const tasks = {
 		/**
 		/**
-		 * Remove all files from bundle directory.
+		 * Removes all files from bundle directory.
 		 */
 		 */
 		clean() {
 		clean() {
 			return utils.clean( bundleDir, '*.*' );
 			return utils.clean( bundleDir, '*.*' );
 		},
 		},
 
 
 		/**
 		/**
-		 * Combine whole editor files into two files `ckeditor.js` and `ckeditor.css`.
+		 * Combines whole editor files into two files `ckeditor.js` and `ckeditor.css`.
 		 *
 		 *
 		 * For JS bundle is required to pass configuration file `gulp bundle --config path/to/file.js` where
 		 * For JS bundle is required to pass configuration file `gulp bundle --config path/to/file.js` where
 		 * we need to specify which editor and features we want to include in our bundle.
 		 * we need to specify which editor and features we want to include in our bundle.
 		 *
 		 *
-		 * 		example-config-file.js:
-		 * 		module.exports = {
-		 * 			// Name of CKEditor instance exposed as global variable by a bundle.
-		 * 			moduleName: 'MyCKEditor',
+		 *		// example-config-file.js:
 		 *
 		 *
-		 * 			// Path to specified editor.
-		 * 			// It could be a path relative to `build/esnext/ckeditor5` directory e.g. `classic-editor/classic.js`
-		 * 			// or path relative to directory where build task will be executed `./full/path/to/custom/editor.js`.
-		 * 			editor: 'classic-editor/classic.js',
+		 *		module.exports = {
+		 *			// Name of CKEditor instance exposed as global variable by a bundle.
+		 *			moduleName: 'MyCKEditor',
 		 *
 		 *
-		 * 			// List of features.
-		 * 			features: [
-		 * 				// It could be a plugin name only if plugin is a default CKEditor plugin.
-		 * 				'delete',
+		 *			// Path to specified editor.
+		 *			// It could be a path relative to `build/esnext/ckeditor5` directory e.g. `classic-editor/classic.js`
+		 *			// or path relative to directory where build task will be executed `./full/path/to/custom/editor.js`.
+		 *			editor: 'classic-editor/classic.js',
 		 *
 		 *
-		 * 				// It could be a path relative to `build/esnext/ckeditor5` directory.
-		 * 				`typing/typing.js`
+		 *			// List of features.
+		 *			features: [
+		 *				// It could be a plugin name only if plugin is a default CKEditor plugin.
+		 *				'delete',
 		 *
 		 *
-		 * 				// Or it could be a path relative to directory where build task will be executed.
-		 * 				'./path/to/some/custom/feature.js',
-		 * 			]
-		 * 		}
+		 *				// It could be a path relative to `build/esnext/ckeditor5` directory.
+		 *				`typing/typing.js`
+		 *
+		 *				// Or it could be a path relative to directory where build task will be executed.
+		 *				'./path/to/some/custom/feature.js',
+		 *			]
+		 *		};
 		 *
 		 *
 		 * @param {String} configFilePath Path to the bundle configuration file.
 		 * @param {String} configFilePath Path to the bundle configuration file.
 		 * @returns {Promise} Promise that resolve bundling for CSS and JS.
 		 * @returns {Promise} Promise that resolve bundling for CSS and JS.
@@ -81,9 +82,7 @@ module.exports = ( config ) => {
 			mkdirp.sync( bundleTmpDir );
 			mkdirp.sync( bundleTmpDir );
 			fs.writeFileSync( temporaryEntryFilePath, utils.renderEntryFileContent( bundleTmpDir, config ) );
 			fs.writeFileSync( temporaryEntryFilePath, utils.renderEntryFileContent( bundleTmpDir, config ) );
 
 
-			/**
-			 * Bundling JS by Rollup.
-			 */
+			// Bundling JS by Rollup.
 			function bundleJS() {
 			function bundleJS() {
 				const outputFile = path.join( bundleDir, 'ckeditor.js' );
 				const outputFile = path.join( bundleDir, 'ckeditor.js' );
 
 
@@ -113,17 +112,15 @@ module.exports = ( config ) => {
 				} );
 				} );
 			}
 			}
 
 
-			/**
-			 * CSS is already bundled by a build task, so we need only to copy it.
-			 */
-			function bundleCSS() {
+			// CSS is already bundled by a build task, so we need only to copy it.
+			function bundleCss() {
 				const cssSource = path.join( sourceBuildDir, 'theme', 'ckeditor.css' );
 				const cssSource = path.join( sourceBuildDir, 'theme', 'ckeditor.css' );
 
 
 				return utils.copyFile( cssSource, bundleDir );
 				return utils.copyFile( cssSource, bundleDir );
 			}
 			}
 
 
 			// Lets wait for both - JS and CSS.
 			// Lets wait for both - JS and CSS.
-			return Promise.all( [ bundleJS(), bundleCSS() ] );
+			return Promise.all( [ bundleJS(), bundleCss() ] );
 		},
 		},
 
 
 		minify: {
 		minify: {

+ 17 - 14
dev/tasks/bundle/utils.js

@@ -63,7 +63,7 @@ const utils = {
 	},
 	},
 
 
 	/**
 	/**
-	 * Transform first letter of passed string to the uppercase.
+	 * Transforms first letter of passed string to the uppercase.
 	 *
 	 *
 	 * @param {String} string String that will be transformed.
 	 * @param {String} string String that will be transformed.
 	 * @returns {String} Transformed string.
 	 * @returns {String} Transformed string.
@@ -73,7 +73,7 @@ const utils = {
 	},
 	},
 
 
 	/**
 	/**
-	 * Render content for the entry file which needs to be passed as main file to the Rollup.
+	 * Renders content for the entry file which needs to be passed as main file to the Rollup.
 	 *
 	 *
 	 * @param {String} dir Path to the entryfile directory. Import paths need to be relative to this directory.
 	 * @param {String} dir Path to the entryfile directory. Import paths need to be relative to this directory.
 	 * @param {Object} data Configuration object.
 	 * @param {Object} data Configuration object.
@@ -140,7 +140,7 @@ export default class ${ data.moduleName } extends ${ creatorName } {
 	},
 	},
 
 
 	/**
 	/**
-	 * Save files from stream in specific destination and add `.min` suffix to the name.
+	 * Saves files from stream in specific destination and add `.min` suffix to the name.
 	 *
 	 *
 	 * @param {Stream} stream Source stream.
 	 * @param {Stream} stream Source stream.
 	 * @param {String} destination Path to the destination directory.
 	 * @param {String} destination Path to the destination directory.
@@ -155,7 +155,7 @@ export default class ${ data.moduleName } extends ${ creatorName } {
 	},
 	},
 
 
 	/**
 	/**
-	 * Copy specified file to specified destination.
+	 * Copies specified file to specified destination.
 	 *
 	 *
 	 * @param {String} from Source path.
 	 * @param {String} from Source path.
 	 * @param {String} to Destination directory.
 	 * @param {String} to Destination directory.
@@ -170,7 +170,7 @@ export default class ${ data.moduleName } extends ${ creatorName } {
 	},
 	},
 
 
 	/**
 	/**
-	 * Get size of the file.
+	 * Gets size of the file.
 	 *
 	 *
 	 * @param {String} path Path to the file.
 	 * @param {String} path Path to the file.
 	 * @returns {Number} Size in bytes.
 	 * @returns {Number} Size in bytes.
@@ -180,7 +180,7 @@ export default class ${ data.moduleName } extends ${ creatorName } {
 	},
 	},
 
 
 	/**
 	/**
-	 * Get human readable gzipped size of the file.
+	 * Gets human readable gzipped size of the file.
 	 *
 	 *
 	 * @param {String} path Path to the file.
 	 * @param {String} path Path to the file.
 	 * @returns {Number} Size in bytes.
 	 * @returns {Number} Size in bytes.
@@ -190,14 +190,17 @@ export default class ${ data.moduleName } extends ${ creatorName } {
 	},
 	},
 
 
 	/**
 	/**
-	 * Get normal and gzipped size of every passed file in specified directory.
+	 * Gets normal and gzipped size of every passed file in specified directory.
 	 *
 	 *
 	 * @param {Array.<String>} files List of file paths.
 	 * @param {Array.<String>} files List of file paths.
 	 * @param {String} [rootDir=''] When each file is in the same directory.
 	 * @param {String} [rootDir=''] When each file is in the same directory.
 	 * @returns {Array.<Object>} List with file size data.
 	 * @returns {Array.<Object>} List with file size data.
-	 * @returns {Array.<Object.name>} File name.
-	 * @returns {Array.<Object.size>} File size in human readable format.
-	 * @returns {Array.<Object.gzippedSize>} Gzipped file size in human readable format.
+	 *
+	 * Objects contain the following fields:
+	 *
+	 * * name – File name.
+	 * * size – File size in human readable format.
+	 * * gzippedSize – Gzipped file size in human readable format.
 	 */
 	 */
 	getFilesSizeStats( files, rootDir = '' ) {
 	getFilesSizeStats( files, rootDir = '' ) {
 		return files.map( ( file ) => {
 		return files.map( ( file ) => {
@@ -212,11 +215,11 @@ export default class ${ data.moduleName } extends ${ creatorName } {
 	},
 	},
 
 
 	/**
 	/**
-	 * Print on console summary with a list of files with their size stats.
+	 * Prints on console summary with a list of files with their size stats.
 	 *
 	 *
-	 * 		Title:
-	 * 		file.js: 1 MB (gzipped: 400 kB)
-	 * 		file.css 500 kB (gzipped: 100 kB)
+	 *		Title:
+	 *		file.js: 1 MB (gzipped: 400 kB)
+	 *		file.css 500 kB (gzipped: 100 kB)
 	 *
 	 *
 	 * @param {String} title Summary title.
 	 * @param {String} title Summary title.
 	 * @param {Array.<Object>} filesStats
 	 * @param {Array.<Object>} filesStats