-
Notifications
You must be signed in to change notification settings - Fork 894
/
Gruntfile.js
150 lines (142 loc) · 4.45 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
// eslint-disable-next-line import/no-extraneous-dependencies
const timeGrunt = require( "time-grunt" );
const path = require( "path" );
// eslint-disable-next-line import/no-extraneous-dependencies
const loadGruntConfig = require( "load-grunt-config" );
const { flattenVersionForFile } = require( "./config/webpack/paths" );
require( "dotenv" ).config();
module.exports = function( grunt ) {
timeGrunt( grunt );
const pkg = grunt.file.readJSON( "package.json" );
const pluginVersion = pkg.yoast.pluginVersion;
/* Used to switch between development and release builds.
Switches based on the grunt command (which is the third 'argv', after node and grunt, so index 2).*/
const developmentBuild = ! [ "create-rc", "release", "release:js", "artifact", "deploy:trunk", "deploy:master" ].includes( process.argv[ 2 ] );
// Define project configuration.
const project = {
developmentBuild,
pluginVersion,
pluginVersionSlug: flattenVersionForFile( pluginVersion ),
pluginSlug: "wordpress-seo",
pluginMainFile: "wp-seo.php",
paths: {
/**
* Gets the config path.
*
* @returns {string} Config path.
*/
get config() {
return this.grunt + "task-config/";
},
css: "css/dist/",
grunt: "config/grunt/",
images: "images/",
js: "packages/js/src/",
jsDist: "js/dist/",
logs: "logs/",
svnCheckoutDir: ".wordpress-svn",
assets: "svn-assets",
vendor: "vendor/",
vendorPrefixed: "vendor_prefixed/",
},
files: {
css: [
"css/src/*.css",
],
cssMap: [
"css/dist/*.css.map",
],
js: [
"packages/js/src/**/*.js",
],
jsTests: [
"packages/js/tests/**/*.js",
],
php: [
"*.php",
"admin/**/*.php",
"frontend/**/*.php",
"inc/**/*.php",
"src/**/*.php",
"config/**/*.php",
],
versionFiles: [
"package.json",
"wp-seo-main.php",
"wp-seo.php",
],
pot: {
/*
* Yoast JS are the @yoast JavaScript packages.
* They (currently) have the `yoast-components` textdomain.
* They get combined with the `yoastComponents` translations to one yoast-components.pot file.
*/
yoastJsAnalysisReport: "<%= paths.languages %>yoast-js-analysis-report.pot",
yoastJsComponents: "<%= paths.languages %>yoast-js-components.pot",
yoastJsHelpers: "<%= paths.languages %>yoast-js-helpers.pot",
yoastJsSearchMetadataPreviews: "<%= paths.languages %>yoast-js-search-metadata-previews.pot",
yoastJsSocialMetadataForms: "<%= paths.languages %>yoast-js-social-metadata-forms.pot",
yoastJsReplacementVariableEditor: "<%= paths.languages %>yoast-js-replacement-variable-editor.pot",
yoastseojs: "<%= paths.languages %>yoast-seo-js.pot",
yoastComponents: "<%= paths.languages %>yoast-components.pot",
yoastComponentsRemaining: "gettext.pot",
wordpressSeoJs: "<%= paths.languages %>wordpress-seojs.pot",
php: {
yoastseojs: "<%= paths.languages %>yoast-seo-js.php",
yoastComponents: "<%= paths.languages %>yoast-components.php",
wordpressSeoJs: "<%= paths.languages %>wordpress-seojs.php",
},
},
artifact: "artifact",
artifactComposer: "artifact-composer",
phptests: "tests/**/*.php",
/**
* Gets the config path glob.
*
* @returns {string} Config path glob.
*/
get config() {
return project.paths.config + "*.js";
},
/**
* Gets the changelog path file.
*
* @returns {string} Changelog path file.
*/
get changelog() {
return project.paths.theme + "changelog.txt";
},
grunt: "Gruntfile.js",
},
pkg,
};
// Load Grunt configurations and tasks.
loadGruntConfig( grunt, {
configPath: path.join( process.cwd(), "node_modules/@yoast/grunt-plugin-tasks/config/" ),
overridePath: path.join( process.cwd(), project.paths.config ),
data: project,
jitGrunt: {
staticMappings: {
addtextdomain: "grunt-wp-i18n",
makepot: "grunt-wp-i18n",
/* eslint-disable-next-line camelcase */
glotpress_download: "grunt-glotpress",
gittag: "grunt-git",
gitfetch: "grunt-git",
gitadd: "grunt-git",
gitstatus: "grunt-git",
gitcommit: "grunt-git",
gitcheckout: "grunt-git",
gitpull: "grunt-git",
gitpush: "grunt-git",
postcss: "@lodder/grunt-postcss",
"update-version": "@yoast/grunt-plugin-tasks",
"set-version": "@yoast/grunt-plugin-tasks",
"update-changelog-to-latest": "@yoast/grunt-plugin-tasks",
"register-prompt": "grunt-prompt",
"notify-slack": "notify-slack",
},
customTasksDir: "config/grunt/custom-tasks",
},
} );
};