@verdaccio/ui-components 4.0.0-next-8.2 → 4.0.0-next-8.3

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 (274) hide show
  1. package/.babelrc +9 -1
  2. package/CHANGELOG.md +2 -273
  3. package/build/AppTest/AppRoute.js +18 -27
  4. package/build/AppTest/pages/Front/Home.js +2 -8
  5. package/build/AppTest/pages/Front/index.js +1 -13
  6. package/build/AppTest/pages/Version/Version.js +15 -19
  7. package/build/AppTest/pages/Version/index.js +1 -13
  8. package/build/Theme/ResetStyles.js +10 -16
  9. package/build/Theme/StyleBaseline.js +6 -13
  10. package/build/Theme/ThemeProvider.js +25 -33
  11. package/build/Theme/colors.js +1 -7
  12. package/build/Theme/index.js +5 -44
  13. package/build/Theme/theme.js +26 -32
  14. package/build/components/ActionBar/ActionBar.js +26 -33
  15. package/build/components/ActionBar/ActionBarAction.js +59 -59
  16. package/build/components/ActionBar/index.js +1 -13
  17. package/build/components/Author/Author.js +17 -23
  18. package/build/components/Author/index.js +1 -13
  19. package/build/components/Author/styles.js +5 -12
  20. package/build/components/CopyClipboard/CopyToClipBoard.js +40 -40
  21. package/build/components/CopyClipboard/index.js +2 -20
  22. package/build/components/CopyClipboard/utils.js +1 -8
  23. package/build/components/Dependencies/Dependencies.js +27 -34
  24. package/build/components/Dependencies/DependencyBlock.js +29 -35
  25. package/build/components/Dependencies/index.js +1 -13
  26. package/build/components/Dependencies/types.js +1 -5
  27. package/build/components/Dependencies/utits.js +1 -7
  28. package/build/components/Deprecated/Deprecated.js +10 -16
  29. package/build/components/Deprecated/index.js +1 -13
  30. package/build/components/Developers/DeveloperType.js +1 -7
  31. package/build/components/Developers/Developers.js +29 -37
  32. package/build/components/Developers/Title.js +26 -29
  33. package/build/components/Developers/get-unique-developer-values.js +1 -7
  34. package/build/components/Developers/index.js +2 -20
  35. package/build/components/Distribution/Dist.js +29 -32
  36. package/build/components/Distribution/index.js +1 -13
  37. package/build/components/Distribution/styles.js +7 -14
  38. package/build/components/Engines/Engines.js +53 -54
  39. package/build/components/Engines/index.js +1 -13
  40. package/build/components/Engines/styles.js +5 -12
  41. package/build/components/ErrorBoundary/ErrorBoundary.js +5 -14
  42. package/build/components/ErrorBoundary/index.js +1 -13
  43. package/build/components/Forbidden/Forbidden.js +33 -35
  44. package/build/components/Forbidden/index.js +1 -13
  45. package/build/components/FundButton/FundButton.js +42 -41
  46. package/build/components/FundButton/index.js +1 -13
  47. package/build/components/HeaderInfoDialog/HeaderInfoDialog.js +39 -41
  48. package/build/components/HeaderInfoDialog/index.js +1 -13
  49. package/build/components/Heading/Heading.js +12 -17
  50. package/build/components/Heading/index.js +1 -13
  51. package/build/components/Help/Help.js +23 -31
  52. package/build/components/Help/index.js +1 -13
  53. package/build/components/Help/styles.js +3 -10
  54. package/build/components/Icons/DevsIcons/CommonJS.js +4 -11
  55. package/build/components/Icons/DevsIcons/ES6Module.js +4 -11
  56. package/build/components/Icons/DevsIcons/Git.js +4 -11
  57. package/build/components/Icons/DevsIcons/NodeJS.js +4 -11
  58. package/build/components/Icons/DevsIcons/TypeScript.js +4 -11
  59. package/build/components/Icons/DevsIcons/index.js +5 -40
  60. package/build/components/Icons/Earth.js +13 -19
  61. package/build/components/Icons/FileBinary.js +6 -12
  62. package/build/components/Icons/Law.js +6 -12
  63. package/build/components/Icons/License.js +7 -13
  64. package/build/components/Icons/License.js.map +1 -1
  65. package/build/components/Icons/Managers/Npm.js +4 -11
  66. package/build/components/Icons/Managers/Pnpm.js +4 -11
  67. package/build/components/Icons/Managers/Yarn.js +4 -11
  68. package/build/components/Icons/Managers/index.js +3 -26
  69. package/build/components/Icons/SvgIcon.js +27 -23
  70. package/build/components/Icons/Time.js +8 -14
  71. package/build/components/Icons/Version.js +6 -12
  72. package/build/components/Icons/index.js +8 -79
  73. package/build/components/Install/Install.js +32 -39
  74. package/build/components/Install/InstallListItem.js +47 -52
  75. package/build/components/Install/index.js +1 -13
  76. package/build/components/Keywords/KeywordListItems.js +11 -17
  77. package/build/components/Keywords/Keywords.js +20 -25
  78. package/build/components/Keywords/index.js +1 -13
  79. package/build/components/Label/Label.js +17 -18
  80. package/build/components/Label/index.js +1 -13
  81. package/build/components/Link/Link.js +16 -22
  82. package/build/components/Link/index.js +1 -13
  83. package/build/components/LinkExternal/LinkExternal.js +15 -19
  84. package/build/components/LinkExternal/index.js +1 -13
  85. package/build/components/Loading/Loading.js +8 -15
  86. package/build/components/Loading/Spinner/Spinner.js +41 -35
  87. package/build/components/Loading/Spinner/index.js +1 -13
  88. package/build/components/Loading/index.js +1 -13
  89. package/build/components/Loading/styles.js +15 -19
  90. package/build/components/LoginDialog/LoginDialog.js +72 -68
  91. package/build/components/LoginDialog/LoginDialogCloseButton.js +28 -31
  92. package/build/components/LoginDialog/LoginDialogForm.js +46 -45
  93. package/build/components/LoginDialog/LoginDialogFormError.js +34 -36
  94. package/build/components/LoginDialog/LoginDialogHeader.js +42 -42
  95. package/build/components/LoginDialog/index.js +1 -13
  96. package/build/components/Logo/Logo.js +44 -47
  97. package/build/components/Logo/index.js +1 -13
  98. package/build/components/MenuItem/MenuItem.js +7 -16
  99. package/build/components/MenuItem/index.js +1 -13
  100. package/build/components/NoItems/NoItems.js +16 -17
  101. package/build/components/NoItems/index.js +1 -13
  102. package/build/components/NotFound/NotFound.js +31 -35
  103. package/build/components/NotFound/index.js +1 -13
  104. package/build/components/Package/Package.js +105 -100
  105. package/build/components/Package/index.js +1 -20
  106. package/build/components/Package/styles.js +78 -73
  107. package/build/components/PackageList/PackageList.js +56 -57
  108. package/build/components/PackageList/index.js +1 -13
  109. package/build/components/Person/Person.js +22 -28
  110. package/build/components/Person/PersonTooltip.js +17 -21
  111. package/build/components/Person/index.js +1 -13
  112. package/build/components/Person/utils.js +6 -14
  113. package/build/components/RawViewer/RawViewer.js +27 -33
  114. package/build/components/RawViewer/index.js +1 -13
  115. package/build/components/Readme/Readme.js +21 -27
  116. package/build/components/Readme/Readme.js.map +1 -1
  117. package/build/components/Readme/Readme.spec.js +10 -13
  118. package/build/components/Readme/Readme.spec.js.map +1 -1
  119. package/build/components/Readme/index.js +1 -13
  120. package/build/components/Readme/types.js +1 -5
  121. package/build/components/Readme/utils.js +8 -16
  122. package/build/components/RegistryInfoDialog/RegistryInfoDialog.js +18 -24
  123. package/build/components/RegistryInfoDialog/index.js +1 -13
  124. package/build/components/RegistryInfoDialog/styles.js +34 -32
  125. package/build/components/RegistryInfoDialog/types.js +1 -5
  126. package/build/components/Repository/Repository.js +36 -41
  127. package/build/components/Repository/index.js +1 -13
  128. package/build/components/Search/AutoComplete/AutoComplete.js +22 -31
  129. package/build/components/Search/AutoComplete/index.js +1 -13
  130. package/build/components/Search/AutoComplete/styles.js +2 -9
  131. package/build/components/Search/Search.js +71 -69
  132. package/build/components/Search/SearchItem.js +87 -79
  133. package/build/components/Search/index.js +1 -13
  134. package/build/components/Search/styles.js +7 -14
  135. package/build/components/Search/utils.js +3 -9
  136. package/build/components/SettingsMenu/SettingsMenu.js +56 -57
  137. package/build/components/SettingsMenu/index.js +1 -13
  138. package/build/components/SideBarTitle/SideBarTitle.js +52 -51
  139. package/build/components/SideBarTitle/index.js +1 -13
  140. package/build/components/SideBarTitle/utils.js +6 -15
  141. package/build/components/TextField/TextField.js +22 -21
  142. package/build/components/TextField/index.js +1 -13
  143. package/build/components/UpLinks/UpLinks.js +32 -38
  144. package/build/components/UpLinks/UplinkLink.js +12 -18
  145. package/build/components/UpLinks/index.js +1 -13
  146. package/build/components/UpLinks/styles.js +28 -29
  147. package/build/components/Versions/HistoryList.js +56 -60
  148. package/build/components/Versions/TagList.js +29 -33
  149. package/build/components/Versions/Versions.js +44 -52
  150. package/build/components/Versions/index.js +1 -13
  151. package/build/components/Versions/styles.js +26 -27
  152. package/build/components/Versions/types.js +1 -5
  153. package/build/hooks/index.js +2 -20
  154. package/build/hooks/useLocalStorage.js +7 -12
  155. package/build/hooks/useOnClickOutside.js +4 -9
  156. package/build/index.js +63 -530
  157. package/build/layouts/Version/Version.js +9 -16
  158. package/build/layouts/Version/index.js +1 -13
  159. package/build/providers/AppConfigurationProvider/AppConfigurationProvider.js +24 -31
  160. package/build/providers/AppConfigurationProvider/index.js +1 -20
  161. package/build/providers/PersistenceSettingProvider/PersistenceSettingProvider.js +15 -24
  162. package/build/providers/PersistenceSettingProvider/index.js +1 -20
  163. package/build/providers/TranslatorProvider/TranslatorProvider.js +24 -30
  164. package/build/providers/TranslatorProvider/TranslatorProvider.spec.js +19 -22
  165. package/build/providers/TranslatorProvider/index.js +1 -26
  166. package/build/providers/VersionProvider/VersionProvider.js +27 -29
  167. package/build/providers/VersionProvider/index.js +1 -20
  168. package/build/providers/index.js +3 -38
  169. package/build/sections/Detail/ContainerContent.js +20 -28
  170. package/build/sections/Detail/Detail.js +22 -30
  171. package/build/sections/Detail/ReadmeSection.js +8 -14
  172. package/build/sections/Detail/Tabs.js +20 -26
  173. package/build/sections/Detail/index.js +1 -13
  174. package/build/sections/Footer/Footer.js +73 -70
  175. package/build/sections/Footer/index.js +1 -13
  176. package/build/sections/Footer/styles.js +62 -57
  177. package/build/sections/Header/Header.js +34 -42
  178. package/build/sections/Header/HeaderGreetings.js +12 -18
  179. package/build/sections/Header/HeaderLeft.js +25 -29
  180. package/build/sections/Header/HeaderMenu.js +23 -29
  181. package/build/sections/Header/HeaderRight.js +41 -49
  182. package/build/sections/Header/HeaderSettingsDialog.js +60 -58
  183. package/build/sections/Header/HeaderToolTip.js +13 -17
  184. package/build/sections/Header/HeaderToolTipIcon.js +23 -31
  185. package/build/sections/Header/LanguageSwitch.js +51 -54
  186. package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.js +75 -80
  187. package/build/sections/Header/RegistryInfoContent/index.js +1 -13
  188. package/build/sections/Header/RegistryInfoContent/styles.js +12 -16
  189. package/build/sections/Header/index.js +1 -13
  190. package/build/sections/Header/styles.js +32 -36
  191. package/build/sections/Home/Home.js +14 -19
  192. package/build/sections/Home/index.js +1 -13
  193. package/build/sections/SideBar/Sidebar.js +40 -47
  194. package/build/sections/SideBar/index.js +1 -13
  195. package/build/sections/index.js +2 -20
  196. package/build/src/Theme/index.d.ts +1 -1
  197. package/build/store/api.js +28 -29
  198. package/build/store/index.js +3 -51
  199. package/build/store/models/configuration.js +20 -22
  200. package/build/store/models/download.js +26 -27
  201. package/build/store/models/index.js +13 -19
  202. package/build/store/models/login.js +60 -63
  203. package/build/store/models/manifest.js +57 -58
  204. package/build/store/models/packages.js +29 -27
  205. package/build/store/models/routes.js +1 -7
  206. package/build/store/models/search.js +62 -61
  207. package/build/store/models/utils.js +1 -7
  208. package/build/store/storage.js +4 -11
  209. package/build/store/store.js +6 -13
  210. package/build/test/i18n-config.js +4 -11
  211. package/build/test/test-react-testing-library.js +32 -50
  212. package/build/types/index.js +1 -5
  213. package/build/types/packageMeta.js +1 -5
  214. package/build/utils/__partials__/packageMeta.js +1 -7
  215. package/build/utils/cli-utils.js +12 -32
  216. package/build/utils/index.js +8 -74
  217. package/build/utils/loadable.js +6 -14
  218. package/build/utils/routes.js +1 -7
  219. package/build/utils/token.js +11 -18
  220. package/build/utils/url.js +12 -22
  221. package/build/utils/utils.js +32 -46
  222. package/package.json +11 -9
  223. package/src/AppTest/AppRoute.test.tsx +5 -4
  224. package/src/Theme/index.ts +1 -1
  225. package/src/components/Author/Author.test.tsx +2 -1
  226. package/src/components/CopyClipboard/CopyToClipBoard.test.tsx +2 -1
  227. package/src/components/Dependencies/Dependencies.test.tsx +7 -0
  228. package/src/components/Dependencies/DependencyBlock.test.tsx +3 -2
  229. package/src/components/Engines/Engines.test.tsx +3 -2
  230. package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +2 -1
  231. package/src/components/Forbidden/Forbidden.test.tsx +3 -2
  232. package/src/components/HeaderInfoDialog/HeaderInfoDialog.test.tsx +2 -1
  233. package/src/components/LoginDialog/LoginDialog.test.tsx +8 -7
  234. package/src/components/NotFound/Notfound.test.tsx +3 -2
  235. package/src/components/PackageList/Packagelist.test.tsx +2 -1
  236. package/src/components/Search/Search.test.tsx +9 -8
  237. package/src/components/Versions/Versions.test.tsx +8 -8
  238. package/src/providers/TranslatorProvider/TranslatorProvider.spec.tsx +2 -1
  239. package/src/providers/VersionProvider/VersionProvider.tsx +5 -2
  240. package/src/sections/Home/Home.test.tsx +7 -3
  241. package/src/sections/SideBar/Sidebar.test.tsx +8 -7
  242. package/src/sections/SideBar/Sidebar.tsx +1 -0
  243. package/src/store/api.test.ts +8 -6
  244. package/src/store/models/login.test.ts +24 -20
  245. package/src/test/test-react-testing-library.tsx +3 -5
  246. package/src/utils/cli-utils.test.ts +10 -9
  247. package/src/utils/token.test.ts +5 -3
  248. package/tsconfig.build.json +1 -1
  249. package/vitest/api/glob-sidebar.json +12520 -0
  250. package/vitest/api/got-sidebar.json +23346 -0
  251. package/vitest/api/home-packages.json +40 -0
  252. package/vitest/api/jquery-readme.js +3 -0
  253. package/vitest/api/jquery-sidebar.json +5908 -0
  254. package/vitest/api/search-verdaccio.json +1192 -0
  255. package/vitest/api/storybook-readme.js +3 -0
  256. package/vitest/api/storybook-sidebar.json +53782 -0
  257. package/vitest/api/storybook-v.json +53782 -0
  258. package/vitest/identity.js +29 -0
  259. package/vitest/react-markdown.tsx +7 -0
  260. package/vitest/server-handlers.ts +82 -0
  261. package/vitest/server.ts +6 -0
  262. package/vitest/setup-env.ts +33 -0
  263. package/vitest/setup.ts +40 -0
  264. package/vitest/unit/components/__mocks__/token.ts +33 -0
  265. package/vitest/unit/empty-string.ts +1 -0
  266. package/vitest/unit/empty.ts +1 -0
  267. package/vitest/vitestSerializer.ts +31 -0
  268. package/vitest.config.mjs +39 -0
  269. package/build/__mocks__/react-markdown.js +0 -18
  270. package/build/__mocks__/remark-plugin.js +0 -8
  271. package/build/src/__mocks__/react-markdown.d.ts +0 -4
  272. package/build/src/__mocks__/remark-plugin.d.ts +0 -1
  273. package/src/__mocks__/react-markdown.tsx +0 -8
  274. package/src/__mocks__/remark-plugin.ts +0 -1
@@ -1,35 +1,28 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isTokenExpire = isTokenExpire;
7
- var _jsBase = require("js-base64");
8
- var _isNumber = _interopRequireDefault(require("lodash/isNumber"));
9
- var _isString = _interopRequireDefault(require("lodash/isString"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- function isTokenExpire(token) {
12
- if (!(0, _isString.default)(token)) {
1
+ import { Base64 } from 'js-base64';
2
+ import isNumber from 'lodash/isNumber';
3
+ import isString from 'lodash/isString';
4
+ export function isTokenExpire(token) {
5
+ if (!isString(token)) {
13
6
  return true;
14
7
  }
15
- const [, payload] = token.split('.');
8
+ var [, payload] = token.split('.');
16
9
  if (!payload) {
17
10
  return true;
18
11
  }
19
- let exp;
12
+ var exp;
20
13
  try {
21
- exp = JSON.parse(_jsBase.Base64.decode(payload)).exp;
14
+ exp = JSON.parse(Base64.decode(payload)).exp;
22
15
  } catch (error) {
23
16
  // eslint-disable-next-line no-console
24
17
  console.error('Invalid token:', error, token);
25
18
  return true;
26
19
  }
27
- if (!exp || !(0, _isNumber.default)(exp)) {
20
+ if (!exp || !isNumber(exp)) {
28
21
  return true;
29
22
  }
30
23
  // Report as expire before (real expire time - 30s)
31
- const jsTimestamp = exp * 1000 - 30000;
32
- const expired = Date.now() >= jsTimestamp;
24
+ var jsTimestamp = exp * 1000 - 30000;
25
+ var expired = Date.now() >= jsTimestamp;
33
26
  return expired;
34
27
  }
35
28
  //# sourceMappingURL=token.js.map
@@ -1,37 +1,27 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.downloadFile = downloadFile;
7
- exports.extractFileName = extractFileName;
8
- exports.isEmail = isEmail;
9
- exports.isURL = isURL;
10
- var _isEmail = _interopRequireDefault(require("validator/lib/isEmail"));
11
- var _isURL = _interopRequireDefault(require("validator/lib/isURL"));
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- function isURL(url) {
14
- return (0, _isURL.default)(url || '', {
1
+ import isEmailValidator from 'validator/lib/isEmail';
2
+ import isURLValidator from 'validator/lib/isURL';
3
+ export function isURL(url) {
4
+ return isURLValidator(url || '', {
15
5
  protocols: ['http', 'https', 'git+https', 'git'],
16
6
  require_protocol: true,
17
7
  require_tld: false
18
8
  });
19
9
  }
20
- function isEmail(email) {
21
- return (0, _isEmail.default)(email || '');
10
+ export function isEmail(email) {
11
+ return isEmailValidator(email || '');
22
12
  }
23
- function extractFileName(url) {
13
+ export function extractFileName(url) {
24
14
  return url.substring(url.lastIndexOf('/') + 1);
25
15
  }
26
16
  function blobToFile(blob, fileName) {
27
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- const b = blob;
18
+ var b = blob;
29
19
  b.lastModified = Date.now();
30
20
  b.name = fileName;
31
21
  return b;
32
22
  }
33
- function downloadFile(fileStream, fileName) {
34
- let file;
23
+ export function downloadFile(fileStream, fileName) {
24
+ var file;
35
25
  // File constructor is not supported by Edge
36
26
  // https://developer.mozilla.org/en-US/docs/Web/API/File#Browser_compatibility
37
27
  // @ts-ignore. Please see: https://github.com/microsoft/TypeScript/issues/33792
@@ -46,8 +36,8 @@ function downloadFile(fileStream, fileName) {
46
36
  lastModified: Date.now()
47
37
  });
48
38
  }
49
- const objectURL = URL.createObjectURL(file);
50
- const fileLink = document.createElement('a');
39
+ var objectURL = URL.createObjectURL(file);
40
+ var fileLink = document.createElement('a');
51
41
  fileLink.href = objectURL;
52
42
  fileLink.download = fileName;
53
43
 
@@ -1,27 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TIMEFORMAT = void 0;
7
- exports.fileSizeSI = fileSizeSI;
8
- exports.formatDate = formatDate;
9
- exports.formatDateDistance = formatDateDistance;
10
- exports.formatLicense = formatLicense;
11
- exports.formatRepository = formatRepository;
12
- exports.getAuthorName = getAuthorName;
13
- exports.getLastUpdatedPackageTime = getLastUpdatedPackageTime;
14
- exports.getRecentReleases = getRecentReleases;
15
- exports.getUplink = getUplink;
16
- var _dayjs = _interopRequireDefault(require("dayjs"));
17
- var _localizedFormat = _interopRequireDefault(require("dayjs/plugin/localizedFormat"));
18
- var _relativeTime = _interopRequireDefault(require("dayjs/plugin/relativeTime"));
19
- var _i18next = _interopRequireDefault(require("i18next"));
20
- var _isString = _interopRequireDefault(require("lodash/isString"));
21
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
- const TIMEFORMAT = exports.TIMEFORMAT = 'L LTS';
23
- _dayjs.default.extend(_relativeTime.default);
24
- _dayjs.default.extend(_localizedFormat.default);
1
+ import dayjs from 'dayjs';
2
+ import localizedFormat from 'dayjs/plugin/localizedFormat';
3
+ import relativeTime from 'dayjs/plugin/relativeTime';
4
+ import i18next from 'i18next';
5
+ import isString from 'lodash/isString';
6
+ export var TIMEFORMAT = 'L LTS';
7
+ dayjs.extend(relativeTime);
8
+ dayjs.extend(localizedFormat);
25
9
 
26
10
  /**
27
11
  * Formats license field for webui.
@@ -29,11 +13,11 @@ _dayjs.default.extend(_localizedFormat.default);
29
13
  */
30
14
  // License should use type License defined above, but conflicts with the unit test that provide array or empty object
31
15
  /* eslint-disable @typescript-eslint/no-explicit-any */
32
- function formatLicense(license) {
33
- if ((0, _isString.default)(license)) {
16
+ export function formatLicense(license) {
17
+ if (isString(license)) {
34
18
  return license;
35
19
  }
36
- if (license?.type) {
20
+ if (license !== null && license !== void 0 && license.type) {
37
21
  return license.type;
38
22
  }
39
23
  return;
@@ -45,30 +29,31 @@ function formatLicense(license) {
45
29
 
46
30
  // Repository should use type Repository defined above, but conflicts with the unit test that provide array or empty object
47
31
  /* eslint-disable @typescript-eslint/no-explicit-any */
48
- function formatRepository(repository) {
49
- if ((0, _isString.default)(repository)) {
32
+ export function formatRepository(repository) {
33
+ if (isString(repository)) {
50
34
  return repository;
51
35
  }
52
- if (repository?.url) {
36
+ if (repository !== null && repository !== void 0 && repository.url) {
53
37
  return repository.url;
54
38
  }
55
39
  return null;
56
40
  }
57
- function formatDate(lastUpdate) {
58
- return (0, _dayjs.default)(new Date(lastUpdate)).format(TIMEFORMAT);
41
+ export function formatDate(lastUpdate) {
42
+ return dayjs(new Date(lastUpdate)).format(TIMEFORMAT);
59
43
  }
60
- function formatDateDistance(lastUpdate) {
61
- return (0, _dayjs.default)(new Date(lastUpdate)).fromNow();
44
+ export function formatDateDistance(lastUpdate) {
45
+ return dayjs(new Date(lastUpdate)).fromNow();
62
46
  }
63
47
 
64
48
  /**
65
49
  * For <LastSync /> component
66
50
  * @param {array} uplinks
67
51
  */
68
- function getLastUpdatedPackageTime(uplinks = {}) {
69
- let lastUpdate = 0;
52
+ export function getLastUpdatedPackageTime() {
53
+ var uplinks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
54
+ var lastUpdate = 0;
70
55
  Object.keys(uplinks).forEach(function computeUplink(upLinkName) {
71
- const status = uplinks[upLinkName];
56
+ var status = uplinks[upLinkName];
72
57
  if (status.fetched > lastUpdate) {
73
58
  lastUpdate = status.fetched;
74
59
  }
@@ -81,36 +66,37 @@ function getLastUpdatedPackageTime(uplinks = {}) {
81
66
  * @param {Object} time
82
67
  * @returns {Array} last 3 releases
83
68
  */
84
- function getRecentReleases(time = {}) {
85
- const recent = Object.keys(time).map(version => ({
69
+ export function getRecentReleases() {
70
+ var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
71
+ var recent = Object.keys(time).map(version => ({
86
72
  version,
87
73
  time: formatDate(time[version])
88
74
  }));
89
75
  return recent.slice(recent.length - 3, recent.length).reverse();
90
76
  }
91
- function getAuthorName(authorName) {
77
+ export function getAuthorName(authorName) {
92
78
  if (!authorName) {
93
- return _i18next.default.t('author-unknown');
79
+ return i18next.t('author-unknown');
94
80
  }
95
81
  if (authorName.toLowerCase() === 'anonymous') {
96
- return _i18next.default.t('author-anonymous');
82
+ return i18next.t('author-anonymous');
97
83
  }
98
84
  return authorName;
99
85
  }
100
- function getUplink(upLinkName, packageName) {
86
+ export function getUplink(upLinkName, packageName) {
101
87
  // TODO: make this a config like "uplinks: npmjs: web: https://www.npmjs.com/package/"
102
88
  switch (upLinkName) {
103
89
  case 'npmjs':
104
- return `https://www.npmjs.com/package/${packageName}`;
90
+ return "https://www.npmjs.com/package/".concat(packageName);
105
91
  }
106
92
  return null;
107
93
  }
108
- function fileSizeSI(a, b, c, d, e) {
94
+ export function fileSizeSI(a, b, c, d, e) {
109
95
  b = Math;
110
96
  c = b.log;
111
97
  d = 1e3;
112
98
  e = c(a) / c(d) | 0;
113
- let size = a / b.pow(d, e);
99
+ var size = a / b.pow(d, e);
114
100
  // no decimals for Bytes
115
101
  if (e === 0) {
116
102
  return Math.floor(size) + ' Bytes';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/ui-components",
3
- "version": "4.0.0-next-8.2",
3
+ "version": "4.0.0-next-8.3",
4
4
  "description": "theme ui component",
5
5
  "author": "Juan Picado <juanpicado19@gmail.com>",
6
6
  "license": "MIT",
@@ -8,8 +8,8 @@
8
8
  "main": "./build/index.js",
9
9
  "types": "build/index.d.ts",
10
10
  "dependencies": {
11
- "@emotion/react": "11.10.6",
12
- "@emotion/styled": "11.10.6",
11
+ "@emotion/react": "11.11.4",
12
+ "@emotion/styled": "11.11.5",
13
13
  "@fontsource/material-icons": "^4.5.4",
14
14
  "@fontsource/roboto": "^4.5.8",
15
15
  "@microlink/react-json-view": "^1.23.3",
@@ -48,7 +48,6 @@
48
48
  "devDependencies": {
49
49
  "@babel/core": "7.24.9",
50
50
  "@emotion/babel-plugin": "11.12.0",
51
- "@emotion/jest": "11.13.0",
52
51
  "@storybook/addon-actions": "^6.5.15",
53
52
  "@storybook/addon-essentials": "^6.5.15",
54
53
  "@storybook/addon-interactions": "^6.5.15",
@@ -56,25 +55,28 @@
56
55
  "@storybook/builder-webpack5": "^6.5.15",
57
56
  "@storybook/manager-webpack5": "^6.5.15",
58
57
  "@storybook/react": "^6.5.15",
59
- "@storybook/testing-library": "^0.2.0",
60
58
  "@testing-library/dom": "10.4.0",
61
59
  "@testing-library/jest-dom": "6.4.8",
62
60
  "@testing-library/react": "16.0.0",
63
61
  "@types/hast": "^2.0.0",
64
62
  "@types/react-router": "^5.1.20",
65
63
  "@types/unist": "^2.0.0",
66
- "@verdaccio/types": "13.0.0-next-8.1",
64
+ "@verdaccio/types": "13.0.0-next-8.2",
65
+ "@vitejs/plugin-react": "^4.3.4",
66
+ "jsdom": "^24.0.0",
67
67
  "babel-loader": "9.1.3",
68
68
  "mockdate": "3.0.5",
69
+ "mutationobserver-shim": "0.3.7",
69
70
  "msw": "0.49.3",
70
- "typescript": "4.9.5"
71
+ "typescript": "4.9.5",
72
+ "vitest": "2.1.2",
73
+ "whatwg-fetch": "3.6.20"
71
74
  },
72
75
  "msw": {
73
76
  "workerDirectory": "public"
74
77
  },
75
78
  "scripts": {
76
- "test": "cross-env TZ=UTC jest --config jest/jest.config.js",
77
- "test:html": "cross-env TZ=UTC jest --config jest/jest.config.js --coverage-reporters=html",
79
+ "test": "cross-env TZ=UTC vitest run",
78
80
  "clean": "rimraf ./build",
79
81
  "type-check": "tsc --noEmit -p tsconfig.build.json",
80
82
  "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { MemoryRouter } from 'react-router';
3
+ import { vi } from 'vitest';
3
4
 
4
5
  import { store } from '../';
5
6
  import { act, renderWithStore, screen, waitFor } from '../test/test-react-testing-library';
@@ -7,8 +8,8 @@ import AppRoute from './AppRoute';
7
8
 
8
9
  // force the windows to expand to display items
9
10
  // https://github.com/bvaughn/react-virtualized/issues/493#issuecomment-640084107
10
- jest.spyOn(HTMLElement.prototype, 'offsetHeight', 'get').mockReturnValue(600);
11
- jest.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(600);
11
+ vi.spyOn(HTMLElement.prototype, 'offsetHeight', 'get').mockReturnValue(600);
12
+ vi.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(600);
12
13
 
13
14
  function appTest(path: string) {
14
15
  renderWithStore(
@@ -19,10 +20,10 @@ function appTest(path: string) {
19
20
  );
20
21
  }
21
22
 
22
- // See jest/server-handlers.ts for test routes
23
+ // See vi/server-handlers.ts for test routes
23
24
  describe('AppRoute', () => {
24
25
  afterEach(() => {
25
- jest.clearAllMocks();
26
+ vi.clearAllMocks();
26
27
  });
27
28
 
28
29
  test('renders Front component for ROOT path', async () => {
@@ -1,4 +1,4 @@
1
1
  export * as colors from './colors';
2
2
  export { ThemeProvider, useCustomTheme } from './ThemeProvider';
3
3
  export { default as StyleBaseline } from './StyleBaseline';
4
- export { Theme, FontWeight } from './theme';
4
+ export { Theme, FontWeight, getTheme } from './theme';
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { vi } from 'vitest';
2
3
 
3
4
  import { cleanup, render, screen } from '../../test/test-react-testing-library';
4
5
  import { PackageMetaInterface } from '../../types/packageMeta';
@@ -10,7 +11,7 @@ const withAuthorComponent = (packageMeta: PackageMetaInterface): JSX.Element =>
10
11
 
11
12
  describe('<Author /> component', () => {
12
13
  beforeEach(() => {
13
- jest.resetAllMocks();
14
+ vi.resetAllMocks();
14
15
  cleanup();
15
16
  });
16
17
 
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
+ import { vi } from 'vitest';
2
3
 
3
4
  import { fireEvent, render, screen } from '../../test/test-react-testing-library';
4
5
  import CopyToClipBoard from './CopyToClipBoard';
5
6
 
6
7
  Object.assign(navigator, {
7
- clipboard: { writeText: jest.fn().mockImplementation(() => Promise.resolve()) },
8
+ clipboard: { writeText: vi.fn().mockImplementation(() => Promise.resolve()) },
8
9
  });
9
10
 
10
11
  describe('CopyToClipBoard component', () => {
@@ -1,9 +1,16 @@
1
1
  import React from 'react';
2
2
  import { HashRouter } from 'react-router-dom';
3
+ import { vi } from 'vitest';
3
4
 
4
5
  import { render, screen } from '../../test/test-react-testing-library';
5
6
  import Dependencies from './Dependencies';
6
7
 
8
+ const replaceMock = vi.fn(() => []);
9
+ Object.defineProperty(window, 'location', {
10
+ writable: true,
11
+ value: { ...window.location, replace: replaceMock, href: '' },
12
+ });
13
+
7
14
  describe('<Dependencies /> component', () => {
8
15
  test('Renders a message when there are no dependencies', () => {
9
16
  const packageMeta = {
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import { MemoryRouter, Route } from 'react-router';
3
+ import { vi } from 'vitest';
3
4
 
4
5
  import { fireEvent, render, screen } from '../../test/test-react-testing-library';
5
6
  import { DependencyBlock } from './DependencyBlock';
6
7
 
7
- const mockHistory = jest.fn();
8
+ const mockHistory = vi.fn();
8
9
 
9
- jest.mock('react-router-dom', () => ({
10
+ vi.mock('react-router-dom', () => ({
10
11
  useHistory: () => ({
11
12
  push: mockHistory,
12
13
  }),
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
+ import { vi } from 'vitest';
2
3
 
3
4
  import { cleanup, render } from '../../test/test-react-testing-library';
4
5
  import { PackageMetaInterface } from '../../types/packageMeta';
5
6
  import Engine from './Engines';
6
7
 
7
- jest.mock('./img/node.png', () => '');
8
- jest.mock('../Install/img/npm.svg', () => '');
8
+ vi.mock('./img/node.png', () => '');
9
+ vi.mock('../Install/img/npm.svg', () => '');
9
10
 
10
11
  const mockPackageMeta = (
11
12
  engines?: PackageMetaInterface['latest']['engines']
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { vi } from 'vitest';
2
3
 
3
4
  import { render, screen } from '../../test/test-react-testing-library';
4
5
  import ErrorBoundary from './ErrorBoundary';
@@ -20,7 +21,7 @@ describe('ErrorBoundary component', () => {
20
21
  };
21
22
 
22
23
  // Suppress error messages for this test
23
- const spy = jest.spyOn(console, 'error');
24
+ const spy = vi.spyOn(console, 'error');
24
25
  spy.mockImplementation(() => {});
25
26
 
26
27
  render(
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import { MemoryRouter } from 'react-router';
3
+ import { vi } from 'vitest';
3
4
 
4
5
  import { fireEvent, render, screen } from '../../test/test-react-testing-library';
5
6
  import Forbidden from './Forbidden';
6
7
 
7
- const mockHistory = jest.fn();
8
+ const mockHistory = vi.fn();
8
9
 
9
- jest.mock('react-router-dom', () => ({
10
+ vi.mock('react-router-dom', () => ({
10
11
  useHistory: () => ({
11
12
  push: mockHistory,
12
13
  }),
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
+ import { vi } from 'vitest';
2
3
 
3
4
  import { fireEvent, render, screen } from '../../test/test-react-testing-library';
4
5
  import HeaderInfoDialog from './HeaderInfoDialog';
5
6
 
6
7
  describe('HeaderInfoDialog', () => {
7
- const onCloseDialog = jest.fn();
8
+ const onCloseDialog = vi.fn();
8
9
 
9
10
  const tabs = [{ label: 'Tab 1' }, { label: 'Tab 2' }];
10
11
 
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { vi } from 'vitest';
2
3
 
3
4
  import { api, store } from '../../';
4
5
  import {
@@ -13,14 +14,14 @@ import LoginDialog from './LoginDialog';
13
14
 
14
15
  describe('<LoginDialog /> component', () => {
15
16
  beforeEach(() => {
16
- jest.resetModules();
17
- jest.resetAllMocks();
17
+ vi.resetModules();
18
+ vi.resetAllMocks();
18
19
  cleanup();
19
20
  });
20
21
 
21
22
  test('should render the component in default state', () => {
22
23
  const props = {
23
- onClose: jest.fn(),
24
+ onClose: vi.fn(),
24
25
  };
25
26
  const { container } = renderWithStore(<LoginDialog onClose={props.onClose} />, store);
26
27
  expect(container.firstChild).toMatchSnapshot();
@@ -29,7 +30,7 @@ describe('<LoginDialog /> component', () => {
29
30
  test('should load the component with the open prop', async () => {
30
31
  const props = {
31
32
  open: true,
32
- onClose: jest.fn(),
33
+ onClose: vi.fn(),
33
34
  };
34
35
 
35
36
  const { getByTestId } = renderWithStore(
@@ -44,7 +45,7 @@ describe('<LoginDialog /> component', () => {
44
45
  test('onClose: should close the login modal', async () => {
45
46
  const props = {
46
47
  open: true,
47
- onClose: jest.fn(),
48
+ onClose: vi.fn(),
48
49
  };
49
50
 
50
51
  const { getByTestId } = renderWithStore(
@@ -65,10 +66,10 @@ describe('<LoginDialog /> component', () => {
65
66
  test('setCredentials - should set username and password in state', async () => {
66
67
  const props = {
67
68
  open: true,
68
- onClose: jest.fn(),
69
+ onClose: vi.fn(),
69
70
  };
70
71
 
71
- jest.spyOn(api, 'request').mockImplementation(() =>
72
+ vi.spyOn(api, 'request').mockImplementation(() =>
72
73
  Promise.resolve({
73
74
  username: 'xyz',
74
75
  token: 'djsadaskljd',
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import { MemoryRouter } from 'react-router';
3
+ import { vi } from 'vitest';
3
4
 
4
5
  import { fireEvent, render, screen } from '../../test/test-react-testing-library';
5
6
  import NotFound from './NotFound';
6
7
 
7
- const mockHistory = jest.fn();
8
+ const mockHistory = vi.fn();
8
9
 
9
- jest.mock('react-router-dom', () => ({
10
+ vi.mock('react-router-dom', () => ({
10
11
  useHistory: () => ({
11
12
  push: mockHistory,
12
13
  }),
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { BrowserRouter } from 'react-router-dom';
3
+ import { vi } from 'vitest';
3
4
 
4
5
  import { store } from '../../store';
5
6
  import { cleanup, renderWithStore } from '../../test/test-react-testing-library';
@@ -18,7 +19,7 @@ describe('<PackageList /> component', () => {
18
19
 
19
20
  test('should load the component with packages', () => {
20
21
  // Mock <Autosizer /> width
21
- jest.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(600);
22
+ vi.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(600);
22
23
 
23
24
  const props = {
24
25
  packages: [
@@ -1,17 +1,18 @@
1
1
  import React from 'react';
2
2
  import { BrowserRouter as Router } from 'react-router-dom';
3
+ import { vi } from 'vitest';
3
4
 
4
5
  import { api, store } from '../../';
5
6
  import { fireEvent, renderWithStore, screen, waitFor } from '../../test/test-react-testing-library';
6
7
  import Search from './Search';
7
8
  import { cleanDescription } from './utils';
8
9
 
9
- jest.mock('lodash/debounce', () =>
10
- jest.fn((fn) => {
11
- fn.cancel = jest.fn();
12
- return fn;
13
- })
14
- );
10
+ vi.mock('lodash/debounce', () => ({
11
+ default: vi.fn((fn) => {
12
+ // Immediately execute the function for testing
13
+ return (...args: any[]) => fn(...args);
14
+ }),
15
+ }));
15
16
 
16
17
  /* eslint-disable verdaccio/jsx-spread */
17
18
  const ComponentToBeRendered: React.FC = () => (
@@ -22,7 +23,7 @@ const ComponentToBeRendered: React.FC = () => (
22
23
 
23
24
  describe('<Search /> component', () => {
24
25
  beforeEach(() => {
25
- jest.spyOn(api, 'request').mockImplementation(() =>
26
+ vi.spyOn(api, 'request').mockImplementation(() =>
26
27
  Promise.resolve([
27
28
  {
28
29
  name: 'verdaccio-ui/types',
@@ -37,7 +38,7 @@ describe('<Search /> component', () => {
37
38
  });
38
39
 
39
40
  afterEach(() => {
40
- jest.clearAllMocks();
41
+ vi.clearAllMocks();
41
42
  });
42
43
 
43
44
  test('should load the component in default state', () => {
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable verdaccio/jsx-spread */
2
2
  import React from 'react';
3
3
  import { MemoryRouter } from 'react-router-dom';
4
+ import { vi } from 'vitest';
4
5
 
5
6
  import { fireEvent, render, screen } from '../../test/test-react-testing-library';
6
7
  import Versions, { Props } from './Versions';
@@ -13,16 +14,15 @@ const VersionsComponent: React.FC<Props> = (props) => (
13
14
  </MemoryRouter>
14
15
  );
15
16
 
16
- jest.mock('lodash/debounce', () =>
17
- jest.fn((fn) => {
18
- fn.cancel = jest.fn();
19
- return fn;
20
- })
21
- );
22
-
17
+ vi.mock('lodash/debounce', () => ({
18
+ default: vi.fn((fn) => {
19
+ // Immediately execute the function for testing
20
+ return (...args: any[]) => fn(...args);
21
+ }),
22
+ }));
23
23
  describe('<Version /> component', () => {
24
24
  afterEach(() => {
25
- jest.clearAllMocks();
25
+ vi.clearAllMocks();
26
26
  });
27
27
 
28
28
  test('should render versions', () => {
@@ -3,6 +3,7 @@ import i18n from 'i18next';
3
3
  import React from 'react';
4
4
  import { initReactI18next } from 'react-i18next';
5
5
  import { useTranslation } from 'react-i18next';
6
+ import { vi } from 'vitest';
6
7
 
7
8
  import TranslatorProvider, { useLanguage } from './TranslatorProvider';
8
9
 
@@ -41,7 +42,7 @@ const RandomComponent = () => {
41
42
  };
42
43
 
43
44
  test('should provide translation', () => {
44
- const mount = jest.fn();
45
+ const mount = vi.fn();
45
46
  const { getByText } = render(
46
47
  <TranslatorProvider i18n={i18n} listLanguages={[]} onMount={mount}>
47
48
  <RandomComponent />