@opentapd/tplugin-cli 0.52.0 → 0.52.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.
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/lib/resources.js CHANGED
@@ -178,6 +178,12 @@ function filterResourcesConfigs(docObj, entranceTmpl) {
178
178
  let resourcesConfigs = docObj.app.resources || [];
179
179
  const resourcesKey = []; const tagKey = {};
180
180
 
181
+ const notSupportedMultiEntrance = {
182
+ app_for_setting: true,
183
+ app_for_project: true,
184
+ app_for_devops_setting: true,
185
+ };
186
+
181
187
  // 合并添加的配置信息
182
188
  resourcesConfigs = resourcesConfigs.concat(entranceTmpl.resourcesConfigs);
183
189
  resourcesConfigs = resourcesConfigs.filter((resources) => {
@@ -191,8 +197,11 @@ function filterResourcesConfigs(docObj, entranceTmpl) {
191
197
  return true;
192
198
  }
193
199
 
194
- // 存在重复时,直接过滤
195
- return false;
200
+ if (notSupportedMultiEntrance[resources.key]) {
201
+ return false;
202
+ }
203
+
204
+ return true;
196
205
  });
197
206
 
198
207
  return resourcesConfigs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentapd/tplugin-cli",
3
- "version": "0.52.0",
3
+ "version": "0.52.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.34.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,5 +79,5 @@
78
79
  "node": ">=14.13.0"
79
80
  },
80
81
  "main": "index.js",
81
- "gitHead": "8de7ca919cc1df59a7327cafa58f17c1b26429bc"
82
+ "gitHead": "db777408d9ddd4efb4802b19a623b81327f1340c"
82
83
  }