8
0
Просмотр исходного кода

Renamed ckeditor5-dirs module's methods.

Maksymilian Barnaś 9 лет назад
Родитель
Сommit
9d130f15e7

+ 1 - 1
dev/tasks/dev/tasks/init.js

@@ -19,7 +19,7 @@ const log = require( '../../../utils/log' );
  */
 module.exports = ( installTask, ckeditor5Path, packageJSON, workspaceRoot ) => {
 	// Get all CKEditor dependencies from package.json.
-	const dependencies = ckeditor5Dirs.getCKEditorDependencies( packageJSON.dependencies );
+	const dependencies = ckeditor5Dirs.getDependencies( packageJSON.dependencies );
 
 	if ( dependencies ) {
 		for ( let dependency in dependencies ) {

+ 2 - 2
dev/tasks/dev/tasks/relink.js

@@ -23,10 +23,10 @@ module.exports = ( ckeditor5Path, packageJSON, workspaceRoot ) => {
 	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 
 	// Get all CKEditor dependencies from package.json.
-	const dependencies = ckeditor5Dirs.getCKEditorDependencies( packageJSON.dependencies );
+	const dependencies = ckeditor5Dirs.getDependencies( packageJSON.dependencies );
 
 	if ( dependencies ) {
-		const directories = ckeditor5Dirs.getCKE5Directories( workspaceAbsolutePath );
+		const directories = ckeditor5Dirs.getDirectories( workspaceAbsolutePath );
 
 		if ( directories.length ) {
 			for ( let dependency in dependencies ) {

+ 2 - 2
dev/tasks/dev/tasks/status.js

@@ -23,10 +23,10 @@ module.exports = ( ckeditor5Path, packageJSON, workspaceRoot ) => {
 	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 
 	// Get all CKEditor dependencies from package.json.
-	const dependencies = ckeditor5Dirs.getCKEditorDependencies( packageJSON.dependencies );
+	const dependencies = ckeditor5Dirs.getDependencies( packageJSON.dependencies );
 
 	if ( dependencies ) {
-		const directories = ckeditor5Dirs.getCKE5Directories( workspaceAbsolutePath );
+		const directories = ckeditor5Dirs.getDirectories( workspaceAbsolutePath );
 
 		if ( directories.length ) {
 			for ( let dependency in dependencies ) {

+ 3 - 3
dev/tasks/dev/tasks/update.js

@@ -39,10 +39,10 @@ module.exports = ( installTask, ckeditor5Path, packageJSON, workspaceRoot, runNp
 	git.fetchAll( ckeditor5Path );
 
 	// Get all CKEditor dependencies from package.json.
-	const dependencies = ckeditor5Dirs.getCKEditorDependencies( packageJSON.dependencies );
+	const dependencies = ckeditor5Dirs.getDependencies( packageJSON.dependencies );
 
 	if ( dependencies ) {
-		const directories = ckeditor5Dirs.getCKE5Directories( workspaceAbsolutePath );
+		const directories = ckeditor5Dirs.getDirectories( workspaceAbsolutePath );
 
 		for ( let dependency in dependencies ) {
 			const repositoryURL = dependencies[ dependency ];
@@ -87,7 +87,7 @@ module.exports = ( installTask, ckeditor5Path, packageJSON, workspaceRoot, runNp
 
 	// Remove symlinks not used in this configuration.
 	const nodeModulesPath = path.join( ckeditor5Path, 'node_modules' );
-	const symlinks = ckeditor5Dirs.getCKE5Symlinks( nodeModulesPath );
+	const symlinks = ckeditor5Dirs.getSymlinks( nodeModulesPath );
 	symlinks
 		.filter( dir => typeof dependencies[ dir ] == 'undefined' )
 		.forEach( dir => {

+ 1 - 1
dev/tasks/exec/tasks.js

@@ -73,7 +73,7 @@ function execute( execTask, ckeditor5Path, packageJSON, workspaceRoot, parameter
 	const mergedStream = merge();
 	const specificRepository = parameters.repository;
 
-	let devDirectories = ckeditor5Dirs.getCKE5DevDirectories( workspacePath, packageJSON, ckeditor5Path );
+	let devDirectories = ckeditor5Dirs.getDevDirectories( workspacePath, packageJSON, ckeditor5Path );
 
 	if ( specificRepository ) {
 		devDirectories = devDirectories.filter( ( dir ) => {

+ 10 - 10
dev/tests/dev/ckeditor5-dirs.js

@@ -24,8 +24,8 @@ describe( 'utils', () => {
 	} );
 
 	describe( 'ckeditor5dirs', () => {
-		describe( 'getCKEditorDependencies', () => {
-			it( 'should be defined', () => expect( ckeditor5Dirs.getCKEditorDependencies ).to.be.a( 'function' ) );
+		describe( 'getDependencies', () => {
+			it( 'should be defined', () => expect( ckeditor5Dirs.getDependencies ).to.be.a( 'function' ) );
 
 			it( 'should return null if no CKEditor5 repository is found', () => {
 				const dependencies = {
@@ -33,8 +33,8 @@ describe( 'utils', () => {
 					'plugin2': '',
 					'plugin3': ''
 				};
-				expect( ckeditor5Dirs.getCKEditorDependencies( dependencies ) ).to.equal( null );
-				expect( ckeditor5Dirs.getCKEditorDependencies() ).to.equal( null );
+				expect( ckeditor5Dirs.getDependencies( dependencies ) ).to.equal( null );
+				expect( ckeditor5Dirs.getDependencies() ).to.equal( null );
 			} );
 
 			it( 'should return only ckeditor5- dependencies', () => {
@@ -44,7 +44,7 @@ describe( 'utils', () => {
 					'plugin2': '',
 					'ckeditor5-core': 'ckeditor/ckeditor5-core'
 				};
-				const ckeditorDependencies = ckeditor5Dirs.getCKEditorDependencies( dependencies );
+				const ckeditorDependencies = ckeditor5Dirs.getDependencies( dependencies );
 
 				expect( ckeditorDependencies ).to.be.an( 'object' );
 				expect( ckeditorDependencies.plugin1 ).to.be.a( 'undefined' );
@@ -54,14 +54,14 @@ describe( 'utils', () => {
 			} );
 		} );
 
-		describe( 'getCKE5Directories', () => {
-			it( 'should be defined', () => expect( ckeditor5Dirs.getCKE5Directories ).to.be.a( 'function' ) );
+		describe( 'getDirectories', () => {
+			it( 'should be defined', () => expect( ckeditor5Dirs.getDirectories ).to.be.a( 'function' ) );
 
 			it( 'should return only ckeditor5 directories', () => {
 				const workspacePath = '/workspace/path';
 				const sourceDirectories = [ 'tools', 'ckeditor5', 'ckeditor5-core', '.bin', 'ckeditor5-plugin-image' ];
 				sandbox.stub( tools, 'getDirectories', () => sourceDirectories );
-				const directories = ckeditor5Dirs.getCKE5Directories( workspacePath );
+				const directories = ckeditor5Dirs.getDirectories( workspacePath );
 
 				expect( directories.length ).equal( 2 );
 				expect( directories[ 0 ] ).equal( 'ckeditor5-core' );
@@ -69,14 +69,14 @@ describe( 'utils', () => {
 			} );
 		} );
 
-		describe( 'getCKE5Symlinks', () => {
+		describe( 'getSymlinks', () => {
 			it( 'should return CKE5 symlinks from provided path', () => {
 				const fs = require( 'fs' );
 				const path = 'path/to/dir';
 				sandbox.stub( fs, 'readdirSync' ).returns( [ 'ckeditor5-core', 'ckeditor5-image', 'other-dependency' ] );
 				sandbox.stub( tools, 'isSymlink' ).returns( true );
 
-				const symlinks = ckeditor5Dirs.getCKE5Symlinks( path );
+				const symlinks = ckeditor5Dirs.getSymlinks( path );
 				expect( symlinks.length ).to.equal( 2 );
 				expect( symlinks[ 0 ] ).to.equal( 'ckeditor5-core' );
 				expect( symlinks[ 1 ] ).to.equal( 'ckeditor5-image' );

+ 2 - 2
dev/tests/dev/init.js

@@ -16,7 +16,7 @@ describe( 'dev-init', () => {
 	const workspaceRoot = '..';
 
 	it( 'should get all ckedtior5- dependencies and execute dev-install on them', () => {
-		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
+		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getDependencies' );
 		const installSpy = sinon.spy();
 		const JSON = {
 			dependencies: {
@@ -39,7 +39,7 @@ describe( 'dev-init', () => {
 	} );
 
 	it( 'should not call dev-install if no ckedtior5- dependencies', () => {
-		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
+		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getDependencies' );
 		const installSpy = sinon.spy();
 		const JSON = {
 			dependencies: {}

+ 8 - 8
dev/tests/dev/relink.js

@@ -21,8 +21,8 @@ describe( 'dev-relink', () => {
 
 	it( 'should link dev repositories', () => {
 		const dirs = [ 'ckeditor5-core', 'ckeditor5-devtest' ];
-		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( dirs );
+		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getDependencies' );
+		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( dirs );
 		const linkStub = sinon.stub( tools, 'linkDirectories' );
 		const json = {
 			dependencies: {
@@ -44,8 +44,8 @@ describe( 'dev-relink', () => {
 	} );
 
 	it( 'should not link when no dependencies are found', () => {
-		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' );
+		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getDependencies' );
+		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getDirectories' );
 		const linkStub = sinon.stub( tools, 'linkDirectories' );
 		const json = {
 			dependencies: {
@@ -63,8 +63,8 @@ describe( 'dev-relink', () => {
 	} );
 
 	it( 'should not link when no plugins in dev mode', () => {
-		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( [] );
+		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getDependencies' );
+		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( [] );
 		const linkStub = sinon.stub( tools, 'linkDirectories' );
 		const json = {
 			dependencies: {
@@ -84,8 +84,8 @@ describe( 'dev-relink', () => {
 
 	it( 'should write error message when linking is unsuccessful', () => {
 		const dirs = [ 'ckeditor5-core' ];
-		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( dirs );
+		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getDependencies' );
+		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( dirs );
 		const error = new Error( 'Error message.' );
 		const linkStub = sinon.stub( tools, 'linkDirectories' ).throws( error );
 		const json = {

+ 8 - 8
dev/tests/dev/status.js

@@ -23,8 +23,8 @@ describe( 'dev-status', () => {
 
 	it( 'should show status of dev repositories', () => {
 		const dirs = [ 'ckeditor5-core', 'ckeditor5-devtest' ];
-		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( dirs );
+		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getDependencies' );
+		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( dirs );
 		const statusStub = sinon.stub( git, 'getStatus' );
 		const json = {
 			dependencies: {
@@ -46,8 +46,8 @@ describe( 'dev-status', () => {
 	} );
 
 	it( 'should not get status when no dependencies are found', () => {
-		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' );
+		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getDependencies' );
+		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getDirectories' );
 		const statusStub = sinon.stub( git, 'getStatus' );
 		const json = {
 			dependencies: {
@@ -65,8 +65,8 @@ describe( 'dev-status', () => {
 	} );
 
 	it( 'should not get status when no plugins in dev mode', () => {
-		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( [] );
+		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getDependencies' );
+		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( [] );
 		const statusStub = sinon.stub( git, 'getStatus' );
 		const json = {
 			dependencies: {
@@ -86,8 +86,8 @@ describe( 'dev-status', () => {
 
 	it( 'should write error message when getStatus is unsuccessful', () => {
 		const dirs = [ 'ckeditor5-core' ];
-		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
-		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( dirs );
+		const getDependenciesSpy = sinon.spy( ckeditor5Dirs, 'getDependencies' );
+		const getDirectoriesStub = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( dirs );
 		const error = new Error( 'Error message.' );
 		const statusStub = sinon.stub( git, 'getStatus' ).throws( error );
 		const json = {

+ 17 - 17
dev/tests/dev/update.js

@@ -24,7 +24,7 @@ describe( 'dev-update', () => {
 	const spies = {};
 
 	beforeEach( () => {
-		spies.getDependencies = sinon.spy( ckeditor5Dirs, 'getCKEditorDependencies' );
+		spies.getDependencies = sinon.spy( ckeditor5Dirs, 'getDependencies' );
 		spies.checkout = sinon.stub( git, 'checkout' );
 		spies.pull = sinon.stub( git, 'pull' );
 		spies.fetchAll = sinon.stub( git, 'fetchAll' );
@@ -40,8 +40,8 @@ describe( 'dev-update', () => {
 	it( 'should update dev repositories', () => {
 		const dirs = [ 'ckeditor5-core', 'ckeditor5-devtest' ];
 		const installTask = sinon.spy();
-		spies.getDirectories = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( dirs );
-		spies.getCKE5Symlinks = sinon.stub( ckeditor5Dirs, 'getCKE5Symlinks' ).returns( [] );
+		spies.getDirectories = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( dirs );
+		spies.getSymlinks = sinon.stub( ckeditor5Dirs, 'getSymlinks' ).returns( [] );
 
 		const json = {
 			dependencies: {
@@ -72,7 +72,7 @@ describe( 'dev-update', () => {
 		sinon.assert.calledWithExactly( spies.npmUpdate.secondCall, path.join( workspaceAbsolutePath, dirs[ 1 ] ) );
 		sinon.assert.calledWithExactly( spies.npmUpdate.thirdCall, ckeditor5Path );
 
-		sinon.assert.calledOnce( spies.getCKE5Symlinks );
+		sinon.assert.calledOnce( spies.getSymlinks );
 		sinon.assert.notCalled( spies.removeSymlink );
 		sinon.assert.notCalled( installTask );
 	} );
@@ -80,8 +80,8 @@ describe( 'dev-update', () => {
 	it( 'should install missing dependencies', () => {
 		const dirs = [ 'ckeditor5-core', 'ckeditor5-devtest' ];
 		const installTask = sinon.spy();
-		spies.getDirectories = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( dirs );
-		spies.getCKE5Symlinks = sinon.stub( ckeditor5Dirs, 'getCKE5Symlinks' ).returns( [] );
+		spies.getDirectories = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( dirs );
+		spies.getSymlinks = sinon.stub( ckeditor5Dirs, 'getSymlinks' ).returns( [] );
 
 		const json = {
 			dependencies: {
@@ -116,15 +116,15 @@ describe( 'dev-update', () => {
 		sinon.assert.calledOnce( installTask );
 		sinon.assert.calledWithExactly( installTask, ckeditor5Path, workspaceRoot, 'ckeditor/ckeditor5-ui' );
 
-		sinon.assert.calledOnce( spies.getCKE5Symlinks );
+		sinon.assert.calledOnce( spies.getSymlinks );
 		sinon.assert.notCalled( spies.removeSymlink );
 	} );
 
 	it( 'should remove symlinks that are not needed', () => {
 		const dirs = [ 'ckeditor5-core', 'ckeditor5-devtest' ];
 		const installTask = sinon.spy();
-		spies.getDirectories = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( dirs );
-		spies.getCKE5Symlinks = sinon.stub( ckeditor5Dirs, 'getCKE5Symlinks' ).returns( [ 'ckeditor5-unused' ] );
+		spies.getDirectories = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( dirs );
+		spies.getSymlinks = sinon.stub( ckeditor5Dirs, 'getSymlinks' ).returns( [ 'ckeditor5-unused' ] );
 
 		const json = {
 			dependencies: {
@@ -155,7 +155,7 @@ describe( 'dev-update', () => {
 		sinon.assert.calledWithExactly( spies.npmUpdate.secondCall, path.join( workspaceAbsolutePath, dirs[ 1 ] ) );
 		sinon.assert.calledWithExactly( spies.npmUpdate.thirdCall, ckeditor5Path );
 
-		sinon.assert.calledOnce( spies.getCKE5Symlinks );
+		sinon.assert.calledOnce( spies.getSymlinks );
 		sinon.assert.notCalled( installTask );
 
 		sinon.assert.calledOnce( spies.removeSymlink );
@@ -168,8 +168,8 @@ describe( 'dev-update', () => {
 		const installTask = sinon.spy();
 		const outSpy = sinon.spy();
 		const errSpy = sinon.spy();
-		spies.getDirectories = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( dirs );
-		spies.getCKE5Symlinks = sinon.stub( ckeditor5Dirs, 'getCKE5Symlinks' ).returns( [ 'ckeditor5-unused' ] );
+		spies.getDirectories = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( dirs );
+		spies.getSymlinks = sinon.stub( ckeditor5Dirs, 'getSymlinks' ).returns( [ 'ckeditor5-unused' ] );
 		spies.linkDirectories.throws();
 
 		log.configure( outSpy, errSpy );
@@ -200,7 +200,7 @@ describe( 'dev-update', () => {
 
 		sinon.assert.notCalled( spies.npmUpdate );
 
-		sinon.assert.calledOnce( spies.getCKE5Symlinks );
+		sinon.assert.calledOnce( spies.getSymlinks );
 		sinon.assert.notCalled( installTask );
 
 		sinon.assert.calledOnce( spies.removeSymlink );
@@ -210,11 +210,11 @@ describe( 'dev-update', () => {
 
 	it( 'should skip updating if no dependencies found and fetch only main repository', () => {
 		spies.getDependencies.restore();
-		spies.getDependencies = sinon.stub( ckeditor5Dirs, 'getCKEditorDependencies' ).returns( null );
+		spies.getDependencies = sinon.stub( ckeditor5Dirs, 'getDependencies' ).returns( null );
 		const dirs = [ 'ckeditor5-core', 'ckeditor5-devtest' ];
 		const installTask = sinon.spy();
-		spies.getDirectories = sinon.stub( ckeditor5Dirs, 'getCKE5Directories' ).returns( dirs );
-		spies.getCKE5Symlinks = sinon.stub( ckeditor5Dirs, 'getCKE5Symlinks' ).returns( [] );
+		spies.getDirectories = sinon.stub( ckeditor5Dirs, 'getDirectories' ).returns( dirs );
+		spies.getSymlinks = sinon.stub( ckeditor5Dirs, 'getSymlinks' ).returns( [] );
 
 		const json = {
 			dependencies: {
@@ -234,7 +234,7 @@ describe( 'dev-update', () => {
 
 		sinon.assert.notCalled( spies.npmUpdate );
 
-		sinon.assert.calledOnce( spies.getCKE5Symlinks );
+		sinon.assert.calledOnce( spies.getSymlinks );
 		sinon.assert.notCalled( installTask );
 
 		sinon.assert.notCalled( spies.removeSymlink );

+ 6 - 6
dev/utils/ckeditor5-dirs.js

@@ -20,7 +20,7 @@ module.exports = {
 	 * @param {Object} dependencies Dependencies object loaded from package.json file.
 	 * @returns {Object|null}
 	 */
-	getCKEditorDependencies( dependencies ) {
+	getDependencies( dependencies ) {
 		let result = null;
 
 		if ( dependencies ) {
@@ -44,7 +44,7 @@ module.exports = {
 	 * @param {String} path
 	 * @returns {Array}
 	 */
-	getCKE5Directories( path ) {
+	getDirectories( path ) {
 		return tools.getDirectories( path ).filter( dir => {
 			return dependencyRegExp.test( dir );
 		} );
@@ -56,7 +56,7 @@ module.exports = {
 	 * @param {String} path Path to directory,
 	 * @returns {Array} Array with directories names.
 	 */
-	getCKE5Symlinks( path ) {
+	getSymlinks( path ) {
 		const fs = require( 'fs' );
 		const pth = require( 'path' );
 
@@ -75,9 +75,9 @@ module.exports = {
 	 * @param {String} ckeditor5Path Absolute path to ckeditor5 root directory.
 	 * @returns {Array.<Object>}
 	 */
-	getCKE5DevDirectories( workspacePath, packageJSON, ckeditor5Path ) {
-		const directories = this.getCKE5Directories( workspacePath );
-		const dependencies = this.getCKEditorDependencies( packageJSON.dependencies );
+	getDevDirectories( workspacePath, packageJSON, ckeditor5Path ) {
+		const directories = this.getDirectories( workspacePath );
+		const dependencies = this.getDependencies( packageJSON.dependencies );
 
 		let devDirectories = [];