@caweb/cli 1.0.3 → 1.0.5

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
@@ -1,15 +1,150 @@
1
1
  # caweb-cli
2
- `caweb-cli` rapidly sets up a local WordPress environment using [wp-env](https://www.npmjs.com/package/@wordpress/env), fully configured to the [CAWebPublishing Service](https://caweb.cdt.ca.gov/). The cli will automatically generate the necessary [.wp-env.json](https://www.npmjs.com/package/@wordpress/env#wp-envjson) file, to override or add additional configuration options use the [.wp-env.override.json](https://www.npmjs.com/package/@wordpress/env#wp-envoverridejson) file.
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
- Starts the CAWebPublishing WordPress Environment.
14
- ### `caweb shell`
15
- Open a shell session in the WordPress environment.
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
- // rewrite and flush permalink structure.
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
- wpGreen(
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: 'If passed, the network will use subdomains, instead of subdirectories. Doesnt work with localhost’.',
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
  };
@@ -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 { convertToMultisite } = require('../wordpress');
31
+ const { configureWordPress } = require('../wordpress');
32
32
 
33
33
  /**
34
34
  * Promisified dependencies
@@ -115,26 +115,10 @@ module.exports = async function start({
115
115
  await sleep( 4000 );
116
116
  }
117
117
 
118
-
119
118
  // Download any resources required for CAWeb.
120
119
  if( ! bare ){
121
120
  await downloadSources({spinner, config});
122
121
  }
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
122
 
139
123
  // Write docker-compose.override.yml file to workDirectoryPath.
140
124
  await writeFile(
@@ -142,7 +126,27 @@ module.exports = async function start({
142
126
  yaml.dump( buildDockerComposeConfig(workDirectoryPath) )
143
127
  );
144
128
 
145
- spinner.text = 'Configuring CAWebPublishing Environments...';
129
+ // We need to bring the WordPress and CLI instances up again so they pick up
130
+ // any config changes that may have been added to the docker-compose.override.yml.
131
+ await dockerCompose.upMany(
132
+ [
133
+ 'wordpress', 'tests-wordpress',
134
+ 'cli', 'tests-cli'
135
+ ], {
136
+ cwd: workDirectoryPath,
137
+ commandOptions: ['--build', '--force-recreate'],
138
+ log: debug
139
+ })
140
+
141
+ // Make additional WordPress Configurations.
142
+ await Promise.all( [
143
+ retry( () => configureWordPress( 'development', config, spinner, multisite, subdomain ), {
144
+ times: 2,
145
+ } ),
146
+ retry( () => configureWordPress( 'tests', config, spinner, multisite, subdomain ), {
147
+ times: 2,
148
+ } )
149
+ ] );
146
150
 
147
151
  // Make CAWeb WordPress Configurations.
148
152
  await Promise.all( [
@@ -157,13 +161,9 @@ module.exports = async function start({
157
161
  // Start phpMyAdmin Service.
158
162
  spinner.text = 'Starting phpMyAdmin Service';
159
163
 
160
- // We need to bring the WordPress instances up again so they pick up
161
- // any config changes that may have been added to the docker-compose.override.yml.
162
164
  await dockerCompose.upMany(
163
165
  [
164
166
  'phpmyadmin','tests-phpmyadmin',
165
- 'wordpress', 'tests-wordpress',
166
- 'cli', 'tests-cli'
167
167
  ], {
168
168
  cwd: workDirectoryPath,
169
169
  commandOptions: ['--build', '--force-recreate'],
@@ -172,7 +172,7 @@ module.exports = async function start({
172
172
 
173
173
  spinner.prefixText = preText +
174
174
  `phpMyAdmin development site started at http://localhost:8080\n` +
175
- `phpMyAdmin development site started at http://localhost:9090\n\n`;
175
+ `phpMyAdmin test site started at http://localhost:9090\n\n`;
176
176
 
177
177
  spinner.text = 'Done!';
178
178
 
@@ -9,6 +9,8 @@ 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' );
13
+ const yaml = require( 'js-yaml' );
12
14
 
13
15
  /**
14
16
  * Internal dependencies
@@ -16,7 +18,7 @@ const run = require('@wordpress/env/lib/commands/run');
16
18
  const {
17
19
  runDockerCmds,
18
20
  } = require('../docker');
19
-
21
+
20
22
  const {
21
23
  buildWPEnvConfig,
22
24
  buildDockerComposeConfig
@@ -63,8 +65,16 @@ module.exports = async function test({
63
65
  try {
64
66
  const config = await loadConfig(path.resolve('.'));
65
67
  const {WP_PERMALINK} = config.env[ environment ].config
66
-
68
+ const { workDirectoryPath} = config;
69
+ const {name} = getHostUser();
70
+ const containerName = path.basename(workDirectoryPath) + ('tests' === environment ? '-tests' : '') + '-cli';
71
+ //const containerID = await execSync(`docker ps -qf "name=${containerName}"`).toString().trim();
72
+
67
73
  spinner.text = "Testing code...";
74
+
75
+
76
+ spinner.text = 'Completed Testing code...'
77
+
68
78
  /*
69
79
  let result = await runDockerCmds(
70
80
  environment,
@@ -79,7 +89,6 @@ module.exports = async function test({
79
89
  }
80
90
  */
81
91
 
82
- spinner.text = 'Completed Testing code...'
83
92
 
84
93
  } catch(error) {
85
94
  console.log(error)
package/lib/configs.js CHANGED
@@ -4,8 +4,15 @@
4
4
  const path = require( 'path' );
5
5
  const fs = require('fs-extra');
6
6
  const pkg = require( '../package.json' );
7
+ const yaml = require( 'js-yaml' );
8
+ const getHostUser = require( '@wordpress/env/lib/get-host-user' );
7
9
 
8
10
 
11
+ /**
12
+ * Promisified dependencies
13
+ */
14
+ const { writeFile } = fs.promises;
15
+
9
16
  /**
10
17
  * Build .wp-env.json
11
18
  *
@@ -44,6 +51,11 @@ const buildWPEnvConfig = (bare, multisite) => {
44
51
  * @returns object
45
52
  */
46
53
  const buildDockerComposeConfig = (workDirectoryPath) => {
54
+ const {name} = getHostUser();
55
+
56
+ // generate cli config file for cli containers.
57
+ generateCLIConfig(workDirectoryPath);
58
+
47
59
  let dockerConfig = {
48
60
  version: '3.7',
49
61
  services: {
@@ -68,6 +80,32 @@ const buildDockerComposeConfig = (workDirectoryPath) => {
68
80
  MEMORY_LIMIT: '5G',
69
81
  MAX_EXECUTION_TIME: 7200
70
82
  }
83
+ },
84
+ cli: {
85
+ build: {
86
+ context: '.',
87
+ dockerfile: 'CLI.Dockerfile'
88
+ },
89
+ volumes: [ path.join(workDirectoryPath, 'config.yml') + `:/home/${name}/.wp-cli/config.yml` ]
90
+ },
91
+ "tests-cli": {
92
+ build: {
93
+ context: '.',
94
+ dockerfile: 'Tests-CLI.Dockerfile'
95
+ },
96
+ volumes: [ path.join(workDirectoryPath, 'config.yml') + `:/home/${name}/.wp-cli/config.yml`]
97
+ },
98
+ wordpress: {
99
+ build: {
100
+ context: '.',
101
+ dockerfile: 'WordPress.Dockerfile'
102
+ }
103
+ },
104
+ "tests-wordpress": {
105
+ build: {
106
+ context: '.',
107
+ dockerfile: 'Tests-WordPress.Dockerfile'
108
+ }
71
109
  }
72
110
  }
73
111
 
@@ -87,40 +125,56 @@ const buildDockerComposeConfig = (workDirectoryPath) => {
87
125
 
88
126
  // Add extra volumes to WordPress instances.
89
127
  if( extraVolumes.length ){
90
-
91
128
  dockerConfig.services.wordpress = {
92
- build: {
93
- context: '.',
94
- dockerfile: 'WordPress.Dockerfile'
95
- },
96
- volumes: extraVolumes,
129
+ ...dockerConfig.services.wordpress,
130
+ volumes: [
131
+ ...extraVolumes
132
+ ],
97
133
  };
98
134
  dockerConfig.services.cli = {
99
- build: {
100
- context: '.',
101
- dockerfile: 'CLI.Dockerfile'
102
- },
103
- volumes: extraVolumes,
135
+ ...dockerConfig.services.cli,
136
+ volumes: [
137
+ ...dockerConfig.services.cli.volumes,
138
+ ...extraVolumes
139
+ ],
104
140
  };
105
141
  dockerConfig.services['tests-wordpress'] = {
106
- build: {
107
- context: '.',
108
- dockerfile: 'Tests-WordPress.Dockerfile'
109
- },
110
- volumes: extraVolumes,
142
+ ...dockerConfig.services['tests-wordpress'],
143
+ volumes: [
144
+ ...extraVolumes
145
+ ],
111
146
  };
112
147
  dockerConfig.services['tests-cli'] = {
113
- build: {
114
- context: '.',
115
- dockerfile: 'Tests-CLI.Dockerfile'
116
- },
117
- volumes: extraVolumes,
148
+ ...dockerConfig.services['tests-cli'],
149
+ volumes: [
150
+ ...dockerConfig.services['tests-cli'].volumes,
151
+ ...extraVolumes
152
+ ],
118
153
  };
154
+
119
155
  }
120
156
 
121
157
  return dockerConfig;
122
158
  }
123
159
 
160
+ /**
161
+ * Generate config.yml
162
+ *
163
+ * @param {string} workDirectoryPath Path to the work directory located in ~/.wp-env.
164
+ *
165
+ * @returns void
166
+ */
167
+ async function generateCLIConfig(workDirectoryPath){
168
+ const yml = {
169
+ path: '/var/www/html',
170
+ apache_modules: ['mod_rewrite']
171
+ };
172
+
173
+ await writeFile(
174
+ path.join(workDirectoryPath, 'config.yml'),
175
+ yaml.dump(yml));
176
+ }
177
+
124
178
  module.exports = {
125
179
  buildWPEnvConfig,
126
180
  buildDockerComposeConfig
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, DIVI_BUILDER_OPTIONS, DIVI_UPDATE_OPTIONS } = require('./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 config options.
70
- Object.entries(config.env[ environment ].config).forEach(([k,v]) => {
71
- // if the option is prefixed with ET_.
72
- if ( `${k}`.startsWith('ET_') ){
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( undefined !== DIVI_OPTIONS[k] ){
76
- diviOptions[DIVI_OPTIONS[k].name] = v;
80
+ if( 'et_divi' === group ){
81
+ diviOptions[data.name] = option_value;
77
82
  // is a valid Divi Builder Option.
78
- }else if( undefined !== DIVI_BUILDER_OPTIONS[k] ){
79
- diviBuilderOptions[DIVI_BUILDER_OPTIONS[k].name] = v;
83
+ }else if( 'et_bfb_settings' === group ){
84
+ diviBuilderOptions[data.name] = option_value;
80
85
  // is a valid Divi Update Option.
81
- }else if( undefined !== DIVI_UPDATE_OPTIONS[k] ){
82
- diviUpdateOptions[DIVI_UPDATE_OPTIONS[k].name] = v;
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/options.js CHANGED
@@ -189,73 +189,71 @@ const CAWEB_OPTIONS = {
189
189
  }
190
190
 
191
191
  const DIVI_OPTIONS = {
192
- ET_DYNAMIC_MODULE: {
193
- name: 'divi_dynamic_module_framework',
194
- defaultValue: 'on',
195
- label: 'Dynamic Module Framework'
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
- ET_DYNAMIC_CSS: {
198
- name: 'divi_dynamic_css',
199
- defaultValue: 'on',
200
- label: 'Dynamic CSS'
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
- ET_CRITICAL_CSS: {
203
- name: 'divi_critical_css',
204
- defaultValue: 'on',
205
- label: 'Critical CSS'
206
- },
207
- ET_DYNAMIC_JS: {
208
- name: 'divi_dynamic_js_libraries',
209
- defaultValue: 'on',
210
- label: 'Dynamic JavaScript Libraries'
211
- },
212
- ET_CLASSIC_EDITOR: {
213
- name: 'et_enable_classic_editor',
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,8 @@
1
1
  'use strict';
2
2
  const { writeFile } = require('fs-extra');
3
3
  const path = require( 'path' );
4
+ const { execSync } = require( 'child_process' );
5
+
4
6
  /**
5
7
  * External dependencies
6
8
  */
@@ -113,8 +115,43 @@ async function generateHTAccess(environment, workDirectoryPath, subdomain){
113
115
  await writeFile(path.join(workDirectoryPath, folder, '.htaccess'), htaccess);
114
116
 
115
117
  }
118
+ /**
119
+ * Configures WordPress for the given environment by installing WordPress,
120
+ * activating all plugins, and activating the first theme. These steps are
121
+ * performed sequentially so as to not overload the WordPress instance.
122
+ *
123
+ * @param {WPEnvironment} environment The environment to configure. Either 'development' or 'tests'.
124
+ * @param {WPConfig} config The wp-env config object.
125
+ * @param {Object} spinner A CLI spinner which indicates progress.
126
+ * @param {boolean} multisite True if converting to multisite.
127
+ * @param {boolean} subdomain True if converting to multisite subdomain.
128
+ */
129
+ async function configureWordPress(environment, config, spinner, multisite, subdomain){
130
+ const { workDirectoryPath} = config;
131
+ const {
132
+ WP_PERMALINK
133
+ } = config.env[ environment ].config
134
+
135
+
136
+ // Convert to multisite if flag was passed.
137
+ if( multisite ){
138
+ spinner.text = 'Converting to multisite ' + ( subdomain ? 'subdomain' : 'subdirectory') + '...'
139
+
140
+ await convertToMultisite( environment, config, subdomain )
141
+ }
142
+
143
+ // rewrite and flush permalink structure.
144
+ await runDockerCmds(
145
+ environment,
146
+ [
147
+ `wp rewrite structure ${WP_PERMALINK} --hard`
148
+ ],
149
+ config
150
+ );
151
+ }
116
152
 
117
153
  module.exports = {
154
+ configureWordPress,
118
155
  isMultisite,
119
156
  convertToMultisite,
120
157
  generateHTAccess
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caweb/cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
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
- "test": "echo \"Error: run tests from root\" && exit 0",
20
- "prelocaltest": "npm uninstall @caweb/cli",
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": "^8.11.0",
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.3.2",
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
  }