Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update readme for wiki; add Grunt for building and deploying
* Update phpunit coverage whitelist to include all files rather than limit to one * Fix coverage warnings * Remove tests directory from PHPCS exclusion. * Add global doc and fix phpcs in WPCOM_AMP_Polldaddy_Embed * Move contents of readme to wiki; sync readme.md with readme.txt * Remove readme-assets which have been moved to the wiki repo * Remove readme sections now in wiki; add Grunt for building and deploying * Add verify_matching_versions command from better-code-editing feature plugin * Add verify_matching_versions and phpunit as dependencies of deploy command. * Fix paths for jshint. * Add version to composer.json. * Update contributors * Add create-release-zip task as part of grunt build * Updated all version instances to 0.6 * Completed 0.6 changelog * Build 0.6-beta release
- Loading branch information
1 parent
78c60fa
commit d5362a7
Showing
33 changed files
with
2,568 additions
and
754 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
.DS_Store | ||
vendor | ||
build | ||
node_modules | ||
wiki | ||
amp.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* eslint-env node */ | ||
/* jshint node:true */ | ||
|
||
module.exports = function( grunt ) { | ||
'use strict'; | ||
|
||
grunt.initConfig( { | ||
|
||
pkg: grunt.file.readJSON( 'package.json' ), | ||
|
||
// JavaScript linting with JSHint. | ||
jshint: { | ||
options: { | ||
jshintrc: '.jshintrc' | ||
}, | ||
all: [ | ||
'Gruntfile.js', | ||
'assets/**/*.js' | ||
] | ||
}, | ||
|
||
// Clean up the build. | ||
clean: { | ||
build: { | ||
src: [ 'build' ] | ||
} | ||
}, | ||
|
||
// Shell actions. | ||
shell: { | ||
options: { | ||
stdout: true, | ||
stderr: true | ||
}, | ||
readme: { | ||
command: './dev-lib/generate-markdown-readme' // Generate the readme.md. | ||
}, | ||
phpunit: { | ||
command: 'phpunit' | ||
}, | ||
verify_matching_versions: { | ||
command: 'php bin/verify-version-consistency.php' | ||
}, | ||
create_release_zip: { | ||
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e amp.zip ]; then rm amp.zip; fi; cd build; zip -r ../amp.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/amp.zip"' | ||
} | ||
}, | ||
|
||
// Deploys a git Repo to the WordPress SVN repo. | ||
wp_deploy: { | ||
deploy: { | ||
options: { | ||
plugin_slug: 'amp', | ||
build_dir: 'build', | ||
assets_dir: 'wp-assets' | ||
} | ||
} | ||
} | ||
|
||
} ); | ||
|
||
// Load tasks. | ||
grunt.loadNpmTasks( 'grunt-contrib-clean' ); | ||
grunt.loadNpmTasks( 'grunt-contrib-copy' ); | ||
grunt.loadNpmTasks( 'grunt-contrib-jshint' ); | ||
grunt.loadNpmTasks( 'grunt-shell' ); | ||
grunt.loadNpmTasks( 'grunt-wp-deploy' ); | ||
|
||
// Register tasks. | ||
grunt.registerTask( 'default', [ | ||
'build' | ||
] ); | ||
|
||
grunt.registerTask( 'readme', [ | ||
'shell:readme' | ||
] ); | ||
|
||
grunt.registerTask( 'build', function() { | ||
var done = this.async(); | ||
|
||
grunt.util.spawn( | ||
{ | ||
cmd: 'git', | ||
args: [ 'ls-files' ] | ||
}, | ||
function( err, res ) { | ||
if ( err ) { | ||
throw new Error( err.message ); | ||
} | ||
|
||
grunt.config.set( 'copy', { | ||
build: { | ||
src: res.stdout.trim().split( /\n/ ).filter( function( file ) { | ||
return ! /^(\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|dev-lib|readme\.md)/.test( file ); | ||
} ), | ||
dest: 'build', | ||
expand: true | ||
} | ||
} ); | ||
grunt.task.run( 'readme' ); | ||
grunt.task.run( 'copy' ); | ||
grunt.task.run( 'shell:create_release_zip' ); | ||
done(); | ||
} | ||
); | ||
} ); | ||
|
||
grunt.registerTask( 'create-release-zip', [ | ||
'build', | ||
'shell:create_release_zip' | ||
] ); | ||
|
||
grunt.registerTask( 'deploy', [ | ||
'build', | ||
'jshint', | ||
'shell:phpunit', | ||
'shell:verify_matching_versions', | ||
'wp_deploy', | ||
'clean' | ||
] ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/** | ||
* Create embed test post. | ||
* | ||
* @codeCoverageIgnore | ||
* @package AMP | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env | ||
<?php | ||
/** | ||
* Verify versions referenced in plugin match. | ||
* | ||
* @codeCoverageIgnore | ||
* @package AMP | ||
*/ | ||
|
||
if ( 'cli' !== php_sapi_name() ) { | ||
fwrite( STDERR, "Must run from CLI.\n" ); | ||
exit( 1 ); | ||
} | ||
|
||
$versions = array(); | ||
|
||
$versions['package.json'] = json_decode( file_get_contents( dirname( __FILE__ ) . '/../package.json' ) )->version; | ||
$versions['package-lock.json'] = json_decode( file_get_contents( dirname( __FILE__ ) . '/../package-lock.json' ) )->version; | ||
$versions['composer.json'] = json_decode( file_get_contents( dirname( __FILE__ ) . '/../composer.json' ) )->version; | ||
|
||
$readme_txt = file_get_contents( dirname( __FILE__ ) . '/../readme.txt' ); | ||
if ( ! preg_match( '/Stable tag:\s+(?P<version>\S+)/i', $readme_txt, $matches ) ) { | ||
echo "Could not find stable tag in readme\n"; | ||
exit( 1 ); | ||
} | ||
$versions['readme.txt#stable-tag'] = $matches['version']; | ||
|
||
if ( ! preg_match( '/== Changelog ==\s+=\s+(?P<version>\d+\.\d+(?:.\d+)?)/', $readme_txt, $matches ) ) { | ||
echo "Could not find version i n readme.txt changelog\n"; | ||
exit( 1 ); | ||
} | ||
$versions['readme.txt#changelog'] = $matches['version']; | ||
|
||
$readme_md = file_get_contents( dirname( __FILE__ ) . '/../readme.md' ); | ||
if ( ! preg_match( '/## Changelog ##\s+###\s+(?P<version>\d+\.\d+(?:.\d+)?)/', $readme_md, $matches ) ) { | ||
echo "Could not find version in readme.md changelog\n"; | ||
exit( 1 ); | ||
} | ||
$versions['readme.md#changelog'] = $matches['version']; | ||
|
||
$plugin_file = file_get_contents( dirname( __FILE__ ) . '/../amp.php' ); | ||
if ( ! preg_match( '/\*\s*Version:\s*(?P<version>\d+\.\d+(?:.\d+)?)/', $plugin_file, $matches ) ) { | ||
echo "Could not find version in readme metadata\n"; | ||
exit( 1 ); | ||
} | ||
$versions['amp.php#metadata'] = $matches['version']; | ||
|
||
if ( ! preg_match( '/define\( \'AMP__VERSION\', \'(?P<version>[^\\\']+)\'/', $plugin_file, $matches ) ) { | ||
echo "Could not find version in AMP__VERSION constant\n"; | ||
exit( 1 ); | ||
} | ||
$versions['AMP__VERSION'] = $matches['version']; | ||
|
||
fwrite( STDERR, "Version references:\n" ); | ||
|
||
echo json_encode( $versions, JSON_PRETTY_PRINT ) . "\n"; | ||
|
||
if ( 1 !== count( array_unique( $versions ) ) ) { | ||
fwrite( STDERR, "Error: Not all version references have been updated.\n" ); | ||
exit( 1 ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.