@caweb/cli 1.0.5 → 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/bin/caweb +3 -17
- package/lib/admin.js +40 -0
- package/lib/caweb.js +20 -17
- package/lib/cli.js +224 -142
- package/lib/commands/blocks/create-block.js +110 -0
- package/lib/commands/blocks/update-block.js +66 -0
- package/lib/commands/destroy.js +56 -0
- package/lib/commands/index.js +33 -9
- package/lib/commands/shell.js +2 -3
- package/lib/commands/start.js +57 -69
- package/lib/commands/stop.js +41 -0
- package/lib/commands/tasks/update-plugins.js +15 -8
- package/lib/commands/test.js +17 -70
- package/lib/configs.js +41 -21
- package/lib/divi.js +28 -26
- package/lib/download-sources.js +15 -15
- package/lib/env.js +3 -6
- package/lib/options.js +2 -2
- package/lib/spinner.js +70 -0
- 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 +45 -27
- package/package.json +10 -4
- package/lib/commands/tasks/index.js +0 -13
- package/lib/docker.js +0 -66
package/lib/commands/test.js
CHANGED
|
@@ -1,50 +1,20 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { execSync } = require( 'child_process' );
|
|
9
|
-
const dockerCompose = require( 'docker-compose' );
|
|
10
|
-
const loadConfig = require( '@wordpress/env/lib/config/load-config' );
|
|
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' );
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import loadConfig from '@wordpress/env/lib/config/load-config.js';
|
|
6
|
+
import fs from 'fs-extra';
|
|
14
7
|
|
|
15
8
|
/**
|
|
16
9
|
* Internal dependencies
|
|
17
10
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const {
|
|
23
|
-
buildWPEnvConfig,
|
|
24
|
-
buildDockerComposeConfig
|
|
25
|
-
} = require('../configs');
|
|
26
|
-
|
|
27
|
-
const pkg = require( '../../package.json' );
|
|
28
|
-
const { DIVI_OPTIONS } = require('../options');
|
|
29
|
-
|
|
30
|
-
const {
|
|
31
|
-
isDiviThemeActive,
|
|
32
|
-
configureDivi
|
|
33
|
-
} = require('../divi');
|
|
34
|
-
|
|
35
|
-
const {
|
|
36
|
-
activateCAWeb,
|
|
37
|
-
configureCAWeb
|
|
38
|
-
} = require('../caweb');
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
generateHTAccess
|
|
42
|
-
} = require( '../wordpress' );
|
|
11
|
+
import { runCLICmds, runCmd } from '../utils.js';
|
|
12
|
+
import generateOverridesMD from '../admin.js';
|
|
13
|
+
import { CAWEB_OPTIONS, DIVI_OPTIONS } from '../options.js';
|
|
43
14
|
|
|
44
15
|
/**
|
|
45
16
|
* Promisified dependencies
|
|
46
17
|
*/
|
|
47
|
-
const { writeFile } = fs.promises;
|
|
48
18
|
|
|
49
19
|
/**
|
|
50
20
|
* Test code.
|
|
@@ -54,46 +24,23 @@ const { writeFile } = fs.promises;
|
|
|
54
24
|
* @param {boolean} options.environment Which environment to test in.
|
|
55
25
|
* @param {boolean} options.debug True if debug mode is enabled.
|
|
56
26
|
*/
|
|
57
|
-
|
|
27
|
+
export default async function test({
|
|
58
28
|
spinner,
|
|
59
|
-
environment,
|
|
60
29
|
debug,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}) {
|
|
30
|
+
environment
|
|
31
|
+
} ) {
|
|
64
32
|
|
|
65
|
-
|
|
33
|
+
spinner.text = "Testing Code Functionality";
|
|
66
34
|
const config = await loadConfig(path.resolve('.'));
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
spinner.text = "Testing code...";
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
spinner.text = 'Completed Testing code...'
|
|
77
|
-
|
|
78
|
-
/*
|
|
79
|
-
let result = await runDockerCmds(
|
|
80
|
-
environment,
|
|
81
|
-
['wp theme is-installed CAWeb'],
|
|
82
|
-
config
|
|
35
|
+
|
|
36
|
+
let result = await runCLICmds(
|
|
37
|
+
'development',
|
|
38
|
+
['wp --version'],
|
|
39
|
+
config,
|
|
40
|
+
spinner
|
|
83
41
|
)
|
|
84
42
|
|
|
85
|
-
if( '' !== result.out ) {
|
|
86
|
-
console.log( JSON.parse(result.out))
|
|
87
|
-
}else{
|
|
88
|
-
console.log(result);
|
|
89
|
-
}
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
43
|
|
|
93
|
-
|
|
94
|
-
console.log(error)
|
|
44
|
+
console.log( result );
|
|
95
45
|
|
|
96
|
-
process.exit( 1 );
|
|
97
|
-
}
|
|
98
|
-
|
|
99
46
|
};
|
package/lib/configs.js
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const getHostUser = require( '@wordpress/env/lib/get-host-user' );
|
|
9
|
-
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import yaml from 'js-yaml';
|
|
7
|
+
import getHostUser from '@wordpress/env/lib/get-host-user.js';
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* Promisified dependencies
|
|
13
11
|
*/
|
|
14
12
|
const { writeFile } = fs.promises;
|
|
15
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
|
+
|
|
16
17
|
/**
|
|
17
18
|
* Build .wp-env.json
|
|
18
19
|
*
|
|
19
20
|
* @param {boolean} bare True if excluding any CAWeb Configurations.
|
|
20
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.
|
|
21
24
|
*
|
|
22
25
|
* @returns object
|
|
23
26
|
*/
|
|
24
|
-
const buildWPEnvConfig = (bare, multisite) => {
|
|
27
|
+
const buildWPEnvConfig = (bare, multisite, plugin, theme) => {
|
|
28
|
+
let themes = [];
|
|
29
|
+
let plugins = [];
|
|
30
|
+
|
|
25
31
|
let config = {
|
|
26
32
|
core: `WordPress/WordPress#${pkg.config.WP_VER}`,
|
|
27
33
|
phpVersion: `${pkg.config.PHP_VER}`,
|
|
@@ -32,12 +38,37 @@ const buildWPEnvConfig = (bare, multisite) => {
|
|
|
32
38
|
|
|
33
39
|
// if not bare then include our theme.
|
|
34
40
|
if( ! bare ){
|
|
35
|
-
|
|
41
|
+
themes.push('CAWebPublishing/CAWeb')
|
|
36
42
|
}
|
|
37
43
|
|
|
44
|
+
// if root directory is a theme
|
|
45
|
+
if( theme ){
|
|
46
|
+
themes.push( '.' );
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
// if is multisite
|
|
39
50
|
if( multisite ){
|
|
40
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;
|
|
41
72
|
}
|
|
42
73
|
|
|
43
74
|
return config;
|
|
@@ -64,18 +95,7 @@ const buildDockerComposeConfig = (workDirectoryPath) => {
|
|
|
64
95
|
restart: 'always',
|
|
65
96
|
ports: ['8080:80'],
|
|
66
97
|
environment: {
|
|
67
|
-
|
|
68
|
-
UPLOAD_LIMIT: '3G',
|
|
69
|
-
MEMORY_LIMIT: '5G',
|
|
70
|
-
MAX_EXECUTION_TIME: 7200
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
"tests-phpmyadmin": {
|
|
74
|
-
image: `phpmyadmin:latest`,
|
|
75
|
-
restart: 'always',
|
|
76
|
-
ports: ['9090:80'],
|
|
77
|
-
environment: {
|
|
78
|
-
PMA_HOST : 'tests-mysql',
|
|
98
|
+
PMA_HOSTS : 'mysql,tests-mysql',
|
|
79
99
|
UPLOAD_LIMIT: '3G',
|
|
80
100
|
MEMORY_LIMIT: '5G',
|
|
81
101
|
MAX_EXECUTION_TIME: 7200
|
|
@@ -175,7 +195,7 @@ async function generateCLIConfig(workDirectoryPath){
|
|
|
175
195
|
yaml.dump(yml));
|
|
176
196
|
}
|
|
177
197
|
|
|
178
|
-
|
|
198
|
+
export {
|
|
179
199
|
buildWPEnvConfig,
|
|
180
200
|
buildDockerComposeConfig
|
|
181
201
|
}
|
package/lib/divi.js
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* Internal dependencies
|
|
9
3
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { runCLICmds } from './utils.js';
|
|
5
|
+
import { DIVI_OPTIONS } from './options.js';
|
|
12
6
|
|
|
13
7
|
|
|
14
8
|
/**
|
|
15
9
|
* Checks if Divi Theme is active for the WordPress Environment.
|
|
16
10
|
*
|
|
17
|
-
* @param {string}
|
|
18
|
-
* @param {WPConfig}
|
|
11
|
+
* @param {string} environment Which environment to activate the theme on.
|
|
12
|
+
* @param {WPConfig} config The wp-env config object.
|
|
13
|
+
* @param {Object} spinner A CLI spinner which indicates progress.
|
|
19
14
|
*/
|
|
20
15
|
async function isDiviThemeActive(
|
|
21
16
|
environment,
|
|
22
|
-
config
|
|
17
|
+
config,
|
|
18
|
+
spinner
|
|
23
19
|
){
|
|
24
20
|
|
|
25
|
-
return await
|
|
21
|
+
return await runCLICmds(
|
|
26
22
|
environment,
|
|
27
23
|
['wp theme is-active Divi'],
|
|
28
|
-
config
|
|
24
|
+
config,
|
|
25
|
+
spinner
|
|
29
26
|
);
|
|
30
27
|
|
|
31
28
|
}
|
|
@@ -40,31 +37,34 @@ async function isDiviThemeActive(
|
|
|
40
37
|
*/
|
|
41
38
|
async function configureDivi( environment, config, spinner ) {
|
|
42
39
|
|
|
43
|
-
const activeTheme = await isDiviThemeActive( environment, config );
|
|
40
|
+
const activeTheme = await isDiviThemeActive( environment, config, spinner );
|
|
44
41
|
|
|
45
42
|
// if Divi theme is active.
|
|
46
43
|
if( false !== activeTheme ){
|
|
47
44
|
let cmds = [];
|
|
48
|
-
let diviOptions = await
|
|
45
|
+
let diviOptions = await runCLICmds(
|
|
49
46
|
environment,
|
|
50
47
|
[ 'wp option get et_divi --format=json' ],
|
|
51
|
-
config
|
|
48
|
+
config,
|
|
49
|
+
spinner
|
|
52
50
|
)
|
|
53
|
-
let diviBuilderOptions = await
|
|
51
|
+
let diviBuilderOptions = await runCLICmds(
|
|
54
52
|
environment,
|
|
55
53
|
[ 'wp option get et_bfb_settings --format=json' ],
|
|
56
|
-
config
|
|
54
|
+
config,
|
|
55
|
+
spinner
|
|
57
56
|
)
|
|
58
|
-
let diviUpdateOptions = await
|
|
57
|
+
let diviUpdateOptions = await runCLICmds(
|
|
59
58
|
environment,
|
|
60
59
|
[ 'wp option get et_automatic_updates_options --format=json' ],
|
|
61
|
-
config
|
|
60
|
+
config,
|
|
61
|
+
spinner
|
|
62
62
|
)
|
|
63
63
|
|
|
64
64
|
// parse the options into a json object.
|
|
65
|
-
diviOptions = diviOptions ? JSON.parse( diviOptions ) : {};
|
|
66
|
-
diviBuilderOptions = diviBuilderOptions ? JSON.parse( diviBuilderOptions ) : {};
|
|
67
|
-
diviUpdateOptions =
|
|
65
|
+
diviOptions = typeof result === 'object' && ! diviOptions.exitCode ? JSON.parse( diviOptions ) : {};
|
|
66
|
+
diviBuilderOptions = typeof result === 'object' && ! diviBuilderOptions.exitCode ? JSON.parse( diviBuilderOptions ) : {};
|
|
67
|
+
diviUpdateOptions = typeof result === 'object' && ! diviUpdateOptions.exitCode ? JSON.parse( diviUpdateOptions ) : {};
|
|
68
68
|
|
|
69
69
|
// iterate over mapped Divi option groups.
|
|
70
70
|
Object.entries(DIVI_OPTIONS).forEach(([group, options]) => {
|
|
@@ -95,6 +95,7 @@ async function configureDivi( environment, config, spinner ) {
|
|
|
95
95
|
diviBuilderOptions = JSON.stringify( diviBuilderOptions );
|
|
96
96
|
diviUpdateOptions = JSON.stringify( diviUpdateOptions );
|
|
97
97
|
|
|
98
|
+
// update each option.
|
|
98
99
|
cmds.push(`wp option update et_divi '${diviOptions}' --format=json`);
|
|
99
100
|
cmds.push(`wp option update et_bfb_settings '${diviBuilderOptions}' --format=json`);
|
|
100
101
|
cmds.push(`wp option update et_automatic_updates_options '${diviUpdateOptions}' --format=json`);
|
|
@@ -109,17 +110,18 @@ async function configureDivi( environment, config, spinner ) {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
// Execute theme option commands.
|
|
112
|
-
await
|
|
113
|
+
await runCLICmds(
|
|
113
114
|
environment,
|
|
114
115
|
cmds,
|
|
115
|
-
config
|
|
116
|
+
config,
|
|
117
|
+
spinner
|
|
116
118
|
)
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
|
|
124
|
+
export {
|
|
123
125
|
configureDivi,
|
|
124
126
|
isDiviThemeActive
|
|
125
127
|
};
|
package/lib/download-sources.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Modified from wp-env
|
|
2
|
+
* Modified from wp-env
|
|
3
3
|
* Few modifications made:
|
|
4
4
|
* - Downloads CAWebPublishing Resources, excluding WordPress.
|
|
5
|
-
* - Target directory for downloadZipSource is expected to be absolute.
|
|
6
5
|
* - Ensure parent directory of source.path exists before attempting to extract in downloadZipSource, otherwise it will complain that file/directory doesn't exist.
|
|
7
6
|
* @see @wordpress/env/lib/download-sources.js
|
|
8
7
|
*/
|
|
9
|
-
|
|
8
|
+
|
|
10
9
|
/**
|
|
11
10
|
* External dependencies
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
import util from 'util';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import fs from 'fs-extra';
|
|
15
|
+
import SimpleGit from 'simple-git';
|
|
16
|
+
import got from 'got';
|
|
17
|
+
import stream from 'stream';
|
|
18
|
+
import zip from 'extract-zip';
|
|
19
|
+
import rim from 'rimraf';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* Internal dependencies
|
|
@@ -23,9 +25,9 @@ const got = require( 'got' );
|
|
|
23
25
|
/**
|
|
24
26
|
* Promisified dependencies
|
|
25
27
|
*/
|
|
26
|
-
const pipeline = util.promisify(
|
|
27
|
-
const extractZip = util.promisify(
|
|
28
|
-
const rimraf = util.promisify(
|
|
28
|
+
const pipeline = util.promisify( stream.pipeline );
|
|
29
|
+
const extractZip = util.promisify( zip );
|
|
30
|
+
const rimraf = util.promisify( rim );
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Download CAWeb Resources.
|
|
@@ -120,7 +122,6 @@ async function downloadSource(src, { onProgress, spinner, debug } ){
|
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
|
|
124
125
|
/**
|
|
125
126
|
* Clones the git repository at `source.url` into `source.path`. If the
|
|
126
127
|
* repository already exists, it is updated instead.
|
|
@@ -255,7 +256,7 @@ function dowloadPlugins(pluginDir){
|
|
|
255
256
|
return [
|
|
256
257
|
{
|
|
257
258
|
basename: 'Design System',
|
|
258
|
-
url: 'https://github.com/
|
|
259
|
+
url: 'https://github.com/CAWebPublishing/design-system-wordpress.git',
|
|
259
260
|
ref: 'main',
|
|
260
261
|
path: path.join(pluginDir, 'design-system-wordpress'),
|
|
261
262
|
clonePath: path.join(pluginDir, 'design-system-wordpress'),
|
|
@@ -271,7 +272,6 @@ function dowloadPlugins(pluginDir){
|
|
|
271
272
|
]
|
|
272
273
|
}
|
|
273
274
|
|
|
274
|
-
|
|
275
|
+
export {
|
|
275
276
|
downloadSources
|
|
276
|
-
|
|
277
277
|
}
|
package/lib/env.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
/**
|
|
3
2
|
* Internal dependencies
|
|
4
3
|
*/
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
//const { LifecycleScriptError } = require( './execute-lifecycle-script' );
|
|
8
|
-
const commands = require( './commands' );
|
|
5
|
+
import * as commands from './commands/index.js';
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
export default {
|
|
11
8
|
...commands
|
|
12
|
-
}
|
|
9
|
+
}
|
package/lib/options.js
CHANGED
|
@@ -170,7 +170,7 @@ const github_options = {
|
|
|
170
170
|
},
|
|
171
171
|
CAWEB_GIT_USER: {
|
|
172
172
|
name: 'caweb_username',
|
|
173
|
-
defaultValue: '
|
|
173
|
+
defaultValue: 'CAWebPublishing',
|
|
174
174
|
label: 'Username'
|
|
175
175
|
},
|
|
176
176
|
CAWEB_ACCESS_TOKEN: {
|
|
@@ -253,7 +253,7 @@ const DIVI_OPTIONS = {
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
|
|
256
|
+
export {
|
|
257
257
|
CAWEB_OPTIONS,
|
|
258
258
|
DIVI_OPTIONS
|
|
259
259
|
}
|
package/lib/spinner.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
|
|
4
|
+
// Colors.
|
|
5
|
+
const boldWhite = chalk.bold.white;
|
|
6
|
+
const wpPrimary = boldWhite.bgHex( '#00669b' );
|
|
7
|
+
const wpGreen = boldWhite.bgHex( '#4ab866' );
|
|
8
|
+
const wpRed = boldWhite.bgHex( '#d94f4f' );
|
|
9
|
+
const wpYellow = boldWhite.bgHex( '#f0b849' );
|
|
10
|
+
|
|
11
|
+
// Spinner.
|
|
12
|
+
const withSpinner =
|
|
13
|
+
( command ) =>
|
|
14
|
+
( ...args ) => {
|
|
15
|
+
const spinner = ora().start();
|
|
16
|
+
|
|
17
|
+
// commander passes arguments/options differently than yargs.
|
|
18
|
+
// lets combine arguments with options
|
|
19
|
+
const cmd = args.pop();
|
|
20
|
+
|
|
21
|
+
cmd.registeredArguments.forEach(arg => {
|
|
22
|
+
// get arg from list.
|
|
23
|
+
let v = args.shift();
|
|
24
|
+
|
|
25
|
+
// add arg to options.
|
|
26
|
+
args[args.length - 1][arg._name] = v;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// add any global options.
|
|
30
|
+
args[0] = {
|
|
31
|
+
...args[0],
|
|
32
|
+
...cmd.parent.opts()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
args[ 0 ].spinner = spinner;
|
|
36
|
+
let time = process.hrtime();
|
|
37
|
+
return command( ...args ).then(
|
|
38
|
+
( message ) => {
|
|
39
|
+
time = process.hrtime( time );
|
|
40
|
+
spinner.succeed(
|
|
41
|
+
`${ message || spinner.text } (in ${ time[ 0 ] }s ${ (
|
|
42
|
+
time[ 1 ] / 1e6
|
|
43
|
+
).toFixed( 0 ) }ms)`
|
|
44
|
+
);
|
|
45
|
+
process.exit( 0 );
|
|
46
|
+
},
|
|
47
|
+
( error ) => {
|
|
48
|
+
if( error ){
|
|
49
|
+
// Error is an unknown error. That means there was a bug in our code.
|
|
50
|
+
spinner.fail(
|
|
51
|
+
typeof error === 'string' ? error : error.message
|
|
52
|
+
);
|
|
53
|
+
// Disable reason: Using console.error() means we get a stack trace.
|
|
54
|
+
console.error( error );
|
|
55
|
+
process.exit( 1 );
|
|
56
|
+
}else{
|
|
57
|
+
spinner.fail( 'An unknown error occurred.' );
|
|
58
|
+
process.exit( 1 );
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
wpPrimary,
|
|
66
|
+
wpGreen,
|
|
67
|
+
wpRed,
|
|
68
|
+
wpYellow,
|
|
69
|
+
withSpinner
|
|
70
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
|
|
2
|
+
.popover-content {
|
|
3
|
+
position: absolute;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column-reverse;
|
|
6
|
+
row-gap: .5rem;
|
|
7
|
+
left: -10000px;
|
|
8
|
+
top: auto;
|
|
9
|
+
width: 1px;
|
|
10
|
+
height: 1px;
|
|
11
|
+
background-color: white;
|
|
12
|
+
padding: 1rem;
|
|
13
|
+
z-index: 100;
|
|
14
|
+
outline: 0;
|
|
15
|
+
border-radius: .5rem;
|
|
16
|
+
overflow: visible;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
--shadow-color: 220 3% 15%;
|
|
19
|
+
--shadow-strength: 1%;
|
|
20
|
+
box-shadow: 5px 7px 15px grey;
|
|
21
|
+
}
|
|
22
|
+
.popover-content:focus {
|
|
23
|
+
outline: 2px solid var(--highlight-color, #fec02f);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.popover-container {
|
|
27
|
+
position: relative;
|
|
28
|
+
width: fit-content;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.popover-content::before {
|
|
32
|
+
content: '';
|
|
33
|
+
position: absolute;
|
|
34
|
+
width: 1rem;
|
|
35
|
+
height: 1rem;
|
|
36
|
+
left: 0;
|
|
37
|
+
top: 50%;
|
|
38
|
+
background-color: white;
|
|
39
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
40
|
+
}
|
|
41
|
+
.popover-revealed {
|
|
42
|
+
width: max-content;
|
|
43
|
+
height: max-content;
|
|
44
|
+
left: var(--x);
|
|
45
|
+
top: var(--y);
|
|
46
|
+
transform: translateY(-50%);
|
|
47
|
+
}
|
|
48
|
+
@media screen and (max-width: 950px) {
|
|
49
|
+
.popover-content::before {
|
|
50
|
+
content: none;
|
|
51
|
+
}
|
|
52
|
+
.popover-revealed {
|
|
53
|
+
left: calc(50% + var(--x-offset-m, 0%));
|
|
54
|
+
transform: translate(-50%, 0);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.popover-legend {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: row;
|
|
61
|
+
gap: .75rem;
|
|
62
|
+
align-items: flex-start;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.popover-legend svg {
|
|
66
|
+
height: 1.5em;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.popover-revealed p {
|
|
70
|
+
font-weight: 400;
|
|
71
|
+
font-size: 1em;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.popover-header {
|
|
75
|
+
margin: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.popover-stat {
|
|
79
|
+
margin: 0 0 .5rem 0;
|
|
80
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
jQuery( document ).ready( function ( $ ) { // eslint-disable-line
|
|
2
|
+
$( document ).on( 'mouseover', '.popover', function ( ele ) {
|
|
3
|
+
togglePopover( ele.currentTarget.id );
|
|
4
|
+
} );
|
|
5
|
+
|
|
6
|
+
$( document ).on( 'mouseout', '.popover', function ( ele ) {
|
|
7
|
+
togglePopover( ele.currentTarget.id, false );
|
|
8
|
+
} );
|
|
9
|
+
|
|
10
|
+
function togglePopover( id, popin = true ) {
|
|
11
|
+
if ( undefined !== id ) {
|
|
12
|
+
const current = $( '#' + id );
|
|
13
|
+
const popver = $( '#' + id + '-popover' );
|
|
14
|
+
|
|
15
|
+
if ( popin ) {
|
|
16
|
+
current.addClass( 'highlighted' );
|
|
17
|
+
|
|
18
|
+
if ( undefined !== popver ) {
|
|
19
|
+
$( popver ).addClass( 'popover-revealed' );
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
current.removeClass( 'highlighted' );
|
|
23
|
+
|
|
24
|
+
if ( undefined !== popver ) {
|
|
25
|
+
$( popver ).removeClass( 'popover-revealed' );
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} );
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the translation of text.
|
|
3
|
+
*
|
|
4
|
+
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-i18n/
|
|
5
|
+
*/
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* React hook that is used to mark the block wrapper element.
|
|
10
|
+
* It provides all the necessary props like the class name.
|
|
11
|
+
*
|
|
12
|
+
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/
|
|
13
|
+
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops
|
|
14
|
+
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#richtext
|
|
15
|
+
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#innerblocks
|
|
16
|
+
*/
|
|
17
|
+
import { useBlockProps, RichText, InnerBlocks } from '@wordpress/block-editor';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
|
|
21
|
+
* Those files can contain any CSS code that gets applied to the editor.
|
|
22
|
+
*
|
|
23
|
+
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css
|
|
24
|
+
*/
|
|
25
|
+
import './editor.scss';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The edit function describes the structure of your block in the context of the
|
|
29
|
+
* editor. This represents what the editor will render when the block is used.
|
|
30
|
+
*
|
|
31
|
+
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit
|
|
32
|
+
*
|
|
33
|
+
* @return {WPElement} Element to render.
|
|
34
|
+
*/
|
|
35
|
+
export default function Edit(props) {
|
|
36
|
+
let {
|
|
37
|
+
setAttributes,
|
|
38
|
+
attributes: {}
|
|
39
|
+
} = props;
|
|
40
|
+
|
|
41
|
+
const blockProps = useBlockProps();
|
|
42
|
+
|
|
43
|
+
return(
|
|
44
|
+
<div {...blockProps}>
|
|
45
|
+
<p>Render Block Output</p>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|