@caweb/cli 1.5.0 → 1.5.2
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/commands/blocks/create-block.js +8 -9
- package/commands/index.js +1 -1
- package/commands/sync/index.js +553 -0
- package/commands/sync/prompts.js +107 -0
- package/lib/cli.js +37 -12
- package/package.json +6 -4
- package/commands/sync.js +0 -402
- package/configs/webpack.config.js +0 -192
|
@@ -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;
|