kn-cli 1.0.9 → 1.0.11

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/report.sh CHANGED
@@ -3,43 +3,57 @@ then
3
3
  . ${HOME}/.nvm/nvm.sh
4
4
  fi
5
5
 
6
- export build_env=prod
7
- export mock=0
6
+ node_version="v16.18.0"
7
+ checkResult(){
8
+ ret=$?
9
+ if [ $ret != 0 ]
10
+ then
11
+ echo "[$1]执行失败"
12
+ exit 2
13
+ return 0
14
+ else
15
+ echo "[$1]执行成功"
16
+ return 0
17
+ fi
18
+ }
19
+
8
20
 
9
21
  checkNode(){
10
22
  for line in `node -v`
11
23
  do
12
- if [ $line != "v10.15.0" ]
24
+ if [ $line != $node_version ]
13
25
  then
14
- nvm use v10.15.0
26
+ echo "change Node from $line to $node_version"
27
+ nvm use $node_version
15
28
  ret=$?
16
29
  if [ $ret != 0 ]
17
30
  then
18
- echo -e "\033[41;37m Change Node to v10.15.0 (try nvm use v10.15.0)\033[0m"
19
- return 0
31
+ echo "Please run nvm install $node_version"
32
+ exit 3
20
33
  else
21
- return 1
34
+ return 0
22
35
  fi
23
36
  else
24
- return 1
37
+ return 0
25
38
  fi
26
39
  done
27
40
  }
28
41
 
42
+ export build_env=prod
43
+ export mock=0
44
+ export noSkipNpmInstall=1
45
+
29
46
  dev(){
30
- npm config set sass_binary_site http://npm.taobao.org/mirrors/node-sass -g
31
47
  npm config delete registry -g
32
48
  npm config delete registry
33
-
34
49
  npm install
50
+ checkResult "npm install"
35
51
  npm run report
36
52
  }
37
53
 
38
54
  checkNode
39
- ret=$?
40
- if [ $ret = 1 ]
41
- then
42
- dev
43
- fi
55
+ checkResult "检查node"
44
56
 
57
+ dev
58
+ checkResult "report"
45
59
 
@@ -37,13 +37,11 @@ if (process.env.npm_config_report) {
37
37
  const dirname = __dirname;
38
38
  const webpackPath=__webpackPath;
39
39
  console.log(`=====================env=========================`);
40
- console.log(`__dirname:${__dirname}`);
41
40
  console.log(`dirname:${dirname}`);
42
41
  console.log(`webpackPath:${webpackPath}`);
43
42
  console.log(`build_env:${process.env.build_env}`);
44
43
  console.log(`mock:${process.env.mock}`);
45
44
  console.log(`noSkipNpmInstall:${process.env.noSkipNpmInstall}`);
46
-
47
45
  console.log(`=====================env end=========================`);
48
46
  const devMode = process.env.build_env !== 'prod';
49
47
  const hashMode = process.env.build_env != 'localdebug';
@@ -76,6 +74,14 @@ module.exports = {
76
74
  contentBase: "dist",
77
75
  host: '0.0.0.0',
78
76
  open: true,
77
+ overlay:true,
78
+ stats:{
79
+ all: false,
80
+ colors:true,
81
+ errors:true,
82
+ errorDetails:true,
83
+ warnings:true
84
+ },
79
85
  // port: 8080,
80
86
  // useLocalIp:true,
81
87
  // https:true,//注意开了https就不能使用本地ip访问,只能使用0.0.0.0
@@ -320,8 +326,8 @@ module.exports = {
320
326
  ...otherPlugins,
321
327
  new CopyPlugin({
322
328
  patterns: [
323
- { from: dirname + '/static', to: dirname + '/dist/static' },
324
- { from: dirname + '/pluginjs', to: dirname + '/dist/pluginjs' }
329
+ { from: dirname + '/static', to: dirname + '/dist/static' ,noErrorOnMissing:true},
330
+ { from: dirname + '/pluginjs', to: dirname + '/dist/pluginjs',noErrorOnMissing:true }
325
331
  ],
326
332
  }),
327
333
  new webpack.SourceMapDevToolPlugin({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kn-cli",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -6,7 +6,8 @@
6
6
  2. 创建项目: kn-cli --create
7
7
  3. 调试项目: kn-cli --dev
8
8
  4. 编译项目: kn-cli --build
9
- 5. 当项目中需要添加第三方npm包时,务必使用--save参数`npm i 包名 --save`
9
+ 5. 当项目中需要添加第三方npm包时,务必使用--save参数`npm i 包名 --save`
10
+ 6. 包模块分析: kn-cli --report
10
11
 
11
12
 
12
13
  > 项目创建后,记得执行sh init.sh 以激活git分支提交日志
@@ -16,6 +17,10 @@
16
17
 
17
18
 
18
19
  # 更新日志
20
+ * 1.0.10
21
+ 1. 增加 `kn-cli --report`对包的模块化进行报告输出
22
+ 2. 对 `statics`和`pluginjs`文件夹不存在或内部没有文件的情况下会编译报错进行了修复,现在不会再导致编译失败了
23
+
19
24
 
20
25
  * 1.0.9
21
26
  1. 移动端模板内增加build.sh用于测试环境打包用
package/src/build.js CHANGED
@@ -220,6 +220,9 @@ module.exports= async (options={})=> {
220
220
  }
221
221
  cmd = `export build_env=${build_env} mock=${mock} noSkipNpmInstall=${noSkipNpmInstall}\nsh dev.sh`;
222
222
  task.title=`调试环境:env=${answer.type},mock=${answer.mock},install=${answer.install}`
223
+ }else if( type =='report'){
224
+ task.title='执行report';
225
+ cmd='sh report.sh';
223
226
  }
224
227
  let req = shelljs.exec(cmd)
225
228
  if(req.code==0){
package/src/cli.js CHANGED
@@ -41,5 +41,12 @@ module.exports=async (args)=> {
41
41
  }
42
42
  return 1;
43
43
  }
44
+ else if(get(options,"report")){
45
+ const req = await build({type:'report'});
46
+ if(!req){
47
+ process.exit(2);
48
+ }
49
+ return 1;
50
+ }
44
51
 
45
52
  }
@@ -9,6 +9,7 @@ module.exports=function(rawArgs) {
9
9
  "--create": Boolean,
10
10
  "--version": Boolean,
11
11
  "--test": Boolean,
12
+ "--report":Boolean,
12
13
  "-v": "--version",//-v 转译成 --version
13
14
  },
14
15
  {
@@ -25,5 +26,6 @@ module.exports=function(rawArgs) {
25
26
  install: get(args, "--create", false),
26
27
  version: get(args, "--version", false),
27
28
  test: get(args, "--test", false),
29
+ report: get(args, "--report", false),
28
30
  };
29
31
  }
@@ -9,6 +9,9 @@ sh dev.sh
9
9
  ### 安装新的库
10
10
  npm i 库名称 --save
11
11
 
12
+ ### 模块构建报告
13
+ sh report.sh
14
+
12
15
  ### 测试环境部署
13
16
  1. sh build.sh
14
17
 
@@ -0,0 +1,68 @@
1
+ if [ -d "${HOME}/.nvm/" ]
2
+ then
3
+ . ${HOME}/.nvm/nvm.sh
4
+ fi
5
+
6
+ node_version="v16.18.0"
7
+
8
+ checkNode(){
9
+ for line in `node -v`
10
+ do
11
+ if [ $line != $node_version ]
12
+ then
13
+ echo "change Node from $line to $node_version"
14
+ nvm use $node_version
15
+ ret=$?
16
+ if [ $ret != 0 ]
17
+ then
18
+ echo "Please run nvm install $node_version"
19
+ exit 3
20
+ else
21
+ return 0
22
+ fi
23
+ else
24
+ return 0
25
+ fi
26
+ done
27
+ }
28
+
29
+ checkResult(){
30
+ ret=$?
31
+ if [ $ret != 0 ]
32
+ then
33
+ echo "[$1]执行失败"
34
+ exit 2
35
+ return 0
36
+ else
37
+ echo "[$1]执行成功"
38
+ return 0
39
+ fi
40
+ }
41
+
42
+
43
+ checkKnCli(){
44
+ if ! [ -x "$(command -v kn-cli)" ]
45
+ then
46
+ npm i kn-cli -g
47
+ return 0
48
+ fi
49
+ return 0
50
+ }
51
+
52
+
53
+ build(){
54
+ npm config delete registry -g
55
+ npm config delete registry
56
+
57
+ checkKnCli
58
+ checkResult "检查kn-cli"
59
+
60
+ kn-cli --report
61
+ checkResult "kn-cli --report"
62
+ }
63
+
64
+ checkNode
65
+ checkResult "检查node"
66
+
67
+ build
68
+ checkResult "build"