forked from bonny/WordPress-Simple-History
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
162 lines (146 loc) Β· 4.1 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
module.exports = function (grunt) {
require("time-grunt")(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.makepot = {
target: {
options: {
cwd: "", // Directory of files to internationalize.
domainPath: "languages/", // Where to save the POT file.
exclude: [], // List of files or directories to ignore.
include: [], // List of files or directories to include.
i18nToolsPath: "node_modules/grunt-wp-i18n/vendor/wp-i18n-tools", // Path to the i18n tools directory.
mainFile: "", // Main project file.
potComments: "", // The copyright at the beginning of the POT file.
potFilename: "", // Name of the POT file.
potHeaders: {
poedit: true, // Includes common Poedit headers.
"x-poedit-keywordslist": true, // Include a list of all possible gettext functions.
}, // Headers to add to the generated POT file.
processPot: null, // A callback function for manipulating the POT file.
type: "wp-plugin", // Type of project (wp-plugin or wp-theme).
updateTimestamp: true, // Whether the POT-Creation-Date should be updated without other changes.
},
},
};
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("makepot", "Make .POT-files for languages/translation.", [
"makepot",
]);
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]);
}
);
};