diff --git a/.eslintrc b/.eslintrc index 1d1b87842..c007b0994 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,6 +1,7 @@ { "extends": [ "@verdaccio", + "prettier", "plugin:react/recommended", "plugin:jest/recommended", "plugin:prettier/recommended", diff --git a/i18n/config.ts b/i18n/config.ts index 7410050dc..dbcdd9e11 100644 --- a/i18n/config.ts +++ b/i18n/config.ts @@ -64,7 +64,7 @@ i18n // init i18next // for all options read: https://www.i18next.com/overview/configuration-options .init({ - // in case window.VEDACCIO_LANGUAGE is undefined,it will fall back to 'en-US' + // in case window.__VERDACCIO_BASENAME_UI_OPTIONS.language is undefined,it will fall back to 'en-US' lng: window?.__VERDACCIO_BASENAME_UI_OPTIONS?.language || 'en-US', fallbackLng: 'en-US', whitelist: [ diff --git a/jest/jest.config.js b/jest/jest.config.js index 6eba0620c..616526047 100644 --- a/jest/jest.config.js +++ b/jest/jest.config.js @@ -15,6 +15,7 @@ module.exports = { '/scripts', '/.circleci', '/tools', + '/jest', '/build', '/.vscode/', '/test/e2e/', @@ -28,6 +29,7 @@ module.exports = { // note: this section has to be on sync with webpack configuration 'verdaccio-ui/components/(.*)': '/src/components/$1', 'verdaccio-ui/utils/(.*)': '/src/utils/$1', + 'verdaccio-ui/providers/(.*)': '/src/providers/$1', 'verdaccio-ui/design-tokens/(.*)': '/src/design-tokens/$1', }, }; diff --git a/jest/setup.ts b/jest/setup.ts index a45f14f8f..086d0334e 100644 --- a/jest/setup.ts +++ b/jest/setup.ts @@ -5,12 +5,20 @@ import { GlobalWithFetchMock } from 'jest-fetch-mock'; import 'mutationobserver-shim'; -// @ts-ignore : Property '__APP_VERSION__' does not exist on type 'Global'. -global.__APP_VERSION__ = '1.0.0'; // @ts-ignore : Property '__VERDACCIO_BASENAME_UI_OPTIONS' does not exist on type 'Global'. -global.__VERDACCIO_BASENAME_UI_OPTIONS = { base: 'http://localhost' }; -// @ts-ignore : Property 'VERDACCIO_API_URL' does not exist on type 'Global'. -global.VERDACCIO_API_URL = 'https://verdaccio.tld'; +global.__VERDACCIO_BASENAME_UI_OPTIONS = { + base: 'http://localhost', + protocol: 'http', + host: 'localhost', + primaryColor: '#4b5e40', + url_prefix: '', + darkMode: false, + language: 'en-US', + uri: 'http://localhost:4872', + title: 'Verdaccio Dev UI', + scope: '', + version: 'v1.0.0', +}; const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock; customGlobal.fetch = require('jest-fetch-mock'); diff --git a/package.json b/package.json index bd3fc4b6f..e26177e2f 100644 --- a/package.json +++ b/package.json @@ -90,11 +90,11 @@ "emotion": "10.0.27", "emotion-theming": "10.0.27", "eslint": "7.15.0", + "eslint-config-prettier": "7.2.0", "eslint-loader": "^4.0.2", "eslint-plugin-codeceptjs": "1.3.0", "eslint-plugin-import": "2.22.1", "eslint-plugin-jsx-a11y": "6.4.1", - "eslint-plugin-prettier": "3.2.0", "eslint-plugin-react": "7.21.5", "eslint-plugin-react-hooks": "4.2.0", "eslint-plugin-verdaccio": "9.6.1", @@ -153,7 +153,7 @@ "typescript": "3.9.6", "url-loader": "^4.1.1", "validator": "13.1.1", - "verdaccio": "4.8.1", + "verdaccio": "4.11.3", "verdaccio-auth-memory": "9.7.2", "verdaccio-memory": "9.7.2", "wait-on": "5.2.0", @@ -212,11 +212,9 @@ }, "lint-staged": { "*.{js,tsx,ts}": [ - "eslint . --ext .js,.ts,.tsx", - "prettier --write" + "eslint . --ext .js,.ts,.tsx" ], "*": [ - "detect-secrets-launcher --baseline .secrets-baseline --word-list", "git add" ] }, diff --git a/partials/storage/jquery/jquery-3.3.1.tgz b/partials/storage/jquery/jquery-3.3.1.tgz new file mode 100644 index 000000000..2241e568c Binary files /dev/null and b/partials/storage/jquery/jquery-3.3.1.tgz differ diff --git a/partials/storage/jquery/package.json b/partials/storage/jquery/package.json index 408c4caec..a457e0ec8 100644 --- a/partials/storage/jquery/package.json +++ b/partials/storage/jquery/package.json @@ -4981,7 +4981,7 @@ "shasum": "958ce29e81c9790f31be7792df5d4d95fc57fbca" } }, - "_rev": "61-e6be890a78963127", + "_rev": "63-5c66112fe65cff7d", "readme": "# jQuery\n\n> jQuery is a fast, small, and feature-rich JavaScript library.\n\nFor information on how to get started and how to use jQuery, please see [jQuery's documentation](http://api.jquery.com/).\nFor source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery).\n\nIf upgrading, please see the [blog post for 3.3.1](https://blog.jquery.com/2017/03/20/jquery-3.3.1-now-available/). This includes notable differences from the previous version and a more readable changelog.\n\n## Including jQuery\n\nBelow are some of the most common ways to include jQuery.\n\n### Browser\n\n#### Script tag\n\n```html\n\n```\n\n#### Babel\n\n[Babel](http://babeljs.io/) is a next generation JavaScript compiler. One of the features is the ability to use ES6/ES2015 modules now, even though browsers do not yet support this feature natively.\n\n```js\nimport $ from \"jquery\";\n```\n\n#### Browserify/Webpack\n\nThere are several ways to use [Browserify](http://browserify.org/) and [Webpack](https://webpack.github.io/). For more information on using these tools, please refer to the corresponding project's documention. In the script, including jQuery will usually look like this...\n\n```js\nvar $ = require(\"jquery\");\n```\n\n#### AMD (Asynchronous Module Definition)\n\nAMD is a module format built for the browser. For more information, we recommend [require.js' documentation](http://requirejs.org/docs/whyamd.html).\n\n```js\ndefine([\"jquery\"], function($) {\n\n});\n```\n\n### Node\n\nTo include jQuery in [Node](nodejs.org), first install with npm.\n\n```sh\nnpm install jquery\n```\n\nFor jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/tmpvar/jsdom). This can be useful for testing purposes.\n\n```js\nrequire(\"jsdom\").env(\"\", function(err, window) {\n\tif (err) {\n\t\tconsole.error(err);\n\t\treturn;\n\t}\n\n\tvar $ = require(\"jquery\")(window);\n});\n```", "_id": "jquery" -} +} \ No newline at end of file diff --git a/src/App/App.test.tsx b/src/App/App.test.tsx index 1f03b6bbd..dd4cea4bc 100644 --- a/src/App/App.test.tsx +++ b/src/App/App.test.tsx @@ -30,7 +30,7 @@ jest.mock('verdaccio-ui/utils/storage', () => { return new LocalStorageMock(); }); -jest.mock('verdaccio-ui/utils/api', () => ({ +jest.mock('verdaccio-ui/providers/API/api', () => ({ // eslint-disable-next-line jest/no-mocks-import request: require('../../jest/unit/components/__mocks__/api').default.request, })); diff --git a/src/App/App.tsx b/src/App/App.tsx index c375f5c49..ea23e9e13 100644 --- a/src/App/App.tsx +++ b/src/App/App.tsx @@ -35,7 +35,7 @@ const StyledBoxContent = styled(Box)<{ theme?: Theme }>(({ theme }) => ({ /* eslint-disable react/jsx-no-bind */ /* eslint-disable react-hooks/exhaustive-deps */ const App: React.FC = () => { - const [user, setUser] = useState(); + const [user, setUser] = useState(); /** * Logout user * Required by:
diff --git a/src/App/AppContext.ts b/src/App/AppContext.ts index a8837ab52..006c1c09b 100644 --- a/src/App/AppContext.ts +++ b/src/App/AppContext.ts @@ -6,7 +6,7 @@ export interface AppProps { } export interface User { - username: string; + username: string | null; } export interface AppContextProps extends AppProps { diff --git a/src/App/AppContextProvider.tsx b/src/App/AppContextProvider.tsx index 6422891ac..686cf2860 100644 --- a/src/App/AppContextProvider.tsx +++ b/src/App/AppContextProvider.tsx @@ -1,5 +1,7 @@ import React, { useState, useEffect } from 'react'; +import { useConfig } from 'verdaccio-ui/providers/config'; + import AppContext, { AppProps, User } from './AppContext'; interface Props { @@ -8,8 +10,9 @@ interface Props { /* eslint-disable react-hooks/exhaustive-deps */ const AppContextProvider: React.FC = ({ children, user }) => { + const { configOptions } = useConfig(); const [state, setState] = useState({ - scope: window.VERDACCIO_SCOPE || '', + scope: configOptions.scope ?? '', user, }); diff --git a/src/App/AppRoute.tsx b/src/App/AppRoute.tsx index 99244214f..b141148e5 100644 --- a/src/App/AppRoute.tsx +++ b/src/App/AppRoute.tsx @@ -22,8 +22,7 @@ enum Route { } export const history = createBrowserHistory({ - // @ts-ignore - basename: window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix, + basename: window?.__VERDACCIO_BASENAME_UI_OPTIONS?.url_prefix, }); const AppRoute: React.FC = () => { @@ -36,7 +35,7 @@ const AppRoute: React.FC = () => { const { user } = appContext; - const isUserLoggedIn = user && user.username; + const isUserLoggedIn = user?.username; return ( diff --git a/src/App/Footer/Footer.test.tsx b/src/App/Footer/Footer.test.tsx index 771aaa788..3e2970eeb 100644 --- a/src/App/Footer/Footer.test.tsx +++ b/src/App/Footer/Footer.test.tsx @@ -6,11 +6,11 @@ import Footer from './Footer'; describe('