@caweb/cli 1.15.4 → 1.15.6

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.
@@ -0,0 +1,121 @@
1
+ // This file is auto-generated via "npm run update:webpack:flags"
2
+ const buildFlags = [
3
+ "-c",
4
+ "--config",
5
+ "--config-name",
6
+ "-m",
7
+ "--merge",
8
+ "--disable-interpret",
9
+ "--env",
10
+ "--node-env",
11
+ "--config-node-env",
12
+ "--analyze",
13
+ "--progress",
14
+ "-j",
15
+ "--json",
16
+ "--fail-on-warnings",
17
+ "-d",
18
+ "--devtool",
19
+ "--no-devtool",
20
+ "--entry",
21
+ "-e",
22
+ "--extends",
23
+ "--mode",
24
+ "--name",
25
+ "-o",
26
+ "--output-path",
27
+ "--stats",
28
+ "--no-stats",
29
+ "-t",
30
+ "--target",
31
+ "--no-target",
32
+ "-w",
33
+ "--watch",
34
+ "--no-watch",
35
+ "--watch-options-stdin",
36
+ "--no-watch-options-stdin",
37
+ "--color",
38
+ "--no-color",
39
+ "-v",
40
+ "--version",
41
+ "-h",
42
+ "--help"
43
+ ];
44
+
45
+ const serveFlags = [
46
+ "--allowed-hosts",
47
+ "--allowed-hosts-reset",
48
+ "--bonjour",
49
+ "--no-bonjour",
50
+ "--no-client",
51
+ "--client-logging",
52
+ "--client-overlay",
53
+ "--no-client-overlay",
54
+ "--client-overlay-errors",
55
+ "--no-client-overlay-errors",
56
+ "--client-overlay-warnings",
57
+ "--no-client-overlay-warnings",
58
+ "--client-overlay-runtime-errors",
59
+ "--no-client-overlay-runtime-errors",
60
+ "--client-overlay-trusted-types-policy-name",
61
+ "--client-progress",
62
+ "--no-client-progress",
63
+ "--client-reconnect",
64
+ "--no-client-reconnect",
65
+ "--client-web-socket-transport",
66
+ "--client-web-socket-url",
67
+ "--client-web-socket-url-hostname",
68
+ "--client-web-socket-url-pathname",
69
+ "--client-web-socket-url-password",
70
+ "--client-web-socket-url-port",
71
+ "--client-web-socket-url-protocol",
72
+ "--client-web-socket-url-username",
73
+ "--compress",
74
+ "--no-compress",
75
+ "--history-api-fallback",
76
+ "--no-history-api-fallback",
77
+ "--host",
78
+ "--hot",
79
+ "--no-hot",
80
+ "--ipc",
81
+ "--live-reload",
82
+ "--no-live-reload",
83
+ "--open",
84
+ "--no-open",
85
+ "--open-target",
86
+ "--open-app-name",
87
+ "--open-reset",
88
+ "--open-target-reset",
89
+ "--open-app-name-reset",
90
+ "--port",
91
+ "--server-type",
92
+ "--server-options-passphrase",
93
+ "--server-options-request-cert",
94
+ "--no-server-options-request-cert",
95
+ "--server-options-ca",
96
+ "--server-options-ca-reset",
97
+ "--server-options-cert",
98
+ "--server-options-cert-reset",
99
+ "--server-options-crl",
100
+ "--server-options-crl-reset",
101
+ "--server-options-key",
102
+ "--server-options-key-reset",
103
+ "--server-options-pfx",
104
+ "--server-options-pfx-reset",
105
+ "--static",
106
+ "--no-static",
107
+ "--static-directory",
108
+ "--static-public-path",
109
+ "--static-serve-index",
110
+ "--no-static-serve-index",
111
+ "--static-watch",
112
+ "--no-static-watch",
113
+ "--static-reset",
114
+ "--static-public-path-reset",
115
+ "--watch-files",
116
+ "--watch-files-reset",
117
+ "--no-web-socket-server",
118
+ "--web-socket-server-type"
119
+ ];
120
+
121
+ export { buildFlags, serveFlags };
@@ -11,42 +11,7 @@ import {
11
11
  runCmd
12
12
  } from '../../lib/index.js';
13
13
 
14
- const webpackAllowedFlags = [
15
- "-c",
16
- "--config",
17
- "--config-name",
18
- "-m",
19
- "--merge",
20
- "--disable-interpret",
21
- "--env",
22
- "--node-env",
23
- "--config-node-env",
24
- "--analyze",
25
- "--progress",
26
- "-j",
27
- "--json",
28
- "--fail-on-warnings",
29
- "-d",
30
- "--devtool",
31
- "--no-devtool",
32
- "--entry",
33
- "-e",
34
- "--extends",
35
- "--mode",
36
- "--name",
37
- "-o",
38
- "--output-path",
39
- "--stats",
40
- "--no-stats",
41
- "-t",
42
- "--target",
43
- "--no-target",
44
- "-w",
45
- "--watch",
46
- "--no-watch",
47
- "--watch-options-stdin",
48
- "--no-watch-options-stdin",
49
- ];
14
+ import { buildFlags, serveFlags } from './webpack-flags.js';
50
15
 
51
16
  /**
52
17
  * Build the current project
@@ -65,7 +30,8 @@ export default async function webpack({
65
30
  externals
66
31
  } ) {
67
32
  const webpackCommand = 'build' === process.argv[2] ? 'build' : 'serve' ;
68
-
33
+ const webpackAllowedFlags = 'build' === webpackCommand ? buildFlags : serveFlags ;
34
+
69
35
  // we use our default config from the @caweb/webpack
70
36
  const defaultConfigPath = path.resolve('node_modules', '@caweb', 'webpack', 'webpack.config.js' );
71
37
 
@@ -98,8 +64,10 @@ export default async function webpack({
98
64
 
99
65
  }
100
66
 
101
- // add the --merge flag to allow merging configs.
102
- webPackArgs.push( '--merge' );
67
+ // if -c or --config appears twice in the args we add the --merge flag
68
+ if( webPackArgs.filter( arg => '-c' === arg || '--config' === arg ).length > 1 ){
69
+ webPackArgs.push( '--merge' );
70
+ }
103
71
 
104
72
  let unknown = false;
105
73
  let unkownArgs = [];
package/lib/cli.js CHANGED
@@ -4,7 +4,7 @@
4
4
  //const wpenv_cli = require('@wordpress/env/lib/cli');
5
5
  import path from 'path';
6
6
  import fs from 'fs';
7
- import { Command, Argument, Option } from 'commander';
7
+ import { Command, Argument, Option, InvalidArgumentError } from 'commander';
8
8
 
9
9
  /**
10
10
  * Internal dependencies
@@ -62,7 +62,22 @@ function addWebpackCmds(){
62
62
  // Serve Command.
63
63
  program.command('serve')
64
64
  .description('Serves the current project using CAWebPublishing templates.')
65
- .addOption(new Option('--template <template>', 'Serves the project using templating.').choices(['default', 'blank']).default('default'))
65
+ .addOption(new Option('--template <template>', 'Serves the project using templating.').choices(['default', 'blank', '<local file>']).default('default').argParser( ( choice, t ) => {
66
+
67
+ // if choice is a valid option return it.
68
+ if( [ 'default', 'blank' ].includes( choice ) ){
69
+ return choice;
70
+ }
71
+
72
+ // if choice is a valid local file return the absolute path.
73
+ const localPath = path.resolve( choice );
74
+ if( fs.existsSync( localPath ) ){
75
+ return localPath;
76
+ }
77
+
78
+ // invalid option return error.
79
+ throw new InvalidArgumentError('Allowed choices are default, blank, <local file>.');
80
+ }))
66
81
  .addOption(new Option('--scheme <scheme>', 'Serves the project using template colorscheme.').choices([
67
82
  'delta',
68
83
  'eureka',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caweb/cli",
3
- "version": "1.15.4",
3
+ "version": "1.15.6",
4
4
  "description": "CAWebPublishing Command Line Interface.",
5
5
  "exports": "./lib/env.js",
6
6
  "type": "module",
@@ -20,7 +20,8 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "caweb": "node bin/caweb.js",
23
- "doc": "node ./docs/tool/index.js",
23
+ "update:webpack:flags": "node ./scripts/webpack-flags.js",
24
+ "doc": "node ./scripts/documentation.js",
24
25
  "test": "echo \"Error: run tests from root\" && exit 0"
25
26
  },
26
27
  "homepage": "https://github.com/CAWebPublishing/cli#readme",
@@ -63,7 +64,7 @@
63
64
  }
64
65
  },
65
66
  "dependencies": {
66
- "@caweb/webpack": "^1.5.11",
67
+ "@caweb/webpack": "^1.5.13",
67
68
  "@inquirer/prompts": "^8.1.0",
68
69
  "@wordpress/create-block": "^4.80.0",
69
70
  "@wordpress/env": "^10.37.0",