wp-blank-scripts 3.0.0-beta.0 → 3.0.0-beta.10
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 +21 -10
- package/cli/{settings.js → config.js} +18 -18
- package/config/.eslintrc.react.js +1 -0
- package/config/.prettierrc.js +1 -1
- package/config/lint-staged.config.js +1 -1
- package/index.js +15 -18
- package/lib/{addSettings.js → addDeployConfig.js} +3 -4
- package/lib/buildProject.js +16 -7
- package/logger.js +1 -1
- package/overridable/checkProjectDependencies.js +28 -25
- package/overridable/index.js +0 -8
- package/package.json +7 -7
- package/utils/checkNodeVersion.js +3 -1
- package/webpack.base.config.js +23 -20
- package/webpack.react.config.js +51 -59
- package/webpack.wp.config.js +3 -4
- package/cli/upgrade.js +0 -150
- package/config/.huskyrc.js +0 -6
package/README.md
CHANGED
|
@@ -2,7 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
CLI and build tool for Wordpress projects.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Upgrade to v3
|
|
6
|
+
|
|
7
|
+
Surprisingly there are no breaking changes.
|
|
8
|
+
|
|
9
|
+
**v3 Warnings**
|
|
10
|
+
|
|
11
|
+
#### Sass division outside of calc() deprecated
|
|
12
|
+
|
|
13
|
+
Deprecation Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
|
|
14
|
+
Recommendation: math.div(-$grid-gutter, 2) or calc(-1 * $grid-gutter / 2). More info and automated migrator: https://sass-lang.com/d/slash-div
|
|
15
|
+
|
|
16
|
+
Fix:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
npm install -g sass-migrator
|
|
20
|
+
sass-migrator division **/*.scss
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Project Structure
|
|
6
25
|
|
|
7
26
|
```
|
|
8
27
|
/
|
|
@@ -290,21 +309,13 @@ exports.copyFiles = (paths) => {
|
|
|
290
309
|
},
|
|
291
310
|
{
|
|
292
311
|
// Copy files inside a directory the the theme
|
|
293
|
-
from: path.join(sourceDir, 'new-directory'
|
|
312
|
+
from: path.join(sourceDir, 'new-directory'),
|
|
294
313
|
to: themePath,
|
|
295
|
-
transformPath(targetPath) {
|
|
296
|
-
// Need to fix the path
|
|
297
|
-
return targetPath.replace(path.join(sourceDir, 'new-directory'), '');
|
|
298
|
-
},
|
|
299
314
|
},
|
|
300
315
|
{
|
|
301
316
|
// Copy file from a directory to the root directory
|
|
302
317
|
from: path.join(sourceDir, 'directory-file-was-in', 'file.txt'),
|
|
303
318
|
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
319
|
},
|
|
309
320
|
{
|
|
310
321
|
// Copy all files from vendor (except vivo-digital & johnpbloch) to the theme/inc/vendor
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
2
|
const inquirer = require('inquirer');
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const addDeployConfig = require('../lib/addDeployConfig');
|
|
5
5
|
|
|
6
6
|
const logger = require('../logger');
|
|
7
7
|
const getCliOptions = require('../utils/getCliOptions');
|
|
@@ -64,23 +64,23 @@ module.exports = async () => {
|
|
|
64
64
|
{
|
|
65
65
|
name: 'urlProduction',
|
|
66
66
|
message: 'What is the production URL?',
|
|
67
|
-
when: answers => answers.environment === 'production',
|
|
67
|
+
when: (answers) => answers.environment === 'production',
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
name: 'hostProduction',
|
|
71
71
|
message: 'What is the production server host?',
|
|
72
|
-
when: answers => answers.environment === 'production',
|
|
72
|
+
when: (answers) => answers.environment === 'production',
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
name: 'userProduction',
|
|
76
76
|
message: 'What is the production server user?',
|
|
77
|
-
when: answers => answers.environment === 'production',
|
|
77
|
+
when: (answers) => answers.environment === 'production',
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
name: 'destinationProduction',
|
|
81
81
|
message: 'What is the production path?',
|
|
82
|
-
when: answers => answers.environment === 'production',
|
|
83
|
-
default: answers => {
|
|
82
|
+
when: (answers) => answers.environment === 'production',
|
|
83
|
+
default: (answers) => {
|
|
84
84
|
const user = answers.userProduction;
|
|
85
85
|
return `/home/${user}/public_html`;
|
|
86
86
|
},
|
|
@@ -88,40 +88,40 @@ module.exports = async () => {
|
|
|
88
88
|
{
|
|
89
89
|
name: 'dbNameProduction',
|
|
90
90
|
message: 'Production database name?',
|
|
91
|
-
when: answers => answers.environment === 'production',
|
|
91
|
+
when: (answers) => answers.environment === 'production',
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
94
|
name: 'dbUserNameProduction',
|
|
95
95
|
message: 'Production database username?',
|
|
96
|
-
when: answers => answers.environment === 'production',
|
|
96
|
+
when: (answers) => answers.environment === 'production',
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
name: 'dbPasswordProduction',
|
|
100
100
|
message: 'Production database password?',
|
|
101
|
-
when: answers => answers.environment === 'production',
|
|
101
|
+
when: (answers) => answers.environment === 'production',
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
name: 'urlStaging',
|
|
105
105
|
message: 'What is the staging URL?',
|
|
106
|
-
when: answers => answers.environment === 'staging',
|
|
106
|
+
when: (answers) => answers.environment === 'staging',
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
name: 'hostStaging',
|
|
110
110
|
message: 'What is the staging server host?',
|
|
111
|
-
when: answers => answers.environment === 'staging',
|
|
111
|
+
when: (answers) => answers.environment === 'staging',
|
|
112
112
|
default: 'staging.vivo.digital',
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
name: 'userStaging',
|
|
116
116
|
message: 'What is the staging server user?',
|
|
117
|
-
when: answers => answers.environment === 'staging',
|
|
117
|
+
when: (answers) => answers.environment === 'staging',
|
|
118
118
|
default: 'stagingvivo',
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
121
|
name: 'destinationStaging',
|
|
122
122
|
message: 'What is the staging path?',
|
|
123
|
-
when: answers => answers.environment === 'staging',
|
|
124
|
-
default: answers => {
|
|
123
|
+
when: (answers) => answers.environment === 'staging',
|
|
124
|
+
default: (answers) => {
|
|
125
125
|
const user = answers.userStaging;
|
|
126
126
|
let url = answers.urlStaging;
|
|
127
127
|
url = url && url.replace('https://', '');
|
|
@@ -132,17 +132,17 @@ module.exports = async () => {
|
|
|
132
132
|
{
|
|
133
133
|
name: 'dbNameStaging',
|
|
134
134
|
message: 'Staging database name?',
|
|
135
|
-
when: answers => answers.environment === 'staging',
|
|
135
|
+
when: (answers) => answers.environment === 'staging',
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
name: 'dbUserNameStaging',
|
|
139
139
|
message: 'Staging database username?',
|
|
140
|
-
when: answers => answers.environment === 'staging',
|
|
140
|
+
when: (answers) => answers.environment === 'staging',
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
name: 'dbPasswordStaging',
|
|
144
144
|
message: 'Staging database password?',
|
|
145
|
-
when: answers => answers.environment === 'staging',
|
|
145
|
+
when: (answers) => answers.environment === 'staging',
|
|
146
146
|
},
|
|
147
147
|
]);
|
|
148
148
|
|
|
@@ -150,7 +150,7 @@ module.exports = async () => {
|
|
|
150
150
|
const confirmed = options.didPrompt ? await confirmOptions(options) : true;
|
|
151
151
|
|
|
152
152
|
if (confirmed) {
|
|
153
|
-
await
|
|
153
|
+
await addDeployConfig(options);
|
|
154
154
|
logger.success(`${options.environment} Settings updated!`);
|
|
155
155
|
}
|
|
156
156
|
} catch (err) {
|
package/config/.prettierrc.js
CHANGED
package/index.js
CHANGED
|
@@ -10,11 +10,9 @@ const deploy = require('./cli/deploy');
|
|
|
10
10
|
const importSQL = require('./cli/import');
|
|
11
11
|
const exportSQL = require('./cli/export');
|
|
12
12
|
const pullSQL = require('./cli/pull');
|
|
13
|
-
const
|
|
14
|
-
const settings = require('./cli/settings'); //@TODO rename... addDeployConfig
|
|
13
|
+
const addDeployConfig = require('./cli/config');
|
|
15
14
|
|
|
16
15
|
const exitWithError = require('./utils/exitWithError');
|
|
17
|
-
const logger = require('./logger');
|
|
18
16
|
|
|
19
17
|
const _ = () => {};
|
|
20
18
|
|
|
@@ -23,7 +21,7 @@ yargs
|
|
|
23
21
|
.command(
|
|
24
22
|
'build',
|
|
25
23
|
'Build',
|
|
26
|
-
yargs =>
|
|
24
|
+
(yargs) =>
|
|
27
25
|
yargs.option('environment', {
|
|
28
26
|
describe: 'The environment to build for.',
|
|
29
27
|
}),
|
|
@@ -34,7 +32,7 @@ yargs
|
|
|
34
32
|
.command(
|
|
35
33
|
'setup',
|
|
36
34
|
'Setup Project',
|
|
37
|
-
yargs =>
|
|
35
|
+
(yargs) =>
|
|
38
36
|
yargs
|
|
39
37
|
.option('projectLocation', {
|
|
40
38
|
describe: 'Where is the project located?',
|
|
@@ -59,7 +57,7 @@ yargs
|
|
|
59
57
|
.command(
|
|
60
58
|
'deploy',
|
|
61
59
|
'Deploy',
|
|
62
|
-
yargs =>
|
|
60
|
+
(yargs) =>
|
|
63
61
|
yargs
|
|
64
62
|
.option('environment', {
|
|
65
63
|
describe: 'The environment to deploy to.',
|
|
@@ -81,7 +79,7 @@ yargs
|
|
|
81
79
|
.command(
|
|
82
80
|
'import',
|
|
83
81
|
'Import SQL',
|
|
84
|
-
yargs =>
|
|
82
|
+
(yargs) =>
|
|
85
83
|
yargs
|
|
86
84
|
.option('file', {
|
|
87
85
|
describe: 'The path to the file to import.',
|
|
@@ -103,7 +101,7 @@ yargs
|
|
|
103
101
|
.command(
|
|
104
102
|
'export',
|
|
105
103
|
'Export SQL',
|
|
106
|
-
yargs =>
|
|
104
|
+
(yargs) =>
|
|
107
105
|
yargs.option('environment', {
|
|
108
106
|
describe: 'The environment you are exporting for.',
|
|
109
107
|
}),
|
|
@@ -112,7 +110,7 @@ yargs
|
|
|
112
110
|
.command(
|
|
113
111
|
'pull',
|
|
114
112
|
'Pull SQL',
|
|
115
|
-
yargs =>
|
|
113
|
+
(yargs) =>
|
|
116
114
|
yargs.option('environment', {
|
|
117
115
|
describe: 'The environment you are pulling from.',
|
|
118
116
|
}),
|
|
@@ -121,31 +119,30 @@ yargs
|
|
|
121
119
|
.command(
|
|
122
120
|
'hooks',
|
|
123
121
|
'Run a git hook',
|
|
124
|
-
yargs =>
|
|
122
|
+
(yargs) =>
|
|
125
123
|
yargs.option('type', {
|
|
126
124
|
describe: 'The git hook to run.',
|
|
127
125
|
}),
|
|
128
126
|
hooks
|
|
129
127
|
)
|
|
130
|
-
.command('upgrade', 'Upgrade to v0.4', _, upgrade)
|
|
131
128
|
.command(
|
|
132
|
-
'
|
|
133
|
-
'Add
|
|
134
|
-
yargs =>
|
|
129
|
+
'config',
|
|
130
|
+
'Add deployment config',
|
|
131
|
+
(yargs) =>
|
|
135
132
|
yargs.option('environment', {
|
|
136
|
-
describe: 'What environment are you adding
|
|
133
|
+
describe: 'What environment are you adding deployment config for?',
|
|
137
134
|
}),
|
|
138
|
-
|
|
135
|
+
addDeployConfig
|
|
139
136
|
)
|
|
140
137
|
.help()
|
|
141
138
|
.alias('h', 'help')
|
|
142
139
|
.demandCommand()
|
|
143
140
|
.strict().argv;
|
|
144
141
|
|
|
145
|
-
process.on('uncaughtException', err => {
|
|
142
|
+
process.on('uncaughtException', (err) => {
|
|
146
143
|
exitWithError(err.message);
|
|
147
144
|
});
|
|
148
145
|
|
|
149
|
-
process.on('unhandledRejection', err => {
|
|
146
|
+
process.on('unhandledRejection', (err) => {
|
|
150
147
|
exitWithError(err instanceof Error ? err.stack || err.message : 'Something went wrong');
|
|
151
148
|
});
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const glob = require('glob');
|
|
3
|
-
const slugify = require('slugify');
|
|
4
3
|
const replace = require('replace-in-file');
|
|
5
4
|
|
|
6
5
|
const logger = require('../logger');
|
|
7
6
|
const getProjectPath = require('../utils/getProjectPath');
|
|
8
7
|
|
|
9
|
-
const getReplacements = options => {
|
|
8
|
+
const getReplacements = (options) => {
|
|
10
9
|
if (options.environment === 'production') {
|
|
11
10
|
return [
|
|
12
11
|
['{{url_production}}', options.urlProduction],
|
|
@@ -32,7 +31,7 @@ const getReplacements = options => {
|
|
|
32
31
|
return;
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
module.exports = async options => {
|
|
34
|
+
module.exports = async (options) => {
|
|
36
35
|
const projectPath = getProjectPath();
|
|
37
36
|
const filesToReplace = [
|
|
38
37
|
...glob.sync('config/*', { cwd: projectPath, dot: true }),
|
|
@@ -44,7 +43,7 @@ module.exports = async options => {
|
|
|
44
43
|
let files = filesToReplace;
|
|
45
44
|
if (getProjectPath() !== process.cwd()) {
|
|
46
45
|
// Check if the script is being run from outside of the project and then fix the paths
|
|
47
|
-
files = files.map(file => getProjectPath(file));
|
|
46
|
+
files = files.map((file) => getProjectPath(file));
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
// Remove any files that don't exist
|
package/lib/buildProject.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
|
-
const opn = require('opn');
|
|
3
2
|
const rimraf = require('rimraf');
|
|
4
3
|
const webpack = require('webpack');
|
|
5
4
|
const { merge } = require('webpack-merge');
|
|
@@ -88,12 +87,22 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
88
87
|
const settings = getSettings();
|
|
89
88
|
const url = settings.url[options.environment];
|
|
90
89
|
|
|
91
|
-
const compiler = webpack(config, (err
|
|
92
|
-
if (err
|
|
90
|
+
const compiler = webpack(config, (err) => {
|
|
91
|
+
if (err) {
|
|
93
92
|
logger.error(err.stack || err);
|
|
93
|
+
|
|
94
|
+
if (err.details) {
|
|
95
|
+
logger.error(err.details);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (failOnError) {
|
|
99
|
+
exitWithError();
|
|
100
|
+
}
|
|
101
|
+
|
|
94
102
|
return;
|
|
95
103
|
}
|
|
96
104
|
});
|
|
105
|
+
|
|
97
106
|
const devMiddleware = webpackDevMiddleware(compiler, {
|
|
98
107
|
publicPath: config.output.publicPath,
|
|
99
108
|
stats: {
|
|
@@ -103,12 +112,13 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
103
112
|
},
|
|
104
113
|
writeToDisk: true,
|
|
105
114
|
});
|
|
115
|
+
|
|
106
116
|
const hotMiddleware = webpackHotMiddleware(compiler);
|
|
107
117
|
|
|
108
118
|
browserSync({
|
|
109
119
|
host: 'localhost',
|
|
110
120
|
https: process.env.HTTPS,
|
|
111
|
-
open:
|
|
121
|
+
open: true,
|
|
112
122
|
port: process.env.PORT || 3000,
|
|
113
123
|
proxy: {
|
|
114
124
|
target: url,
|
|
@@ -122,7 +132,6 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
122
132
|
});
|
|
123
133
|
|
|
124
134
|
devMiddleware.waitUntilValid(() => {
|
|
125
|
-
opn(url.replace('8888', process.env.PORT));
|
|
126
135
|
logger.success('Build finished successfully!');
|
|
127
136
|
});
|
|
128
137
|
|
|
@@ -149,11 +158,11 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
149
158
|
const info = stats.toJson();
|
|
150
159
|
|
|
151
160
|
if (stats.hasWarnings()) {
|
|
152
|
-
info.warnings.forEach(warning => logger.warn(warning));
|
|
161
|
+
info.warnings.forEach((warning) => logger.warn(warning));
|
|
153
162
|
}
|
|
154
163
|
|
|
155
164
|
if (stats.hasErrors()) {
|
|
156
|
-
info.errors.forEach(error => {
|
|
165
|
+
info.errors.forEach((error) => {
|
|
157
166
|
logger.error(chalk.red(error));
|
|
158
167
|
});
|
|
159
168
|
|
package/logger.js
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const chalk = require('chalk');
|
|
3
|
+
const rimraf = require('rimraf');
|
|
3
4
|
|
|
4
5
|
const logger = require('../logger');
|
|
5
6
|
const getProjectPath = require('../utils/getProjectPath');
|
|
7
|
+
const execAsync = require('../utils/execAsync');
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function checkProjectDependencies() {
|
|
10
|
-
const projectPackage = getProjectPath('package.json');
|
|
11
|
-
const pck = JSON.parse(fs.readFileSync(projectPackage, 'utf8'));
|
|
12
|
-
const { dependencies, devDependencies } = pck;
|
|
13
|
-
|
|
14
|
-
// Babel polyfill/runtime check
|
|
15
|
-
if (BABEL.some(name => dependencies[name])) {
|
|
16
|
-
logger.warn(
|
|
17
|
-
`${chalk.bold('babel polyfill or runtimeyfi')} is no longer required with >=0.4.0.
|
|
18
|
-
Please remove it from your project devDependencies: ${chalk.yellow(
|
|
19
|
-
`yarn remove ${BABEL.join(' ')}`
|
|
20
|
-
)}`
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// mamp-cli
|
|
25
|
-
if (devDependencies['mamp-cli']) {
|
|
26
|
-
logger.warn(
|
|
27
|
-
`${chalk.bold('mamp-cli')} is no longer required with >=2.0.0.
|
|
28
|
-
Please remove it from your project devDependencies: ${chalk.yellow('yarn remove mamp-cli')}`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
9
|
+
async function checkProjectDependencies() {
|
|
32
10
|
const vendorDir = getProjectPath('vendor');
|
|
33
11
|
const hasInstalledComposer = fs.existsSync(vendorDir);
|
|
34
12
|
if (!hasInstalledComposer) {
|
|
@@ -45,6 +23,31 @@ function checkProjectDependencies() {
|
|
|
45
23
|
// Warn if fx-classes < v2 is being used
|
|
46
24
|
logger.warn('You are using an old version of fx-classes, please upgrade to at least v2.');
|
|
47
25
|
}
|
|
26
|
+
|
|
27
|
+
// Husky pre-commit hooks activation and migration from v4 to v8
|
|
28
|
+
const huskyDirectory = getProjectPath('.husky');
|
|
29
|
+
const oldHuskyConfig = getProjectPath('.huskyrc.js');
|
|
30
|
+
|
|
31
|
+
// Delete old config if it exists
|
|
32
|
+
if (fs.existsSync(oldHuskyConfig)) {
|
|
33
|
+
try {
|
|
34
|
+
rimraf.sync(oldHuskyConfig);
|
|
35
|
+
logger.info('Old Husky config deleted');
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.warn('Error while deleting old Husky config:', err);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!fs.existsSync(huskyDirectory)) {
|
|
42
|
+
// Husky now requires a "one-time" explicit git hook activation
|
|
43
|
+
const husky = `node_modules/.bin/husky`;
|
|
44
|
+
|
|
45
|
+
await execAsync(`${husky} install`);
|
|
46
|
+
logger.info('Upgrading Husky git hooks config');
|
|
47
|
+
await execAsync(`${husky} add .husky/pre-commit 'npx lint-staged'`);
|
|
48
|
+
await execAsync(`${husky} add .husky/post-merge 'wp-scripts hooks --type="post-merge"'`);
|
|
49
|
+
logger.success('Husky upgrade successful!');
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
module.exports = checkProjectDependencies;
|
package/overridable/index.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
const logger = require('../logger');
|
|
5
|
-
|
|
6
4
|
let overrides;
|
|
7
5
|
const overridesPath = path.resolve(process.cwd(), './tasks/overrides.js');
|
|
8
6
|
if (fs.existsSync(overridesPath)) {
|
|
9
7
|
overrides = require(overridesPath);
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
if (overrides.copyFxClasses) {
|
|
13
|
-
logger.warn(
|
|
14
|
-
`You are using the old "copyFxClasses" override, please upgrade your code to use the new "copyFx" API.`
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
10
|
const checkProjectDependencies = require('./checkProjectDependencies');
|
|
19
11
|
const copyFx = require('./copyFx');
|
|
20
12
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wp-blank-scripts",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.10",
|
|
4
4
|
"description": "Personal Wordpress Scripts",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
11
|
},
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
13
|
+
"node": ">=10"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"cli",
|
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
"author": "ViVO Digital",
|
|
32
32
|
"license": "ISC",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@
|
|
34
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
|
|
35
35
|
"@prettier/plugin-php": "^0.19.6",
|
|
36
|
+
"@swc/cli": "^0.1.62",
|
|
37
|
+
"@swc/core": "^1.3.67",
|
|
36
38
|
"browser-sync": "^2.29.3",
|
|
37
39
|
"chalk": "4.1.2",
|
|
38
40
|
"copy-webpack-plugin": "^11.0.0",
|
|
@@ -58,15 +60,13 @@
|
|
|
58
60
|
"mini-css-extract-plugin": "^2.7.6",
|
|
59
61
|
"mysql": "^2.18.1",
|
|
60
62
|
"node-fetch": "2",
|
|
61
|
-
"normalize.css": "^8.0.1",
|
|
62
|
-
"opn": "^6.0.0",
|
|
63
63
|
"ora": "^5.4.1",
|
|
64
64
|
"postcss": "^8.4.24",
|
|
65
65
|
"postcss-loader": "^7.3.3",
|
|
66
66
|
"postcss-preset-env": "^8.5.0",
|
|
67
67
|
"prettier": "^2.8.8",
|
|
68
68
|
"raw-loader": "^4.0.2",
|
|
69
|
-
"react-
|
|
69
|
+
"react-refresh": "^0.14.0",
|
|
70
70
|
"replace-in-file": "^7.0.1",
|
|
71
71
|
"rimraf": "^5.0.1",
|
|
72
72
|
"rsync": "^0.6.1",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"slugify": "^1.6.6",
|
|
78
78
|
"ssh2": "0.8.9",
|
|
79
79
|
"style-loader": "^3.3.3",
|
|
80
|
+
"swc-loader": "^0.2.3",
|
|
80
81
|
"tempy": "^0.2.1",
|
|
81
82
|
"terser-webpack-plugin": "^5.3.9",
|
|
82
|
-
"time-fix-plugin": "^2.0.7",
|
|
83
83
|
"webpack": "^5.87.0",
|
|
84
84
|
"webpack-dev-middleware": "^6.1.1",
|
|
85
85
|
"webpack-hot-middleware": "^2.25.3",
|
|
@@ -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
|
@@ -5,7 +5,6 @@ const CopyPlugin = require('copy-webpack-plugin');
|
|
|
5
5
|
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
|
|
6
6
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
7
7
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
8
|
-
const TimeFixPlugin = require('time-fix-plugin');
|
|
9
8
|
const cssnano = require('cssnano');
|
|
10
9
|
const glob = require('glob');
|
|
11
10
|
const postcssPresetEnv = require('postcss-preset-env');
|
|
@@ -35,6 +34,7 @@ function makeBaseConfig(options) {
|
|
|
35
34
|
const themePath = path.join(buildPath, themeDir);
|
|
36
35
|
|
|
37
36
|
const fxFiles = getFxFiles(copyFx());
|
|
37
|
+
const fontsDir = path.join(sourceDir, 'assets', 'fonts');
|
|
38
38
|
|
|
39
39
|
const sourceFiles = [
|
|
40
40
|
{
|
|
@@ -51,11 +51,15 @@ function makeBaseConfig(options) {
|
|
|
51
51
|
to: path.join(themePath, 'assets', 'img'),
|
|
52
52
|
globOptions: { ignore: ['.DS_Store'] },
|
|
53
53
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
...(fs.existsSync(fontsDir)
|
|
55
|
+
? [
|
|
56
|
+
{
|
|
57
|
+
from: fontsDir,
|
|
58
|
+
to: path.join(themePath, 'assets', 'fonts'),
|
|
59
|
+
globOptions: { ignore: ['.DS_Store'] },
|
|
60
|
+
},
|
|
61
|
+
]
|
|
62
|
+
: []),
|
|
59
63
|
{
|
|
60
64
|
from: path.join(sourceDir, 'templates'),
|
|
61
65
|
to: themePath,
|
|
@@ -168,14 +172,15 @@ function makeBaseConfig(options) {
|
|
|
168
172
|
rules: [
|
|
169
173
|
{
|
|
170
174
|
test: /\.[jt]sx?$/,
|
|
171
|
-
exclude: /node_modules
|
|
175
|
+
exclude: /node_modules/,
|
|
172
176
|
use: {
|
|
173
|
-
loader: '
|
|
177
|
+
loader: 'swc-loader',
|
|
174
178
|
options: {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
jsc: {
|
|
180
|
+
parser: {
|
|
181
|
+
jsx: true,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
179
184
|
},
|
|
180
185
|
},
|
|
181
186
|
...loaderOverrides.js,
|
|
@@ -197,11 +202,11 @@ function makeBaseConfig(options) {
|
|
|
197
202
|
loader: 'postcss-loader',
|
|
198
203
|
options: {
|
|
199
204
|
postcssOptions: {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
postcssPresetEnv(
|
|
203
|
-
|
|
204
|
-
]
|
|
205
|
+
plugins() {
|
|
206
|
+
if (isProd) {
|
|
207
|
+
return [postcssPresetEnv(), cssnano()];
|
|
208
|
+
}
|
|
209
|
+
return [postcssPresetEnv({ browsers: 'last 2 versions' })];
|
|
205
210
|
},
|
|
206
211
|
},
|
|
207
212
|
sourceMap: !isProd,
|
|
@@ -211,7 +216,7 @@ function makeBaseConfig(options) {
|
|
|
211
216
|
loader: 'sass-loader',
|
|
212
217
|
options: {
|
|
213
218
|
sourceMap: !isProd,
|
|
214
|
-
|
|
219
|
+
additionalData: sassVariables,
|
|
215
220
|
},
|
|
216
221
|
},
|
|
217
222
|
],
|
|
@@ -241,8 +246,6 @@ function makeBaseConfig(options) {
|
|
|
241
246
|
],
|
|
242
247
|
},
|
|
243
248
|
plugins: [
|
|
244
|
-
// TODO: See if we can remove
|
|
245
|
-
// new TimeFixPlugin(),
|
|
246
249
|
new CopyPlugin({ patterns: filesToCopy }),
|
|
247
250
|
new RemoveEmptyScriptsPlugin({ silent: true }),
|
|
248
251
|
],
|
package/webpack.react.config.js
CHANGED
|
@@ -6,6 +6,7 @@ const webpack = require('webpack');
|
|
|
6
6
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
7
7
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
8
8
|
const postcssPresetEnv = require('postcss-preset-env');
|
|
9
|
+
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
9
10
|
const cssnano = require('cssnano');
|
|
10
11
|
|
|
11
12
|
const getSettings = require('./utils/projectSettings');
|
|
@@ -16,26 +17,28 @@ function makeReactWebpackConfig(options) {
|
|
|
16
17
|
const isProd = mode === 'production';
|
|
17
18
|
const sourceDir = 'app';
|
|
18
19
|
const sourcePath = path.join(process.cwd(), sourceDir);
|
|
19
|
-
const entryPath = path.join(sourcePath, 'index.js');
|
|
20
|
+
const entryPath = [path.join(sourcePath, 'index.js')];
|
|
20
21
|
const globalVariablesPath = path.join(sourcePath, 'variables.scss');
|
|
21
22
|
|
|
22
23
|
const settings = getSettings();
|
|
23
24
|
const themeDir = path.join('wp-content', 'themes', settings.project);
|
|
24
25
|
|
|
25
|
-
if (!fs.existsSync(entryPath)) {
|
|
26
|
-
const relativeEntryPath = path.relative(process.cwd(), entryPath);
|
|
26
|
+
if (!fs.existsSync(entryPath[0])) {
|
|
27
|
+
const relativeEntryPath = path.relative(process.cwd(), entryPath[0]);
|
|
27
28
|
exitWithError(`This project is a React project, but the entry file is missing.
|
|
28
29
|
Please create ${chalk.yellow(relativeEntryPath)} to continue.`);
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
if (!isProd) {
|
|
33
|
+
entryPath.unshift('webpack-hot-middleware/client');
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
const config = {
|
|
32
37
|
entry: {
|
|
33
|
-
// Make sure global is first
|
|
34
|
-
style: ['normalize.css'],
|
|
35
38
|
main: entryPath,
|
|
36
39
|
},
|
|
37
40
|
output: {
|
|
38
|
-
filename: chunkData => {
|
|
41
|
+
filename: (chunkData) => {
|
|
39
42
|
if (chunkData.chunk.name === 'adminScripts') {
|
|
40
43
|
return path.join(themeDir, 'assets', 'js', 'admin.js');
|
|
41
44
|
}
|
|
@@ -46,16 +49,33 @@ function makeReactWebpackConfig(options) {
|
|
|
46
49
|
},
|
|
47
50
|
module: {
|
|
48
51
|
rules: [
|
|
52
|
+
{
|
|
53
|
+
test: /\.[jt]sx?$/,
|
|
54
|
+
exclude: /node_modules/,
|
|
55
|
+
use: {
|
|
56
|
+
loader: 'swc-loader',
|
|
57
|
+
options: {
|
|
58
|
+
sourceMap: true,
|
|
59
|
+
jsc: {
|
|
60
|
+
parser: {
|
|
61
|
+
jsx: true,
|
|
62
|
+
},
|
|
63
|
+
transform: {
|
|
64
|
+
react: {
|
|
65
|
+
development: !isProd,
|
|
66
|
+
refresh: !isProd,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
49
73
|
{
|
|
50
74
|
test: /\.css$/,
|
|
51
75
|
include: [sourcePath],
|
|
52
76
|
use: [
|
|
53
77
|
{
|
|
54
|
-
loader: MiniCssExtractPlugin.loader,
|
|
55
|
-
options: {
|
|
56
|
-
hmr: !isProd,
|
|
57
|
-
reloadAll: true,
|
|
58
|
-
},
|
|
78
|
+
loader: !isProd ? 'style-loader' : MiniCssExtractPlugin.loader,
|
|
59
79
|
},
|
|
60
80
|
{
|
|
61
81
|
loader: 'css-loader',
|
|
@@ -64,14 +84,15 @@ function makeReactWebpackConfig(options) {
|
|
|
64
84
|
{
|
|
65
85
|
loader: 'postcss-loader',
|
|
66
86
|
options: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
87
|
+
postcssOptions: {
|
|
88
|
+
plugins() {
|
|
89
|
+
if (isProd) {
|
|
90
|
+
return [postcssPresetEnv(), cssnano()];
|
|
91
|
+
}
|
|
92
|
+
return [postcssPresetEnv({ browsers: 'last 2 versions' })];
|
|
93
|
+
},
|
|
94
|
+
sourceMap: !isProd,
|
|
73
95
|
},
|
|
74
|
-
sourceMap: true,
|
|
75
96
|
},
|
|
76
97
|
},
|
|
77
98
|
],
|
|
@@ -79,13 +100,9 @@ function makeReactWebpackConfig(options) {
|
|
|
79
100
|
{
|
|
80
101
|
test: /\.scss$/,
|
|
81
102
|
include: [sourcePath],
|
|
82
|
-
|
|
103
|
+
use: [
|
|
83
104
|
{
|
|
84
|
-
loader: MiniCssExtractPlugin.loader,
|
|
85
|
-
options: {
|
|
86
|
-
hmr: !isProd,
|
|
87
|
-
reloadAll: true,
|
|
88
|
-
},
|
|
105
|
+
loader: !isProd ? 'style-loader' : MiniCssExtractPlugin.loader,
|
|
89
106
|
},
|
|
90
107
|
{
|
|
91
108
|
loader: 'css-loader',
|
|
@@ -97,14 +114,15 @@ function makeReactWebpackConfig(options) {
|
|
|
97
114
|
{
|
|
98
115
|
loader: 'postcss-loader',
|
|
99
116
|
options: {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
117
|
+
postcssOptions: {
|
|
118
|
+
plugins() {
|
|
119
|
+
if (isProd) {
|
|
120
|
+
return [postcssPresetEnv(), cssnano()];
|
|
121
|
+
}
|
|
122
|
+
return [postcssPresetEnv({ browsers: 'last 2 versions' })];
|
|
123
|
+
},
|
|
124
|
+
sourceMap: !isProd,
|
|
106
125
|
},
|
|
107
|
-
sourceMap: true,
|
|
108
126
|
},
|
|
109
127
|
},
|
|
110
128
|
{
|
|
@@ -121,19 +139,6 @@ function makeReactWebpackConfig(options) {
|
|
|
121
139
|
},
|
|
122
140
|
],
|
|
123
141
|
},
|
|
124
|
-
{
|
|
125
|
-
test: /\.(eot|ttf|woff|woff2)$/,
|
|
126
|
-
include: [sourcePath],
|
|
127
|
-
use: [
|
|
128
|
-
{
|
|
129
|
-
loader: 'file-loader',
|
|
130
|
-
options: {
|
|
131
|
-
name: '[contenthash].[ext]',
|
|
132
|
-
outputPath: path.join(themeDir, 'assets', 'fonts'),
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
},
|
|
137
142
|
{
|
|
138
143
|
test: /.*\.(gif|png|svg|jpe?g)$/i,
|
|
139
144
|
include: [sourcePath],
|
|
@@ -164,20 +169,13 @@ function makeReactWebpackConfig(options) {
|
|
|
164
169
|
excludeChunks: ['adminScripts', 'admin.style'],
|
|
165
170
|
}),
|
|
166
171
|
new MiniCssExtractPlugin({
|
|
167
|
-
|
|
172
|
+
filename({ name }) {
|
|
168
173
|
if (name === 'admin.style') {
|
|
169
174
|
return path.join(themeDir, 'assets', 'css', 'admin.style.css');
|
|
170
175
|
}
|
|
171
176
|
|
|
172
177
|
return path.join(themeDir, 'assets', 'css', isProd ? '[contenthash].css' : '[name].css');
|
|
173
178
|
},
|
|
174
|
-
fallback: 'style-loader',
|
|
175
|
-
use: [
|
|
176
|
-
{
|
|
177
|
-
loader: 'css-loader',
|
|
178
|
-
options: { minimize: isProd, url: false, sourceMap: !isProd },
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
179
|
}),
|
|
182
180
|
],
|
|
183
181
|
optimization: {
|
|
@@ -210,15 +208,9 @@ function makeReactWebpackConfig(options) {
|
|
|
210
208
|
version: false,
|
|
211
209
|
},
|
|
212
210
|
};
|
|
213
|
-
|
|
214
211
|
if (!isProd) {
|
|
215
|
-
config.entry.main = [
|
|
216
|
-
'webpack-hot-middleware/client',
|
|
217
|
-
'react-hot-loader/patch',
|
|
218
|
-
config.entry.main,
|
|
219
|
-
];
|
|
220
212
|
config.plugins.push(new webpack.HotModuleReplacementPlugin());
|
|
221
|
-
config.
|
|
213
|
+
config.plugins.push(new ReactRefreshWebpackPlugin({ overlay: false }));
|
|
222
214
|
}
|
|
223
215
|
|
|
224
216
|
return config;
|
package/webpack.wp.config.js
CHANGED
|
@@ -13,7 +13,6 @@ const getSettings = require('./utils/projectSettings');
|
|
|
13
13
|
|
|
14
14
|
function makeWpWebpackConfig() {
|
|
15
15
|
const mode = process.env.NODE_ENV || 'development';
|
|
16
|
-
const isProd = mode === 'production';
|
|
17
16
|
|
|
18
17
|
const settings = getSettings();
|
|
19
18
|
|
|
@@ -25,12 +24,12 @@ function makeWpWebpackConfig() {
|
|
|
25
24
|
|
|
26
25
|
// Source entries
|
|
27
26
|
const mainScripts = {};
|
|
28
|
-
glob.sync(path.join(sourcePath, 'assets', 'js', '*.js')).forEach(filePath => {
|
|
27
|
+
glob.sync(path.join(sourcePath, 'assets', 'js', '*.js')).forEach((filePath) => {
|
|
29
28
|
const name = path.basename(filePath, '.js');
|
|
30
29
|
mainScripts[name] = [filePath];
|
|
31
30
|
});
|
|
32
31
|
|
|
33
|
-
glob.sync(path.join(sourcePath, 'assets', 'js', 'gutenberg', '*.js')).forEach(filePath => {
|
|
32
|
+
glob.sync(path.join(sourcePath, 'assets', 'js', 'gutenberg', '*.js')).forEach((filePath) => {
|
|
34
33
|
const name = path.basename(filePath, '.js');
|
|
35
34
|
mainScripts[`gutenberg/${name}`] = [filePath];
|
|
36
35
|
});
|
|
@@ -52,7 +51,7 @@ function makeWpWebpackConfig() {
|
|
|
52
51
|
return {
|
|
53
52
|
entry: {
|
|
54
53
|
...mainScripts,
|
|
55
|
-
style: [
|
|
54
|
+
style: [...fxFiles.sass, ...mainStyles],
|
|
56
55
|
},
|
|
57
56
|
plugins: [
|
|
58
57
|
new MiniCssExtractPlugin({
|
package/cli/upgrade.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const rimraf = require('rimraf');
|
|
4
|
-
const replace = require('replace-in-file');
|
|
5
|
-
const ora = require('ora');
|
|
6
|
-
|
|
7
|
-
const execAsync = require('../utils/execAsync');
|
|
8
|
-
const logger = require('../logger');
|
|
9
|
-
|
|
10
|
-
const unusedPackages = [
|
|
11
|
-
'pace-progress',
|
|
12
|
-
'@babel/polyfill',
|
|
13
|
-
'@babel/runtime',
|
|
14
|
-
'babel-polyfill',
|
|
15
|
-
'babel-runtime',
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
const filesToChange = [
|
|
19
|
-
[path.join('config', 'htaccess.txt'), path.join('config', '.htaccess')],
|
|
20
|
-
[
|
|
21
|
-
path.join('config', 'htaccess-staging.txt'),
|
|
22
|
-
path.join('config', '.htaccess-staging'),
|
|
23
|
-
],
|
|
24
|
-
[
|
|
25
|
-
path.join('config', 'htaccess-production.txt'),
|
|
26
|
-
path.join('config', '.htaccess-production'),
|
|
27
|
-
],
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
module.exports = async () => {
|
|
31
|
-
logger.log('Upgrading your project to the latest wp-blank-scripts');
|
|
32
|
-
|
|
33
|
-
// Rename files
|
|
34
|
-
filesToChange.forEach(([to, from]) => {
|
|
35
|
-
if (fs.existsSync(to)) {
|
|
36
|
-
fs.renameSync(to, from);
|
|
37
|
-
logger.log(`Renamed ${to} to ${from}`);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const pckFile = fs.readFileSync('package.json');
|
|
42
|
-
const pck = JSON.parse(pckFile);
|
|
43
|
-
|
|
44
|
-
// Remove browserify-shim from package.json
|
|
45
|
-
delete pck['browserify-shim'];
|
|
46
|
-
delete pck['browserify'];
|
|
47
|
-
logger.log('Removed browserify & browserify-shim config');
|
|
48
|
-
|
|
49
|
-
// Add new pull command
|
|
50
|
-
pck.scripts.pull = 'wp-scripts pull';
|
|
51
|
-
|
|
52
|
-
// Add new vivo config
|
|
53
|
-
pck.vivo = {
|
|
54
|
-
'dev-command': 'start',
|
|
55
|
-
designs: [],
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
logger.log('Added new fields to project package');
|
|
59
|
-
|
|
60
|
-
fs.writeFileSync('package.json', JSON.stringify(pck, null, 2));
|
|
61
|
-
|
|
62
|
-
// Remove pace-progress occurences from style.scss, preloader.scss, main.js
|
|
63
|
-
const scriptFilePP = path.join('src', 'assets', 'js', 'main.js');
|
|
64
|
-
const styleFilePP = path.join(
|
|
65
|
-
'src',
|
|
66
|
-
'assets',
|
|
67
|
-
'css',
|
|
68
|
-
'partials',
|
|
69
|
-
'preloader.scss'
|
|
70
|
-
);
|
|
71
|
-
const mainStyleFile = path.join('src', 'assets', 'css', 'style.scss');
|
|
72
|
-
|
|
73
|
-
// Remove from main.js
|
|
74
|
-
const importLinesPreloader = [
|
|
75
|
-
'// Pace',
|
|
76
|
-
'import pace from \'pace-progress\';',
|
|
77
|
-
'pace.start();',
|
|
78
|
-
];
|
|
79
|
-
replace.sync({
|
|
80
|
-
files: scriptFilePP,
|
|
81
|
-
from: importLinesPreloader,
|
|
82
|
-
to: '',
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Delete preloader.scss
|
|
86
|
-
rimraf.sync(styleFilePP);
|
|
87
|
-
logger.log('Removed pace-progress from project');
|
|
88
|
-
|
|
89
|
-
// Remove import from style.scss
|
|
90
|
-
const importPreloaderStyles = '@import \'partials/preloader\';';
|
|
91
|
-
replace.sync({
|
|
92
|
-
files: mainStyleFile,
|
|
93
|
-
from: importPreloaderStyles,
|
|
94
|
-
to: '',
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// Rename admin.css
|
|
98
|
-
const enqueueFile = path.join('src', 'inc', 'fx-enqueue.php');
|
|
99
|
-
replace.sync({
|
|
100
|
-
files: enqueueFile,
|
|
101
|
-
from: 'admin.css',
|
|
102
|
-
to: 'admin.style.css',
|
|
103
|
-
});
|
|
104
|
-
logger.log('Renamed admin styles in enqueue');
|
|
105
|
-
|
|
106
|
-
// Remove normalize.css
|
|
107
|
-
const normalizeFile = path.join(
|
|
108
|
-
'src',
|
|
109
|
-
'assets',
|
|
110
|
-
'css',
|
|
111
|
-
'vendor',
|
|
112
|
-
'normalize.scss'
|
|
113
|
-
);
|
|
114
|
-
rimraf.sync(normalizeFile);
|
|
115
|
-
const styleFile = path.join('src', 'assets', 'css', 'style.scss');
|
|
116
|
-
const importLine = '@import \'vendor/normalize\';';
|
|
117
|
-
replace.sync({
|
|
118
|
-
files: styleFile,
|
|
119
|
-
from: importLine,
|
|
120
|
-
to: '',
|
|
121
|
-
});
|
|
122
|
-
logger.log('Removed normalize.css from project');
|
|
123
|
-
|
|
124
|
-
// Remove deployment.log
|
|
125
|
-
rimraf.sync('deployment.log');
|
|
126
|
-
logger.log('Removed deployment.log from project');
|
|
127
|
-
|
|
128
|
-
const packagesToRemove = unusedPackages.filter(p =>
|
|
129
|
-
Boolean(pck.dependencies[p] || pck.devDependencies[p])
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
if (packagesToRemove.length > 0) {
|
|
133
|
-
// Remove unused packages
|
|
134
|
-
logger.log('Removing unused packages...');
|
|
135
|
-
|
|
136
|
-
const spinner = ora();
|
|
137
|
-
spinner.prefixText = logger.prefix;
|
|
138
|
-
spinner.start();
|
|
139
|
-
await execAsync(`yarn remove ${packagesToRemove.join(' ')}`);
|
|
140
|
-
|
|
141
|
-
spinner.stop();
|
|
142
|
-
logger.log(
|
|
143
|
-
`Removed ${packagesToRemove.length} package${
|
|
144
|
-
packagesToRemove.length === 1 ? '' : 's'
|
|
145
|
-
}`
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
logger.success('Upgraded to wp-blank-scripts v0.4, you\'re good to go!');
|
|
150
|
-
};
|