Skip to content

Commit

Permalink
Merge pull request #195 from xwp/update/config-packages
Browse files Browse the repository at this point in the history
Update npm and composer packages
  • Loading branch information
westonruter authored Jul 16, 2019
2 parents 16397ba + 17f5c4a commit 092902c
Show file tree
Hide file tree
Showing 15 changed files with 1,045 additions and 308 deletions.
8 changes: 4 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"root": true,
"extends": [
"wordpress",
"eslint:recommended"
],
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ],
"env": {
"browser": true,
"es6": true
},
"globals": {
"wp": true
},
"parserOptions": {
"ecmaVersion": 2018
}
Expand Down
66 changes: 32 additions & 34 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ module.exports = function( grunt ) {
// Clean up the build.
clean: {
build: {
src: [ 'build' ]
}
src: [ 'build' ],
},
},

// Shell actions.
shell: {
options: {
stdout: true,
stderr: true
stderr: true,
},
readme: {
command: 'npm run generate-readme' // Generate the readme.md.
command: 'npm run generate-readme', // Generate the readme.md.
},
phpunit: {
command: 'phpunit'
command: 'phpunit',
},
verify_matching_versions: {
command: 'php bin/verify-version-consistency.php'
command: 'php bin/verify-version-consistency.php',
},
install_workbox: {
command: 'if [ -e wp-includes/js/workbox* ]; then rm -r wp-includes/js/workbox*; fi; npx workbox copyLibraries wp-includes/js/ && mv wp-includes/js/workbox-v* wp-includes/js/workbox'
command: 'if [ -e wp-includes/js/workbox* ]; then rm -r wp-includes/js/workbox*; fi; npx workbox copyLibraries wp-includes/js/ && mv wp-includes/js/workbox-v* wp-includes/js/workbox',
},
create_build_zip: {
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e pwa.zip ]; then rm pwa.zip; fi; cd build; zip -r ../pwa.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/pwa.zip"'
}
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e pwa.zip ]; then rm pwa.zip; fi; cd build; zip -r ../pwa.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/pwa.zip"',
},
},

// Deploys a git Repo to the WordPress SVN repo.
Expand All @@ -45,10 +45,10 @@ module.exports = function( grunt ) {
options: {
plugin_slug: 'pwa',
build_dir: 'build',
assets_dir: 'wp-assets'
}
}
}
assets_dir: 'wp-assets',
},
},
},

} );

Expand All @@ -60,39 +60,37 @@ module.exports = function( grunt ) {

// Register tasks.
grunt.registerTask( 'default', [
'build'
'build',
] );

grunt.registerTask( 'readme', [
'shell:readme'
'shell:readme',
] );

grunt.registerTask( 'build', function() {
var done, spawnQueue, stdout;
done = this.async();
spawnQueue = [];
stdout = [];
const done = this.async();
const spawnQueue = [];
const stdout = [];

grunt.task.run( 'shell:install_workbox' );

spawnQueue.push(
{
cmd: 'git',
args: [ '--no-pager', 'log', '-1', '--format=%h', '--date=short' ]
args: [ '--no-pager', 'log', '-1', '--format=%h', '--date=short' ],
},
{
cmd: 'git',
args: [ 'ls-files' ]
args: [ 'ls-files' ],
}
);

function finalize() {
var commitHash, lsOutput, versionAppend, paths;
commitHash = stdout.shift();
lsOutput = stdout.shift();
versionAppend = commitHash + '-' + new Date().toISOString().replace( /\.\d+/, '' ).replace( /-|:/g, '' );
const commitHash = stdout.shift();
const lsOutput = stdout.shift();
const versionAppend = commitHash + '-' + new Date().toISOString().replace( /\.\d+/, '' ).replace( /-|:/g, '' );

paths = lsOutput.trim().split( /\n/ ).filter( function( file ) {
const paths = lsOutput.trim().split( /\n/ ).filter( function( file ) {
return ! /^(\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|readme\.md|composer\..*|webpack.*)/.test( file );
} );
paths.push( 'wp-includes/js/workbox/*' );
Expand All @@ -105,8 +103,8 @@ module.exports = function( grunt ) {
expand: true,
options: {
noProcess: [ '*/**', 'LICENSE' ], // That is, only process pwa.php and readme.txt.
process: function( content, srcpath ) {
var matches, version, versionRegex;
process( content, srcpath ) {
let matches, version, versionRegex;
if ( /pwa\.php$/.test( srcpath ) ) {
versionRegex = /(\*\s+Version:\s+)(\d+(\.\d+)+-\w+)/;

Expand All @@ -120,9 +118,9 @@ module.exports = function( grunt ) {
}
}
return content;
}
}
}
},
},
},
} );
grunt.task.run( 'readme' );
grunt.task.run( 'copy' );
Expand All @@ -131,7 +129,7 @@ module.exports = function( grunt ) {
}

function doNext() {
var nextSpawnArgs = spawnQueue.shift();
const nextSpawnArgs = spawnQueue.shift();
if ( ! nextSpawnArgs ) {
finalize();
} else {
Expand All @@ -152,13 +150,13 @@ module.exports = function( grunt ) {
} );

grunt.registerTask( 'create-build-zip', [
'shell:create_build_zip'
'shell:create_build_zip',
] );

grunt.registerTask( 'deploy', [
'shell:verify_matching_versions',
'shell:phpunit',
'build',
'wp_deploy'
'wp_deploy',
] );
};
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"php": "^5.6.0 || ^7.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
"phpcompatibility/phpcompatibility-wp": "^1",
"wp-coding-standards/wpcs": "^1",
"xwp/wp-dev-lib": "1.1.1"
"dealerdirect/phpcodesniffer-composer-installer": "0.5.0",
"phpcompatibility/phpcompatibility-wp": "2.0.0",
"wp-coding-standards/wpcs": "2.1.1",
"xwp/wp-dev-lib": "1.2.2"
}
}
Loading

0 comments on commit 092902c

Please # to comment.