@caweb/cli 1.3.17 → 1.4.0
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/assets/logo.ico +0 -0
- package/commands/serve.js +11 -2
- package/configs/webpack.config.js +8 -9
- package/gen/site-generator.js +51 -18
- package/package.json +14 -11
package/assets/logo.ico
ADDED
|
Binary file
|
package/commands/serve.js
CHANGED
|
@@ -39,6 +39,8 @@ export default async function serve({
|
|
|
39
39
|
// Otherwise we load a blank html page
|
|
40
40
|
process.env.CDT_TEMPLATE = template;
|
|
41
41
|
|
|
42
|
+
// Let our webpack config know it's serving not building
|
|
43
|
+
process.env.CAWEB_SERVE = true;
|
|
42
44
|
|
|
43
45
|
// Our default Webpack Configuration
|
|
44
46
|
const defaultConfig = path.join( projectPath, 'configs', 'webpack.config.js' );
|
|
@@ -46,7 +48,7 @@ export default async function serve({
|
|
|
46
48
|
let webPackArgs = [
|
|
47
49
|
'serve',
|
|
48
50
|
'--open',
|
|
49
|
-
'--mode=
|
|
51
|
+
'--mode=none',
|
|
50
52
|
'--config',
|
|
51
53
|
defaultConfig
|
|
52
54
|
];
|
|
@@ -72,7 +74,14 @@ export default async function serve({
|
|
|
72
74
|
await runCmd(
|
|
73
75
|
'webpack',
|
|
74
76
|
webPackArgs
|
|
75
|
-
)
|
|
77
|
+
).then(({stdout, stderr}) => {
|
|
78
|
+
// if an error was thrown, and no output
|
|
79
|
+
if( stderr && ! stdout.toString() ){
|
|
80
|
+
console.log( stderr.toString() )
|
|
81
|
+
}else{
|
|
82
|
+
spinner.text = 'Done'
|
|
83
|
+
}
|
|
84
|
+
});
|
|
76
85
|
|
|
77
86
|
|
|
78
87
|
};
|
|
@@ -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
|
-
|
|
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:
|
|
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(
|
|
116
|
+
if( process.env.CAWEB_SERVE ){
|
|
117
|
+
delete webpackConfig.devServer;
|
|
118
|
+
|
|
120
119
|
SiteGenerator( webpackConfig );
|
|
121
120
|
}
|
|
122
121
|
|
package/gen/site-generator.js
CHANGED
|
@@ -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/
|
|
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(
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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(
|
|
85
|
-
template: path.join(
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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",
|
|
@@ -38,7 +40,7 @@
|
|
|
38
40
|
"access": "public"
|
|
39
41
|
},
|
|
40
42
|
"config": {
|
|
41
|
-
"WP_VER": "6.5.
|
|
43
|
+
"WP_VER": "6.5.4",
|
|
42
44
|
"PHP_VER": "8.1",
|
|
43
45
|
"DEFAULTS": {
|
|
44
46
|
"FS_METHOD": "direct",
|
|
@@ -56,19 +58,20 @@
|
|
|
56
58
|
}
|
|
57
59
|
},
|
|
58
60
|
"dependencies": {
|
|
59
|
-
"@wordpress/create-block": "^4.
|
|
60
|
-
"@wordpress/env": "^
|
|
61
|
-
"@wordpress/scripts": "^
|
|
62
|
-
"accessibility-checker": "^3.1.
|
|
61
|
+
"@wordpress/create-block": "^4.43.0",
|
|
62
|
+
"@wordpress/env": "^10.0.0",
|
|
63
|
+
"@wordpress/scripts": "^28.0.0",
|
|
64
|
+
"accessibility-checker": "^3.1.72",
|
|
63
65
|
"autoprefixer": "^10.4.19",
|
|
64
|
-
"axios": "^1.
|
|
65
|
-
"axios-retry": "^4.
|
|
66
|
+
"axios": "^1.7.2",
|
|
67
|
+
"axios-retry": "^4.4.0",
|
|
66
68
|
"chalk": "^5.3.0",
|
|
67
|
-
"commander": "^12.
|
|
69
|
+
"commander": "^12.1.0",
|
|
68
70
|
"cross-spawn": "^7.0.3",
|
|
69
|
-
"css-loader": "^7.1.
|
|
71
|
+
"css-loader": "^7.1.2",
|
|
70
72
|
"docker-compose": "^0.24.8",
|
|
71
73
|
"fs-extra": "^11.2.0",
|
|
74
|
+
"got": "^14.4.1",
|
|
72
75
|
"handlebars-loader": "^1.7.3",
|
|
73
76
|
"html-to-json-parser": "^2.0.1",
|
|
74
77
|
"html-webpack-plugin": "^5.6.0",
|
|
@@ -79,6 +82,6 @@
|
|
|
79
82
|
"sass-loader": "^14.2.1",
|
|
80
83
|
"terminal-link": "^3.0.0",
|
|
81
84
|
"url": "^0.11.3",
|
|
82
|
-
"webpack": "^5.
|
|
85
|
+
"webpack": "^5.92.0"
|
|
83
86
|
}
|
|
84
87
|
}
|