@caweb/cli 1.0.2 → 1.0.4
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 +143 -8
- package/lib/caweb.js +3 -9
- package/lib/cli.js +4 -12
- package/lib/commands/start.js +11 -19
- package/lib/commands/test.js +5 -1
- package/lib/config.yml +3 -0
- package/lib/divi.js +20 -14
- package/lib/download-sources.js +21 -10
- package/lib/options.js +60 -62
- package/lib/wordpress.js +45 -0
- package/package.json +6 -17
package/README.md
CHANGED
|
@@ -1,15 +1,150 @@
|
|
|
1
1
|
# caweb-cli
|
|
2
|
-
`caweb-cli`
|
|
2
|
+
`caweb-cli` utilizes [wp-env](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/) in the background; to rapidly set up a local WordPress environment, fully configured for the [CAWebPublishing Service](https://caweb.cdt.ca.gov/). The cli will automatically generate the necessary [.wp-env.json](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/#wp-env-json) file, to override or add additional configuration options use the [.wp-env.override.json](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/#wp-env-override-json) file.
|
|
3
3
|
|
|
4
4
|
## Additional Features
|
|
5
|
-
- phpMyAdmin Service
|
|
6
5
|
- Downloads and configures the [CAWeb Theme](https://github.com/CA-cODE-Works/CAWeb)
|
|
7
|
-
- Downloads and configures the [Divi Theme](https://www.elegantthemes.com/gallery/divi/) (*requires valid ElegantThemes Username and API Key*)
|
|
6
|
+
- Downloads and configures the [Divi Theme](https://www.elegantthemes.com/gallery/divi/) (*requires valid ElegantThemes Username and API Key*)
|
|
7
|
+
- Adds phpMyAdmin Service for both WordPress environments. (Username: <strong>bold</strong> , Password: <strong>password</strong>)
|
|
8
|
+
-- phpMyAdmin development site starts at http://localhost:8080
|
|
9
|
+
-- phpMyAdmin test site started at http://localhost:9090
|
|
8
10
|
|
|
11
|
+
- Adds config.yml to both cli containers
|
|
12
|
+
<pre>
|
|
13
|
+
path: /var/www/html
|
|
14
|
+
apache_modules:
|
|
15
|
+
- mod_rewrite
|
|
16
|
+
</pre>
|
|
9
17
|
## Command Reference
|
|
10
|
-
`caweb-cli` is a wrapper for [wp-env](https://www.npmjs.com/package/@wordpress/env); therefore, all commands from wp-env are readily available, for more information on those commands [see](https://www.npmjs.com/package/@wordpress/env#command-referenced). ***Note:** substitute `wp-env` command with `caweb`.
|
|
11
|
-
|
|
12
18
|
### `caweb start`
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
Generates the required wp-env.json, starts the WordPress environment, downloads any CAWebPublishing sources and approved plugins.
|
|
20
|
+
<pre>
|
|
21
|
+
caweb start
|
|
22
|
+
|
|
23
|
+
Options:
|
|
24
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
25
|
+
--update Download source updates and apply WordPress configuration.
|
|
26
|
+
[boolean] [default: false]
|
|
27
|
+
--xdebug Enables Xdebug. If not passed, Xdebug is turned off. If no
|
|
28
|
+
modes are set, uses "debug". You may set multiple Xdebug
|
|
29
|
+
modes by passing them in a comma-separated list:
|
|
30
|
+
`--xdebug=develop,coverage`. See
|
|
31
|
+
https://xdebug.org/docs/all_settings#mode for information
|
|
32
|
+
about Xdebug modes. [string]
|
|
33
|
+
--scripts Execute any configured lifecycle scripts.
|
|
34
|
+
[boolean] [default: true]
|
|
35
|
+
--bare True if excluding any downloads from CAWeb, use this if you
|
|
36
|
+
want to use a local version of the CAWeb Theme,
|
|
37
|
+
Configurations will still be applied.
|
|
38
|
+
[boolean] [default: false]
|
|
39
|
+
-m, --multisite True if converting to multisite. [boolean] [default: false]
|
|
40
|
+
--subdomain If passed, the network will use subdomains, instead of
|
|
41
|
+
subdirectories. Doesn't work with 'localhost', make sure to
|
|
42
|
+
set Port to 80. [boolean] [default: false]
|
|
43
|
+
</pre>
|
|
44
|
+
### `caweb stop`
|
|
45
|
+
<pre>
|
|
46
|
+
caweb stop
|
|
47
|
+
|
|
48
|
+
Stops running WordPress for development and tests and frees the ports.
|
|
49
|
+
|
|
50
|
+
Options:
|
|
51
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
52
|
+
</pre>
|
|
53
|
+
### `caweb clean [environment]`
|
|
54
|
+
<pre>
|
|
55
|
+
caweb clean [environment]
|
|
56
|
+
|
|
57
|
+
Cleans the WordPress databases.
|
|
58
|
+
|
|
59
|
+
Positionals:
|
|
60
|
+
environment Which environments' databases to clean.
|
|
61
|
+
[string] [choices: "all", "development", "tests"] [default: "tests"]
|
|
62
|
+
|
|
63
|
+
Options:
|
|
64
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
65
|
+
--scripts Execute any configured lifecycle scripts. [boolean] [default: true]
|
|
66
|
+
</pre>
|
|
67
|
+
### `caweb run <container> [command...]`
|
|
68
|
+
<pre>
|
|
69
|
+
caweb run <container> [command...]
|
|
70
|
+
|
|
71
|
+
Runs an arbitrary command in one of the underlying Docker containers. A double
|
|
72
|
+
dash can be used to pass arguments to the container without parsing them. This
|
|
73
|
+
is necessary if you are using an option that is defined below. You can use
|
|
74
|
+
`bash` to open a shell session and both `composer` and `phpunit` are available
|
|
75
|
+
in all WordPress and CLI containers. WP-CLI is also available in the CLI
|
|
76
|
+
containers.
|
|
77
|
+
|
|
78
|
+
Positionals:
|
|
79
|
+
container The underlying Docker service to run the command on.
|
|
80
|
+
[string] [required] [choices: "mysql", "tests-mysql", "wordpress",
|
|
81
|
+
"tests-wordpress", "cli", "tests-cli"]
|
|
82
|
+
command The command to run. [array] [default: []]
|
|
83
|
+
|
|
84
|
+
Options:
|
|
85
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
86
|
+
--env-cwd The command's working directory inside of the container. Paths
|
|
87
|
+
without a leading slash are relative to the WordPress root.
|
|
88
|
+
[string] [default: "."]
|
|
89
|
+
</pre>
|
|
90
|
+
### `caweb destroy`
|
|
91
|
+
<pre>
|
|
92
|
+
caweb destroy
|
|
93
|
+
|
|
94
|
+
Destroy the WordPress environment. Deletes docker containers, volumes, and
|
|
95
|
+
networks associated with the WordPress environment and removes local files.
|
|
96
|
+
|
|
97
|
+
Options:
|
|
98
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
99
|
+
--scripts Execute any configured lifecycle scripts. [boolean] [default: true]
|
|
100
|
+
</pre>
|
|
101
|
+
### `caweb logs [environment]`
|
|
102
|
+
<pre>
|
|
103
|
+
caweb logs [environment]
|
|
104
|
+
|
|
105
|
+
displays PHP and Docker logs for given WordPress environment.
|
|
106
|
+
|
|
107
|
+
Positionals:
|
|
108
|
+
environment Which environment to display the logs from.
|
|
109
|
+
[string] [choices: "development", "tests", "all"] [default: "development"]
|
|
110
|
+
|
|
111
|
+
Options:
|
|
112
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
113
|
+
--watch Watch for logs as they happen. [boolean] [default: true]
|
|
114
|
+
</pre>
|
|
115
|
+
### `caweb install-path`
|
|
116
|
+
<pre>
|
|
117
|
+
caweb install-path
|
|
118
|
+
|
|
119
|
+
Get the path where all of the environment files are stored. This includes the
|
|
120
|
+
Docker files, WordPress, PHPUnit files, and any sources that were downloaded.
|
|
121
|
+
|
|
122
|
+
Options:
|
|
123
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
124
|
+
</pre>
|
|
125
|
+
### `caweb shell [environment]`
|
|
126
|
+
<pre>
|
|
127
|
+
caweb shell [environment]
|
|
128
|
+
|
|
129
|
+
Open shell terminal in WordPress environment.
|
|
130
|
+
|
|
131
|
+
Positionals:
|
|
132
|
+
environment Which environment to open terminal in.
|
|
133
|
+
[string] [choices: "development", "tests"] [default: "development"]
|
|
134
|
+
|
|
135
|
+
Options:
|
|
136
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
137
|
+
</pre>
|
|
138
|
+
### `caweb update-plugins [environment]`
|
|
139
|
+
<pre>
|
|
140
|
+
caweb update-plugins [environment]
|
|
141
|
+
|
|
142
|
+
Updates all plugins in the WordPress environment.
|
|
143
|
+
|
|
144
|
+
Positionals:
|
|
145
|
+
environment Which environment to update.
|
|
146
|
+
[string] [choices: "development", "tests"] [default: "development"]
|
|
147
|
+
|
|
148
|
+
Options:
|
|
149
|
+
--debug Enable debug output. [boolean] [default: false]
|
|
150
|
+
</pre>
|
package/lib/caweb.js
CHANGED
|
@@ -62,6 +62,8 @@ async function configureCAWeb( environment, config, spinner ) {
|
|
|
62
62
|
|
|
63
63
|
// if our theme is active.
|
|
64
64
|
if( false !== isThemeActivated ){
|
|
65
|
+
spinner.text = `Configuring CAWebPublishing ${environment} Environment...`;
|
|
66
|
+
|
|
65
67
|
let themeOptions = [];
|
|
66
68
|
|
|
67
69
|
// iterate over config options.
|
|
@@ -114,15 +116,7 @@ async function configureCAWeb( environment, config, spinner ) {
|
|
|
114
116
|
)
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
|
|
118
|
-
await runDockerCmds(
|
|
119
|
-
environment,
|
|
120
|
-
[
|
|
121
|
-
`wp rewrite structure ${WP_PERMALINK} --hard`,
|
|
122
|
-
'wp rewrite flush --hard'
|
|
123
|
-
],
|
|
124
|
-
config
|
|
125
|
-
);
|
|
119
|
+
|
|
126
120
|
}
|
|
127
121
|
|
|
128
122
|
module.exports = {
|
package/lib/cli.js
CHANGED
|
@@ -64,15 +64,7 @@ module.exports = function cli() {
|
|
|
64
64
|
// we are overwriting the default wp-env start command with our own.
|
|
65
65
|
yargs.command(
|
|
66
66
|
'start',
|
|
67
|
-
|
|
68
|
-
chalk`Starts WordPress for development on port {bold.underline ${ terminalLink(
|
|
69
|
-
'8888',
|
|
70
|
-
'http://localhost:8888'
|
|
71
|
-
) }} (override with WP_ENV_PORT) and tests on port {bold.underline ${ terminalLink(
|
|
72
|
-
'8889',
|
|
73
|
-
'http://localhost:8889'
|
|
74
|
-
) }} (override with WP_ENV_TESTS_PORT). The current working directory must be a WordPress installation, a plugin, a theme, or contain a .wp-env.json file. After first install, use the '--update' flag to download updates to mapped sources and to re-apply WordPress configuration options.`
|
|
75
|
-
),
|
|
67
|
+
false,
|
|
76
68
|
( args ) => {
|
|
77
69
|
args.option( 'update', {
|
|
78
70
|
type: 'boolean',
|
|
@@ -104,7 +96,7 @@ module.exports = function cli() {
|
|
|
104
96
|
} );
|
|
105
97
|
args.option( 'subdomain', {
|
|
106
98
|
type: 'boolean',
|
|
107
|
-
describe:
|
|
99
|
+
describe: "If passed, the network will use subdomains, instead of subdirectories. Doesn't work with 'localhost', make sure to set Port to 80.",
|
|
108
100
|
default: false,
|
|
109
101
|
} );
|
|
110
102
|
},
|
|
@@ -142,7 +134,7 @@ module.exports = function cli() {
|
|
|
142
134
|
)
|
|
143
135
|
|
|
144
136
|
// Test Command.
|
|
145
|
-
yargs.command(
|
|
137
|
+
/*yargs.command(
|
|
146
138
|
'test [environment]',
|
|
147
139
|
'Test commands on a WordPress environment',
|
|
148
140
|
(args) => {
|
|
@@ -155,7 +147,7 @@ module.exports = function cli() {
|
|
|
155
147
|
|
|
156
148
|
},
|
|
157
149
|
withSpinner( env.test )
|
|
158
|
-
)
|
|
150
|
+
)*/
|
|
159
151
|
|
|
160
152
|
return yargs;
|
|
161
153
|
};
|
package/lib/commands/start.js
CHANGED
|
@@ -28,7 +28,7 @@ const CONFIG_CACHE_KEY = 'config_checksum';
|
|
|
28
28
|
const { configureCAWeb } = require('../caweb');
|
|
29
29
|
const { buildWPEnvConfig, buildDockerComposeConfig } = require('../configs');
|
|
30
30
|
const {downloadSources } = require('../download-sources');
|
|
31
|
-
const {
|
|
31
|
+
const { configureWordPress } = require('../wordpress');
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Promisified dependencies
|
|
@@ -115,26 +115,20 @@ module.exports = async function start({
|
|
|
115
115
|
await sleep( 4000 );
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// Make additional WordPress Configurations.
|
|
119
|
+
await Promise.all( [
|
|
120
|
+
retry( () => configureWordPress( 'development', config, spinner, multisite, subdomain ), {
|
|
121
|
+
times: 2,
|
|
122
|
+
} ),
|
|
123
|
+
retry( () => configureWordPress( 'tests', config, spinner, multisite, subdomain ), {
|
|
124
|
+
times: 2,
|
|
125
|
+
} )
|
|
126
|
+
] );
|
|
118
127
|
|
|
119
128
|
// Download any resources required for CAWeb.
|
|
120
129
|
if( ! bare ){
|
|
121
130
|
await downloadSources({spinner, config});
|
|
122
131
|
}
|
|
123
|
-
|
|
124
|
-
// if multisite.
|
|
125
|
-
if( multisite ){
|
|
126
|
-
spinner.text = 'Converting to multisite ' + ( subdomain ? 'subdomain' : 'subdirectory') + '...'
|
|
127
|
-
|
|
128
|
-
await Promise.all( [
|
|
129
|
-
retry( () => convertToMultisite( 'development', config, subdomain ), {
|
|
130
|
-
times: 2,
|
|
131
|
-
} ),
|
|
132
|
-
retry( () => convertToMultisite( 'tests', config, subdomain ), {
|
|
133
|
-
times: 2,
|
|
134
|
-
} ),
|
|
135
|
-
] );
|
|
136
|
-
|
|
137
|
-
}
|
|
138
132
|
|
|
139
133
|
// Write docker-compose.override.yml file to workDirectoryPath.
|
|
140
134
|
await writeFile(
|
|
@@ -142,8 +136,6 @@ module.exports = async function start({
|
|
|
142
136
|
yaml.dump( buildDockerComposeConfig(workDirectoryPath) )
|
|
143
137
|
);
|
|
144
138
|
|
|
145
|
-
spinner.text = 'Configuring CAWebPublishing Environments...';
|
|
146
|
-
|
|
147
139
|
// Make CAWeb WordPress Configurations.
|
|
148
140
|
await Promise.all( [
|
|
149
141
|
retry( () => configureCAWeb( 'development', config, spinner ), {
|
|
@@ -172,7 +164,7 @@ module.exports = async function start({
|
|
|
172
164
|
|
|
173
165
|
spinner.prefixText = preText +
|
|
174
166
|
`phpMyAdmin development site started at http://localhost:8080\n` +
|
|
175
|
-
`phpMyAdmin
|
|
167
|
+
`phpMyAdmin test site started at http://localhost:9090\n\n`;
|
|
176
168
|
|
|
177
169
|
spinner.text = 'Done!';
|
|
178
170
|
|
package/lib/commands/test.js
CHANGED
|
@@ -9,6 +9,7 @@ const { execSync } = require( 'child_process' );
|
|
|
9
9
|
const dockerCompose = require( 'docker-compose' );
|
|
10
10
|
const loadConfig = require( '@wordpress/env/lib/config/load-config' );
|
|
11
11
|
const run = require('@wordpress/env/lib/commands/run');
|
|
12
|
+
const getHostUser = require( '@wordpress/env/lib/get-host-user' );
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
@@ -63,8 +64,11 @@ module.exports = async function test({
|
|
|
63
64
|
try {
|
|
64
65
|
const config = await loadConfig(path.resolve('.'));
|
|
65
66
|
const {WP_PERMALINK} = config.env[ environment ].config
|
|
66
|
-
|
|
67
|
+
const { workDirectoryPath} = config;
|
|
68
|
+
const {name} = getHostUser();
|
|
69
|
+
|
|
67
70
|
spinner.text = "Testing code...";
|
|
71
|
+
|
|
68
72
|
/*
|
|
69
73
|
let result = await runDockerCmds(
|
|
70
74
|
environment,
|
package/lib/config.yml
ADDED
package/lib/divi.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
const { runDockerCmds } = require('./docker');
|
|
11
|
-
const { DIVI_OPTIONS
|
|
11
|
+
const { DIVI_OPTIONS } = require('./options');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -66,23 +66,29 @@ async function configureDivi( environment, config, spinner ) {
|
|
|
66
66
|
diviBuilderOptions = diviBuilderOptions ? JSON.parse( diviBuilderOptions ) : {};
|
|
67
67
|
diviUpdateOptions = undefined !== diviUpdateOptions && diviUpdateOptions ? JSON.parse( diviUpdateOptions ) : {};
|
|
68
68
|
|
|
69
|
-
// iterate over
|
|
70
|
-
Object.entries(
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
// iterate over mapped Divi option groups.
|
|
70
|
+
Object.entries(DIVI_OPTIONS).forEach(([group, options]) => {
|
|
71
|
+
// iterate over each group options.
|
|
72
|
+
Object.entries(options).forEach(([key, data]) => {
|
|
73
|
+
|
|
74
|
+
// if user config has a Divi option variable use that, otherwise use our default.
|
|
75
|
+
let option_value = undefined !== config.env[ environment ].config[key] ?
|
|
76
|
+
config.env[ environment ].config[key] :
|
|
77
|
+
data.defaultValue;
|
|
78
|
+
|
|
74
79
|
// is a valid Divi Option.
|
|
75
|
-
if(
|
|
76
|
-
diviOptions[
|
|
80
|
+
if( 'et_divi' === group ){
|
|
81
|
+
diviOptions[data.name] = option_value;
|
|
77
82
|
// is a valid Divi Builder Option.
|
|
78
|
-
}else if(
|
|
79
|
-
diviBuilderOptions[
|
|
83
|
+
}else if( 'et_bfb_settings' === group ){
|
|
84
|
+
diviBuilderOptions[data.name] = option_value;
|
|
80
85
|
// is a valid Divi Update Option.
|
|
81
|
-
}else if(
|
|
82
|
-
diviUpdateOptions[
|
|
86
|
+
}else if( 'et_automatic_updates_options' === group ){
|
|
87
|
+
diviUpdateOptions[data.name] = option_value;
|
|
83
88
|
}
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
|
|
90
|
+
})
|
|
91
|
+
})
|
|
86
92
|
|
|
87
93
|
// parse option object back to string.
|
|
88
94
|
diviOptions = JSON.stringify( diviOptions );
|
package/lib/download-sources.js
CHANGED
|
@@ -58,16 +58,7 @@ async function downloadSources(
|
|
|
58
58
|
let pluginDir = path.resolve(workDirectoryPath, 'plugins');
|
|
59
59
|
let themeDir = path.resolve(workDirectoryPath, 'themes');
|
|
60
60
|
|
|
61
|
-
let sources =
|
|
62
|
-
{
|
|
63
|
-
basename: 'Design System',
|
|
64
|
-
url: 'https://github.com/CA-CODE-Works/design-system-wordpress.git',
|
|
65
|
-
ref: 'main',
|
|
66
|
-
path: path.join(pluginDir, 'design-system-wordpress'),
|
|
67
|
-
clonePath: path.join(pluginDir, 'design-system-wordpress'),
|
|
68
|
-
type: 'git'
|
|
69
|
-
}
|
|
70
|
-
];
|
|
61
|
+
let sources = dowloadPlugins(pluginDir);
|
|
71
62
|
|
|
72
63
|
// Add Divi Theme and plugin to sources.
|
|
73
64
|
if( (undefined !== dev.config.ET_USERNAME &&
|
|
@@ -260,6 +251,26 @@ async function downloadZipSource( source, { onProgress, spinner, debug } ) {
|
|
|
260
251
|
onProgress( 1 );
|
|
261
252
|
}
|
|
262
253
|
|
|
254
|
+
function dowloadPlugins(pluginDir){
|
|
255
|
+
return [
|
|
256
|
+
{
|
|
257
|
+
basename: 'Design System',
|
|
258
|
+
url: 'https://github.com/CA-CODE-Works/design-system-wordpress.git',
|
|
259
|
+
ref: 'main',
|
|
260
|
+
path: path.join(pluginDir, 'design-system-wordpress'),
|
|
261
|
+
clonePath: path.join(pluginDir, 'design-system-wordpress'),
|
|
262
|
+
type: 'git'
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
basename: 'Query Monitor',
|
|
266
|
+
url: 'https://downloads.wordpress.org/plugin/query-monitor.3.15.0.zip',
|
|
267
|
+
path: path.join(pluginDir, 'query-monitor'),
|
|
268
|
+
type: 'zip',
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
|
|
263
274
|
module.exports = {
|
|
264
275
|
downloadSources
|
|
265
276
|
|
package/lib/options.js
CHANGED
|
@@ -189,73 +189,71 @@ const CAWEB_OPTIONS = {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
const DIVI_OPTIONS = {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
'et_divi': {
|
|
193
|
+
ET_DYNAMIC_MODULE: {
|
|
194
|
+
name: 'divi_dynamic_module_framework',
|
|
195
|
+
defaultValue: 'on',
|
|
196
|
+
label: 'Dynamic Module Framework'
|
|
197
|
+
},
|
|
198
|
+
ET_DYNAMIC_CSS: {
|
|
199
|
+
name: 'divi_dynamic_css',
|
|
200
|
+
defaultValue: 'on',
|
|
201
|
+
label: 'Dynamic CSS'
|
|
202
|
+
},
|
|
203
|
+
ET_CRITICAL_CSS: {
|
|
204
|
+
name: 'divi_critical_css',
|
|
205
|
+
defaultValue: 'on',
|
|
206
|
+
label: 'Critical CSS'
|
|
207
|
+
},
|
|
208
|
+
ET_DYNAMIC_JS: {
|
|
209
|
+
name: 'divi_dynamic_js_libraries',
|
|
210
|
+
defaultValue: 'on',
|
|
211
|
+
label: 'Dynamic JavaScript Libraries'
|
|
212
|
+
},
|
|
213
|
+
ET_CLASSIC_EDITOR: {
|
|
214
|
+
name: 'et_enable_classic_editor',
|
|
215
|
+
defaultValue: 'on',
|
|
216
|
+
label: 'Enable Classic Editor'
|
|
217
|
+
},
|
|
218
|
+
ET_STATIC_CSS_GENERATION: {
|
|
219
|
+
name: 'et_pb_static_css_file',
|
|
220
|
+
defaultValue: 'on',
|
|
221
|
+
label: 'Static CSS File Generation'
|
|
222
|
+
},
|
|
223
|
+
ET_PRODUCT_TOUR: {
|
|
224
|
+
name: 'et_pb_product_tour_global',
|
|
225
|
+
defaultValue: 'off',
|
|
226
|
+
label: 'Product Tour'
|
|
227
|
+
}
|
|
196
228
|
},
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
229
|
+
'et_bfb_settings': {
|
|
230
|
+
ET_NEW_BUILDER_EXPERIENCE: {
|
|
231
|
+
name: 'enable_bfb',
|
|
232
|
+
defaultValue: 'off',
|
|
233
|
+
label: 'Enable The Latest Divi Builder Experience'
|
|
234
|
+
},
|
|
235
|
+
ET_OUTPUT_STYLES_INLINE: {
|
|
236
|
+
name: 'et_pb_css_in_footer',
|
|
237
|
+
defaultValue: 'off',
|
|
238
|
+
label: 'Output Styles Inline'
|
|
239
|
+
}
|
|
201
240
|
},
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
defaultValue: 'on',
|
|
215
|
-
label: 'Enable Classic Editor'
|
|
216
|
-
},
|
|
217
|
-
ET_STATIC_CSS_GENERATION: {
|
|
218
|
-
name: 'et_pb_static_css_file',
|
|
219
|
-
defaultValue: 'on',
|
|
220
|
-
label: 'Static CSS File Generation'
|
|
221
|
-
},
|
|
222
|
-
ET_PRODUCT_TOUR: {
|
|
223
|
-
name: 'et_pb_product_tour_global',
|
|
224
|
-
defaultValue: 'off',
|
|
225
|
-
label: 'Product Tour'
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const DIVI_BUILDER_OPTIONS = {
|
|
230
|
-
ET_NEW_BUILDER_EXPERIENCE: {
|
|
231
|
-
name: 'enable_bfb',
|
|
232
|
-
defaultValue: 'off',
|
|
233
|
-
label: 'Enable The Latest Divi Builder Experience'
|
|
234
|
-
},
|
|
235
|
-
ET_OUTPUT_STYLES_INLINE: {
|
|
236
|
-
name: 'et_pb_css_in_footer',
|
|
237
|
-
defaultValue: 'off',
|
|
238
|
-
label: 'Output Styles Inline'
|
|
241
|
+
'et_automatic_updates_options': {
|
|
242
|
+
ET_USERNAME: {
|
|
243
|
+
name: 'username',
|
|
244
|
+
defaultValue: '',
|
|
245
|
+
label: 'Username'
|
|
246
|
+
},
|
|
247
|
+
ET_API_KEY: {
|
|
248
|
+
name: 'api_key',
|
|
249
|
+
defaultValue: '',
|
|
250
|
+
label: 'API Key'
|
|
251
|
+
}
|
|
252
|
+
|
|
239
253
|
}
|
|
240
254
|
}
|
|
241
255
|
|
|
242
|
-
const DIVI_UPDATE_OPTIONS = {
|
|
243
|
-
ET_USERNAME: {
|
|
244
|
-
name: 'username',
|
|
245
|
-
defaultValue: '',
|
|
246
|
-
label: 'Username'
|
|
247
|
-
},
|
|
248
|
-
ET_API_KEY: {
|
|
249
|
-
name: 'api_key',
|
|
250
|
-
defaultValue: '',
|
|
251
|
-
label: 'API Key'
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
256
256
|
module.exports = {
|
|
257
257
|
CAWEB_OPTIONS,
|
|
258
|
-
DIVI_OPTIONS
|
|
259
|
-
DIVI_BUILDER_OPTIONS,
|
|
260
|
-
DIVI_UPDATE_OPTIONS
|
|
258
|
+
DIVI_OPTIONS
|
|
261
259
|
}
|
package/lib/wordpress.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const { writeFile } = require('fs-extra');
|
|
3
3
|
const path = require( 'path' );
|
|
4
|
+
const getHostUser = require( '@wordpress/env/lib/get-host-user' );
|
|
5
|
+
const { execSync } = require( 'child_process' );
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* External dependencies
|
|
6
9
|
*/
|
|
@@ -113,8 +116,50 @@ async function generateHTAccess(environment, workDirectoryPath, subdomain){
|
|
|
113
116
|
await writeFile(path.join(workDirectoryPath, folder, '.htaccess'), htaccess);
|
|
114
117
|
|
|
115
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Configures WordPress for the given environment by installing WordPress,
|
|
121
|
+
* activating all plugins, and activating the first theme. These steps are
|
|
122
|
+
* performed sequentially so as to not overload the WordPress instance.
|
|
123
|
+
*
|
|
124
|
+
* @param {WPEnvironment} environment The environment to configure. Either 'development' or 'tests'.
|
|
125
|
+
* @param {WPConfig} config The wp-env config object.
|
|
126
|
+
* @param {Object} spinner A CLI spinner which indicates progress.
|
|
127
|
+
* @param {boolean} multisite True if converting to multisite.
|
|
128
|
+
* @param {boolean} subdomain True if converting to multisite subdomain.
|
|
129
|
+
*/
|
|
130
|
+
async function configureWordPress(environment, config, spinner, multisite, subdomain){
|
|
131
|
+
const { workDirectoryPath} = config;
|
|
132
|
+
const {
|
|
133
|
+
WP_PERMALINK
|
|
134
|
+
} = config.env[ environment ].config
|
|
135
|
+
|
|
136
|
+
const {name} = getHostUser();
|
|
137
|
+
|
|
138
|
+
const containerName = path.basename(workDirectoryPath) + ('tests' === environment ? '-tests' : '') + '-cli';
|
|
139
|
+
const containerID = await execSync(`docker ps -qf "name=${containerName}"`).toString().trim();
|
|
140
|
+
|
|
141
|
+
// Add cli config.yml to cli container.
|
|
142
|
+
await execSync(`docker exec ${containerID} mkdir -p /home/${name}/.wp-cli/ && docker cp ./lib/config.yml ${containerID}:/home/${name}/.wp-cli/config.yml`);
|
|
143
|
+
|
|
144
|
+
// Convert to multisite if flag was passed.
|
|
145
|
+
if( multisite ){
|
|
146
|
+
spinner.text = 'Converting to multisite ' + ( subdomain ? 'subdomain' : 'subdirectory') + '...'
|
|
147
|
+
|
|
148
|
+
await convertToMultisite( environment, config, subdomain )
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// rewrite and flush permalink structure.
|
|
152
|
+
await runDockerCmds(
|
|
153
|
+
environment,
|
|
154
|
+
[
|
|
155
|
+
`wp rewrite structure ${WP_PERMALINK} --hard`
|
|
156
|
+
],
|
|
157
|
+
config
|
|
158
|
+
);
|
|
159
|
+
}
|
|
116
160
|
|
|
117
161
|
module.exports = {
|
|
162
|
+
configureWordPress,
|
|
118
163
|
isMultisite,
|
|
119
164
|
convertToMultisite,
|
|
120
165
|
generateHTAccess
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "CAWebPublishing Command Line Interface.",
|
|
5
5
|
"main": "lib/env.js",
|
|
6
6
|
"files": [
|
|
@@ -16,10 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"caweb": "caweb",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"localtest": "npm pack && npm i caweb-cli-%npm_package_version%.tgz",
|
|
22
|
-
"postlocaltest": "del caweb-cli-%npm_package_version%.tgz"
|
|
19
|
+
"local": "npm pack && npm i caweb-cli-%npm_package_version%.tgz",
|
|
20
|
+
"test": "echo \"Error: run tests from root\" && exit 0"
|
|
23
21
|
},
|
|
24
22
|
"repository": {
|
|
25
23
|
"type": "git",
|
|
@@ -39,12 +37,12 @@
|
|
|
39
37
|
},
|
|
40
38
|
"homepage": "https://github.com/CAWebPublishing/caweb-cli#readme",
|
|
41
39
|
"dependencies": {
|
|
42
|
-
"@wordpress/env": "^
|
|
40
|
+
"@wordpress/env": "^9.0.0",
|
|
43
41
|
"chalk": "^4.0.0",
|
|
44
42
|
"fs-extra": "^11.1.1"
|
|
45
43
|
},
|
|
46
44
|
"config": {
|
|
47
|
-
"WP_VER": "6.
|
|
45
|
+
"WP_VER": "6.4.2",
|
|
48
46
|
"PHP_VER": "8.1",
|
|
49
47
|
"DEFAULTS": {
|
|
50
48
|
"WP_DEFAULT_THEME": "CAWeb",
|
|
@@ -58,16 +56,7 @@
|
|
|
58
56
|
"ADMIN_COOKIE_PATH": "/",
|
|
59
57
|
"COOKIE_DOMAIN": "",
|
|
60
58
|
"COOKIEPATH": "",
|
|
61
|
-
"SITECOOKIEPATH": ""
|
|
62
|
-
"ET_DYNAMIC_MODULE": "on",
|
|
63
|
-
"ET_DYNAMIC_CSS": "on",
|
|
64
|
-
"ET_CRITICAL_CSS": "on",
|
|
65
|
-
"ET_DYNAMIC_JS": "on",
|
|
66
|
-
"ET_STATIC_CSS_GENERATION": "on",
|
|
67
|
-
"ET_OUTPUT_STYLES_INLINE": "off",
|
|
68
|
-
"ET_PRODUCT_TOUR": "off",
|
|
69
|
-
"ET_NEW_BUILDER_EXPERIENCE": "off",
|
|
70
|
-
"ET_CLASSIC_EDITOR": "on"
|
|
59
|
+
"SITECOOKIEPATH": ""
|
|
71
60
|
}
|
|
72
61
|
}
|
|
73
62
|
}
|