Skip to content

Commit 3ad270c

Browse files
Merge pull request #130 from fjarrett/improved-readme
Improve readme and grunt tasks
2 parents eaffdbc + 2a58d66 commit 3ad270c

8 files changed

Lines changed: 456 additions & 72 deletions

File tree

.distignore

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
# A set of files you probably don't want in your WordPress.org distribution
2-
.distignore
3-
.editorconfig
4-
.git
5-
.gitignore
6-
.travis.yml
7-
.DS_Store
8-
Thumbs.db
9-
bin
10-
behat.yml
11-
circle.yml
2+
.*
3+
*.xml
4+
*.yml
125
Gruntfile.js
136
package.json
14-
phpunit.xml
15-
multisite.xml
167
phpunit.xml.dist
17-
phpcs.ruleset.xml
18-
README.md
19-
wp-cli.local.yml
20-
tests
21-
/vendor/lcache/lcache/tests
22-
node_modules
8+
readme.md
9+
Thumbs.db
10+
bin/
11+
node_modules/
12+
tests/
13+
vendor/lcache/lcache/tests/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.zip
22
.DS_Store
3+
Thumbs.db
34
node_modules/
45
vendor/
56
pantheon-wordpress-upstream-master

Gruntfile.js

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,69 @@
1+
/* global module, require */
2+
13
module.exports = function( grunt ) {
24

35
'use strict';
4-
// Project configuration
6+
7+
var pkg = grunt.file.readJSON( 'package.json' );
8+
59
grunt.initConfig( {
610

7-
pkg: grunt.file.readJSON( 'package.json' ),
11+
pkg: pkg,
812

9-
wp_readme_to_markdown: {
10-
options: {
11-
screenshot_url: 'https://s.w.org/plugins/{plugin}/{screenshot}.png',
12-
},
13-
your_target: {
14-
files: {
15-
'README.md': 'readme.txt'
13+
devUpdate: {
14+
check: {},
15+
update: {
16+
options: {
17+
updateType: 'force'
1618
}
17-
},
19+
}
1820
},
1921

2022
phpcs: {
21-
plugin: {
22-
src: './'
23-
},
2423
options: {
25-
bin: "vendor/bin/phpcs --extensions=php --ignore=\"*/vendor/*,*/lib/*,*/node_modules/*\"",
26-
standard: "phpcs.ruleset.xml"
24+
bin: 'vendor/bin/phpcs --extensions=php --ignore="*/vendor/*,*/lib/*,*/node_modules/*"',
25+
standard: 'phpcs.ruleset.xml'
26+
},
27+
main: {
28+
src: '*.php'
2729
}
2830
},
2931

32+
wp_readme_to_markdown: {
33+
options: {
34+
post_convert: function( readme ) {
35+
var matches = readme.match( /\*\*Tags:\*\*(.*)\r?\n/ ),
36+
tags = matches[1].trim().split( ', ' ),
37+
section = matches[0];
38+
39+
for ( var i = 0; i < tags.length; i++ ) {
40+
section = section.replace( tags[i], '[' + tags[i] + '](https://wordpress.org/plugins/tags/' + tags[i] + '/)' );
41+
}
42+
43+
// Tag links
44+
readme = readme.replace( matches[0], section );
45+
46+
// Badges
47+
readme = readme.replace( '## Description ##', grunt.template.process( pkg.badges.join( ' ' ) ) + " \r\n\r\n## Description ##" );
48+
49+
return readme;
50+
},
51+
screenshot_url: 'https://ps.w.org/{plugin}/assets/{screenshot}.png'
52+
},
53+
main: {
54+
files: {
55+
'readme.md': 'readme.txt'
56+
}
57+
}
58+
}
59+
3060
} );
3161

32-
grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' );
33-
grunt.loadNpmTasks( 'grunt-phpcs' );
34-
grunt.registerTask( 'readme', ['wp_readme_to_markdown']);
62+
require( 'matchdep' ).filterDev( 'grunt-*' ).forEach( grunt.loadNpmTasks );
63+
64+
grunt.registerTask( 'dev-check', [ 'devUpdate:check' ] );
65+
grunt.registerTask( 'dev-update', [ 'devUpdate:update' ] );
66+
grunt.registerTask( 'readme', [ 'wp_readme_to_markdown' ] );
3567

3668
grunt.util.linefeed = '\n';
3769

0 commit comments

Comments
 (0)