@verdaccio/ui-theme 3.1.0 → 6.0.0-6-next.11
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/.babelrc +33 -0
- package/.eslintrc +115 -0
- package/.stylelintrc +40 -0
- package/CHANGELOG.md +152 -554
- package/LICENSE +1 -1
- package/README.md +22 -95
- package/config/env.js +9 -0
- package/jest/api/packages.json +42 -0
- package/jest/identity.js +29 -0
- package/jest/jest.config.js +39 -0
- package/jest/jestEnvironment.js +1 -0
- package/jest/server-handlers.ts +9 -0
- package/jest/server.ts +6 -0
- package/jest/setup-env.ts +15 -0
- package/jest/setup.ts +31 -0
- package/jest/unit/components/__mocks__/api.ts +47 -0
- package/jest/unit/components/__mocks__/token.ts +31 -0
- package/jest/unit/components/store/login.ts +23 -0
- package/jest/unit/components/store/logo.ts +7 -0
- package/jest/unit/components/store/package.ts +174 -0
- package/jest/unit/components/store/packageMeta.ts +592 -0
- package/jest/unit/empty.ts +1 -0
- package/lib/constants.ts +9 -0
- package/package.json +153 -228
- package/src/App/App.test.tsx +123 -0
- package/src/App/App.tsx +54 -0
- package/src/App/AppError.tsx +38 -0
- package/src/App/AppRoute.tsx +63 -0
- package/src/App/Footer/Footer.test.tsx +20 -0
- package/src/App/Footer/Footer.tsx +111 -0
- package/src/App/Footer/__snapshots__/Footer.test.tsx.snap +456 -0
- package/src/App/Footer/index.ts +1 -0
- package/src/App/Footer/styles.ts +44 -0
- package/src/App/Header/Header.test.tsx +152 -0
- package/src/App/Header/Header.tsx +74 -0
- package/src/App/Header/HeaderGreetings.tsx +22 -0
- package/src/App/Header/HeaderInfoDialog.tsx +19 -0
- package/src/App/Header/HeaderLeft.tsx +31 -0
- package/src/App/Header/HeaderMenu.tsx +65 -0
- package/src/App/Header/HeaderRight.tsx +118 -0
- package/src/App/Header/HeaderToolTip.tsx +19 -0
- package/src/App/Header/HeaderToolTipIcon.tsx +75 -0
- package/src/App/Header/LanguageSwitch.tsx +125 -0
- package/src/App/Header/LoginDialog/LoginDialog.test.tsx +112 -0
- package/src/App/Header/LoginDialog/LoginDialog.tsx +81 -0
- package/src/App/Header/LoginDialog/LoginDialogCloseButton.tsx +32 -0
- package/src/App/Header/LoginDialog/LoginDialogForm.tsx +97 -0
- package/src/App/Header/LoginDialog/LoginDialogFormError.tsx +43 -0
- package/src/App/Header/LoginDialog/LoginDialogHeader.tsx +48 -0
- package/src/App/Header/LoginDialog/__snapshots__/LoginDialog.test.tsx.snap +3 -0
- package/src/App/Header/LoginDialog/index.ts +1 -0
- package/src/App/Header/RegistryInfoContent/RegistryInfoContent.test.tsx +27 -0
- package/src/App/Header/RegistryInfoContent/RegistryInfoContent.tsx +155 -0
- package/src/App/Header/RegistryInfoContent/index.ts +1 -0
- package/src/App/Header/RegistryInfoDialog/RegistryInfoDialog.tsx +30 -0
- package/src/App/Header/RegistryInfoDialog/index.ts +1 -0
- package/src/App/Header/RegistryInfoDialog/styles.ts +16 -0
- package/src/App/Header/RegistryInfoDialog/types.ts +7 -0
- package/src/App/Header/Search/Search.test.tsx +168 -0
- package/src/App/Header/Search/Search.tsx +127 -0
- package/src/App/Header/Search/SearchAdornment.tsx +18 -0
- package/src/App/Header/Search/__snapshots__/Search.test.tsx.snap +101 -0
- package/src/App/Header/Search/index.ts +1 -0
- package/src/App/Header/index.ts +1 -0
- package/src/App/Header/styles.ts +89 -0
- package/src/App/index.ts +1 -0
- package/src/App/utils/loadable.tsx +10 -0
- package/src/components/.eslintrc +7 -0
- package/src/components/ActionBar/ActionBar.test.tsx +91 -0
- package/src/components/ActionBar/ActionBar.tsx +45 -0
- package/src/components/ActionBar/ActionBarAction.tsx +75 -0
- package/src/components/ActionBar/__snapshots__/ActionBar.test.tsx.snap +122 -0
- package/src/components/ActionBar/index.ts +1 -0
- package/src/components/AppBar.tsx +10 -0
- package/src/components/Author/Author.test.tsx +75 -0
- package/src/components/Author/Author.tsx +47 -0
- package/src/components/Author/__snapshots__/Author.test.tsx.snap +353 -0
- package/src/components/Author/index.ts +1 -0
- package/src/components/Author/styles.ts +23 -0
- package/src/components/AutoComplete/AutoComplete.tsx +179 -0
- package/src/components/AutoComplete/AutoCompleteV2.tsx +296 -0
- package/src/components/AutoComplete/index.ts +1 -0
- package/src/components/AutoComplete/styles.tsx +58 -0
- package/src/components/AutoComplete/useAutoComplete.tsx +61 -0
- package/src/components/Avatar.tsx +3 -0
- package/src/components/Box.tsx +8 -0
- package/src/components/Button.tsx +10 -0
- package/src/components/Card.tsx +10 -0
- package/src/components/CardActions.tsx +13 -0
- package/src/components/CardContent.tsx +10 -0
- package/src/components/Chip.tsx +10 -0
- package/src/components/CircularProgress.tsx +15 -0
- package/src/components/CopyToClipBoard.tsx +45 -0
- package/src/components/Dialog.tsx +10 -0
- package/src/components/DialogActions.tsx +16 -0
- package/src/components/DialogContent.tsx +16 -0
- package/src/components/DialogTitle.tsx +10 -0
- package/src/components/Divider.tsx +10 -0
- package/src/components/FloatingActionButton.tsx +12 -0
- package/src/components/FormControl.tsx +10 -0
- package/src/components/FormHelperText.tsx +16 -0
- package/src/components/Grid.tsx +10 -0
- package/src/components/Heading.tsx +15 -0
- package/src/components/IconButton.tsx +10 -0
- package/src/components/Icons/.eslintrc +5 -0
- package/src/components/Icons/Earth.tsx +36 -0
- package/src/components/Icons/FileBinary.tsx +20 -0
- package/src/components/Icons/Law.tsx +20 -0
- package/src/components/Icons/License.tsx +18 -0
- package/src/components/Icons/Time.tsx +19 -0
- package/src/components/Icons/Version.tsx +20 -0
- package/src/components/Icons/index.ts +5 -0
- package/src/components/Input.tsx +10 -0
- package/src/components/InputAdornment/InputAdornment.tsx +16 -0
- package/src/components/InputAdornment/index.ts +1 -0
- package/src/components/InputLabel.tsx +10 -0
- package/src/components/Label/Label.test.tsx +15 -0
- package/src/components/Label/Label.tsx +35 -0
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +14 -0
- package/src/components/Label/index.ts +1 -0
- package/src/components/Link.tsx +39 -0
- package/src/components/List.tsx +10 -0
- package/src/components/ListItem.tsx +23 -0
- package/src/components/ListItemText.tsx +16 -0
- package/src/components/Loading/Loading.test.tsx +12 -0
- package/src/components/Loading/Loading.tsx +17 -0
- package/src/components/Loading/Spinner/Spinner.test.tsx +14 -0
- package/src/components/Loading/Spinner/Spinner.tsx +35 -0
- package/src/components/Loading/Spinner/__snapshots__/Spinner.test.tsx.snap +148 -0
- package/src/components/Loading/Spinner/index.tsx +1 -0
- package/src/components/Loading/__snapshots__/Loading.test.tsx.snap +86 -0
- package/src/components/Loading/index.ts +1 -0
- package/src/components/Loading/styles.ts +17 -0
- package/src/components/Logo/Logo.test.tsx +12 -0
- package/src/components/Logo/Logo.tsx +55 -0
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +19 -0
- package/src/components/Logo/img/logo-black-and-white.svg +1 -0
- package/src/components/Logo/img/logo.svg +1 -0
- package/src/components/Logo/index.ts +1 -0
- package/src/components/Menu.tsx +10 -0
- package/src/components/MenuItem.tsx +25 -0
- package/src/components/NotFound/NotFound.tsx +52 -0
- package/src/components/NotFound/Notfound.test.tsx +37 -0
- package/src/components/NotFound/__snapshots__/Notfound.test.tsx.snap +44 -0
- package/src/components/NotFound/img/package.svg +1 -0
- package/src/components/NotFound/index.ts +1 -0
- package/src/components/NotFound/styles.ts +40 -0
- package/src/components/Paper.tsx +10 -0
- package/src/components/SnackbarContent.tsx +15 -0
- package/src/components/SvgIcon.tsx +38 -0
- package/src/components/Tab.tsx +10 -0
- package/src/components/Tabs.tsx +14 -0
- package/src/components/Text/Text.tsx +17 -0
- package/src/components/Text/TextConfig.ts +7 -0
- package/src/components/Text/index.ts +2 -0
- package/src/components/TextField/TextField.test.tsx +16 -0
- package/src/components/TextField/TextField.tsx +23 -0
- package/src/components/TextField/__snapshots__/TextField.test.tsx.snap +19 -0
- package/src/components/TextField/index.ts +1 -0
- package/src/components/Toolbar.tsx +10 -0
- package/src/components/Tooltip.tsx +25 -0
- package/src/design-tokens/ResetStyles.tsx +44 -0
- package/src/design-tokens/StyleBaseline.tsx +14 -0
- package/src/design-tokens/ThemeContext.ts +13 -0
- package/src/design-tokens/ThemeProvider.tsx +44 -0
- package/src/design-tokens/emotion.ts +5 -0
- package/src/design-tokens/load-dayjs-locale.ts +98 -0
- package/src/design-tokens/theme.ts +159 -0
- package/src/design-tokens/useLocalStorage.ts +40 -0
- package/src/design-tokens/useOnClickOutside.ts +28 -0
- package/src/design-tokens/useTheme.ts +7 -0
- package/src/i18n/ABOUT_TRANSLATIONS.md +13 -0
- package/src/i18n/config.ts +52 -0
- package/src/i18n/crowdin/ui.json +170 -0
- package/src/i18n/deprecated_translations_dont_use/cs-CZ.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/de-DE.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/en-US.json +170 -0
- package/src/i18n/deprecated_translations_dont_use/es-ES.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/fr-FR.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/ja-JP.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/km-KH.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/pt-BR.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/ru-RU.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/tr-TR.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/uk-UA.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/zh-CN.json +168 -0
- package/src/i18n/deprecated_translations_dont_use/zh-TW.json +165 -0
- package/src/i18n/enabledLanguages.ts +35 -0
- package/src/index.tsx +36 -0
- package/src/lib/constants.ts +9 -0
- package/src/pages/Version/DetailContainer/Dependencies/Dependencies.test.tsx +93 -0
- package/src/pages/Version/DetailContainer/Dependencies/Dependencies.tsx +100 -0
- package/src/pages/Version/DetailContainer/Dependencies/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Dependencies/styles.ts +26 -0
- package/src/pages/Version/DetailContainer/Dependencies/types.ts +7 -0
- package/src/pages/Version/DetailContainer/Deprecated/Deprecated.test.tsx +34 -0
- package/src/pages/Version/DetailContainer/Deprecated/Deprecated.tsx +31 -0
- package/src/pages/Version/DetailContainer/Deprecated/index.ts +1 -0
- package/src/pages/Version/DetailContainer/DetailContainer.test.tsx +13 -0
- package/src/pages/Version/DetailContainer/DetailContainer.tsx +37 -0
- package/src/pages/Version/DetailContainer/DetailContainerContent.tsx +41 -0
- package/src/pages/Version/DetailContainer/DetailContainerContentReadme.tsx +19 -0
- package/src/pages/Version/DetailContainer/DetailContainerTabs.tsx +36 -0
- package/src/pages/Version/DetailContainer/NoItems/NoItems.tsx +16 -0
- package/src/pages/Version/DetailContainer/NoItems/Noitems.test.tsx +16 -0
- package/src/pages/Version/DetailContainer/NoItems/__snapshots__/Noitems.test.tsx.snap +9 -0
- package/src/pages/Version/DetailContainer/NoItems/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Readme/Readme.spec.tsx +19 -0
- package/src/pages/Version/DetailContainer/Readme/Readme.tsx +22 -0
- package/src/pages/Version/DetailContainer/Readme/__snapshots__/Readme.spec.tsx.snap +94 -0
- package/src/pages/Version/DetailContainer/Readme/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Readme/types.ts +3 -0
- package/src/pages/Version/DetailContainer/UpLinks/UpLinks.test.tsx +58 -0
- package/src/pages/Version/DetailContainer/UpLinks/UpLinks.tsx +45 -0
- package/src/pages/Version/DetailContainer/UpLinks/__snapshots__/UpLinks.test.tsx.snap +247 -0
- package/src/pages/Version/DetailContainer/UpLinks/index.ts +1 -0
- package/src/pages/Version/DetailContainer/UpLinks/styles.ts +24 -0
- package/src/pages/Version/DetailContainer/Versions/Versions.test.tsx +60 -0
- package/src/pages/Version/DetailContainer/Versions/Versions.tsx +41 -0
- package/src/pages/Version/DetailContainer/Versions/VersionsHistoryList.tsx +40 -0
- package/src/pages/Version/DetailContainer/Versions/VersionsTagList.tsx +28 -0
- package/src/pages/Version/DetailContainer/Versions/__partials__/data.json +5984 -0
- package/src/pages/Version/DetailContainer/Versions/__snapshots__/Versions.test.tsx.snap +3 -0
- package/src/pages/Version/DetailContainer/Versions/index.ts +1 -0
- package/src/pages/Version/DetailContainer/Versions/styles.ts +30 -0
- package/src/pages/Version/DetailContainer/__snapshots__/DetailContainer.test.tsx.snap +103 -0
- package/src/pages/Version/DetailContainer/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/DetailSidebar.tsx +55 -0
- package/src/pages/Version/DetailSidebar/DetailSidebarFundButton.test.tsx +111 -0
- package/src/pages/Version/DetailSidebar/DetailSidebarFundButton.tsx +53 -0
- package/src/pages/Version/DetailSidebar/DetailSidebarTitle.tsx +40 -0
- package/src/pages/Version/DetailSidebar/Developers/Developers.test.tsx +117 -0
- package/src/pages/Version/DetailSidebar/Developers/Developers.tsx +90 -0
- package/src/pages/Version/DetailSidebar/Developers/DevelopersTitle.tsx +32 -0
- package/src/pages/Version/DetailSidebar/Developers/__snapshots__/Developers.test.tsx.snap +380 -0
- package/src/pages/Version/DetailSidebar/Developers/get-unique-developer-values.ts +16 -0
- package/src/pages/Version/DetailSidebar/Developers/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Developers/styles.ts +31 -0
- package/src/pages/Version/DetailSidebar/Dist/Dist.test.tsx +78 -0
- package/src/pages/Version/DetailSidebar/Dist/Dist.tsx +49 -0
- package/src/pages/Version/DetailSidebar/Dist/__snapshots__/Dist.test.tsx.snap +602 -0
- package/src/pages/Version/DetailSidebar/Dist/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Dist/styles.ts +27 -0
- package/src/pages/Version/DetailSidebar/Engines/Engines.test.tsx +71 -0
- package/src/pages/Version/DetailSidebar/Engines/Engines.tsx +58 -0
- package/src/pages/Version/DetailSidebar/Engines/img/node.png +0 -0
- package/src/pages/Version/DetailSidebar/Engines/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Engines/styles.ts +14 -0
- package/src/pages/Version/DetailSidebar/Install/Install.test.tsx +64 -0
- package/src/pages/Version/DetailSidebar/Install/Install.tsx +52 -0
- package/src/pages/Version/DetailSidebar/Install/InstallListItem.tsx +97 -0
- package/src/pages/Version/DetailSidebar/Install/__partials__/data.json +5984 -0
- package/src/pages/Version/DetailSidebar/Install/img/npm.svg +15 -0
- package/src/pages/Version/DetailSidebar/Install/img/pnpm.svg +1 -0
- package/src/pages/Version/DetailSidebar/Install/img/yarn.svg +1 -0
- package/src/pages/Version/DetailSidebar/Install/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/Repository/Repository.test.tsx +78 -0
- package/src/pages/Version/DetailSidebar/Repository/Repository.tsx +93 -0
- package/src/pages/Version/DetailSidebar/Repository/__partials__/data.json +5984 -0
- package/src/pages/Version/DetailSidebar/Repository/__snapshots__/Repository.test.tsx.snap +3 -0
- package/src/pages/Version/DetailSidebar/Repository/img/git.png +0 -0
- package/src/pages/Version/DetailSidebar/Repository/index.ts +1 -0
- package/src/pages/Version/DetailSidebar/index.ts +1 -0
- package/src/pages/Version/Version.test.tsx +68 -0
- package/src/pages/Version/Version.tsx +41 -0
- package/src/pages/Version/VersionContextProvider.tsx +43 -0
- package/src/pages/Version/VersionLayout.tsx +20 -0
- package/src/pages/Version/__partials__/data.json +5984 -0
- package/src/pages/Version/context.ts +10 -0
- package/src/pages/Version/get-route-package-name.ts +9 -0
- package/src/pages/Version/index.ts +4 -0
- package/src/pages/Version/version-config.ts +19 -0
- package/src/pages/home/Home.tsx +25 -0
- package/src/pages/home/PackageList/Help/Help.test.tsx +12 -0
- package/src/pages/home/PackageList/Help/Help.tsx +56 -0
- package/src/pages/home/PackageList/Help/__snapshots__/Help.test.tsx.snap +159 -0
- package/src/pages/home/PackageList/Help/index.ts +1 -0
- package/src/pages/home/PackageList/Help/styles.ts +13 -0
- package/src/pages/home/PackageList/Package/Package.test.tsx +56 -0
- package/src/pages/home/PackageList/Package/Package.tsx +253 -0
- package/src/pages/home/PackageList/Package/Tag/Tag.test.tsx +16 -0
- package/src/pages/home/PackageList/Package/Tag/Tag.tsx +11 -0
- package/src/pages/home/PackageList/Package/Tag/__snapshots__/Tag.test.tsx.snap +21 -0
- package/src/pages/home/PackageList/Package/Tag/index.ts +1 -0
- package/src/pages/home/PackageList/Package/Tag/styles.ts +11 -0
- package/src/pages/home/PackageList/Package/index.ts +1 -0
- package/src/pages/home/PackageList/Package/styles.ts +112 -0
- package/src/pages/home/PackageList/PackageList.tsx +81 -0
- package/src/pages/home/PackageList/Packagelist.test.tsx +60 -0
- package/src/pages/home/PackageList/index.ts +1 -0
- package/src/pages/home/index.ts +1 -0
- package/src/providers/API/api.test.ts +136 -0
- package/src/providers/API/api.ts +73 -0
- package/src/providers/API/storage.ts +12 -0
- package/src/providers/config/AppConfigurationProvider.tsx +57 -0
- package/src/providers/config/index.ts +1 -0
- package/src/store/index.ts +1 -0
- package/src/store/models/configuration.ts +42 -0
- package/src/store/models/download.ts +31 -0
- package/src/store/models/index.ts +17 -0
- package/src/store/models/login.ts +90 -0
- package/src/store/models/manifest.ts +91 -0
- package/src/store/models/packages.ts +36 -0
- package/src/store/models/search.ts +81 -0
- package/src/store/store.ts +15 -0
- package/src/template/favicon.ico +0 -0
- package/src/template/index.html +21 -0
- package/src/utils/.eslintrc +5 -0
- package/src/utils/cli-utils.test.ts +66 -0
- package/src/utils/cli-utils.ts +38 -0
- package/src/utils/colors.ts +1 -0
- package/src/utils/constants.ts +5 -0
- package/src/utils/file-size.ts +13 -0
- package/src/utils/i18nForTests.ts +25 -0
- package/src/utils/login.test.ts +71 -0
- package/src/utils/login.ts +44 -0
- package/src/utils/package.test.ts +101 -0
- package/src/utils/package.ts +105 -0
- package/src/utils/sec-utils.ts +15 -0
- package/src/utils/storage.ts +12 -0
- package/src/utils/test-react-testing-library.tsx +38 -0
- package/src/utils/url.test.ts +28 -0
- package/src/utils/url.ts +58 -0
- package/src/utils/windows.ts +3 -0
- package/static/favicon.ico +0 -0
- package/static/index.html +21 -0
- package/static/main.c57129036f278d0c7acf.js +2 -0
- package/static/main.c57129036f278d0c7acf.js.LICENSE.txt +1456 -0
- package/static/manifest.json +5 -17
- package/static/runtime.c57129036f278d0c7acf.js +2 -0
- package/static/{runtime.f6e570dfe38870a45bf5.js.LICENSE.txt → runtime.c57129036f278d0c7acf.js.LICENSE.txt} +2 -2
- package/static/vendors.c57129036f278d0c7acf.js +2 -0
- package/static/vendors.c57129036f278d0c7acf.js.LICENSE.txt +2932 -0
- package/tools/.eslintrc +14 -0
- package/tools/_verdaccio.config.yaml +59 -0
- package/tools/dev.server.js +48 -0
- package/tools/getPackageJson.js +25 -0
- package/tools/verdaccio.js +31 -0
- package/tools/webpack.config.js +82 -0
- package/tools/webpack.dev.config.babel.js +60 -0
- package/tools/webpack.prod.config.babel.js +81 -0
- package/tsconfig.build.json +24 -0
- package/tsconfig.json +27 -0
- package/types/custom.d.ts +9 -0
- package/types/files.d.ts +9 -0
- package/types/index.ts +12 -0
- package/types/jest-dom.d.ts +1 -0
- package/types/packageMeta.ts +82 -0
- package/static/238.f6e570dfe38870a45bf5.js +0 -2
- package/static/238.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/718.f6e570dfe38870a45bf5.js +0 -2
- package/static/718.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/73.f6e570dfe38870a45bf5.js +0 -2
- package/static/73.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Dependencies.f6e570dfe38870a45bf5.js +0 -2
- package/static/Dependencies.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Dist.f6e570dfe38870a45bf5.js +0 -2
- package/static/Dist.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Engines.f6e570dfe38870a45bf5.js +0 -2
- package/static/Engines.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Home.f6e570dfe38870a45bf5.js +0 -2
- package/static/Home.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Install.f6e570dfe38870a45bf5.js +0 -2
- package/static/Install.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/NotFound.f6e570dfe38870a45bf5.js +0 -2
- package/static/NotFound.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Provider.f6e570dfe38870a45bf5.js +0 -2
- package/static/Provider.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Repository.f6e570dfe38870a45bf5.js +0 -2
- package/static/Repository.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/UpLinks.f6e570dfe38870a45bf5.js +0 -2
- package/static/UpLinks.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Version.f6e570dfe38870a45bf5.js +0 -2
- package/static/Version.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/Versions.f6e570dfe38870a45bf5.js +0 -2
- package/static/Versions.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/main.f6e570dfe38870a45bf5.js +0 -2
- package/static/main.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -10
- package/static/runtime.f6e570dfe38870a45bf5.js +0 -2
- package/static/vendors.f6e570dfe38870a45bf5.js +0 -2
- package/static/vendors.f6e570dfe38870a45bf5.js.LICENSE.txt +0 -98
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
|
|
3
|
+
export const Wrapper = styled('span')({
|
|
4
|
+
verticalAlign: 'middle',
|
|
5
|
+
lineHeight: '22px',
|
|
6
|
+
borderRadius: '2px',
|
|
7
|
+
color: '#485a3e',
|
|
8
|
+
backgroundColor: '#f3f4f2',
|
|
9
|
+
padding: '0.22rem 0.4rem',
|
|
10
|
+
margin: '8px 8px 0 0',
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, PackageInterface } from './Package';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import { default as Photo } from 'verdaccio-ui/components/Avatar';
|
|
5
|
+
import Grid from 'verdaccio-ui/components/Grid';
|
|
6
|
+
import { default as MuiIconButton } from 'verdaccio-ui/components/IconButton';
|
|
7
|
+
import Label from 'verdaccio-ui/components/Label';
|
|
8
|
+
import List from 'verdaccio-ui/components/List';
|
|
9
|
+
import ListItemText from 'verdaccio-ui/components/ListItemText';
|
|
10
|
+
import { default as MuiText } from 'verdaccio-ui/components/Text';
|
|
11
|
+
import { Theme } from 'verdaccio-ui/design-tokens/theme';
|
|
12
|
+
|
|
13
|
+
export const OverviewItem = styled('span')<{ theme?: Theme }>(({ theme }) => ({
|
|
14
|
+
display: 'flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
margin: '0 0 0 16px',
|
|
17
|
+
color: theme?.palette.type === 'light' ? theme?.palette.greyLight2 : theme?.palette.white,
|
|
18
|
+
fontSize: 12,
|
|
19
|
+
[`@media (max-width: ${theme?.breakPoints.medium}px)`]: {
|
|
20
|
+
':nth-of-type(3)': {
|
|
21
|
+
display: 'none',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
[`@media (max-width: ${theme?.breakPoints.small}px)`]: {
|
|
25
|
+
':nth-of-type(4)': {
|
|
26
|
+
display: 'none',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
export const Published = styled('span')<{ theme?: Theme }>(({ theme }) => ({
|
|
32
|
+
color: theme?.palette.type === 'light' ? theme?.palette.greyLight2 : theme?.palette.white,
|
|
33
|
+
margin: '0 5px 0 0',
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
export const Text = styled(Label)<{ theme?: Theme }>(({ theme }) => ({
|
|
37
|
+
fontSize: '12px',
|
|
38
|
+
fontWeight: theme?.fontWeight.semiBold,
|
|
39
|
+
color: theme?.palette.type === 'light' ? theme?.palette.greyLight2 : theme?.palette.white,
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
export const Details = styled('span')({
|
|
43
|
+
marginLeft: '5px',
|
|
44
|
+
lineHeight: 1.5,
|
|
45
|
+
display: 'flex',
|
|
46
|
+
flexDirection: 'column',
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const Author = styled('div')({
|
|
50
|
+
display: 'flex',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const Avatar = styled(Photo)({
|
|
55
|
+
width: '20px',
|
|
56
|
+
height: '20px',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const WrapperLink = styled(Link)({
|
|
60
|
+
textDecoration: 'none',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const PackageTitle = styled('span')<{ theme?: Theme }>(({ theme }) => ({
|
|
64
|
+
fontWeight: theme?.fontWeight.bold,
|
|
65
|
+
fontSize: 20,
|
|
66
|
+
display: 'block',
|
|
67
|
+
marginBottom: 12,
|
|
68
|
+
color: theme?.palette.type == 'dark' ? theme?.palette.dodgerBlue : theme?.palette.eclipse,
|
|
69
|
+
cursor: 'pointer',
|
|
70
|
+
[`@media (max-width: ${theme?.breakPoints.small}px)`]: {
|
|
71
|
+
fontSize: 14,
|
|
72
|
+
marginBottom: 8,
|
|
73
|
+
},
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
export const GridRightAligned = styled(Grid)({
|
|
77
|
+
textAlign: 'right',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const Wrapper = styled(List)<{ theme?: Theme }>(({ theme }) => ({
|
|
81
|
+
':hover': {
|
|
82
|
+
backgroundColor:
|
|
83
|
+
theme?.palette?.type == 'dark' ? theme?.palette?.secondary.main : theme?.palette?.greyLight3,
|
|
84
|
+
},
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
export const IconButton = styled(MuiIconButton)({
|
|
88
|
+
padding: 6,
|
|
89
|
+
svg: {
|
|
90
|
+
fontSize: 16,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export const TagContainer = styled('span')<{ theme?: Theme }>(({ theme }) => ({
|
|
95
|
+
marginTop: 8,
|
|
96
|
+
marginBottom: 12,
|
|
97
|
+
display: 'flex',
|
|
98
|
+
flexWrap: 'wrap',
|
|
99
|
+
[`@media (max-width: ${theme?.breakPoints.medium}px)`]: {
|
|
100
|
+
display: 'none',
|
|
101
|
+
},
|
|
102
|
+
}));
|
|
103
|
+
|
|
104
|
+
export const PackageListItemText = styled(ListItemText)({
|
|
105
|
+
paddingRight: 0,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export const Description = styled(MuiText)<{ theme?: Theme }>(({ theme }) => ({
|
|
109
|
+
color: theme?.palette.type === 'light' ? theme?.palette.greyDark2 : theme?.palette.white,
|
|
110
|
+
fontSize: '14px',
|
|
111
|
+
paddingRight: 0,
|
|
112
|
+
}));
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AutoSizer } from 'react-virtualized/dist/commonjs/AutoSizer';
|
|
3
|
+
import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
|
|
4
|
+
import { List, ListRowProps } from 'react-virtualized/dist/commonjs/List';
|
|
5
|
+
import { WindowScroller } from 'react-virtualized/dist/commonjs/WindowScroller';
|
|
6
|
+
|
|
7
|
+
import Divider from 'verdaccio-ui/components/Divider';
|
|
8
|
+
import { formatLicense } from 'verdaccio-ui/utils/package';
|
|
9
|
+
|
|
10
|
+
import Help from './Help';
|
|
11
|
+
import Package, { PackageInterface } from './Package';
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
packages: PackageInterface[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const cache = new CellMeasurerCache({
|
|
18
|
+
fixedWidth: true,
|
|
19
|
+
defaultHeight: 100,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/* eslint-disable verdaccio/jsx-no-style */
|
|
23
|
+
const PackageList: React.FC<Props> = ({ packages }) => {
|
|
24
|
+
const renderRow = ({ index, key, parent, style }: ListRowProps) => {
|
|
25
|
+
const { name, version, description, time, keywords, dist, homepage, bugs, author, license } =
|
|
26
|
+
packages[index];
|
|
27
|
+
// TODO: move format license to API side.
|
|
28
|
+
const formattedLicense = formatLicense(license);
|
|
29
|
+
return (
|
|
30
|
+
<CellMeasurer cache={cache} columnIndex={0} key={key} parent={parent} rowIndex={index}>
|
|
31
|
+
<div style={style}>
|
|
32
|
+
{index !== 0 && <Divider />}
|
|
33
|
+
<Package
|
|
34
|
+
author={author}
|
|
35
|
+
bugs={bugs}
|
|
36
|
+
description={description}
|
|
37
|
+
dist={dist}
|
|
38
|
+
homepage={homepage}
|
|
39
|
+
keywords={keywords}
|
|
40
|
+
license={formattedLicense}
|
|
41
|
+
name={name}
|
|
42
|
+
time={time}
|
|
43
|
+
version={version}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
</CellMeasurer>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (packages.length === 0) {
|
|
51
|
+
return <Help />;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<WindowScroller>
|
|
56
|
+
{({ height, isScrolling, scrollTop, onChildScroll }) => (
|
|
57
|
+
<AutoSizer disableHeight={true}>
|
|
58
|
+
{({ width }) => {
|
|
59
|
+
return (
|
|
60
|
+
<List
|
|
61
|
+
autoHeight={true}
|
|
62
|
+
deferredMeasurementCache={cache}
|
|
63
|
+
height={height}
|
|
64
|
+
isScrolling={isScrolling}
|
|
65
|
+
onScroll={onChildScroll}
|
|
66
|
+
overscanRowCount={3}
|
|
67
|
+
rowCount={packages.length}
|
|
68
|
+
rowHeight={cache.rowHeight}
|
|
69
|
+
rowRenderer={renderRow}
|
|
70
|
+
scrollTop={scrollTop}
|
|
71
|
+
width={width}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}}
|
|
75
|
+
</AutoSizer>
|
|
76
|
+
)}
|
|
77
|
+
</WindowScroller>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { PackageList };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import { renderWithStore, cleanup } from 'verdaccio-ui/utils/test-react-testing-library';
|
|
5
|
+
|
|
6
|
+
import { store } from '../../../store';
|
|
7
|
+
|
|
8
|
+
import { PackageList } from './PackageList';
|
|
9
|
+
|
|
10
|
+
describe('<PackageList /> component', () => {
|
|
11
|
+
beforeEach(cleanup);
|
|
12
|
+
|
|
13
|
+
test('should load the component with no packages', () => {
|
|
14
|
+
const props = {
|
|
15
|
+
packages: [],
|
|
16
|
+
};
|
|
17
|
+
const wrapper = renderWithStore(<PackageList packages={props.packages} />, store);
|
|
18
|
+
expect(wrapper.getByText('No Package Published Yet.')).toBeInTheDocument();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('should load the component with packages', () => {
|
|
22
|
+
// Mock <Autosizer /> width
|
|
23
|
+
jest.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(600);
|
|
24
|
+
|
|
25
|
+
const props = {
|
|
26
|
+
packages: [
|
|
27
|
+
{
|
|
28
|
+
name: 'verdaccio',
|
|
29
|
+
version: '1.0.0',
|
|
30
|
+
time: new Date(1532211072138).getTime(),
|
|
31
|
+
description: 'Private NPM repository',
|
|
32
|
+
author: { name: 'Sam', avatar: 'test avatar' },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'abc',
|
|
36
|
+
version: '1.0.1',
|
|
37
|
+
time: new Date(1532211072138).getTime(),
|
|
38
|
+
description: 'abc description',
|
|
39
|
+
author: { name: 'Rose', avatar: 'test avatar' },
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'xyz',
|
|
43
|
+
version: '1.1.0',
|
|
44
|
+
description: 'xyz description',
|
|
45
|
+
author: { name: 'Martin', avatar: 'test avatar' },
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
help: false,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const wrapper = renderWithStore(
|
|
52
|
+
<BrowserRouter>
|
|
53
|
+
<PackageList packages={props.packages} />
|
|
54
|
+
</BrowserRouter>,
|
|
55
|
+
store
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(wrapper.queryAllByTestId('package-item-list')).toHaveLength(3);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PackageList } from './PackageList';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Home';
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import api, { handleResponseType } from './api';
|
|
2
|
+
|
|
3
|
+
describe('api', () => {
|
|
4
|
+
describe('handleResponseType', () => {
|
|
5
|
+
test('should handle missing Content-Type', async () => {
|
|
6
|
+
const responseText = `responseText`;
|
|
7
|
+
const ok = false;
|
|
8
|
+
const response: Response = {
|
|
9
|
+
url: 'http://localhost:8080/-/packages',
|
|
10
|
+
ok,
|
|
11
|
+
headers: new Headers(),
|
|
12
|
+
text: async () => responseText,
|
|
13
|
+
} as Response;
|
|
14
|
+
|
|
15
|
+
const handled = await handleResponseType(response);
|
|
16
|
+
|
|
17
|
+
expect(handled).toEqual([ok, responseText]);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('should test tgz scenario', async () => {
|
|
21
|
+
const blob = new Blob(['foo']);
|
|
22
|
+
const blobPromise = Promise.resolve<Blob>(blob);
|
|
23
|
+
const response: Response = {
|
|
24
|
+
url: 'http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz',
|
|
25
|
+
blob: () => blobPromise,
|
|
26
|
+
ok: true,
|
|
27
|
+
headers: new Headers(),
|
|
28
|
+
} as Response;
|
|
29
|
+
const handled = await handleResponseType(response);
|
|
30
|
+
|
|
31
|
+
expect(handled).toEqual([true, blob]);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('api client', () => {
|
|
36
|
+
let fetchSpy: jest.SpyInstance;
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
fetchSpy = jest.spyOn(window, 'fetch');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
fetchSpy.mockRestore();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('when url is a resource url', async () => {
|
|
47
|
+
fetchSpy.mockImplementation(() =>
|
|
48
|
+
Promise.resolve({
|
|
49
|
+
headers: new Headers({
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
}),
|
|
52
|
+
ok: true,
|
|
53
|
+
json: () => ({ a: 1 }),
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const response = await api.request('https://verdaccio.tld/resource');
|
|
58
|
+
|
|
59
|
+
expect(fetchSpy).toHaveBeenCalledWith('https://verdaccio.tld/resource', {
|
|
60
|
+
credentials: 'same-origin',
|
|
61
|
+
headers: {},
|
|
62
|
+
method: 'GET',
|
|
63
|
+
});
|
|
64
|
+
expect(response).toEqual({ a: 1 });
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('when there is token from storage', async () => {
|
|
68
|
+
jest.resetModules();
|
|
69
|
+
jest.doMock('./storage', () => ({ getItem: () => 'token-xx-xx-xx' }));
|
|
70
|
+
|
|
71
|
+
fetchSpy.mockImplementation(() =>
|
|
72
|
+
Promise.resolve({
|
|
73
|
+
headers: new Headers({
|
|
74
|
+
'Content-Type': 'application/json',
|
|
75
|
+
}),
|
|
76
|
+
ok: true,
|
|
77
|
+
json: () => ({ c: 3 }),
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const api = require('./api').default;
|
|
82
|
+
const response = await api.request('https://verdaccio.tld/resource', 'GET');
|
|
83
|
+
|
|
84
|
+
expect(fetchSpy).toHaveBeenCalledWith('https://verdaccio.tld/resource', {
|
|
85
|
+
credentials: 'same-origin',
|
|
86
|
+
headers: new Headers({
|
|
87
|
+
Authorization: 'Bearer token-xx-xx-xx',
|
|
88
|
+
'x-client': 'verdaccio-ui',
|
|
89
|
+
}),
|
|
90
|
+
method: 'GET',
|
|
91
|
+
});
|
|
92
|
+
expect(response).toEqual({ c: 3 });
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('when url is a cross origin url', async () => {
|
|
96
|
+
fetchSpy.mockImplementation(() =>
|
|
97
|
+
Promise.resolve({
|
|
98
|
+
headers: new Headers({
|
|
99
|
+
'Content-Type': 'application/json',
|
|
100
|
+
}),
|
|
101
|
+
ok: true,
|
|
102
|
+
json: () => ({ b: 2 }),
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const response = await api.request('https://verdaccio.xyz/resource');
|
|
107
|
+
expect(fetchSpy).toHaveBeenCalledWith('https://verdaccio.xyz/resource', {
|
|
108
|
+
credentials: 'same-origin',
|
|
109
|
+
headers: {},
|
|
110
|
+
method: 'GET',
|
|
111
|
+
});
|
|
112
|
+
expect(response).toEqual({ b: 2 });
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('when api returns an error 3.x.x - 4.x.x', async () => {
|
|
116
|
+
fetchSpy.mockImplementation(() =>
|
|
117
|
+
Promise.resolve({
|
|
118
|
+
headers: new Headers({
|
|
119
|
+
'Content-Type': 'application/json',
|
|
120
|
+
}),
|
|
121
|
+
ok: false,
|
|
122
|
+
json: () => {},
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
await expect(api.request('/resource')).rejects.toThrow(new Error('something went wrong'));
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('when api returns an error 5.x.x', async () => {
|
|
130
|
+
const errorMessage = 'Internal server error';
|
|
131
|
+
fetchSpy.mockImplementation(() => Promise.reject(new Error(errorMessage)));
|
|
132
|
+
|
|
133
|
+
await expect(api.request('/resource')).rejects.toThrow(new Error(errorMessage));
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import storage from './storage';
|
|
2
|
+
import '../../../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Handles response according to content type
|
|
6
|
+
* @param {object} response
|
|
7
|
+
* @returns {promise}
|
|
8
|
+
*/
|
|
9
|
+
export function handleResponseType(response: Response): Promise<[boolean, any]> {
|
|
10
|
+
if (response.headers) {
|
|
11
|
+
const contentType = response.headers.get('Content-Type');
|
|
12
|
+
if (contentType?.includes('application/pdf')) {
|
|
13
|
+
return Promise.all([response.ok, response.blob()]);
|
|
14
|
+
}
|
|
15
|
+
if (contentType?.includes('application/json')) {
|
|
16
|
+
return Promise.all([response.ok, response.json()]);
|
|
17
|
+
}
|
|
18
|
+
// it includes all text types
|
|
19
|
+
if (contentType?.includes('text/')) {
|
|
20
|
+
return Promise.all([response.ok, response.text()]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// unfortunately on download files there is no header available
|
|
24
|
+
if (response.url && response.url.endsWith('.tgz') === true) {
|
|
25
|
+
return Promise.all([response.ok, response.blob()]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return Promise.all([response.ok, response.text()]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const AuthHeader = 'Authorization';
|
|
33
|
+
|
|
34
|
+
class API {
|
|
35
|
+
public request<T>(
|
|
36
|
+
url: string,
|
|
37
|
+
method = 'GET',
|
|
38
|
+
options: RequestInit = { headers: {} }
|
|
39
|
+
): Promise<T> {
|
|
40
|
+
const token = storage.getItem('token');
|
|
41
|
+
const headers = new Headers(options.headers);
|
|
42
|
+
|
|
43
|
+
if (token && headers.has(AuthHeader) === false) {
|
|
44
|
+
headers.set(AuthHeader, `Bearer ${token}`);
|
|
45
|
+
options.headers = headers;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
headers.set('x-client', 'verdaccio-ui');
|
|
49
|
+
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
fetch(url, {
|
|
52
|
+
method,
|
|
53
|
+
credentials: 'same-origin',
|
|
54
|
+
...options,
|
|
55
|
+
})
|
|
56
|
+
.then(handleResponseType)
|
|
57
|
+
.then((response) => {
|
|
58
|
+
if (response[0]) {
|
|
59
|
+
resolve(response[1]);
|
|
60
|
+
} else {
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
|
+
console.error(response);
|
|
63
|
+
reject(new Error('something went wrong'));
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.catch((error) => {
|
|
67
|
+
reject(error);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default new API();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import memoryStorage from 'localstorage-memory';
|
|
2
|
+
|
|
3
|
+
let storage: Storage;
|
|
4
|
+
try {
|
|
5
|
+
localStorage.setItem('__TEST__', '');
|
|
6
|
+
localStorage.removeItem('__TEST__');
|
|
7
|
+
storage = localStorage;
|
|
8
|
+
} catch (err: any) {
|
|
9
|
+
storage = memoryStorage;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default storage;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { TemplateUIOptions } from '@verdaccio/types';
|
|
2
|
+
import isEmpty from 'lodash/isEmpty';
|
|
3
|
+
import isNil from 'lodash/isNil';
|
|
4
|
+
import React, { createContext, FunctionComponent, useContext, useMemo, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
import { PRIMARY_COLOR } from 'verdaccio-ui/utils/colors';
|
|
7
|
+
|
|
8
|
+
type ConfigProviderProps = {
|
|
9
|
+
configOptions: TemplateUIOptions;
|
|
10
|
+
setConfigOptions: Function;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const defaultValues: ConfigProviderProps = {
|
|
14
|
+
configOptions: {
|
|
15
|
+
primaryColor: PRIMARY_COLOR,
|
|
16
|
+
darkMode: false,
|
|
17
|
+
pkgManagers: ['yarn', 'pnpm', 'npm'],
|
|
18
|
+
scope: '',
|
|
19
|
+
base: '',
|
|
20
|
+
login: true,
|
|
21
|
+
url_prefix: '',
|
|
22
|
+
title: 'Verdaccio',
|
|
23
|
+
},
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
25
|
+
setConfigOptions: () => {},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function getConfiguration() {
|
|
29
|
+
const uiConfiguration = window?.__VERDACCIO_BASENAME_UI_OPTIONS ?? defaultValues.configOptions;
|
|
30
|
+
if (isNil(uiConfiguration.primaryColor) || isEmpty(uiConfiguration.primaryColor)) {
|
|
31
|
+
uiConfiguration.primaryColor = PRIMARY_COLOR;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return uiConfiguration;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const AppConfigurationContext = createContext<ConfigProviderProps>(defaultValues);
|
|
38
|
+
|
|
39
|
+
const AppConfigurationProvider: FunctionComponent = ({ children }) => {
|
|
40
|
+
const [configOptions, setConfigOptions] = useState(getConfiguration());
|
|
41
|
+
|
|
42
|
+
const value = useMemo(
|
|
43
|
+
() => ({
|
|
44
|
+
configOptions,
|
|
45
|
+
setConfigOptions,
|
|
46
|
+
}),
|
|
47
|
+
[configOptions]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<AppConfigurationContext.Provider value={value}>{children}</AppConfigurationContext.Provider>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default AppConfigurationProvider;
|
|
56
|
+
|
|
57
|
+
export const useConfig = () => useContext(AppConfigurationContext);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, useConfig } from './AppConfigurationProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { store } from './store';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createModel } from '@rematch/core';
|
|
2
|
+
import { Package, TemplateUIOptions } from '@verdaccio/types';
|
|
3
|
+
import isEmpty from 'lodash/isEmpty';
|
|
4
|
+
import isNil from 'lodash/isNil';
|
|
5
|
+
|
|
6
|
+
import { PRIMARY_COLOR } from 'verdaccio-ui/utils/colors';
|
|
7
|
+
|
|
8
|
+
import API from '../../providers/API/api';
|
|
9
|
+
|
|
10
|
+
import type { RootModel } from '.';
|
|
11
|
+
|
|
12
|
+
const defaultValues: TemplateUIOptions = {
|
|
13
|
+
primaryColor: PRIMARY_COLOR,
|
|
14
|
+
darkMode: false,
|
|
15
|
+
pkgManagers: ['yarn', 'pnpm', 'npm'],
|
|
16
|
+
scope: '',
|
|
17
|
+
base: '',
|
|
18
|
+
login: true,
|
|
19
|
+
url_prefix: '',
|
|
20
|
+
title: 'Verdaccio',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function getConfiguration() {
|
|
24
|
+
const uiConfiguration = window?.__VERDACCIO_BASENAME_UI_OPTIONS ?? defaultValues;
|
|
25
|
+
if (isNil(uiConfiguration.primaryColor) || isEmpty(uiConfiguration.primaryColor)) {
|
|
26
|
+
uiConfiguration.primaryColor = PRIMARY_COLOR;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return uiConfiguration;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const configuration = createModel<RootModel>()({
|
|
33
|
+
state: {
|
|
34
|
+
config: getConfiguration(),
|
|
35
|
+
},
|
|
36
|
+
effects: (dispatch) => ({
|
|
37
|
+
async getPackages() {
|
|
38
|
+
const payload: Package[] = await API.request(`/-/verdaccio/packages`, 'GET');
|
|
39
|
+
dispatch.packages.savePackages(payload);
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createModel } from '@rematch/core';
|
|
2
|
+
|
|
3
|
+
import API from '../../providers/API/api';
|
|
4
|
+
import { downloadFile, extractFileName } from '../../utils/url';
|
|
5
|
+
|
|
6
|
+
import type { RootModel } from '.';
|
|
7
|
+
|
|
8
|
+
export const download = createModel<RootModel>()({
|
|
9
|
+
state: {},
|
|
10
|
+
reducers: {},
|
|
11
|
+
effects: () => ({
|
|
12
|
+
async getTarball({ link }) {
|
|
13
|
+
// const basePath = state.configuration.config.base;
|
|
14
|
+
try {
|
|
15
|
+
const fileStream: Blob = await API.request(link, 'GET', {
|
|
16
|
+
headers: {
|
|
17
|
+
['accept']:
|
|
18
|
+
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
|
|
19
|
+
},
|
|
20
|
+
credentials: 'include',
|
|
21
|
+
});
|
|
22
|
+
const fileName = extractFileName(link);
|
|
23
|
+
downloadFile(fileStream, fileName);
|
|
24
|
+
} catch (error: any) {
|
|
25
|
+
// TODO: handle better error
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.error('error on download', error);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Models } from '@rematch/core';
|
|
2
|
+
|
|
3
|
+
import { configuration } from './configuration';
|
|
4
|
+
import { download } from './download';
|
|
5
|
+
import { login } from './login';
|
|
6
|
+
import { manifest } from './manifest';
|
|
7
|
+
import { packages } from './packages';
|
|
8
|
+
import { search } from './search';
|
|
9
|
+
export interface RootModel extends Models<RootModel> {
|
|
10
|
+
packages: typeof packages;
|
|
11
|
+
manifest: typeof manifest;
|
|
12
|
+
configuration: typeof configuration;
|
|
13
|
+
download: typeof download;
|
|
14
|
+
login: typeof login;
|
|
15
|
+
search: typeof search;
|
|
16
|
+
}
|
|
17
|
+
export const models: RootModel = { packages, configuration, search, download, login, manifest };
|