Преглед изворни кода

Merge branch 'master' into t/157

Piotrek Koszuliński пре 9 година
родитељ
комит
ed54d15c86

+ 12 - 5
dev/tasks/build/utils.js

@@ -32,11 +32,18 @@ const utils = {
 	 */
 	benderLauncherCode:
 `
-require( [ 'tests' ], bender.defer(), function( err ) {
-	// The problem with Require.JS is that there are no stacktraces if we won't log this.
-	console.error( err );
-	console.log( err.stack );
-} );
+	var defer = bender.defer();
+	require( [ 'tests', '/tests/engine/_utils/view.js', '/tests/engine/_utils/model.js' ], 
+	function( tests, view, model ) { 
+		bender.view = view;
+		bender.model = model;
+		defer();
+	}, 
+	function( err ) {
+		// The problem with Require.JS is that there are no stacktraces if we won't log this.
+		console.error( err );
+		console.log( err.stack );
+	} );
 `,
 
 	/**

+ 18 - 9
dev/tasks/dev/tasks/update.js

@@ -11,15 +11,17 @@ const path = require( 'path' );
 const log = require( '../utils/log' );
 
 /**
- * 1. Get CKEditor 5 dependencies from package.json in main CKEditor 5 repository.
- * 2. If dependency's repository is already cloned in workspace:
- *		2.1. Fetch and checkout to specified branch.
- *		2.2. Pull changes to that branch.
- *		2.3. if --npm-update was specified run npm update --dev in that repository.
- *		2.4. Recreate symbolic link between repo and main node_modules.
- * 3. If dependency's repository is not cloned yet - run gulp install on this dependency.
- * 4. Remove symbolic links to dependencies that are not used in current package.json configuration.
- * 5. if --npm-update was specified run npm update --dev in main CKeditor 5 repository.
+ * 1. Fetch all branches from each origin in main CKEditor 5 repository.
+ * 2. Get CKEditor 5 dependencies from package.json in main CKEditor 5 repository.
+ * 3. If dependency's repository is already cloned in workspace:
+ *		3.1. Fetch all branches from each origin.
+ *		3.2. Checkout to specified branch.
+ *		3.3. Pull changes to that branch.
+ *		3.4. if --npm-update was specified run npm update --dev in that repository.
+ *		3.5. Recreate symbolic link between repo and main node_modules.
+ * 4. If dependency's repository is not cloned yet - run gulp install on this dependency.
+ * 5. Remove symbolic links to dependencies that are not used in current package.json configuration.
+ * 6. if --npm-update was specified run npm update --dev in main CKEditor 5 repository.
  *
  * @param {Function} installTask Install task to use on each dependency that is missing from workspace.
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
@@ -31,6 +33,10 @@ const log = require( '../utils/log' );
 module.exports = ( installTask, ckeditor5Path, packageJSON, workspaceRoot, runNpmUpdate ) => {
 	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 
+	// Fetch main repository
+	log.out( `Fetching branches from ${ packageJSON.name }...` );
+	git.fetchAll( ckeditor5Path );
+
 	// Get all CKEditor dependencies from package.json.
 	const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );
 
@@ -44,6 +50,9 @@ module.exports = ( installTask, ckeditor5Path, packageJSON, workspaceRoot, runNp
 
 			// Check if repository's directory already exists.
 			if ( directories.indexOf( urlInfo.name ) > -1 ) {
+				log.out( `Fetching branches from ${ urlInfo.name }...` );
+				git.fetchAll( repositoryAbsolutePath );
+
 				log.out( `Checking out ${ urlInfo.name } to ${ urlInfo.branch }...` );
 				git.checkout( repositoryAbsolutePath, urlInfo.branch );
 

+ 15 - 2
dev/tasks/dev/utils/git.js

@@ -66,7 +66,7 @@ module.exports = {
 	},
 
 	/**
-	 * Fetches all remotes and checks out branch on selected repository.
+	 * Checks out branch on selected repository.
 	 *
 	 * @param {String} repositoryLocation Absolute path to repository.
 	 * @param {String} branchName Name of the branch to checkout.
@@ -74,7 +74,6 @@ module.exports = {
 	checkout( repositoryLocation, branchName ) {
 		const checkoutCommands = [
 			`cd ${ repositoryLocation }`,
-			`git fetch --all`,
 			`git checkout ${ branchName }`
 		];
 
@@ -96,6 +95,20 @@ module.exports = {
 		tools.shExec( pullCommands.join( ' && ' ) );
 	},
 
+	/**
+	 * Fetch all branches from each origin on selected repository.
+	 *
+	 * @param {String} repositoryLocation
+	 */
+	fetchAll( repositoryLocation ) {
+		const fetchCommands = [
+			`cd ${ repositoryLocation }`,
+			`git fetch --all`
+		];
+
+		tools.shExec( fetchCommands.join( ' && ' ) );
+	},
+
 	/**
 	 * Initializes new repository, adds and merges CKEditor5 boilerplate project.
 	 *

+ 19 - 1
dev/tests/dev/git.js

@@ -151,7 +151,6 @@ describe( 'utils', () => {
 				const branchName = 'branch-to-checkout';
 				const checkoutCommands = [
 					`cd ${ repositoryLocation }`,
-					`git fetch --all`,
 					`git checkout ${ branchName }`
 				].join( ' && ' );
 
@@ -164,6 +163,7 @@ describe( 'utils', () => {
 
 		describe( 'pull', () => {
 			it( 'should be defined', () => expect( git.pull ).to.be.a( 'function' ) );
+
 			it( 'should call pull commands', () => {
 				const shExecStub = sandbox.stub( tools, 'shExec' );
 				const repositoryLocation = 'path/to/repository';
@@ -177,8 +177,24 @@ describe( 'utils', () => {
 			} );
 		} );
 
+		describe( 'fetchAll', () => {
+			it( 'should be defined', () => expect( git.fetchAll ).to.be.a( 'function' ) );
+
+			it( 'should call fetch commands', () => {
+				const shExecStub = sandbox.stub( tools, 'shExec' );
+				const repositoryLocation = 'path/to/repository';
+				const fetchCommands = `cd ${ repositoryLocation } && git fetch --all`;
+
+				git.fetchAll( repositoryLocation );
+
+				expect( shExecStub.calledOnce ).to.be.equal( true );
+				expect( shExecStub.firstCall.args[ 0 ] ).to.be.equal( fetchCommands );
+			} );
+		} );
+
 		describe( 'initializeRepository', () => {
 			it( 'should be defined', () => expect( git.initializeRepository ).to.be.a( 'function' ) );
+
 			it( 'should call initialize commands', () => {
 				const shExecStub = sandbox.stub( tools, 'shExec' );
 				const repositoryLocation = 'path/to/repository';
@@ -195,6 +211,7 @@ describe( 'utils', () => {
 
 		describe( 'getStatus', () => {
 			it( 'should be defined', () => expect( git.getStatus ).to.be.a( 'function' ) );
+
 			it( 'should call status command', () => {
 				const shExecStub = sandbox.stub( tools, 'shExec' );
 				const repositoryLocation = 'path/to/repository';
@@ -209,6 +226,7 @@ describe( 'utils', () => {
 
 		describe( 'initialCommit', () => {
 			it( 'should be defined', () => expect( git.initialCommit ).to.be.a( 'function' ) );
+
 			it( 'should execute commit commands', () => {
 				const shExecStub = sandbox.stub( tools, 'shExec' );
 				const pluginName = 'ckeditor5-plugin-name';

+ 21 - 1
dev/tests/dev/update.js

@@ -23,6 +23,7 @@ describe( 'dev-update', () => {
 		spies.getDependencies = sinon.spy( tools, 'getCKEditorDependencies' );
 		spies.checkout = sinon.stub( git, 'checkout' );
 		spies.pull = sinon.stub( git, 'pull' );
+		spies.fetchAll = sinon.stub( git, 'fetchAll' );
 		spies.npmUpdate = sinon.stub( tools, 'npmUpdate' );
 		spies.linkDirectories = sinon.stub( tools, 'linkDirectories' );
 		spies.removeSymlink = sinon.stub( tools, 'removeSymlink' );
@@ -51,6 +52,10 @@ describe( 'dev-update', () => {
 		const repoPath1 = path.join( workspaceAbsolutePath, dirs[ 0 ] );
 		const repoPath2 = path.join( workspaceAbsolutePath, dirs[ 1 ] );
 
+		sinon.assert.calledThrice( spies.fetchAll );
+		sinon.assert.calledWithExactly( spies.fetchAll.firstCall, ckeditor5Path );
+		sinon.assert.calledWithExactly( spies.fetchAll.secondCall, repoPath1 );
+		sinon.assert.calledWithExactly( spies.fetchAll.thirdCall, repoPath2 );
 		sinon.assert.calledTwice( spies.checkout );
 		sinon.assert.calledWithExactly( spies.checkout.firstCall, repoPath1, 'master' );
 		sinon.assert.calledWithExactly( spies.checkout.secondCall, repoPath2, 'new-branch' );
@@ -88,6 +93,10 @@ describe( 'dev-update', () => {
 		const repoPath1 = path.join( workspaceAbsolutePath, dirs[ 0 ] );
 		const repoPath2 = path.join( workspaceAbsolutePath, dirs[ 1 ] );
 
+		sinon.assert.calledThrice( spies.fetchAll );
+		sinon.assert.calledWithExactly( spies.fetchAll.firstCall, ckeditor5Path );
+		sinon.assert.calledWithExactly( spies.fetchAll.secondCall, repoPath1 );
+		sinon.assert.calledWithExactly( spies.fetchAll.thirdCall, repoPath2 );
 		sinon.assert.calledTwice( spies.checkout );
 		sinon.assert.calledWithExactly( spies.checkout.firstCall, repoPath1, 'master' );
 		sinon.assert.calledWithExactly( spies.checkout.secondCall, repoPath2, 'new-branch' );
@@ -126,6 +135,10 @@ describe( 'dev-update', () => {
 		const repoPath1 = path.join( workspaceAbsolutePath, dirs[ 0 ] );
 		const repoPath2 = path.join( workspaceAbsolutePath, dirs[ 1 ] );
 
+		sinon.assert.calledThrice( spies.fetchAll );
+		sinon.assert.calledWithExactly( spies.fetchAll.firstCall, ckeditor5Path );
+		sinon.assert.calledWithExactly( spies.fetchAll.secondCall, repoPath1 );
+		sinon.assert.calledWithExactly( spies.fetchAll.thirdCall, repoPath2 );
 		sinon.assert.calledTwice( spies.checkout );
 		sinon.assert.calledWithExactly( spies.checkout.firstCall, repoPath1, 'master' );
 		sinon.assert.calledWithExactly( spies.checkout.secondCall, repoPath2, 'new-branch' );
@@ -170,6 +183,10 @@ describe( 'dev-update', () => {
 		const repoPath1 = path.join( workspaceAbsolutePath, dirs[ 0 ] );
 		const repoPath2 = path.join( workspaceAbsolutePath, dirs[ 1 ] );
 
+		sinon.assert.calledThrice( spies.fetchAll );
+		sinon.assert.calledWithExactly( spies.fetchAll.firstCall, ckeditor5Path );
+		sinon.assert.calledWithExactly( spies.fetchAll.secondCall, repoPath1 );
+		sinon.assert.calledWithExactly( spies.fetchAll.thirdCall, repoPath2 );
 		sinon.assert.calledTwice( spies.checkout );
 		sinon.assert.calledWithExactly( spies.checkout.firstCall, repoPath1, 'master' );
 		sinon.assert.calledWithExactly( spies.checkout.secondCall, repoPath2, 'new-branch' );
@@ -187,7 +204,7 @@ describe( 'dev-update', () => {
 		sinon.assert.calledTwice( errSpy );
 	} );
 
-	it( 'should skip updating if no dependencies found', () => {
+	it( 'should skip updating if no dependencies found and fetch only main repository', () => {
 		spies.getDependencies.restore();
 		spies.getDependencies = sinon.stub( tools, 'getCKEditorDependencies' ).returns( null );
 		const dirs = [ 'ckeditor5-core', 'ckeditor5-devtest' ];
@@ -205,6 +222,9 @@ describe( 'dev-update', () => {
 
 		updateTask( installTask, ckeditor5Path, json, workspaceRoot, false );
 
+		sinon.assert.calledOnce( spies.fetchAll );
+		sinon.assert.calledWithExactly( spies.fetchAll.firstCall, ckeditor5Path );
+
 		sinon.assert.notCalled( spies.checkout );
 		sinon.assert.notCalled( spies.pull );
 

+ 3 - 0
package.json

@@ -8,10 +8,13 @@
     "WYSIWYG"
   ],
   "dependencies": {
+    "ckeditor5-delete": "ckeditor/ckeditor5-delete",
     "ckeditor5-engine": "ckeditor/ckeditor5-engine",
+    "ckeditor5-enter": "ckeditor/ckeditor5-enter",
     "ckeditor5-theme-lark": "ckeditor/ckeditor5-theme-lark",
     "ckeditor5-ui": "ckeditor/ckeditor5-ui",
     "ckeditor5-ui-default": "ckeditor/ckeditor5-ui-default",
+    "ckeditor5-undo": "ckeditor/ckeditor5-undo",
     "ckeditor5-utils": "ckeditor/ckeditor5-utils",
     "requirejs": "Reinmar/requirejs"
   },

+ 2 - 1
tests/.jshintrc

@@ -20,6 +20,7 @@
 		"describe": false,
 		"expect": false,
 		"it": false,
-		"sinon": false
+		"sinon": false,
+		"bender": false
 	}
 }

+ 28 - 0
tests/_utils-tests/benderglobals.js

@@ -0,0 +1,28 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+describe( 'bender global utils', () => {
+	describe( 'view', () => {
+		it( 'should be published in bender object', () => {
+			expect( bender.view ).to.be.an( 'object' );
+			expect( bender.view ).to.have.property( 'getData' ).that.is.a( 'function' );
+			expect( bender.view ).to.have.property( 'setData' ).that.is.a( 'function' );
+			expect( bender.view ).to.have.property( 'parse' ).that.is.a( 'function' );
+			expect( bender.view ).to.have.property( 'stringify' ).that.is.a( 'function' );
+		} );
+	} );
+
+	describe( 'model', () => {
+		it( 'should be published in bender object', () => {
+			expect( bender.model ).to.be.an( 'object' );
+			expect( bender.model ).to.have.property( 'getData' ).that.is.a( 'function' );
+			expect( bender.model ).to.have.property( 'setData' ).that.is.a( 'function' );
+			expect( bender.model ).to.have.property( 'parse' ).that.is.a( 'function' );
+			expect( bender.model ).to.have.property( 'stringify' ).that.is.a( 'function' );
+		} );
+	} );
+} );

+ 2 - 2
tests/_utils-tests/module__amd.js

@@ -23,9 +23,9 @@ describe( 'amdTestUtils', () => {
 		} );
 
 		it( 'generates an absolute path from a simple path', () => {
-			const path = getModulePath( 'engine/treeview' );
+			const path = getModulePath( 'engine/dataController' );
 
-			expect( path ).to.equal( '/ckeditor5/engine/treeview.js' );
+			expect( path ).to.equal( '/ckeditor5/engine/dataController.js' );
 		} );
 
 		it( 'does not process an absolute path', () => {

+ 2 - 2
tests/_utils/module__amd.js

@@ -100,10 +100,10 @@ const utils = {
 	 * This method uses {@link #getModulePath} to process module and dependency paths so you need to use
 	 * the simplified notation.
 	 *
-	 *		const modules = amdTestUtils.require( { treeView: 'engine/treeview/treeview' } );
+	 *		const modules = amdTestUtils.require( { modelDocument: 'engine/model/document' } );
 	 *
 	 *		// Later on, inside tests:
-	 *		const TreeView = modules.treeView;
+	 *		const ModelDocument = modules.modelDocument;
 	 *
 	 * @params {Object} modules The object (`ref => modulePath`) with modules to be loaded.
 	 * @returns {Object} The object that will hold the loaded modules.