cloudcc-cli 1.6.0 → 1.6.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 +1147 -1128
- package/bin/cc.js +48 -48
- package/bin/plugin.js +5 -5
- package/bin/project.js +5 -5
- package/package.json +34 -34
- package/src/classes/create.js +43 -43
- package/src/classes/index.js +8 -8
- package/src/classes/publish.js +48 -47
- package/src/config/get.js +22 -0
- package/src/config/index.js +8 -0
- package/src/config/use.js +16 -0
- package/src/object/get.js +16 -0
- package/src/object/index.js +7 -0
- package/src/plugin/create.js +80 -80
- package/src/plugin/create1.js +66 -67
- package/src/plugin/index.js +8 -8
- package/src/plugin/publish.js +298 -305
- package/src/plugin/publish1.js +286 -293
- package/src/project/create.js +89 -89
- package/src/project/create1.js +111 -94
- package/src/project/index.js +7 -7
- package/src/recordType/get.js +16 -0
- package/src/recordType/index.js +7 -0
- package/src/script/create.js +33 -0
- package/src/script/index.js +8 -0
- package/src/script/publish.js +69 -0
- package/src/timer/create.js +29 -29
- package/src/timer/index.js +8 -8
- package/src/timer/publish.js +47 -47
- package/src/token/get.js +13 -0
- package/src/token/index.js +7 -0
- package/src/triggers/create.js +35 -35
- package/src/triggers/index.js +8 -8
- package/src/triggers/publish.js +51 -51
- package/template/Appvue +29 -29
- package/template/babelconfigjs +5 -5
- package/template/cloudcc-cli.configjs +1 -0
- package/template/demojava +14 -14
- package/template/gitignore +11 -0
- package/template/index.js +57 -52
- package/template/indexhtml +21 -21
- package/template/indexvue +34 -34
- package/template/javaconfigjson +2 -2
- package/template/mainjs +13 -13
- package/template/package-lockjson +12115 -12115
- package/template/packagejson +42 -46
- package/template/vueconfigjs +26 -26
- package/utils/checkVersion.js +105 -105
- package/utils/http.js +122 -122
- package/utils/utils.js +54 -44
package/bin/cc.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const chalk = require("chalk")
|
|
3
|
-
|
|
4
|
-
let argvs = process.argv.splice(2);
|
|
5
|
-
// 动作
|
|
6
|
-
let action = argvs[0]
|
|
7
|
-
if (!action) {
|
|
8
|
-
console.log()
|
|
9
|
-
console.log(chalk.yellow("请查看帮助文档:https://cloudccone.feishu.cn/wiki/Q2AgwlxAtijmMJkjXXZcYgQVnmw?fromScene=spaceOverview"));
|
|
10
|
-
console.log()
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// 类型
|
|
15
|
-
let type = argvs[1]
|
|
16
|
-
if (!type) {
|
|
17
|
-
console.log()
|
|
18
|
-
console.log(chalk.yellow("请查看帮助文档:https://cloudccone.feishu.cn/wiki/Q2AgwlxAtijmMJkjXXZcYgQVnmw?fromScene=spaceOverview"));
|
|
19
|
-
console.log()
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
cc.
|
|
36
|
-
//
|
|
37
|
-
cc.
|
|
38
|
-
//
|
|
39
|
-
cc.
|
|
40
|
-
//
|
|
41
|
-
cc.
|
|
42
|
-
//
|
|
43
|
-
cc.
|
|
44
|
-
try {
|
|
45
|
-
cc[
|
|
46
|
-
} catch (e) {
|
|
47
|
-
console.log()
|
|
48
|
-
console.log(chalk.yellow("请查看帮助文档:https://cloudccone.feishu.cn/wiki/Q2AgwlxAtijmMJkjXXZcYgQVnmw?fromScene=spaceOverview"), e);
|
|
49
|
-
console.log()
|
|
2
|
+
const chalk = require("chalk")
|
|
3
|
+
|
|
4
|
+
let argvs = process.argv.splice(2);
|
|
5
|
+
// 动作
|
|
6
|
+
let action = argvs[0]
|
|
7
|
+
if (!action) {
|
|
8
|
+
console.log()
|
|
9
|
+
console.log(chalk.yellow("请查看帮助文档:https://cloudccone.feishu.cn/wiki/Q2AgwlxAtijmMJkjXXZcYgQVnmw?fromScene=spaceOverview"));
|
|
10
|
+
console.log()
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 类型
|
|
15
|
+
let type = argvs[1]
|
|
16
|
+
if (!type) {
|
|
17
|
+
console.log()
|
|
18
|
+
console.log(chalk.yellow("请查看帮助文档:https://cloudccone.feishu.cn/wiki/Q2AgwlxAtijmMJkjXXZcYgQVnmw?fromScene=spaceOverview"));
|
|
19
|
+
console.log()
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const cc = {}
|
|
24
|
+
// 创建模板项目
|
|
25
|
+
cc.project = require("../src/project/index")
|
|
26
|
+
// 组件的管理
|
|
27
|
+
cc.plugin = require("../src/plugin/index")
|
|
28
|
+
// 类的管理
|
|
29
|
+
cc.classes = require("../src/classes/index")
|
|
30
|
+
// 定时器的管理
|
|
31
|
+
cc.timer = require("../src/timer/index")
|
|
32
|
+
// 触发器的管理
|
|
33
|
+
cc.triggers = require("../src/triggers/index")
|
|
34
|
+
// 客户端脚本的管理
|
|
35
|
+
cc.script = require("../src/script/index")
|
|
36
|
+
// token管理
|
|
37
|
+
cc.token = require("../src/token/index")
|
|
38
|
+
// 对象管理
|
|
39
|
+
cc.object = require("../src/object/index")
|
|
40
|
+
// 对象记录类型管理
|
|
41
|
+
cc.recordType = require("../src/recordType/index")
|
|
42
|
+
// 配置管理
|
|
43
|
+
cc.config = require("../src/config/index")
|
|
44
|
+
try {
|
|
45
|
+
cc[argvs[1]](argvs[0], argvs);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.log()
|
|
48
|
+
console.log(chalk.yellow("请查看帮助文档:https://cloudccone.feishu.cn/wiki/Q2AgwlxAtijmMJkjXXZcYgQVnmw?fromScene=spaceOverview"), e);
|
|
49
|
+
console.log()
|
|
50
50
|
}
|
package/bin/plugin.js
CHANGED
package/bin/project.js
CHANGED
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cloudcc-cli",
|
|
3
|
-
"version": "1.6.
|
|
4
|
-
"description": "cloudcc-cli",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"cloudcc",
|
|
7
|
-
"cloudcc-cli"
|
|
8
|
-
],
|
|
9
|
-
"main": "./bin",
|
|
10
|
-
"author": "cloudcc",
|
|
11
|
-
"license": "ISC",
|
|
12
|
-
"bin": {
|
|
13
|
-
"cloudccCreate": "bin/project.js",
|
|
14
|
-
"cloudccBuild": "bin/plugin.js",
|
|
15
|
-
"cc": "bin/cc.js"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"cc-pull": "git fetch --tags -f && git pull",
|
|
19
|
-
"publish-lib": "npm publish --registry https://registry.npmjs.org && curl https://npmmirror.com/sync/cloudcc-cli"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"axios": "^0.21.4",
|
|
23
|
-
"boxen": "^4.0.0",
|
|
24
|
-
"chalk": "^2.4.2",
|
|
25
|
-
"crypto-js": "^4.1.1",
|
|
26
|
-
"dayjs": "^1.10.7",
|
|
27
|
-
"fs-extra": "^11.2.0",
|
|
28
|
-
"inquirer": "^8.1.0",
|
|
29
|
-
"marked": "^5.0.1",
|
|
30
|
-
"mem-fs": "^2.2.1",
|
|
31
|
-
"mem-fs-editor": "^9.0.1",
|
|
32
|
-
"vue-custom-element": "^3.3.0",
|
|
33
|
-
"vue-template-compiler": "^2.6.14"
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "cloudcc-cli",
|
|
3
|
+
"version": "1.6.2",
|
|
4
|
+
"description": "cloudcc-cli",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cloudcc",
|
|
7
|
+
"cloudcc-cli"
|
|
8
|
+
],
|
|
9
|
+
"main": "./bin",
|
|
10
|
+
"author": "cloudcc",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"bin": {
|
|
13
|
+
"cloudccCreate": "bin/project.js",
|
|
14
|
+
"cloudccBuild": "bin/plugin.js",
|
|
15
|
+
"cc": "bin/cc.js"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"cc-pull": "git fetch --tags -f && git pull",
|
|
19
|
+
"publish-lib": "npm publish --registry https://registry.npmjs.org && curl https://npmmirror.com/sync/cloudcc-cli"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"axios": "^0.21.4",
|
|
23
|
+
"boxen": "^4.0.0",
|
|
24
|
+
"chalk": "^2.4.2",
|
|
25
|
+
"crypto-js": "^4.1.1",
|
|
26
|
+
"dayjs": "^1.10.7",
|
|
27
|
+
"fs-extra": "^11.2.0",
|
|
28
|
+
"inquirer": "^8.1.0",
|
|
29
|
+
"marked": "^5.0.1",
|
|
30
|
+
"mem-fs": "^2.2.1",
|
|
31
|
+
"mem-fs-editor": "^9.0.1",
|
|
32
|
+
"vue-custom-element": "^3.3.0",
|
|
33
|
+
"vue-template-compiler": "^2.6.14"
|
|
34
|
+
}
|
|
35
35
|
}
|
package/src/classes/create.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
const { checkUpdate } = require("../../utils/checkVersion")
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
const path = require("path")
|
|
4
|
-
const chalk = require("chalk")
|
|
5
|
-
/**
|
|
6
|
-
* 创建文件
|
|
7
|
-
* @param {string} name 文件名称
|
|
8
|
-
*/
|
|
9
|
-
async function create(name) {
|
|
10
|
-
let res = await checkUpdate();
|
|
11
|
-
if (!res) {
|
|
12
|
-
const classesPath = path.join(process.cwd(), "classes/" + name);
|
|
13
|
-
try {
|
|
14
|
-
fs.mkdirSync(classesPath, { recursive: true })
|
|
15
|
-
const javaTmp = `
|
|
16
|
-
public class ${name}{
|
|
17
|
-
private UserInfo userInfo;
|
|
18
|
-
|
|
19
|
-
public ${name}(UserInfo userInfo){
|
|
20
|
-
this.userInfo = userInfo;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
public String demo(String str){
|
|
25
|
-
str = "demo";
|
|
26
|
-
return str;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`
|
|
30
|
-
fs.writeFileSync(path.join(classesPath, name + ".java"), javaTmp)
|
|
31
|
-
fs.writeFileSync(path.join(classesPath, "config.json"), `{"name":"${name}","version":"3"}`)
|
|
32
|
-
console.log()
|
|
33
|
-
console.log(chalk.green("创建成功:" + name))
|
|
34
|
-
console.log()
|
|
35
|
-
} catch (e) {
|
|
36
|
-
console.log()
|
|
37
|
-
console.log(chalk.red("创建失败:" + e))
|
|
38
|
-
console.log()
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports = create;
|
|
1
|
+
const { checkUpdate } = require("../../utils/checkVersion")
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path")
|
|
4
|
+
const chalk = require("chalk")
|
|
5
|
+
/**
|
|
6
|
+
* 创建文件
|
|
7
|
+
* @param {string} name 文件名称
|
|
8
|
+
*/
|
|
9
|
+
async function create(name) {
|
|
10
|
+
let res = await checkUpdate();
|
|
11
|
+
if (!res) {
|
|
12
|
+
const classesPath = path.join(process.cwd(), "classes/" + name);
|
|
13
|
+
try {
|
|
14
|
+
fs.mkdirSync(classesPath, { recursive: true })
|
|
15
|
+
const javaTmp = `
|
|
16
|
+
public class ${name}{
|
|
17
|
+
private UserInfo userInfo;
|
|
18
|
+
|
|
19
|
+
public ${name}(UserInfo userInfo){
|
|
20
|
+
this.userInfo = userInfo;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public String demo(String str){
|
|
25
|
+
str = "demo";
|
|
26
|
+
return str;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`
|
|
30
|
+
fs.writeFileSync(path.join(classesPath, name + ".java"), javaTmp)
|
|
31
|
+
fs.writeFileSync(path.join(classesPath, "config.json"), `{"name":"${name}","version":"3"}`)
|
|
32
|
+
console.log()
|
|
33
|
+
console.log(chalk.green("创建成功:" + name))
|
|
34
|
+
console.log()
|
|
35
|
+
} catch (e) {
|
|
36
|
+
console.log()
|
|
37
|
+
console.log(chalk.red("创建失败:" + e))
|
|
38
|
+
console.log()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = create;
|
package/src/classes/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const cc = {}
|
|
2
|
-
cc.create = require("./create")
|
|
3
|
-
cc.publish = require("./publish")
|
|
4
|
-
function Classes(action,
|
|
5
|
-
cc[action](
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
module.exports = Classes;
|
|
1
|
+
const cc = {}
|
|
2
|
+
cc.create = require("./create")
|
|
3
|
+
cc.publish = require("./publish")
|
|
4
|
+
function Classes(action, argvs) {
|
|
5
|
+
cc[action](argvs[2])
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
module.exports = Classes;
|
package/src/classes/publish.js
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
// 检查cli版本更新功能
|
|
2
|
-
const { checkUpdate } = require("../../utils/checkVersion")
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path")
|
|
5
|
-
const chalk = require("chalk")
|
|
6
|
-
const { postNormal } = require("../../utils/http")
|
|
7
|
-
|
|
8
|
-
const { getBusToken } = require("../../utils/utils")
|
|
9
|
-
/**
|
|
10
|
-
* 发布文件
|
|
11
|
-
* @param {string} name 文件名称
|
|
12
|
-
*/
|
|
13
|
-
async function publish(name) {
|
|
14
|
-
let res = await checkUpdate();
|
|
15
|
-
if (!res) {
|
|
16
|
-
console.log();
|
|
17
|
-
console.log(chalk.green('发布中,请稍后...'));
|
|
18
|
-
console.log();
|
|
19
|
-
const classPath = path.join(process.cwd(), `classes/${name}/`);
|
|
20
|
-
let classContent = fs.readFileSync(classPath + `${name}.java`, 'utf8');
|
|
21
|
-
let configContent = JSON.parse(fs.readFileSync(classPath + "config.json", 'utf8'));
|
|
22
|
-
// 获取token成功后,发布内容
|
|
23
|
-
if (await getBusToken()) {
|
|
24
|
-
let body = {
|
|
25
|
-
"id": configContent.id,
|
|
26
|
-
"name": name,
|
|
27
|
-
"version": configContent.version,
|
|
28
|
-
"source": encodeURI(classContent),
|
|
29
|
-
"folderId": "wgd"
|
|
30
|
-
}
|
|
31
|
-
let url = new URL(global.baseUrl).origin
|
|
32
|
-
let res = await postNormal(url + "/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
console.log();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
1
|
+
// 检查cli版本更新功能
|
|
2
|
+
const { checkUpdate } = require("../../utils/checkVersion")
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path")
|
|
5
|
+
const chalk = require("chalk")
|
|
6
|
+
const { postNormal } = require("../../utils/http")
|
|
7
|
+
|
|
8
|
+
const { getBusToken } = require("../../utils/utils")
|
|
9
|
+
/**
|
|
10
|
+
* 发布文件
|
|
11
|
+
* @param {string} name 文件名称
|
|
12
|
+
*/
|
|
13
|
+
async function publish(name) {
|
|
14
|
+
let res = await checkUpdate();
|
|
15
|
+
if (!res) {
|
|
16
|
+
console.log();
|
|
17
|
+
console.log(chalk.green('发布中,请稍后...'));
|
|
18
|
+
console.log();
|
|
19
|
+
const classPath = path.join(process.cwd(), `classes/${name}/`);
|
|
20
|
+
let classContent = fs.readFileSync(classPath + `${name}.java`, 'utf8');
|
|
21
|
+
let configContent = JSON.parse(fs.readFileSync(classPath + "config.json", 'utf8'));
|
|
22
|
+
// 获取token成功后,发布内容
|
|
23
|
+
if (await getBusToken()) {
|
|
24
|
+
let body = {
|
|
25
|
+
"id": configContent.id,
|
|
26
|
+
"name": name,
|
|
27
|
+
"version": configContent.version,
|
|
28
|
+
"source": encodeURI(classContent),
|
|
29
|
+
"folderId": "wgd"
|
|
30
|
+
}
|
|
31
|
+
let url = new URL(global.baseUrl).origin
|
|
32
|
+
let res = await postNormal(url + "/setup/api/ccfag/save", body)
|
|
33
|
+
console.log(res)
|
|
34
|
+
if (res.result) {
|
|
35
|
+
console.log(chalk.green('发布成功!'));
|
|
36
|
+
console.log();
|
|
37
|
+
// 组件发布成功后,判断下配置文件是否有id,如果没有,那么将id存储到配置中
|
|
38
|
+
if (!configContent.id) {
|
|
39
|
+
configContent.id = res.data
|
|
40
|
+
fs.writeFileSync(path.join(classPath, "config.json"), JSON.stringify(configContent))
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
console.log(chalk.red('发布失败:' + res.returnInfo));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
module.exports = publish;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
const chalk = require("chalk")
|
|
3
|
+
const path = require("path")
|
|
4
|
+
/**
|
|
5
|
+
* 获取token
|
|
6
|
+
*/
|
|
7
|
+
async function get(projectPath = process.cwd()) {
|
|
8
|
+
let config = require(path.join(projectPath, "cloudcc-cli.config.js"))
|
|
9
|
+
if (config) {
|
|
10
|
+
console.log();
|
|
11
|
+
Object.keys(config).map((item) => {
|
|
12
|
+
if (item == config.use) {
|
|
13
|
+
console.log(chalk.green(`*${item}`));
|
|
14
|
+
} else if ("use" != item) {
|
|
15
|
+
console.log(item);
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
console.log();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = get;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const fs = require("fs")
|
|
3
|
+
/**
|
|
4
|
+
* 获取token
|
|
5
|
+
*/
|
|
6
|
+
function use(env, projectPath = process.cwd()) {
|
|
7
|
+
let config = require(path.join(projectPath, "cloudcc-cli.config.js"));
|
|
8
|
+
config.use = env;
|
|
9
|
+
fs.writeFileSync(path.join(projectPath, "cloudcc-cli.config.js"),
|
|
10
|
+
`module.exports =
|
|
11
|
+
${JSON.stringify(config)}
|
|
12
|
+
`
|
|
13
|
+
, 'utf8');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = use;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { getBusToken } = require("../../utils/utils")
|
|
2
|
+
const { postNormal } = require("../../utils/http")
|
|
3
|
+
/**
|
|
4
|
+
* 获取对象集合
|
|
5
|
+
*/
|
|
6
|
+
async function get(path = process.cwd()) {
|
|
7
|
+
// 获取token成功后,发布内容
|
|
8
|
+
if (await getBusToken(path)) {
|
|
9
|
+
let url = new URL(global.baseUrl).origin
|
|
10
|
+
let res = await postNormal(url + "/setup/api/customObject/standardObjList")
|
|
11
|
+
console.log(JSON.stringify(res.data))
|
|
12
|
+
return res.data
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = get;
|
package/src/plugin/create.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const inquirer = require("inquirer")
|
|
3
|
-
// 检查cli版本更新功能
|
|
4
|
-
const { checkUpdate } = require("../../utils/checkVersion")
|
|
5
|
-
const temp = `<template>
|
|
6
|
-
<div class="cc-container">
|
|
7
|
-
<div>Hello CloudCC</div>
|
|
8
|
-
<div>
|
|
9
|
-
<a href="https://cloudccone.feishu.cn/wiki/JZ7CwcRfriU8taknCKCcwKEmncd">
|
|
10
|
-
开发者文档</a
|
|
11
|
-
>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
</template>
|
|
15
|
-
|
|
16
|
-
<script>
|
|
17
|
-
export default {
|
|
18
|
-
data() {
|
|
19
|
-
return {
|
|
20
|
-
componentInfo: {
|
|
21
|
-
// 组件唯一标识,全局唯一
|
|
22
|
-
component: "cloudcc-demo-01",
|
|
23
|
-
// 组件名称,在页面编辑器显示的名字
|
|
24
|
-
compName: "cloudcc-demo-01",
|
|
25
|
-
// 组件描述信息
|
|
26
|
-
compDesc: "组件描述信息",
|
|
27
|
-
},
|
|
28
|
-
isLock: false,
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
</script>
|
|
33
|
-
<style lang="scss" scoped>
|
|
34
|
-
.cc-container {
|
|
35
|
-
text-align: center;
|
|
36
|
-
padding: 8px;
|
|
37
|
-
background: goldenrod;
|
|
38
|
-
}
|
|
39
|
-
</style>`
|
|
40
|
-
/**
|
|
41
|
-
* 创建组件模板文件
|
|
42
|
-
*/
|
|
43
|
-
class Builder {
|
|
44
|
-
constructor() {
|
|
45
|
-
this.options = {
|
|
46
|
-
// 开发配置信息
|
|
47
|
-
devConsoleConfig: {
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
this.plugin = process.argv.splice(2)[0]
|
|
51
|
-
}
|
|
52
|
-
async init() {
|
|
53
|
-
let res = await checkUpdate();
|
|
54
|
-
if (!res) {
|
|
55
|
-
// 获得用户输入
|
|
56
|
-
let answers;
|
|
57
|
-
if (this.plugin) {
|
|
58
|
-
answers = { buildFileName: this.plugin + "/demo.vue" }
|
|
59
|
-
} else {
|
|
60
|
-
answers = await this.ask();
|
|
61
|
-
answers.buildFileName = "./plugin/" + answers.buildFileName
|
|
62
|
-
}
|
|
63
|
-
fs.writeFileSync(answers.buildFileName, temp);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* 命令行交互
|
|
68
|
-
* @returns 结果
|
|
69
|
-
*/
|
|
70
|
-
ask() {
|
|
71
|
-
const prompt = [];
|
|
72
|
-
prompt.push({
|
|
73
|
-
type: "input",
|
|
74
|
-
name: "buildFileName",
|
|
75
|
-
message: "请输入文件名,如index.vue",
|
|
76
|
-
})
|
|
77
|
-
return inquirer.prompt(prompt)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
module.exports = Builder;
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const inquirer = require("inquirer")
|
|
3
|
+
// 检查cli版本更新功能
|
|
4
|
+
const { checkUpdate } = require("../../utils/checkVersion")
|
|
5
|
+
const temp = `<template>
|
|
6
|
+
<div class="cc-container">
|
|
7
|
+
<div>Hello CloudCC</div>
|
|
8
|
+
<div>
|
|
9
|
+
<a href="https://cloudccone.feishu.cn/wiki/JZ7CwcRfriU8taknCKCcwKEmncd">
|
|
10
|
+
开发者文档</a
|
|
11
|
+
>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
export default {
|
|
18
|
+
data() {
|
|
19
|
+
return {
|
|
20
|
+
componentInfo: {
|
|
21
|
+
// 组件唯一标识,全局唯一
|
|
22
|
+
component: "cloudcc-demo-01",
|
|
23
|
+
// 组件名称,在页面编辑器显示的名字
|
|
24
|
+
compName: "cloudcc-demo-01",
|
|
25
|
+
// 组件描述信息
|
|
26
|
+
compDesc: "组件描述信息",
|
|
27
|
+
},
|
|
28
|
+
isLock: false,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
</script>
|
|
33
|
+
<style lang="scss" scoped>
|
|
34
|
+
.cc-container {
|
|
35
|
+
text-align: center;
|
|
36
|
+
padding: 8px;
|
|
37
|
+
background: goldenrod;
|
|
38
|
+
}
|
|
39
|
+
</style>`
|
|
40
|
+
/**
|
|
41
|
+
* 创建组件模板文件
|
|
42
|
+
*/
|
|
43
|
+
class Builder {
|
|
44
|
+
constructor() {
|
|
45
|
+
this.options = {
|
|
46
|
+
// 开发配置信息
|
|
47
|
+
devConsoleConfig: {
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
this.plugin = process.argv.splice(2)[0]
|
|
51
|
+
}
|
|
52
|
+
async init() {
|
|
53
|
+
let res = await checkUpdate();
|
|
54
|
+
if (!res) {
|
|
55
|
+
// 获得用户输入
|
|
56
|
+
let answers;
|
|
57
|
+
if (this.plugin) {
|
|
58
|
+
answers = { buildFileName: this.plugin + "/demo.vue" }
|
|
59
|
+
} else {
|
|
60
|
+
answers = await this.ask();
|
|
61
|
+
answers.buildFileName = "./plugin/" + answers.buildFileName
|
|
62
|
+
}
|
|
63
|
+
fs.writeFileSync(answers.buildFileName, temp);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 命令行交互
|
|
68
|
+
* @returns 结果
|
|
69
|
+
*/
|
|
70
|
+
ask() {
|
|
71
|
+
const prompt = [];
|
|
72
|
+
prompt.push({
|
|
73
|
+
type: "input",
|
|
74
|
+
name: "buildFileName",
|
|
75
|
+
message: "请输入文件名,如index.vue",
|
|
76
|
+
})
|
|
77
|
+
return inquirer.prompt(prompt)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
module.exports = Builder;
|