8
0
Pārlūkot izejas kodu

Deleted temporary files.

Szymon Kupś 10 gadi atpakaļ
vecāks
revīzija
a6db143f2a

+ 0 - 20
dev/tasks/plugin.js

@@ -1,20 +0,0 @@
-'use strict';
-
-var createPlugin = require( './plugin/create' );
-var installPlugin = require( './plugin/install' );
-
-module.exports = function( grunt ) {
-	grunt.registerTask( 'plugin', function( target ) {
-		var done = this.async();
-
-		switch ( target ) {
-			case 'create':
-				createPlugin( grunt, done );
-				break;
-
-			case 'install':
-				installPlugin( grunt, done );
-				break;
-		}
-	} );
-};

+ 0 - 112
dev/tasks/plugin/common.js

@@ -1,112 +0,0 @@
-'use strict';
-var tools = require( '../utils/tools' );
-var path = require( 'path' );
-var fs = require( 'fs' );
-var INITIAL_COMMIT_MESSAGE = 'Initial plugin commit.';
-
-module.exports = {
-	linkPlugin: function( data ) {
-		// Don't use sudo on windows when executing npm link.
-		var isWin = process.platform == 'win32';
-		data.grunt.log.writeln( 'Linking plugin with npm link...' );
-
-		return new Promise( function( resolve ) {
-			var linkCommands = [
-				'cd ' + data.repositoryLocation,
-				( !isWin ? 'sudo ' : '' ) + 'npm link',
-				'cd ' + data.cwd,
-				'npm link ' + data.pluginName
-			];
-
-			tools.shExec( linkCommands.join( ' && ' ) );
-			resolve( data );
-		} );
-	},
-
-	cloneRepository: function( data ) {
-		var repo = 'git@github.com:' + data.gitHubUrl;
-		data.grunt.log.writeln( 'Cloning repository ' + repo + '...' );
-
-		return new Promise( function( resolve ) {
-			var cloneCommands = [
-				'cd ' + path.join( data.repositoryLocation, '..' ),
-				'git clone ' + repo
-			];
-
-			tools.shExec( cloneCommands.join( ' && ' ) );
-			resolve( data );
-		} );
-	},
-
-	/**
-	 * Creates initial git commit for new plugin. New plugin is created by merging CKEditor5 boilerplate and modifying
-	 * package.json. After that initial commit is needed.
-	 * @param data
-	 * @param {String} data.repositoryLocation New plugin location on disk.
-	 */
-	commitNewPlugin: function( data ) {
-		return new Promise( function( resolve ) {
-			var commitCommands = [
-				'cd ' + data.repositoryLocation,
-				'git add package.json',
-				'git commit -m "' + INITIAL_COMMIT_MESSAGE + '"'
-			];
-
-			tools.shExec( commitCommands.join( ' && ' ) );
-			resolve( data );
-		} );
-	},
-
-	/**
-	 * Updates CKEditor5 package.json file by adding new plugin dependency. Returns promise resolved when update is
-	 * finished.
-	 * @param {Object} data
-	 * @param {String} data.cwd Grunt starting directory - full path to CKEditor5 git repository on disk.
-	 * @param {String} data.pluginName New plugin name.
-	 * @param {String} data.gitHubUrl New plugin GitHub url.
-	 * @returns {Promise}
-	 */
-	updatePackageJson: function( data ) {
-		data.grunt.log.writeln( 'Updating CKEditor5 package.json...' );
-
-		return new Promise( function( resolve, reject ) {
-			module.exports.updateJSONFile( path.join( data.cwd, 'package.json' ), function( json ) {
-				if ( !json.dependencies ) {
-					json.dependencies = {};
-				}
-
-				json.dependencies[ data.pluginName ] = data.gitHubUrl;
-
-				return json;
-			} ).then( function() {
-				resolve( data );
-			}, function( error ) {
-				reject( error );
-			} );
-		} );
-	},
-
-	// Changes given package.json.
-	updateJSONFile: function( path, changeFn ) {
-		return new Promise( function( resolve, reject ) {
-			fs.readFile( path, 'utf-8', function( err, file ) {
-				var json;
-
-				if ( err ) {
-					return reject( err );
-				}
-
-				// Update package.json file.
-				json = JSON.parse( file );
-				json = changeFn( json );
-				fs.writeFile( path, JSON.stringify( json, null, 2 ), 'utf-8', function( err ) {
-					if ( err ) {
-						return reject( err );
-					}
-
-					resolve( );
-				} );
-			} );
-		} );
-	}
-};

+ 0 - 68
dev/tasks/plugin/create.js

@@ -1,68 +0,0 @@
-'use strict';
-var inquiries = require( './inquiries' );
-var common = require( './common' );
-var path = require( 'path' );
-var tools = require( '../utils/tools' );
-
-module.exports = function( grunt, done ) {
-	var data = {
-		grunt: grunt,
-		cwd: process.cwd(),
-		pluginName: '',
-		repositoryLocation: '',
-		gitHubUrl: '',
-		version: '0.0.1'
-	};
-
-	inquiries.getPluginName( data )
-		.then( inquiries.getRepositoryLocation )
-		.then( inquiries.getPluginVersion )
-		.then( inquiries.getPluginGitHubUrl )
-		.then( createRepository )
-		.then( updatePluginPackageJSON )
-		.then( common.updatePackageJson )
-		.then( common.linkPlugin )
-		.then( common.commitNewPlugin )
-		.then( function() {
-			done();
-		} ).catch( function( e ) {
-			done( e );
-		} );
-};
-
-// Updates plugin package.json by adding name of the plugin and version.
-function updatePluginPackageJSON( data ) {
-	var packageJSONPath = path.join( data.repositoryLocation, 'package.json' );
-
-	data.grunt.log.writeln( 'Updating plugin\'s package.json...' );
-
-	return new Promise( function( resolve ) {
-		common.updateJSONFile( packageJSONPath, function( json ) {
-			json.name = data.pluginName;
-			json.version = data.version;
-
-			return json;
-		} ).then( function() {
-			resolve( data );
-		} );
-	} );
-}
-
-// Initializes git repository and merges ckeditor5 boilerplate into master branch.
-function createRepository( data ) {
-	data.grunt.log.writeln( 'Initializing plugin repository...' );
-
-	return new Promise( function( resolve ) {
-		var repositoryLocation = data.repositoryLocation;
-		var initializeRepoCommands = [
-			'git init ' + repositoryLocation,
-			'cd ' + repositoryLocation,
-			'git remote add boilerplate git@github.com:ckeditor/ckeditor-boilerplate.git',
-			'git fetch boilerplate ckeditor5',
-			'git merge boilerplate/ckeditor5'
-		];
-
-		tools.shExec( initializeRepoCommands.join( ' && ' ) );
-		resolve( data );
-	} );
-}

+ 0 - 81
dev/tasks/plugin/inquiries.js

@@ -1,81 +0,0 @@
-'use strict';
-var inquirer = require( 'inquirer' );
-var path = require( 'path' );
-var fs = require( 'fs' );
-var DEFAULT_PLUGIN_NAME_PREFIX = 'ckeditor5-plugin-';
-var DEFAULT_GITHUB_URL_PREFIX = 'ckeditor/';
-
-module.exports = {
-	getPluginName: function( data ) {
-		return new Promise( function( resolve ) {
-			inquirer.prompt( [ {
-				name: 'pluginName',
-				message: 'Enter plugin name without ' + DEFAULT_PLUGIN_NAME_PREFIX + ' prefix:',
-				validate: function( input ) {
-					var regexp = /^[a-zA-Z0-9-_]+$/;
-
-					return regexp.test( input ) ? true : 'Please provide a valid plugin name.';
-				},
-				default: data.pluginName ? data.pluginName : null
-			} ], function( answers ) {
-				data.pluginName = DEFAULT_PLUGIN_NAME_PREFIX + answers.pluginName;
-				resolve( data );
-			} );
-		} );
-	},
-
-	// Ask for initial version of the plugin.
-	getPluginVersion: function( data ) {
-		return new Promise( function( resolve ) {
-			inquirer.prompt( [ {
-				name: 'version',
-				message: 'Enter plugin\'s initial version:',
-				default: data.version ? data.version : ''
-			} ], function( answers ) {
-				data.version = answers.version;
-				resolve( data );
-			} );
-		} );
-	},
-
-	// Ask for the location of the repository.
-	getRepositoryLocation: function( data ) {
-		var defaultLocation = path.join( data.cwd, '..', data.pluginName );
-
-		return new Promise( function( resolve ) {
-			inquirer.prompt( [ {
-				name: 'path',
-				message: 'Enter repository location:',
-				default: defaultLocation,
-				validate: function( input ) {
-					var status;
-
-					try {
-						status = fs.statSync( input );
-					} catch ( e ) {}
-
-					return status && ( status.isFile() || status.isDirectory() ) ? 'Repository location already exists.' : true;
-				}
-			} ], function( answers ) {
-				data.repositoryLocation = answers.path;
-				resolve( data );
-			} );
-		} );
-	},
-
-	// Ask for GitHub Url.
-	getPluginGitHubUrl: function( data ) {
-		var defaultGitHubUrl = DEFAULT_GITHUB_URL_PREFIX + data.pluginName;
-
-		return new Promise( function( resolve ) {
-			inquirer.prompt( [ {
-				name: 'gitHubUrl',
-				message: 'Enter plugin\'s GitHub URL:',
-				default: defaultGitHubUrl
-			} ], function( answers ) {
-				data.gitHubUrl = answers.gitHubUrl;
-				resolve( data );
-			} );
-		} );
-	}
-};

+ 0 - 31
dev/tasks/plugin/install.js

@@ -1,31 +0,0 @@
-'use strict';
-var inquiries = require( './inquiries' );
-var common = require( './common' );
-
-/**
- * Executes plugin install grunt task.
- * @param grunt
- * @param done
- */
-module.exports = function( grunt, done ) {
-	var data = {
-		grunt: grunt,
-		cwd: process.cwd(),
-		pluginName: '',
-		repositoryLocation: '',
-		gitHubUrl: ''
-	};
-
-	inquiries.getPluginName( data )
-		.then( inquiries.getRepositoryLocation )
-		.then( inquiries.getPluginGitHubUrl )
-		.then( common.cloneRepository )
-		.then( common.linkPlugin )
-		.then( common.updatePackageJson )
-		.then( function() {
-			done();
-		} )
-		.catch( function( error ) {
-			done( error );
-		} );
-};

+ 0 - 64
dev/tasks/test/dev.js

@@ -1,64 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-/* global describe, it */
-
-var chai = require( 'chai' );
-var tools = require( '../utils/tools' );
-var sinon = require( 'sinon' );
-var path = require( 'path' );
-var expect = chai.expect;
-var dev = require( './../dev' );
-var grunt = {
-	tasks: {},
-	registerTask: function( taskName, fn ) {
-		this.tasks[ taskName ] = fn;
-	},
-	log: {
-		writeln: function() {}
-	}
-};
-
-dev( grunt );
-
-describe( 'tasks', function() {
-	describe( 'dev:init', function() {
-		it( 'should get ckeditor5- dependencies, clone repositories and link them', function() {
-			var getDepsSpy = sinon.spy( tools, 'getCKEditorDependencies' );
-			var cloneRepositoryStub = sinon.stub( tools, 'cloneRepository' );
-			var npmLinkStub = sinon.stub( tools, 'npmLink' );
-			var regexp = /^ckeditor\//;
-			var ckeditor5Path = process.cwd();
-			var location = path.join( ckeditor5Path, '..' );
-			var dependencies, keys;
-
-			grunt.tasks.dev( 'init' );
-
-			getDepsSpy.restore();
-			cloneRepositoryStub.restore();
-			npmLinkStub.restore();
-
-			expect( getDepsSpy.calledOnce ).to.equal( true );
-			dependencies = getDepsSpy.firstCall.returnValue;
-
-			if ( dependencies ) {
-				keys = Object.keys( dependencies ).filter( key => regexp.test( dependencies[ key ] ) );
-
-				expect( cloneRepositoryStub.callCount ).to.equal( keys.length );
-				expect( npmLinkStub.callCount ).to.equal( keys.length );
-
-				keys.forEach( function( key, i ) {
-					expect( cloneRepositoryStub.getCall( i ).args[0] ).equal( dependencies[ key ] );
-					expect( cloneRepositoryStub.getCall( i ).args[1] ).equal( location );
-
-					expect( npmLinkStub.getCall( i ).args[0] ).equal( path.join( location, key ) );
-					expect( npmLinkStub.getCall( i ).args[1] ).equal( ckeditor5Path );
-					expect( npmLinkStub.getCall( i ).args[2] ).equal( key );
-				} );
-			}
-		} );
-	} );
-} );

+ 0 - 92
dev/tasks/test/tools.js

@@ -1,92 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-/* global describe, it */
-
-var chai = require( 'chai' );
-var sinon = require( 'sinon' );
-var expect = chai.expect;
-var tools = require( '../utils/tools' );
-
-describe( 'utils', function() {
-	describe( 'tools', function() {
-		describe( 'cloneRepository', function() {
-			it( 'should be defined', function() {
-				expect( tools.cloneRepository ).to.be.a( 'function' );
-			} );
-
-			it( 'should run clone repository commands', function( ) {
-				var shExecStub = sinon.stub( tools, 'shExec' );
-				var gitHubUrl = '/cksource/test';
-				var destination = '/destination/dir';
-
-				tools.cloneRepository( gitHubUrl, destination );
-				shExecStub.restore();
-
-				expect( shExecStub.calledOnce ).to.equal( true );
-				expect( shExecStub.firstCall.args[ 0 ] ).to.equal( 'cd ' + destination + ' && git clone git@github.com:' + gitHubUrl );
-			} );
-		} );
-
-		describe( 'npmLink', function() {
-			it( 'should be defined', function() {
-				expect( tools.cloneRepository ).to.be.a( 'function' );
-			} );
-
-			it( 'should run npm link commands', function( ) {
-				var shExecStub = sinon.stub( tools, 'shExec' );
-				var source = '/source/dir';
-				var destination = '/destination/dir';
-				var pluginName = 'ckeditor5-plugin-name';
-				var isWin = process.platform == 'win32';
-				var linkCommands = [
-					'cd ' + source,
-					( !isWin ? 'sudo ' : '' ) + 'npm link',
-					'cd ' + destination,
-					'npm link ' + pluginName
-				];
-
-				tools.npmLink( source, destination, pluginName );
-				shExecStub.restore();
-
-				expect( shExecStub.calledOnce ).to.equal( true );
-				expect( shExecStub.firstCall.args[ 0 ] ).to.equal( linkCommands.join( ' && ' ) );
-			} );
-		} );
-
-		describe( 'getCKEditorDependencies', function() {
-			it( 'should be defined', function() {
-				expect( tools.getCKEditorDependencies ).to.be.a( 'function' );
-			} );
-
-			it( 'should return null if no CKEditor5 repository is found', function() {
-				var dependencies = {
-					'plugin1': '',
-					'plugin2': '',
-					'plugin3': ''
-				};
-				expect( tools.getCKEditorDependencies( dependencies ) ).to.equal( null );
-			} );
-
-			it( 'should return only ckeditor5- dependencies', function() {
-				var dependencies = {
-					'plugin1': '',
-					'ckeditor5-plugin-image': '',
-					'plugin2': '',
-					'ckeditor5-core': ''
-				};
-
-				var ckeditorDependencies = tools.getCKEditorDependencies( dependencies );
-
-				expect( ckeditorDependencies ).to.be.an( 'object' );
-				expect( ckeditorDependencies.plugin1 ).to.be.a( 'undefined' );
-				expect( ckeditorDependencies.plugin2 ).to.be.a( 'undefined' );
-				expect( ckeditorDependencies[ 'ckeditor5-plugin-image' ] ).to.be.a( 'string' );
-				expect( ckeditorDependencies[ 'ckeditor5-core' ] ).to.be.a( 'string' );
-			} );
-		} );
-	} );
-} );