瀏覽代碼

Changed dev-plugin-create task to use local template files instead of boilerplate project.

Szymon Kupś 10 年之前
父節點
當前提交
3353d19083

+ 26 - 10
dev/tasks/dev/tasks/dev-plugin-create.js

@@ -14,16 +14,13 @@ const path = require( 'path' );
  * 1. Ask for new plugin name.
  * 2. Ask for initial version.
  * 3. Ask for GitHub URL.
- * 4. Initialize repository
- * 		4.1. Initialize Git repository.
- * 		4.2. Fetch and merge boilerplate project.
- * 5. Copy template files.
+ * 4. Initialize repository.
+ * 5. Copy files to new repository.
  * 6. Update package.json file in new plugin'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.
- * 11. Install Git hooks in plugin repository.
  *
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {String} workspaceRoot Relative path to workspace root.
@@ -32,6 +29,25 @@ const path = require( 'path' );
  */
 module.exports = ( ckeditor5Path, workspaceRoot, writeln ) => {
 	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
+	const fileStructure = {
+		'./': [
+			'.editorconfig',
+			'.jshintrc',
+			'.jscsrc',
+			'.gitattributes',
+			'./dev/tasks/dev/templates'
+		],
+		'tests/': [
+			'tests/.jshintrc'
+		],
+		'dev/': [
+			'dev/.jshintrc'
+		],
+		'dev/tasks/lint': [
+			'dev/tasks/lint'
+		]
+	};
+
 	let pluginName;
 	let repositoryPath;
 	let pluginVersion;
@@ -55,8 +71,11 @@ module.exports = ( ckeditor5Path, workspaceRoot, writeln ) => {
 			writeln( `Initializing repository ${ repositoryPath }...` );
 			git.initializeRepository( repositoryPath );
 
-			writeln( `Copying template files to ${ repositoryPath }...` );
-			tools.copyTemplateFiles( repositoryPath );
+			writeln( `Copying files into ${ repositoryPath }...` );
+
+			for ( let destination in fileStructure ) {
+				tools.copy( fileStructure[ destination ], path.join( repositoryPath, destination ) );
+			}
 
 			writeln( `Updating package.json files...` );
 			tools.updateJSONFile( path.join( repositoryPath, 'package.json' ), ( json ) => {
@@ -83,8 +102,5 @@ module.exports = ( ckeditor5Path, workspaceRoot, writeln ) => {
 
 			writeln( `Running npm install in ${ pluginName }.` );
 			tools.npmInstall( repositoryPath );
-
-			writeln( `Installing Git hooks in ${ pluginName }.` );
-			tools.installGitHooks( repositoryPath );
 		} );
 };

+ 10 - 0
dev/tasks/dev/templates/.gitignore

@@ -0,0 +1,10 @@
+# These files will be ignored by Git and by our linting tools:
+#	grunt jshint
+#	grunt jscs
+#
+# Be sure to append /** to folders to have everything inside them ignored.
+
+# All "dot directories".
+.*/**
+
+node_modules/**

+ 13 - 0
dev/tasks/dev/templates/gulpfile.js

@@ -0,0 +1,13 @@
+/* jshint node: true, esnext: true */
+
+'use strict';
+
+const config = {
+	ROOT_DIR: '.',
+	WORKSPACE_DIR: '..',
+
+	// Files ignored by jshit and jscs tasks. Files from .gitignore will be added automatically during tasks execution.
+	IGNORED_FILES: [ 'lib/**' ]
+};
+
+require( './dev/tasks/lint/tasks' )( config );

+ 22 - 0
dev/tasks/dev/templates/package.json

@@ -0,0 +1,22 @@
+{
+	"name": "",
+	"version": "",
+	"description": "",
+	"keywords": [],
+	"dependencies": {},
+	"devDependencies": {
+		"git-guppy": "^1.0.1",
+		"gulp": "^3.9.0",
+		"gulp-filter": "^3.0.1",
+		"gulp-jscs": "^3.0.2",
+		"gulp-jshint": "^2.0.0",
+		"guppy-pre-commit": "^0.3.0",
+		"jshint": "^2.9.1",
+		"jshint-reporter-jscs": "^0.1.0"
+	},
+	"author": "CKSource (http://cksource.com/)",
+	"license": "See LICENSE.md",
+	"homepage": "",
+	"bugs": "",
+	"repository": ""
+}

+ 1 - 9
dev/tasks/dev/utils/git.js

@@ -118,15 +118,7 @@ module.exports = {
 	 * @param {String} repositoryPath Absolute path where repository should be created.
 	 */
 	initializeRepository( repositoryPath ) {
-		const initializeCommands = [
-			`git init ${ repositoryPath }`,
-			`cd ${ repositoryPath }`,
-			`git remote add boilerplate ${ this.BOILERPLATE_REPOSITORY }`,
-			`git fetch boilerplate ${ this.BOILERPLATE_BRANCH }`,
-			`git merge boilerplate/${ this.BOILERPLATE_BRANCH }`
-		];
-
-		tools.shExec( initializeCommands.join( ' && ' ) );
+		tools.shExec( `git init ${ repositoryPath }` );
 	},
 
 	/**

+ 21 - 6
dev/tasks/dev/utils/tools.js

@@ -4,7 +4,6 @@ let dirtyFiles,
 	ignoreList;
 
 const dependencyRegExp = /^ckeditor5-/;
-const TEMPLATE_PATH = './dev/tasks/gulp/dev/templates';
 
 module.exports = {
 	/**
@@ -313,14 +312,30 @@ module.exports = {
 	},
 
 	/**
-	 * Copies template files to specified destination.
+	 * Copies source files/directories into destination directory.
+	 * If directory path is provided in sources array - all files inside that directory will be copied.
 	 *
-	 * @param {String} destination
+	 * @param { Array } source Source files/directories.
+	 * @param { String} destination Path to destination directory.
 	 */
-	copyTemplateFiles( destination ) {
+	copy( sources, destination ) {
 		const path = require( 'path' );
-		const templatesPath = path.resolve( TEMPLATE_PATH );
-		this.shExec( `cp ${ path.join( templatesPath, '*.md' ) } ${ destination }` );
+		const fs = require( 'fs-extra' );
+		destination = path.resolve( destination );
+
+		fs.ensureDirSync( destination );
+
+		sources.forEach( source => {
+			source = path.resolve( source );
+
+			if ( this.isFile( source ) ) {
+				fs.copySync( source, path.join( destination, path.basename( source ) ) );
+			}
+
+			if ( this.isDirectory( source ) ) {
+				fs.copySync( source, destination );
+			}
+		} );
 	},
 
 	/**

+ 1 - 1
package.json

@@ -25,6 +25,7 @@
     "chai": "^3.4.0",
     "concat-stream": "^1.5.1",
     "del": "^2.0.2",
+    "fs-extra": "^0.26.4",
     "git-guppy": "^1.0.1",
     "gulp": "^3.9.0",
     "gulp-babel": "^6.1.0",
@@ -41,7 +42,6 @@
     "istanbul": "^0.4.1",
     "jshint": "^2.9.1",
     "jshint-reporter-jscs": "^0.1.0",
-    "jshint-stylish": "^2.1.0",
     "merge-stream": "^1.0.0",
     "minimist": "^1.2.0",
     "mocha": "^2.2.5",