Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

276 lines
7.3KB

  1. import json
  2. from typing import NamedTuple, Tuple, List, Sequence, Union, Optional, Mapping
  3. import sys
  4. import textwrap
  5. class Git(NamedTuple):
  6. url: str
  7. ref: str
  8. auto_lib: Optional[str] = None
  9. def to_dict(self) -> dict:
  10. return {
  11. 'url': self.url,
  12. 'ref': self.ref,
  13. 'auto-lib': self.auto_lib,
  14. }
  15. RemoteInfo = Union[Git]
  16. class Version(NamedTuple):
  17. version: str
  18. remote: RemoteInfo
  19. depends: Mapping[str, str] = {}
  20. description: str = '(No description provided)'
  21. def to_dict(self) -> dict:
  22. ret: dict = {
  23. 'description': self.description,
  24. }
  25. ret['depends'] = self.depends
  26. if isinstance(self.remote, Git):
  27. ret['git'] = self.remote.to_dict()
  28. return ret
  29. class Package(NamedTuple):
  30. name: str
  31. versions: List[Version]
  32. def many_versions(name: str,
  33. versions: Sequence[str],
  34. *,
  35. tag_fmt: str = '{}',
  36. git_url: str,
  37. auto_lib: str = None,
  38. description='(No description was provided)') -> Package:
  39. return Package(name, [
  40. Version(
  41. ver,
  42. description='\n'.join(textwrap.wrap(description)),
  43. remote=Git(
  44. url=git_url, ref=tag_fmt.format(ver), auto_lib=auto_lib))
  45. for ver in versions
  46. ])
  47. packages = [
  48. many_versions(
  49. 'range-v3',
  50. (
  51. '0.5.0',
  52. '0.9.0',
  53. '0.9.1',
  54. '0.10.0',
  55. ),
  56. git_url='https://github.com/ericniebler/range-v3.git',
  57. auto_lib='range-v3/range-v3',
  58. description=
  59. 'Range library for C++14/17/20, basis for C++20\'s std::ranges',
  60. ),
  61. many_versions(
  62. 'nlohmann-json',
  63. (
  64. '3.0.0',
  65. '3.0.1',
  66. '3.1.0',
  67. '3.1.1',
  68. '3.1.2',
  69. '3.2.0',
  70. '3.3.0',
  71. '3.4.0',
  72. '3.5.0',
  73. '3.6.0',
  74. '3.6.1',
  75. '3.7.0',
  76. '3.7.1',
  77. '3.7.2',
  78. '3.7.3',
  79. ),
  80. git_url='https://github.com/vector-of-bool/json.git',
  81. tag_fmt='dds/{}',
  82. description='JSON for Modern C++',
  83. ),
  84. Package('ms-wil', [
  85. Version(
  86. '2020.03.16',
  87. description='The Windows Implementation Library',
  88. remote=Git('https://github.com/vector-of-bool/wil.git',
  89. 'dds/2020.03.16'))
  90. ]),
  91. many_versions(
  92. 'neo-sqlite3',
  93. (
  94. '0.1.0',
  95. '0.2.0',
  96. '0.2.1',
  97. '0.2.2',
  98. '0.2.3',
  99. ),
  100. description='A modern and low-level C++ SQLite API',
  101. git_url='https://github.com/vector-of-bool/neo-sqlite3.git',
  102. ),
  103. Package('neo-fun', [
  104. Version(
  105. '0.1.0',
  106. description='Some library fundamentals that you might find useful',
  107. remote=Git('https://github.com/vector-of-bool/neo-fun.git',
  108. '0.1.0')),
  109. Version(
  110. '0.1.1',
  111. description='Some library fundamentals that you might find useful',
  112. remote=Git('https://github.com/vector-of-bool/neo-fun.git',
  113. '0.1.1'))
  114. ]),
  115. many_versions(
  116. 'neo-concepts',
  117. (
  118. '0.1.0',
  119. '0.2.0',
  120. '0.2.1',
  121. '0.2.2',
  122. ),
  123. description=
  124. 'Minimal C++ concepts library. Contains many definitions from C++20.',
  125. git_url='https://github.com/vector-of-bool/neo-concepts.git',
  126. ),
  127. Package('semver', [
  128. Version(
  129. '0.2.1',
  130. description=
  131. 'A C++ library that implements Semantic Versioning parsing, emitting, '
  132. 'types, ordering, and operations. See https://semver.org/',
  133. remote=Git('https://github.com/vector-of-bool/semver.git',
  134. '0.2.1')),
  135. Version(
  136. '0.2.2',
  137. description=
  138. 'A C++ library that implements Semantic Versioning parsing, emitting, '
  139. 'types, ordering, and operations. See https://semver.org/',
  140. remote=Git('https://github.com/vector-of-bool/semver.git',
  141. '0.2.2')),
  142. ]),
  143. many_versions(
  144. 'pubgrub',
  145. (
  146. '0.1.2',
  147. '0.2.0',
  148. '0.2.1',
  149. ),
  150. description=
  151. 'A C++ implementation of the Pubgrub version solving algorithm',
  152. git_url='https://github.com/vector-of-bool/pubgrub.git',
  153. ),
  154. many_versions(
  155. 'vob-json5',
  156. ('0.1.5', ),
  157. description='A C++ implementation of a JSON5 parser',
  158. git_url='https://github.com/vector-of-bool/json5.git',
  159. ),
  160. Package('vob-semester', [
  161. Version(
  162. '0.1.0',
  163. description='A C++ library to process recursive dynamic data',
  164. remote=Git('https://github.com/vector-of-bool/semester.git',
  165. '0.1.0'),
  166. depends={
  167. 'neo-fun': '^0.1.0',
  168. 'neo-concepts': '^0.2.1',
  169. }),
  170. Version(
  171. '0.1.1',
  172. description='A C++ library to process recursive dynamic data',
  173. remote=Git('https://github.com/vector-of-bool/semester.git',
  174. '0.1.1'),
  175. depends={
  176. 'neo-fun': '^0.1.1',
  177. 'neo-concepts': '^0.2.2',
  178. }),
  179. ]),
  180. Package('ctre', [
  181. Version(
  182. '2.7.0',
  183. description=
  184. 'A compile-time PCRE (almost) compatible regular expression matcher',
  185. remote=Git(
  186. 'https://github.com/hanickadot/compile-time-regular-expressions.git',
  187. 'v2.7',
  188. auto_lib='hanickadot/ctre',
  189. ))
  190. ]),
  191. many_versions(
  192. 'spdlog',
  193. (
  194. '0.9.0',
  195. '0.10.0',
  196. '0.11.0',
  197. '0.12.0',
  198. '0.13.0',
  199. '0.14.0',
  200. '0.16.0',
  201. '0.16.1',
  202. '0.16.2',
  203. '0.17.0',
  204. '1.0.0',
  205. '1.1.0',
  206. '1.2.0',
  207. '1.2.1',
  208. '1.3.0',
  209. '1.3.1',
  210. '1.4.0',
  211. '1.4.1',
  212. '1.4.2',
  213. ),
  214. git_url='https://github.com/gabime/spdlog.git',
  215. tag_fmt='v{}',
  216. auto_lib='spdlog/spdlog',
  217. description='Fast C++ logging library',
  218. ),
  219. many_versions(
  220. 'fmt',
  221. (
  222. '0.8.0',
  223. '0.9.0',
  224. '0.10.0',
  225. '0.12.0',
  226. '1.0.0',
  227. '1.1.0',
  228. '2.0.0',
  229. '2.0.1',
  230. '2.1.0',
  231. '2.1.1',
  232. '3.0.0',
  233. '3.0.1',
  234. '3.0.2',
  235. '4.0.0',
  236. '4.1.0',
  237. '5.0.0',
  238. '5.1.0',
  239. '5.2.0',
  240. '5.2.1',
  241. '5.3.0',
  242. '6.0.0',
  243. '6.1.0',
  244. '6.1.1',
  245. '6.1.2',
  246. ),
  247. git_url='https://github.com/fmtlib/fmt.git',
  248. auto_lib='fmt/fmt',
  249. description='A modern formatting library : https://fmt.dev/',
  250. ),
  251. ]
  252. data = {
  253. 'version': 1,
  254. 'packages': {
  255. pkg.name: {ver.version: ver.to_dict()
  256. for ver in pkg.versions}
  257. for pkg in packages
  258. }
  259. }
  260. print(json.dumps(data, indent=2, sort_keys=True))