|
@@ -101,7 +101,7 @@ gulp.task( 'compile:themes:esnext', callback => {
|
|
|
|
|
|
|
|
// Building tasks. ------------------------------------------------------------
|
|
// Building tasks. ------------------------------------------------------------
|
|
|
|
|
|
|
|
-const ckeditor5DevBundle = require( '@ckeditor/ckeditor5-dev-bundler-rollup' )( config );
|
|
|
|
|
|
|
+const ckeditor5DevBundler = require( '@ckeditor/ckeditor5-dev-bundler-rollup' )( config );
|
|
|
|
|
|
|
|
gulp.task( 'build', callback => {
|
|
gulp.task( 'build', callback => {
|
|
|
runSequence(
|
|
runSequence(
|
|
@@ -110,15 +110,15 @@ gulp.task( 'build', callback => {
|
|
|
'bundle:minify:js',
|
|
'bundle:minify:js',
|
|
|
'bundle:minify:css'
|
|
'bundle:minify:css'
|
|
|
],
|
|
],
|
|
|
- () => ckeditor5DevBundle.showSummaryFromConfig( callback )
|
|
|
|
|
|
|
+ () => ckeditor5DevBundler.showSummaryFromConfig( callback )
|
|
|
);
|
|
);
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
// Helpers. ---------------------------
|
|
// Helpers. ---------------------------
|
|
|
|
|
|
|
|
-gulp.task( 'bundle:clean', ckeditor5DevBundle.cleanFromConfig );
|
|
|
|
|
-gulp.task( 'bundle:minify:js', ckeditor5DevBundle.minify.jsFromConfig );
|
|
|
|
|
-gulp.task( 'bundle:minify:css', ckeditor5DevBundle.minify.cssFromConfig );
|
|
|
|
|
|
|
+gulp.task( 'bundle:clean', ckeditor5DevBundler.cleanFromConfig );
|
|
|
|
|
+gulp.task( 'bundle:minify:js', ckeditor5DevBundler.minify.jsFromConfig );
|
|
|
|
|
+gulp.task( 'bundle:minify:css', ckeditor5DevBundler.minify.cssFromConfig );
|
|
|
|
|
|
|
|
// Generates the bundle without minifying it.
|
|
// Generates the bundle without minifying it.
|
|
|
gulp.task( 'bundle:generate',
|
|
gulp.task( 'bundle:generate',
|
|
@@ -127,7 +127,7 @@ gulp.task( 'bundle:generate',
|
|
|
'compile:js:esnext',
|
|
'compile:js:esnext',
|
|
|
'compile:themes:esnext'
|
|
'compile:themes:esnext'
|
|
|
],
|
|
],
|
|
|
- ckeditor5DevBundle.generateFromConfig
|
|
|
|
|
|
|
+ ckeditor5DevBundler.generateFromConfig
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
// Task specific for building editors for testing releases.
|
|
// Task specific for building editors for testing releases.
|
|
@@ -136,7 +136,7 @@ gulp.task( 'compile:bundled-sample-tests:build-editors',
|
|
|
'compile:js:esnext',
|
|
'compile:js:esnext',
|
|
|
'compile:themes:esnext'
|
|
'compile:themes:esnext'
|
|
|
],
|
|
],
|
|
|
- ckeditor5DevBundle.buildEditorsForSamples
|
|
|
|
|
|
|
+ buildEditorsForSamples
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
// Documentation. -------------------------------------------------------------
|
|
// Documentation. -------------------------------------------------------------
|
|
@@ -144,3 +144,86 @@ gulp.task( 'compile:bundled-sample-tests:build-editors',
|
|
|
const docsBuilder = ckeditor5DevCompiler.docs;
|
|
const docsBuilder = ckeditor5DevCompiler.docs;
|
|
|
|
|
|
|
|
gulp.task( 'docs', [ 'compile:js:esnext' ], docsBuilder.buildDocs );
|
|
gulp.task( 'docs', [ 'compile:js:esnext' ], docsBuilder.buildDocs );
|
|
|
|
|
+
|
|
|
|
|
+// Testing. -------------------------------------------------------------------
|
|
|
|
|
+
|
|
|
|
|
+// TODO The below code is here only temporarily. It will be extracted to a separat package
|
|
|
|
|
+// once we'll understand better where it should belong. Right now it's somewhere beyond testing
|
|
|
|
|
+// environment, compilation and documentation.
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Prepares configurations for bundler based on sample files and builds editors
|
|
|
|
|
+ * based on prepared configuration.
|
|
|
|
|
+ *
|
|
|
|
|
+ * You can find more details in: https://github.com/ckeditor/ckeditor5/issues/260
|
|
|
|
|
+ *
|
|
|
|
|
+ * @returns {Stream}
|
|
|
|
|
+ */
|
|
|
|
|
+function buildEditorsForSamples() {
|
|
|
|
|
+ const { utils: compilerUtils } = require( '@ckeditor/ckeditor5-dev-compiler' )( config );
|
|
|
|
|
+ const { stream, tools: tools } = require( '@ckeditor/ckeditor5-dev-utils' );
|
|
|
|
|
+
|
|
|
|
|
+ const gulpFilter = require( 'gulp-filter' );
|
|
|
|
|
+ const gulpRename = require( 'gulp-rename' );
|
|
|
|
|
+ const path = require( 'path' );
|
|
|
|
|
+
|
|
|
|
|
+ const bundleDir = path.join( config.ROOT_DIR, config.BUNDLE_DIR );
|
|
|
|
|
+
|
|
|
|
|
+ return compilerUtils.getFilesStream( config.ROOT_DIR, config.DOCUMENTATION.SAMPLES )
|
|
|
|
|
+ .pipe( gulpFilter( ( file ) => path.extname( file.path ) === '.js' ) )
|
|
|
|
|
+ .pipe( gulpRename( ( file ) => {
|
|
|
|
|
+ file.dirname = file.dirname.replace( '/docs/samples', '' );
|
|
|
|
|
+ } ) )
|
|
|
|
|
+ .pipe( stream.noop( ( file ) => {
|
|
|
|
|
+ const contents = file.contents.toString( 'utf-8' );
|
|
|
|
|
+ const bundleConfig = {};
|
|
|
|
|
+
|
|
|
|
|
+ // Prepare the config based on sample.
|
|
|
|
|
+
|
|
|
|
|
+ bundleConfig.format = 'iife';
|
|
|
|
|
+
|
|
|
|
|
+ // Find `moduleName` from line which ends with "// editor:name".
|
|
|
|
|
+ bundleConfig.moduleName = contents.match( /([a-z]+)\.create(.*)\/\/ ?editor:name/i )[ 1 ];
|
|
|
|
|
+
|
|
|
|
|
+ // Find `editor` from line which ends with "// editor:module".
|
|
|
|
|
+ bundleConfig.editor = contents.match( /([-a-z0-9]+\/[-a-z0-9]+)(\.js)?'; ?\/\/ ?editor:module/i )[ 1 ];
|
|
|
|
|
+
|
|
|
|
|
+ // Find `features` from line which ends with "// editor:features".
|
|
|
|
|
+ bundleConfig.features = contents.match( /(\[[^\]]+\]),? ?\/\/ ?(.*)editor:features/i )[ 1 ]
|
|
|
|
|
+ .match( /([a-z-\/]+)/gi );
|
|
|
|
|
+
|
|
|
|
|
+ // Extract `path` from Sample's path.
|
|
|
|
|
+ bundleConfig.path = file.path.match( /ckeditor5-(.*)\.js$/ )[ 1 ];
|
|
|
|
|
+
|
|
|
|
|
+ const splitPath = bundleConfig.path.split( path.sep );
|
|
|
|
|
+ const packageName = splitPath[ 0 ];
|
|
|
|
|
+
|
|
|
|
|
+ // Clean the output paths.
|
|
|
|
|
+ return ckeditor5DevBundler.clean( bundleConfig )
|
|
|
|
|
+ // Then bundle a editor.
|
|
|
|
|
+ .then( () => ckeditor5DevBundler.generate( bundleConfig ) )
|
|
|
|
|
+ // Then copy created files.
|
|
|
|
|
+ .then( () => {
|
|
|
|
|
+ const beginPath = splitPath.slice( 1, -1 ).join( path.sep ) || '.';
|
|
|
|
|
+ const fileName = splitPath.slice( -1 ).join();
|
|
|
|
|
+ const builtEditorPath = path.join( bundleDir, bundleConfig.path, bundleConfig.moduleName );
|
|
|
|
|
+ const destinationPath = path.join.apply( null, [
|
|
|
|
|
+ config.MODULE_DIR.amd,
|
|
|
|
|
+ 'tests',
|
|
|
|
|
+ packageName,
|
|
|
|
|
+ 'samples',
|
|
|
|
|
+ beginPath,
|
|
|
|
|
+ '_assets',
|
|
|
|
|
+ fileName
|
|
|
|
|
+ ] );
|
|
|
|
|
+
|
|
|
|
|
+ // Copy editor builds to proper directory.
|
|
|
|
|
+ return Promise.all( [
|
|
|
|
|
+ tools.copyFile( `${ builtEditorPath }.js`, destinationPath ),
|
|
|
|
|
+ tools.copyFile( `${ builtEditorPath }.css`, destinationPath )
|
|
|
|
|
+ ] );
|
|
|
|
|
+ } )
|
|
|
|
|
+ // And clean up.
|
|
|
|
|
+ .then( () => tools.clean( path.join( config.BUNDLE_DIR, packageName, '..' ), packageName ) );
|
|
|
|
|
+ } ) );
|
|
|
|
|
+}
|