-
-
Notifications
You must be signed in to change notification settings - Fork 69
/
gruntfile.js
135 lines (121 loc) Β· 3.28 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
module.exports = function (grunt) {
// Require all grunt-tasks instead of manually initialize them.
require("load-grunt-tasks")(grunt);
var pkg = grunt.file.readJSON("package.json");
var gig = require("gitignore-globs");
var gag = require("gitattributes-globs");
var ignored_gitignore = gig(".gitignore", { negate: true }).map(function (
value
) {
return value.replace(/^!\//, "!");
});
var ignored_gitattributes = gag(".gitattributes", { negate: true }).map(
function (value) {
return value.replace(/^!\//, "!");
}
);
let config = {};
config.pkg = pkg;
config.version = {
main: {
options: {
prefix: "Version:[\\s]+",
},
src: ["index.php"],
},
main2: {
options: {
prefix: "'SIMPLE_HISTORY_VERSION', '",
},
src: ["index.php"],
},
readme: {
options: {
prefix: "Stable tag:[\\s]+",
},
src: ["readme.txt"],
},
pkg: {
src: ["package.json"],
},
};
config.wp_deploy = {
deploy: {
options: {
deploy_trunk: true,
deploy_tag: true,
plugin_slug: "<%= pkg.name %>",
plugin_main_file: "index.php",
build_dir: "build",
assets_dir: "assets-wp-repo",
svn_user: "eskapism",
},
},
// Deploy without tagging the release, useful when only changes to the readme,
// for example when changing the "Tested up to" value.
deploy_without_tag: {
options: {
deploy_trunk: true,
deploy_tag: false,
plugin_slug: "<%= pkg.name %>",
plugin_main_file: "index.php",
build_dir: "build",
assets_dir: "assets-wp-repo",
svn_user: "eskapism",
},
},
assets: {
options: {
deploy_trunk: false,
deploy_tag: false,
plugin_slug: "<%= pkg.name %>",
plugin_main_file: "<%= wp_deploy.deploy.options.plugin_main_file %>",
build_dir: "<%= wp_deploy.deploy.options.build_dir %>",
assets_dir: "<%= wp_deploy.deploy.options.assets_dir %>",
svn_user: "<%= wp_deploy.deploy.options.svn_user %>",
},
},
};
config.clean = {
main: ["<%= wp_deploy.deploy.options.build_dir %>"],
};
config.copy = {
main: {
src: [
"**",
"!.*",
"!.git/**",
"!<%= wp_deploy.deploy.options.assets_dir %>/**",
"!<%= wp_deploy.deploy.options.build_dir %>/**",
"!README.md",
ignored_gitignore,
ignored_gitattributes,
],
dest: "<%= wp_deploy.deploy.options.build_dir %>/",
},
};
grunt.initConfig(config);
// Task(s) to run. Default is default.
grunt.registerTask("build", "Clean and copy", ["clean", "copy"]);
grunt.registerTask("deploy", "Deploy plugin to WordPress plugin repository", [
"build",
"wp_deploy:deploy",
]);
grunt.registerTask(
"deploy:assets",
"Deploy plugin asssets to WordPress plugin repository",
["build", "wp_deploy:assets"]
);
grunt.registerTask(
"bump",
"Bump version in major, minor, patch or custom steps.",
function (version) {
if (!version) {
grunt.fail.fatal(
"No version specified. Usage: bump:major, bump:minor, bump:patch, bump:x.y.z"
);
}
grunt.task.run(["version::" + version]);
}
);
};