-
Notifications
You must be signed in to change notification settings - Fork 2
/
.wp-env-afterStart.sh
executable file
·133 lines (118 loc) · 4.83 KB
/
.wp-env-afterStart.sh
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
#!/usr/bin/env bash
#
# this script is used to customize the created wp-env instance
#
WPENV_INSTALLPATH="$(realpath --relative-to $(pwd) $(pnpm run --silent wp-env install-path))"
# # build gutenberg for development (for debugging purposes - i.e. including source maps etc.)
# pushd "${WPENV_INSTALLPATH}/gutenberg"
# # compute path to our configured nodejs provided by pnpm environment
# NODE_PATH="$(dirname $(which node))/.."
# # calling the original npm delivered with the configured nodejs version is a bit quirky but works :-)
# $NODE_PATH/bin/node "$NODE_PATH/lib/node_modules/npm/bin/npm-cli.js" ci
# $NODE_PATH/bin/node "$NODE_PATH/lib/node_modules/npm/bin/npm-cli.js" run build
# popd
# # build gutenberg for development (for debugging purposes - i.e. including source maps etc.)
# pushd "${WPENV_INSTALLPATH}/gutenberg"
# # compute path to our configured nodejs provided by pnpm environment
# NODE_PATH="$(dirname $(which node))/.."
# # calling the original npm delivered with the configured nodejs version is a bit quirky but works :-)
# $NODE_PATH/bin/node "$NODE_PATH/lib/node_modules/npm/bin/npm-cli.js" ci
# $NODE_PATH/bin/node "$NODE_PATH/lib/node_modules/npm/bin/npm-cli.js" run build:packages
# # build gutenberg in development mode
# ./node_modules/.bin/wp-scripts start --no-watch
# # build static gutenberg storybook
# $NODE_PATH/bin/node "$NODE_PATH/lib/node_modules/npm/bin/npm-cli.js" run storybook:build
# popd
# remove dolly demo plugin
rm -f $WPENV_INSTALLPATH/{tests-WordPress,WordPress}/wp-content/plugins/hello.php
for prefix in '' 'tests-' ; do
# this wp-cli configuration file needs to be created to enable wp-cli to work with the apache mod_rewrite module
pnpm run wp-env run ${prefix}cli sh -c 'echo -e "apache_modules:\n - mod_rewrite" > /var/www/html/wp-cli.yml'
# The wp rewrite flush command regenerates the rewrite rules for your WordPress site, which includes refreshing the permalinks.
pnpm run wp-env run ${prefix}cli wp --quiet rewrite flush
# The wp rewrite structure command updates the permalink structure. --hard also updates the .htaccess file
pnpm run wp-env run ${prefix}cli wp --quiet rewrite structure '/%postname%' --hard
# activate our theme
pnpm run wp-env run ${prefix}cli wp --quiet theme activate extended-global-styles
# deactivate the deprecated cpt plugin
pnpm run wp-env run ${prefix}cli wp --quiet plugin deactivate cpt
# Updates an option value for example the value of Simple page is id = 2
pnpm run wp-env run ${prefix}cli wp option update page_on_front 2
# Update the page as front page by default.
pnpm run wp-env run ${prefix}cli wp option update show_on_front page
done
function plugins {
for PLUGIN in $(find packages/wp-content/plugins -mindepth 1 -maxdepth 1 -type d -printf '%f\n'); do
echo " \"/var/www/html/wp-content/plugins/${PLUGIN}\":\"\${workspaceFolder}/packages/wp-content/plugins/${PLUGIN}\","
done
}
function themes {
for THEME in $(find packages/wp-content/themes -mindepth 1 -maxdepth 1 -type d -printf '%f\n'); do
echo " \"/var/www/html/wp-content/themes/${THEME}\":\"\${workspaceFolder}/packages/wp-content/themes/${THEME}\","
done
}
# generate launch configuration
cat << EOF > '.vscode/launch.json'
{
// THIS FILE IS MACHINE GENERATED by .wp-env-afterStart.sh - DO NOT EDIT!
// If you need to confgure additional launch configurations consider defining them in a vscode *.code-workspace file
"version": "0.2.0",
"configurations": [
{
"name": "wp-env",
"type": "php",
"request": "launch",
"port": 9003,
"stopOnEntry": false, // set to true for debugging this launch configuration
"log": false, // set to true to get extensive xdebug logs
"pathMappings": {
$(plugins)
$(themes)
// "/var/www/html/wp-content/plugins/gutenberg": "\${workspaceFolder}/${WPENV_INSTALLPATH}/gutenberg",
"/var/www/html": "\${workspaceFolder}/${WPENV_INSTALLPATH}/WordPress",
}
}
]
}
EOF
# generate settings.json
cat << EOF > '.vscode/settings.json'
{
"intelephense.files.exclude": [
"**/.git/**",
"**/.svn/**",
"**/.hg/**",
"**/CVS/**",
"**/.DS_Store/**",
"**/node_modules/**",
"**/bower_components/**",
"**/vendor/**/{Tests,tests}/**",
"**/.history/**",
"**/vendor/**/vendor/**",
"**/dist/**",
"**/buid/**",
],
"search.exclude": {
"**/node_modules": true,
"**/build/**" : true,
"**/build-module/**" : true
},
"intelephense.environment.includePaths": [
"${WPENV_INSTALLPATH}/WordPress"
],
"git.autoRepositoryDetection": false,
"json.schemas": [
{
"fileMatch": ["jsonschema.json", "*schema.json"],
"url": "https://json-schema.org/draft/2019-09/schema"
},
{
"fileMatch": ["tsconfig.json"],
"url": "https://json.schemastore.org/tsconfig"
}
],
"[html]": {
"editor.formatOnSave": false
}
}
EOF