Jelajahi Sumber

Removed dev-boilerplate-update task.

Szymon Kupś 10 tahun lalu
induk
melakukan
1112605a94

+ 0 - 5
dev/tasks/dev/tasks.js

@@ -9,7 +9,6 @@ const initTask = require( './tasks/dev-init' );
 const installTask = require( './tasks/dev-install' );
 const pluginCreateTask = require( './tasks/dev-plugin-create' );
 const updateTask = require( './tasks/dev-update' );
-const boilerplateUpdateTask = require( './tasks/dev-boilerplate-update' );
 const relinkTask = require( './tasks/dev-relink' );
 
 module.exports = ( config ) => {
@@ -41,10 +40,6 @@ module.exports = ( config ) => {
 		statusTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log, console.error );
 	} );
 
-	gulp.task( 'dev-boilerplate-update', () => {
-		boilerplateUpdateTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log, console.error );
-	} );
-
 	gulp.task( 'dev-relink', () => {
 		relinkTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log, console.error );
 	} );

+ 0 - 52
dev/tasks/dev/tasks/dev-boilerplate-update.js

@@ -1,52 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-const tools = require( '../utils/tools' );
-const git = require( '../utils/git' );
-const path = require( 'path' );
-
-/**
- * 1. Get CKEditor5 dependencies from package.json file.
- * 2. Scan workspace for repositories that match dependencies from package.json file.
- * 3. Fetch and merge boilerplate remote.
- *
- * @param {String} ckeditor5Path Path to main CKEditor5 repository.
- * @param {Object} packageJSON Parsed package.json file from CKEditor5 repository.
- * @param {String} workspaceRoot Relative path to workspace root.
- * @param {Function} writeln Function for log output.
- * @param {Function} writeError Function of error output
- */
-module.exports = ( ckeditor5Path, packageJSON, workspaceRoot, writeln, writeError ) => {
-	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
-
-	// Get all CKEditor dependencies from package.json.
-	const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );
-
-	if ( dependencies ) {
-		const directories = tools.getCKE5Directories( workspaceAbsolutePath );
-
-		if ( directories.length ) {
-			for ( let dependency in dependencies ) {
-				const repositoryAbsolutePath = path.join( workspaceAbsolutePath, dependency );
-
-				// Check if repository's directory already exists.
-				if ( directories.indexOf( dependency ) > -1 ) {
-					try {
-						writeln( `Updating boilerplate in ${ dependency }...` );
-						git.updateBoilerplate( repositoryAbsolutePath );
-					} catch ( error ) {
-						writeError( error );
-					}
-				}
-			}
-		} else {
-			writeln( 'No CKEditor5 plugins in development mode.' );
-		}
-	} else {
-		writeln( 'No CKEditor5 dependencies found in package.json file.' );
-	}
-};

+ 0 - 38
dev/tasks/dev/utils/git.js

@@ -8,23 +8,6 @@
 const tools = require( './tools' );
 
 module.exports = {
-	/**
-	 * Holds boilerplate repository Git URL.
-	 *
-	 * @private
-	 * @readonly
-	 * @type {String}
-	 */
-	BOILERPLATE_REPOSITORY: 'git@github.com:ckeditor/ckeditor-boilerplate.git',
-
-	/**
-	 * Holds boilerplate branch used in CKEditor5 projects.
-	 *
-	 * @private
-	 * @readonly
-	 * @type {String}
-	 */
-	BOILERPLATE_BRANCH: 'ckeditor5',
 
 	/**
 	 * Parses GitHub URL. Extracts used server, repository and branch.
@@ -131,27 +114,6 @@ module.exports = {
 		return tools.shExec( `cd ${ repositoryPath } && git status --porcelain -sb` );
 	},
 
-	/**
-	 * Updates boilerplate project in specified repository.
-	 * @param {String} repositoryPath Absolute path to repository.
-	 */
-	updateBoilerplate( repositoryPath ) {
-		const regexp = /boilerplate(\n|$)/;
-
-		// Try to add boilerplate remote if one is not already added.
-		if ( !regexp.test( tools.shExec( `cd ${ repositoryPath } && git remote` ) ) ) {
-			tools.shExec( `cd ${ repositoryPath } && git remote add boilerplate ${ this.BOILERPLATE_REPOSITORY }` );
-		}
-
-		const updateCommands = [
-			`cd ${ repositoryPath }`,
-			`git fetch boilerplate ${ this.BOILERPLATE_BRANCH }`,
-			`git merge boilerplate/${ this.BOILERPLATE_BRANCH }`
-		];
-
-		tools.shExec( updateCommands.join( ' && ' ) );
-	},
-
 	/**
 	 * Creates initial commit on repository under specified path.
 	 *

+ 0 - 110
dev/tests/dev/dev-boilerplate-update.js

@@ -1,110 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* global describe, it */
-
-'use strict';
-
-const sinon = require( 'sinon' );
-const tools = require( '../../tasks/dev/utils/tools' );
-const git = require( '../../tasks/dev/utils/git' );
-const path = require( 'path' );
-
-describe( 'dev-boilerplate-update', () => {
-	const task = require( '../../tasks/dev/tasks/dev-boilerplate-update' );
-	const ckeditor5Path = 'path/to/ckeditor5';
-	const workspaceRoot = '..';
-	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
-	const emptyFn = () => {};
-
-	it( 'should update boilerplate in dev repositories', () => {
-		const dirs = [ 'ckeditor5-core', 'ckeditor5-devtest' ];
-		const getDependenciesSpy = sinon.spy( tools, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( tools, 'getCKE5Directories' ).returns( dirs );
-		const updateStub = sinon.stub( git, 'updateBoilerplate' );
-		const json = {
-			dependencies: {
-				'ckeditor5-core': 'ckeditor/ckeditor5-core',
-				'ckeditor5-devtest': 'ckeditor/ckeditor5-devtest#new-branch',
-				'other-plugin': '1.2.3'
-			}
-		};
-
-		task( ckeditor5Path, json, workspaceRoot, emptyFn, emptyFn );
-
-		getDependenciesSpy.restore();
-		getDirectoriesStub.restore();
-		updateStub.restore();
-
-		sinon.assert.calledTwice( updateStub );
-		sinon.assert.calledWithExactly( updateStub.firstCall, path.join( workspaceAbsolutePath, dirs[ 0 ] ) );
-		sinon.assert.calledWithExactly( updateStub.secondCall, path.join( workspaceAbsolutePath, dirs[ 1 ] ) );
-	} );
-
-	it( 'should not update boilerplate when no dependencies are found', () => {
-		const getDependenciesSpy = sinon.spy( tools, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( tools, 'getCKE5Directories' );
-		const updateStub = sinon.stub( git, 'updateBoilerplate' );
-		const json = {
-			dependencies: {
-				'other-plugin': '1.2.3'
-			}
-		};
-
-		task( ckeditor5Path, json, workspaceRoot, emptyFn, emptyFn );
-
-		getDependenciesSpy.restore();
-		getDirectoriesStub.restore();
-		updateStub.restore();
-
-		sinon.assert.notCalled( updateStub );
-	} );
-
-	it( 'should not update boilerplate when no plugins in dev mode', () => {
-		const getDependenciesSpy = sinon.spy( tools, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( tools, 'getCKE5Directories' ).returns( [] );
-		const updateStub = sinon.stub( git, 'updateBoilerplate' );
-		const json = {
-			dependencies: {
-				'ckeditor5-devtest': 'ckeditor/ckeditor5-devtest#new-branch',
-				'other-plugin': '1.2.3'
-			}
-		};
-
-		task( ckeditor5Path, json, workspaceRoot, emptyFn, emptyFn );
-
-		getDependenciesSpy.restore();
-		getDirectoriesStub.restore();
-		updateStub.restore();
-
-		sinon.assert.notCalled( updateStub );
-	} );
-
-	it( 'should write error message when updating boilerplate is unsuccessful', () => {
-		const dirs = [ 'ckeditor5-core' ];
-		const getDependenciesSpy = sinon.spy( tools, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( tools, 'getCKE5Directories' ).returns( dirs );
-		const error = new Error( 'Error message.' );
-		const updateStub = sinon.stub( git, 'updateBoilerplate' ).throws( error );
-		const json = {
-			dependencies: {
-				'ckeditor5-core': 'ckeditor/ckeditor5-core',
-				'ckeditor5-devtest': 'ckeditor/ckeditor5-devtest#new-branch',
-				'other-plugin': '1.2.3'
-			}
-		};
-		const writeErrorSpy = sinon.spy();
-
-		task( ckeditor5Path, json, workspaceRoot, emptyFn, writeErrorSpy );
-
-		getDependenciesSpy.restore();
-		getDirectoriesStub.restore();
-		updateStub.restore();
-
-		sinon.assert.calledOnce( updateStub );
-		sinon.assert.calledOnce( writeErrorSpy );
-		sinon.assert.calledWithExactly( writeErrorSpy, error );
-	} );
-} );

+ 0 - 37
dev/tests/dev/git.js

@@ -203,43 +203,6 @@ describe( 'utils', () => {
 			} );
 		} );
 
-		describe( 'updateBoilerplate', () => {
-			it( 'should be defined', () => expect( git.updateBoilerplate ).to.be.a( 'function' ) );
-			it( 'should fetch and merge boilerplate if remote already exists', () => {
-				const shExecStub = sandbox.stub( tools, 'shExec' );
-				const repositoryLocation = 'path/to/repository';
-				const updateCommands = [
-					`cd ${ repositoryLocation }`,
-					`git fetch boilerplate ${ git.BOILERPLATE_BRANCH }`,
-					`git merge boilerplate/${ git.BOILERPLATE_BRANCH }`
-				];
-				shExecStub.onCall( 0 ).returns( 'origin\nboilerplate' );
-
-				git.updateBoilerplate( repositoryLocation );
-
-				expect( shExecStub.calledTwice ).to.equal( true );
-				expect( shExecStub.secondCall.args[ 0 ] ).to.equal( updateCommands.join( ' && ' ) );
-			} );
-
-			it( 'should add boilerplate remote if one not exists', () => {
-				const shExecStub = sandbox.stub( tools, 'shExec' );
-				const repositoryLocation = 'path/to/repository';
-				const addRemoteCommands = `cd ${ repositoryLocation } && git remote add boilerplate ${ git.BOILERPLATE_REPOSITORY }`;
-				const updateCommands = [
-					`cd ${ repositoryLocation }`,
-					`git fetch boilerplate ${ git.BOILERPLATE_BRANCH }`,
-					`git merge boilerplate/${ git.BOILERPLATE_BRANCH }`
-				];
-				shExecStub.onCall( 0 ).returns( 'origin\nnew' );
-
-				git.updateBoilerplate( repositoryLocation );
-
-				expect( shExecStub.calledThrice ).to.equal( true );
-				expect( shExecStub.secondCall.args[ 0 ] ).to.equal( addRemoteCommands );
-				expect( shExecStub.thirdCall.args[ 0 ] ).to.equal( updateCommands.join( ' && ' )  );
-			} );
-		} );
-
 		describe( 'initialCommit', () => {
 			it( 'should be defined', () => expect( git.initialCommit ).to.be.a( 'function' ) );
 			it( 'should execute commit commands', () => {