cloudcc-cli 1.2.1 → 1.2.3

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": "cloudcc-cli",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "cloudcc-cli",
5
5
  "keywords": [
6
6
  "cloudcc",
@@ -19,7 +19,8 @@
19
19
  "cloudccBuildTag": "bin/buildtag.js"
20
20
  },
21
21
  "scripts": {
22
- "publish-lib": "npm publish --registry https://registry.npmjs.org"
22
+ "cc-pull": "git fetch --tags -f && git pull",
23
+ "publish-lib": "npm publish --registry https://registry.npmjs.org && curl https://npmmirror.com/sync/cloudcc-cli"
23
24
  },
24
25
  "dependencies": {
25
26
  "axios": "^0.21.4",
@@ -1,4 +1,4 @@
1
- const { execSync } = require('child_process');
1
+ const { exec, execSync, spawn, spawnSync } = require('child_process');
2
2
  const { post } = require('../utils/http');
3
3
  const fs = require('fs');
4
4
  const path = require("path")
@@ -35,14 +35,12 @@ class Builder {
35
35
  let item = dirs[i]
36
36
  let obj = this.getVueValue(item);
37
37
  this.initPluginFile(item, obj.compName);
38
- this.build(obj);
39
- await this.upload(obj, config)
38
+ this.build(obj, config)
40
39
  }
41
40
  } else {
42
41
  let obj = this.getVueValue(answers.buildFileName);
43
42
  this.initPluginFile(answers.buildFileName, obj.compName);
44
- this.build(obj);
45
- await this.upload(obj, config)
43
+ this.build(obj, config)
46
44
  }
47
45
  }
48
46
  }
@@ -127,15 +125,20 @@ class Builder {
127
125
  * 编译文件,将vue编译为js文件
128
126
  * @param {编译对象信息} obj
129
127
  */
130
- build(obj) {
128
+ build(obj, config) {
131
129
  console.log(chalk.green('编译中,请稍后...'));
132
- let { stdout, stderr, error } = execSync('npx vue-cli-service build --target lib --name ' + obj.compName + ' --dest build plugin/plugin.js');
133
- if (null == error) {
134
- console.log(chalk.green('编译成功!'));
135
- } else {
136
- console.log(chalk.red('编译失败:', error));
137
- }
138
- fs.unlinkSync('plugin/plugin.js');
130
+ exec('npx vue-cli-service build --target lib --name ' + obj.compName + ' --dest build plugin/plugin.js', async (error, stdout, stderr) => {
131
+ if (error) {
132
+ console.log('编译失败:', error);
133
+ console.log(chalk.red('编译失败:' + stdout));
134
+ return;
135
+ } else {
136
+ console.log(chalk.green('编译成功!'));
137
+ console.log();
138
+ await this.upload(obj, config)
139
+ fs.unlinkSync('plugin/plugin.js');
140
+ }
141
+ })
139
142
  }
140
143
  /**
141
144
  * 将文件上传
@@ -48,9 +48,7 @@ class Publish {
48
48
  */
49
49
  async init() {
50
50
  // 检查cli版本,提示用户更新:false:不更新,true:更新
51
- // let update = false
52
- let update = false;
53
- // let update = await checkUpdate();
51
+ let update = await checkUpdate();
54
52
  if (!update) {
55
53
  // 1:版本发布信息,包含发布版本类型信息
56
54
  let condition = {};
@@ -97,13 +95,14 @@ class Publish {
97
95
 
98
96
  // 4:如果存在多语言配置,则更新多语言
99
97
  if (projectConfig.config && projectConfig.config["language-config"]) {
98
+ // 获得命令行多语言参数
100
99
  let i18n = this.args.get("language")
101
- // 如果不存在language那么需要询问是否需要发布版本
100
+ // 如果存在命令行参数,那么获取,否则询问
102
101
  if (!i18n) {
103
- // 询问是否更新多语言
104
102
  i18n = await askI18n()
105
103
  }
106
- if (i18n.checked === '1') {
104
+ // 如果选择为1,那么下载多语言
105
+ if ('1' === i18n || '1' === i18n.checked) {
107
106
  let laguage = projectConfig.config["language-config"]
108
107
  // 执行更新多语言文件
109
108
  await updatei18n(laguage)
@@ -44,7 +44,6 @@ class Publish {
44
44
  */
45
45
  async init() {
46
46
  // 检查cli版本,提示用户更新:false:不更新,true:更新
47
- // let update = false
48
47
  let update = await checkUpdate();
49
48
  if (!update) {
50
49
  // 1:版本发布信息,包含发布版本类型信息
package/template/indexvue CHANGED
@@ -36,7 +36,6 @@ export default {
36
36
  bizType: "基础组件",
37
37
  compDesc: "常用的操作按钮。",
38
38
  /* 组件分类:
39
- * public: 公开组件(其他组织可见)
40
39
  * private:私有组件(自己组织可见)
41
40
  * beta:组件测试版本
42
41
  */
@@ -8,9 +8,20 @@ const chalk = require("chalk")
8
8
  */
9
9
  function checkNpmVersion() {
10
10
  let currentVersion = Number(config.version.replace(/\./g, ""));
11
- let onlineVersion = exec(`npm view cloudcc-cli version --registry http://registry.npmjs.org`)
12
- onlineVersion = onlineVersion.toString("utf8").trim();
13
- let onlineVersionNum = Number(onlineVersion.replace(/\./g, ""))
11
+ let onlineVersionNum
12
+ let onlineVersion = '0.0.1'
13
+
14
+ // 从npm官网获取版本号
15
+ // onlineVersion = exec(`npm view cloudcc-cli version --registry http://registry.npmjs.org`)
16
+ // onlineVersion = onlineVersion.toString("utf8").trim();
17
+
18
+ // 从阿里源获取版本号
19
+ try {
20
+ onlineVersion = exec(`curl -s http://www.npmmirror.com/package/cloudcc-cli`)
21
+ onlineVersion = onlineVersion.toString("utf8").trim().split('img title="')[1].split('" src')[0];
22
+ } catch (e) {
23
+ }
24
+ onlineVersionNum = Number(onlineVersion.replace(/\./g, ""));
14
25
  // 如果结果大于0,那么提示升级
15
26
  if (onlineVersionNum - currentVersion > 0) {
16
27
  console.log();
@@ -19,7 +30,7 @@ function checkNpmVersion() {
19
30
  console.log(chalk.green("当前版本:v" + config.version));
20
31
  console.log(chalk.green("最新版本:v" + onlineVersion));
21
32
  console.log();
22
- console.log(chalk.yellow(`如无法自动更新,请使用命令更新:npm install -g cloudcc-cli@${onlineVersion} --registry https://registry.npmjs.org`));
33
+ console.log(chalk.yellow(`如无法自动更新,请使用命令更新:npm install -g cloudcc-cli@${onlineVersion} --registry http://registry.npmmirror.com`));
23
34
  return onlineVersion;
24
35
  }
25
36
  return null;
package/utils/test.js CHANGED
@@ -1,4 +1,2 @@
1
- version = "Release-V12.3.2"
2
- version = version.split("\n")[0]
3
- version = version.split("-V")[1]
4
- console.log("Release-V12.3.2",version);
1
+ const fs = require('fs')
2
+ const exec = require('child_process').execSync;