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

Moved workspaceRoot option as global in gruntfile.js.

Szymon Kupś 10 лет назад
Родитель
Сommit
5247916363

+ 7 - 20
dev/tasks/dev.js

@@ -15,49 +15,36 @@ const ckeditor5Path = process.cwd();
 
 
 module.exports = ( grunt ) => {
 module.exports = ( grunt ) => {
 	const packageJSON = grunt.config.data.pkg;
 	const packageJSON = grunt.config.data.pkg;
+	const workspaceRoot = grunt.config.data.workspaceRoot;
 
 
 	grunt.registerTask( 'dev-init', function() {
 	grunt.registerTask( 'dev-init', function() {
-		const options = getOptions( this );
-		initTask( ckeditor5Path, packageJSON, options, grunt.log.writeln, grunt.log.error );
+		initTask( ckeditor5Path, packageJSON, workspaceRoot, grunt.log.writeln, grunt.log.error );
 	} );
 	} );
 
 
 	grunt.registerTask( 'dev-plugin-create', function() {
 	grunt.registerTask( 'dev-plugin-create', function() {
 		const done = this.async();
 		const done = this.async();
-		const options = getOptions( this );
-		pluginCreateTask( ckeditor5Path, options, grunt.log.writeln )
+		pluginCreateTask( ckeditor5Path, workspaceRoot, grunt.log.writeln )
 			.then( done )
 			.then( done )
 			.catch( ( error )  => done( error ) );
 			.catch( ( error )  => done( error ) );
 	} );
 	} );
 
 
 	grunt.registerTask( 'dev-plugin-install', function() {
 	grunt.registerTask( 'dev-plugin-install', function() {
 		const done = this.async();
 		const done = this.async();
-		const options = getOptions( this );
-		pluginInstallTask( ckeditor5Path, options, grunt.log.writeln )
+		pluginInstallTask( ckeditor5Path, workspaceRoot, grunt.log.writeln )
 			.then( done )
 			.then( done )
 			.catch( ( error )  => done( error ) );
 			.catch( ( error )  => done( error ) );
 	} );
 	} );
 
 
 	grunt.registerTask( 'dev-update', function() {
 	grunt.registerTask( 'dev-update', function() {
-		const options = getOptions( this );
-		pluginUpdateTask( ckeditor5Path, packageJSON, options, grunt.log.writeln, grunt.log.error );
+		pluginUpdateTask( ckeditor5Path, packageJSON, workspaceRoot, grunt.log.writeln, grunt.log.error );
 	} );
 	} );
 
 
 	grunt.registerTask( 'dev-status', function() {
 	grunt.registerTask( 'dev-status', function() {
-		const options = getOptions( this );
-		pluginStatusTask( ckeditor5Path, packageJSON, options, grunt.log.writeln, grunt.log.error );
+		pluginStatusTask( ckeditor5Path, packageJSON, workspaceRoot, grunt.log.writeln, grunt.log.error );
 	} );
 	} );
 
 
 	grunt.registerTask( 'dev-boilerplate-update', function() {
 	grunt.registerTask( 'dev-boilerplate-update', function() {
-		const options = getOptions( this );
-		boilerplateUpdateTask( ckeditor5Path, packageJSON, options, grunt.log.writeln, grunt.log.error );
+		boilerplateUpdateTask( ckeditor5Path, packageJSON, workspaceRoot, grunt.log.writeln, grunt.log.error );
 	} );
 	} );
-
-	function getOptions( task ) {
-		const options = {
-			workspaceRoot: '..'
-		};
-
-		return task.options( options );
-	}
 };
 };
 
 

+ 7 - 9
dev/tasks/tests/dev-init.js

@@ -19,10 +19,8 @@ describe( 'dev-tasks', () => {
 	describe( 'dev-init', () => {
 	describe( 'dev-init', () => {
 		const initTask = require( '../utils/dev-init' );
 		const initTask = require( '../utils/dev-init' );
 		const mainRepositoryPath = '/path/to/repository';
 		const mainRepositoryPath = '/path/to/repository';
-		const options = {
-			workspaceRoot: '..'
-		};
-		const workspacePath = path.join( mainRepositoryPath, options.workspaceRoot );
+		const workspaceRoot = '..';
+		const workspacePath = path.join( mainRepositoryPath, workspaceRoot );
 
 
 		beforeEach( () => createSpies() );
 		beforeEach( () => createSpies() );
 		afterEach( () => restoreSpies() );
 		afterEach( () => restoreSpies() );
@@ -56,7 +54,7 @@ describe( 'dev-tasks', () => {
 				}
 				}
 			};
 			};
 
 
-			initTask( mainRepositoryPath, packageJSON, options, emptyFn, emptyFn );
+			initTask( mainRepositoryPath, packageJSON, workspaceRoot, emptyFn, emptyFn );
 			expect( spies.getDependencies.calledOnce ).to.equal( true );
 			expect( spies.getDependencies.calledOnce ).to.equal( true );
 			expect( spies.getDependencies.firstCall.args[ 0 ] ).to.equal( packageJSON.dependencies );
 			expect( spies.getDependencies.firstCall.args[ 0 ] ).to.equal( packageJSON.dependencies );
 			expect( spies.getDirectories.called ).to.equal( false );
 			expect( spies.getDirectories.called ).to.equal( false );
@@ -77,11 +75,11 @@ describe( 'dev-tasks', () => {
 				}
 				}
 			};
 			};
 
 
-			initTask( mainRepositoryPath, packageJSON, options, emptyFn, emptyFn );
+			initTask( mainRepositoryPath, packageJSON, workspaceRoot, emptyFn, emptyFn );
 			expect( spies.getDependencies.calledOnce ).to.equal( true );
 			expect( spies.getDependencies.calledOnce ).to.equal( true );
 			expect( spies.getDependencies.firstCall.args[ 0 ] ).to.equal( packageJSON.dependencies );
 			expect( spies.getDependencies.firstCall.args[ 0 ] ).to.equal( packageJSON.dependencies );
 			expect( spies.getDirectories.calledOnce ).to.equal( true );
 			expect( spies.getDirectories.calledOnce ).to.equal( true );
-			expect( spies.getDirectories.firstCall.args[ 0 ] ).to.equal( path.join( mainRepositoryPath, options.workspaceRoot ) );
+			expect( spies.getDirectories.firstCall.args[ 0 ] ).to.equal( path.join( mainRepositoryPath, workspaceRoot ) );
 			expect( spies.parseRepositoryUrl.calledTwice ).to.equal( true );
 			expect( spies.parseRepositoryUrl.calledTwice ).to.equal( true );
 			expect( spies.cloneRepository.calledTwice ).to.equal( true );
 			expect( spies.cloneRepository.calledTwice ).to.equal( true );
 			expect( spies.cloneRepository.firstCall.args[ 0 ] ).to.equal( spies.parseRepositoryUrl.firstCall.returnValue );
 			expect( spies.cloneRepository.firstCall.args[ 0 ] ).to.equal( spies.parseRepositoryUrl.firstCall.returnValue );
@@ -107,11 +105,11 @@ describe( 'dev-tasks', () => {
 			spies.getDirectories.restore();
 			spies.getDirectories.restore();
 			spies.getDirectories = sinon.stub( tools, 'getCKE5Directories', () => [ 'ckeditor5-core', 'ckeditor5-plugin-devtest' ] );
 			spies.getDirectories = sinon.stub( tools, 'getCKE5Directories', () => [ 'ckeditor5-core', 'ckeditor5-plugin-devtest' ] );
 
 
-			initTask( mainRepositoryPath, packageJSON, options, emptyFn, emptyFn );
+			initTask( mainRepositoryPath, packageJSON, workspaceRoot, emptyFn, emptyFn );
 			expect( spies.getDependencies.calledOnce ).to.equal( true );
 			expect( spies.getDependencies.calledOnce ).to.equal( true );
 			expect( spies.getDependencies.firstCall.args[ 0 ] ).to.equal( packageJSON.dependencies );
 			expect( spies.getDependencies.firstCall.args[ 0 ] ).to.equal( packageJSON.dependencies );
 			expect( spies.getDirectories.calledOnce ).to.equal( true );
 			expect( spies.getDirectories.calledOnce ).to.equal( true );
-			expect( spies.getDirectories.firstCall.args[ 0 ] ).to.equal( path.join( mainRepositoryPath, options.workspaceRoot ) );
+			expect( spies.getDirectories.firstCall.args[ 0 ] ).to.equal( path.join( mainRepositoryPath, workspaceRoot ) );
 			expect( spies.parseRepositoryUrl.calledTwice ).to.equal( true );
 			expect( spies.parseRepositoryUrl.calledTwice ).to.equal( true );
 			expect( spies.cloneRepository.called ).to.equal( false );
 			expect( spies.cloneRepository.called ).to.equal( false );
 			expect( spies.checkout.calledTwice ).to.equal( true );
 			expect( spies.checkout.calledTwice ).to.equal( true );

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

@@ -16,12 +16,12 @@ const path = require( 'path' );
  *
  *
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {Object} packageJSON Parsed package.json file from CKEditor5 repository.
  * @param {Object} packageJSON Parsed package.json file from CKEditor5 repository.
- * @param {Object} options grunt options.
+ * @param {String} workspaceRoot Relative path to workspace root.
  * @param {Function} writeln Function for log output.
  * @param {Function} writeln Function for log output.
  * @param {Function} writeError Function of error output
  * @param {Function} writeError Function of error output
  */
  */
-module.exports = ( ckeditor5Path, packageJSON, options, writeln, writeError ) => {
-	const workspaceAbsolutePath = path.join( ckeditor5Path, options.workspaceRoot );
+module.exports = ( ckeditor5Path, packageJSON, workspaceRoot, writeln, writeError ) => {
+	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 
 
 	// Get all CKEditor dependencies from package.json.
 	// Get all CKEditor dependencies from package.json.
 	const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );
 	const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );

+ 3 - 3
dev/tasks/utils/dev-init.js

@@ -21,12 +21,12 @@ const path = require( 'path' );
  *
  *
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {Object} packageJSON Parsed package.json file from CKEditor5 repository.
  * @param {Object} packageJSON Parsed package.json file from CKEditor5 repository.
- * @param {Object} options grunt options.
+ * @param {String} workspaceRoot Relative path to workspace root.
  * @param {Function} writeln Function for log output.
  * @param {Function} writeln Function for log output.
  * @param {Function} writeError Function of error output
  * @param {Function} writeError Function of error output
  */
  */
-module.exports = ( ckeditor5Path, packageJSON, options, writeln, writeError ) => {
-	const workspaceAbsolutePath = path.join( ckeditor5Path, options.workspaceRoot );
+module.exports = ( ckeditor5Path, packageJSON, workspaceRoot, writeln, writeError ) => {
+	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 
 
 	// Get all CKEditor dependencies from package.json.
 	// Get all CKEditor dependencies from package.json.
 	const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );
 	const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );

+ 3 - 3
dev/tasks/utils/dev-plugin-create.js

@@ -24,12 +24,12 @@ const path = require( 'path' );
  * 9. Install Git hooks in plugin repository.
  * 9. Install Git hooks in plugin repository.
  *
  *
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
- * @param {Object} options grunt options.
+ * @param {String} workspaceRoot Relative path to workspace root.
  * @param {Function} writeln Function for log output.
  * @param {Function} writeln Function for log output.
  * @returns {Promise} Returns promise fulfilled after task is done.
  * @returns {Promise} Returns promise fulfilled after task is done.
  */
  */
-module.exports = ( ckeditor5Path, options, writeln ) => {
-	const workspaceAbsolutePath = path.join( ckeditor5Path, options.workspaceRoot );
+module.exports = ( ckeditor5Path, workspaceRoot, writeln ) => {
+	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 	let pluginName;
 	let pluginName;
 	let repositoryPath;
 	let repositoryPath;
 	let pluginVersion;
 	let pluginVersion;

+ 3 - 3
dev/tasks/utils/dev-plugin-install.js

@@ -21,12 +21,12 @@ const path = require( 'path' );
  * 8. Install Git hooks in plugin repository.
  * 8. Install Git hooks in plugin repository.
  *
  *
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
- * @param {Object} options grunt options.
+ * @param {String} workspaceRoot Relative path to workspace root.
  * @param {Function} writeln Function for log output.
  * @param {Function} writeln Function for log output.
  * @returns {Promise} Returns promise fulfilled after task is done.
  * @returns {Promise} Returns promise fulfilled after task is done.
  */
  */
-module.exports = ( ckeditor5Path, options, writeln ) => {
-	const workspaceAbsolutePath = path.join( ckeditor5Path, options.workspaceRoot );
+module.exports = ( ckeditor5Path, workspaceRoot, writeln ) => {
+	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 	let pluginName;
 	let pluginName;
 	let repositoryPath;
 	let repositoryPath;
 	let gitHubUrl;
 	let gitHubUrl;

+ 3 - 3
dev/tasks/utils/dev-status.js

@@ -16,12 +16,12 @@ const path = require( 'path' );
  *
  *
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {Object} packageJSON Parsed package.json file from CKEditor5 repository.
  * @param {Object} packageJSON Parsed package.json file from CKEditor5 repository.
- * @param {Object} options grunt options.
+ * @param {String} workspaceRoot Relative path to workspace root.
  * @param {Function} writeln Function for log output.
  * @param {Function} writeln Function for log output.
  * @param {Function} writeError Function of error output
  * @param {Function} writeError Function of error output
  */
  */
-module.exports = ( ckeditor5Path, packageJSON, options, writeln, writeError ) => {
-	const workspaceAbsolutePath = path.join( ckeditor5Path, options.workspaceRoot );
+module.exports = ( ckeditor5Path, packageJSON, workspaceRoot, writeln, writeError ) => {
+	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 
 
 	// Get all CKEditor dependencies from package.json.
 	// Get all CKEditor dependencies from package.json.
 	const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );
 	const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );

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

@@ -16,12 +16,12 @@ const path = require( 'path' );
  *
  *
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {Object} packageJSON Parsed package.json file from CKEditor5 repository.
  * @param {Object} packageJSON Parsed package.json file from CKEditor5 repository.
- * @param {Object} options grunt options.
+ * @param {String} workspaceRoot Relative path to workspace root.
  * @param {Function} writeln Function for log output.
  * @param {Function} writeln Function for log output.
  * @param {Function} writeError Function of error output
  * @param {Function} writeError Function of error output
  */
  */
-module.exports = ( ckeditor5Path, packageJSON, options, writeln, writeError ) => {
-	const workspaceAbsolutePath = path.join( ckeditor5Path, options.workspaceRoot );
+module.exports = ( ckeditor5Path, packageJSON, workspaceRoot, writeln, writeError ) => {
+	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 
 
 	// Get all CKEditor dependencies from package.json.
 	// Get all CKEditor dependencies from package.json.
 	const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );
 	const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );

+ 1 - 6
gruntfile.js

@@ -15,6 +15,7 @@ module.exports = ( grunt ) => {
 	// Basic configuration which will be overloaded by the tasks.
 	// Basic configuration which will be overloaded by the tasks.
 	grunt.initConfig( {
 	grunt.initConfig( {
 		pkg: grunt.file.readJSON( 'package.json' ),
 		pkg: grunt.file.readJSON( 'package.json' ),
+		workspaceRoot: '..',
 
 
 		jshint: {
 		jshint: {
 			options: {
 			options: {
@@ -26,12 +27,6 @@ module.exports = ( grunt ) => {
 			options: {
 			options: {
 				excludeFiles: ignoreFiles
 				excludeFiles: ignoreFiles
 			}
 			}
-		},
-
-		dev: {
-			options: {
-				workspaceRoot: '..'
-			}
 		}
 		}
 	} );
 	} );