cloudcc-cli 1.1.2 → 1.1.5

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/template/httpjs CHANGED
@@ -1,109 +1,109 @@
1
- import VueCookies from "vue-cookies";
2
- import axios from 'axios'
3
- import packageJson from '../package.json'
4
- const service = axios.create({
5
- timeout: 60000, // request timeout
6
- headers: {
7
- 'Content-Type': 'application/json; charset=utf-8',
8
- },
9
- })
10
-
11
- // request interceptor
12
- service.interceptors.request.use(
13
- config => {
14
- config.headers.accessToken = VueCookies.get("JSESSIONID")
15
- return config
16
- },
17
- error => {
18
- // Do something with request error
19
- Promise.reject(error)
20
- }
21
- )
22
-
23
- // response interceptor
24
- service.interceptors.response.use(
25
- response => {
26
- const code = response.data.code || 200
27
- if (code !== 200) {
28
- return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
29
- } else {
30
- return response.data
31
- }
32
- },
33
- error => {
34
- return Promise.reject(error)
35
- }
36
- )
37
- const formateData = data => {
38
- return {
39
- head: {
40
- appType: packageJson.name,
41
- appVersion: packageJson.version,
42
- accessToken: VueCookies.get("JSESSIONID")
43
- },
44
- body: {
45
- ...data
46
- }
47
- }
48
- }
49
- export default {
50
- get: (url, data = {}, responseType = '') => {
51
- return service({
52
- url: url,
53
- method: 'get',
54
- params: data,
55
- responseType: responseType
56
- })
57
- },
58
- getLight: (url, data = {}, responseType = '') => {
59
- return service({
60
- url: url,
61
- method: 'get',
62
- params: data,
63
- responseType: responseType
64
- })
65
- },
66
- postLight: (url, data = {}) => {
67
- return service({
68
- url: url,
69
- method: 'post',
70
- data: { ...data },
71
- })
72
- },
73
- post: (url, data = {}, responseType = '') => {
74
- return service({
75
- url: url,
76
- method: 'post',
77
- data: formateData(data),
78
- responseType: responseType
79
- })
80
- },
81
- postParams: (url, data = {}) => {
82
- return service({
83
- url: url,
84
- method: 'post',
85
- params: data
86
- })
87
- },
88
- patch: (url, data = {}) => {
89
- return service({
90
- url: url,
91
- method: 'patch',
92
- data: formateData(data)
93
- })
94
- },
95
- delete: (url, data = {}) => {
96
- return service({
97
- url: url,
98
- method: 'delete',
99
- data: formateData(data)
100
- })
101
- },
102
- put: (url, data = {}) => {
103
- return service({
104
- url: url,
105
- method: 'put',
106
- data: formateData(data)
107
- })
108
- }
109
- }
1
+ import VueCookies from "vue-cookies";
2
+ import axios from 'axios'
3
+ import packageJson from '../package.json'
4
+ const service = axios.create({
5
+ timeout: 60000, // request timeout
6
+ headers: {
7
+ 'Content-Type': 'application/json; charset=utf-8',
8
+ },
9
+ })
10
+
11
+ // request interceptor
12
+ service.interceptors.request.use(
13
+ config => {
14
+ config.headers.accessToken = VueCookies.get("JSESSIONID")
15
+ return config
16
+ },
17
+ error => {
18
+ // Do something with request error
19
+ Promise.reject(error)
20
+ }
21
+ )
22
+
23
+ // response interceptor
24
+ service.interceptors.response.use(
25
+ response => {
26
+ const code = response.data.code || 200
27
+ if (code !== 200) {
28
+ return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
29
+ } else {
30
+ return response.data
31
+ }
32
+ },
33
+ error => {
34
+ return Promise.reject(error)
35
+ }
36
+ )
37
+ const formateData = data => {
38
+ return {
39
+ head: {
40
+ appType: packageJson.name,
41
+ appVersion: packageJson.version,
42
+ accessToken: VueCookies.get("JSESSIONID")
43
+ },
44
+ body: {
45
+ ...data
46
+ }
47
+ }
48
+ }
49
+ export default {
50
+ get: (url, data = {}, responseType = '') => {
51
+ return service({
52
+ url: url,
53
+ method: 'get',
54
+ params: data,
55
+ responseType: responseType
56
+ })
57
+ },
58
+ getLight: (url, data = {}, responseType = '') => {
59
+ return service({
60
+ url: url,
61
+ method: 'get',
62
+ params: data,
63
+ responseType: responseType
64
+ })
65
+ },
66
+ postLight: (url, data = {}) => {
67
+ return service({
68
+ url: url,
69
+ method: 'post',
70
+ data: { ...data },
71
+ })
72
+ },
73
+ post: (url, data = {}, responseType = '') => {
74
+ return service({
75
+ url: url,
76
+ method: 'post',
77
+ data: formateData(data),
78
+ responseType: responseType
79
+ })
80
+ },
81
+ postParams: (url, data = {}) => {
82
+ return service({
83
+ url: url,
84
+ method: 'post',
85
+ params: data
86
+ })
87
+ },
88
+ patch: (url, data = {}) => {
89
+ return service({
90
+ url: url,
91
+ method: 'patch',
92
+ data: formateData(data)
93
+ })
94
+ },
95
+ delete: (url, data = {}) => {
96
+ return service({
97
+ url: url,
98
+ method: 'delete',
99
+ data: formateData(data)
100
+ })
101
+ },
102
+ put: (url, data = {}) => {
103
+ return service({
104
+ url: url,
105
+ method: 'put',
106
+ data: formateData(data)
107
+ })
108
+ }
109
+ }
package/template/index.js CHANGED
@@ -1,61 +1,61 @@
1
- const fs = require("fs");
2
- const chalk = require("chalk")
3
- const path = require("path")
4
- module.exports = function (creator, options, callback) {
5
- const { name, description } = options;
6
-
7
- const cwd = process.cwd();
8
-
9
-
10
- const projectPath = path.join(cwd, name);
11
- const pluginPath = path.join(projectPath, "plugin");
12
- const src = path.join(projectPath, "src");
13
- const utils = path.join(projectPath, "utils");
14
- const public = path.join(projectPath, "public");
15
-
16
- //新建项目目录
17
- //同步创建目录,以免文件目录不对齐
18
- fs.mkdirSync(projectPath)
19
- fs.mkdirSync(pluginPath)
20
- fs.mkdirSync(src)
21
- fs.mkdirSync(public)
22
-
23
- creator.copyTpl('packagejson', path.join(projectPath, "package.json"), {
24
- name, description
25
- })
26
-
27
- creator.copyTpl('vueconfigjs', path.join(projectPath, "vue.config.js"))
28
-
29
- creator.copyTpl('babelconfigjs', path.join(projectPath, "babel.config.js"))
30
-
31
- creator.copyTpl('mainjs', path.join(src, "main.js"))
32
-
33
- creator.copyTpl('Appvue', path.join(src, "App.vue"))
34
-
35
- creator.copyTpl('httpjs', path.join(utils, "http.js"))
36
-
37
- creator.copyTpl('generateIDjs', path.join(utils, "generateID.js"))
38
-
39
- creator.copyTpl('indexvue', path.join(pluginPath, "index.vue"))
40
-
41
- creator.copyTpl('indexhtml', path.join(public, "index.html"))
42
-
43
- creator.fs.commit(() => {
44
- console.log();
45
- console.log(`${chalk.grey(`创建项目: ${name}`)} ${chalk.green('✔ ')}`);
46
- console.log(`${chalk.grey(`创建目录: ${name}/plugin`)} ${chalk.green('✔ ')}`);
47
- console.log(`${chalk.grey(`创建文件: ${name}/plugin/index.vue`)} ${chalk.green('✔ ')}`);
48
-
49
- console.log(`${chalk.grey(`创建目录: ${name}/public`)} ${chalk.green('✔ ')}`);
50
- console.log(`${chalk.grey(`创建文件: ${name}/plugin/index.html`)} ${chalk.green('✔ ')}`);
51
-
52
- console.log(`${chalk.grey(`创建目录: ${name}/src`)} ${chalk.green('✔ ')}`);
53
- console.log(`${chalk.grey(`创建文件: ${name}/src/App.vue`)} ${chalk.green('✔ ')}`);
54
- console.log(`${chalk.grey(`创建文件: ${name}/src/main.js`)} ${chalk.green('✔ ')}`);
55
-
56
- console.log(`${chalk.grey(`创建文件: ${name}/babel.config.js`)} ${chalk.green('✔ ')}`);
57
- console.log(`${chalk.grey(`创建文件: ${name}/package.json`)} ${chalk.green('✔ ')}`);
58
- console.log(`${chalk.grey(`创建文件: ${name}/vue.config.js`)} ${chalk.green('✔ ')}`);
59
- callback();
60
- });
1
+ const fs = require("fs");
2
+ const chalk = require("chalk")
3
+ const path = require("path")
4
+ module.exports = function (creator, options, callback) {
5
+ const { name, description } = options;
6
+
7
+ const cwd = process.cwd();
8
+
9
+
10
+ const projectPath = path.join(cwd, name);
11
+ const pluginPath = path.join(projectPath, "plugin");
12
+ const src = path.join(projectPath, "src");
13
+ const utils = path.join(projectPath, "utils");
14
+ const public = path.join(projectPath, "public");
15
+
16
+ //新建项目目录
17
+ //同步创建目录,以免文件目录不对齐
18
+ fs.mkdirSync(projectPath)
19
+ fs.mkdirSync(pluginPath)
20
+ fs.mkdirSync(src)
21
+ fs.mkdirSync(public)
22
+
23
+ creator.copyTpl('packagejson', path.join(projectPath, "package.json"), {
24
+ name, description
25
+ })
26
+
27
+ creator.copyTpl('vueconfigjs', path.join(projectPath, "vue.config.js"))
28
+
29
+ creator.copyTpl('babelconfigjs', path.join(projectPath, "babel.config.js"))
30
+
31
+ creator.copyTpl('mainjs', path.join(src, "main.js"))
32
+
33
+ creator.copyTpl('Appvue', path.join(src, "App.vue"))
34
+
35
+ creator.copyTpl('httpjs', path.join(utils, "http.js"))
36
+
37
+ creator.copyTpl('generateIDjs', path.join(utils, "generateID.js"))
38
+
39
+ creator.copyTpl('indexvue', path.join(pluginPath, "index.vue"))
40
+
41
+ creator.copyTpl('indexhtml', path.join(public, "index.html"))
42
+
43
+ creator.fs.commit(() => {
44
+ console.log();
45
+ console.log(`${chalk.grey(`创建项目: ${name}`)} ${chalk.green('✔ ')}`);
46
+ console.log(`${chalk.grey(`创建目录: ${name}/plugin`)} ${chalk.green('✔ ')}`);
47
+ console.log(`${chalk.grey(`创建文件: ${name}/plugin/index.vue`)} ${chalk.green('✔ ')}`);
48
+
49
+ console.log(`${chalk.grey(`创建目录: ${name}/public`)} ${chalk.green('✔ ')}`);
50
+ console.log(`${chalk.grey(`创建文件: ${name}/plugin/index.html`)} ${chalk.green('✔ ')}`);
51
+
52
+ console.log(`${chalk.grey(`创建目录: ${name}/src`)} ${chalk.green('✔ ')}`);
53
+ console.log(`${chalk.grey(`创建文件: ${name}/src/App.vue`)} ${chalk.green('✔ ')}`);
54
+ console.log(`${chalk.grey(`创建文件: ${name}/src/main.js`)} ${chalk.green('✔ ')}`);
55
+
56
+ console.log(`${chalk.grey(`创建文件: ${name}/babel.config.js`)} ${chalk.green('✔ ')}`);
57
+ console.log(`${chalk.grey(`创建文件: ${name}/package.json`)} ${chalk.green('✔ ')}`);
58
+ console.log(`${chalk.grey(`创建文件: ${name}/vue.config.js`)} ${chalk.green('✔ ')}`);
59
+ callback();
60
+ });
61
61
  }