@caweb/cli 1.15.15 → 1.15.17
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/commands/gen-scripts.js
CHANGED
|
@@ -38,12 +38,13 @@ export default async function genScripts({
|
|
|
38
38
|
"caweb": "caweb",
|
|
39
39
|
"create-site": "caweb create-site",
|
|
40
40
|
"serve": "caweb serve",
|
|
41
|
+
"serve:no-audit": "caweb serve --no-audit --no-jshint --no-a11y",
|
|
41
42
|
"build": "caweb build",
|
|
42
43
|
"convert-site": "caweb convert-site",
|
|
43
44
|
"launch": "caweb launch",
|
|
44
45
|
"launch:multi": "caweb launch --multisite",
|
|
45
46
|
"launch:multi:subdomain": "caweb launch --multisite --subdomain",
|
|
46
|
-
"launch:sync": "caweb launch --sync
|
|
47
|
+
"launch:sync": "caweb launch --sync",
|
|
47
48
|
"launch:update": "caweb launch --update",
|
|
48
49
|
"stop": "caweb stop",
|
|
49
50
|
"shutdown": "caweb destroy",
|
|
@@ -623,6 +623,13 @@ function generateShortcodes( mainContent, opts = {
|
|
|
623
623
|
// all theses elements can go in other modules
|
|
624
624
|
// they also need to be added to the allowedModules list
|
|
625
625
|
case 'a':
|
|
626
|
+
// if the element first child is an image
|
|
627
|
+
if( content[0] && content[0].rawTagName === 'img' ) {
|
|
628
|
+
// add the anchors attributes to the image
|
|
629
|
+
content[0].rawAttrs = content[0].rawAttrs + ' ' + rawAttrs;
|
|
630
|
+
output += generateModuleShortcode('image', content[0] );
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
626
633
|
case 'b':
|
|
627
634
|
case 'p':
|
|
628
635
|
case 'ol':
|
|
@@ -809,17 +816,20 @@ function generateModuleShortcode(module, element ){
|
|
|
809
816
|
let attrs = {};
|
|
810
817
|
let moduleName = 'et_pb_' + module;
|
|
811
818
|
|
|
819
|
+
// commonly named attributes can be declared here to avoid repetition
|
|
820
|
+
let header, title, img;
|
|
821
|
+
|
|
812
822
|
switch( module ) {
|
|
813
|
-
case 'blurb':
|
|
823
|
+
case 'blurb':
|
|
814
824
|
/**
|
|
815
825
|
* if blurb module is requested
|
|
816
826
|
* we try and make the shortcode as if the element
|
|
817
827
|
* was made with a Card Component
|
|
818
828
|
*/
|
|
819
829
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
830
|
+
header = element.querySelector('.card-header');
|
|
831
|
+
title = element.querySelector('.card-title');
|
|
832
|
+
img = element.children.filter( c => c.tagName.toLowerCase() === 'img' );
|
|
823
833
|
|
|
824
834
|
content = element.querySelector('.card-body');
|
|
825
835
|
|
|
@@ -887,14 +897,14 @@ function generateModuleShortcode(module, element ){
|
|
|
887
897
|
}
|
|
888
898
|
}
|
|
889
899
|
break;
|
|
890
|
-
|
|
891
|
-
case 'ca_card':
|
|
900
|
+
|
|
901
|
+
case 'ca_card':
|
|
892
902
|
/**
|
|
893
903
|
* if card module is requested
|
|
894
904
|
*/
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
905
|
+
header = element.querySelector('.card-header');
|
|
906
|
+
title = element.querySelector('.card-title');
|
|
907
|
+
img = element.children.filter( c => c.tagName.toLowerCase() === 'img' );
|
|
898
908
|
let layout = element.classList.toString().match(/card-(\w+)/g)[0].replace('card-', '');
|
|
899
909
|
|
|
900
910
|
content = element.querySelector('.card-body');
|
|
@@ -962,8 +972,8 @@ function generateModuleShortcode(module, element ){
|
|
|
962
972
|
}
|
|
963
973
|
}
|
|
964
974
|
break;
|
|
965
|
-
|
|
966
|
-
case 'heading':
|
|
975
|
+
|
|
976
|
+
case 'heading':
|
|
967
977
|
|
|
968
978
|
attrs = {
|
|
969
979
|
title: element.innerHTML.trim(),
|
|
@@ -986,7 +996,12 @@ function generateModuleShortcode(module, element ){
|
|
|
986
996
|
content = element.innerHTML.trim()
|
|
987
997
|
|
|
988
998
|
break;
|
|
989
|
-
|
|
999
|
+
|
|
1000
|
+
case 'image':
|
|
1001
|
+
let {src, href: url} = convertRawAttrs( element.rawAttrs )
|
|
1002
|
+
attrs = { src, url };
|
|
1003
|
+
|
|
1004
|
+
break;
|
|
990
1005
|
}
|
|
991
1006
|
|
|
992
1007
|
if( element.classList.length ){
|
|
@@ -2,28 +2,100 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import Handlebars from 'handlebars';
|
|
8
|
+
|
|
5
9
|
import CAWebHTMLPlugin from "@caweb/html-webpack-plugin";
|
|
6
10
|
import CAWebA11yPlugin from '@caweb/a11y-webpack-plugin';
|
|
7
11
|
import CAWebCSSAuditPlugin from '@caweb/css-audit-webpack-plugin';
|
|
8
12
|
import CAWebJSHintPlugin from '@caweb/jshint-webpack-plugin';
|
|
9
13
|
|
|
10
|
-
import { flagExists } from '@caweb/webpack/lib/args.js';
|
|
14
|
+
import { flagExists, getArgVal } from '@caweb/webpack/lib/args.js';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// this is the path to the current project directory
|
|
18
|
+
const appPath = process.cwd();
|
|
19
|
+
|
|
20
|
+
let templatePath = path.join(appPath, 'node_modules', '@caweb', 'template');
|
|
21
|
+
|
|
22
|
+
// we read the app caweb.json file if it exists
|
|
23
|
+
let caweb = fs.existsSync( path.join(appPath, 'caweb.json') ) ?
|
|
24
|
+
JSON.parse(fs.readFileSync(path.join(appPath, 'caweb.json')))
|
|
25
|
+
: {};
|
|
26
|
+
|
|
27
|
+
// argument variables
|
|
28
|
+
let template = getArgVal( 'template', path.join(templatePath, 'patterns', 'default.html') );
|
|
29
|
+
let searchTemplate = getArgVal( 'search-template', path.join(templatePath, 'patterns', 'search.html') );
|
|
30
|
+
let scheme = getArgVal( 'scheme', 'oceanside' );
|
|
31
|
+
|
|
32
|
+
// Additional pages directory
|
|
33
|
+
let basePageDir = path.join(appPath, 'content', 'pages');
|
|
34
|
+
let additionalPages = ! fs.existsSync( basePageDir ) ? [] :
|
|
35
|
+
fs.readdirSync( basePageDir, { withFileTypes: true, recursive: true } )
|
|
36
|
+
.filter( dirent => dirent.isFile() && (dirent.name.endsWith('.html') || dirent.name.endsWith('.handlebars')) )
|
|
37
|
+
.map( ( dirent ) => {
|
|
38
|
+
|
|
39
|
+
let fileTemplate = path.join( dirent.parentPath, dirent.name );
|
|
40
|
+
|
|
41
|
+
// replace .html, uppercase the first letter of each word
|
|
42
|
+
// this is to make sure the title is readable
|
|
43
|
+
// and not just a file name
|
|
44
|
+
let title = dirent.name.replace('.html', '').replace(/\b\w/g, c => c.toUpperCase());
|
|
45
|
+
let content = fs.readFileSync( fileTemplate, 'utf-8' );
|
|
46
|
+
let data = {
|
|
47
|
+
...caweb.site,
|
|
48
|
+
scheme
|
|
49
|
+
};
|
|
50
|
+
let compiler = Handlebars.compile( content );
|
|
51
|
+
let compiledContent = compiler(data);
|
|
52
|
+
|
|
53
|
+
return new CAWebHTMLPlugin({
|
|
54
|
+
template,
|
|
55
|
+
filename: fileTemplate.replace(basePageDir, '') ,
|
|
56
|
+
title,
|
|
57
|
+
templateParameters: {
|
|
58
|
+
scheme,
|
|
59
|
+
partial: compiledContent,
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
});
|
|
63
|
+
})
|
|
11
64
|
|
|
12
65
|
export default {
|
|
13
66
|
|
|
14
67
|
plugins: [
|
|
15
68
|
// add custom plugins here
|
|
16
69
|
// Used for Site Generation
|
|
17
|
-
new CAWebHTMLPlugin(
|
|
70
|
+
new CAWebHTMLPlugin({
|
|
71
|
+
template,
|
|
72
|
+
templateParameters: {
|
|
73
|
+
scheme,
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
|
|
77
|
+
// this plugin generates Search Results page using the template found in patterns/search.html
|
|
78
|
+
caweb?.site?.google?.search ? new CAWebHTMLPlugin({
|
|
79
|
+
template: searchTemplate,
|
|
80
|
+
// favicon,
|
|
81
|
+
filename: 'serp.html',
|
|
82
|
+
title: 'Search Results Page',
|
|
83
|
+
templateParameters: {
|
|
84
|
+
scheme
|
|
85
|
+
},
|
|
86
|
+
}) : false,
|
|
87
|
+
|
|
88
|
+
// Additional pages from content/pages directory
|
|
89
|
+
...additionalPages,
|
|
18
90
|
|
|
19
91
|
// // IBM Accessibility
|
|
20
|
-
|
|
92
|
+
flagExists('a11y') && getArgVal('a11y') && new CAWebA11yPlugin(),
|
|
21
93
|
|
|
22
94
|
// // WP CSS Auditor
|
|
23
|
-
|
|
95
|
+
flagExists('audit') && getArgVal('audit') && new CAWebCSSAuditPlugin(),
|
|
24
96
|
|
|
25
97
|
// // JSHint
|
|
26
|
-
|
|
98
|
+
flagExists('jshint') && getArgVal('jshint') && new CAWebJSHintPlugin(),
|
|
27
99
|
|
|
28
100
|
].filter( Boolean ),
|
|
29
101
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/cli",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.17",
|
|
4
4
|
"description": "CAWebPublishing Command Line Interface.",
|
|
5
5
|
"exports": "./lib/env.js",
|
|
6
6
|
"type": "module",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@caweb/a11y-webpack-plugin": "^2.1.0",
|
|
68
68
|
"@caweb/css-audit-webpack-plugin": "^2.1.0",
|
|
69
|
-
"@caweb/html-webpack-plugin": "^2.1.
|
|
69
|
+
"@caweb/html-webpack-plugin": "^2.1.4",
|
|
70
70
|
"@caweb/jshint-webpack-plugin": "^2.1.0",
|
|
71
|
-
"@caweb/webpack": "^1.6.
|
|
71
|
+
"@caweb/webpack": "^1.6.5",
|
|
72
72
|
"@inquirer/prompts": "^8.2.0",
|
|
73
73
|
"@wordpress/create-block": "^4.82.0",
|
|
74
74
|
"@wordpress/env": "^10.39.0",
|