From c814080957b2aaf729e38703fb2e36a62bec8d73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2019 22:51:21 +0000 Subject: [PATCH 1/8] chore(deps): bump lodash.merge from 4.6.1 to 4.6.2 Bumps [lodash.merge](https://github.com/lodash/lodash) from 4.6.1 to 4.6.2. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/commits) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index f1b4a56..10b0ab7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8154,9 +8154,9 @@ lodash.memoize@^4.1.2: integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= lodash.merge@^4.6.1: - version "4.6.1" - resolved "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54" - integrity sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ== + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== lodash.once@^4.0.0: version "4.1.1" From cca2c3c0d72459931b0ab9d0dfb9925a2c1d27b5 Mon Sep 17 00:00:00 2001 From: Griffithtp Date: Wed, 10 Jul 2019 23:51:25 +0100 Subject: [PATCH 2/8] fix: localhost domain download tarball button --- src/utils/url.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/url.ts b/src/utils/url.ts index 68da74f..4832633 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -6,6 +6,7 @@ export function isURL(url): boolean { return isURLValidator(url || '', { protocols: ['http', 'https', 'git+https'], require_protocol: true, + require_tld: false, }); } From 46e5f09dbf751baae64796d73396574e0ec64bab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jul 2019 07:17:47 +0000 Subject: [PATCH 3/8] chore(deps): bump lodash.template from 4.4.0 to 4.5.0 Bumps [lodash.template](https://github.com/lodash/lodash) from 4.4.0 to 4.5.0. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.4.0...4.5.0) Signed-off-by: dependabot[bot] --- yarn.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index f1b4a56..2d8c2bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8088,9 +8088,9 @@ lockfile@1.0.4: dependencies: signal-exit "^3.0.2" -lodash._reinterpolate@~3.0.0: +lodash._reinterpolate@^3.0.0: version "3.0.0" - resolved "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" + resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= lodash.camelcase@^4.3.0: @@ -8174,19 +8174,19 @@ lodash.sortby@^4.7.0: integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= lodash.template@^4.0.2: - version "4.4.0" - resolved "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0" - integrity sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A= + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" + integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A== dependencies: - lodash._reinterpolate "~3.0.0" + lodash._reinterpolate "^3.0.0" lodash.templatesettings "^4.0.0" lodash.templatesettings@^4.0.0: - version "4.1.0" - resolved "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz#2b4d4e95ba440d915ff08bc899e4553666713316" - integrity sha1-K01OlbpEDZFf8IvImeRVNmZxMxY= + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz#e481310f049d3cf6d47e912ad09313b154f0fb33" + integrity sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ== dependencies: - lodash._reinterpolate "~3.0.0" + lodash._reinterpolate "^3.0.0" lodash.unescape@4.0.1: version "4.0.1" From 5148fdca66342a0efeb0a2298a57f7723507dafe Mon Sep 17 00:00:00 2001 From: Griffithtp Date: Sat, 13 Jul 2019 07:53:23 +0100 Subject: [PATCH 4/8] refactor: add @types/validator --- package.json | 1 + src/utils/url.ts | 2 +- yarn.lock | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d05c834..c94e9bb 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@types/react": "16.8.16", "@types/react-dom": "16.8.4", "@types/react-router-dom": "4.3.2", + "@types/validator": "10.11.1", "@verdaccio/babel-preset": "0.2.1", "@verdaccio/eslint-config": "0.0.1", "@verdaccio/types": "6.1.0", diff --git a/src/utils/url.ts b/src/utils/url.ts index 4832633..119888e 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -2,7 +2,7 @@ import isURLValidator from 'validator/lib/isURL'; import isEmailValidator from 'validator/lib/isEmail'; import '../../types'; -export function isURL(url): boolean { +export function isURL(url: string): boolean { return isURLValidator(url || '', { protocols: ['http', 'https', 'git+https'], require_protocol: true, diff --git a/yarn.lock b/yarn.lock index f1b4a56..ffdd3c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1743,6 +1743,11 @@ resolved "https://registry.verdaccio.org/@types%2funist/-/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e" integrity sha512-FvUupuM3rlRsRtCN+fDudtmytGO6iHJuuRKS1Ss0pG5z8oX0diNEw94UEL7hgDbpN94rgaK5R7sWm6RrSkZuAQ== +"@types/validator@10.11.1": + version "10.11.1" + resolved "https://registry.npmjs.org/@types/validator/-/validator-10.11.1.tgz#76e983ce155261838463b73728856cf8bc628d53" + integrity sha512-bVhLqvb+5xUNWRFnuuecRVISTvsG6AdhrB2kb/tChgtuTTqARqlQ3rLhOPy8cINZEUB8PkR+goyWF6fWxg4iSw== + "@types/vfile-message@*": version "1.0.1" resolved "https://registry.verdaccio.org/@types%2fvfile-message/-/vfile-message-1.0.1.tgz#e1e9895cc6b36c462d4244e64e6d0b6eaf65355a" From 795544a14ccd58b99627946fcec9067e7cdf0823 Mon Sep 17 00:00:00 2001 From: Griffithtp Date: Sat, 13 Jul 2019 15:28:25 +0100 Subject: [PATCH 5/8] test: add unit test for url utils --- src/utils/url.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/utils/url.test.ts diff --git a/src/utils/url.test.ts b/src/utils/url.test.ts new file mode 100644 index 0000000..33b99b1 --- /dev/null +++ b/src/utils/url.test.ts @@ -0,0 +1,27 @@ +import { isURL, isEmail, getRegistryURL } from './url'; + +describe('url', () => { + test('isURL() - should return true for localhost', () => { + expect(isURL('http://localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz')).toBeTruthy(); + }); + + test('isURL() - should return false when protocol is missing', () => { + expect(isURL('localhost:8080/bootstrap/-/bootstrap-4.3.1.tgz')).toBeFalsy(); + }); + + test('isEmail() - should return true if valid', () => { + expect(isEmail('email@domain.com')).toBeTruthy(); + }); + test('isEmail() - should return false if invalid', () => { + expect(isEmail('')).toBeFalsy(); + }); + + test('getRegistryURL() - should keep slash if location is a sub directory', () => { + history.pushState({}, 'page title', '/-/web/detail'); + expect(getRegistryURL()).toBe('http://localhost/-/web/detail'); + history.pushState({}, 'page title', '/'); + }); + test('getRegistryURL() - should not add slash if location is not a sub directory', () => { + expect(getRegistryURL()).toBe('http://localhost'); + }); +}); From ecc452131417c888165c7e4918d963c103cfbf16 Mon Sep 17 00:00:00 2001 From: Griffithtp Date: Sun, 14 Jul 2019 12:35:57 +0100 Subject: [PATCH 6/8] refactor: remove getBaseNamePath() and history.ts --- src/history.ts | 8 -------- src/router.tsx | 6 +++++- src/utils/url.ts | 8 -------- 3 files changed, 5 insertions(+), 17 deletions(-) delete mode 100644 src/history.ts diff --git a/src/history.ts b/src/history.ts deleted file mode 100644 index a8f41b8..0000000 --- a/src/history.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { createBrowserHistory } from 'history'; -import { getBaseNamePath } from './utils/url'; - -const history = createBrowserHistory({ - basename: getBaseNamePath(), -}); - -export default history; diff --git a/src/router.tsx b/src/router.tsx index dcc0e2b..394b8ee 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -2,12 +2,16 @@ import React, { Component, ReactElement } from 'react'; import { Router, Route, Switch } from 'react-router-dom'; +import { createBrowserHistory } from 'history'; import { AppContextConsumer, AppStateInterface } from './App/App'; import { asyncComponent } from './utils/asyncComponent'; -import history from './history'; import Header from './components/Header'; +const history = createBrowserHistory({ + basename: window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix, +}); + const NotFound = asyncComponent(() => import('./components/NotFound')); const VersionPackage = asyncComponent(() => import('./pages/version/Version')); const HomePage = asyncComponent(() => import('./pages/home')); diff --git a/src/utils/url.ts b/src/utils/url.ts index 119888e..d428410 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -18,11 +18,3 @@ export function getRegistryURL(): string { // Don't add slash if it's not a sub directory return `${location.origin}${location.pathname === '/' ? '' : location.pathname}`; } - -export function getBaseNamePath(): string { - return window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix; -} - -export function getRootPath(): string { - return window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.base; -} From 2ffb2b5bf103b1838db0b826af7e2f8542be4cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Herrera=20Guzm=C3=A1n?= Date: Sun, 14 Jul 2019 18:08:20 +0200 Subject: [PATCH 7/8] chore: execute commitlint on commit-msg and not pre-commit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c94e9bb..bc960f4 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,7 @@ }, "husky": { "hooks": { - "pre-commit": "commitlint -e $GIT_PARAMS" + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } }, "license": "MIT", From ec243b1352dd0475b8ee3624a66c247c05958b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Herrera=20Guzm=C3=A1n?= Date: Mon, 15 Jul 2019 14:43:44 +0200 Subject: [PATCH 8/8] fix: css repetition is not closed in Logo component --- src/components/Header/__snapshots__/Header.test.tsx.snap | 4 ++-- src/components/Loading/__snapshots__/Loading.test.tsx.snap | 2 +- src/components/Logo/Logo.tsx | 1 + src/components/Logo/__snapshots__/Logo.test.tsx.snap | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/Header/__snapshots__/Header.test.tsx.snap b/src/components/Header/__snapshots__/Header.test.tsx.snap index 547a7a4..228f683 100644 --- a/src/components/Header/__snapshots__/Header.test.tsx.snap +++ b/src/components/Header/__snapshots__/Header.test.tsx.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`
component with logged in state should load the component in logged in state 1`] = `"
"`; +exports[`
component with logged in state should load the component in logged in state 1`] = `"
"`; -exports[`
component with logged out state should load the component in logged out state 1`] = `"
"`; +exports[`
component with logged out state should load the component in logged out state 1`] = `"
"`; diff --git a/src/components/Loading/__snapshots__/Loading.test.tsx.snap b/src/components/Loading/__snapshots__/Loading.test.tsx.snap index 5d29230..502a45a 100644 --- a/src/components/Loading/__snapshots__/Loading.test.tsx.snap +++ b/src/components/Loading/__snapshots__/Loading.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[` component should render the component in default state 1`] = `"
"`; +exports[` component should render the component in default state 1`] = `"
"`; diff --git a/src/components/Logo/Logo.tsx b/src/components/Logo/Logo.tsx index b8abe82..0436255 100644 --- a/src/components/Logo/Logo.tsx +++ b/src/components/Logo/Logo.tsx @@ -23,6 +23,7 @@ const StyledLogo = styled('div')` background-repeat: no-repeat; width: ${({ size }) => size}; height: ${({ size }) => size}; + } `; const Logo: React.FC = ({ size = Size.Small }) => { return ; diff --git a/src/components/Logo/__snapshots__/Logo.test.tsx.snap b/src/components/Logo/__snapshots__/Logo.test.tsx.snap index 5a6b61a..837e012 100644 --- a/src/components/Logo/__snapshots__/Logo.test.tsx.snap +++ b/src/components/Logo/__snapshots__/Logo.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[` component should render the component in default state 1`] = `"
"`; +exports[` component should render the component in default state 1`] = `"
"`;