@caweb/cli 1.1.0 → 1.2.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.
- package/README.md +62 -27
- package/lib/admin.js +40 -0
- package/lib/caweb.js +1 -1
- package/lib/cli.js +24 -0
- package/lib/commands/blocks/create-block.js +110 -0
- package/lib/commands/blocks/update-block.js +66 -0
- package/lib/commands/destroy.js +5 -15
- package/lib/commands/index.js +5 -1
- package/lib/commands/start.js +5 -1
- package/lib/commands/tasks/update-plugins.js +1 -1
- package/lib/commands/test.js +4 -4
- package/lib/configs.js +32 -2
- package/lib/divi.js +1 -1
- package/lib/download-sources.js +1 -1
- package/lib/env.js +3 -11
- package/lib/options.js +1 -1
- package/lib/template/assets/css/popover.css +80 -0
- package/lib/template/assets/js/popover.js +30 -0
- package/lib/template/block/edit.js.mustache +48 -0
- package/lib/template/block/editor.scss.mustache +5 -0
- package/lib/template/block/index.js.mustache +40 -0
- package/lib/template/block/save.js.mustache +21 -0
- package/lib/template/block/style.scss.mustache +6 -0
- package/lib/template/index.cjs +48 -0
- package/lib/template/plugin/$slug.php.mustache +135 -0
- package/lib/template/plugin/core/cdec-api.php.mustache +44 -0
- package/lib/template/plugin/core/filters.php.mustache +111 -0
- package/lib/template/plugin/core/functions.php.mustache +25 -0
- package/lib/template/plugin/inc/renderer.php.mustache +25 -0
- package/lib/utils.js +150 -0
- package/lib/wordpress.js +1 -1
- package/package.json +3 -2
- package/lib/docker.js +0 -68
package/README.md
CHANGED
|
@@ -1,45 +1,55 @@
|
|
|
1
1
|
# caweb-cli
|
|
2
|
-
`caweb-cli`
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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/lib/admin.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
await fs.writeFileSync(
|
|
36
|
+
path.join(process.cwd(), 'docs', 'OVERRIDES.MD'),
|
|
37
|
+
output.join('\n')
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
};
|
package/lib/caweb.js
CHANGED
|
@@ -7,7 +7,7 @@ import retry from '@wordpress/env/lib/retry.js';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { CAWEB_OPTIONS } from'./options.js';
|
|
10
|
-
import { runCLICmds } from'./
|
|
10
|
+
import { runCLICmds } from'./utils.js';
|
|
11
11
|
import { isMultisite } from'./wordpress.js';
|
|
12
12
|
import { configureDivi } from'./divi.js';
|
|
13
13
|
|
package/lib/cli.js
CHANGED
|
@@ -90,6 +90,16 @@ export default function cli() {
|
|
|
90
90
|
'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.',
|
|
91
91
|
false
|
|
92
92
|
)
|
|
93
|
+
.option(
|
|
94
|
+
'-p, --plugin',
|
|
95
|
+
'True if root directory is a plugin.',
|
|
96
|
+
false
|
|
97
|
+
)
|
|
98
|
+
.option(
|
|
99
|
+
'-t, --theme',
|
|
100
|
+
'True if root directory is a theme.',
|
|
101
|
+
false
|
|
102
|
+
)
|
|
93
103
|
.option(
|
|
94
104
|
'-m, --multisite',
|
|
95
105
|
'True if converting to multisite.',
|
|
@@ -194,6 +204,20 @@ export default function cli() {
|
|
|
194
204
|
.allowUnknownOption(true)
|
|
195
205
|
.action( withSpinner(env.updatePlugins) )
|
|
196
206
|
|
|
207
|
+
// Create a Design System Block Command.
|
|
208
|
+
program.command('create-block')
|
|
209
|
+
.description('Scaffold for WordPress plugin to register CA.gov Design System Block.')
|
|
210
|
+
.argument('<slug>', 'Plugin slug to use.')
|
|
211
|
+
.allowUnknownOption(true)
|
|
212
|
+
.action( withSpinner(env.createBlock) )
|
|
213
|
+
|
|
214
|
+
// Update a Design System Block Command.
|
|
215
|
+
program.command('update-block')
|
|
216
|
+
.description('Updates a CA.gov Design System Block.')
|
|
217
|
+
.argument('<slug>', 'Plugin slug to update.')
|
|
218
|
+
.allowUnknownOption(true)
|
|
219
|
+
.action( withSpinner(env.updateBlock) )
|
|
220
|
+
|
|
197
221
|
// Test Command.
|
|
198
222
|
// Ensure this is commented out.
|
|
199
223
|
program.command('test')
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import inquirer from 'inquirer';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import {runCmd} from '../../utils.js';
|
|
13
|
+
import updateBlock from './update-block.js';
|
|
14
|
+
|
|
15
|
+
const localPath = path.resolve( path.join(process.cwd(), 'node_modules/@caweb/cli/package.json') )
|
|
16
|
+
const pkg = JSON.parse( await fs.readFile(localPath) );
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get NPM Package Latest Version
|
|
20
|
+
* @param {string} options.slug Block slug.
|
|
21
|
+
* @param {Object} options.spinner A CLI spinner which indicates progress.
|
|
22
|
+
*/
|
|
23
|
+
async function getNPMPackageVersion(pkg, spinner){
|
|
24
|
+
return await runCmd(
|
|
25
|
+
'npm',
|
|
26
|
+
[
|
|
27
|
+
'view',
|
|
28
|
+
`${pkg}`,
|
|
29
|
+
'version'
|
|
30
|
+
],
|
|
31
|
+
spinner
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create Block
|
|
38
|
+
*
|
|
39
|
+
* @param {Object} options
|
|
40
|
+
* @param {Object} options.spinner A CLI spinner which indicates progress.
|
|
41
|
+
* @param {boolean} options.debug True if debug mode is enabled.
|
|
42
|
+
* @param {string} options.slug Block slug.
|
|
43
|
+
*/
|
|
44
|
+
export default async function createBlock({
|
|
45
|
+
spinner,
|
|
46
|
+
debug,
|
|
47
|
+
slug
|
|
48
|
+
} ) {
|
|
49
|
+
// if block directory already exists.
|
|
50
|
+
if( fs.existsSync(path.resolve(process.cwd(), slug)) ){
|
|
51
|
+
spinner.info(`${slug} already exists.`)
|
|
52
|
+
|
|
53
|
+
const { yesUpdate } = await inquirer.prompt( [
|
|
54
|
+
{
|
|
55
|
+
type: 'confirm',
|
|
56
|
+
name: 'yesUpdate',
|
|
57
|
+
message: 'Would you like to update it?',
|
|
58
|
+
default: false,
|
|
59
|
+
},
|
|
60
|
+
] );
|
|
61
|
+
|
|
62
|
+
if( yesUpdate ){
|
|
63
|
+
spinner.text = `Updating ${slug}...`;
|
|
64
|
+
await updateBlock({spinner, debug, slug});
|
|
65
|
+
}
|
|
66
|
+
// create a new block
|
|
67
|
+
}else{
|
|
68
|
+
// Get cagov component version if it exists.
|
|
69
|
+
let version = await getNPMPackageVersion(`@cagov/${slug}`, spinner);
|
|
70
|
+
|
|
71
|
+
// call the wordpress create-block command using our template.
|
|
72
|
+
await runCmd(
|
|
73
|
+
'npx',
|
|
74
|
+
[
|
|
75
|
+
`@wordpress/create-block`,
|
|
76
|
+
slug,
|
|
77
|
+
'--template=' + path.resolve( path.join(process.cwd(), 'node_modules/@caweb/cli/lib/template/index.cjs') )
|
|
78
|
+
],
|
|
79
|
+
spinner,
|
|
80
|
+
{
|
|
81
|
+
stdio: 'inherit'
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
// install cagov npm package if it exists.
|
|
86
|
+
if( version ){
|
|
87
|
+
// capture spinner.text result
|
|
88
|
+
let spinnerText = spinner.text;
|
|
89
|
+
spinner.text = '';
|
|
90
|
+
|
|
91
|
+
await runCmd(
|
|
92
|
+
'npm',
|
|
93
|
+
[
|
|
94
|
+
'install',
|
|
95
|
+
`@cagov/${slug}@${version}`,
|
|
96
|
+
],
|
|
97
|
+
spinner,
|
|
98
|
+
{
|
|
99
|
+
cwd: path.resolve( path.join(process.cwd(), slug ) ),
|
|
100
|
+
stdio: 'inherit'
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
spinner.text = spinnerText;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import {runCmd} from '../../utils.js';
|
|
12
|
+
import createBlock from './create-block.js';
|
|
13
|
+
|
|
14
|
+
const localPath = path.resolve( path.join(process.cwd(), 'node_modules/@caweb/cli/package.json') )
|
|
15
|
+
const pkg = JSON.parse( await fs.readFile(localPath) );
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create Block
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} options
|
|
22
|
+
* @param {Object} options.spinner A CLI spinner which indicates progress.
|
|
23
|
+
* @param {boolean} options.debug True if debug mode is enabled.
|
|
24
|
+
* @param {string} options.slug Block slug.
|
|
25
|
+
*/
|
|
26
|
+
export default async function updateBlock({
|
|
27
|
+
spinner,
|
|
28
|
+
debug,
|
|
29
|
+
slug
|
|
30
|
+
} ) {
|
|
31
|
+
|
|
32
|
+
// if block directory exists.
|
|
33
|
+
if( fs.existsSync(path.resolve(process.cwd(), slug)) ){
|
|
34
|
+
spinner.text = `Updating ${slug} block plugin.`;
|
|
35
|
+
|
|
36
|
+
// make tmp directory
|
|
37
|
+
fs.ensureDir( `${slug}.tmp`);
|
|
38
|
+
|
|
39
|
+
// move inc directory to tmp directory
|
|
40
|
+
fs.copySync(`${slug}/inc/`, `${slug}.tmp/inc/`);
|
|
41
|
+
|
|
42
|
+
// move src directory to tmp directory
|
|
43
|
+
fs.copySync(`${slug}/src/`, `${slug}.tmp/src/`);
|
|
44
|
+
|
|
45
|
+
// delete old block.
|
|
46
|
+
fs.removeSync( `${slug}` );
|
|
47
|
+
|
|
48
|
+
// Recreate the block.
|
|
49
|
+
await createBlock({spinner, debug, slug});
|
|
50
|
+
|
|
51
|
+
// move inc directory back to block directory
|
|
52
|
+
fs.copySync(`${slug}.tmp/inc/`, `${slug}/inc/` );
|
|
53
|
+
|
|
54
|
+
// move src directory back to block directory
|
|
55
|
+
fs.copySync(`${slug}.tmp/src/`, `${slug}/src/`);
|
|
56
|
+
|
|
57
|
+
// delete tmp directory.
|
|
58
|
+
fs.removeSync( `${slug}.tmp` );
|
|
59
|
+
|
|
60
|
+
spinner.succeed(`${slug} has been updated!`);
|
|
61
|
+
|
|
62
|
+
}else{
|
|
63
|
+
spinner.fail(`${slug} plugin directory not found.`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
};
|
package/lib/commands/destroy.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import loadConfig from '@wordpress/env/lib/config/load-config.js';
|
|
3
|
-
import { spawn } from 'node:child_process';
|
|
4
|
-
import { v2 as dockerCompose } from 'docker-compose';
|
|
5
|
-
|
|
6
|
-
import { default as wpEnvDestroy } from '@wordpress/env/lib/commands/destroy.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
1
|
|
|
12
2
|
/**
|
|
13
|
-
*
|
|
3
|
+
* External dependencies
|
|
14
4
|
*/
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { default as wpEnvDestroy } from '@wordpress/env/lib/commands/destroy.js';
|
|
15
7
|
|
|
16
8
|
/**
|
|
17
|
-
*
|
|
9
|
+
* Destroys the development server.
|
|
18
10
|
*
|
|
19
11
|
* @param {Object} options
|
|
20
12
|
* @param {Object} options.spinner A CLI spinner which indicates progress.
|
|
@@ -50,9 +42,7 @@ export default async function destroy({
|
|
|
50
42
|
|
|
51
43
|
childProc.on( 'error', reject );
|
|
52
44
|
childProc.on( 'exit', ( code ) => {
|
|
53
|
-
|
|
54
|
-
// ctrl-d (so it is not an error which should fail the script.)
|
|
55
|
-
if ( code === 0 || code === 130 ) {
|
|
45
|
+
if ( code === 0 ) {
|
|
56
46
|
resolve();
|
|
57
47
|
} else {
|
|
58
48
|
reject( `Command failed with exit code ${ code }` );
|
package/lib/commands/index.js
CHANGED
|
@@ -15,6 +15,8 @@ import installPath from '@wordpress/env/lib/commands/install-path.js';
|
|
|
15
15
|
*/
|
|
16
16
|
import shell from './shell.js';
|
|
17
17
|
import updatePlugins from './tasks/update-plugins.js'
|
|
18
|
+
import createBlock from './blocks/create-block.js'
|
|
19
|
+
import updateBlock from './blocks/update-block.js'
|
|
18
20
|
|
|
19
21
|
import test from './test.js';
|
|
20
22
|
|
|
@@ -36,5 +38,7 @@ export {
|
|
|
36
38
|
destroy,
|
|
37
39
|
test,
|
|
38
40
|
shell,
|
|
39
|
-
updatePlugins
|
|
41
|
+
updatePlugins,
|
|
42
|
+
createBlock,
|
|
43
|
+
updateBlock
|
|
40
44
|
}
|
package/lib/commands/start.js
CHANGED
|
@@ -42,6 +42,8 @@ const { writeFile } = fs.promises;
|
|
|
42
42
|
* @param {boolean} options.scripts Indicates whether or not lifecycle scripts should be executed.
|
|
43
43
|
* @param {boolean} options.debug True if debug mode is enabled.
|
|
44
44
|
* @param {boolean} options.bare True if excluding any CAWeb Configurations.
|
|
45
|
+
* @param {boolean} options.plugin True if root directory is a plugin.
|
|
46
|
+
* @param {boolean} options.theme True if root directory is a theme.
|
|
45
47
|
* @param {boolean} options.multisite True if converting to multisite.
|
|
46
48
|
* @param {boolean} options.subdomain True if converting to multisite subdomain.
|
|
47
49
|
*
|
|
@@ -53,6 +55,8 @@ export default async function start({
|
|
|
53
55
|
scripts,
|
|
54
56
|
debug,
|
|
55
57
|
bare,
|
|
58
|
+
plugin,
|
|
59
|
+
theme,
|
|
56
60
|
multisite,
|
|
57
61
|
subdomain
|
|
58
62
|
}) {
|
|
@@ -62,7 +66,7 @@ export default async function start({
|
|
|
62
66
|
// Write CAWeb .wp-env.json file.
|
|
63
67
|
await writeFile(
|
|
64
68
|
path.join(process.cwd(), '.wp-env.json'),
|
|
65
|
-
JSON.stringify( buildWPEnvConfig(bare, multisite), null, 4 )
|
|
69
|
+
JSON.stringify( buildWPEnvConfig(bare, multisite, plugin, theme), null, 4 )
|
|
66
70
|
);
|
|
67
71
|
|
|
68
72
|
// Get current wp-env cache key
|
package/lib/commands/test.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import loadConfig from '@wordpress/env/lib/config/load-config.js';
|
|
6
|
+
import fs from 'fs-extra';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
|
-
import { runCLICmds } from '../
|
|
11
|
-
import
|
|
11
|
+
import { runCLICmds, runCmd } from '../utils.js';
|
|
12
|
+
import generateOverridesMD from '../admin.js';
|
|
13
|
+
import { CAWEB_OPTIONS, DIVI_OPTIONS } from '../options.js';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Promisified dependencies
|
|
@@ -41,6 +43,4 @@ export default async function test({
|
|
|
41
43
|
|
|
42
44
|
console.log( result );
|
|
43
45
|
|
|
44
|
-
spinner.text = "Done!";
|
|
45
|
-
|
|
46
46
|
};
|
package/lib/configs.js
CHANGED
|
@@ -19,10 +19,15 @@ const pkg = JSON.parse( await fs.readFile(localPath) );
|
|
|
19
19
|
*
|
|
20
20
|
* @param {boolean} bare True if excluding any CAWeb Configurations.
|
|
21
21
|
* @param {boolean} multisite True if converting to multisite.
|
|
22
|
+
* @param {boolean} plugin True if root directory is a plugin.
|
|
23
|
+
* @param {boolean} theme True if root directory is a theme.
|
|
22
24
|
*
|
|
23
25
|
* @returns object
|
|
24
26
|
*/
|
|
25
|
-
const buildWPEnvConfig = (bare, multisite) => {
|
|
27
|
+
const buildWPEnvConfig = (bare, multisite, plugin, theme) => {
|
|
28
|
+
let themes = [];
|
|
29
|
+
let plugins = [];
|
|
30
|
+
|
|
26
31
|
let config = {
|
|
27
32
|
core: `WordPress/WordPress#${pkg.config.WP_VER}`,
|
|
28
33
|
phpVersion: `${pkg.config.PHP_VER}`,
|
|
@@ -33,12 +38,37 @@ const buildWPEnvConfig = (bare, multisite) => {
|
|
|
33
38
|
|
|
34
39
|
// if not bare then include our theme.
|
|
35
40
|
if( ! bare ){
|
|
36
|
-
|
|
41
|
+
themes.push('CAWebPublishing/CAWeb')
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
// if root directory is a theme
|
|
45
|
+
if( theme ){
|
|
46
|
+
themes.push( '.' );
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
// if is multisite
|
|
40
50
|
if( multisite ){
|
|
41
51
|
config.config['WP_ALLOW_MULTISITE'] = true;
|
|
52
|
+
|
|
53
|
+
// set CAWeb as Default Theme if it was downloaded
|
|
54
|
+
if( ! bare ){
|
|
55
|
+
config.config['WP_DEFAULT_THEME'] = 'CAWeb';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// if root directory is a plugin
|
|
60
|
+
if( plugin ){
|
|
61
|
+
plugins.push( '.' );
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// add plugins if sources were added
|
|
65
|
+
if( plugins.length ){
|
|
66
|
+
config['plugins'] = plugins;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// add themes if sources were added
|
|
70
|
+
if( themes.length ){
|
|
71
|
+
config['themes'] = themes;
|
|
42
72
|
}
|
|
43
73
|
|
|
44
74
|
return config;
|
package/lib/divi.js
CHANGED
package/lib/download-sources.js
CHANGED
|
@@ -256,7 +256,7 @@ function dowloadPlugins(pluginDir){
|
|
|
256
256
|
return [
|
|
257
257
|
{
|
|
258
258
|
basename: 'Design System',
|
|
259
|
-
url: 'https://github.com/
|
|
259
|
+
url: 'https://github.com/CAWebPublishing/design-system-wordpress.git',
|
|
260
260
|
ref: 'main',
|
|
261
261
|
path: path.join(pluginDir, 'design-system-wordpress'),
|
|
262
262
|
clonePath: path.join(pluginDir, 'design-system-wordpress'),
|
package/lib/env.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import start from './start.js';
|
|
5
|
-
import destroy from './destroy.js';
|
|
6
|
-
import test from './test.js';
|
|
7
|
-
import shell from './shell.js';
|
|
8
4
|
|
|
9
|
-
import
|
|
5
|
+
import * as commands from './commands/index.js';
|
|
10
6
|
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
destroy,
|
|
14
|
-
test,
|
|
15
|
-
shell,
|
|
16
|
-
updatePlugins
|
|
7
|
+
export default {
|
|
8
|
+
...commands
|
|
17
9
|
}
|