How to use @ckeditor/ckeditor5-dev-utils - 10 common examples

To help you get started, we’ve selected a few @ckeditor/ckeditor5-dev-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / lib / tests.js View on Github external
bundleDir = path.join( rootDir, bundleDir );

		const ckeditor5DevBundler = require( '@ckeditor/ckeditor5-dev-bundler-rollup' )( {
			ROOT_DIR: rootDir,
			MODULE_DIR: {
				esnext: ''
			},
			BUNDLE_DIR: bundleDir
		} );

		return docsUtils.getSamplesStream( rootDir, samplesGlob )
			.pipe( gulpFilter( ( file ) => path.extname( file.path ) === '.js' ) )
			.pipe( gulpRename( ( file ) => {
				file.dirname = file.dirname.replace( '/docs/samples', '' );
			} ) )
			.pipe( stream.noop( ( file ) => {
				const bundleConfig = docsUtils.getBundlerConfigFromSample( file.contents.toString( 'utf-8' ) );
				bundleConfig.format = 'iife';
				bundleConfig.path = file.path.match( /\/samples\/(.*)\.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 );
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / bin / prepare-mrgit-json.js View on Github external
* For licensing, see LICENSE.md.
 */

'use strict';

const TEST_DIR_PATH = process.argv[ 2 ];

if ( !TEST_DIR_PATH ) {
	throw new Error( 'The script requires one parameter: a path to the testing directory.' );
}

const path = require( 'path' );
const createMrGitJsonContent = require( '../lib/bin/createmrgitjsoncontent' );
const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );

tools.updateJSONFile( path.join( TEST_DIR_PATH, 'mrgit.json' ), () => {
	const originalPackageJson = require( path.join( process.cwd(), 'package.json' ) );
	const testingPackageJson = require( path.join( TEST_DIR_PATH, 'package.json' ) );

	return createMrGitJsonContent( testingPackageJson, {
		packageName: originalPackageJson.name,
		// For PR build we want to get the latest commit from given PR instead of Merge Commit.
		// See: https://github.com/ckeditor/ckeditor5-dev/issues/484
		commit: process.env.TRAVIS_PULL_REQUEST_SHA || process.env.TRAVIS_COMMIT,
		// Specify a repository that provides the package specified as `packageName` and which should be cloned.
		// Forked repositories should be able to execute the test scenario as well.
		// See: https://github.com/ckeditor/ckeditor5-dev/issues/542.
		repository: process.env.TRAVIS_PULL_REQUEST_SLUG || process.env.TRAVIS_REPO_SLUG
	} );
} );
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / lib / utils / automated-tests / getwebpackconfig.js View on Github external
/**
 * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const path = require( 'path' );
const escapedPathSep = path.sep == '/' ? '/' : '\\\\';
const { getPostCssConfig } = require( '@ckeditor/ckeditor5-dev-utils' ).styles;

/**
 * @param {Object} options
 * @returns {Object}
 */
module.exports = function getWebpackConfigForAutomatedTests( options ) {
	const config = {
		mode: 'development',

		module: {
			rules: [
				{
					// test: **/ckeditor5-*/theme/icons/*.svg
					test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
					use: [ 'raw-loader' ]
				},
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / lib / utils / manual-tests / getwebpackconfig.js View on Github external
/**
 * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const path = require( 'path' );
const WebpackNotifierPlugin = require( './webpacknotifierplugin' );
const { getPostCssConfig } = require( '@ckeditor/ckeditor5-dev-utils' ).styles;
const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' );

/**
 * @param {Object} options
 * @param {Object} options.entries
 * @param {String} options.buildDir
 * @param {String} options.themePath
 * @param {String} [options.language]
 * @param {Array.} [options.additionalLanguages]
 * @returns {Object}
 */
module.exports = function getWebpackConfigForManualTests( options ) {
	return {
		mode: 'development',

		// Use cheap source maps because Safari had problem with ES6 + inline source maps.
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / lib / utils / automated-tests / getwebpackconfig.js View on Github external
module: {
			rules: [
				{
					// test: **/ckeditor5-*/theme/icons/*.svg
					test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
					use: [ 'raw-loader' ]
				},
				{
					// test: **/ckeditor5-*/theme/**/*.css
					test: /\.css$/,
					use: [
						'style-loader',
						{
							loader: 'postcss-loader',
							options: getPostCssConfig( {
								themeImporter: {
									themePath: options.themePath
								},
								minify: true
							} )
						},
					]
				},
				{
					test: /\.(txt|html|rtf)$/,
					use: [ 'raw-loader' ]
				},
				{
					test: /\.js$/,
					loader: require.resolve( '../ck-debug-loader' ),
					query: {
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / lib / tests.js View on Github external
const fileName = splitPath.slice( -1 ).join();
						const builtEditorPath = path.join( bundleDir, bundleConfig.path, bundleConfig.moduleName );
						const destinationPath = path.join.apply( null, [
							testPath,
							'tests',
							packageName,
							'samples',
							beginPath,
							'_assets',
							fileName
						] );

						// Copy editor builds to proper directory.
						return Promise.all( [
							tools.copyFile( `${ builtEditorPath }.js`, `${ destinationPath }.js` ),
							tools.copyFile( `${ builtEditorPath }.css`, `${ destinationPath }.css` )
						] );
					} )
					// And clean up.
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-env / lib / release-tools / utils / transform-commit / getchangedfilesforcommit.js View on Github external
module.exports = function getChangedFilesForCommit( commitId ) {
	const gitCommand = `git log -m -1 --name-only --pretty="format:" ${ commitId }`;
	const changedFiles = tools.shExec( gitCommand, { verbosity: 'error' } ).trim();

	// Merge commits can have two parents. Returned files for merge commits looks like:
	// file1            <-- files from merged branch
	// file2            <-- files from merged branch
	// file             <-- files from merged branch
	//
	// other-file1      <-- files from last commit before merge
	// other-file2      <-- files from last commit before merge
	// We need to filter out files from commit before merge.

	return changedFiles.split( '\n\n' )[ 0 ].split( '\n' );
};
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-env / lib / release-tools / tasks / generatechangelogforsubpackages.js View on Github external
module.exports = function generateChangelogForSubPackages( options ) {
	const log = logger();
	const cwd = process.cwd();

	const pathsCollection = getSubPackagesPaths( {
		cwd: options.cwd,
		packages: options.packages,
		skipPackages: options.skipPackages || []
	} );

	const skippedPackages = new Set();
	const generatedChangelogsMap = new Map();

	return executeOnPackages( pathsCollection.matched, generateChangelogTask )
		.then( () => {
			process.chdir( cwd );

			// No changelog has generated. Abort.
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-env / lib / release-tools / tasks / generatesummarychangelog.js View on Github external
module.exports = function generateSummaryChangelog( options ) {
	const log = logger();
	const cwd = process.cwd();

	const indent = ' '.repeat( cliUtils.INDENT_SIZE );
	const pathsCollection = getSubRepositoriesPaths( {
		cwd: options.cwd,
		packages: options.packages,
		scope: options.scope || null,
		skipPackages: options.skipPackages || [],
		skipMainRepository: true
	} );

	// The main repository must be at the end because its changelog is a summary of all changes that have been done.
	if ( !options.skipMainRepository ) {
		pathsCollection.skipped.delete( options.cwd );
		pathsCollection.matched.add( options.cwd );
	}
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-env / lib / translations / collect-utils.js View on Github external
/**
 * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const del = require( 'del' );
const glob = require( 'glob' );
const fs = require( 'fs-extra' );
const path = require( 'path' );
const logger = require( '@ckeditor/ckeditor5-dev-utils' ).logger();
const { findOriginalStrings } = require( '@ckeditor/ckeditor5-dev-utils' ).translations;

const langContextSuffix = path.join( 'lang', 'contexts.json' );
const corePackageName = 'ckeditor5-core';

const utils = {
	/**
	 * Collect translations and return array of translations.
	 *
	 * @returns {Array.}
	 */
	collectTranslations() {
		const srcPaths = [ process.cwd(), 'packages', '*', 'src', '**', '*.js' ].join( '/' );

		const files = glob.sync( srcPaths )
			.filter( srcPath => !srcPath.match( /packages\/[^/]+\/src\/lib\// ) );