kn-cli 1.0.70 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kn-cli",
3
- "version": "1.0.70",
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
@@ -96,6 +96,9 @@ module.exports = {
96
96
 
97
97
  # 更新日志
98
98
 
99
+ * 1.0.71
100
+ 增加运行日志中,每个任务的消耗时间
101
+
99
102
  * 1.0.70
100
103
  cli.config增加sourcemap{local:true}的可选配置,用来将sourcemap部署到生产本地
101
104
 
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
- return new Promise(resolve=>{
137
- setTimeout(resolve,500);
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
- return new Promise(resolve=>{
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();
@@ -1,6 +0,0 @@
1
- **/node_modules
2
- **/package-lock.json
3
- **/.DS_Store
4
- **/dist
5
- **/release
6
-
@@ -1,6 +0,0 @@
1
- **/node_modules
2
- **/package-lock.json
3
- **/.DS_Store
4
- **/dist
5
- **/release
6
-
@@ -1,6 +0,0 @@
1
- **/node_modules
2
- **/package-lock.json
3
- **/.DS_Store
4
- **/dist
5
- **/release
6
-
@@ -1,6 +0,0 @@
1
- **/node_modules
2
- **/package-lock.json
3
- **/.DS_Store
4
- **/dist
5
- **/release
6
-
@@ -1,6 +0,0 @@
1
- **/node_modules
2
- **/package-lock.json
3
- **/.DS_Store
4
- **/dist
5
- **/release
6
-