From bf1d37761e737ce049218e7604408359aaa27263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=BCsken?= Date: Tue, 11 Jun 2024 09:47:48 +0200 Subject: [PATCH] Add grunt task for crating zip plugin package --- .gitignore | 4 +++ Gruntfile.js | 82 ++++++++++++++++++++++++++++++++-------------------- package.json | 3 ++ 3 files changed, 57 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 2c7bcda..41025ce 100755 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,7 @@ vendor # PHP Unit .phpunit.result.cache + +#other files +languages/multisite-enhancements.pot +multisite-enhancements.zip diff --git a/Gruntfile.js b/Gruntfile.js index b01c730..236a568 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -14,6 +14,10 @@ module.exports = function( grunt ) { scripts: { src: 'assets/js/', dest: 'assets/js/' + }, + resources: { + src: 'resources/', + dest: 'resources/' } }, @@ -27,17 +31,11 @@ module.exports = function( grunt ) { options: { optimizationLevel: 7 }, - assets: { - expand: true, - cwd: '<%= config.w-org-assets.src %>', - src: [ '*.{gif,jpeg,jpg,png}' ], - dest: '<%= config.w-org-assets.dest %>' - }, - images: { + resources: { expand: true, - cwd: '<%= config.images.src %>', + cwd: '<%= config.resources.src %>', src: [ '**/*.{gif,jpeg,jpg,png}' ], - dest: '<%= config.images.dest %>' + dest: '<%= config.resources.dest %>' } }, @@ -127,19 +125,8 @@ module.exports = function( grunt ) { options: { include: [ 'multisite-enhancements.php', - 'src/class-add-admin-favicon.php', - 'src/class-add-blog-id.php', - 'src/class-add-css.php', - 'src/class-add-plugin-list.php', - 'scr/class-add-site-status-labels.php', - 'src/class-add-ssl-identifier.php', - 'src/class-add-theme-list.php', - 'src/class-admin-bar-tweaks.php', - 'src/class-change-footer-text.php', - 'src/class-filtering-themes.php', - 'src/class-multisite-add-new-plugin.php', - 'src/settings.php' - + 'uninstall.php', + 'src/.*' ], type: 'wp-plugin' } @@ -154,9 +141,9 @@ module.exports = function( grunt ) { }, assets: { - files: [ '<%= config.w-org-assets.src %>*.{gif,jpeg,jpg,png}' ], + files: [ '<%= config.resources.src %>*.{gif,jpeg,jpg,png}' ], tasks: [ - 'newer:imagemin:w-org-assets' + 'newer:imagemin:resources' ] }, @@ -176,13 +163,6 @@ module.exports = function( grunt ) { ] }, - images: { - files: [ '<%= config.images.src %>**/*.{gif,jpeg,jpg,png}' ], - tasks: [ - 'newer:imagemin:images' - ] - }, - json: { files: [ '*.json' ], tasks: [ @@ -202,7 +182,39 @@ module.exports = function( grunt ) { 'jsvalidate:dest' ] } + }, + compress: { + zip: { + options: { + archive: 'multisite-enhancements.zip' + }, + files: [ + { src: [ 'multisite-enhancements.php' ], dest: '/multisite-enhancements/', filter: 'isFile' }, + { src: [ 'readme.txt' ], dest: '/multisite-enhancements/', filter: 'isFile' }, + { src: [ 'LICENSE' ], dest: '/multisite-enhancements/', filter: 'isFile' }, + { src: [ 'src/**' ], dest: '/multisite-enhancements/' }, + { src: [ 'assets/**' ], dest: '/multisite-enhancements/' }, + { src: [ 'vendor/**' ], dest: '/multisite-enhancements/' } + ] + } + }, + + run: { + composer_no_dev: { + cmd: 'composer', + args: [ + 'install', + '--prefer-dist', + '--no-dev' + ] + }, + composer_with_dev: { + cmd: 'composer', + args: [ + 'install' + ] + } } }; @@ -261,7 +273,6 @@ module.exports = function( grunt ) { 'assets', 'configs', 'grunt', - 'images', 'json', 'scripts' ] ); @@ -277,6 +288,13 @@ module.exports = function( grunt ) { 'makepot' ] ); + grunt.registerTask( 'package', [ + 'precommit', + 'run:composer_no_dev', + 'compress:zip', + 'run:composer_with_dev' + ] ); + // Delegation task for grunt-newer to check files different from the individual task's files. grunt.registerTask( 'delegate', function() { grunt.task.run( this.args.join( ':' ) ); diff --git a/package.json b/package.json index affff0a..04b3370 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,8 @@ }, "devDependencies": { "grunt": ">=1.6.1", + "grunt-cli": "^1.4.3", + "grunt-contrib-compress": "^2.0.0", "grunt-contrib-concat": "~0.5.1", "grunt-contrib-imagemin": "^4.0.0", "grunt-contrib-jshint": "^3.0.0", @@ -26,6 +28,7 @@ "grunt-jsvalidate": "~0.2.2", "grunt-lineending": "~1.0.0", "grunt-newer": "~1.1.1", + "grunt-run": "^0.8.1", "grunt-wp-i18n": "^1.0.3", "jshint-stylish": "~2.1.0", "load-grunt-tasks": "~3.3.0",