Selaa lähdekoodia

Changed naming from plugin to package in dev-tasks.

Szymon Kupś 10 vuotta sitten
vanhempi
sitoutus
ca0d8758c1

+ 6 - 6
dev/tasks/dev/tasks.js

@@ -7,7 +7,7 @@ const minimist = require( 'minimist' );
 const statusTask = require( './tasks/dev-status' );
 const initTask = require( './tasks/dev-init' );
 const installTask = require( './tasks/dev-install' );
-const pluginCreateTask = require( './tasks/dev-plugin-create' );
+const pluginCreateTask = require( './tasks/dev-package-create' );
 const updateTask = require( './tasks/dev-update' );
 const relinkTask = require( './tasks/dev-relink' );
 
@@ -19,7 +19,7 @@ module.exports = ( config ) => {
 		initTask( installTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log );
 	} );
 
-	gulp.task( 'dev-plugin-create', ( done ) => {
+	gulp.task( 'dev-package-create', ( done ) => {
 		pluginCreateTask( ckeditor5Path, config.WORKSPACE_DIR, console.log )
 			.then( done )
 			.catch( ( error )  => done( error ) );
@@ -46,16 +46,16 @@ module.exports = ( config ) => {
 
 	gulp.task( 'dev-install', () => {
 		const options = minimist( process.argv.slice( 2 ), {
-			string: [ 'plugin' ],
+			string: [ 'package' ],
 			default: {
 				plugin: ''
 			}
 		} );
 
-		if ( options.plugin ) {
-			installTask( ckeditor5Path, config.WORKSPACE_DIR, options.plugin, console.log );
+		if ( options.package ) {
+			installTask( ckeditor5Path, config.WORKSPACE_DIR, options.package, console.log );
 		} else {
-			throw new Error( 'Please provide a plugin to install: gulp dev-install --plugin <path|GitHub URL|name>' );
+			throw new Error( 'Please provide a package to install: gulp dev-install --plugin <path|GitHub URL|name>' );
 		}
 	} );
 };

+ 6 - 6
dev/tasks/dev/tasks/dev-install.js

@@ -10,22 +10,22 @@ const tools = require( '../utils/tools' );
 const path = require( 'path' );
 
 /**
- * This tasks install specified module in development mode. It can be executed by typing:
- * 		grunt dev-install --plugin <git_hub_url|npm_name|path_on_disk>
+ * This tasks install specified package in development mode. It can be executed by typing:
+ * 		grunt dev-install --package <git_hub_url|npm_name|path_on_disk>
  *
  *
  * It performs following steps:
  * 1. If GitHub URL is provided - clones the repository.
  * 2. If NPM module name is provided - gets GitHub URL from NPM and clones the repository.
  * 3. If path on disk is provided - it is used directly.
- * 4. Runs `npm install` in plugin repository.
- * 5. If plugin exists in `ckeditor5/node_modules/` - runs `npm uninstall plugin_name`.
- * 6. Links plugin directory into `ckeditor5/node_modules/`.
+ * 4. Runs `npm install` in package repository.
+ * 5. If package exists in `ckeditor5/node_modules/` - runs `npm uninstall package_name`.
+ * 6. Links package directory into `ckeditor5/node_modules/`.
  * 7. Adds dependency to `ckeditor5/package.json`.
  *
  * @param {String} ckeditor5Path Absolute path to `ckeditor5` repository.
  * @param {String} workspaceRoot Relative path to workspace root directory.
- * @param {String} name Name of the NPM module or GitHub URL.
+ * @param {String} name Name of the NPM package or GitHub URL.
  * @param {Function} writeln Function used to report progress to the console.
  */
 module.exports = ( ckeditor5Path, workspaceRoot, name, writeln ) => {

+ 19 - 19
dev/tasks/dev/tasks/dev-plugin-create.js → dev/tasks/dev/tasks/dev-package-create.js

@@ -11,16 +11,16 @@ const tools = require( '../utils/tools' );
 const path = require( 'path' );
 
 /**
- * 1. Ask for new plugin name.
+ * 1. Ask for new package name.
  * 2. Ask for initial version.
  * 3. Ask for GitHub URL.
  * 4. Initialize repository.
  * 5. Copy files to new repository.
- * 6. Update package.json file in new plugin's repository.
+ * 6. Update package.json file in new package's repository.
  * 7. Update package.json file in CKEditor5 repository.
  * 8. Create initial commit.
- * 9. Link new plugin.
- * 10. Call `npm install` in plugin repository.
+ * 9. Link new package.
+ * 10. Call `npm install` in package repository.
  *
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {String} workspaceRoot Relative path to workspace root.
@@ -48,22 +48,22 @@ module.exports = ( ckeditor5Path, workspaceRoot, writeln ) => {
 		]
 	};
 
-	let pluginName;
+	let packageName;
 	let repositoryPath;
-	let pluginVersion;
+	let packageVersion;
 	let gitHubUrl;
 
-	return inquiries.getPluginName()
+	return inquiries.getPackageName()
 		.then( result => {
-			pluginName = result;
-			repositoryPath = path.join( workspaceAbsolutePath, pluginName );
+			packageName = result;
+			repositoryPath = path.join( workspaceAbsolutePath, packageName );
 
-			return inquiries.getPluginVersion();
+			return inquiries.getPackageVersion();
 		} )
 		.then( result => {
-			pluginVersion = result;
+			packageVersion = result;
 
-			return inquiries.getPluginGitHubUrl( pluginName );
+			return inquiries.getPackageGitHubUrl( packageName );
 		} )
 		.then( result => {
 			gitHubUrl = result;
@@ -79,8 +79,8 @@ module.exports = ( ckeditor5Path, workspaceRoot, writeln ) => {
 
 			writeln( `Updating package.json files...` );
 			tools.updateJSONFile( path.join( repositoryPath, 'package.json' ), ( json ) => {
-				json.name = pluginName;
-				json.version = pluginVersion;
+				json.name = packageName;
+				json.version = packageVersion;
 
 				return json;
 			} );
@@ -89,18 +89,18 @@ module.exports = ( ckeditor5Path, workspaceRoot, writeln ) => {
 				if ( !json.dependencies ) {
 					json.dependencies = {};
 				}
-				json.dependencies[ pluginName ] = gitHubUrl;
+				json.dependencies[ packageName ] = gitHubUrl;
 
 				return json;
 			} );
 
 			writeln( `Creating initial commit...` );
-			git.initialCommit( pluginName, repositoryPath );
+			git.initialCommit( packageName, repositoryPath );
 
-			writeln( `Linking ${ pluginName } to node_modules...` );
-			tools.linkDirectories( repositoryPath, path.join( ckeditor5Path, 'node_modules', pluginName ) );
+			writeln( `Linking ${ packageName } to node_modules...` );
+			tools.linkDirectories( repositoryPath, path.join( ckeditor5Path, 'node_modules', packageName ) );
 
-			writeln( `Running npm install in ${ pluginName }.` );
+			writeln( `Running npm install in ${ packageName }.` );
 			tools.npmInstall( repositoryPath );
 		} );
 };

+ 10 - 10
dev/tasks/dev/utils/inquiries.js

@@ -11,27 +11,27 @@ const DEFAULT_PLUGIN_VERSION = '0.0.1';
 const DEFAULT_GITHUB_URL_PREFIX = 'ckeditor/';
 
 module.exports = {
-	getPluginName() {
+	getPackageName() {
 		return new Promise( ( resolve ) => {
 			inquirer.prompt( [ {
-				name: 'pluginName',
-				message: 'Enter plugin name without ' + DEFAULT_PLUGIN_NAME_PREFIX + ' prefix:',
+				name: 'packageName',
+				message: 'Enter package name without ' + DEFAULT_PLUGIN_NAME_PREFIX + ' prefix:',
 				validate: ( input ) => {
 					const regexp = /^[\w-]+$/;
 
-					return regexp.test( input ) ? true : 'Please provide a valid plugin name.';
+					return regexp.test( input ) ? true : 'Please provide a valid package name.';
 				}
 			} ], ( answers ) => {
-				resolve( DEFAULT_PLUGIN_NAME_PREFIX + answers.pluginName );
+				resolve( DEFAULT_PLUGIN_NAME_PREFIX + answers.packageName );
 			} );
 		} );
 	},
 
-	getPluginVersion( ) {
+	getPackageVersion( ) {
 		return new Promise( ( resolve ) => {
 			inquirer.prompt( [ {
 				name: 'version',
-				message: 'Enter plugin\'s initial version:',
+				message: 'Enter package\'s initial version:',
 				default: DEFAULT_PLUGIN_VERSION
 			} ], ( answers ) => {
 				resolve( answers.version );
@@ -39,13 +39,13 @@ module.exports = {
 		} );
 	},
 
-	getPluginGitHubUrl( pluginName ) {
-		const defaultGitHubUrl = DEFAULT_GITHUB_URL_PREFIX + pluginName;
+	getPackageGitHubUrl( packageName ) {
+		const defaultGitHubUrl = DEFAULT_GITHUB_URL_PREFIX + packageName;
 
 		return new Promise( ( resolve ) => {
 			inquirer.prompt( [ {
 				name: 'gitHubUrl',
-				message: 'Enter plugin\'s GitHub URL:',
+				message: 'Enter package\'s GitHub URL:',
 				default: defaultGitHubUrl
 			} ], ( answers ) => {
 				resolve( answers.gitHubUrl );

+ 20 - 20
dev/tests/dev/dev-plugin-create.js → dev/tests/dev/dev-package-create.js

@@ -15,16 +15,16 @@ const inquiries = require( '../../tasks/dev/utils/inquiries' );
 const git = require( '../../tasks/dev/utils/git' );
 const path = require( 'path' );
 
-describe( 'dev-plugin-create', () => {
+describe( 'dev-package-create', () => {
 	const emptyFn = () => { };
 	let spies;
 
 	const mainRepositoryPath = '/path/to/repository';
 	const workspaceRoot = '..';
 	const workspacePath = path.join( mainRepositoryPath, workspaceRoot );
-	const pluginName = 'plugin-name';
-	const pluginVersion = '0.0.1';
-	const gitHubUrl = 'ckeditor5/plugin-name';
+	const packageName = 'package-name';
+	const packageVersion = '0.0.1';
+	const gitHubUrl = 'ckeditor5/package-name';
 
 	beforeEach( () => createSpies() );
 	afterEach( () => restoreSpies() );
@@ -33,9 +33,9 @@ describe( 'dev-plugin-create', () => {
 		spies = {
 			linkDirectories: sinon.stub( tools, 'linkDirectories' ),
 			npmInstall: sinon.stub( tools, 'npmInstall' ),
-			getPluginName: sinon.stub( inquiries, 'getPluginName' ).returns( new Promise( ( r ) => r( pluginName ) ) ),
-			getPluginVersion: sinon.stub( inquiries, 'getPluginVersion' ).returns( new Promise( ( r ) => r( pluginVersion ) ) ),
-			getPluginGitHubUrl: sinon.stub( inquiries, 'getPluginGitHubUrl' ).returns( new Promise( ( r ) => r( gitHubUrl ) ) ),
+			getPackageName: sinon.stub( inquiries, 'getPackageName' ).returns( new Promise( ( r ) => r( packageName ) ) ),
+			getPackageVersion: sinon.stub( inquiries, 'getPackageVersion' ).returns( new Promise( ( r ) => r( packageVersion ) ) ),
+			getPackageGitHubUrl: sinon.stub( inquiries, 'getPackageGitHubUrl' ).returns( new Promise( ( r ) => r( gitHubUrl ) ) ),
 			initializeRepository: sinon.stub( git, 'initializeRepository' ),
 			updateJSONFile: sinon.stub( tools, 'updateJSONFile' ),
 			copy: sinon.stub( tools, 'copy' ),
@@ -49,16 +49,16 @@ describe( 'dev-plugin-create', () => {
 		}
 	}
 
-	const pluginCreateTask = require( '../../tasks/dev/tasks/dev-plugin-create' );
-	const repositoryPath = path.join( workspacePath, pluginName );
+	const packageCreateTask = require( '../../tasks/dev/tasks/dev-package-create' );
+	const repositoryPath = path.join( workspacePath, packageName );
 
-	it( 'should exist', () => expect( pluginCreateTask ).to.be.a( 'function' ) );
+	it( 'should exist', () => expect( packageCreateTask ).to.be.a( 'function' ) );
 
-	it( 'should create a plugin', () => {
-		return pluginCreateTask( mainRepositoryPath, workspaceRoot, emptyFn ).then( () => {
-			expect( spies.getPluginName.calledOnce ).to.equal( true );
-			expect( spies.getPluginVersion.calledOnce ).to.equal( true );
-			expect( spies.getPluginGitHubUrl.calledOnce ).to.equal( true );
+	it( 'should create a package', () => {
+		return packageCreateTask( mainRepositoryPath, workspaceRoot, emptyFn ).then( () => {
+			expect( spies.getPackageName.calledOnce ).to.equal( true );
+			expect( spies.getPackageVersion.calledOnce ).to.equal( true );
+			expect( spies.getPackageGitHubUrl.calledOnce ).to.equal( true );
 			expect( spies.initializeRepository.calledOnce ).to.equal( true );
 			expect( spies.initializeRepository.firstCall.args[ 0 ] ).to.equal( repositoryPath );
 			expect( spies.copy.called ).to.equal( true );
@@ -66,19 +66,19 @@ describe( 'dev-plugin-create', () => {
 			expect( spies.updateJSONFile.firstCall.args[ 0 ] ).to.equal( path.join( repositoryPath, 'package.json' ) );
 			let updateFn = spies.updateJSONFile.firstCall.args[ 1 ];
 			let json = updateFn( {} );
-			expect( json.name ).to.equal( pluginName );
-			expect( json.version ).to.equal( pluginVersion );
+			expect( json.name ).to.equal( packageName );
+			expect( json.version ).to.equal( packageVersion );
 			expect( spies.updateJSONFile.secondCall.args[ 0 ] ).to.equal( path.join( mainRepositoryPath, 'package.json' ) );
 			updateFn = spies.updateJSONFile.secondCall.args[ 1 ];
 			json = updateFn( {} );
 			expect( json.dependencies ).to.be.an( 'object' );
-			expect( json.dependencies[ pluginName ] ).to.equal( gitHubUrl );
+			expect( json.dependencies[ packageName ] ).to.equal( gitHubUrl );
 			expect( spies.initialCommit.calledOnce ).to.equal( true );
-			expect( spies.initialCommit.firstCall.args[ 0 ] ).to.equal( pluginName );
+			expect( spies.initialCommit.firstCall.args[ 0 ] ).to.equal( packageName );
 			expect( spies.initialCommit.firstCall.args[ 1 ] ).to.equal( repositoryPath );
 			expect( spies.linkDirectories.calledOnce ).to.equal( true );
 			expect( spies.linkDirectories.firstCall.args[ 0 ] ).to.equal( repositoryPath );
-			expect( spies.linkDirectories.firstCall.args[ 1 ] ).to.equal( path.join( mainRepositoryPath, 'node_modules', pluginName ) );
+			expect( spies.linkDirectories.firstCall.args[ 1 ] ).to.equal( path.join( mainRepositoryPath, 'node_modules', packageName ) );
 			expect( spies.npmInstall.calledOnce ).to.equal( true );
 			expect( spies.npmInstall.firstCall.args[ 0 ] ).to.equal( repositoryPath );
 		} );