@opentapd/tplugin-cli 0.52.1 → 0.53.1-alpha.0

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.
Files changed (2) hide show
  1. package/lib/lint.js +121 -1
  2. package/package.json +4 -6
package/lib/lint.js CHANGED
@@ -11,6 +11,117 @@ const yaml = require('js-yaml');
11
11
  const spinner = require('../util/spinner');
12
12
  const tapdsdk = require('../util/tapd');
13
13
  const checkPluginYaml = require('../util/checkPluginYaml');
14
+ const Joi = require('joi');
15
+
16
+ const schema = Joi.object({
17
+ app: {
18
+ code: Joi.string(),
19
+ desc: Joi.string(),
20
+ name: Joi.string(),
21
+ resources: Joi.array(),
22
+ scopes: Joi.array().items(Joi.string()),
23
+ tag: Joi.array().items({ name: Joi.string() }),
24
+ modules: {
25
+ autotasks: Joi.array().items({
26
+ code: Joi.string().required(),
27
+ conditions: Joi.array().items({
28
+ code: Joi.string().required(),
29
+ data: {
30
+ handler: Joi.string().required(),
31
+ },
32
+ icon: Joi.string().required(),
33
+ name: Joi.string().required(),
34
+ option: {
35
+ handler: Joi.string().required(),
36
+ },
37
+ related: Joi.array().items(Joi.string()),
38
+ type: Joi.string(),
39
+ desc: Joi.string(),
40
+ })
41
+ .unique('code'),
42
+ executors: {
43
+ actions: Joi.array().items({
44
+ code: Joi.string(),
45
+ desc: Joi.string(),
46
+ exec: {
47
+ handler: Joi.string(),
48
+ },
49
+ icon: Joi.string(),
50
+ name: Joi.string(),
51
+ option: {
52
+ handler: Joi.string(),
53
+ },
54
+ related: Joi.array().items(Joi.string()),
55
+ }),
56
+ },
57
+ icon: Joi.string(),
58
+ name: Joi.string(),
59
+ search: {
60
+ handler: Joi.string(),
61
+ },
62
+ trigger: {
63
+ events: Joi.array().items({
64
+ code: Joi.string(),
65
+ desc: Joi.string(),
66
+ event_change: {
67
+ handler: Joi.string(),
68
+ },
69
+ icon: Joi.string(),
70
+ name: Joi.string(),
71
+ option: {
72
+ handler: Joi.string(),
73
+ },
74
+ related: Joi.array().items(Joi.string()),
75
+ }),
76
+ },
77
+ })
78
+ .unique('code'),
79
+ object: Joi.array().items({
80
+ code: Joi.string().required(),
81
+ fields: {
82
+ handler: Joi.string().required(),
83
+ },
84
+ getter: {
85
+ handler: Joi.string().required(),
86
+ },
87
+ name: Joi.string().required(),
88
+ relations: Joi.array().items({
89
+ code: Joi.string().required(),
90
+ handler: Joi.string().required(),
91
+ related: Joi.string(),
92
+ type: Joi.string(),
93
+ })
94
+ .unique('code'),
95
+ })
96
+ .unique('code'),
97
+ },
98
+ fields: Joi.array().items({
99
+ code: Joi.string().required(),
100
+ name: Joi.string(),
101
+ desc: Joi.string(),
102
+ option: Joi.array().items({
103
+ value: Joi.string().required(),
104
+ name: Joi.string().required(),
105
+ })
106
+ .unique('value'),
107
+ related: Joi.array().items(Joi.string()
108
+ .valid('story', 'bug', 'task')),
109
+ type: Joi.string().valid(
110
+ 'text',
111
+ 'multi_select',
112
+ 'select',
113
+ 'checkbox',
114
+ 'radio',
115
+ 'textarea',
116
+ 'cascade_radio',
117
+ 'cascade_checkbox',
118
+ )
119
+ .required(),
120
+ validate: Joi.string(),
121
+ })
122
+ .unique('code'),
123
+ },
124
+ });
14
125
 
15
126
  // 检查插件格式
16
127
  module.exports = async () => {
@@ -20,9 +131,18 @@ module.exports = async () => {
20
131
  spinner.start('开始校验plugin.yaml...');
21
132
  const yamlPath = `${process.cwd()}/plugin.yaml`;
22
133
 
23
- const docObj = yaml.load(fs.readFileSync(yamlPath, 'utf8'));
134
+ const yamlFile = fs.readFileSync(yamlPath, 'utf8');
135
+ const docObj = yaml.load(yamlFile);
24
136
  const doc = yaml.dump(docObj);
25
137
 
138
+ const yamlInJSON = yaml.load(yamlFile, { json: true });
139
+
140
+ const { error } = schema.validate(yamlInJSON);
141
+ if (error) {
142
+ error.title = 'plugin.yaml校验不通过';
143
+ throw error;
144
+ }
145
+
26
146
  // 发起lint,远程校验文件配置内容
27
147
  const res = await lint(doc);
28
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentapd/tplugin-cli",
3
- "version": "0.52.1",
3
+ "version": "0.53.1-alpha.0",
4
4
  "description": "tplugin-cli",
5
5
  "bin": {
6
6
  "tplugin-cli": "index.js"
@@ -26,7 +26,7 @@
26
26
  "author": "",
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
- "@opentapd/tplugin-core": "^1.34.0",
29
+ "@opentapd/tplugin-core": "^1.35.1-alpha.0",
30
30
  "address": "^1.2.2",
31
31
  "archiver": "^5.3.1",
32
32
  "axios": "^0.21.1",
@@ -39,6 +39,7 @@
39
39
  "fs-extra": "^10.0.0",
40
40
  "get-port": "^5.1.1",
41
41
  "inquirer": "^8.1.2",
42
+ "joi": "^17.13.3",
42
43
  "js-base64": "^3.6.1",
43
44
  "js-yaml": "^4.1.0",
44
45
  "json5": "^2.2.0",
@@ -78,8 +79,5 @@
78
79
  "node": ">=14.13.0"
79
80
  },
80
81
  "main": "index.js",
81
- "publishConfig": {
82
- "tag": "latest"
83
- },
84
- "gitHead": "1f5669cd72a0b909bc1ba0c0b26f267a33d27b29"
82
+ "gitHead": "76bbc5b50be86c54cb91553f849c6982402da53d"
85
83
  }