@caweb/cli 1.3.17 → 1.4.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.
Binary file
package/commands/a11y.js CHANGED
@@ -3,9 +3,10 @@
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
+ import achecker from 'accessibility-checker';
6
7
  import path from 'path';
8
+ import { isUrl } from 'check-valid-url';
7
9
  import fs from 'fs';
8
- import resolveBin from 'resolve-bin';
9
10
 
10
11
  /**
11
12
  * Internal dependencies
@@ -16,7 +17,7 @@ import defaultConfig from '../configs/aceconfig.js';
16
17
  import {
17
18
  runCmd,
18
19
  } from '../lib/index.js';
19
-
20
+ import { stderr, stdout } from 'process';
20
21
 
21
22
 
22
23
  /**
@@ -25,14 +26,17 @@ import {
25
26
  * @param {Object} options
26
27
  * @param {Object} options.spinner A CLI spinner which indicates progress.
27
28
  * @param {boolean} options.debug True if debug mode is enabled.
29
+ * @param {boolean} options.url True if debug mode is enabled.
28
30
  */
29
31
  export default async function a11y({
30
32
  spinner,
31
33
  debug,
34
+ url
32
35
  } ) {
33
36
 
34
37
  // Spinner not needed at the moment
35
- spinner.stop()
38
+ spinner.stop();
39
+
36
40
  const {
37
41
  ruleArchive,
38
42
  policies,
@@ -62,13 +66,30 @@ export default async function a11y({
62
66
  outputFormat,
63
67
  '---outputFilenameTimestamp',
64
68
  outputFilenameTimestamp,
65
- process.argv.pop()
69
+ url
66
70
  ];
67
71
 
68
- // run webpack with our arguments.
69
- await runCmd(
70
- 'achecker',
71
- acheckerArgs,
72
- )
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
+
73
94
 
74
95
  };
package/commands/serve.js CHANGED
@@ -15,6 +15,8 @@ import {
15
15
  runCmd
16
16
  } from '../lib/index.js';
17
17
 
18
+ import a11y from './a11y.js';
19
+
18
20
  /**
19
21
  * Serves the current project
20
22
  *
@@ -39,6 +41,8 @@ export default async function serve({
39
41
  // Otherwise we load a blank html page
40
42
  process.env.CDT_TEMPLATE = template;
41
43
 
44
+ // Let our webpack config know it's serving not building
45
+ process.env.CAWEB_SERVE = true;
42
46
 
43
47
  // Our default Webpack Configuration
44
48
  const defaultConfig = path.join( projectPath, 'configs', 'webpack.config.js' );
@@ -46,7 +50,7 @@ export default async function serve({
46
50
  let webPackArgs = [
47
51
  'serve',
48
52
  '--open',
49
- '--mode=development',
53
+ '--mode=none',
50
54
  '--config',
51
55
  defaultConfig
52
56
  ];
@@ -72,7 +76,19 @@ export default async function serve({
72
76
  await runCmd(
73
77
  'webpack',
74
78
  webPackArgs
75
- )
79
+ ).then(({stdout, stderr}) => {
80
+ // if an error was thrown, and no output
81
+ if( stderr && ! stdout.toString() ){
82
+ console.log( stderr.toString() )
83
+ }else{
84
+
85
+ // run a11y checker as well
86
+ //await a11y({spinner, debug, url: './public/index.html' })
87
+
88
+ //return;
89
+ spinner.text = 'Done'
90
+ }
91
+ });
76
92
 
77
93
 
78
94
  };
@@ -10,10 +10,7 @@
10
10
  * External dependencies
11
11
  */
12
12
  import baseConfig from '@wordpress/scripts/config/webpack.config.js';
13
- import path from 'path';
14
- import fs from 'fs';
15
13
  import MiniCssExtractPlugin from "mini-css-extract-plugin";
16
- import CopyWebpackPlugin from 'copy-webpack-plugin';
17
14
 
18
15
  /**
19
16
  * Internal dependencies
@@ -85,11 +82,11 @@ baseConfig.module.rules.forEach((rule, i) => {
85
82
  // Our Webpack Configuration.
86
83
  let webpackConfig = {
87
84
  ...baseConfig,
88
- //target: 'browserslist',
85
+ target: 'web',
89
86
  devtool: false,
90
87
  output: {
91
88
  ...baseConfig.output,
92
- publicPath: `./`,
89
+ publicPath: `/`,
93
90
  clean: true
94
91
  },
95
92
  plugins: [
@@ -104,10 +101,10 @@ let webpackConfig = {
104
101
  module: {
105
102
  rules: [
106
103
  ...baseConfig.module.rules,
107
- {
104
+ /*{
108
105
  test: /\.html$/,
109
- loader: 'handlebars-loader'
110
- }
106
+ loader:'handlebars-loader'
107
+ }*/
111
108
  ]
112
109
  },
113
110
  performance: {
@@ -116,7 +113,9 @@ let webpackConfig = {
116
113
  }
117
114
  };
118
115
 
119
- if( ! isProduction ){
116
+ if( process.env.CAWEB_SERVE ){
117
+ delete webpackConfig.devServer;
118
+
120
119
  SiteGenerator( webpackConfig );
121
120
  }
122
121
 
@@ -7,7 +7,7 @@
7
7
  import path from 'node:path';
8
8
  import fs from 'fs-extra';
9
9
 
10
- import { CAWEB_OPTIONS, DIVI_OPTIONS } from '../../lib/options.js';
10
+ import { CAWEB_OPTIONS, DIVI_OPTIONS } from '../../lib/index.js';
11
11
 
12
12
  generateOverridesMD()
13
13
 
@@ -14,14 +14,18 @@ import {
14
14
  generatePages
15
15
  } from './parser.js';
16
16
 
17
- import {
17
+ /*import {
18
18
  projectPath,
19
19
  appPath
20
- } from '../lib/helpers.js';
21
-
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');
22
26
  const srcPath = path.join( appPath, 'src');
23
27
  const dataPath = path.join( srcPath, 'data');
24
- const assetsPath = path.join( srcPath, 'assets');
28
+ //const assetsPath = path.join( srcPath, 'assets');
25
29
 
26
30
  // default meta used for site generation when no meta is passed
27
31
  const meta = {
@@ -56,7 +60,7 @@ function getSiteData(){
56
60
 
57
61
  export default (webpackConfig) => {
58
62
  // we only proceed if and index.html exists
59
- if( ! fs.existsSync( path.join( srcPath, 'index.html' )) ){
63
+ if( ! fs.existsSync( path.join( samplePath, 'index.html' )) ){
60
64
  return;
61
65
  }
62
66
 
@@ -66,10 +70,21 @@ export default (webpackConfig) => {
66
70
  // get site data
67
71
  let siteData = getSiteData();
68
72
 
69
- // if favicon doesn't exist use fallback asset.
70
- let favicon = fs.existsSync(path.join(assetsPath, 'images', 'favicon.ico')) ?
71
- path.join(assetsPath, 'images', 'favicon.ico') :
72
- path.join(projectPath, 'assets', 'favicon.ico') ;
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
+ );
73
88
 
74
89
  let defaultPage = {
75
90
  minify: false,
@@ -81,8 +96,8 @@ export default (webpackConfig) => {
81
96
  webpackConfig.plugins = [
82
97
  ...webpackConfig.plugins,
83
98
  new HtmlWebpackPlugin({
84
- filename: path.join( process.cwd(), 'public', 'index.html'),
85
- template: path.join(srcPath, 'index.html'),
99
+ filename: path.join( appPath, 'public', 'index.html'),
100
+ template: path.join(samplePath, 'index.html'),
86
101
  //templateContent: generatePages(siteData),
87
102
  title: 'Test Site',
88
103
  ...defaultPage
@@ -99,13 +114,31 @@ export default (webpackConfig) => {
99
114
  host: 'localhost',
100
115
  port: 9000,
101
116
  compress: true,
102
- proxy: {
103
- '/public': {
104
- pathRewrite: {
105
- '^/build': '',
106
- },
117
+ static: [
118
+ {
119
+ directory: path.join( appPath, 'build'),
107
120
  },
108
- },
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
+ ],
109
143
  }
110
-
111
144
  };
package/lib/cli.js CHANGED
@@ -227,6 +227,7 @@ export default function cli() {
227
227
 
228
228
  // a11y Command.
229
229
  program.command('a11y')
230
+ .addArgument(new Argument('<url>', 'URL to scan for accessibility checks.'))
230
231
  .description('Runs accessibility checks.')
231
232
  .allowUnknownOption(true)
232
233
  .action(withSpinner(env.a11y))
package/lib/helpers.js CHANGED
@@ -40,9 +40,12 @@ async function runCmd(cmd, args,opts = { stdio: ['inherit', 'pipe'] }){
40
40
  */
41
41
  cmd += /^win/.test(process.platform) ? '.cmd' : '';
42
42
  break;
43
+ case 'achecker':
44
+ cmd = resolveBin('accessibility-checker', {executable: 'achecker'})
45
+ break;
43
46
  case 'webpack':
44
47
  cmd = resolveBin(cmd)
45
- break
48
+ break;
46
49
  }
47
50
 
48
51
  return spawn.sync( cmd, args, {...opts, env: process.env});
package/lib/index.js CHANGED
@@ -25,7 +25,9 @@ import {
25
25
  convertToMultisite,
26
26
  generateHTAccess,
27
27
  getTaxonomies,
28
- createTaxonomies
28
+ createTaxonomies,
29
+ CAWEB_OPTIONS,
30
+ DIVI_OPTIONS
29
31
  } from './wordpress/index.js';
30
32
 
31
33
  export {
@@ -49,5 +51,7 @@ export {
49
51
  convertToMultisite,
50
52
  generateHTAccess,
51
53
  getTaxonomies,
52
- createTaxonomies
54
+ createTaxonomies,
55
+ CAWEB_OPTIONS,
56
+ DIVI_OPTIONS
53
57
  }
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@caweb/cli",
3
- "version": "1.3.17",
3
+ "version": "1.4.1",
4
4
  "description": "CAWebPublishing Command Line Interface.",
5
5
  "exports": "./lib/env.js",
6
6
  "type": "module",
7
7
  "node": ">=20",
8
+ "main": "./lib/env.js",
8
9
  "author": "CAWebPublishing",
9
10
  "license": "ISC",
10
11
  "bin": {
11
12
  "caweb": "bin/caweb.js"
12
13
  },
13
14
  "files": [
15
+ "assets",
14
16
  "bin",
15
17
  "commands",
16
18
  "configs",
@@ -20,6 +22,7 @@
20
22
  "template"
21
23
  ],
22
24
  "scripts": {
25
+ "doc": "node ./docs/tool/index.js",
23
26
  "test": "echo \"Error: run tests from root\" && exit 0"
24
27
  },
25
28
  "homepage": "https://github.com/CAWebPublishing/cli#readme",
@@ -38,7 +41,7 @@
38
41
  "access": "public"
39
42
  },
40
43
  "config": {
41
- "WP_VER": "6.5.3",
44
+ "WP_VER": "6.5.4",
42
45
  "PHP_VER": "8.1",
43
46
  "DEFAULTS": {
44
47
  "FS_METHOD": "direct",
@@ -56,19 +59,21 @@
56
59
  }
57
60
  },
58
61
  "dependencies": {
59
- "@wordpress/create-block": "^4.41.0",
60
- "@wordpress/env": "^9.9.0",
61
- "@wordpress/scripts": "^27.8.0",
62
- "accessibility-checker": "^3.1.71",
62
+ "@wordpress/create-block": "^4.44.0",
63
+ "@wordpress/env": "^10.1.0",
64
+ "@wordpress/scripts": "^28.1.0",
65
+ "accessibility-checker": "^3.1.73",
63
66
  "autoprefixer": "^10.4.19",
64
- "axios": "^1.6.8",
65
- "axios-retry": "^4.2.0",
67
+ "axios": "^1.7.2",
68
+ "axios-retry": "^4.4.0",
66
69
  "chalk": "^5.3.0",
67
- "commander": "^12.0.0",
70
+ "check-valid-url": "^0.1.0",
71
+ "commander": "^12.1.0",
68
72
  "cross-spawn": "^7.0.3",
69
- "css-loader": "^7.1.1",
73
+ "css-loader": "^7.1.2",
70
74
  "docker-compose": "^0.24.8",
71
75
  "fs-extra": "^11.2.0",
76
+ "got": "^14.4.1",
72
77
  "handlebars-loader": "^1.7.3",
73
78
  "html-to-json-parser": "^2.0.1",
74
79
  "html-webpack-plugin": "^5.6.0",
@@ -79,6 +84,6 @@
79
84
  "sass-loader": "^14.2.1",
80
85
  "terminal-link": "^3.0.0",
81
86
  "url": "^0.11.3",
82
- "webpack": "^5.91.0"
87
+ "webpack": "^5.92.1"
83
88
  }
84
89
  }