@caweb/webpack 1.3.44 → 1.4.0-beta.1

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.
Files changed (91) hide show
  1. package/package.json +17 -9
  2. package/{plugins/html/webpack.config.js → webpack.config.js} +77 -49
  3. package/.github/workflows/config-publish.yml +0 -23
  4. package/.github/workflows/plugins-publish.yml +0 -31
  5. package/.github/workflows/test +0 -29
  6. package/.gitmodules +0 -3
  7. package/CHANGELOG.md +0 -273
  8. package/plugins/a11y/README.md +0 -19
  9. package/plugins/a11y/aceconfig.js +0 -44
  10. package/plugins/a11y/changelog.txt +0 -31
  11. package/plugins/a11y/index.js +0 -271
  12. package/plugins/a11y/package-lock.json +0 -3303
  13. package/plugins/a11y/package.json +0 -42
  14. package/plugins/css-audit/README.md +0 -20
  15. package/plugins/css-audit/changelog.txt +0 -41
  16. package/plugins/css-audit/css-audit.config.cjs +0 -5
  17. package/plugins/css-audit/default.config.js +0 -19
  18. package/plugins/css-audit/index.js +0 -326
  19. package/plugins/css-audit/package-lock.json +0 -1522
  20. package/plugins/css-audit/package.json +0 -53
  21. package/plugins/css-audit/sample/no-files.html +0 -9
  22. package/plugins/html/CHANGELOG.md +0 -300
  23. package/plugins/html/README.md +0 -62
  24. package/plugins/html/entry/delta.js +0 -19
  25. package/plugins/html/entry/eureka.js +0 -19
  26. package/plugins/html/entry/mono.js +0 -19
  27. package/plugins/html/entry/oceanside.js +0 -19
  28. package/plugins/html/entry/orangecounty.js +0 -19
  29. package/plugins/html/entry/pasorobles.js +0 -19
  30. package/plugins/html/entry/sacramento.js +0 -19
  31. package/plugins/html/entry/santabarbara.js +0 -19
  32. package/plugins/html/entry/santacruz.js +0 -19
  33. package/plugins/html/entry/shasta.js +0 -19
  34. package/plugins/html/entry/sierra.js +0 -19
  35. package/plugins/html/entry/trinity.js +0 -19
  36. package/plugins/html/index.js +0 -105
  37. package/plugins/html/package-lock.json +0 -22895
  38. package/plugins/html/package.json +0 -135
  39. package/plugins/html/sample/blank.html +0 -13
  40. package/plugins/html/sample/components/alerts.html +0 -32
  41. package/plugins/html/sample/components/animations.html +0 -7
  42. package/plugins/html/sample/components/buttons.html +0 -5
  43. package/plugins/html/sample/components/cards.html +0 -88
  44. package/plugins/html/sample/components/lists.html +0 -75
  45. package/plugins/html/sample/components/locations.html +0 -49
  46. package/plugins/html/sample/components/profile-banners.html +0 -48
  47. package/plugins/html/sample/components/sections.html +0 -16
  48. package/plugins/html/sample/components/service-tiles.html +0 -73
  49. package/plugins/html/sample/components/typography.html +0 -42
  50. package/plugins/html/sample/default.html +0 -53
  51. package/plugins/html/sample/favicon.ico +0 -0
  52. package/plugins/html/sample/images/black_puppy.jpg +0 -0
  53. package/plugins/html/sample/images/dolphin_marine_mammals_water.jpg +0 -0
  54. package/plugins/html/sample/images/grayscale_mountain.jpg +0 -0
  55. package/plugins/html/sample/images/silhouette.png +0 -0
  56. package/plugins/html/sample/images/squirrel_tail_bushy_tail.jpg +0 -0
  57. package/plugins/html/sample/index.html +0 -47
  58. package/plugins/html/sample/missing/content.html +0 -4
  59. package/plugins/html/sample/search.html +0 -55
  60. package/plugins/html/sample/structural/branding.html +0 -21
  61. package/plugins/html/sample/structural/footer.html +0 -47
  62. package/plugins/html/sample/structural/header.html +0 -16
  63. package/plugins/html/sample/structural/mobile-controls.html +0 -5
  64. package/plugins/html/sample/structural/navigation.html +0 -30
  65. package/plugins/html/sample/structural/search.html +0 -13
  66. package/plugins/html/sample/structural/utility-header.html +0 -23
  67. package/plugins/html/scripts/create-entrypoints.js +0 -60
  68. package/plugins/html/scripts/schemes.js +0 -123
  69. package/plugins/html/scripts/update-scripts.js +0 -47
  70. package/plugins/html/scripts/webpack.test.js +0 -41
  71. package/plugins/jshint/.customrc +0 -29
  72. package/plugins/jshint/.jshintrc +0 -31
  73. package/plugins/jshint/README.md +0 -24
  74. package/plugins/jshint/changelog.txt +0 -36
  75. package/plugins/jshint/index.js +0 -291
  76. package/plugins/jshint/package-lock.json +0 -24453
  77. package/plugins/jshint/package.json +0 -50
  78. package/plugins/jshint/reporter.cjs +0 -301
  79. package/plugins/jshint/sample/no-files.html +0 -9
  80. package/plugins/jshint/scripts/webpack.test.js +0 -18
  81. package/sample/index.html +0 -364
  82. package/scripts/update-deps.js +0 -38
  83. /package/{plugins/html/helpers → helpers}/logic/endsWith.js +0 -0
  84. /package/{plugins/html/helpers → helpers}/logic/ifCond.js +0 -0
  85. /package/{plugins/html/helpers → helpers}/object/jsonParse.js +0 -0
  86. /package/{plugins/html/helpers → helpers}/object/jsonStringify.js +0 -0
  87. /package/{plugins/html/helpers → helpers}/string/replace.js +0 -0
  88. /package/{plugins/html/helpers → helpers}/string/toLower.js +0 -0
  89. /package/{plugins/html/helpers → helpers}/string/toTitleCase.js +0 -0
  90. /package/{plugins/html/helpers → helpers}/string/toUpper.js +0 -0
  91. /package/{plugins/html/tsconfig.json → tsconfig.json} +0 -0
@@ -1,42 +0,0 @@
1
- {
2
- "name": "@caweb/a11y-webpack-plugin",
3
- "version": "1.0.9",
4
- "description": "CAWebPublishing Webpack Plugin to run Accessibility Scans",
5
- "type": "module",
6
- "main": "index.js",
7
- "files": [
8
- "aceconfig.js",
9
- "index.js",
10
- "README.md"
11
- ],
12
- "scripts": {
13
- "test": "echo \"Error: run tests from root\" && exit 0"
14
- },
15
- "author": "CAWebPublishing",
16
- "license": "ISC",
17
- "bugs": {
18
- "url": "https://github.com/CAWebPublishing/webpack/issues"
19
- },
20
- "publishConfig": {
21
- "access": "public"
22
- },
23
- "homepage": "https://github.com/CAWebPublishing/webpack#readme",
24
- "repository": {
25
- "type": "git",
26
- "url": "https://github.com/CAWebPublishing/webpack",
27
- "directory": "plugins/a11y"
28
- },
29
- "keywords": [
30
- "caweb",
31
- "cagov",
32
- "webpack"
33
- ],
34
- "dependencies": {
35
- "accessibility-checker": "^3.1.76",
36
- "check-valid-url": "^0.1.0"
37
- },
38
- "devDependencies": {
39
- "webpack": "^5.96.1",
40
- "webpack-cli": "^5.1.4"
41
- }
42
- }
@@ -1,20 +0,0 @@
1
- This is a Webpack Plugin that utilizes the [Wordpress CSS Audit](https://github.com/WordPress/css-audit) to audit the projects css.
2
-
3
-
4
- ## Installation
5
- <pre>npm install --save-dev @caweb/css-audit-webpack-plugin</pre>
6
-
7
- ## Get Started
8
- In your Webpack configuration simply add the plugin to your existing plugin array.
9
-
10
- <pre>
11
- import CSSAuditPlugin from '@caweb/css-audit-webpack-plugin';
12
-
13
- export default {
14
- plugins: [
15
- new CSSAuditPlugin()
16
- ]
17
- }
18
- </pre>
19
-
20
- ## Options
@@ -1,41 +0,0 @@
1
- v1.0.12
2
- - Update npm packages
3
- - Added npm devDependencies packages
4
-
5
- v1.0.11
6
- - Update npm packages
7
-
8
- v1.0.10
9
- - Updated Readme
10
-
11
- v1.0.9
12
- - Added sample directory
13
-
14
- v1.0.8
15
- - Fixed issue with hot module replacement not loading
16
-
17
- v1.0.7
18
- - Fixed issue with options constructor parameter not being defined
19
-
20
- v1.0.6
21
- - Fixed issue with outputfolder not existing
22
-
23
- v1.0.5
24
- - Added sample file for when no files are audited
25
-
26
- v1.0.4
27
- - Resolved issue when NODE_OPTIONS not defined
28
-
29
- v1.0.3
30
- - Arguments can be passed via NODE_OPTIONS env variable now
31
- - We no longer scan rtl stylesheets
32
-
33
- v1.0.2
34
- - Reverted removal of node deprecation warnings
35
- - Fixed issue with Hot Module Replacement not triggering
36
-
37
- v1.0.1
38
- - Removed node deprecation warnings
39
-
40
- v1.0.0
41
- - CSS Audit Webpack Plugin
@@ -1,5 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
-
5
- module.exports = {};
@@ -1,19 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
-
5
- export default {
6
- format: 'html',
7
- filename: 'css-audit',
8
- colors: true,
9
- important: true,
10
- displayNone: true,
11
- selectors: true,
12
- mediaQueries: true,
13
- typography: true,
14
- propertyValues: [
15
- 'font-size',
16
- 'padding,padding-top,padding-bottom,padding-right,padding-left' ,
17
- 'property-values', 'margin,margin-top,marin-bottom,marin-right,marin-left',
18
- ]
19
- };
@@ -1,326 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * External dependencies
5
- */
6
- import { sync as resolveBin } from 'resolve-bin';
7
- import spawn from 'cross-spawn';
8
- import { getAllFilesSync } from 'get-all-files'
9
- import EntryDependency from "webpack/lib/dependencies/EntryDependency.js";
10
-
11
- import path from 'path';
12
- import fs from 'fs';
13
- import deepmerge from 'deepmerge';
14
- import chalk from 'chalk';
15
- import { fileURLToPath, URL } from 'url';
16
-
17
- // default configuration
18
- import {default as DefaultConfig} from './default.config.js';
19
-
20
- const boldWhite = chalk.bold.white;
21
- const boldGreen = chalk.bold.green;
22
- const boldBlue = chalk.bold.hex('#03a7fc');
23
- const currentPath = path.dirname(fileURLToPath(import.meta.url));
24
-
25
- // CSS Audit Plugin
26
- class CSSAuditPlugin {
27
- config = {}
28
-
29
- constructor(opts = {}) {
30
-
31
- // if no outputFolder is defined fallback to the default path
32
- if( ! opts.outputFolder ){
33
- opts.outputFolder = path.join(currentPath, 'bin', 'auditor', 'public')
34
- // path must be absolute
35
- }else if( ! path.isAbsolute(opts.outputFolder) ){
36
- opts.outputFolder = path.join(process.cwd(), opts.outputFolder );
37
- }
38
-
39
- this.config = deepmerge(DefaultConfig, opts);
40
- }
41
-
42
- apply(compiler) {
43
- const staticDir = {
44
- directory: this.config.outputFolder,
45
- watch: true
46
- }
47
- let { devServer, output } = compiler.options;
48
- let hostUrl = 'localhost' === devServer.host ? `http://${devServer.host}`: devServer.host;
49
- let hostPort = devServer.port;
50
-
51
- if( hostPort && 80 !== hostPort )
52
- {
53
- hostUrl = `${hostUrl}:${hostPort}`;
54
- }
55
-
56
- // if dev server allows for multiple pages to be opened
57
- // add css-audit.html to open property.
58
- if( Array.isArray(devServer.open) ){
59
- devServer.open.push(`${hostUrl}/${this.config.rewrite ? this.config.rewrite : this.config.filename}.html`)
60
- }else if( 'object' === typeof devServer.open && Array.isArray(devServer.open.target) ){
61
- devServer.open.target.push(`${hostUrl}/${this.config.filename}.html`)
62
- }
63
-
64
- // add our static directory
65
- if( Array.isArray(devServer.static) ){
66
- devServer.static.push(staticDir)
67
- }else{
68
- devServer.static = [].concat(devServer.static, staticDir );
69
- }
70
-
71
- // we always make sure the output folder exists
72
- fs.mkdirSync( staticDir.directory, { recursive: true } );
73
-
74
- // Wait for configuration preset plugins to apply all configure webpack defaults
75
- compiler.hooks.initialize.tap('CSS Audit Plugin', () => {
76
- compiler.hooks.compilation.tap(
77
- "CSS Audit Plugin",
78
- (compilation, { normalModuleFactory }) => {
79
- compilation.dependencyFactories.set(
80
- EntryDependency,
81
- normalModuleFactory
82
- );
83
- }
84
- );
85
-
86
- const { entry, options, context } = {
87
- entry: path.join(staticDir.directory, 'css-audit.update.js'),
88
- options: {
89
- name: 'css-audit.update'
90
- },
91
- context: staticDir.directory
92
- };
93
-
94
- const dep = new EntryDependency(entry);
95
- dep.loc = {
96
- name: options.name
97
- };
98
-
99
- fs.writeFileSync(
100
- path.join(staticDir.directory, `css-audit.update.js`),
101
- `` // required for hot-update to compile on our page, blank script for now
102
- );
103
-
104
- compiler.hooks.thisCompilation.tap('CSS Audit Plugin',
105
- /**
106
- * Hook into the webpack compilation
107
- * @param {Compilation} compilation
108
- */
109
- (compilation) => {
110
-
111
- compiler.hooks.make.tapAsync("CSS Audit Plugin", (compilation, callback) => {
112
-
113
- compilation.addEntry(
114
- context,
115
- dep,
116
- options,
117
- err => {
118
- callback(err);
119
- });
120
- });
121
-
122
-
123
-
124
- });
125
-
126
- compiler.hooks.done.tapAsync('CSS Audit Plugin',
127
- (stats, callback) => {
128
- let files = [];
129
- getAllFilesSync(compiler.options.output.path).toArray().forEach(f => {
130
- // we skip any Right to Left style sheets
131
- if( f.endsWith('.css') && ! f.endsWith('-rtl.css') ){
132
- files.push(f)
133
- }
134
- })
135
- console.log(`<i> ${boldGreen('[webpack-dev-middleware] Running CSS Audit...')}`);
136
-
137
- let result = this.audit(files, this.config );
138
-
139
- if( result ){
140
- // we have to inject the css-audit.update.js file into the head in order for the webpack-dev-server scripts to load.
141
- let pageContent = fs.readFileSync(path.join(staticDir.directory, `${this.config.filename}.html`))
142
-
143
- fs.writeFileSync(
144
- path.join(staticDir.directory, `${this.config.filename}.html`),
145
- pageContent.toString().replace('</head>', `<script src="./css-audit.update.js"></script>\n</head>`)
146
- )
147
- }
148
-
149
- console.log(`<i> ${boldGreen('[webpack-dev-middleware] CSS Audit can be viewed at')} ${ boldBlue(new URL(`${hostUrl}/${this.config.filename}.html`).toString()) }`);
150
-
151
- callback();
152
- }
153
- )
154
-
155
- });
156
-
157
- }
158
-
159
- /**
160
- * Run WordPress CSS Audit
161
- *
162
- * @link https://github.com/WordPress/css-audit/blob/trunk/README.md
163
- *
164
- * @param {Array} files
165
- * @param {Object} options
166
- * @param {boolean} options.debug
167
- * @param {boolean} options.format
168
- * @param {boolean} options.filename
169
- * @param {boolean} options.outputFolder Where the audit should be saved.
170
- * @param {boolean} options.colors
171
- * @param {boolean} options.important
172
- * @param {boolean} options.displayNone
173
- * @param {boolean} options.selectors
174
- * @param {boolean} options.mediaQueries
175
- * @param {boolean} options.typography
176
- * @param {Array} options.propertyValues
177
- */
178
- audit(files, {
179
- debug,
180
- format,
181
- filename,
182
- outputFolder,
183
- colors,
184
- important,
185
- displayNone,
186
- selectors,
187
- mediaQueries,
188
- typography,
189
- propertyValues
190
- }){
191
-
192
- let filesToBeAudited = [];
193
- let filesWithIssues = [];
194
-
195
- // the css audit tool always outputs to its own public directory
196
- let defaultOutputPath = path.join(currentPath, 'bin', 'auditor', 'public');
197
-
198
- // we always make sure the output folder exists
199
- fs.mkdirSync( outputFolder, { recursive: true } );
200
-
201
- files.forEach( (paths, i) => {
202
- let resolvePath = path.resolve(paths);
203
-
204
- try {
205
- // if given path is a directory
206
- if( fs.statSync(resolvePath).isDirectory() ){
207
-
208
- // get all .css files
209
- getAllFilesSync(resolvePath).toArray().forEach(f => {
210
- if( f.endsWith('.css') ){
211
- filesToBeAudited.push(f)
212
- }
213
- })
214
- // if given path is a file and a .css file
215
- }else if( fs.statSync(paths).isFile() && (paths.endsWith('.css') || paths.endsWith('.scss')) ){
216
- filesToBeAudited.push(paths)
217
- }
218
- // invalid path/file
219
- } catch (error) {
220
- filesWithIssues.push(paths)
221
- }
222
-
223
- });
224
-
225
- if( ! filesToBeAudited.length ){
226
- console.log('No file(s) or directory path(s) were given or default directory was not found.')
227
- console.log('Auditor did not execute.');
228
-
229
- fs.copyFileSync(
230
- path.join(currentPath, 'sample', 'no-files.html'),
231
- path.join(defaultOutputPath, `${filename}.html`),
232
- )
233
-
234
- return false;
235
- }
236
-
237
- /**
238
- * We combine process arguments from argv, argv0
239
- */
240
- const processArgs = [
241
- ...process.argv,
242
- ...process.argv0.split(' '),
243
-
244
- ]
245
-
246
- // we also add args from env.NODE_OPTIONS
247
- if( process.env.NODE_OPTIONS ){
248
- processArgs.push( ...process.env.NODE_OPTIONS.split(' ').filter(e=>e).map((o) => o.replaceAll("'", '')) )
249
- }
250
-
251
- /**
252
- * the css audit uses the filename for the title, rather than the project name
253
- * we fix that by passing the project name for the file name
254
- * then renaming the file to the intended file name.
255
- */
256
- let auditArgs = [
257
- colors && ! processArgs.includes('--no-colors') ? '--colors' : '',
258
- important && ! processArgs.includes('--no-important') ? '--important' : '',
259
- displayNone && ! processArgs.includes('--no-display-none') ? '--display-none' : '',
260
- selectors && ! processArgs.includes('--no-selectors') ? '--selectors' : '',
261
- mediaQueries && ! processArgs.includes('--no-media-queries') ? '--media-queries' : '',
262
- typography && ! processArgs.includes('--no-typography') ? '--typography' : '',
263
- format ? `--format=${format}` : '',
264
- filename ? `--filename=${path.basename(process.cwd())}` : ''
265
- ].filter( e => e)
266
-
267
- if( propertyValues && ! processArgs.includes('--no-property-values') ){
268
- propertyValues.forEach((p) => {
269
- auditArgs.push(`--property-values=${p.replace(' ',',')}`)
270
- })
271
- }
272
-
273
- let { stdout, stderr } = spawn.sync(
274
- 'node ' + resolveBin('@caweb/css-audit-webpack-plugin', {executable: 'auditor'}),
275
- [
276
- ...filesToBeAudited,
277
- ...auditArgs
278
- ],
279
- {
280
- stdio: 'pipe',
281
- cwd: fs.existsSync(path.join(process.cwd(), 'css-audit.config.cjs')) ? process.cwd() : currentPath
282
- }
283
- )
284
-
285
- if( stderr && stderr.toString() ){
286
- console.log( stderr.toString() )
287
- }
288
-
289
- if( stdout && stdout.toString() ){
290
-
291
-
292
- // rename the file back to the intended file name instead of the project name
293
- let outputFile = path.join(outputFolder, `${filename}.html`);
294
-
295
- fs.renameSync(
296
- path.join(defaultOutputPath, `${path.basename(process.cwd())}.html`),
297
- outputFile
298
- )
299
-
300
- // we also move the style.css as well case the output path is different than the default.
301
- if( fs.existsSync( path.join( defaultOutputPath, 'style.css' ) ) ){
302
- fs.renameSync(
303
- path.join( defaultOutputPath, 'style.css' ),
304
- path.join( outputFolder, 'style.css' )
305
- )
306
- }
307
-
308
- let msg = stdout.toString().replace('undefined', '');
309
-
310
- // the command was ran via cli
311
- if( 'audit' === process.argv[2] ){
312
- console.log( msg );
313
- console.log( path.resolve(outputFile) )
314
- // otherwise it's being applied during the webpack process.
315
- }else{
316
- return msg;
317
- }
318
-
319
- }
320
-
321
- } // end of audit
322
-
323
- } // end of class
324
-
325
-
326
- export default CSSAuditPlugin;