@next-core/brick-container 2.89.24 → 2.89.26

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.
@@ -46,6 +46,49 @@ def get_snippets_from_stories(stories_content):
46
46
  return ret_snippets
47
47
 
48
48
 
49
+ def get_v3_story_provider(pr, examples_content, types_content):
50
+ story_id = pr.get("name", "")
51
+ if not story_id:
52
+ return
53
+ story = { "storyId": story_id, "v3Brick": True, "type": "provider" }
54
+ desc = pr.get("description")
55
+ if type(desc) != dict:
56
+ desc = {"en": desc, "zh": desc}
57
+ story["description"] = desc
58
+
59
+ text = pr.get("text")
60
+ if not text:
61
+ text = desc
62
+ story["text"] = text
63
+
64
+ story["category"] = pr.get("category", "other")
65
+ story["alias"] = pr.get("alias", [])
66
+ story["icon"] = pr.get("icon")
67
+
68
+ if story_id in examples_content:
69
+ story["conf"] = examples_content[story_id]
70
+
71
+ doc = pr.get("doc", {})
72
+ if story_id in types_content:
73
+ doc["interface"] = types_content[story_id]
74
+ if "id" not in doc:
75
+ doc["id"] = story_id
76
+ if "name" not in doc:
77
+ doc["name"] = story_id
78
+ if "docKind" not in doc:
79
+ doc["docKind"] = "provider"
80
+ if "description" not in doc:
81
+ doc["description"] = desc
82
+ doc["properties"] = []
83
+ doc["events"] = []
84
+ doc["slots"] = []
85
+ doc["methods"] = []
86
+ doc["parts"] = []
87
+ story["doc"] = doc
88
+
89
+ return story
90
+
91
+
49
92
  def get_v3_story(br, examples_content, types_content):
50
93
  story_id = br.get("name", "")
51
94
  if not story_id:
@@ -80,8 +123,8 @@ def get_v3_story(br, examples_content, types_content):
80
123
  doc["id"] = story_id
81
124
  if "name" not in doc:
82
125
  doc["name"] = story_id
83
- if "docKink" not in doc:
84
- doc["docKink"] = "brick"
126
+ if "docKind" not in doc:
127
+ doc["docKind"] = "brick"
85
128
  if "description" not in doc:
86
129
  doc["description"] = desc
87
130
  if "properties" not in doc:
@@ -94,11 +137,8 @@ def get_v3_story(br, examples_content, types_content):
94
137
  doc["parts"] = parts
95
138
  if "slots" not in doc:
96
139
  doc["slots"] = slots
97
- # TODO: interface in doc
98
140
  story["doc"] = doc
99
141
 
100
- # TODO: conf
101
-
102
142
  return story
103
143
 
104
144
 
@@ -129,6 +169,10 @@ def collect_stories(install_path):
129
169
  story = get_v3_story(br, examples_content, types_content)
130
170
  if story:
131
171
  stories_content.append(story)
172
+ for pr in manifest_content.get("providers", []):
173
+ story = get_v3_story_provider(pr, examples_content, types_content)
174
+ if story:
175
+ stories_content.append(story)
132
176
  return stories_content
133
177
  return []
134
178
 
@@ -242,12 +286,23 @@ def remove_tar_gz_file(nb_targz_path):
242
286
  os.remove(nb_targz_path)
243
287
 
244
288
 
289
+ def get_version(install_path):
290
+ version_file = os.path.join(install_path, "version.ini")
291
+ package_version = "0.0.0"
292
+ try:
293
+ with open(version_file, "r") as f:
294
+ lines = f.readlines()
295
+ package_version = str.strip(lines[1])
296
+ except:
297
+ print "version.ini read error, use version", package_version
298
+ return package_version
299
+
300
+
301
+
245
302
  def report_brick_next(org, install_path):
246
303
  # 读取版本信息
247
- version_file = os.path.join(install_path, "version.ini")
248
- with open(version_file, "r") as f:
249
- lines = f.readlines()
250
- package_version = str.strip(lines[1])
304
+ package_version = get_version(install_path)
305
+
251
306
  targz_name = "brick_next.tar.gz"
252
307
  brick_targz_path = os.path.join(install_path, targz_name)
253
308
  if not mk_nb_tar_gz(brick_targz_path, install_path):
@@ -260,10 +315,7 @@ def report_brick_next(org, install_path):
260
315
 
261
316
  def report_nb(org, install_path):
262
317
  # 读取版本信息
263
- version_file = os.path.join(install_path, "version.ini")
264
- with open(version_file, "r") as f:
265
- lines = f.readlines()
266
- package_version = str.strip(lines[1])
318
+ package_version = get_version(install_path)
267
319
 
268
320
  package_name, bricks_content, stories_content, snippets_content, contract_content = collect(
269
321
  install_path)
@@ -281,10 +333,7 @@ def report_nb(org, install_path):
281
333
 
282
334
  def report_nt(org, install_path):
283
335
  # 读取版本信息
284
- version_file = os.path.join(install_path, "version.ini")
285
- with open(version_file, "r") as f:
286
- lines = f.readlines()
287
- package_version = str.strip(lines[1])
336
+ package_version = get_version(install_path)
288
337
 
289
338
  package_name = os.path.basename(install_path)
290
339
  if package_name: