@caweb/cli 1.5.0 → 1.5.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.
package/lib/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
-
4
+ //const wpenv_cli = require('@wordpress/env/lib/cli');
5
5
  import path from 'path';
6
6
  import fs from 'fs';
7
7
  import { Command, Argument, Option } from 'commander';
@@ -39,13 +39,17 @@ const envArg = new Argument('[environment]', 'Which environment to use.')
39
39
  ])
40
40
  .default('development');
41
41
 
42
+
43
+ /**
44
+ * Adds commands for webpack
45
+ */
42
46
  function addWebpackCmds(){
43
47
 
44
48
  // Build Command.
45
49
  program.command('build')
46
- .description('Builds the current project.')
47
- .allowUnknownOption(true)
48
- .action(env.webpack)
50
+ .description('Builds the current project.')
51
+ .allowUnknownOption(true)
52
+ .action(env.webpack)
49
53
 
50
54
 
51
55
  // Serve Command.
@@ -127,6 +131,7 @@ function addWPEnvCommands(){
127
131
 
128
132
  // Start command.
129
133
  program.command('start')
134
+ .alias('launch')
130
135
  .description(
131
136
  `Starts two CAWebPublishing WordPress instances\ndevelopment on port http://localhost:8888 (override with WP_ENV_PORT)\ntests on port http://localhost:8889 (override with WP_ENV_TESTS_PORT).`
132
137
  )
@@ -174,6 +179,7 @@ function addWPEnvCommands(){
174
179
 
175
180
  // Destroy Command.
176
181
  program.command('destroy')
182
+ .alias('shutdown')
177
183
  .description(
178
184
  'Deletes docker containers, volumes, and networks associated with the CAWebPublishing instances and removes local files.'
179
185
  )
@@ -255,7 +261,6 @@ function addWPEnvCommands(){
255
261
 
256
262
  export default function cli() {
257
263
 
258
-
259
264
  program
260
265
  .name('caweb')
261
266
  .usage( '<command>' )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caweb/cli",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "CAWebPublishing Command Line Interface.",
5
5
  "exports": "./lib/env.js",
6
6
  "type": "module",
@@ -56,9 +56,9 @@
56
56
  }
57
57
  },
58
58
  "dependencies": {
59
- "@caweb/webpack": "^1.0.0",
60
- "@wordpress/create-block": "^4.45.0",
61
- "@wordpress/env": "^10.2.0",
59
+ "@caweb/webpack": "^1.0.1",
60
+ "@wordpress/create-block": "^4.46.0",
61
+ "@wordpress/env": "^10.3.0",
62
62
  "axios": "^1.7.2",
63
63
  "axios-retry": "^4.4.1",
64
64
  "chalk": "^5.3.0",
@@ -1,192 +0,0 @@
1
- /**
2
- * WebPack Configuration for California Department of Technology
3
- *
4
- * Utilizes WordPress Scripts Webpack configuration as base.
5
- * s
6
- * @link https://webpack.js.org/configuration/
7
- */
8
-
9
- /**
10
- * External dependencies
11
- */
12
- import baseConfig from '@wordpress/scripts/config/webpack.config.js';
13
- import path from 'path';
14
- import fs from 'fs';
15
- import HtmlWebpackPlugin from 'html-webpack-plugin';
16
- import {HtmlWebpackSkipAssetsPlugin} from 'html-webpack-skip-assets-plugin';
17
-
18
- import CSSAuditPlugin from '../lib/webpack/plugins/css-audit/index.js';
19
- import A11yPlugin from '../lib/webpack/plugins/a11y/index.js';
20
- import JSHintPlugin from '../lib/webpack/plugins/jshint/index.js';
21
-
22
- /**
23
- * Internal dependencies
24
- */
25
- import {
26
- projectPath,
27
- appPath
28
- } from '../lib/index.js';
29
-
30
-
31
- const samplePath = path.join( appPath, 'sample');
32
- const srcPath = path.join( appPath, 'src');
33
- const dataPath = path.join( srcPath, 'data');
34
-
35
-
36
- // Update some of the default WordPress webpack rules.
37
- baseConfig.module.rules.forEach((rule, i) => {
38
- const r = new RegExp(rule.test).toString();
39
-
40
- switch(r){
41
- // WordPress adds a hash to asset file names we remove that hash.
42
- case new RegExp(/\.(bmp|png|jpe?g|gif|webp)$/i).toString():
43
- rule.generator.filename = 'images/[name][ext]';
44
- break;
45
- case new RegExp(/\.(woff|woff2|eot|ttf|otf)$/i).toString():
46
- rule.generator.filename = 'fonts/[name][ext]';
47
- break;
48
- case new RegExp(/\.svg$/).toString():
49
- // we don't want SVG to be asset/inline otherwise the resource may not be available.
50
- // the asset should be an asset/resource we move them to the fonts folder.
51
- if( 'asset/inline' === rule.type ){
52
- rule.type = 'asset/resource';
53
- rule.generator = { filename: 'fonts/[name][ext]' };
54
-
55
- delete rule.issuer;
56
- }
57
- break;
58
- }
59
- });
60
-
61
- // Our Webpack Configuration.
62
- let webpackConfig = {
63
- ...baseConfig,
64
- target: 'web',
65
- cache: false,
66
- output: {
67
- ...baseConfig.output,
68
- publicPath: `/public`,
69
- clean: true
70
- },
71
- performance: {
72
- maxAssetSize: 500000,
73
- maxEntrypointSize: 500000
74
- }
75
- };
76
-
77
- // Delete the default WP Dev Server
78
- delete webpackConfig.devServer;
79
-
80
- // Only add the Dev Server if the serve command is ran.
81
- if( 'serve' === process.argv[2] ){
82
-
83
- // Add html rule
84
- webpackConfig.module.rules = [
85
- ...baseConfig.module.rules,
86
- {
87
- test: /\.html$/,
88
- loader:'handlebars-loader'
89
- }
90
- ]
91
-
92
- // we only want to display errors and warnings
93
- webpackConfig.stats = 'errors-warnings';
94
-
95
- let pageTemplate = {
96
- title: path.basename(appPath),
97
- minify: false,
98
- meta: {
99
- "Author": "CAWebPublishing",
100
- "Description": "State of California",
101
- "Keywords": "California,government",
102
- "viewport": "width=device-width, initial-scale=1.0, minimum-scale=1.0"
103
- },
104
- templateParameters: {
105
- "title" : path.basename(appPath)
106
- },
107
- skipAssets: [
108
- '**/index-rtl.css', // we skip the Right-to-Left Styles
109
- '**/css-audit.*', // we skip the CSSAudit Files
110
- '**/a11y.*', // we skip the A11y Files
111
- '**/jshint.*', // we skip the JSHint Files
112
- ]
113
- }
114
-
115
- // if an favicon exists.
116
- if( fs.existsSync(path.join(srcPath, 'favicon.ico')) ){
117
- pageTemplate.favicon = path.join(srcPath, 'favicon.ico');
118
- }
119
-
120
- // Sample Page.
121
- let sample = {
122
- ...pageTemplate,
123
- filename: path.join( appPath, 'public', 'index.html'),
124
- template: path.join(samplePath, 'index.html')
125
- }
126
-
127
- webpackConfig.plugins.push(
128
- new HtmlWebpackPlugin(sample),
129
- new HtmlWebpackSkipAssetsPlugin(),
130
- new JSHintPlugin(),
131
- new A11yPlugin(),
132
- new CSSAuditPlugin({
133
- format: 'html',
134
- colors: ! process.argv.includes('--no-colors'),
135
- important: ! process.argv.includes('--no-important'),
136
- displayNone: ! process.argv.includes('--no-display-none'),
137
- selectors: ! process.argv.includes('--no-selectors'),
138
- mediaQueries: ! process.argv.includes('--no-media-queries'),
139
- typography: ! process.argv.includes('--no-typography'),
140
- propertyValues: process.argv.includes('--no-property-values') ? false : [
141
- 'font-size',
142
- 'padding,padding-top,padding-bottom,padding-right,padding-left' ,
143
- 'property-values', 'margin,margin-top,marin-bottom,marin-right,marin-left',
144
- ]
145
- })
146
- );
147
-
148
- webpackConfig.devServer = {
149
- devMiddleware: {
150
- writeToDisk: true
151
- },
152
- headers: {
153
- },
154
- hot: true,
155
- open: ['http://localhost:9000'],
156
- //client: 'verbose',
157
- allowedHosts: 'auto',
158
- host: 'localhost',
159
- port: 9000,
160
- compress: true,
161
- static: [
162
- {
163
- directory: path.join( appPath, 'build'),
164
- },
165
- {
166
- directory: path.join(appPath, 'public')
167
- },
168
- {
169
- directory: path.join(appPath, 'node_modules'),
170
- },
171
- {
172
- directory: path.join(appPath, 'src'),
173
- },
174
- ],
175
- proxy: [
176
- {
177
- context: ['/node_modules'],
178
- target: 'http://localhost:9000',
179
- pathRewrite: { '^/node_modules': '' },
180
- },
181
- {
182
- context: ['/src'],
183
- target: 'http://localhost:9000',
184
- pathRewrite: { '^/src': '' },
185
- }
186
- ],
187
- }
188
-
189
-
190
- }
191
-
192
- export default webpackConfig;