cloudcc-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/README.md +17 -1
- package/bin/buildtag.js +1 -1
- package/bin/createPlugin.js +7 -0
- package/bin/publishh5.js +1 -1
- package/package.json +2 -1
- package/src/builderCreate.js +86 -0
- package/src/builderPlugin.js +0 -16
- package/src/creatorTemProject.js +5 -5
- package/template/packagejson +5 -3
- package/utils/checkVersion.js +8 -8
package/README.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
+
# ReleaseV1.5.2
|
|
2
|
+
#### 发布日期:2023-10-17
|
|
3
|
+
#### 发布范围:全量
|
|
4
|
+
#### 发布内容
|
|
5
|
+
* 迭代
|
|
6
|
+
* 创建模板项目去掉安装依赖和打开vs code操作
|
|
7
|
+
* 更改获取版本号的源地址,使用阿里源获取版本信息
|
|
8
|
+
|
|
9
|
+
# ReleaseV1.5.1
|
|
10
|
+
#### 发布日期:2023-09-20
|
|
11
|
+
#### 发布范围:全量
|
|
12
|
+
#### 发布内容
|
|
13
|
+
* 迭代
|
|
14
|
+
* 添加cloudccCreatePlugin创建模板文件命令
|
|
15
|
+
|
|
16
|
+
|
|
1
17
|
# ReleaseV1.5.0
|
|
2
|
-
#### 发布日期:
|
|
18
|
+
#### 发布日期:2023-09-19
|
|
3
19
|
#### 发布范围:全量
|
|
4
20
|
#### 发布内容
|
|
5
21
|
* 迭代
|
package/bin/buildtag.js
CHANGED
package/bin/publishh5.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcc-cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "cloudcc-cli",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudcc",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"bin": {
|
|
13
13
|
"cloudccCreate": "bin/create.js",
|
|
14
14
|
"cloudccBuild": "bin/build.js",
|
|
15
|
+
"cloudccCreatePlugin": "bin/createPlugin.js",
|
|
15
16
|
"cloudccPublic": "bin/publish.js",
|
|
16
17
|
"cloudccPublicH5": "bin/publishh5.js",
|
|
17
18
|
"cloudccBuildCCSDK": "bin/buildccsdk.js",
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
const { post } = require('../utils/http');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require("path")
|
|
5
|
+
const chalk = require("chalk")
|
|
6
|
+
const inquirer = require("inquirer")
|
|
7
|
+
// 检查cli版本更新功能
|
|
8
|
+
const { checkUpdate } = require("../utils/checkVersion")
|
|
9
|
+
const BaseUrl = "https://developer.apis.cloudcc.cn"
|
|
10
|
+
const axios = require("axios")
|
|
11
|
+
const temp = `<template>
|
|
12
|
+
<div class="cc-container">
|
|
13
|
+
<div>Hello CloudCC</div>
|
|
14
|
+
<div>
|
|
15
|
+
<a href="https://cloudccone.feishu.cn/wiki/JZ7CwcRfriU8taknCKCcwKEmncd">
|
|
16
|
+
开发者文档</a
|
|
17
|
+
>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
export default {
|
|
24
|
+
data() {
|
|
25
|
+
return {
|
|
26
|
+
componentInfo: {
|
|
27
|
+
// 组件唯一标识,全局唯一
|
|
28
|
+
component: "cloudcc-demo-01",
|
|
29
|
+
// 组件名称,在页面编辑器显示的名字
|
|
30
|
+
compName: "cloudcc-demo-01",
|
|
31
|
+
// 组件描述信息
|
|
32
|
+
compDesc: "组件描述信息",
|
|
33
|
+
},
|
|
34
|
+
isLock: false,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
</script>
|
|
39
|
+
<style lang="scss" scoped>
|
|
40
|
+
.cc-container {
|
|
41
|
+
text-align: center;
|
|
42
|
+
padding: 8px;
|
|
43
|
+
background: goldenrod;
|
|
44
|
+
}
|
|
45
|
+
</style>`
|
|
46
|
+
/**
|
|
47
|
+
* 创建组件模板文件
|
|
48
|
+
*/
|
|
49
|
+
class Builder {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.options = {
|
|
52
|
+
// 开发配置信息
|
|
53
|
+
devConsoleConfig: {
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
this.plugin = process.argv.splice(2)[0]
|
|
57
|
+
}
|
|
58
|
+
async init() {
|
|
59
|
+
let res = await checkUpdate();
|
|
60
|
+
if (!res) {
|
|
61
|
+
// 获得用户输入
|
|
62
|
+
let answers;
|
|
63
|
+
if (this.plugin) {
|
|
64
|
+
answers = { buildFileName: this.plugin + "/demo.vue" }
|
|
65
|
+
} else {
|
|
66
|
+
answers = await this.ask();
|
|
67
|
+
answers.buildFileName = "./plugin/" + answers.buildFileName
|
|
68
|
+
}
|
|
69
|
+
fs.writeFileSync(answers.buildFileName, temp);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 命令行交互
|
|
74
|
+
* @returns 结果
|
|
75
|
+
*/
|
|
76
|
+
ask() {
|
|
77
|
+
const prompt = [];
|
|
78
|
+
prompt.push({
|
|
79
|
+
type: "input",
|
|
80
|
+
name: "buildFileName",
|
|
81
|
+
message: "请输入文件名,如index.vue",
|
|
82
|
+
})
|
|
83
|
+
return inquirer.prompt(prompt)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
module.exports = Builder;
|
package/src/builderPlugin.js
CHANGED
|
@@ -26,7 +26,6 @@ class Builder {
|
|
|
26
26
|
if (!res) {
|
|
27
27
|
this.options.devConsoleConfig = this.getPackageJson();
|
|
28
28
|
let config = this.options.devConsoleConfig
|
|
29
|
-
// await this.getSecretKey(config.username)
|
|
30
29
|
// 如果不是私有化部署,那么需要获取token
|
|
31
30
|
if ("private" != this.options.devConsoleConfig.version) { // private私有化
|
|
32
31
|
config = { "accessToken": await this.getToken(config) };
|
|
@@ -75,21 +74,6 @@ class Builder {
|
|
|
75
74
|
const packageJson = JSON.parse(fs.readFileSync("package.json", 'utf8'));
|
|
76
75
|
return packageJson.devConsoleConfig; // cloudcc-plugin 中的 devConsoleConfig
|
|
77
76
|
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* 通过用户名获取密钥
|
|
81
|
-
* @param {string} username 用户名
|
|
82
|
-
*/
|
|
83
|
-
async getSecretKey(username) {
|
|
84
|
-
let res = await axios.post(this.options.devConsoleConfig.baseUrl || BaseUrl + "/sysconfig/auth/secretkey/get", { username }, {
|
|
85
|
-
timeout: 60000,
|
|
86
|
-
headers: {
|
|
87
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
88
|
-
},
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
console.log("res", JSON.stringify(res))
|
|
92
|
-
}
|
|
93
77
|
/**
|
|
94
78
|
* 请求用户token
|
|
95
79
|
* @param {用户信息} devConsoleConfig
|
package/src/creatorTemProject.js
CHANGED
|
@@ -68,12 +68,12 @@ class Creator {
|
|
|
68
68
|
console.log(chalk.green("开始构建,请稍后"));
|
|
69
69
|
const tplBuilder = require("../template/index");
|
|
70
70
|
tplBuilder(this, this.options, () => {
|
|
71
|
+
// console.log();
|
|
72
|
+
// console.log(chalk.green('安装依赖'));
|
|
73
|
+
// let os = process.platform
|
|
74
|
+
// exec(`cd ${this.options.name} && ${'darwin' == os ? 'sudo' : ''} npm install --registry http://registry.npmmirror.com && code . `)
|
|
71
75
|
console.log();
|
|
72
|
-
console.log(chalk.green('
|
|
73
|
-
let os = process.platform
|
|
74
|
-
exec(`cd ${this.options.name} && ${'darwin' == os ? 'sudo' : ''} npm install --registry http://registry.npmmirror.com && code . `)
|
|
75
|
-
console.log();
|
|
76
|
-
console.log(chalk.green('构建完成'))
|
|
76
|
+
console.log(chalk.green('构建完成,运行前请安装依赖'))
|
|
77
77
|
})
|
|
78
78
|
}
|
|
79
79
|
|
package/template/packagejson
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"description": "cloudcc-plugin-dev",
|
|
5
5
|
"devConsoleConfig": {
|
|
6
|
-
"username": "
|
|
7
|
-
"secretKey": "
|
|
6
|
+
"username": "xxx",
|
|
7
|
+
"secretKey": "xxxxx"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"serve": "vue-cli-service serve"
|
|
10
|
+
"serve": "vue-cli-service serve",
|
|
11
|
+
"build-plugin": "cloudccBuild",
|
|
12
|
+
"build-create-plugin": "cloudccCreatePlugin"
|
|
11
13
|
},
|
|
12
14
|
"dependencies": {
|
|
13
15
|
"element-ui": "2.15.12",
|
package/utils/checkVersion.js
CHANGED
|
@@ -12,16 +12,16 @@ function checkNpmVersion() {
|
|
|
12
12
|
let onlineVersionNum
|
|
13
13
|
let onlineVersion = '0.0.1'
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
// 从阿里源获取版本号
|
|
16
|
+
onlineVersion = exec(`npm view cloudcc-cli version --registry http://registry.npmmirror.com`)
|
|
17
|
+
onlineVersion = onlineVersion.toString("utf8").trim();
|
|
18
18
|
|
|
19
19
|
// 从阿里源获取版本号
|
|
20
|
-
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} catch (e) {
|
|
24
|
-
}
|
|
20
|
+
// try {
|
|
21
|
+
// onlineVersion = exec(`curl -s https://npmmirror.com/api/info?pkgName=cloudcc-cli`)
|
|
22
|
+
// onlineVersion = JSON.parse(onlineVersion.toString("utf8").trim()).data['dist-tags'].latest
|
|
23
|
+
// } catch (e) {
|
|
24
|
+
// }
|
|
25
25
|
onlineVersionNum = Number(onlineVersion.replace(/\./g, ""));
|
|
26
26
|
|
|
27
27
|
console.log(chalk.green(
|