Przeglądaj źródła

Merge branch 't/362'

Piotrek Koszuliński 9 lat temu
rodzic
commit
f5a225b606

+ 2 - 1
.jshintrc

@@ -1,4 +1,5 @@
 {
+  "node": true,
   "esnext": true,
   "immed": true,
   "loopfunc": true,
@@ -6,6 +7,6 @@
   "nonbsp": true,
   "undef": true,
   "unused": true,
-  "strict": "implied",
+  "strict": true,
   "varstmt": true
 }

+ 1 - 1
.travis.yml

@@ -18,4 +18,4 @@ install:
   - npm install
   - npm install @ckeditor/ckeditor5-dev-tests
 script:
-  - node_modules/.bin/ckeditor5-dev-tests --ignore-duplicates --reporter=dots --files=**/*.js
+  - node_modules/.bin/ckeditor5-dev-tests --reporter=dots

+ 0 - 37
build-config.js

@@ -1,37 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* jshint browser: false, node: true, strict: true */
-
-'use strict';
-
-module.exports = {
-	// Specify path where bundled editor will be saved.
-	destinationPath: './build/dist/',
-
-	editor: 'editor-classic/classic',
-	plugins: [
-		'autoformat',
-		'basic-styles/bold',
-		'basic-styles/italic',
-		'clipboard',
-		'enter',
-		'heading',
-		'image',
-		'link',
-		'list',
-		'paragraph',
-		'typing',
-		'undo'
-	],
-
-	rollupOptions: {
-		// Name of CKEditor instance exposed as global variable by a bundle.
-		moduleName: 'ClassicEditor',
-
-		// The format of the generated bundle.
-		format: 'iife',
-	}
-};

+ 0 - 8
build/README.md

@@ -1,8 +0,0 @@
-CKEditor 5 – Build Directory
-============================
-
-This directory contains files created during build process of CKEditor 5:
-
- - `dist` - bundled version of CKEditor 5, created by executing `gulp bundle` task. See more: [Bundling](https://github.com/ckeditor/ckeditor5/wiki/Development-Workflow#bundling).
- - `modules` - versions of CKEditor transpiled to specified module format: AMD, CommonJS and ES6 modules. See more: [Compiling CKEditor](https://github.com/ckeditor/ckeditor5/wiki/Development-Environment#compiling-ckeditor).
- - `docs` - JavaScript documentation created form source code by `gulp docs` task.

+ 21 - 160
gulpfile.js

@@ -3,51 +3,14 @@
  * For licensing, see LICENSE.md.
  */
 
-/* jshint browser: false, node: true, strict: true */
-
 'use strict';
 
 const path = require( 'path' );
 const gulp = require( 'gulp' );
-const runSequence = require( 'run-sequence' );
-const compiler = require( '@ckeditor/ckeditor5-dev-compiler' );
-
-const config = {
-	ROOT_DIR: '.',
-	MODULE_DIR: {
-		amd: './build/modules/amd',
-		cjs: './build/modules/cjs',
-		esnext: './build/modules/esnext'
-	},
-	BUNDLE_DIR: './build/dist',
-	WORKSPACE_DIR: '..',
-
-	// Path to the default configuration file for bundler.
-	BUNDLE_DEFAULT_CONFIG: './dev/bundles/build-config-standard.js',
-
-	DOCUMENTATION: {
-		// Path to the built editors.
-		BUNDLE_DIR: './build/docs/assets/scripts/samples',
-		// Path to the built documentation.
-		DESTINATION_DIR: './build/docs',
-		// Glob pattern with samples.
-		SAMPLES: './docs/samples/**/*.@(md|html|js)'
-	},
-
-	// Files ignored by jshint and jscs tasks. Files from .gitignore will be added automatically during tasks execution.
-	IGNORED_FILES: [
-		'src/lib/**'
-	]
-};
-
-// Return an array with paths to the CKEditor 5 dependencies.
-function getCKEditor5PackagesPaths() {
-	return compiler.utils.getPackages( config.ROOT_DIR );
-}
 
 // Lint tasks. ---------------------------------------------------------------
 
-const ckeditor5Lint = require( '@ckeditor/ckeditor5-dev-lint' )( config );
+const ckeditor5Lint = require( '@ckeditor/ckeditor5-dev-lint' )();
 
 gulp.task( 'lint', ckeditor5Lint.lint );
 gulp.task( 'lint-staged', ckeditor5Lint.lintStaged );
@@ -55,7 +18,9 @@ gulp.task( 'pre-commit', [ 'lint-staged' ] );
 
 // Development environment tasks. ---------------------------------------------
 
-const ckeditor5DevEnv = require( '@ckeditor/ckeditor5-dev-env' )( config );
+const ckeditor5DevEnv = require( '@ckeditor/ckeditor5-dev-env' )( {
+	workspaceDir: '..'
+} );
 
 gulp.task( 'init', ckeditor5DevEnv.initRepository );
 gulp.task( 'create-package', ckeditor5DevEnv.createPackage );
@@ -67,137 +32,33 @@ gulp.task( 'relink', ckeditor5DevEnv.relink );
 gulp.task( 'install', ckeditor5DevEnv.installPackage );
 gulp.task( 'exec', ckeditor5DevEnv.execOnRepositories );
 
-// Compilation tasks. ---------------------------------------------------------
-
-gulp.task( 'default', [ 'compile' ] );
-
-gulp.task( 'compile', () => {
-	const args = compiler.utils.parseArguments();
-	const formats = {};
-
-	for ( const item of args.formats ) {
-		formats[ item ] = config.MODULE_DIR[ item ];
-	}
-
-	return compiler.tasks.compile( {
-		formats,
-		packages: getCKEditor5PackagesPaths(),
-		watch: args.watch,
-		es5: args.es5,
-		samplesGlob: config.DOCUMENTATION.SAMPLES,
-		verbosity: args.verbosity
-	} );
-} );
-
-// Tasks specific for preparing compiled output with unmodified source files. Used by `gulp docs`.
-// TODO: These tasks should be moved directly to ckeditor5-dev-docs.
-gulp.task( 'compile:clean:js:esnext', () => {
-	return compiler.tasks.clean.js( [ config.MODULE_DIR.esnext ] );
-} );
-
-gulp.task( 'compile:clean:themes:esnext', () => {
-	return compiler.tasks.clean.themes( [ config.MODULE_DIR.esnext ] );
-} );
-
-gulp.task( 'compile:sass:esnext', () => {
-	return compiler.tasks.process.sass( {
-		formats: { esnext: config.MODULE_DIR.esnext },
-		packages: getCKEditor5PackagesPaths()
-	} );
-} );
-
-gulp.task( 'compile:icons:esnext', () => {
-	return compiler.tasks.process.icons( {
-		formats: { esnext: config.MODULE_DIR.esnext },
-		packages: getCKEditor5PackagesPaths()
-	} );
-} );
-
-gulp.task( 'compile:js:esnext', [ 'compile:clean:js:esnext' ], () => {
-	return compiler.tasks.process.js( {
-		formats: { esnext: config.MODULE_DIR.esnext },
-		packages: getCKEditor5PackagesPaths()
-	} );
-} );
-
-gulp.task( 'compile:themes:esnext', ( callback ) => {
-	runSequence( 'compile:clean:themes:esnext', 'compile:icons:esnext', 'compile:sass:esnext', callback );
-} );
-
-// Building tasks. ------------------------------------------------------------
-
-gulp.task( 'build', () => {
-	const bundler = require( '@ckeditor/ckeditor5-dev-bundler-rollup' );
-
-	return bundler.tasks.build( getBuildOptions() );
-} );
-
-function getBuildOptions() {
-	const minimist = require( 'minimist' );
-	const pathToConfig = minimist( process.argv.slice( 2 ) ).config || './build-config';
-
-	return {
-		packages: getCKEditor5PackagesPaths(),
-		buildConfig: require( path.resolve( '.', pathToConfig ) ),
-	};
-}
-
 // Documentation. -------------------------------------------------------------
 
-gulp.task( 'docs', [ 'docs:clean', 'compile:js:esnext', 'compile:themes:esnext' ], ( done ) => {
-	runSequence( 'docs:build', done );
-} );
-
-// Documentation's helpers.
-gulp.task( 'docs:clean', () => {
-	const docsBuilder = require( '@ckeditor/ckeditor5-dev-docs' ).docs( config );
-
-	return docsBuilder.clean();
-} );
-
-gulp.task( 'docs:build', () => {
-	const docsBuilder = require( '@ckeditor/ckeditor5-dev-docs' ).docs( config );
-
-	return docsBuilder.buildDocs();
+gulp.task( 'docs', () => {
+	return require( '@ckeditor/ckeditor5-dev-docs' )
+		.build( {
+			readmePath: path.join( process.cwd(), 'README.md' ),
+			sourceFiles: [
+				process.cwd() + '/node_modules/ckeditor5-*/src/**/*.@(js|jsdoc)',
+				'!' + process.cwd() + '/node_modules/ckeditor5-*/src/lib/**/*.js'
+			],
+			destinationPath: path.join( process.cwd(), 'build', 'docs' )
+		} );
 } );
 
 // Tests. ---------------------------------------------------------------------
 
 gulp.task( 'test', () => {
-	const tests = require( '@ckeditor/ckeditor5-dev-tests' );
-
-	return tests.tasks.automated.test( getTestOptions() );
-} );
-
-// Requires compiled sources. Task should be used in parallel with `gulp compile --formats=esnext --watch`.
-gulp.task( 'test:server', () => {
-	const tests = require( '@ckeditor/ckeditor5-dev-tests' );
-	const options = getTestOptions();
-
-	options.sourcePath = path.resolve( config.MODULE_DIR.esnext );
-
-	return tests.tasks.automated.runTests( options );
+	return require( '@ckeditor/ckeditor5-dev-tests' )
+		.runAutomatedTests( getTestOptions() );
 } );
 
-gulp.task( 'test:manual', ( done ) => {
-	const tests = require( '@ckeditor/ckeditor5-dev-tests' );
-
-	tests.tasks.manual.run( {
-		packages: getCKEditor5PackagesPaths()
-	}, done );
+gulp.task( 'test:manual', () => {
+	return require( '@ckeditor/ckeditor5-dev-tests' )
+		.runManualTests( getTestOptions() );
 } );
 
 function getTestOptions() {
-	const tests = require( '@ckeditor/ckeditor5-dev-tests' );
-	const options = tests.utils.parseArguments();
-
-	options.packages = getCKEditor5PackagesPaths();
-
-	// If --paths weren't specified, then test all packages.
-	if ( !options.paths ) {
-		options.paths = options.packages
-			.map( ( packagePath ) => tests.utils.getPackageName( path.resolve( packagePath ) ) );
-	}
-
-	return options;
+	return require( '@ckeditor/ckeditor5-dev-tests' )
+		.parseArguments( process.argv.slice( 2 ) );
 }

+ 6 - 10
package.json

@@ -24,27 +24,23 @@
     "ckeditor5-theme-lark": "ckeditor/ckeditor5-theme-lark",
     "ckeditor5-typing": "ckeditor/ckeditor5-typing",
     "ckeditor5-ui": "ckeditor/ckeditor5-ui",
-    "ckeditor5-ui-default": "ckeditor/ckeditor5-ui-default",
     "ckeditor5-undo": "ckeditor/ckeditor5-undo",
     "ckeditor5-utils": "ckeditor/ckeditor5-utils"
   },
   "devDependencies": {
-    "@ckeditor/ckeditor5-dev-bundler-rollup": "^5.0.0",
-    "@ckeditor/ckeditor5-dev-compiler": "^6.0.0",
-    "@ckeditor/ckeditor5-dev-docs": "^5.0.0",
-    "@ckeditor/ckeditor5-dev-env": "^1.0.0",
-    "@ckeditor/ckeditor5-dev-lint": "^1.0.1",
-    "@ckeditor/ckeditor5-dev-tests": "^3.1.0",
+    "@ckeditor/ckeditor5-dev-docs": "^6.0.0",
+    "@ckeditor/ckeditor5-dev-env": "^2.0.0",
+    "@ckeditor/ckeditor5-dev-lint": "^2.0.0",
+    "@ckeditor/ckeditor5-dev-tests": "^4.0.0",
     "gulp": "^3.9.0",
-    "guppy-pre-commit": "^0.4.0",
-    "run-sequence": "^1.1.5"
+    "guppy-pre-commit": "^0.4.0"
   },
   "engines": {
     "node": ">=6.0.0",
     "npm": ">=3.0.0"
   },
   "author": "CKSource (http://cksource.com/)",
-  "license": "See LICENSE.md",
+  "license": "(GPL-2.0 OR LGPL-2.1 OR MPL-1.1)",
   "homepage": "http://ckeditor.com",
   "bugs": "https://github.com/ckeditor/ckeditor5/issues",
   "repository": {

+ 41 - 0
scripts/fix-src-imports.js

@@ -0,0 +1,41 @@
+#!/usr/bin/env node
+
+'use strict';
+
+const fs = require( 'fs' );
+const path = require( 'path' );
+const glob = require( 'glob' );
+
+const srcDir = path.join( process.cwd(), 'src' );
+const srcPath = path.join( srcDir , '**', '*.js' );
+
+for ( const filePath of glob.sync( srcPath ) ) {
+	const fileDepth = countOcurrences( filePath.replace( srcDir + '/', '' ), path.sep );
+	const fix = ( wholeImport, pathStart ) => fixImport( wholeImport, pathStart, fileDepth );
+
+	const fileContent = fs.readFileSync( filePath, 'utf-8' )
+		.replace( /\nimport[^']+?'((\.\.\/)+[\w-]+)\/[^']+?'/gm, fix );
+
+	fs.writeFileSync( filePath, fileContent , 'utf-8' );
+}
+
+function fixImport( wholeImport, pathStart, fileDepth ) {
+	const indexOfPathStart = wholeImport.indexOf( '../' );
+	const packageShortName = pathStart.split( '/' ).slice( -1 )[0];
+	const importDepth = countOcurrences( pathStart, '../' );
+
+	if ( importDepth <= fileDepth ) {
+		return wholeImport;
+	}
+
+	return (
+		wholeImport.slice( 0, indexOfPathStart ) +
+		'ckeditor5-' + packageShortName +
+		'/src' +
+		wholeImport.slice( indexOfPathStart + pathStart.length )
+	);
+}
+
+function countOcurrences( str, pattern ) {
+	return str.split( pattern ).length - 1;
+}

+ 54 - 0
scripts/fix-test-imports.js

@@ -0,0 +1,54 @@
+#!/usr/bin/env node
+
+'use strict';
+
+const fs = require( 'fs' );
+const path = require( 'path' );
+const glob = require( 'glob' );
+
+const testDir = path.join( process.cwd(), 'tests' );
+const testPath = path.join( testDir , '**', '*.js' );
+
+for ( const filePath of glob.sync( testPath ) ) {
+	const fileContent = fs.readFileSync( filePath, 'utf-8' )
+		.replace( /\nimport[^']+?'([^']+?)'/gm, fixImport );
+
+	fs.writeFileSync( filePath, fileContent , 'utf-8' );
+}
+
+function fixImport( wholeImport , path ) {
+	let fixedImport = fixCkeditorPaths( wholeImport, path );
+	fixedImport = fixTestPaths( fixedImport, path );
+
+	return fixedImport;
+}
+
+function fixCkeditorPaths( wholeImport, path ) {
+	if ( path.indexOf( 'ckeditor5/' ) !== 0 ) {
+		return wholeImport;
+	}
+
+	const index = wholeImport.indexOf( path );
+	const pathChunks = path.split( '/' );
+
+	return (
+		wholeImport.slice( 0, index ) +
+		'ckeditor5-' + pathChunks[1] + '/src/' + pathChunks.slice( 2 ).join( '/' ) +
+		wholeImport.slice( path.length + index )
+	);
+}
+
+function fixTestPaths( wholeImport, path ) {
+	if ( path.indexOf( 'tests/' ) !== 0 ) {
+		return wholeImport;
+	}
+
+	const index = wholeImport.indexOf( path );
+	const pathChunks = path.split( '/' );
+
+	return (
+		wholeImport.slice( 0, index ) +
+		'ckeditor5-' + pathChunks[1] + '/tests/' + pathChunks.slice( 2 ).join( '/' ) +
+		wholeImport.slice( path.length + index )
+	);
+}

+ 16 - 0
scripts/remove-js-extensions-from-imports.js

@@ -0,0 +1,16 @@
+#!/usr/bin/env node
+
+'use strict';
+
+const fs = require( 'fs' );
+const path = require( 'path' );
+const glob = require( 'glob' );
+
+const srcPath = path.join( process.cwd(), '@(src|tests)', '**', '*.js' );
+
+for ( const filePath of glob.sync( srcPath ) ) {
+	const fileContent = fs.readFileSync( filePath, 'utf-8' )
+		.replace( /\nimport([^;]+)\.js';/g, '\nimport$1\';' );
+
+	fs.writeFileSync( filePath, fileContent , 'utf-8' );
+}

+ 27 - 0
scripts/switch-to-dev-dev.sh

@@ -0,0 +1,27 @@
+#!/bin/sh
+set -e
+
+# If it doesn't exist the following lines won't work.
+if [ ! -d node_modules/@ckeditor ]; then
+  mkdir node_modules/@ckeditor
+fi
+
+echo "Linking ckeditor5-dev-docs..."
+
+rm -rf node_modules/@ckeditor/ckeditor5-dev-docs
+ln -s ../../../ckeditor5-dev/packages/ckeditor5-dev-docs node_modules/@ckeditor
+
+echo "Linking ckeditor5-dev-env..."
+
+rm -rf node_modules/@ckeditor/ckeditor5-dev-env
+ln -s ../../../ckeditor5-dev/packages/ckeditor5-dev-env node_modules/@ckeditor
+
+echo "Linking ckeditor5-dev-lint..."
+
+rm -rf node_modules/@ckeditor/ckeditor5-dev-lint
+ln -s ../../../ckeditor5-dev/packages/ckeditor5-dev-lint node_modules/@ckeditor
+
+echo "Linking ckeditor5-dev-tests..."
+
+rm -rf node_modules/@ckeditor/ckeditor5-dev-tests
+ln -s ../../../ckeditor5-dev/packages/ckeditor5-dev-tests node_modules/@ckeditor