Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update npm and composer packages #195

Merged
merged 4 commits into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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