@caweb/cli 1.13.7 → 1.14.1

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.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import { CAWEB_OPTIONS } from'../options.js';
9
+ import { runCLICmds } from'../../helpers.js';
10
+
11
+ /**
12
+ * Activates the CAWeb Theme for the WordPress Environment if it's installed.
13
+ *
14
+ * @param {string} environment Which environment to activate the theme on.
15
+ * @param {WPConfig} config The wp-env config object.
16
+ * @param {Object} spinner A CLI spinner which indicates progress.
17
+ */
18
+ async function isCAWebActive({environment, cwd}){
19
+ return await runCLICmds({
20
+ environment,
21
+ cmds: ['wp theme is-installed CAWeb'],
22
+ cwd
23
+ });
24
+
25
+ }
26
+
27
+ /**
28
+ * Configures CAWebPublishing Service for the given environment by configure settings,
29
+ * and activating the CAWeb theme. These steps are
30
+ * performed sequentially so as to not overload the WordPress instance.
31
+ *
32
+ * @param {WPEnvironment} environment The environment to configure. Either 'development' or 'tests'.
33
+ * @param {WPConfig} config The wp-env config object.
34
+ * @param {Object} spinner A CLI spinner which indicates progress.
35
+ */
36
+ async function configureCAWeb( {environment, cwd, configs} ) {
37
+
38
+ const isThemeActivated = await isCAWebActive({environment, cwd});
39
+ let cmds = [];
40
+
41
+ // if our theme is active.
42
+ if( false !== isThemeActivated ){
43
+
44
+ // iterate over possible CAWeb Options.
45
+ for(const [k,v] of Object.entries(CAWEB_OPTIONS)){
46
+ // get option value from wp-config.php if exists.
47
+ if( configs[k] ){
48
+ cmds.push(
49
+ `wp option set '${v.name}' "${configs[k]}"`,
50
+ )
51
+ }
52
+ }
53
+ }
54
+
55
+ // return CAWeb Theme Configuration commands.
56
+ return cmds;
57
+ }
58
+
59
+ export {
60
+ isCAWebActive,
61
+ configureCAWeb,
62
+ };
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { runCLICmds } from '../../helpers.js';
5
+ import { DIVI_OPTIONS } from '../options.js';
6
+ import { isCAWebActive } from './caweb.js';
7
+
8
+
9
+ /**
10
+ * Configures Divi for CAWebPublishing Service for the given environment by configure settings.
11
+ * These steps are performed sequentially so as to not overload the WordPress instance.
12
+ *
13
+ * @param {WPEnvironment} environment The environment to configure. Either 'development' or 'tests'.
14
+ * @param {WPConfig} config The wp-env config object.
15
+ * @param {Object} spinner A CLI spinner which indicates progress.
16
+ */
17
+ async function configureDivi( {environment, cwd, configs} ) {
18
+
19
+ const isThemeActivated = await isCAWebActive( {environment, cwd} );
20
+ let cmds = [];
21
+
22
+ // if CAWeb theme is active.
23
+ if( false !== isThemeActivated ){
24
+ let diviOptions = await runCLICmds({
25
+ environment,
26
+ cmds: [ 'wp option get et_divi --format=json' ],
27
+ cwd
28
+ });
29
+
30
+ let diviBuilderOptions = await runCLICmds({
31
+ environment,
32
+ cmds: [ 'wp option get et_bfb_settings --format=json' ],
33
+ cwd
34
+ });
35
+
36
+ let diviUpdateOptions = await runCLICmds({
37
+ environment,
38
+ cmds: [ 'wp option get et_automatic_updates_options --format=json' ],
39
+ cwd
40
+ })
41
+
42
+ // parse the options into a json object.
43
+ diviOptions = typeof result === 'object' && ! diviOptions.exitCode ? JSON.parse( diviOptions ) : {};
44
+ diviBuilderOptions = typeof result === 'object' && ! diviBuilderOptions.exitCode ? JSON.parse( diviBuilderOptions ) : {};
45
+ diviUpdateOptions = typeof result === 'object' && ! diviUpdateOptions.exitCode ? JSON.parse( diviUpdateOptions ) : {};
46
+
47
+ // iterate over mapped Divi option groups.
48
+ Object.entries(DIVI_OPTIONS).forEach(([group, options]) => {
49
+ // iterate over each group options.
50
+ Object.entries(options).forEach(([key, data]) => {
51
+
52
+ // if user config has a Divi option variable use that, otherwise use our default.
53
+ let option_value = configs[key] || null;
54
+
55
+ if( null !== option_value ){
56
+ // is a valid Divi Option.
57
+ if( 'et_divi' === group ){
58
+ diviOptions[data.name] = option_value;
59
+ // is a valid Divi Builder Option.
60
+ }else if( 'et_bfb_settings' === group ){
61
+ diviBuilderOptions[data.name] = option_value;
62
+ // is a valid Divi Update Option.
63
+ }else if( 'et_automatic_updates_options' === group ){
64
+ diviUpdateOptions[data.name] = option_value;
65
+ }
66
+ }
67
+ })
68
+ })
69
+
70
+ // parse option object back to string.
71
+ diviOptions = JSON.stringify( diviOptions );
72
+ diviBuilderOptions = JSON.stringify( diviBuilderOptions );
73
+ diviUpdateOptions = JSON.stringify( diviUpdateOptions );
74
+
75
+ // update each option.
76
+ cmds.push(
77
+ `wp option update et_divi '${diviOptions}' --format=json`,
78
+ `wp option update et_bfb_settings '${diviBuilderOptions}' --format=json`,
79
+ `wp option update et_automatic_updates_options '${diviUpdateOptions}' --format=json`
80
+ );
81
+
82
+ return cmds;
83
+ }
84
+
85
+
86
+ }
87
+
88
+ export {
89
+ configureDivi
90
+ };
@@ -0,0 +1,130 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+ import { format } from 'util';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { runCLICmds } from '../../helpers.js';
12
+ import { configureWordPress } from '../wordpress.js';
13
+ import { configureCAWeb } from './caweb.js';
14
+ import { configureDivi } from './divi.js';
15
+
16
+
17
+ function processArgs( arr ){
18
+ let tmp = [];
19
+
20
+ arr.filter(Boolean).map((o) => {
21
+ return o.replaceAll("'", '').split('=').forEach((e => tmp.push(e)))
22
+ });
23
+
24
+ return tmp
25
+ }
26
+
27
+ function flagExists(flag){
28
+ return flags.includes(flag)
29
+ }
30
+
31
+ function getArgVal(flag){
32
+ return flagExists(flag) ? flags[flags.indexOf(flag) + 1] : false;
33
+ }
34
+
35
+ let flags = [].concat(
36
+ processArgs(process.argv),
37
+ // the following can be uncommented if ever needed to process those args.
38
+ // processArgs(process.argv0.split(' ')),
39
+ // processArgs(process.env)
40
+ // processArgs(process.env.NODE_OPTIONS ? process.env.NODE_OPTIONS.split(' ') : []),
41
+ )
42
+
43
+ const workingDirectoryPath = getArgVal('--cwd') ? getArgVal('--cwd') : process.cwd();
44
+
45
+ // Collect existing wp-config.php values.
46
+ process.stdout.write('Collecting CAWeb configuration data...');
47
+ let configs = {};
48
+ JSON.parse(
49
+ await runCLICmds({
50
+ environment: 'development',
51
+ cmds: ['wp config list --format=json'],
52
+ cwd: workingDirectoryPath
53
+ })
54
+ ).forEach( ( item ) => {
55
+ configs[item.name] = item.value;
56
+ });
57
+
58
+ // wp cli commands that will be ran.
59
+ // process.stdout.write(`\nConfiguring WordPress...\n`);
60
+ let cmds = [
61
+ ...await configureWordPress({
62
+ environment: 'development',
63
+ cwd: workingDirectoryPath,
64
+ multisite: flagExists('--multisite') ? getArgVal('--multisite') : false,
65
+ configs
66
+ })
67
+ ];
68
+
69
+ // Download any resources required for CAWeb.
70
+ if( ! flagExists('--bare') || ( flagExists('--bare') && getArgVal('--bare') ) ){
71
+ // Delete all default themes.
72
+ let defaultThemes = [
73
+ 'twentyten',
74
+ 'twentyeleven',
75
+ 'twentytwelve',
76
+ 'twentythirteen',
77
+ 'twentyfourteen',
78
+ 'twentyfifteen',
79
+ 'twentysixteen',
80
+ 'twentyseventeen',
81
+ 'twentynineteen',
82
+ 'twentytwenty',
83
+ 'twentytwentyone',
84
+ 'twentytwentytwo',
85
+ 'twentytwentythree',
86
+ 'twentytwentyfour',
87
+ 'twentytwentyfive'
88
+ ];
89
+ cmds.push( `wp theme delete ${defaultThemes.join(' ')} --force` );
90
+
91
+ // If Elegant Themes credentials are available, download Divi.
92
+ if( configs.ET_USERNAME && configs.ET_API_KEY ){
93
+ // generate Divi download URL.
94
+ let et_url = `https://www.elegantthemes.com/api/api_downloads.php?api_update=1&theme=%s&api_key=${configs.ET_API_KEY}&username=${configs.ET_USERNAME}`;
95
+
96
+ // add command to install Divi theme.
97
+ cmds.push( `wp theme install '${format( et_url, 'Divi' )}' --force` );
98
+
99
+ // add command to install Divi Builder plugin.
100
+ cmds.push( `wp plugin install '${format( et_url, 'divi-builder' )}' --force` );
101
+ }
102
+
103
+ // Activate CAWeb theme.
104
+ cmds.push( 'wp theme activate CAWeb' );
105
+
106
+ }
107
+
108
+
109
+ cmds.push(
110
+ ...await configureCAWeb({
111
+ environment: 'development',
112
+ cwd: workingDirectoryPath,
113
+ configs,
114
+ }),
115
+ ...await configureDivi({
116
+ environment: 'development',
117
+ cwd: workingDirectoryPath,
118
+ configs,
119
+ })
120
+ );
121
+
122
+ if( cmds.length ){
123
+ process.stdout.write(`\nConfiguring CAWeb...\n`);
124
+ await runCLICmds({
125
+ environment: 'development',
126
+ cmds,
127
+ cwd: workingDirectoryPath,
128
+ debug: true
129
+ });
130
+ }
@@ -3,38 +3,15 @@
3
3
  */
4
4
  import fs from 'fs';
5
5
  import path from 'path';
6
- import yaml from 'js-yaml';
6
+ import dns from 'dns';
7
+
7
8
  /**
8
9
  * Internal dependencies
9
10
  */
10
11
  import {appPath, runCLICmds} from '../helpers.js';
11
12
 
12
13
  /**
13
- * Checks whether WordPress environment is a multisite installation.
14
- *
15
- * @param {string} environment Which environment to check for multisite installation.
16
- * @param {WPConfig} config The wp-env config object.
17
- * @param {Object} spinner A CLI spinner which indicates progress.
18
- * @returns
19
- */
20
- async function isMultisite( environment, config, spinner ){
21
-
22
- const result = await runCLICmds(
23
- environment,
24
- [ 'wp config get MULTISITE' ],
25
- config,
26
- spinner
27
- )
28
-
29
- /**
30
- * If the constant doesn't exist the wp cli returns an exit code of 1
31
- * we have to return false, otherwise we can just return the cli result.
32
- */
33
- return typeof result === 'object' && result.exitCode ? false : result;
34
- }
35
-
36
- /**
37
- * Transforms an existing single-site installation into a multisite installation.
14
+ * Network activate all active plugins.
38
15
  *
39
16
  * @param {string} environment Which environment to convert into a multisite installation.
40
17
  * @param {WPConfig} config The wp-env config object.
@@ -42,106 +19,25 @@ async function isMultisite( environment, config, spinner ){
42
19
  * @param {Object} spinner A CLI spinner which indicates progress.
43
20
  * @returns
44
21
  */
45
- async function convertToMultisite( environment, config, subdomain, spinner ){
46
-
47
- // before we can convert to multisite all plugins must be deactivated.
48
- // first lets get all plugins
49
- let activePlugins = await runCLICmds(
22
+ async function networkActivatePlugins( {environment, cwd} ){
23
+
24
+ // first lets get all active plugins
25
+ let activePlugins = await runCLICmds({
50
26
  environment,
51
- ['wp option get active_plugins --format=json'],
52
- config,
53
- spinner
54
- )
27
+ cmds: ['wp option get active_plugins --format=json'],
28
+ cwd
29
+ })
55
30
 
56
31
  activePlugins = Object.values(JSON.parse( activePlugins ));
57
32
 
58
- // deactivate all active plugins.
59
- if( activePlugins.length ){
60
- await runCLICmds(
61
- environment,
62
- ['wp plugin deactivate ' + activePlugins.join(' ')],
63
- config,
64
- spinner
65
- )
66
- }
67
-
68
- await runCLICmds(
69
- environment,
70
- [
71
- // convert to multisite.
72
- 'wp core multisite-convert' + ( subdomain ? ' --subdomains' : '' ),
73
- ],
74
- config,
75
- spinner
76
- )
77
-
78
33
  // network activate all active plugins again.
79
34
  if( activePlugins.length ){
80
- await runCLICmds(
35
+ await runCLICmds({
81
36
  environment,
82
- ['wp plugin activate ' + activePlugins.join(' ') + ' --network'],
83
- config,
84
- spinner
85
- )
86
- }
87
-
88
- }
89
-
90
- /**
91
- * Generates .htaccess file content.
92
- *
93
- * @param {string} environment Which environment to generate .htaccess for.
94
- * @param {boolean} multisite True if converting to multisite.
95
- * @param {boolean} subdomain True if converting to multisite subdomain.
96
- */
97
- async function generateHTAccess(environment, workDirectoryPath, multisite, subdomain){
98
- let folder = 'development' === environment ? 'WordPress' : 'Tests-WordPress';
99
-
100
- // if .htaccess already exists, no need to generate.
101
- if( fs.existsSync(path.join(workDirectoryPath, folder, '.htaccess')) ){
102
- return; // .htaccess already exists, no need to generate.
103
- }
104
-
105
- // default htaccess for single site.
106
- let htaccess = `
107
- <IfModule mod_rewrite.c>
108
- RewriteEngine On
109
- RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
110
- RewriteBase /
111
- RewriteRule ^index\.php$ - [L]
112
- RewriteCond %{REQUEST_FILENAME} !-f
113
- RewriteCond %{REQUEST_FILENAME} !-d
114
- RewriteRule . /index.php [L]
115
- </IfModule>
116
- `;
117
-
118
-
119
- // if multisite, we need to add the multisite rules.
120
- if( multisite ){
121
- let trailingSlash = subdomain ? '^wp-admin$ wp-admin/ [R=301,L]' : '^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/';
122
- let writeRule1 = subdomain ? '^(wp-(content|admin|includes).*) $1 [L]' : '^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]';
123
- let writeRule2 = subdomain ? '^(.*\.php)$ $1 [L]' : '^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]';
124
-
125
- htaccess = `
126
- RewriteEngine On
127
- RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
128
- RewriteBase /
129
- RewriteRule ^index\.php$ - [L]
130
-
131
- # add a trailing slash to /wp-admin
132
- RewriteRule ${trailingSlash}
133
-
134
- RewriteCond %{REQUEST_FILENAME} -f [OR]
135
- RewriteCond %{REQUEST_FILENAME} -d
136
- RewriteRule ^ - [L]
137
- RewriteRule ${writeRule1}
138
- RewriteRule ${writeRule2}
139
- RewriteRule . index.php [L]
140
- `;
37
+ cmds: ['wp plugin activate ' + activePlugins.join(' ') + ' --network'],
38
+ cwd
39
+ })
141
40
  }
142
-
143
- // write the .htaccess file.
144
- fs.writeFileSync(path.join(workDirectoryPath, folder, '.htaccess'), htaccess.replace(/\t/g, '').trim());
145
41
 
146
42
  }
147
43
 
@@ -152,7 +48,7 @@ async function generateHTAccess(environment, workDirectoryPath, multisite, subdo
152
48
  * @param {WPConfig} config The wp-env config object.
153
49
  * @param {Object} spinner A CLI spinner which indicates progress.
154
50
  */
155
- async function configureApplicationPassword( environment, config, spinner ){
51
+ async function configureApplicationPassword( {environment, cwd, configs} ){
156
52
  let cawebJson = fs.existsSync( path.join(appPath, 'caweb.json') ) ?
157
53
  JSON.parse(fs.readFileSync(path.join(appPath, 'caweb.json')))
158
54
  : {};
@@ -163,35 +59,36 @@ async function configureApplicationPassword( environment, config, spinner ){
163
59
  }
164
60
 
165
61
  // Check if application password exists.
166
- const exists = await runCLICmds(
62
+ const exists = await runCLICmds({
167
63
  environment,
168
- [ 'wp user application-password exists 1 caweb' ],
169
- config, spinner
170
- )
64
+ cmds: [ 'wp user application-password exists 1 caweb && echo $?' ],
65
+ cwd
66
+ })
171
67
 
172
- if( exists ){
173
- const uuid = await runCLICmds(
68
+ if( '0' === exists ){
69
+ const uuid = await runCLICmds({
174
70
  environment,
175
- [ 'wp user application-password list 1 --field=uuid --name=caweb --porcelain' ],
176
- config, spinner
177
- );
71
+ cmds: [ 'wp user application-password list 1 --field=uuid --name=caweb --porcelain' ],
72
+ cwd
73
+ });
178
74
 
179
75
  // delete the existing application password.
180
- await runCLICmds(
76
+ await runCLICmds({
181
77
  environment,
182
- [ `wp user application-password delete 1 ${uuid}` ],
183
- config, spinner
184
- )
78
+ cmds: [ `wp user application-password delete 1 ${uuid}` ],
79
+ cwd
80
+ })
185
81
  }
186
82
 
187
- let pwd = await runCLICmds(
83
+ let pwd = await runCLICmds({
188
84
  environment,
189
- [ 'wp user application-password create 1 caweb --porcelain' ],
190
- config, spinner
191
- )
85
+ cmds: [ 'wp user application-password create 1 caweb --porcelain' ],
86
+ cwd
87
+ });
192
88
 
89
+ // set the local sync information.
193
90
  cawebJson['sync']['local'] = {
194
- 'url': config.env.development.config?.WP_SITEURL || 'http://localhost:8888',
91
+ 'url': configs.WP_SITEURL,
195
92
  'user': 'admin',
196
93
  pwd,
197
94
  }
@@ -203,7 +100,6 @@ async function configureApplicationPassword( environment, config, spinner ){
203
100
  );
204
101
  }
205
102
 
206
-
207
103
  /**
208
104
  * Configures WordPress for the given environment by installing WordPress,
209
105
  * activating all plugins, and activating the first theme. These steps are
@@ -215,38 +111,22 @@ async function configureApplicationPassword( environment, config, spinner ){
215
111
  * @param {boolean} multisite True if converting to multisite.
216
112
  * @param {boolean} subdomain True if converting to multisite subdomain.
217
113
  */
218
- async function configureWordPress(environment, config, spinner, multisite, subdomain){
219
- const {
220
- WP_PERMALINK
221
- } = config.env[ environment ].config
222
-
114
+ async function configureWordPress({environment, cwd, multisite, subdomain, configs}){
115
+
223
116
  // Create an Application Password for the user.
224
- await configureApplicationPassword( environment, config, spinner );
117
+ await configureApplicationPassword( { environment, cwd, configs } );
225
118
 
226
- // Convert to multisite if flag was passed.
227
119
  if( multisite ){
228
- await convertToMultisite( environment, config, subdomain, spinner )
120
+ await networkActivatePlugins( {environment, cwd} );
229
121
  }
230
-
231
- // rewrite and flush permalink structure.
232
- await runCLICmds(
233
- environment,
234
- [
235
- `wp rewrite structure ${WP_PERMALINK} --hard`
236
- ],
237
- config,
238
- spinner
239
- )
240
-
241
- // generate .htaccess
242
- await generateHTAccess( environment, config.workDirectoryPath, multisite, subdomain );
243
-
122
+
123
+ return [
124
+ `wp option update permalink_structure "${configs.WP_PERMALINK}"`,
125
+ `wp rewrite structure ${configs.WP_PERMALINK} --hard`
126
+ ];
127
+
244
128
  }
245
129
 
246
130
  export {
247
- configureWordPress,
248
- configureApplicationPassword,
249
- isMultisite,
250
- convertToMultisite,
251
- generateHTAccess
131
+ configureWordPress
252
132
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caweb/cli",
3
- "version": "1.13.7",
3
+ "version": "1.14.1",
4
4
  "description": "CAWebPublishing Command Line Interface.",
5
5
  "exports": "./lib/env.js",
6
6
  "type": "module",
@@ -21,7 +21,6 @@
21
21
  "scripts": {
22
22
  "caweb": "node bin/caweb.js",
23
23
  "doc": "node ./docs/tool/index.js",
24
- "testa": "node ./test.js",
25
24
  "test": "echo \"Error: run tests from root\" && exit 0"
26
25
  },
27
26
  "homepage": "https://github.com/CAWebPublishing/cli#readme",
@@ -40,9 +39,11 @@
40
39
  "access": "public"
41
40
  },
42
41
  "config": {
43
- "WP_VER": "6.8.2",
42
+ "WP_VER": "6.8.3",
44
43
  "PHP_VER": "8.2",
44
+ "CAWEB_VER": "1.13.3",
45
45
  "DIVI_VER": "4.27.4",
46
+ "QUERY_MONITOR": "3.20.0",
46
47
  "DEFAULTS": {
47
48
  "FS_METHOD": "direct",
48
49
  "WP_DEBUG": true,
@@ -66,11 +67,13 @@
66
67
  "@inquirer/prompts": "^7.9.0",
67
68
  "@wordpress/create-block": "^4.76.0",
68
69
  "@wordpress/env": "^10.33.0",
69
- "axios": "^1.12.2",
70
+ "axios": "^1.13.0",
70
71
  "axios-retry": "^4.5.0",
71
72
  "chalk": "^5.6.2",
72
- "commander": "^14.0.1",
73
+ "commander": "^14.0.2",
73
74
  "cross-spawn": "^7.0.6",
75
+ "crypto": "^1.0.1",
76
+ "deepmerge": "^4.3.1",
74
77
  "docker-compose": "^1.3.0",
75
78
  "fs-extra": "^11.3.2",
76
79
  "html-to-json-parser": "^2.0.1",
@@ -1,44 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import path from 'path';
5
- import loadConfig from '@wordpress/env/lib/config/load-config.js';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import {runCLICmds} from '../../lib/index.js';
11
-
12
- /**
13
- * Promisified dependencies
14
- */
15
-
16
- /**
17
- * Updates all plugins for a given environment.
18
- *
19
- * @param {Object} options
20
- * @param {Object} options.spinner A CLI spinner which indicates progress.
21
- * @param {string} options.environment Which environment to updated.
22
- */
23
- export default async function updatePlugins({
24
- spinner,
25
- environment,
26
- slug
27
- }) {
28
-
29
- spinner.text = "Updating plugins...";
30
- const config = await loadConfig(path.resolve('.'));
31
-
32
- let plugin = 'all' === slug ? '--all' : slug;
33
-
34
- let result = await runCLICmds(
35
- environment,
36
- [`wp plugin update ${plugin}`],
37
- config
38
- );
39
-
40
- spinner.prefixText = `${result}\n`;
41
-
42
- spinner.text = 'Completed updating plugins!'
43
-
44
- };
package/lib/admin.js DELETED
@@ -1,40 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import path from 'node:path';
5
- import fs from 'fs-extra';
6
-
7
- import { CAWEB_OPTIONS, DIVI_OPTIONS } from './options.js';
8
-
9
- /**
10
- * Generates the OVERRIDES.MD
11
- *
12
- */
13
- export default async function generateOverridesMD() {
14
-
15
- let output = [
16
- '## [.wp-env.override.json](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/#wp-env-override-json)',
17
- 'Any fields here will take precedence over .wp-env.json.',
18
- '## <ins>Special Config Values</ins>',
19
- ];
20
-
21
- // Generate CAWeb Options overrides.
22
- output.push('### <ins>CAWeb Options</ins>');
23
- for (const [key, option] of Object.entries(CAWEB_OPTIONS)) {
24
- output.push(`\`${key}\` - Updates CAWeb ${option.label} `);
25
- }
26
-
27
- // Generate Divi Options overrides.
28
- output.push('### <ins>Divi Options</ins>');
29
- for (const [group, options] of Object.entries(DIVI_OPTIONS)) {
30
- for (const [key, option] of Object.entries(options)) {
31
- output.push(`\`${key}\` - Updates CAWeb ${option.label} `);
32
- }
33
- }
34
-
35
- fs.writeFileSync(
36
- path.join(process.cwd(), 'docs', 'OVERRIDES.MD'),
37
- output.join('\n')
38
- );
39
-
40
- };