@caweb/webpack 1.6.3 → 1.6.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.
Files changed (2) hide show
  1. package/lib/args.js +59 -8
  2. package/package.json +3 -3
package/lib/args.js CHANGED
@@ -3,15 +3,65 @@
3
3
  */
4
4
  import { parseArgs } from 'node:util';
5
5
 
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+
10
+ // process.argv first two values are the node executable and the script being executed, so we can ignore those
11
+ let argv = process.argv.slice(2);
12
+
13
+ // process.argv0 first value is the node executable, so we can remove that
14
+ let argv0 = process.argv0.replace(/.*node[.a-z\s]*/, '');
15
+
6
16
  // flags can be passed via argv0
7
17
  // we also add args from NODE_OPTIONS
8
18
  let { values: flags } = parseArgs( {
9
19
  args: [
10
- ...process.argv,
11
- ...process.argv0.split(' '),
20
+ ...argv,
21
+ ...argv0.split(' '),
12
22
  ...(process.env.NODE_OPTIONS ? process.env.NODE_OPTIONS.trim().replace(/(^'|'$)/g, '').split(' ') : []).filter( Boolean )
13
23
  ].filter( Boolean ),
14
24
  strict: false,
25
+ allowPositionals: true,
26
+ allowNegative: true,
27
+
28
+ // in order for the flags to work in the cli's afterStart hook,
29
+ // we need to set the options that are used in the start command
30
+ options: {
31
+ cwd: {
32
+ type: 'string',
33
+ },
34
+ update: {
35
+ type: 'boolean',
36
+ },
37
+ xdebug: {
38
+ type: 'string'
39
+ },
40
+ spx: {
41
+ type: 'string'
42
+ },
43
+ scripts: {
44
+ type: 'boolean',
45
+ },
46
+ sync: {
47
+ type: 'boolean',
48
+ },
49
+ plugin: {
50
+ type: 'boolean',
51
+ short: 'p'
52
+ },
53
+ theme: {
54
+ type: 'boolean',
55
+ short: 't'
56
+ },
57
+ multisite: {
58
+ type: 'boolean',
59
+ short: 'm'
60
+ },
61
+ subdomain: {
62
+ type: 'boolean',
63
+ }
64
+ }
15
65
  } )
16
66
 
17
67
  // function to add a flag
@@ -23,12 +73,13 @@ function addFlag(flag, value = null){
23
73
 
24
74
  // check if a flag exists
25
75
  function flagExists(flag){
26
- return Object.keys(flags).includes(flag)
76
+ // parseArgs removes the leading dashes from flags, so we need to account for that
77
+ return Object.keys(flags).includes(flag.replace(/^-+/, ''));
27
78
  }
28
79
 
29
80
  // get the value of a flag
30
81
  function getArgVal(flag, defaultValue = null){
31
- return flagExists(flag) ? flags[flag] : (defaultValue ?? false);
82
+ return flagExists(flag) ? flags[flag.replace(/^-+/, '')] : (defaultValue ?? false);
32
83
  }
33
84
 
34
85
  // get all flags
@@ -38,8 +89,8 @@ function getAllFlags(){
38
89
 
39
90
  export {
40
91
  flags,
41
- flagExists,
42
- addFlag,
43
- getArgVal,
44
- getAllFlags
92
+ flagExists,
93
+ addFlag,
94
+ getArgVal,
95
+ getAllFlags
45
96
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caweb/webpack",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "description": "CAWebPublishing Webpack Configuration",
5
5
  "main": "webpack.config.js",
6
6
  "files": [
@@ -37,7 +37,7 @@
37
37
  "homepage": "https://github.com/CAWebPublishing/webpack#readme",
38
38
  "dependencies": {
39
39
  "@babel/plugin-proposal-class-properties": "^7.18.6",
40
- "@wordpress/scripts": "^31.3.0",
40
+ "@wordpress/scripts": "^31.4.0",
41
41
  "css-minimizer-webpack-plugin": "^7.0.4",
42
42
  "deepmerge": "^4.3.1",
43
43
  "handlebars": "^4.7.8",
@@ -47,7 +47,7 @@
47
47
  "html-webpack-skip-assets-plugin": "^1.0.4",
48
48
  "thread-loader": "^4.0.4",
49
49
  "ts-loader": "^9.5.4",
50
- "webpack": "^5.104.1",
50
+ "webpack": "^5.105.1",
51
51
  "webpack-cli": "^6.0.1",
52
52
  "webpack-dev-server": "^5.2.3",
53
53
  "webpack-merge": "^6.0.1",