-
Notifications
You must be signed in to change notification settings - Fork 17
/
Gruntfile.js
108 lines (97 loc) · 2.3 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* eslint-env node */
module.exports = function ( grunt ) {
'use strict';
// prettier-ignore
grunt.initConfig( {
// Build a deploy-able plugin.
copy: {
build: {
src: [
'**',
'!.*',
'!.*/**',
'!.DS_Store',
'!assets/css/src/**',
'!assets/js/.gitignore',
'!assets/src/**',
'!bin/**',
'!build/**',
'!built/**',
'!code_of_conduct.md',
'!contributing/**',
'!composer.json',
'!composer.lock',
'!contributing.md',
'!docker-compose.yml',
'!foo-bar.zip',
'!Gruntfile.js',
'!init-plugin.sh',
'!jest.config.js',
'!node_modules/**',
'!npm-debug.log',
'!package.json',
'!package-lock.json',
'!postcss.config.js',
'!phpcs.xml',
'!phpunit.xml',
'!readme.md',
'!renovate.json',
'!tests/**',
'!vendor/**',
'!webpack.config.js',
'!wp-assets/**',
],
dest: 'build',
expand: true,
dot: true,
},
},
// Clean up the build.
clean: {
compiled: {
src: [
'assets/js/*.js',
'!assets/js/admin.js',
'assets/js/*.asset.php',
],
},
build: {
src: [ 'build' ],
},
},
// Shell actions.
shell: {
options: {
stdout: true,
stderr: true,
},
readme: {
command: './vendor/xwp/wp-dev-lib/scripts/generate-markdown-readme', // Generate the readme.md.
},
create_build_zip: {
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e foo-bar.zip ]; then rm foo-bar.zip; fi; cd build; zip -r ../foo-bar.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/foo-bar.zip"',
},
},
// Deploys a git Repo to the WordPress SVN repo.
wp_deploy: {
deploy: {
options: {
plugin_slug: 'foo-bar',
build_dir: 'build',
assets_dir: 'wp-assets',
},
},
},
} );
// Load tasks.
grunt.loadNpmTasks( 'grunt-contrib-clean' );
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks( 'grunt-shell' );
grunt.loadNpmTasks( 'grunt-wp-deploy' );
// Register tasks.
grunt.registerTask( 'default', [ 'build' ] );
grunt.registerTask( 'readme', [ 'shell:readme' ] );
grunt.registerTask( 'build', [ 'readme', 'copy' ] );
grunt.registerTask( 'create-build-zip', [ 'shell:create_build_zip' ] );
grunt.registerTask( 'deploy', [ 'build', 'wp_deploy', 'clean' ] );
};