@caweb/cli 1.4.2 → 1.4.4
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 -180
- package/bin/css-audit/.editorconfig +12 -0
- package/bin/css-audit/.github/workflows/build-report.yml +46 -0
- package/bin/css-audit/.github/workflows/merge-trunk-to-report.yml +17 -0
- package/bin/css-audit/.github/workflows/node.yaml +32 -0
- package/bin/css-audit/.nvmrc +1 -0
- package/bin/css-audit/README.md +131 -0
- package/bin/css-audit/css-audit.config.js +13 -0
- package/bin/css-audit/index.js +38 -0
- package/bin/css-audit/package-lock.json +6689 -0
- package/bin/css-audit/package.json +56 -0
- package/bin/css-audit/public/.gitkeep +1 -0
- package/bin/css-audit/src/__tests__/alphas.js +128 -0
- package/bin/css-audit/src/__tests__/colors.js +115 -0
- package/bin/css-audit/src/__tests__/display-none.js +52 -0
- package/bin/css-audit/src/__tests__/important.js +88 -0
- package/bin/css-audit/src/__tests__/media-queries.js +84 -0
- package/bin/css-audit/src/__tests__/property-values.js +55 -0
- package/bin/css-audit/src/__tests__/run.js +25 -0
- package/bin/css-audit/src/__tests__/selectors.js +66 -0
- package/bin/css-audit/src/audits/alphas.js +70 -0
- package/bin/css-audit/src/audits/colors.js +83 -0
- package/bin/css-audit/src/audits/display-none.js +39 -0
- package/bin/css-audit/src/audits/important.js +60 -0
- package/bin/css-audit/src/audits/media-queries.js +96 -0
- package/bin/css-audit/src/audits/property-values.js +65 -0
- package/bin/css-audit/src/audits/selectors.js +67 -0
- package/bin/css-audit/src/audits/typography.js +41 -0
- package/bin/css-audit/src/formats/cli-table.js +81 -0
- package/bin/css-audit/src/formats/html/_audit-alpha.twig +23 -0
- package/bin/css-audit/src/formats/html/_audit-colors.twig +23 -0
- package/bin/css-audit/src/formats/html/_audit-default.twig +24 -0
- package/bin/css-audit/src/formats/html/index.twig +88 -0
- package/bin/css-audit/src/formats/html/style.css +341 -0
- package/bin/css-audit/src/formats/html.js +52 -0
- package/bin/css-audit/src/formats/json.js +9 -0
- package/bin/css-audit/src/run.js +76 -0
- package/bin/css-audit/src/utils/__tests__/cli.js +70 -0
- package/bin/css-audit/src/utils/__tests__/example-config.config.js +12 -0
- package/bin/css-audit/src/utils/__tests__/get-specificity.js +39 -0
- package/bin/css-audit/src/utils/cli.js +133 -0
- package/bin/css-audit/src/utils/format-report.js +37 -0
- package/bin/css-audit/src/utils/get-specificity.js +97 -0
- package/bin/css-audit/src/utils/get-values-count.js +17 -0
- package/commands/index.js +15 -5
- package/commands/test.js +0 -3
- package/commands/webpack/webpack.js +166 -0
- package/configs/webpack.config.js +151 -81
- package/lib/cli.js +71 -35
- package/lib/helpers.js +3 -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 +18 -12
- package/assets/logo.ico +0 -0
- package/commands/a11y.js +0 -95
- package/commands/build.js +0 -80
- package/commands/serve.js +0 -95
- package/configs/aceconfig.js +0 -28
- package/docs/CREDITS.MD +0 -27
- package/docs/ISSUES.MD +0 -7
- package/docs/OVERRIDES.md +0 -53
- package/docs/ROADMAP.MD +0 -19
- 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/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
|
-
};
|
package/gen/site-generator.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import fs from 'fs';
|
|
6
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
7
|
-
import jsdom from 'jsdom';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import {
|
|
14
|
-
generatePages
|
|
15
|
-
} from './parser.js';
|
|
16
|
-
|
|
17
|
-
/*import {
|
|
18
|
-
projectPath,
|
|
19
|
-
appPath
|
|
20
|
-
} from '../lib/index.js';
|
|
21
|
-
*/
|
|
22
|
-
const currentPath = path.dirname(fileURLToPath(import.meta.url));
|
|
23
|
-
const projectPath = path.resolve( currentPath, '..' );
|
|
24
|
-
const appPath = path.resolve( process.cwd() );
|
|
25
|
-
const samplePath = path.join( appPath, 'sample');
|
|
26
|
-
const srcPath = path.join( appPath, 'src');
|
|
27
|
-
const dataPath = path.join( srcPath, 'data');
|
|
28
|
-
//const assetsPath = path.join( srcPath, 'assets');
|
|
29
|
-
|
|
30
|
-
// default meta used for site generation when no meta is passed
|
|
31
|
-
const meta = {
|
|
32
|
-
"Author": "CAWebPublishing",
|
|
33
|
-
"Description": "State of California",
|
|
34
|
-
"Keywords": "California,government",
|
|
35
|
-
"viewport": "width=device-width, initial-scale=1.0, minimum-scale=1.0"
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Returns an object containing all data from site.json and src/data/examples.json
|
|
41
|
-
*
|
|
42
|
-
* @returns {Object}
|
|
43
|
-
*/
|
|
44
|
-
function getSiteData(){
|
|
45
|
-
|
|
46
|
-
// grab any sample data if it exists.
|
|
47
|
-
let sample = fs.existsSync( path.join(dataPath, 'examples.json') ) ? JSON.parse( fs.readFileSync( path.join(dataPath, 'examples.json') ) ) : {};
|
|
48
|
-
|
|
49
|
-
// grab any site data if it exists.
|
|
50
|
-
let site = fs.existsSync( path.join(appPath, 'site.json') ) ? JSON.parse( fs.readFileSync( path.join(appPath, 'site.json') ) ) : {};
|
|
51
|
-
|
|
52
|
-
// merge datasets together
|
|
53
|
-
let siteData = {
|
|
54
|
-
...sample,
|
|
55
|
-
...site
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return siteData;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default (webpackConfig) => {
|
|
62
|
-
// we only proceed if and index.html exists
|
|
63
|
-
if( ! fs.existsSync( path.join( samplePath, 'index.html' )) ){
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// we only want to display errors and warnings
|
|
68
|
-
webpackConfig.stats = 'errors-warnings';
|
|
69
|
-
|
|
70
|
-
// get site data
|
|
71
|
-
let siteData = getSiteData();
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Favicon
|
|
75
|
-
*
|
|
76
|
-
* Locations:
|
|
77
|
-
* - ./favicon.ico - root of the project
|
|
78
|
-
* - ./src/favicon.ico - src directory
|
|
79
|
-
* - favicon.ico - default icon
|
|
80
|
-
*/
|
|
81
|
-
let favicon = fs.existsSync(path.join(appPath, 'favicon.ico')) ?
|
|
82
|
-
path.join(appPath, 'favicon.ico') :
|
|
83
|
-
(
|
|
84
|
-
fs.existsSync(path.join(srcPath, 'favicon.ico')) ?
|
|
85
|
-
path.join(srcPath, 'favicon.ico') :
|
|
86
|
-
path.join(projectPath, 'assets', 'logo.ico')
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
let defaultPage = {
|
|
90
|
-
minify: false,
|
|
91
|
-
favicon,
|
|
92
|
-
meta: siteData.meta || meta,
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// add html
|
|
96
|
-
webpackConfig.plugins = [
|
|
97
|
-
...webpackConfig.plugins,
|
|
98
|
-
new HtmlWebpackPlugin({
|
|
99
|
-
filename: path.join( appPath, 'public', 'index.html'),
|
|
100
|
-
template: path.join(samplePath, 'index.html'),
|
|
101
|
-
//templateContent: generatePages(siteData),
|
|
102
|
-
title: 'Test Site',
|
|
103
|
-
...defaultPage
|
|
104
|
-
})
|
|
105
|
-
]
|
|
106
|
-
|
|
107
|
-
// add devServer
|
|
108
|
-
webpackConfig.devServer = {
|
|
109
|
-
devMiddleware: {
|
|
110
|
-
writeToDisk: true,
|
|
111
|
-
},
|
|
112
|
-
hot: false,
|
|
113
|
-
allowedHosts: 'auto',
|
|
114
|
-
host: 'localhost',
|
|
115
|
-
port: 9000,
|
|
116
|
-
compress: true,
|
|
117
|
-
static: [
|
|
118
|
-
{
|
|
119
|
-
directory: path.join( appPath, 'build'),
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
directory: path.join(appPath, 'node_modules'),
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
directory: path.join(appPath, 'public'),
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
directory: path.join(appPath, 'src'),
|
|
129
|
-
}
|
|
130
|
-
],
|
|
131
|
-
proxy: [
|
|
132
|
-
{
|
|
133
|
-
context: ['/node_modules'],
|
|
134
|
-
target: 'http://localhost:9000',
|
|
135
|
-
pathRewrite: { '^/node_modules': '' },
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
context: ['/src'],
|
|
139
|
-
target: 'http://localhost:9000',
|
|
140
|
-
pathRewrite: { '^/src': '' },
|
|
141
|
-
}
|
|
142
|
-
],
|
|
143
|
-
}
|
|
144
|
-
};
|