Explorar o código

Introduced `ckeditor5-dev-tests` package and cleaned up the `gulpfile.js`.

Kamil Piechaczek %!s(int64=9) %!d(string=hai) anos
pai
achega
767f3aec16
Modificáronse 2 ficheiros con 4 adicións e 84 borrados
  1. 3 84
      gulpfile.js
  2. 1 0
      package.json

+ 3 - 84
gulpfile.js

@@ -128,13 +128,15 @@ gulp.task( 'bundle:generate',
 	ckeditor5DevBundler.generateFromConfig
 );
 
+const ckeditor5DevTests = require( '@ckeditor/ckeditor5-dev-tests' )( config );
+
 // Task specific for building editors for testing releases.
 gulp.task( 'compile:bundled-sample-tests:build-editors',
 	[
 		'compile:js:esnext',
 		'compile:themes:esnext'
 	],
-	buildEditorsForSamples
+	ckeditor5DevTests.buildEditorsForSamples
 );
 
 // Documentation. -------------------------------------------------------------
@@ -142,86 +144,3 @@ gulp.task( 'compile:bundled-sample-tests:build-editors',
 const docsBuilder = ckeditor5DevCompiler.docs( config );
 
 gulp.task( 'docs', [ 'compile:js:esnext' ], docsBuilder.buildDocs );
-
-// Testing. -------------------------------------------------------------------
-
-// TODO The below code is here only temporarily. It will be extracted to a separate 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' );
-	const { stream, 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 ) );
-		} ) );
-}

+ 1 - 0
package.json

@@ -29,6 +29,7 @@
     "@ckeditor/ckeditor5-dev-compiler": "ckeditor/ckeditor5-dev-compiler",
     "@ckeditor/ckeditor5-dev-env": "^1.0.0",
     "@ckeditor/ckeditor5-dev-lint": "^1.0.1",
+    "@ckeditor/ckeditor5-dev-tests": "ckeditor/ckeditor5-dev-tests",
     "@ckeditor/ckeditor5-dev-utils": "ckeditor/ckeditor5-dev-utils",
     "babel-polyfill": "^6.13.0",
     "benderjs": "^0.4.1",