kn-cli 1.0.69 → 1.0.71
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/build/webpack.config.js +10 -0
- package/package.json +5 -4
- package/readme.md +10 -0
- package/src/build.js +40 -23
- package/templates/template_admin/.gitignore +0 -6
- package/templates/template_app/.gitignore +0 -6
- package/templates/template_oa/.gitignore +0 -6
- package/templates/template_oa_jwt/.gitignore +0 -6
- package/templates/template_offcial/.gitignore +0 -6
package/build/webpack.config.js
CHANGED
|
@@ -14,6 +14,7 @@ const NowDateTime = Date.now();
|
|
|
14
14
|
|
|
15
15
|
//////////// CONFIG ENV ///////////////
|
|
16
16
|
const API_CONFIG = require('./webpack.api.js');
|
|
17
|
+
const cliConfig = require('./cli.config.js');
|
|
17
18
|
let CLI_CONFIG = {};
|
|
18
19
|
let existsCli= fs.existsSync('./cli.config.js');
|
|
19
20
|
if(existsCli){
|
|
@@ -42,6 +43,8 @@ const indexHtml = CLI_CONFIG?.indexHtml ?? true;
|
|
|
42
43
|
const https= CLI_CONFIG?.https ?? false;
|
|
43
44
|
const appVersion= CLI_CONFIG?.version ?? '';
|
|
44
45
|
const devServer=CLI_CONFIG?.devServer??{};
|
|
46
|
+
const prject_name = CLI_CONFIG?.name??'';
|
|
47
|
+
const sourceMapLocal = CLI_CONFIG?.sourcemap?.local??false;//是否将soucemap改为本地
|
|
45
48
|
|
|
46
49
|
let distFolder = 'dist';
|
|
47
50
|
let distJsFolder='';
|
|
@@ -368,9 +371,16 @@ if(devMode){
|
|
|
368
371
|
// publicPath: '..',//resource_path_relative,
|
|
369
372
|
// fileContext: 'js',
|
|
370
373
|
}))
|
|
374
|
+
}else{
|
|
375
|
+
plugins.push(new webpack.SourceMapDevToolPlugin({
|
|
376
|
+
filename: 'sourcemap/[file].map',
|
|
377
|
+
publicPath: sourceMapLocal?'':`http://192.168.90.250:9970/${prject_name}/`,//resource_path_relative,
|
|
378
|
+
// fileContext: 'js',
|
|
379
|
+
}))
|
|
371
380
|
}
|
|
372
381
|
|
|
373
382
|
|
|
383
|
+
|
|
374
384
|
if(indexHtml){
|
|
375
385
|
const shareJs = jsSplitMode?['react-bundle', 'modules-bundle', 'default-bundle', 'styles-bundle','kn-hooks']:[];
|
|
376
386
|
if(jsSplitMode===true || jsSplitMode?.runtime !== false){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kn-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.71",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,12 +32,13 @@
|
|
|
32
32
|
"execa": "~5.1.1",
|
|
33
33
|
"inquirer": "~6.5.2",
|
|
34
34
|
"jsonfile": "~6.1.0",
|
|
35
|
-
"listr2": "~5.0.6",
|
|
36
35
|
"lodash": "~4.17.21",
|
|
37
36
|
"ncp": "~2.0.0",
|
|
38
|
-
"shelljs": "~0.8.5"
|
|
37
|
+
"shelljs": "~0.8.5",
|
|
38
|
+
"listr2": "~6.6.0"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": "16.18.0"
|
|
42
|
-
}
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {}
|
|
43
44
|
}
|
package/readme.md
CHANGED
|
@@ -79,6 +79,9 @@ module.exports = {
|
|
|
79
79
|
// port:8080,
|
|
80
80
|
// useLocalIp:false,//是否使用本地IP地址代替localhost
|
|
81
81
|
// }
|
|
82
|
+
// sourcemap:{
|
|
83
|
+
// local:true //将生产环境的sourcemap部署到生产本地
|
|
84
|
+
// }
|
|
82
85
|
};
|
|
83
86
|
```
|
|
84
87
|
|
|
@@ -92,6 +95,13 @@ module.exports = {
|
|
|
92
95
|
|
|
93
96
|
|
|
94
97
|
# 更新日志
|
|
98
|
+
|
|
99
|
+
* 1.0.71
|
|
100
|
+
增加运行日志中,每个任务的消耗时间
|
|
101
|
+
|
|
102
|
+
* 1.0.70
|
|
103
|
+
cli.config增加sourcemap{local:true}的可选配置,用来将sourcemap部署到生产本地
|
|
104
|
+
|
|
95
105
|
* 1.0.69
|
|
96
106
|
默认生产环境不输出sourcemap
|
|
97
107
|
|
package/src/build.js
CHANGED
|
@@ -2,7 +2,8 @@ const chalk= require("chalk");
|
|
|
2
2
|
// 用于递归复制文件
|
|
3
3
|
const path= require("path");
|
|
4
4
|
const fs = require('fs');
|
|
5
|
-
const {Listr} = require('listr2');
|
|
5
|
+
const {Listr,PRESET_TIMER,color,delay} = require('listr2');
|
|
6
|
+
|
|
6
7
|
const shelljs = require('shelljs');
|
|
7
8
|
const jsonfile = require('jsonfile')
|
|
8
9
|
const {copyDir,TaskNodeVersion,replaceFileData,cleanDir}= require( './utils');
|
|
@@ -93,7 +94,7 @@ module.exports= async (options={})=> {
|
|
|
93
94
|
try{
|
|
94
95
|
const exists = fs.existsSync(tempWebpackDir);
|
|
95
96
|
if(exists==false){
|
|
96
|
-
task.title=`创建临时缓存文件夹成功${tempWebpackDir}`;
|
|
97
|
+
// task.title=`创建临时缓存文件夹成功${tempWebpackDir}`;
|
|
97
98
|
shelljs.mkdir(tempDir);
|
|
98
99
|
shelljs.mkdir(tempProjectDir);
|
|
99
100
|
if(answer){
|
|
@@ -107,7 +108,7 @@ module.exports= async (options={})=> {
|
|
|
107
108
|
answer.install='需要';
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
|
-
task.title='清理旧的缓存文件';
|
|
111
|
+
// task.title='清理旧的缓存文件';
|
|
111
112
|
// 保留node_modules,以提高编译效率
|
|
112
113
|
await cleanDir(tempWebpackDir+'/',{
|
|
113
114
|
exclude:function(file){
|
|
@@ -121,9 +122,9 @@ module.exports= async (options={})=> {
|
|
|
121
122
|
}
|
|
122
123
|
});
|
|
123
124
|
if(logCount){
|
|
124
|
-
task.output=`清除文件:${logCount}`;
|
|
125
|
+
// task.output=`清除文件:${logCount}`;
|
|
125
126
|
}
|
|
126
|
-
task.title=`清理缓存完毕${tempWebpackDir}`;
|
|
127
|
+
// task.title=`清理缓存完毕${tempWebpackDir}`;
|
|
127
128
|
}catch(err){
|
|
128
129
|
task.output=err.message;
|
|
129
130
|
}
|
|
@@ -132,10 +133,11 @@ module.exports= async (options={})=> {
|
|
|
132
133
|
},
|
|
133
134
|
{
|
|
134
135
|
title:"缓冲",
|
|
135
|
-
task:(ctx,task)=>{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
task:async (ctx,task)=>{
|
|
137
|
+
await delay(500)
|
|
138
|
+
// return new Promise(resolve=>{
|
|
139
|
+
// setTimeout(resolve,500);
|
|
140
|
+
// })
|
|
139
141
|
}
|
|
140
142
|
},
|
|
141
143
|
{
|
|
@@ -148,15 +150,13 @@ module.exports= async (options={})=> {
|
|
|
148
150
|
},
|
|
149
151
|
{
|
|
150
152
|
title:"缓冲",
|
|
151
|
-
task:(ctx,task)=>{
|
|
152
|
-
|
|
153
|
-
setTimeout(resolve,500);
|
|
154
|
-
})
|
|
153
|
+
task:async (ctx,task)=>{
|
|
154
|
+
await delay(500)
|
|
155
155
|
}
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
158
|
title:"构造package",
|
|
159
|
-
task:(ctx,task)=>{
|
|
159
|
+
task:async (ctx,task)=>{
|
|
160
160
|
return new Promise(resolve=>{
|
|
161
161
|
try{
|
|
162
162
|
task.title='开始构造package'
|
|
@@ -181,11 +181,11 @@ module.exports= async (options={})=> {
|
|
|
181
181
|
}
|
|
182
182
|
})
|
|
183
183
|
|
|
184
|
-
}
|
|
184
|
+
},options: { persistentOutput: true }
|
|
185
185
|
},
|
|
186
186
|
{
|
|
187
187
|
title:"构造cli配置",
|
|
188
|
-
task:(ctx,task)=>{
|
|
188
|
+
task:async (ctx,task)=>{
|
|
189
189
|
return new Promise(resolve=>{
|
|
190
190
|
if(!existsCli){
|
|
191
191
|
task.output='没有找到cli.config.js'
|
|
@@ -210,11 +210,11 @@ module.exports= async (options={})=> {
|
|
|
210
210
|
`);
|
|
211
211
|
}
|
|
212
212
|
})
|
|
213
|
-
}
|
|
213
|
+
},options: { persistentOutput: true }
|
|
214
214
|
},
|
|
215
215
|
{
|
|
216
216
|
title:"构造api配置",
|
|
217
|
-
task:()=>{
|
|
217
|
+
task:async ()=>{
|
|
218
218
|
return new Promise(resolve=>{
|
|
219
219
|
// 将项目目录下的webpack.api.js替换到临时构造文件夹下
|
|
220
220
|
try{
|
|
@@ -234,11 +234,11 @@ module.exports= async (options={})=> {
|
|
|
234
234
|
`);
|
|
235
235
|
}
|
|
236
236
|
})
|
|
237
|
-
}
|
|
237
|
+
},options: { persistentOutput: true }
|
|
238
238
|
},
|
|
239
239
|
{
|
|
240
240
|
title:"构造config",
|
|
241
|
-
task:(ctx,task)=>{
|
|
241
|
+
task:async (ctx,task)=>{
|
|
242
242
|
return new Promise(async resolve=>{
|
|
243
243
|
let sourceFolder=sourceDir;
|
|
244
244
|
// 开始改写 _webpack/webpack.config.js 和 build.sh
|
|
@@ -267,11 +267,11 @@ module.exports= async (options={})=> {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
})
|
|
270
|
-
}
|
|
270
|
+
},options: { persistentOutput: true }
|
|
271
271
|
},
|
|
272
272
|
{
|
|
273
273
|
title:"执行build",
|
|
274
|
-
task:(ctx,task)=>{
|
|
274
|
+
task:async (ctx,task)=>{
|
|
275
275
|
return new Promise(resolve=>{
|
|
276
276
|
shelljs.cd(tempWebpackDir);
|
|
277
277
|
let cmdParams = [];
|
|
@@ -324,6 +324,7 @@ module.exports= async (options={})=> {
|
|
|
324
324
|
shelljs.exec(`echo ${cmd}>>env.sh`);
|
|
325
325
|
cmd='sh ./env.sh'
|
|
326
326
|
task.title=`执行:${cmd}`;
|
|
327
|
+
task.output=`执行:${cmd}`;
|
|
327
328
|
let req = shelljs.exec(cmd)
|
|
328
329
|
if(req.code==0){
|
|
329
330
|
resolve();
|
|
@@ -339,9 +340,25 @@ module.exports= async (options={})=> {
|
|
|
339
340
|
`);
|
|
340
341
|
}
|
|
341
342
|
})
|
|
343
|
+
},options: { persistentOutput: true }
|
|
344
|
+
}
|
|
345
|
+
],
|
|
346
|
+
{
|
|
347
|
+
concurrent: false,
|
|
348
|
+
rendererOptions: {
|
|
349
|
+
timer: {
|
|
350
|
+
...PRESET_TIMER,
|
|
351
|
+
// condition: (duration)=>duration > 5000,
|
|
352
|
+
format: (duration)=> {
|
|
353
|
+
if (duration > 10000) {
|
|
354
|
+
return color.red
|
|
355
|
+
}
|
|
356
|
+
return color.green
|
|
357
|
+
}
|
|
342
358
|
}
|
|
343
359
|
}
|
|
344
|
-
|
|
360
|
+
}
|
|
361
|
+
);
|
|
345
362
|
|
|
346
363
|
try{
|
|
347
364
|
await tasks.run();
|