@caweb/cli 1.4.3 → 1.4.5
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 +2 -206
- package/commands/index.js +9 -2
- package/commands/test.js +0 -3
- package/commands/webpack/webpack.js +59 -26
- package/configs/webpack.config.js +34 -12
- package/lib/cli.js +65 -38
- package/lib/helpers.js +0 -1
- package/lib/webpack/plugins/a11y/aceconfig.js +44 -0
- package/lib/webpack/plugins/a11y/index.js +272 -0
- package/lib/webpack/plugins/a11y/package.json +12 -0
- package/lib/webpack/plugins/css-audit/css-audit.config.cjs +5 -0
- package/lib/webpack/plugins/css-audit/default.config.js +19 -0
- package/lib/webpack/plugins/css-audit/index.js +297 -0
- package/lib/webpack/plugins/css-audit/package.json +12 -0
- package/lib/webpack/plugins/jshint/.jshintrc +31 -0
- package/lib/webpack/plugins/jshint/index.js +286 -0
- package/lib/webpack/plugins/jshint/package-lock.json +22 -0
- package/lib/webpack/plugins/jshint/package.json +15 -0
- package/lib/webpack/plugins/jshint/reporter.cjs +663 -0
- package/package.json +5 -5
- package/assets/logo.ico +0 -0
- package/commands/a11y.js +0 -95
- package/commands/audit.js +0 -135
- package/configs/aceconfig.js +0 -28
- package/configs/css-audit.config.cjs +0 -9
- package/docs/CREDITS.MD +0 -32
- package/docs/ISSUES.MD +0 -7
- package/docs/OVERRIDES.md +0 -53
- package/docs/ROADMAP.MD +0 -20
- package/docs/SYNC.MD +0 -29
- package/docs/tool/index.js +0 -45
- package/gen/parser.js +0 -166
- package/gen/site-generator.js +0 -144
package/commands/a11y.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import achecker from 'accessibility-checker';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import { isUrl } from 'check-valid-url';
|
|
9
|
-
import fs from 'fs';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
// Our default A11y Checker Configuration
|
|
15
|
-
import defaultConfig from '../configs/aceconfig.js';
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
runCmd,
|
|
19
|
-
} from '../lib/index.js';
|
|
20
|
-
import { stderr, stdout } from 'process';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Run accessibility checks
|
|
25
|
-
*
|
|
26
|
-
* @param {Object} options
|
|
27
|
-
* @param {Object} options.spinner A CLI spinner which indicates progress.
|
|
28
|
-
* @param {boolean} options.debug True if debug mode is enabled.
|
|
29
|
-
* @param {boolean} options.url True if debug mode is enabled.
|
|
30
|
-
*/
|
|
31
|
-
export default async function a11y({
|
|
32
|
-
spinner,
|
|
33
|
-
debug,
|
|
34
|
-
url
|
|
35
|
-
} ) {
|
|
36
|
-
|
|
37
|
-
// Spinner not needed at the moment
|
|
38
|
-
spinner.stop();
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
ruleArchive,
|
|
42
|
-
policies,
|
|
43
|
-
failLevels,
|
|
44
|
-
reportLevels,
|
|
45
|
-
outputFolder,
|
|
46
|
-
outputFormat,
|
|
47
|
-
outputFilenameTimestamp
|
|
48
|
-
} = defaultConfig;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// pass any arguments from the cli
|
|
52
|
-
// overwriting our default config flags.
|
|
53
|
-
// users can overwrite any values by creating a .achecker.yml or aceconfig.js.
|
|
54
|
-
let acheckerArgs = [
|
|
55
|
-
'--ruleArchive',
|
|
56
|
-
ruleArchive,
|
|
57
|
-
'--policies',
|
|
58
|
-
Array.isArray(policies) ? policies.join(',') : policies,
|
|
59
|
-
'--failLevels',
|
|
60
|
-
Array.isArray(failLevels) ? failLevels.join(',') : failLevels,
|
|
61
|
-
'--reportLevels',
|
|
62
|
-
Array.isArray(reportLevels) ? reportLevels.join(',') : reportLevels,
|
|
63
|
-
'--outputFolder',
|
|
64
|
-
outputFolder,
|
|
65
|
-
'--outputFormat',
|
|
66
|
-
outputFormat,
|
|
67
|
-
'---outputFilenameTimestamp',
|
|
68
|
-
outputFilenameTimestamp,
|
|
69
|
-
url
|
|
70
|
-
];
|
|
71
|
-
|
|
72
|
-
// run accessibility checker with our arguments.
|
|
73
|
-
if( isUrl( url ) || fs.existsSync( url ) ){
|
|
74
|
-
let outputDir = path.resolve('.', outputFolder);
|
|
75
|
-
let outputFileName = isUrl( url ) ?
|
|
76
|
-
url.replace(/http[s]+:\/\//, '')
|
|
77
|
-
:
|
|
78
|
-
path.resolve(url).replace(':', '_');
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
let reportFile = path.resolve(outputDir, outputFileName ) + '.html'
|
|
82
|
-
|
|
83
|
-
await runCmd(
|
|
84
|
-
'achecker',
|
|
85
|
-
acheckerArgs,
|
|
86
|
-
).then(({stderr, stdout}) => {
|
|
87
|
-
console.log( reportFile );
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
}else{
|
|
91
|
-
console.log( `${url} is not a valid url.` )
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
};
|
package/commands/audit.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import { getAllFiles, getAllFilesSync } from 'get-all-files'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
runCmd,
|
|
16
|
-
projectPath,
|
|
17
|
-
appPath
|
|
18
|
-
} from '../lib/index.js';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Run WordPress CSS Audit
|
|
22
|
-
*
|
|
23
|
-
* @param {Object} options
|
|
24
|
-
* @param {Object} options.spinner A CLI spinner which indicates progress.
|
|
25
|
-
* @param {boolean} options.debug True if debug mode is enabled.
|
|
26
|
-
*/
|
|
27
|
-
export default async function audit({
|
|
28
|
-
spinner,
|
|
29
|
-
debug
|
|
30
|
-
} ) {
|
|
31
|
-
|
|
32
|
-
let files = [];
|
|
33
|
-
|
|
34
|
-
process.argv.slice(3).forEach( (paths, i) => {
|
|
35
|
-
let resolvePath = path.resolve(paths);
|
|
36
|
-
try {
|
|
37
|
-
// if given path is a directory
|
|
38
|
-
if( fs.statSync(resolvePath).isDirectory() ){
|
|
39
|
-
// get all .css files
|
|
40
|
-
getAllFilesSync(path.resolve(resolvePath)).toArray().forEach(f => {
|
|
41
|
-
if( f.endsWith('.css') ){
|
|
42
|
-
files.push(f)
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
// if given path is a file and a .css file
|
|
46
|
-
}else if( fs.statSync(paths).isFile() && paths.endsWith('.css') ){
|
|
47
|
-
files.push(paths)
|
|
48
|
-
}
|
|
49
|
-
// invalid path/file
|
|
50
|
-
} catch (error) {
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// if no files were passed
|
|
57
|
-
if( ! files.length ){
|
|
58
|
-
// if the default build directory exists we audit it
|
|
59
|
-
if( fs.existsSync(path.resolve('build')) ){
|
|
60
|
-
// get all .css files in build folder
|
|
61
|
-
getAllFilesSync(path.resolve('build')).toArray().forEach(f => {
|
|
62
|
-
if( f.endsWith('.css') ){
|
|
63
|
-
files.push(f)
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// if files are to be audited.
|
|
70
|
-
if( files.length ){
|
|
71
|
-
let auditArgs = [
|
|
72
|
-
...files
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
// default audits.
|
|
76
|
-
let audits = [
|
|
77
|
-
'colors',
|
|
78
|
-
'alphas',
|
|
79
|
-
'important',
|
|
80
|
-
'display-none',
|
|
81
|
-
'selectors',
|
|
82
|
-
'media-queries',
|
|
83
|
-
'typography',
|
|
84
|
-
[ 'property-values', 'font-size' ],
|
|
85
|
-
[ 'property-values', 'padding,padding-top,padding-bottom,padding-right,padding-left' ],
|
|
86
|
-
[ 'property-values', 'margin,margin-top,marin-bottom,marin-right,marin-left' ]
|
|
87
|
-
]
|
|
88
|
-
|
|
89
|
-
audits.forEach(a => {
|
|
90
|
-
let audit = Array.isArray(a) ? a[0] : a;
|
|
91
|
-
|
|
92
|
-
if( ! process.argv.includes(`--no-${audit}`) ){
|
|
93
|
-
if( Array.isArray(a) ){
|
|
94
|
-
auditArgs.push(`--${audit}=` + a.splice(1).join(','))
|
|
95
|
-
}else{
|
|
96
|
-
auditArgs.push(`--${audit}`)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const auditConfigPath = fs.existsSync(path.join(appPath, 'css-audit.config.cjs')) ?
|
|
102
|
-
appPath :
|
|
103
|
-
path.join(projectPath, 'configs')
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
await runCmd(
|
|
107
|
-
'auditor',
|
|
108
|
-
auditArgs,
|
|
109
|
-
{
|
|
110
|
-
cwd: auditConfigPath
|
|
111
|
-
}
|
|
112
|
-
).then(({stderr, stdout}) => {
|
|
113
|
-
// Audit result handling.
|
|
114
|
-
if( stderr ){
|
|
115
|
-
console.log( stderr.toString())
|
|
116
|
-
}
|
|
117
|
-
if( stdout ){
|
|
118
|
-
let msg = stdout.toString().replace('undefined', '');
|
|
119
|
-
|
|
120
|
-
if( 'audit' === process.argv[2] ){
|
|
121
|
-
console.log( msg )
|
|
122
|
-
}else{
|
|
123
|
-
return msg;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
}else{
|
|
130
|
-
spinner.warn('No file(s) or directory path(s) were given.');
|
|
131
|
-
spinner.warn('Default build directory was not found.');
|
|
132
|
-
spinner.warn('Auditor did not execute.');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
};
|
package/configs/aceconfig.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration for Accessibility Checker
|
|
3
|
-
* @link https://www.npmjs.com/package/accessibility-checker
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
ruleArchive: "latest",
|
|
8
|
-
policies: [
|
|
9
|
-
'WCAG_2_1'
|
|
10
|
-
],
|
|
11
|
-
failLevels: [
|
|
12
|
-
'violation',
|
|
13
|
-
'potentialviolation'
|
|
14
|
-
],
|
|
15
|
-
reportLevels: [
|
|
16
|
-
'violation',
|
|
17
|
-
'potentialviolation',
|
|
18
|
-
'recommendation',
|
|
19
|
-
'potentialrecommendation',
|
|
20
|
-
'manual',
|
|
21
|
-
'pass'
|
|
22
|
-
],
|
|
23
|
-
outputFolder: "a11y",
|
|
24
|
-
outputFormat: [
|
|
25
|
-
'html'
|
|
26
|
-
],
|
|
27
|
-
outputFilenameTimestamp: false
|
|
28
|
-
}
|
package/docs/CREDITS.MD
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Sources
|
|
2
|
-
### <ins>Design System Components</ins>
|
|
3
|
-
[Github](https://github.com/cagov/design-system/tree/main/components)
|
|
4
|
-
[NPM Packages](https://www.npmjs.com/search?q=%40cagov)
|
|
5
|
-
|
|
6
|
-
### <ins>docker-compose</ins>
|
|
7
|
-
[Documentation](https://pdmlab.github.io/docker-compose/)
|
|
8
|
-
[Github](https://github.com/PDMLab/docker-compose)
|
|
9
|
-
[NPM Package](https://www.npmjs.com/package/docker-compose)
|
|
10
|
-
|
|
11
|
-
### <ins>wp-env</ins>
|
|
12
|
-
[Documentation](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/)
|
|
13
|
-
[Github](https://github.com/WordPress/gutenberg/tree/HEAD/packages/env)
|
|
14
|
-
[NPM Package](https://www.npmjs.com/package/@wordpress/env)
|
|
15
|
-
|
|
16
|
-
### <ins>create-block</ins>
|
|
17
|
-
[Block API](https://developer.wordpress.org/block-editor/reference-guides/block-api/)
|
|
18
|
-
[Documentation](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/)
|
|
19
|
-
[External Project Templates](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/packages-create-block-external-template/)
|
|
20
|
-
[NPM Package](https://www.npmjs.com/package/@wordpress/create-block)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### <ins>wp cli</ins>
|
|
24
|
-
[Documentation](https://developer.wordpress.org/cli/commands/)
|
|
25
|
-
|
|
26
|
-
### <ins>phpMyAdmin</ins>
|
|
27
|
-
[Docker](https://hub.docker.com/_/phpmyadmin)
|
|
28
|
-
|
|
29
|
-
### <ins>css-audit</ins>
|
|
30
|
-
[Documentation](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/)
|
|
31
|
-
[Documentation](https://make.wordpress.org/core/2021/05/17/introducing-the-wordpress-css-audit-tool/)
|
|
32
|
-
[Github](https://github.com/wordpress/css-audit)
|
package/docs/ISSUES.MD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# Known Issues
|
|
2
|
-
[[Bug](https://github.com/npm/cli/issues/3136)] Arguments are not correctly passed from CLI to npm script (npm 7, Windows, Powershell)
|
|
3
|
-
- Workaround - If using < Node 20, add an additional `--` when passing arguments
|
|
4
|
-
-- Example run
|
|
5
|
-
`npm run caweb start -- -- --multisite`
|
|
6
|
-
instead of
|
|
7
|
-
`npm run caweb start -- --multisite`
|
package/docs/OVERRIDES.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
## [.wp-env.override.json](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/#wp-env-override-json)
|
|
2
|
-
Any fields here will take precedence over .wp-env.json.
|
|
3
|
-
## <ins>Special Config Values</ins>
|
|
4
|
-
### <ins>CAWeb Options</ins>
|
|
5
|
-
`CAWEB_TEMPLATE_VER` - Updates CAWeb State Template Version
|
|
6
|
-
`CAWEB_NAV_MENU_STYLE` - Updates CAWeb Header Menu Type
|
|
7
|
-
`CAWEB_COLORSCHEME` - Updates CAWeb Color Scheme
|
|
8
|
-
`CAWEB_TITLE_DISPLAY` - Updates CAWeb Title Display Default
|
|
9
|
-
`CAWEB_STICKY_NAV` - Updates CAWeb Sticky Navigation
|
|
10
|
-
`CAWEB_MENU_HOME_LINK` - Updates CAWeb Menu Home Link
|
|
11
|
-
`CAWEB_DISPLAY_POSTS_DATE` - Updates CAWeb Display Date for Non-Divi Posts
|
|
12
|
-
`CAWEB_X_UA_COMPATIBILITY` - Updates CAWeb Legacy Browser Support
|
|
13
|
-
`CAWEB_FRONTPAGE_SEARCH` - Updates CAWeb Show Search on Front Page
|
|
14
|
-
`CAWEB_CONTACT_US_PAGE` - Updates CAWeb Contact Us Page
|
|
15
|
-
`CAWEB_GEO_LOCATOR` - Updates CAWeb Enable Geo Locator
|
|
16
|
-
`CAWEB_UTILITY_HOME_LINK` - Updates CAWeb Home Link
|
|
17
|
-
`CAWEB_UTILITY_LINK1_ENABLED` - Updates CAWeb Custom Link 1
|
|
18
|
-
`CAWEB_UTILITY_LINK1_LABEL` - Updates CAWeb Custom Link 1 Label
|
|
19
|
-
`CAWEB_UTILITY_LINK1_URL` - Updates CAWeb Custom Link 1 URL
|
|
20
|
-
`CAWEB_UTILITY_LINK1_NEW_WINDOW` - Updates CAWeb Custom Link 1 Open in New Tab
|
|
21
|
-
`CAWEB_UTILITY_LINK2_ENABLED` - Updates CAWeb Custom Link 2
|
|
22
|
-
`CAWEB_UTILITY_LINK2_LABEL` - Updates CAWeb Custom Link 2 Label
|
|
23
|
-
`CAWEB_UTILITY_LINK2_URL` - Updates CAWeb Custom Link 2 URL
|
|
24
|
-
`CAWEB_UTILITY_LINK2_NEW_WINDOW` - Updates CAWeb Custom Link 2 Open in New Tab
|
|
25
|
-
`CAWEB_UTILITY_LINK3_ENABLED` - Updates CAWeb Custom Link 3
|
|
26
|
-
`CAWEB_UTILITY_LINK3_LABEL` - Updates CAWeb Custom Link 3 Label
|
|
27
|
-
`CAWEB_UTILITY_LINK3_URL` - Updates CAWeb Custom Link 3 URL
|
|
28
|
-
`CAWEB_UTILITY_LINK3_NEW_WINDOW` - Updates CAWeb Custom Link 3 Open in New Tab
|
|
29
|
-
`CAWEB_CAWEB_ORG_LOGO_ALT_TEXT` - Updates CAWeb Organization Logo-Alt Text
|
|
30
|
-
`CAWEB_GOOGLE_SEARCH_ENGINE_ID` - Updates CAWeb Search Engine ID
|
|
31
|
-
`CAWEB_GOOGLE_ANALYTICS_ID` - Updates CAWeb Analytics ID
|
|
32
|
-
`CAWEB_GOOGLE_ANALYTICS4_ID` - Updates CAWeb Analytics 4 ID
|
|
33
|
-
`CAWEB_GOOGLE_TAG_MANAGER_ID` - Updates CAWeb Tag Manager ID
|
|
34
|
-
`CAWEB_GOOGLE_META_ID` - Updates CAWeb Site Verification Meta ID
|
|
35
|
-
`CAWEB_GOOGLE_TRANSLATE_MODE` - Updates CAWeb Enable Google Translate
|
|
36
|
-
`CAWEB_GOOGLE_TRANSLATE_PAGE` - Updates CAWeb Translate Page
|
|
37
|
-
`CAWEB_GOOGLE_TRANSLATE_PAGE_NEW_WINDOW` - Updates CAWeb Open in New Tab
|
|
38
|
-
`CAWEB_GOOGLE_TRANSLATE_ICON` - Updates CAWeb Icon
|
|
39
|
-
`CAWEB_PRIVATE_REPO` - Updates CAWeb Is Private?
|
|
40
|
-
`CAWEB_GIT_USER` - Updates CAWeb Username
|
|
41
|
-
`CAWEB_ACCESS_TOKEN` - Updates CAWeb Token
|
|
42
|
-
### <ins>Divi Options</ins>
|
|
43
|
-
`ET_DYNAMIC_MODULE` - Updates CAWeb Dynamic Module Framework
|
|
44
|
-
`ET_DYNAMIC_CSS` - Updates CAWeb Dynamic CSS
|
|
45
|
-
`ET_CRITICAL_CSS` - Updates CAWeb Critical CSS
|
|
46
|
-
`ET_DYNAMIC_JS` - Updates CAWeb Dynamic JavaScript Libraries
|
|
47
|
-
`ET_CLASSIC_EDITOR` - Updates CAWeb Enable Classic Editor
|
|
48
|
-
`ET_STATIC_CSS_GENERATION` - Updates CAWeb Static CSS File Generation
|
|
49
|
-
`ET_PRODUCT_TOUR` - Updates CAWeb Product Tour
|
|
50
|
-
`ET_NEW_BUILDER_EXPERIENCE` - Updates CAWeb Enable The Latest Divi Builder Experience
|
|
51
|
-
`ET_OUTPUT_STYLES_INLINE` - Updates CAWeb Output Styles Inline
|
|
52
|
-
`ET_USERNAME` - Updates CAWeb Username
|
|
53
|
-
`ET_API_KEY` - Updates CAWeb API Key
|
package/docs/ROADMAP.MD
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# Roadmap Features:
|
|
2
|
-
## Validation with:
|
|
3
|
-
|
|
4
|
-
- SNYK
|
|
5
|
-
https://www.npmjs.com/package/snyk
|
|
6
|
-
- CSS-Audit
|
|
7
|
-
https://github.com/wordpress/css-audit
|
|
8
|
-
|
|
9
|
-
## Testaro
|
|
10
|
-
https://www.npmjs.com/package/testaro
|
|
11
|
-
|
|
12
|
-
## Sonarqube Scanner
|
|
13
|
-
https://www.npmjs.com/package/sonarqube-scanner
|
|
14
|
-
|
|
15
|
-
## BrowserStack
|
|
16
|
-
https://www.npmjs.com/package/browserstack
|
|
17
|
-
|
|
18
|
-
## Control Panel
|
|
19
|
-
https://aapanel.com/new/download.html
|
|
20
|
-
|
package/docs/SYNC.MD
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# caweb.json Configuration
|
|
2
|
-
Under the `sync` property you can list the various WordPress Instances. Each Instance, requires a WordPress Username, Application Password and the Site URL.
|
|
3
|
-
|
|
4
|
-
Sync Example Command:
|
|
5
|
-
Using the example, if you wanted to sync all the changes from the dev instance to your local instance.
|
|
6
|
-
`caweb sync dev local`
|
|
7
|
-
|
|
8
|
-
Sync Configuration Example:
|
|
9
|
-
<pre>
|
|
10
|
-
{
|
|
11
|
-
"sync": {
|
|
12
|
-
"local": {
|
|
13
|
-
"user": "<Username>",
|
|
14
|
-
"pwd": "<a href="https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#basic-authentication-with-application-passwords">Application Password</a>",
|
|
15
|
-
"url": "http://example1.com"
|
|
16
|
-
},
|
|
17
|
-
"dev": {
|
|
18
|
-
"user": "<Username>",
|
|
19
|
-
"pwd": "<a href="https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#basic-authentication-with-application-passwords">Application Password</a>",
|
|
20
|
-
"url": "http://example2.com"
|
|
21
|
-
},
|
|
22
|
-
"test": {
|
|
23
|
-
"user": "<Username>",
|
|
24
|
-
"pwd": "<a href="https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#basic-authentication-with-application-passwords">Application Password</a>",
|
|
25
|
-
"url": "http://example3.com"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
</pre>
|
package/docs/tool/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* External dependencies
|
|
6
|
-
*/
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import fs from 'fs-extra';
|
|
9
|
-
|
|
10
|
-
import { CAWEB_OPTIONS, DIVI_OPTIONS } from '../../lib/index.js';
|
|
11
|
-
|
|
12
|
-
generateOverridesMD()
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Generates the OVERRIDES.MD
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
export default async function generateOverridesMD() {
|
|
19
|
-
|
|
20
|
-
let output = [
|
|
21
|
-
'## [.wp-env.override.json](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/#wp-env-override-json)',
|
|
22
|
-
'Any fields here will take precedence over .wp-env.json.',
|
|
23
|
-
'## <ins>Special Config Values</ins>',
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
// Generate CAWeb Options overrides.
|
|
27
|
-
output.push('### <ins>CAWeb Options</ins>');
|
|
28
|
-
for (const [key, option] of Object.entries(CAWEB_OPTIONS)) {
|
|
29
|
-
output.push(`\`${key}\` - Updates CAWeb ${option.label} `);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Generate Divi Options overrides.
|
|
33
|
-
output.push('### <ins>Divi Options</ins>');
|
|
34
|
-
for (const [group, options] of Object.entries(DIVI_OPTIONS)) {
|
|
35
|
-
for (const [key, option] of Object.entries(options)) {
|
|
36
|
-
output.push(`\`${key}\` - Updates CAWeb ${option.label} `);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
fs.writeFileSync(
|
|
41
|
-
path.join(process.cwd(), 'docs', 'OVERRIDES.MD'),
|
|
42
|
-
output.join('\n')
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
};
|
package/gen/parser.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { HTMLToJSON } from 'html-to-json-parser';
|
|
7
|
-
import jsdom from 'jsdom';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Path Directory Locations
|
|
15
|
-
* - appPath - Project Application Path
|
|
16
|
-
* - srcPath - Project Application Src Path
|
|
17
|
-
* - publicPath - Project Application Public Path
|
|
18
|
-
* - dataPath - Project Application Data Path
|
|
19
|
-
*/
|
|
20
|
-
const appPath = path.resolve(process.cwd());
|
|
21
|
-
const srcPath = path.join( appPath, 'src');
|
|
22
|
-
const dataPath = path.join( srcPath, 'data');
|
|
23
|
-
const assetsPath = path.join( srcPath, 'assets');
|
|
24
|
-
|
|
25
|
-
const fallbackPath = path.join( appPath, 'node_modules', '@cdt', 'template');
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Generate Pages
|
|
29
|
-
*
|
|
30
|
-
* @async
|
|
31
|
-
* @param {Object} siteData Data to use when creating pages
|
|
32
|
-
* @returns {string}
|
|
33
|
-
*/
|
|
34
|
-
async function generatePages(siteData){
|
|
35
|
-
|
|
36
|
-
// we start with a blank html and schema
|
|
37
|
-
let page = '<html><html>';
|
|
38
|
-
let schema = {};
|
|
39
|
-
|
|
40
|
-
// if src/index.html exists
|
|
41
|
-
if(fs.existsSync(path.join(srcPath, 'index.html'))){
|
|
42
|
-
|
|
43
|
-
// get index path file location
|
|
44
|
-
page = path.join(srcPath, 'index.html')
|
|
45
|
-
|
|
46
|
-
// generate page schema
|
|
47
|
-
schema = await convertHTMLtoJson(page, false);
|
|
48
|
-
|
|
49
|
-
// read contents of index file, we strip any newlines
|
|
50
|
-
//page = fs.readFileSync( page ).toString().replace(/\n[\s]+/g,'');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// convert page to jsdom object
|
|
54
|
-
let dom = new jsdom.JSDOM( page );
|
|
55
|
-
|
|
56
|
-
// if we should be using the template
|
|
57
|
-
if( process.env.CDT_TEMPLATE ){
|
|
58
|
-
|
|
59
|
-
// read contents of template index file, we strip any newlines
|
|
60
|
-
page = fs.readFileSync( path.join(fallbackPath, 'src', 'index.html') ).toString().replace(/\n[\s]+/g,'');
|
|
61
|
-
|
|
62
|
-
// create template jsdom object
|
|
63
|
-
let templateDom = new jsdom.JSDOM( page );
|
|
64
|
-
|
|
65
|
-
// colorscheme
|
|
66
|
-
let colorCSS = path.join(fallbackPath, 'build', 'oceanside.css');
|
|
67
|
-
let colorJS = path.join(fallbackPath, 'build', 'oceanside.js');
|
|
68
|
-
|
|
69
|
-
dom.window.document.querySelector('head').append(
|
|
70
|
-
`<link rel="stylesheet" type="text/css" href="${colorCSS}">`
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// update template dom by appending contents of existing dom body
|
|
75
|
-
// after the header
|
|
76
|
-
templateDom.window.document.querySelector('header').append(
|
|
77
|
-
dom.window.document.querySelector('body')
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
// update existing dom with templated changes.
|
|
81
|
-
dom = new jsdom.JSDOM( templateDom.window.document.documentElement.outerHTML);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// generate any data attributes
|
|
85
|
-
populateDataAttrs( dom, siteData, schema );
|
|
86
|
-
|
|
87
|
-
return dom.window.document.documentElement.outerHTML;
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Populate data-cagov attributes with siteData
|
|
94
|
-
*
|
|
95
|
-
* @param {jsdom.JSDOM} dom HTML
|
|
96
|
-
* @param {Object} siteData
|
|
97
|
-
* @param {Object} schema
|
|
98
|
-
*/
|
|
99
|
-
function populateDataAttrs(dom, siteData, schema){
|
|
100
|
-
for( const [attr, data] of Object.entries(siteData) ){
|
|
101
|
-
// if attribute isn't in the schema don't do anything
|
|
102
|
-
if( ! schema.data || ! Object.keys(schema.data).includes(attr) ){
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// any data- attributes should be prefixed with cagov
|
|
107
|
-
// get any elements with the appropriate data- attr
|
|
108
|
-
let elements = dom.window.document.querySelectorAll(`[data-cagov-${attr}]`);
|
|
109
|
-
|
|
110
|
-
// if the data is an array|object pass as data
|
|
111
|
-
let value = Array.isArray(data) || 'object' === typeof data ? JSON.stringify( data ) : data;
|
|
112
|
-
|
|
113
|
-
elements.forEach(element => {
|
|
114
|
-
element.setAttribute(`data-cagov-${attr}`, value);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Generates a page schema including any data attributes in src/data/index.json
|
|
123
|
-
*
|
|
124
|
-
* @async
|
|
125
|
-
* @param {*} file
|
|
126
|
-
* @param {boolean} [write=true]
|
|
127
|
-
* @param {string} [outputPath='']
|
|
128
|
-
* @returns {unknown}
|
|
129
|
-
*/
|
|
130
|
-
async function convertHTMLtoJson( file, write = true, outputPath = '' ){
|
|
131
|
-
if( fs.existsSync( file )){
|
|
132
|
-
let template = fs.readFileSync( file ).toString().replace(/\n[\s]+/g,'');
|
|
133
|
-
let markup = await HTMLToJSON(template, false )
|
|
134
|
-
|
|
135
|
-
let data = fs.existsSync( path.join(dataPath, 'index.json') ) ?
|
|
136
|
-
JSON.parse( fs.readFileSync( path.join(dataPath, 'index.json') ) ) : {};
|
|
137
|
-
|
|
138
|
-
// remove any examples data
|
|
139
|
-
delete data.examples;
|
|
140
|
-
|
|
141
|
-
let schema = {
|
|
142
|
-
title: "California Department of Technology Schema",
|
|
143
|
-
$schema: "http://json-schema.org/2019-09/schema",
|
|
144
|
-
$id: "https://json-schema.org/draft/2019-09/schema",
|
|
145
|
-
type: "object",
|
|
146
|
-
description: "California Department of Technology Schema",
|
|
147
|
-
data,
|
|
148
|
-
markup,
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// Write schema file.
|
|
152
|
-
if( write ){
|
|
153
|
-
fs.writeFileSync(
|
|
154
|
-
path.join(outputPath, 'schema.json'),
|
|
155
|
-
JSON.stringify( schema, null, 4 )
|
|
156
|
-
);
|
|
157
|
-
}else{
|
|
158
|
-
return schema;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export {
|
|
165
|
-
generatePages
|
|
166
|
-
};
|