@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.
- package/README.md +62 -27
- package/bin/caweb +1 -1
- package/bin/wp-cli.phar +0 -0
- package/commands/a11y.js +74 -0
- package/commands/blocks/create-block.js +109 -0
- package/commands/blocks/update-block.js +60 -0
- package/commands/build.js +73 -0
- package/commands/env/destroy.js +49 -0
- package/{lib/commands → commands/env}/start.js +30 -27
- package/{lib/commands → commands/env}/stop.js +4 -10
- package/{lib/commands → commands}/index.js +51 -39
- package/commands/serve.js +78 -0
- package/commands/sync.js +498 -0
- package/{lib/commands → commands}/tasks/update-plugins.js +2 -2
- package/commands/test.js +100 -0
- package/configs/aceconfig.js +28 -0
- package/{lib/configs.js → configs/docker-compose.js} +32 -55
- package/configs/webpack.config.js +119 -0
- package/configs/wp-env.js +76 -0
- package/gen/parser.js +166 -0
- package/gen/site-generator.js +111 -0
- package/lib/admin.js +40 -0
- package/lib/cli.js +129 -63
- package/lib/env.js +3 -11
- package/lib/helpers.js +109 -0
- package/lib/index.js +28 -0
- package/lib/spinner.js +10 -7
- package/lib/{caweb.js → wordpress/caweb.js} +1 -1
- package/lib/{divi.js → wordpress/divi.js} +1 -1
- package/lib/{download-sources.js → wordpress/download-sources.js} +75 -79
- package/lib/wordpress/index.js +16 -0
- package/lib/{options.js → wordpress/options.js} +1 -1
- package/lib/{wordpress.js → wordpress/wordpress.js} +4 -8
- package/package.json +42 -27
- package/template/assets/css/popover.css +80 -0
- package/template/assets/js/popover.js +30 -0
- package/template/block/edit.js.mustache +48 -0
- package/template/block/editor.scss.mustache +5 -0
- package/template/block/index.js.mustache +40 -0
- package/template/block/save.js.mustache +21 -0
- package/template/block/style.scss.mustache +6 -0
- package/template/index.cjs +48 -0
- package/template/plugin/$slug.php.mustache +135 -0
- package/template/plugin/core/cdec-api.php.mustache +44 -0
- package/template/plugin/core/filters.php.mustache +111 -0
- package/template/plugin/core/functions.php.mustache +25 -0
- package/template/plugin/inc/renderer.php.mustache +25 -0
- package/lib/commands/destroy.js +0 -66
- package/lib/commands/test.js +0 -46
- package/lib/docker.js +0 -68
- /package/{lib/commands → commands/tasks}/shell.js +0 -0
|
@@ -29,81 +29,6 @@ const pipeline = util.promisify( stream.pipeline );
|
|
|
29
29
|
const extractZip = util.promisify( zip );
|
|
30
30
|
const rimraf = util.promisify( rim );
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* Download CAWeb Resources.
|
|
34
|
-
*
|
|
35
|
-
* @param {Object} spinner The spinner object to show progress.
|
|
36
|
-
* @return {WPConfig} The config object we've loaded.
|
|
37
|
-
*/
|
|
38
|
-
async function downloadSources(
|
|
39
|
-
{
|
|
40
|
-
spinner,
|
|
41
|
-
config
|
|
42
|
-
}
|
|
43
|
-
) {
|
|
44
|
-
const progresses = {};
|
|
45
|
-
const getProgressSetter = ( id ) => ( progress ) => {
|
|
46
|
-
progresses[ id ] = progress;
|
|
47
|
-
spinner.text =
|
|
48
|
-
`Downloading ${id}.\n` +
|
|
49
|
-
Object.entries( progresses )
|
|
50
|
-
.map(
|
|
51
|
-
( [ key, value ] ) =>
|
|
52
|
-
` - ${ key }: ${ ( value * 100 ).toFixed( 0 ) }/100%`
|
|
53
|
-
)
|
|
54
|
-
.join( '\n' );
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const { workDirectoryPath } = config;
|
|
58
|
-
const { development: dev, tests: test } = config.env;
|
|
59
|
-
|
|
60
|
-
let pluginDir = path.resolve(workDirectoryPath, 'plugins');
|
|
61
|
-
let themeDir = path.resolve(workDirectoryPath, 'themes');
|
|
62
|
-
|
|
63
|
-
let sources = dowloadPlugins(pluginDir);
|
|
64
|
-
|
|
65
|
-
// Add Divi Theme and plugin to sources.
|
|
66
|
-
if( (undefined !== dev.config.ET_USERNAME &&
|
|
67
|
-
undefined !== dev.config.ET_API_KEY) ||
|
|
68
|
-
(undefined !== test.config.ET_USERNAME &&
|
|
69
|
-
undefined !== test.config.ET_API_KEY)
|
|
70
|
-
){
|
|
71
|
-
let url = 'https://www.elegantthemes.com/api/api_downloads.php';
|
|
72
|
-
let user = undefined !== dev.config.ET_USERNAME ? dev.config.ET_USERNAME : test.config.ET_USERNAME;
|
|
73
|
-
let key = undefined !== dev.config.ET_API_KEY ? dev.config.ET_API_KEY : test.config.ET_API_KEY;
|
|
74
|
-
|
|
75
|
-
// Add Divi sources.
|
|
76
|
-
sources = sources.concat( [
|
|
77
|
-
{
|
|
78
|
-
basename: 'Divi',
|
|
79
|
-
url: `${url}?api_update=1&theme=Divi&api_key=${key}&username=${user}`,
|
|
80
|
-
path: path.join(themeDir, 'Divi'),
|
|
81
|
-
type: 'zip'
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
basename: 'Divi Plugin',
|
|
85
|
-
url: `${url}?api_update=1&theme=divi-builder&api_key=${key}&username=${user}`,
|
|
86
|
-
path: path.join(pluginDir, 'divi-builder'),
|
|
87
|
-
type: 'zip'
|
|
88
|
-
}
|
|
89
|
-
]);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Ensure plugin/theme directory exists for downloading resources.
|
|
93
|
-
fs.ensureDir(themeDir);
|
|
94
|
-
fs.ensureDir(pluginDir);
|
|
95
|
-
|
|
96
|
-
await Promise.all(
|
|
97
|
-
sources.map( ( source ) =>
|
|
98
|
-
downloadSource( source, {
|
|
99
|
-
onProgress: getProgressSetter( source.basename ),
|
|
100
|
-
spinner,
|
|
101
|
-
} )
|
|
102
|
-
)
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
|
|
107
32
|
/**
|
|
108
33
|
* Downloads the given source if necessary. The specific action taken depends
|
|
109
34
|
* on the source type. The source is downloaded to source.path.
|
|
@@ -256,7 +181,7 @@ function dowloadPlugins(pluginDir){
|
|
|
256
181
|
return [
|
|
257
182
|
{
|
|
258
183
|
basename: 'Design System',
|
|
259
|
-
url: 'https://github.com/
|
|
184
|
+
url: 'https://github.com/CAWebPublishing/design-system-wordpress.git',
|
|
260
185
|
ref: 'main',
|
|
261
186
|
path: path.join(pluginDir, 'design-system-wordpress'),
|
|
262
187
|
clonePath: path.join(pluginDir, 'design-system-wordpress'),
|
|
@@ -272,6 +197,77 @@ function dowloadPlugins(pluginDir){
|
|
|
272
197
|
]
|
|
273
198
|
}
|
|
274
199
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Download CAWeb Resources.
|
|
202
|
+
*
|
|
203
|
+
* @param {Object} spinner The spinner object to show progress.
|
|
204
|
+
* @return {WPConfig} The config object we've loaded.
|
|
205
|
+
*/
|
|
206
|
+
export async function downloadSources(
|
|
207
|
+
{
|
|
208
|
+
spinner,
|
|
209
|
+
config
|
|
210
|
+
}
|
|
211
|
+
) {
|
|
212
|
+
const progresses = {};
|
|
213
|
+
const getProgressSetter = ( id ) => ( progress ) => {
|
|
214
|
+
progresses[ id ] = progress;
|
|
215
|
+
spinner.text =
|
|
216
|
+
`Downloading ${id}.\n` +
|
|
217
|
+
Object.entries( progresses )
|
|
218
|
+
.map(
|
|
219
|
+
( [ key, value ] ) =>
|
|
220
|
+
` - ${ key }: ${ ( value * 100 ).toFixed( 0 ) }/100%`
|
|
221
|
+
)
|
|
222
|
+
.join( '\n' );
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const { workDirectoryPath } = config;
|
|
226
|
+
const { development: dev, tests: test } = config.env;
|
|
227
|
+
|
|
228
|
+
let pluginDir = path.resolve(workDirectoryPath, 'plugins');
|
|
229
|
+
let themeDir = path.resolve(workDirectoryPath, 'themes');
|
|
230
|
+
|
|
231
|
+
let sources = dowloadPlugins(pluginDir);
|
|
232
|
+
|
|
233
|
+
// Add Divi Theme and plugin to sources.
|
|
234
|
+
if( (undefined !== dev.config.ET_USERNAME &&
|
|
235
|
+
undefined !== dev.config.ET_API_KEY) ||
|
|
236
|
+
(undefined !== test.config.ET_USERNAME &&
|
|
237
|
+
undefined !== test.config.ET_API_KEY)
|
|
238
|
+
){
|
|
239
|
+
let url = 'https://www.elegantthemes.com/api/api_downloads.php';
|
|
240
|
+
let user = undefined !== dev.config.ET_USERNAME ? dev.config.ET_USERNAME : test.config.ET_USERNAME;
|
|
241
|
+
let key = undefined !== dev.config.ET_API_KEY ? dev.config.ET_API_KEY : test.config.ET_API_KEY;
|
|
242
|
+
|
|
243
|
+
// Add Divi sources.
|
|
244
|
+
sources = sources.concat( [
|
|
245
|
+
{
|
|
246
|
+
basename: 'Divi',
|
|
247
|
+
url: `${url}?api_update=1&theme=Divi&api_key=${key}&username=${user}`,
|
|
248
|
+
path: path.join(themeDir, 'Divi'),
|
|
249
|
+
type: 'zip'
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
basename: 'Divi Plugin',
|
|
253
|
+
url: `${url}?api_update=1&theme=divi-builder&api_key=${key}&username=${user}`,
|
|
254
|
+
path: path.join(pluginDir, 'divi-builder'),
|
|
255
|
+
type: 'zip'
|
|
256
|
+
}
|
|
257
|
+
]);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Ensure plugin/theme directory exists for downloading resources.
|
|
261
|
+
fs.ensureDir(themeDir);
|
|
262
|
+
fs.ensureDir(pluginDir);
|
|
263
|
+
|
|
264
|
+
await Promise.all(
|
|
265
|
+
sources.map( ( source ) =>
|
|
266
|
+
downloadSource( source, {
|
|
267
|
+
onProgress: getProgressSetter( source.basename ),
|
|
268
|
+
spinner,
|
|
269
|
+
} )
|
|
270
|
+
)
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { activateCAWeb, configureCAWeb } from "./caweb.js";
|
|
2
|
+
import { downloadSources } from "./download-sources.js";
|
|
3
|
+
import { configureDivi, isDiviThemeActive } from "./divi.js";
|
|
4
|
+
import { configureWordPress, isMultisite, convertToMultisite, generateHTAccess } from "./wordpress.js";
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
activateCAWeb,
|
|
8
|
+
configureCAWeb,
|
|
9
|
+
downloadSources,
|
|
10
|
+
configureDivi,
|
|
11
|
+
isDiviThemeActive,
|
|
12
|
+
configureWordPress,
|
|
13
|
+
isMultisite,
|
|
14
|
+
convertToMultisite,
|
|
15
|
+
generateHTAccess
|
|
16
|
+
}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import fs from 'fs
|
|
5
|
-
import path from '
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import {runCLICmds} from '
|
|
10
|
+
import {runCLICmds} from '../helpers.js';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Promisified dependencies
|
|
14
|
-
*/
|
|
15
|
-
const { writeFile } = fs.promises;
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
14
|
* Checks whether WordPress environment is a multisite installation.
|
|
@@ -128,7 +124,7 @@ async function generateHTAccess(environment, workDirectoryPath, subdomain){
|
|
|
128
124
|
|
|
129
125
|
let folder = 'development' === environment ? 'WordPress' : 'Tests-WordPress'
|
|
130
126
|
|
|
131
|
-
|
|
127
|
+
fs.writeFileSync(path.join(workDirectoryPath, folder, '.htaccess'), htaccess);
|
|
132
128
|
|
|
133
129
|
}
|
|
134
130
|
|
package/package.json
CHANGED
|
@@ -1,55 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "CAWebPublishing Command Line Interface.",
|
|
5
5
|
"exports": "./lib/env.js",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"node": ">=
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"lib"
|
|
11
|
-
],
|
|
12
|
-
"directories": {
|
|
13
|
-
"doc": "docs",
|
|
14
|
-
"lib": "lib"
|
|
15
|
-
},
|
|
7
|
+
"node": ">=20",
|
|
8
|
+
"author": "CAWebPublishing",
|
|
9
|
+
"license": "ISC",
|
|
16
10
|
"bin": {
|
|
17
11
|
"caweb": "bin/caweb"
|
|
18
12
|
},
|
|
13
|
+
"files": [
|
|
14
|
+
"assets",
|
|
15
|
+
"bin",
|
|
16
|
+
"commands",
|
|
17
|
+
"configs",
|
|
18
|
+
"gen",
|
|
19
|
+
"lib",
|
|
20
|
+
"template"
|
|
21
|
+
],
|
|
19
22
|
"scripts": {
|
|
20
|
-
"caweb": "caweb",
|
|
21
|
-
"wp-env": "wp-env",
|
|
22
|
-
"local": "npm pack && npm i caweb-cli-%npm_package_version%.tgz",
|
|
23
23
|
"test": "echo \"Error: run tests from root\" && exit 0"
|
|
24
24
|
},
|
|
25
|
+
"homepage": "https://github.com/CAWebPublishing/caweb-cli#readme",
|
|
25
26
|
"repository": {
|
|
26
27
|
"type": "git",
|
|
27
28
|
"url": "git+https://github.com/CAWebPublishing/caweb-cli.git"
|
|
28
29
|
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/CAWebPublishing/caweb-cli/issues"
|
|
32
|
+
},
|
|
29
33
|
"keywords": [
|
|
30
34
|
"caweb",
|
|
31
35
|
"cagov"
|
|
32
36
|
],
|
|
33
|
-
"author": "CAWebPublishing",
|
|
34
|
-
"license": "ISC",
|
|
35
|
-
"bugs": {
|
|
36
|
-
"url": "https://github.com/CAWebPublishing/caweb-cli/issues"
|
|
37
|
-
},
|
|
38
37
|
"publishConfig": {
|
|
39
38
|
"access": "public"
|
|
40
39
|
},
|
|
41
|
-
"homepage": "https://github.com/CAWebPublishing/caweb-cli#readme",
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"@wordpress/env": "^9.0.0",
|
|
44
|
-
"chalk": "^4.0.0",
|
|
45
|
-
"commander": "^11.1.0",
|
|
46
|
-
"fs-extra": "^11.1.1"
|
|
47
|
-
},
|
|
48
40
|
"config": {
|
|
49
|
-
"WP_VER": "6.4.
|
|
41
|
+
"WP_VER": "6.4.3",
|
|
50
42
|
"PHP_VER": "8.1",
|
|
43
|
+
"CREATE_BLOCK_VER": "4.32.0",
|
|
51
44
|
"DEFAULTS": {
|
|
52
|
-
"WP_DEFAULT_THEME": "CAWeb",
|
|
53
45
|
"FS_METHOD": "direct",
|
|
54
46
|
"WP_DEBUG": true,
|
|
55
47
|
"WP_DEBUG_LOG": true,
|
|
@@ -63,5 +55,28 @@
|
|
|
63
55
|
"SITECOOKIEPATH": "",
|
|
64
56
|
"CONCATENATE_SCRIPTS": false
|
|
65
57
|
}
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@wordpress/env": "^9.2.0",
|
|
61
|
+
"@wordpress/scripts": "^27.1.0",
|
|
62
|
+
"accessibility-checker": "^3.1.67",
|
|
63
|
+
"autoprefixer": "^10.4.17",
|
|
64
|
+
"axios": "^1.6.7",
|
|
65
|
+
"chalk": "^5.3.0",
|
|
66
|
+
"commander": "^12.0.0",
|
|
67
|
+
"cross-spawn": "^7.0.3",
|
|
68
|
+
"css-loader": "^6.10.0",
|
|
69
|
+
"docker-compose": "^0.24.3",
|
|
70
|
+
"handlebars-loader": "^1.7.3",
|
|
71
|
+
"html-to-json-parser": "^2.0.0",
|
|
72
|
+
"html-webpack-plugin": "^5.6.0",
|
|
73
|
+
"mini-css-extract-plugin": "^2.8.0",
|
|
74
|
+
"ora": "^8.0.1",
|
|
75
|
+
"postcss-loader": "^8.1.0",
|
|
76
|
+
"resolve-bin": "^1.0.1",
|
|
77
|
+
"sass-loader": "^14.1.0",
|
|
78
|
+
"terminal-link": "^3.0.0",
|
|
79
|
+
"url": "^0.11.3",
|
|
80
|
+
"webpack": "^5.90.1"
|
|
66
81
|
}
|
|
67
82
|
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers a new block provided a unique name and an object defining its behavior.
|
|
3
|
+
*
|
|
4
|
+
* @see https://developer.wordpress.org/block-editor/developers/block-api/#registering-a-block
|
|
5
|
+
*/
|
|
6
|
+
import { registerBlockType } from '@wordpress/blocks';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
|
|
10
|
+
* All files containing `style` keyword are bundled together. The code used
|
|
11
|
+
* gets applied both to the front of your site and to the editor. All other files
|
|
12
|
+
* get applied to the editor only.
|
|
13
|
+
*
|
|
14
|
+
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css
|
|
15
|
+
*/
|
|
16
|
+
import './style.scss';
|
|
17
|
+
import './editor.scss';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
import Edit from './edit';
|
|
23
|
+
import save from './save';
|
|
24
|
+
import metadata from './block.json';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Every block starts by registering a new block type definition.
|
|
28
|
+
*
|
|
29
|
+
* @see https://developer.wordpress.org/block-editor/developers/block-api/#registering-a-block
|
|
30
|
+
*/
|
|
31
|
+
registerBlockType( metadata.name, {
|
|
32
|
+
/**
|
|
33
|
+
* @see ./edit.js
|
|
34
|
+
*/
|
|
35
|
+
edit: Edit,
|
|
36
|
+
/**
|
|
37
|
+
* @see ./save.js
|
|
38
|
+
*/
|
|
39
|
+
save,
|
|
40
|
+
} );
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hook that is used to mark the block wrapper element.
|
|
3
|
+
* It provides all the necessary props like the class name.
|
|
4
|
+
*
|
|
5
|
+
* @see https://developer.wordpress.org/block-editor/packages/packages-block-editor/#useBlockProps
|
|
6
|
+
*/
|
|
7
|
+
import { InnerBlocks } from '@wordpress/block-editor';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The save function defines the way in which the different attributes should
|
|
11
|
+
* be combined into the final markup, which is then serialized by the block
|
|
12
|
+
* editor into `post_content`.
|
|
13
|
+
*
|
|
14
|
+
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#save
|
|
15
|
+
*
|
|
16
|
+
* @return {WPElement} Element to render.
|
|
17
|
+
*/
|
|
18
|
+
export default function save(props) {
|
|
19
|
+
return <InnerBlocks.Content />;
|
|
20
|
+
}
|
|
21
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
const { join } = require( 'path' );
|
|
5
|
+
const { capitalCase } = require( 'change-case' );
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
const blockSlug = process.argv[ 2 ];
|
|
11
|
+
const blockSlugTitle = capitalCase( blockSlug );
|
|
12
|
+
|
|
13
|
+
const customScripts = {};
|
|
14
|
+
|
|
15
|
+
const npmDependencies = [
|
|
16
|
+
'@wordpress/icons@9.22.0'
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const npmDevDependencies = [];
|
|
20
|
+
|
|
21
|
+
// assetsPath: join( __dirname, 'assets' ),
|
|
22
|
+
module.exports = {
|
|
23
|
+
pluginTemplatesPath: join( __dirname, 'plugin' ),
|
|
24
|
+
blockTemplatesPath: join( __dirname, 'block' ),
|
|
25
|
+
defaultValues: {
|
|
26
|
+
pluginURI: `https://github.com/CAWebPublishing/${ blockSlug }`,
|
|
27
|
+
plugin: true,
|
|
28
|
+
description: `${ blockSlugTitle } Gutenberg Block`,
|
|
29
|
+
version: '1.2.0',
|
|
30
|
+
author: 'CAWebPublishing',
|
|
31
|
+
license: 'GPL-2.0-or-later',
|
|
32
|
+
licenseURI: 'https://www.gnu.org/licenses/gpl-2.0.html',
|
|
33
|
+
namespace: 'caweb',
|
|
34
|
+
category: 'cagov-design-system',
|
|
35
|
+
textdomain: 'cagov-design-system',
|
|
36
|
+
dashicon: 'format-aside',
|
|
37
|
+
supports: {
|
|
38
|
+
html: true,
|
|
39
|
+
},
|
|
40
|
+
attributes: {},
|
|
41
|
+
example: {
|
|
42
|
+
attributes: {}
|
|
43
|
+
},
|
|
44
|
+
customScripts: customScripts,
|
|
45
|
+
npmDependencies: npmDependencies,
|
|
46
|
+
npmDevDependencies: npmDevDependencies,
|
|
47
|
+
},
|
|
48
|
+
};
|