diff --git a/CHANGELOG.md b/CHANGELOG.md index f7a0ac98c..0934057d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -# 1.0.0 +# 1.1.x + +- `assertSingletonPackage` now warns via console.warn, but does not throw. This does allow the info to come accross while still allowing the app developers using multiple libraries time to fix. + +# 1.0.1 - `formatBalance` now allows for `Compact` inputs - `formaBalance` now allows correct formatting of very large decimals diff --git a/package.json b/package.json index 1894d78ae..293eb0b73 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ }, "devDependencies": { "@babel/core": "^7.5.5", - "@polkadot/dev": "^0.30.0-beta.24", - "@polkadot/ts": "^0.1.62", + "@polkadot/dev": "^0.30.0-beta.26", + "@polkadot/ts": "^0.1.63", "gh-pages": "2.0.1" } } diff --git a/packages/util/src/assertSingletonPackage.spec.ts b/packages/util/src/assertSingletonPackage.spec.ts index 99cf2dcdf..7da61360e 100644 --- a/packages/util/src/assertSingletonPackage.spec.ts +++ b/packages/util/src/assertSingletonPackage.spec.ts @@ -7,15 +7,19 @@ import { assertSingletonPackage } from '.'; describe('assertSingletonPackage', (): void => { const NAME = 'assertSingletonPackage'; - it('should not throw the first time', (): void => { - expect( - (): void => assertSingletonPackage(NAME) - ).not.toThrow(); + it('should not log the first time', (): void => { + const spy = jest.spyOn(console, 'warn'); + + assertSingletonPackage(NAME); + expect(spy).not.toHaveBeenCalled(); + spy.mockRestore(); }); - it('should throw the second time', (): void => { - expect( - (): void => assertSingletonPackage(NAME) - ).toThrow(/Multiple versions of assertSingletonPackage detected/); + it('should log the second time', (): void => { + const spy = jest.spyOn(console, 'warn'); + + assertSingletonPackage(NAME); + expect(spy).toHaveBeenCalledWith('Multiple versions of assertSingletonPackage detected, ensure that there is only one version in your dependency tree'); + spy.mockRestore(); }); }); diff --git a/packages/util/src/assertSingletonPackage.ts b/packages/util/src/assertSingletonPackage.ts index 78b8897f0..447a79c92 100644 --- a/packages/util/src/assertSingletonPackage.ts +++ b/packages/util/src/assertSingletonPackage.ts @@ -3,7 +3,6 @@ // of the Apache-2.0 license. See the LICENSE file for details. import isUndefined from './is/undefined'; -import assert from './assert'; interface PjsChecks { __polkadotjs: Record; @@ -25,7 +24,9 @@ export default function assertSingletonPackage (name: string): void { _global.__polkadotjs = {}; } - assert(isUndefined(_global.__polkadotjs[name]), `Multiple versions of ${name} detected, ensure that there is only version one in your dependency tree`); + if (!isUndefined(_global.__polkadotjs[name])) { + console.warn(`Multiple versions of ${name} detected, ensure that there is only one version in your dependency tree`); + } _global.__polkadotjs[name] = true; } diff --git a/yarn.lock b/yarn.lock index 723e22ae2..0d90ca665 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1795,10 +1795,10 @@ universal-user-agent "^3.0.0" url-template "^2.0.8" -"@polkadot/dev@^0.30.0-beta.24": - version "0.30.0-beta.24" - resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.30.0-beta.24.tgz#b007707551dafabfcd6f77faf14a73106a9afc96" - integrity sha512-jbty6uUL+UHLHS8hwSSUp+G6BYyPAYU2SJdBy1KFexuaeMcEQ0n7J8EmgJ6TPegYAs8rmk3jX2xxwct/mUKuTQ== +"@polkadot/dev@^0.30.0-beta.26": + version "0.30.0-beta.26" + resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.30.0-beta.26.tgz#2291b61711f9ae5ab147fca4a6739a55322ce5ef" + integrity sha512-nYAjzZ4SbZOc4tvh9sKDWyWogZC3ORmApFoiV2H5JdUB1zt6EvcqmEOMb1RhrAJggYQqijF+FhmOG78A+9yaqQ== dependencies: "@babel/cli" "^7.5.5" "@babel/core" "^7.5.5" @@ -1811,7 +1811,7 @@ "@babel/preset-typescript" "^7.3.3" "@babel/register" "^7.5.5" "@babel/runtime" "^7.5.5" - "@types/jest" "^24.0.16" + "@types/jest" "^24.0.17" "@types/node" "^12.6.9" "@typescript-eslint/eslint-plugin" "^1.13.0" "@typescript-eslint/parser" "^1.13.0" @@ -1837,12 +1837,12 @@ tslint "^5.18.0" tslint-config-standard "^8.0.1" typedoc "^0.15.0" - typedoc-plugin-markdown "^2.1.0" + typedoc-plugin-markdown "^2.1.1" typedoc-plugin-no-inherit "^1.1.9" typescript "^3.5.3" vuepress "^1.0.3" -"@polkadot/ts@^0.1.62": +"@polkadot/ts@^0.1.63": version "0.1.63" resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.63.tgz#9de0014e706014fc4ce059bc37fd6818d20de492" integrity sha512-NYdq63CFBp1+4V9RMzbaIxG7doaSvIVWlFBb6hMEu0MemheULiag+Gj/98lalVYipB8a4KCBoaIt//YTCEh6oQ== @@ -1978,10 +1978,10 @@ resolved "https://registry.yarnpkg.com/@types/jest-diff/-/jest-diff-20.0.1.tgz#35cc15b9c4f30a18ef21852e255fdb02f6d59b89" integrity sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA== -"@types/jest@^24.0.16": - version "24.0.16" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.0.16.tgz#8d3e406ec0f0dc1688d6711af3062ff9bd428066" - integrity sha512-JrAiyV+PPGKZzw6uxbI761cHZ0G7QMOHXPhtSpcl08rZH6CswXaaejckn3goFKmF7M3nzEoJ0lwYCbqLMmjziQ== +"@types/jest@^24.0.17": + version "24.0.17" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.0.17.tgz#b66ea026efb746eb5db1356ee28518aaff7af416" + integrity sha512-1cy3xkOAfSYn78dsBWy4M3h/QF/HeWPchNFDjysVtp3GHeTdSmtluNnELfCmfNRRHo0OWEcpf+NsEJQvwQfdqQ== dependencies: "@types/jest-diff" "*" @@ -11447,10 +11447,10 @@ typedoc-default-themes@^0.6.0: lunr "^2.3.6" underscore "^1.9.1" -typedoc-plugin-markdown@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-2.1.0.tgz#17b7b97415b97214985d1a61ef7b9a4dce3e8305" - integrity sha512-f7CgreapeUIpm85BnC4ec9PZp10INOpLpItSCV4YFlZS4VaBA/a1D2nYv9+7TVJugc084XlSFUY+OX9fwGAUpA== +typedoc-plugin-markdown@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-2.1.1.tgz#b9bbb48c23b1994be3b9b09f2626887bac613aa0" + integrity sha512-AQxnYLwdOzwCTo+VAVIxIXuVdMsK3Jamyd4m29630Llga+i59dqsYyduFFlzlJM8Xu8EiVCeURwr+vwMl87Gqg== typedoc-plugin-no-inherit@^1.1.9: version "1.1.9"