Spage has uploaded a new change for review.
https://gerrit.wikimedia.org/r/200226
Change subject: BoilerPlate: add std. composer and npm/grunt setup
......................................................................
BoilerPlate: add std. composer and npm/grunt setup
cd BoilerPlate
npm install
npm test
composer install
composer test
runs Wikimedia's code checkers using our recommended continous integration
setup.
It runs parallel-lint and phpcs on PHP code, and jshint and jscs on JavaScript
code.
Change-Id: I71e0c874994cbc7627e1996ce5d2b3e0b2664cc0
---
M .gitignore
A BoilerPlate/.jscsrc
M BoilerPlate/.jshintrc
M BoilerPlate/BoilerPlate.php
A BoilerPlate/Gruntfile.js
A BoilerPlate/composer.json
M BoilerPlate/modules/ext.BoilerPlate.foo.css
M BoilerPlate/modules/ext.BoilerPlate.foo.js
A BoilerPlate/modules/ext.BoilerPlate.js
A BoilerPlate/package.json
M BoilerPlate/specials/SpecialHelloWorld.php
M Example/.jshintrc
12 files changed, 145 insertions(+), 40 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/examples
refs/changes/26/200226/1
diff --git a/.gitignore b/.gitignore
index 4adf6bd..5820100 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
.*.swp
*~
.project
+composer.lock
+vendor
+node_modules
diff --git a/BoilerPlate/.jscsrc b/BoilerPlate/.jscsrc
new file mode 100644
index 0000000..9d22e3f
--- /dev/null
+++ b/BoilerPlate/.jscsrc
@@ -0,0 +1,3 @@
+{
+ "preset": "wikimedia"
+}
diff --git a/BoilerPlate/.jshintrc b/BoilerPlate/.jshintrc
index 4cd914b..d43c482 100644
--- a/BoilerPlate/.jshintrc
+++ b/BoilerPlate/.jshintrc
@@ -1,8 +1,20 @@
{
- "predef": [
- "mediaWiki",
- "jQuery"
- ],
+ // Enforcing
+ "bitwise": true,
+ "eqeqeq": true,
+ "es3": true,
+ "latedef": true,
+ "noarg": true,
+ "nonew": true,
+ "undef": true,
+ "unused": true,
+ "strict": false,
+
+ // Environment
"browser": true,
- "smarttabs": true
+
+ "globals": {
+ "mw": false,
+ "$": false
+ }
}
diff --git a/BoilerPlate/BoilerPlate.php b/BoilerPlate/BoilerPlate.php
index 12a0ebe..928492f 100644
--- a/BoilerPlate/BoilerPlate.php
+++ b/BoilerPlate/BoilerPlate.php
@@ -6,19 +6,19 @@
*
* @file
* @ingroup Extensions
- * @author John Doe, 2014
- * @license GNU General Public Licence 2.0 or later
+ * @author Your Name, 2015
*/
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
'name' => 'BoilerPlate',
'author' => array(
- 'John Doe',
+ 'Your Name',
),
- 'version' => '0.2.0',
+ 'version' => '0.0.0',
'url' => 'https://www.mediawiki.org/wiki/Extension:BoilerPlate',
'descriptionmsg' => 'boilerplate-desc',
+ 'license-name' => 'MIT',
);
/* Setup */
@@ -37,12 +37,13 @@
$wgSpecialPageGroups['HelloWorld'] = 'other';
// Register modules
-$wgResourceModules['ext.BoilerPlate.foo'] = array(
+$wgResourceModules['ext.boilerPlate.foo'] = array(
'scripts' => array(
- 'modules/ext.BoilerPlate.foo.js',
+ 'modules/ext.boilerPlate.js',
+ 'modules/ext.boilerPlate.foo.js',
),
'styles' => array(
- 'modules/ext.BoilerPlate.foo.css',
+ 'modules/ext.boilerPlate.foo.css',
),
'messages' => array(
),
diff --git a/BoilerPlate/Gruntfile.js b/BoilerPlate/Gruntfile.js
new file mode 100644
index 0000000..38a1a09
--- /dev/null
+++ b/BoilerPlate/Gruntfile.js
@@ -0,0 +1,27 @@
+/*jshint node:true */
+module.exports = function ( grunt ) {
+ grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+ grunt.loadNpmTasks( 'grunt-jscs' );
+
+ grunt.initConfig( {
+ jshint: {
+ options: {
+ jshintrc: true
+ },
+ all: [
+ '*.js',
+ 'modules/**/*.js'
+ ]
+ },
+ jscs: {
+ src: '<%= jshint.all %>'
+ },
+ banana: {
+ all: 'i18n/'
+ }
+ } );
+
+ grunt.registerTask( 'lint', [ 'jshint', 'jscs' ] );
+ grunt.registerTask( 'test', [ 'lint' ] );
+ grunt.registerTask( 'default', 'test' );
+};
diff --git a/BoilerPlate/composer.json b/BoilerPlate/composer.json
new file mode 100644
index 0000000..2eb6255
--- /dev/null
+++ b/BoilerPlate/composer.json
@@ -0,0 +1,13 @@
+{
+ "require-dev": {
+ "jakub-onderka/php-parallel-lint": "0.8.*",
+ "mediawiki/mediawiki-codesniffer": "dev-master",
+ "squizlabs/php_codesniffer": "2.1.*"
+ },
+ "scripts": {
+ "test": [
+ "parallel-lint . --exclude vendor",
+ "phpcs . -v
--standard=vendor/mediawiki/mediawiki-codesniffer/MediaWiki
--ignore=vendor/*,node_modules/* --extensions=php"
+ ]
+ }
+}
diff --git a/BoilerPlate/modules/ext.BoilerPlate.foo.css
b/BoilerPlate/modules/ext.BoilerPlate.foo.css
index 4ec947d..5c48759 100644
--- a/BoilerPlate/modules/ext.BoilerPlate.foo.css
+++ b/BoilerPlate/modules/ext.BoilerPlate.foo.css
@@ -1,7 +1,3 @@
-/**
- * Stylesheet for Foo in BoilerPlate.
- */
-
.mw-boilerplate-foo {
- display: block;
+ float: left;
}
diff --git a/BoilerPlate/modules/ext.BoilerPlate.foo.js
b/BoilerPlate/modules/ext.BoilerPlate.foo.js
index dcbbaee..8081346 100644
--- a/BoilerPlate/modules/ext.BoilerPlate.foo.js
+++ b/BoilerPlate/modules/ext.BoilerPlate.foo.js
@@ -1,23 +1,37 @@
-/**
- * JavaScript for Foo in BoilerPlate.
- */
+( function () {
+ var x;
-( function ( mw, $ ) {
- var foo, x, y;
-
- function my() {
-
+ function iffify( y ) {
+ return y + x;
}
- foo = {
- init: function () {
- // ..
- },
- doStuff: function () {
- // ..
+ /**
+ * @class mw.boilerPlate.Foo
+ *
+ * @constructor
+ */
+ function Foo() {
+ }
+
+ /**
+ * @static
+ * @param {string} a
+ * @param {number} b
+ * @return {boolean}
+ */
+ Foo.create = function ( a, b ) {
+ return new Foo( iffify( a + b ) ).connect();
+ };
+
+ Foo.prototype = {
+
+ /**
+ * Establish connection to the server
+ */
+ connect: function () {
}
};
- mw.libs.foo = foo;
+ mw.boilerPlate.Foo = Foo;
-}( mediaWiki, jQuery ) );
+}() );
diff --git a/BoilerPlate/modules/ext.BoilerPlate.js
b/BoilerPlate/modules/ext.BoilerPlate.js
new file mode 100644
index 0000000..40bc4a0
--- /dev/null
+++ b/BoilerPlate/modules/ext.BoilerPlate.js
@@ -0,0 +1,10 @@
+( function () {
+
+ /**
+ * @class mw.boilerPlate
+ * @singleton
+ */
+ mw.boilerPlate = {
+ };
+
+}() );
diff --git a/BoilerPlate/package.json b/BoilerPlate/package.json
new file mode 100644
index 0000000..d8df90e
--- /dev/null
+++ b/BoilerPlate/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "boilerplate",
+ "version": "0.0.0",
+ "scripts": {
+ "test": "grunt test"
+ },
+ "devDependencies": {
+ "grunt": "0.4.5",
+ "grunt-banana-checker": "0.2.0",
+ "grunt-contrib-jshint": "0.10.0",
+ "grunt-jscs": "1.2.0"
+ }
+}
diff --git a/BoilerPlate/specials/SpecialHelloWorld.php
b/BoilerPlate/specials/SpecialHelloWorld.php
index 8fc8f35..f8aee85 100644
--- a/BoilerPlate/specials/SpecialHelloWorld.php
+++ b/BoilerPlate/specials/SpecialHelloWorld.php
@@ -12,8 +12,9 @@
}
/**
- * Shows the page to the user.
- * @param string $sub: The subpage string argument (if any).
+ * Show the page to the user
+ *
+ * @param string $sub The subpage string argument (if any).
* [[Special:HelloWorld/subpage]].
*/
public function execute( $sub ) {
diff --git a/Example/.jshintrc b/Example/.jshintrc
index 4cd914b..2ff5525 100644
--- a/Example/.jshintrc
+++ b/Example/.jshintrc
@@ -1,8 +1,20 @@
{
- "predef": [
- "mediaWiki",
- "jQuery"
- ],
+ // Enforcing
+ "bitwise": true,
+ "eqeqeq": true,
+ "es3": true,
+ "latedef": true,
+ "noarg": true,
+ "nonew": true,
+ "undef": true,
+ "unused": true,
+ "strict": false,
+
+ // Environment
"browser": true,
- "smarttabs": true
+
+ "globals": {
+ "mediaWiki": false,
+ "jQuery": false
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/200226
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I71e0c874994cbc7627e1996ce5d2b3e0b2664cc0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/examples
Gerrit-Branch: master
Gerrit-Owner: Spage <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits