wp-blank-scripts 3.0.0-beta.0 → 3.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -290,21 +290,13 @@ exports.copyFiles = (paths) => {
|
|
|
290
290
|
},
|
|
291
291
|
{
|
|
292
292
|
// Copy files inside a directory the the theme
|
|
293
|
-
from: path.join(sourceDir, 'new-directory'
|
|
293
|
+
from: path.join(sourceDir, 'new-directory'),
|
|
294
294
|
to: themePath,
|
|
295
|
-
transformPath(targetPath) {
|
|
296
|
-
// Need to fix the path
|
|
297
|
-
return targetPath.replace(path.join(sourceDir, 'new-directory'), '');
|
|
298
|
-
},
|
|
299
295
|
},
|
|
300
296
|
{
|
|
301
297
|
// Copy file from a directory to the root directory
|
|
302
298
|
from: path.join(sourceDir, 'directory-file-was-in', 'file.txt'),
|
|
303
299
|
to: '',
|
|
304
|
-
transformPath(targetPath) {
|
|
305
|
-
// Need to fix the path again, otherwise it will stay in the directory
|
|
306
|
-
return targetPath.replace('directory-file-was-in', '');
|
|
307
|
-
},
|
|
308
300
|
},
|
|
309
301
|
{
|
|
310
302
|
// Copy all files from vendor (except vivo-digital & johnpbloch) to the theme/inc/vendor
|
package/lib/buildProject.js
CHANGED
|
@@ -88,12 +88,22 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
88
88
|
const settings = getSettings();
|
|
89
89
|
const url = settings.url[options.environment];
|
|
90
90
|
|
|
91
|
-
const compiler = webpack(config, (err
|
|
92
|
-
if (err
|
|
91
|
+
const compiler = webpack(config, (err) => {
|
|
92
|
+
if (err) {
|
|
93
93
|
logger.error(err.stack || err);
|
|
94
|
+
|
|
95
|
+
if (err.details) {
|
|
96
|
+
logger.error(err.details);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (failOnError) {
|
|
100
|
+
exitWithError();
|
|
101
|
+
}
|
|
102
|
+
|
|
94
103
|
return;
|
|
95
104
|
}
|
|
96
105
|
});
|
|
106
|
+
|
|
97
107
|
const devMiddleware = webpackDevMiddleware(compiler, {
|
|
98
108
|
publicPath: config.output.publicPath,
|
|
99
109
|
stats: {
|
|
@@ -103,6 +113,7 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
103
113
|
},
|
|
104
114
|
writeToDisk: true,
|
|
105
115
|
});
|
|
116
|
+
|
|
106
117
|
const hotMiddleware = webpackHotMiddleware(compiler);
|
|
107
118
|
|
|
108
119
|
browserSync({
|
|
@@ -149,11 +160,11 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
149
160
|
const info = stats.toJson();
|
|
150
161
|
|
|
151
162
|
if (stats.hasWarnings()) {
|
|
152
|
-
info.warnings.forEach(warning => logger.warn(warning));
|
|
163
|
+
info.warnings.forEach((warning) => logger.warn(warning));
|
|
153
164
|
}
|
|
154
165
|
|
|
155
166
|
if (stats.hasErrors()) {
|
|
156
|
-
info.errors.forEach(error => {
|
|
167
|
+
info.errors.forEach((error) => {
|
|
157
168
|
logger.error(chalk.red(error));
|
|
158
169
|
});
|
|
159
170
|
|
|
@@ -3,16 +3,17 @@ const chalk = require('chalk');
|
|
|
3
3
|
|
|
4
4
|
const logger = require('../logger');
|
|
5
5
|
const getProjectPath = require('../utils/getProjectPath');
|
|
6
|
+
const execAsync = require('../utils/execAsync');
|
|
6
7
|
|
|
7
8
|
const BABEL = ['@babel/polyfill', '@babel/runtime', 'babel-polyfill', 'babel-runtime'];
|
|
8
9
|
|
|
9
|
-
function checkProjectDependencies() {
|
|
10
|
+
async function checkProjectDependencies() {
|
|
10
11
|
const projectPackage = getProjectPath('package.json');
|
|
11
12
|
const pck = JSON.parse(fs.readFileSync(projectPackage, 'utf8'));
|
|
12
13
|
const { dependencies, devDependencies } = pck;
|
|
13
14
|
|
|
14
15
|
// Babel polyfill/runtime check
|
|
15
|
-
if (BABEL.some(name => dependencies[name])) {
|
|
16
|
+
if (BABEL.some((name) => dependencies[name])) {
|
|
16
17
|
logger.warn(
|
|
17
18
|
`${chalk.bold('babel polyfill or runtimeyfi')} is no longer required with >=0.4.0.
|
|
18
19
|
Please remove it from your project devDependencies: ${chalk.yellow(
|
|
@@ -45,6 +46,29 @@ function checkProjectDependencies() {
|
|
|
45
46
|
// Warn if fx-classes < v2 is being used
|
|
46
47
|
logger.warn('You are using an old version of fx-classes, please upgrade to at least v2.');
|
|
47
48
|
}
|
|
49
|
+
|
|
50
|
+
// Husky pre-commit hooks activation and migration from v4 to v8
|
|
51
|
+
const huskyDirectory = getProjectPath('.husky');
|
|
52
|
+
const oldHuskyConfig = getProjectPath('.huskyrc.js');
|
|
53
|
+
|
|
54
|
+
// Delete old config if it exists
|
|
55
|
+
if (fs.existsSync(oldHuskyConfig)) {
|
|
56
|
+
try {
|
|
57
|
+
fs.unlinkSync(oldHuskyConfig);
|
|
58
|
+
logger.info('Old Husky config deleted');
|
|
59
|
+
} catch (err) {
|
|
60
|
+
console.warn('Error while deleting old Husky config:', err);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!fs.existsSync(huskyDirectory)) {
|
|
65
|
+
// Husky now requires a "one-time" explicit git hook activation
|
|
66
|
+
await execAsync('yarn husky install');
|
|
67
|
+
logger.info('Upgrading Husky git hooks config');
|
|
68
|
+
execAsync(`npx husky add .husky/pre-commit 'lint-staged'`);
|
|
69
|
+
execAsync(`npx husky add .husky/post-merge 'wp-scripts hooks --type="post-merge"'`);
|
|
70
|
+
logger.success('Husky upgrade successful!');
|
|
71
|
+
}
|
|
48
72
|
}
|
|
49
73
|
|
|
50
74
|
module.exports = checkProjectDependencies;
|
package/package.json
CHANGED
|
@@ -34,7 +34,9 @@ async function checkNodeVerion() {
|
|
|
34
34
|
const currentVersion = await getCurrentNodeVersion();
|
|
35
35
|
|
|
36
36
|
if (projectVersion && !isValidNodeVersion(projectVersion, currentVersion)) {
|
|
37
|
-
logger.warn(
|
|
37
|
+
logger.warn(
|
|
38
|
+
`Your node version (v${currentVersion}) is not valid. This project requires node ${projectVersion}.`
|
|
39
|
+
);
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
|
package/webpack.base.config.js
CHANGED
|
@@ -197,11 +197,11 @@ function makeBaseConfig(options) {
|
|
|
197
197
|
loader: 'postcss-loader',
|
|
198
198
|
options: {
|
|
199
199
|
postcssOptions: {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
postcssPresetEnv(
|
|
203
|
-
|
|
204
|
-
]
|
|
200
|
+
plugins() {
|
|
201
|
+
if (isProd) {
|
|
202
|
+
return [postcssPresetEnv(), cssnano()];
|
|
203
|
+
}
|
|
204
|
+
return [postcssPresetEnv({ browsers: 'last 2 versions' })];
|
|
205
205
|
},
|
|
206
206
|
},
|
|
207
207
|
sourceMap: !isProd,
|
|
@@ -211,7 +211,7 @@ function makeBaseConfig(options) {
|
|
|
211
211
|
loader: 'sass-loader',
|
|
212
212
|
options: {
|
|
213
213
|
sourceMap: !isProd,
|
|
214
|
-
|
|
214
|
+
additionalData: sassVariables,
|
|
215
215
|
},
|
|
216
216
|
},
|
|
217
217
|
],
|