Skip to content

Commit

Permalink
Merge pull request #79 from bueltge/package-creation
Browse files Browse the repository at this point in the history
Add grunt task for crating zip plugin package
  • Loading branch information
bueltge authored Jun 11, 2024
2 parents d51569e + bf1d377 commit b7c4cf9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 32 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ vendor

# PHP Unit
.phpunit.result.cache

#other files
languages/multisite-enhancements.pot
multisite-enhancements.zip
82 changes: 50 additions & 32 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ module.exports = function( grunt ) {
scripts: {
src: 'assets/js/',
dest: 'assets/js/'
},
resources: {
src: 'resources/',
dest: 'resources/'
}
},

Expand All @@ -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 %>'
}
},

Expand Down Expand Up @@ -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'
}
Expand All @@ -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'
]
},

Expand All @@ -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: [
Expand All @@ -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'
]
}
}
};

Expand Down Expand Up @@ -261,7 +273,6 @@ module.exports = function( grunt ) {
'assets',
'configs',
'grunt',
'images',
'json',
'scripts'
] );
Expand All @@ -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( ':' ) );
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit b7c4cf9

Please sign in to comment.