@caweb/cli 1.1.0 → 1.3.0

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.
Files changed (51) hide show
  1. package/README.md +62 -27
  2. package/bin/caweb +1 -1
  3. package/bin/wp-cli.phar +0 -0
  4. package/commands/a11y.js +74 -0
  5. package/commands/blocks/create-block.js +109 -0
  6. package/commands/blocks/update-block.js +60 -0
  7. package/commands/build.js +73 -0
  8. package/commands/env/destroy.js +49 -0
  9. package/{lib/commands → commands/env}/start.js +30 -27
  10. package/{lib/commands → commands/env}/stop.js +4 -10
  11. package/{lib/commands → commands}/index.js +51 -39
  12. package/commands/serve.js +78 -0
  13. package/commands/sync.js +498 -0
  14. package/{lib/commands → commands}/tasks/update-plugins.js +2 -2
  15. package/commands/test.js +100 -0
  16. package/configs/aceconfig.js +28 -0
  17. package/{lib/configs.js → configs/docker-compose.js} +32 -55
  18. package/configs/webpack.config.js +119 -0
  19. package/configs/wp-env.js +76 -0
  20. package/gen/parser.js +166 -0
  21. package/gen/site-generator.js +111 -0
  22. package/lib/admin.js +40 -0
  23. package/lib/cli.js +129 -63
  24. package/lib/env.js +3 -11
  25. package/lib/helpers.js +109 -0
  26. package/lib/index.js +28 -0
  27. package/lib/spinner.js +10 -7
  28. package/lib/{caweb.js → wordpress/caweb.js} +1 -1
  29. package/lib/{divi.js → wordpress/divi.js} +1 -1
  30. package/lib/{download-sources.js → wordpress/download-sources.js} +75 -79
  31. package/lib/wordpress/index.js +16 -0
  32. package/lib/{options.js → wordpress/options.js} +1 -1
  33. package/lib/{wordpress.js → wordpress/wordpress.js} +4 -8
  34. package/package.json +42 -27
  35. package/template/assets/css/popover.css +80 -0
  36. package/template/assets/js/popover.js +30 -0
  37. package/template/block/edit.js.mustache +48 -0
  38. package/template/block/editor.scss.mustache +5 -0
  39. package/template/block/index.js.mustache +40 -0
  40. package/template/block/save.js.mustache +21 -0
  41. package/template/block/style.scss.mustache +6 -0
  42. package/template/index.cjs +48 -0
  43. package/template/plugin/$slug.php.mustache +135 -0
  44. package/template/plugin/core/cdec-api.php.mustache +44 -0
  45. package/template/plugin/core/filters.php.mustache +111 -0
  46. package/template/plugin/core/functions.php.mustache +25 -0
  47. package/template/plugin/inc/renderer.php.mustache +25 -0
  48. package/lib/commands/destroy.js +0 -66
  49. package/lib/commands/test.js +0 -46
  50. package/lib/docker.js +0 -68
  51. /package/{lib/commands → commands/tasks}/shell.js +0 -0
package/README.md CHANGED
@@ -1,45 +1,55 @@
1
1
  # 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.
2
+ `caweb-cli` is a tool which rapidly sets up a local WordPress environment fully configured for the [CAWebPublishing Service](https://caweb.cdt.ca.gov/), allows for the creation of Gutenberg blocks with the CAWebPublishing template configurations, and much more. 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
- ## Additional Features
5
- - Downloads and configures the [CAWeb Theme](https://github.com/CA-cODE-Works/CAWeb)
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
4
+ *`caweb-cli` is largely inspired by WordPress Packages major thanks to the whole WordPress team and community!*
5
+ The following WordPress packages are used:
6
+ [wp-env](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/)
7
+ [create-block](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/)
8
+
9
+ ## Prerequisites
10
+ - Latest version of [Docker Desktop](https://www.docker.com/products/docker-desktop), which includes [Compose v2](https://docs.docker.com/compose/migrate/), is installed.
11
+ - <strong>For Debian-Based Linux distributions:</strong> <code>docker-compose</code> may need to be installed with: <code>sudo apt-get install docker-compose</code>.
12
+ - <strong>For Windows users:</strong> [WSL should be set to version 2 for Windows Docker Desktop compatibility](https://docs.docker.com/desktop/windows/wsl/).
13
+ - git is installed.
10
14
 
15
+ ## Additional Features
16
+ - Downloads and configures the [CAWeb Theme](https://github.com/CAWebPublishing/CAWeb)
17
+ - Downloads approved plugins utilized by the CAWebPublishing Service
18
+ - Downloads and configures the [Divi Theme](https://www.elegantthemes.com/gallery/divi/) and [Divi Builder Plugin](https://www.elegantthemes.com/gallery/divi/) (*requires valid ElegantThemes Username and API Key*)
19
+ - Adds phpMyAdmin Service for both WordPress environments. (Username: <strong>root</strong> , Password: <strong>password</strong>)
20
+ - phpMyAdmin development site starts at http://localhost:8080
21
+ - phpMyAdmin test site started at http://localhost:9090
22
+ - Uses CAWebPublishing [External Project Template Configuration](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/packages-create-block-external-template/) when creating Gutenberg Blocks, see configurations [here](https://github.com/CAWebPublishing/cli/lib/template)
11
23
  - Adds config.yml to both cli containers
12
24
  <pre>
13
25
  path: /var/www/html
14
26
  apache_modules:
15
27
  - mod_rewrite
16
28
  </pre>
29
+ .
30
+
17
31
  ## Command Reference
18
32
  ### `caweb start`
19
33
  Generates the required wp-env.json, starts the WordPress environment, downloads any CAWebPublishing sources and approved plugins.
20
34
  <pre>
21
- caweb start
35
+ caweb start [options]
36
+
37
+ Starts two CAWebPublishing WordPress instances
38
+ development on port 8888 (​http://localhost:8888​) (override with WP_ENV_PORT)
39
+ tests on port 8889 (​http://localhost:8889​) (override with WP_ENV_TESTS_PORT).
40
+ After first install, use the '--update' flag to download updates to mapped sources and to re-apply CAWeb configuration options.
22
41
 
23
42
  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
+ --bare True if excluding any downloads from CAWeb, use this if you want to use a local version of the CAWeb Theme, Configurations will still be applied. (default: false)
44
+ -h, --help display help for command
45
+ -m, --multisite True if converting to multisite. (default: false)
46
+ -p, --plugin True if root directory is a plugin. (default: false)
47
+ --scripts Execute any configured lifecycle scripts. (default: true)
48
+ --subdomain If passed, the network will use subdomains, instead of subdirectories. Doesn't work with 'localhost', make sure to set Port to 80. (default: false)
49
+ -t, --theme True if root directory is a theme. (default: false)
50
+ --update Download source updates and apply WordPress configuration. (default: false)
51
+ --xdebug <mode> Enables Xdebug. If not passed, Xdebug is turned off. If no modes are set, uses "debug". You may set multiple Xdebug modes by passing them in a comma-separated list:
52
+ `--xdebug=develop,coverage`. See https://xdebug.org/docs/all_settings#mode for information about Xdebug modes.
43
53
  </pre>
44
54
  ### `caweb stop`
45
55
  <pre>
@@ -148,3 +158,28 @@ Positionals:
148
158
  Options:
149
159
  --debug Enable debug output. [boolean] [default: false]
150
160
  </pre>
161
+
162
+ ### `caweb create-block [options] <slug>`
163
+ <pre>
164
+ caweb create-block [options] <slug>
165
+
166
+ Scaffold for WordPress plugin to register CA.gov Design System Block.
167
+
168
+ Arguments:
169
+ slug Plugin slug to use.
170
+
171
+ Options:
172
+ -h, --help display help for command
173
+ </pre>
174
+ ### `caweb update-block [options] <slug>`
175
+ <pre>
176
+ caweb update-block [options] <slug>
177
+
178
+ Updates a CA.gov Design System Block.
179
+
180
+ Arguments:
181
+ slug Plugin slug to update.
182
+
183
+ Options:
184
+ -h, --help display help for command
185
+ </pre>
package/bin/caweb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import cli from '../lib/cli.js';
4
4
 
Binary file
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * External dependencies
5
+ */
6
+ import path from 'path';
7
+ import fs from 'fs';
8
+ import resolveBin from 'resolve-bin';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ // Our default A11y Checker Configuration
14
+ import defaultConfig from '../configs/aceconfig.js';
15
+
16
+ import {
17
+ runCmd,
18
+ } from '../lib/index.js';
19
+
20
+
21
+
22
+ /**
23
+ * Run accessibility checks
24
+ *
25
+ * @param {Object} options
26
+ * @param {Object} options.spinner A CLI spinner which indicates progress.
27
+ * @param {boolean} options.debug True if debug mode is enabled.
28
+ */
29
+ export default async function a11y({
30
+ spinner,
31
+ debug,
32
+ } ) {
33
+
34
+ // Spinner not needed at the moment
35
+ spinner.stop()
36
+ const {
37
+ ruleArchive,
38
+ policies,
39
+ failLevels,
40
+ reportLevels,
41
+ outputFolder,
42
+ outputFormat,
43
+ outputFilenameTimestamp
44
+ } = defaultConfig;
45
+
46
+
47
+ // pass any arguments from the cli
48
+ // overwriting our default config flags.
49
+ // users can overwrite any values by creating a .achecker.yml or aceconfig.js.
50
+ let acheckerArgs = [
51
+ '--ruleArchive',
52
+ ruleArchive,
53
+ '--policies',
54
+ Array.isArray(policies) ? policies.join(',') : policies,
55
+ '--failLevels',
56
+ Array.isArray(failLevels) ? failLevels.join(',') : failLevels,
57
+ '--reportLevels',
58
+ Array.isArray(reportLevels) ? reportLevels.join(',') : reportLevels,
59
+ '--outputFolder',
60
+ outputFolder,
61
+ '--outputFormat',
62
+ outputFormat,
63
+ '---outputFilenameTimestamp',
64
+ outputFilenameTimestamp,
65
+ process.argv.pop()
66
+ ];
67
+
68
+ // run webpack with our arguments.
69
+ await runCmd(
70
+ 'achecker',
71
+ acheckerArgs,
72
+ )
73
+
74
+ };
@@ -0,0 +1,109 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import path from 'path';
5
+ import fs from 'fs';
6
+ import inquirer from 'inquirer';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import {runCmd, projectPath} from '../../lib/index.js';
12
+ import updateBlock from './update-block.js';
13
+
14
+ const localFile = path.join(projectPath, 'package.json');
15
+ const pkg = JSON.parse( fs.readFileSync(localFile) );
16
+
17
+ /**
18
+ * Get NPM Package Latest Version
19
+ * @param {string} options.slug Block slug.
20
+ * @param {Object} options.spinner A CLI spinner which indicates progress.
21
+ */
22
+ async function getNPMPackageVersion(pkg, spinner){
23
+ return await runCmd(
24
+ 'npm',
25
+ [
26
+ 'view',
27
+ `${pkg}`,
28
+ 'version'
29
+ ],
30
+ spinner
31
+ )
32
+
33
+ }
34
+
35
+ /**
36
+ * Create Block
37
+ *
38
+ * @param {Object} options
39
+ * @param {Object} options.spinner A CLI spinner which indicates progress.
40
+ * @param {boolean} options.debug True if debug mode is enabled.
41
+ * @param {string} options.slug Block slug.
42
+ */
43
+ export default async function createBlock({
44
+ spinner,
45
+ debug,
46
+ slug
47
+ } ) {
48
+ // if block directory already exists.
49
+ if( fs.existsSync(path.resolve(process.cwd(), slug)) ){
50
+ spinner.info(`${slug} already exists.`)
51
+
52
+ const { yesUpdate } = await inquirer.prompt( [
53
+ {
54
+ type: 'confirm',
55
+ name: 'yesUpdate',
56
+ message: 'Would you like to update it?',
57
+ default: false,
58
+ },
59
+ ] );
60
+
61
+ if( yesUpdate ){
62
+ spinner.text = `Updating ${slug}...`;
63
+ await updateBlock({spinner, debug, slug});
64
+ }
65
+ // create a new block
66
+ }else{
67
+ // Get cagov component version if it exists.
68
+ let version = await getNPMPackageVersion(`@cagov/${slug}`, spinner);
69
+
70
+ // call the wordpress create-block command using our template.
71
+ await runCmd(
72
+ 'npx',
73
+ [
74
+ `@wordpress/create-block`,
75
+ slug,
76
+ '--template=' + path.join(projectPath, 'template', 'index.cjs')
77
+ ],
78
+ spinner,
79
+ {
80
+ stdio: 'inherit'
81
+ }
82
+ )
83
+
84
+ // install cagov npm package if it exists.
85
+ if( version ){
86
+ // capture spinner.text result
87
+ let spinnerText = spinner.text;
88
+ spinner.text = '';
89
+
90
+ await runCmd(
91
+ 'npm',
92
+ [
93
+ 'install',
94
+ `@cagov/${slug}@${version}`,
95
+ ],
96
+ spinner,
97
+ {
98
+ cwd: path.join(process.cwd(), slug ),
99
+ stdio: 'inherit'
100
+ }
101
+ )
102
+
103
+ spinner.text = spinnerText;
104
+
105
+ }
106
+ }
107
+
108
+
109
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import path from 'path';
5
+ import fs from 'fs';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import createBlock from './create-block.js';
11
+
12
+ /**
13
+ * Update Block
14
+ *
15
+ * @param {Object} options
16
+ * @param {Object} options.spinner A CLI spinner which indicates progress.
17
+ * @param {boolean} options.debug True if debug mode is enabled.
18
+ * @param {string} options.slug Block slug.
19
+ */
20
+ export default async function updateBlock({
21
+ spinner,
22
+ debug,
23
+ slug
24
+ } ) {
25
+
26
+ // if block directory exists.
27
+ if( fs.existsSync(path.resolve(process.cwd(), slug)) ){
28
+ spinner.text = `Updating ${slug} block plugin.`;
29
+
30
+ // make tmp directory
31
+ fs.ensureDir( `${slug}.tmp`);
32
+
33
+ // move inc directory to tmp directory
34
+ fs.copySync(`${slug}/inc/`, `${slug}.tmp/inc/`);
35
+
36
+ // move src directory to tmp directory
37
+ fs.copySync(`${slug}/src/`, `${slug}.tmp/src/`);
38
+
39
+ // delete old block.
40
+ fs.removeSync( `${slug}` );
41
+
42
+ // Recreate the block.
43
+ await createBlock({spinner, debug, slug});
44
+
45
+ // move inc directory back to block directory
46
+ fs.copySync(`${slug}.tmp/inc/`, `${slug}/inc/` );
47
+
48
+ // move src directory back to block directory
49
+ fs.copySync(`${slug}.tmp/src/`, `${slug}/src/`);
50
+
51
+ // delete tmp directory.
52
+ fs.removeSync( `${slug}.tmp` );
53
+
54
+ spinner.succeed(`${slug} has been updated!`);
55
+
56
+ }else{
57
+ spinner.fail(`${slug} plugin directory not found.`)
58
+ }
59
+
60
+ };
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * External dependencies
5
+ */
6
+ import path from 'path';
7
+ import fs from 'fs';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import {
13
+ runCmd,
14
+ projectPath,
15
+ appPath
16
+ } from '../lib/index.js';
17
+
18
+
19
+ /**
20
+ * Build the current project
21
+ *
22
+ * @param {Object} options
23
+ * @param {Object} options.spinner A CLI spinner which indicates progress.
24
+ * @param {boolean} options.debug True if debug mode is enabled.
25
+ */
26
+ export default async function build({
27
+ spinner,
28
+ debug,
29
+ } ) {
30
+
31
+ // Spinner not needed at the moment
32
+ spinner.stop()
33
+
34
+ // Since we use @wordpress/scripts webpack config we can leverage
35
+ // the environment variables as well.
36
+ process.env.WP_COPY_PHP_FILES_TO_DIST = true;
37
+
38
+ // Our default Webpack Configuration
39
+ const defaultConfig = path.join( projectPath, 'configs', 'webpack.config.js' );
40
+
41
+ // pass any arguments from the cli
42
+ // add our default config as an extension.
43
+ // users can overwrite any values by creating a webconfig of their own.
44
+ let webPackArgs = [
45
+ '--mode=none',
46
+ '--progress',
47
+ '--config',
48
+ defaultConfig
49
+ ];
50
+
51
+ // CommonJS
52
+ if( fs.existsSync( path.join(appPath, 'webpack.config.cjs' ))){
53
+ webPackArgs.push(
54
+ '--config',
55
+ path.join(appPath, 'webpack.config.cjs' ),
56
+ '--merge'
57
+ )
58
+ // ESM
59
+ }else if( fs.existsSync(path.join(appPath, 'webpack.config.js' )) ){
60
+ webPackArgs.push(
61
+ '--config',
62
+ path.join(appPath, 'webpack.config.js' ),
63
+ '--merge'
64
+ )
65
+ }
66
+
67
+ // run webpack with our arguments.
68
+ await runCmd(
69
+ 'webpack',
70
+ webPackArgs,
71
+ )
72
+
73
+ };
@@ -0,0 +1,49 @@
1
+
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import { default as wpEnvDestroy } from '@wordpress/env/lib/commands/destroy.js';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { runCmd } from '../../lib/index.js';
11
+
12
+ /**
13
+ * Destroys the development server.
14
+ *
15
+ * @param {Object} options
16
+ * @param {Object} options.spinner A CLI spinner which indicates progress.
17
+ * @param {boolean} options.scripts Indicates whether or not lifecycle scripts should be executed.
18
+ * @param {boolean} options.debug True if debug mode is enabled.
19
+ *
20
+ */
21
+ export default async function destroy({
22
+ spinner,
23
+ scripts,
24
+ debug,
25
+ }) {
26
+
27
+ await wpEnvDestroy({spinner, scripts, debug });
28
+
29
+ // wp-env destroy completed successfully if spinner.text reads.
30
+ if( 'Removed WordPress environment.' === spinner.text ){
31
+ spinner.text = "Cleaning up...";
32
+
33
+ // Stop phpMyAdmin as well
34
+ // wp-env doesn't destroy the phpmyadmin image so we have to do it ourselves.
35
+ await runCmd(
36
+ 'docker',
37
+ [
38
+ 'image',
39
+ 'rm',
40
+ 'phpmyadmin'
41
+ ],
42
+ { stdio: 'ignore' }
43
+ )
44
+
45
+ spinner.text = "Removed WordPress environment.'";
46
+
47
+ }
48
+
49
+ }
@@ -1,36 +1,34 @@
1
- import path from 'node:path';
2
- import util from 'node:util';
3
- import fs from 'fs-extra';
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import path from 'path';
5
+ import fs from 'fs';
6
+ import { v2 as dockerCompose } from 'docker-compose';
4
7
  import yaml from 'js-yaml';
5
- import dockerCompose from 'docker-compose';
6
8
 
9
+ /**
10
+ * WordPress dependencies
11
+ */
7
12
  import { default as wpEnvStart} from '@wordpress/env/lib/commands/start.js';
8
- import {
9
- checkDatabaseConnection,
10
- canAccessWPORG
11
- } from '@wordpress/env/lib/wordpress.js';
12
-
13
+ import loadConfig from '@wordpress/env/lib/config/load-config.js';
13
14
  import retry from '@wordpress/env/lib/retry.js';
15
+ import { didCacheChange, getCache } from '@wordpress/env/lib/cache.js';
16
+ import { canAccessWPORG } from '@wordpress/env/lib/wordpress.js';
14
17
 
15
18
  const CONFIG_CACHE_KEY = 'config_checksum';
16
19
 
17
- import loadConfig from '@wordpress/env/lib/config/load-config.js';
18
- import { didCacheChange, getCache } from '@wordpress/env/lib/cache.js';
19
-
20
20
  /**
21
21
  * Internal dependencies
22
22
  */
23
+ import { appPath } from '../../lib/helpers.js';
24
+ import wpEnvConfig from '../../configs/wp-env.js';
25
+ import dockerConfig from '../../configs/docker-compose.js';
23
26
 
24
- import { configureCAWeb } from '../caweb.js';
25
- import {downloadSources } from '../download-sources.js';
26
- import { configureWordPress } from '../wordpress.js';
27
- import { buildWPEnvConfig, buildDockerComposeConfig } from '../configs.js';
28
-
29
- /**
30
- * Promisified dependencies
31
- */
32
- const sleep = util.promisify( setTimeout );
33
- const { writeFile } = fs.promises;
27
+ import {
28
+ configureCAWeb,
29
+ downloadSources,
30
+ configureWordPress
31
+ } from '../../lib/wordpress/index.js';
34
32
 
35
33
  /**
36
34
  * Starts the development server.
@@ -42,6 +40,8 @@ const { writeFile } = fs.promises;
42
40
  * @param {boolean} options.scripts Indicates whether or not lifecycle scripts should be executed.
43
41
  * @param {boolean} options.debug True if debug mode is enabled.
44
42
  * @param {boolean} options.bare True if excluding any CAWeb Configurations.
43
+ * @param {boolean} options.plugin True if root directory is a plugin.
44
+ * @param {boolean} options.theme True if root directory is a theme.
45
45
  * @param {boolean} options.multisite True if converting to multisite.
46
46
  * @param {boolean} options.subdomain True if converting to multisite subdomain.
47
47
  *
@@ -53,6 +53,8 @@ export default async function start({
53
53
  scripts,
54
54
  debug,
55
55
  bare,
56
+ plugin,
57
+ theme,
56
58
  multisite,
57
59
  subdomain
58
60
  }) {
@@ -60,9 +62,9 @@ export default async function start({
60
62
  spinner.text = 'Writing configuration file...';
61
63
 
62
64
  // Write CAWeb .wp-env.json file.
63
- await writeFile(
64
- path.join(process.cwd(), '.wp-env.json'),
65
- JSON.stringify( buildWPEnvConfig(bare, multisite), null, 4 )
65
+ fs.writeFileSync(
66
+ path.join(appPath, '.wp-env.json'),
67
+ JSON.stringify( wpEnvConfig(bare, multisite, plugin, theme), null, 4 )
66
68
  );
67
69
 
68
70
  // Get current wp-env cache key
@@ -103,9 +105,9 @@ export default async function start({
103
105
  }
104
106
 
105
107
  // Write docker-compose.override.yml file to workDirectoryPath.
106
- await writeFile(
108
+ fs.writeFileSync(
107
109
  path.join(workDirectoryPath, 'docker-compose.override.yml'),
108
- yaml.dump( buildDockerComposeConfig(workDirectoryPath) )
110
+ yaml.dump( dockerConfig(workDirectoryPath) )
109
111
  );
110
112
 
111
113
  // Only run configurations when config has changed.
@@ -160,6 +162,7 @@ export default async function start({
160
162
  spinner.prefixText = preText +
161
163
  `phpMyAdmin site started at http://localhost:8080\n\n`;
162
164
 
165
+
163
166
  spinner.text = 'Done!';
164
167
 
165
168
  };
@@ -1,18 +1,12 @@
1
- import path from 'node:path';
2
- import { spawn } from 'node:child_process';
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import path from 'path';
3
5
  import loadConfig from '@wordpress/env/lib/config/load-config.js';
4
6
  import { v2 as dockerCompose } from 'docker-compose';
5
7
 
6
8
  import { default as wpEnvStop } from '@wordpress/env/lib/commands/stop.js';
7
9
 
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- /**
13
- * Promisified dependencies
14
- */
15
-
16
10
  /**
17
11
  * Starts the development server.
18
12
  *