From 3c50876d737ced86f2e3677c1ee7be6328dcdcc9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" Date: Fri, 22 Mar 2019 18:01:04 +0430 Subject: [PATCH 01/11] chore(deps): update all non-major dependencies (#5325) --- distributions/nuxt-ts/package.json | 2 +- distributions/nuxt/package.json | 2 +- packages/babel-preset-app/package.json | 2 +- packages/builder/package.json | 2 +- packages/typescript/package.json | 2 +- yarn.lock | 114 +++++++++++++++---------- 6 files changed, 74 insertions(+), 50 deletions(-) diff --git a/distributions/nuxt-ts/package.json b/distributions/nuxt-ts/package.json index b5808ab2d9..5d1d3feb07 100644 --- a/distributions/nuxt-ts/package.json +++ b/distributions/nuxt-ts/package.json @@ -60,7 +60,7 @@ "@nuxt/cli": "2.5.1", "@nuxt/core": "2.5.1", "@nuxt/generator": "2.5.1", - "@nuxt/loading-screen": "^0.1.2", + "@nuxt/loading-screen": "^0.1.3", "@nuxt/opencollective": "^0.2.1", "@nuxt/typescript": "2.5.1", "@nuxt/webpack": "2.5.1" diff --git a/distributions/nuxt/package.json b/distributions/nuxt/package.json index 7203f6bc0f..2bb2d601ae 100644 --- a/distributions/nuxt/package.json +++ b/distributions/nuxt/package.json @@ -58,7 +58,7 @@ "@nuxt/cli": "2.5.1", "@nuxt/core": "2.5.1", "@nuxt/generator": "2.5.1", - "@nuxt/loading-screen": "^0.1.2", + "@nuxt/loading-screen": "^0.1.3", "@nuxt/opencollective": "^0.2.1", "@nuxt/webpack": "2.5.1" }, diff --git a/packages/babel-preset-app/package.json b/packages/babel-preset-app/package.json index 2f46cfd89d..2b44557001 100644 --- a/packages/babel-preset-app/package.json +++ b/packages/babel-preset-app/package.json @@ -17,7 +17,7 @@ "@babel/plugin-transform-runtime": "^7.4.0", "@babel/preset-env": "^7.4.2", "@babel/runtime": "^7.4.2", - "@vue/babel-preset-jsx": "^1.0.0-beta.2", + "@vue/babel-preset-jsx": "^1.0.0-beta.3", "core-js": "^2.6.5" }, "publishConfig": { diff --git a/packages/builder/package.json b/packages/builder/package.json index 7af260ea44..677abd4b66 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -11,7 +11,7 @@ "@nuxt/devalue": "^1.2.2", "@nuxt/utils": "2.5.1", "@nuxt/vue-app": "2.5.1", - "chokidar": "^2.1.2", + "chokidar": "^2.1.4", "consola": "^2.5.7", "fs-extra": "^7.0.1", "glob": "^7.1.3", diff --git a/packages/typescript/package.json b/packages/typescript/package.json index 3cce97b78c..d0299a78ad 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -13,7 +13,7 @@ "@types/etag": "^1.8.0", "@types/express": "^4.16.1", "@types/html-minifier": "^3.5.3", - "@types/node": "^11.11.4", + "@types/node": "^11.11.5", "@types/optimize-css-assets-webpack-plugin": "^1.3.4", "@types/serve-static": "^1.13.2", "@types/terser-webpack-plugin": "^1.2.1", diff --git a/yarn.lock b/yarn.lock index 7df24b24c2..494e7e31f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1461,10 +1461,10 @@ error-stack-parser "^2.0.0" string-width "^2.0.0" -"@nuxt/loading-screen@^0.1.2": - version "0.1.2" - resolved "https://registry.npmjs.org/@nuxt/loading-screen/-/loading-screen-0.1.2.tgz#2438ce21fcc1ae33cbd5168430b763c7ee93626d" - integrity sha512-IsSySwZ5nHF34RUdsTEElvx/dLP8uBDTek1xL5vuqgBL+4hsanbBPMhz2B9XSkCLM0wrqKORaZAfY1ZYXmHajA== +"@nuxt/loading-screen@^0.1.3": + version "0.1.3" + resolved "https://registry.npmjs.org/@nuxt/loading-screen/-/loading-screen-0.1.3.tgz#5061d067e56b2191941f616afbabe5fcfbff6800" + integrity sha512-DEI1r2kNgWhQVosHmihxhC9aYU6sHeTIFZ4Dg0pgHrfe51A2C4Th+G9G+aouqG3XSpC5OKZZ9SKqs+A6j8hMDQ== dependencies: connect "^3.6.6" fs-extra "^7.0.1" @@ -1684,11 +1684,16 @@ resolved "https://registry.npmjs.org/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d" integrity sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw== -"@types/node@*", "@types/node@^11.11.4", "@types/node@^11.9.5": +"@types/node@*", "@types/node@^11.9.5": version "11.11.4" resolved "https://registry.npmjs.org/@types/node/-/node-11.11.4.tgz#8808bd5a82bbf6f5d412eff1c228d178e7c24bb3" integrity sha512-02tIL+QIi/RW4E5xILdoAMjeJ9kYq5t5S2vciUdFPXv/ikFTb0zK8q9vXkg4+WAJuYXGiVT1H28AkD2C+IkXVw== +"@types/node@^11.11.5": + version "11.11.5" + resolved "https://registry.npmjs.org/@types/node/-/node-11.11.5.tgz#0c57e12eb44d44e5b6735593925286553ee7cebf" + integrity sha512-pz6wNe/XwyesgfVX7P6B0hY3TnTAYXk6KSTLdpQfbuq3be+hnMoCuFzE+yLTskPdBwmNiGRL2TAsnF09aRugvQ== + "@types/optimize-css-assets-webpack-plugin@^1.3.4": version "1.3.4" resolved "https://registry.npmjs.org/@types/optimize-css-assets-webpack-plugin/-/optimize-css-assets-webpack-plugin-1.3.4.tgz#6838ab7a3a5ec1253ad98c348bdcd009e91b39cd" @@ -1785,68 +1790,68 @@ resolved "https://registry.npmjs.org/@types/yargs/-/yargs-12.0.10.tgz#17a8ec65cd8e88f51b418ceb271af18d3137df67" integrity sha512-WsVzTPshvCSbHThUduGGxbmnwcpkgSctHGHTqzWyFg4lYAuV5qXlyFPOsP3OWqCINfmg/8VXP+zJaa4OxEsBQQ== -"@vue/babel-helper-vue-jsx-merge-props@^1.0.0-beta.2": - version "1.0.0-beta.2" - resolved "https://registry.npmjs.org/@vue/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-1.0.0-beta.2.tgz#f3e20d77b89ddb7a4b9b7a75372f05cd3ac22d92" - integrity sha512-Yj92Q1GcGjjctecBfnBmVqKSlMdyZaVq10hlZB4HSd1DJgu4cWgpEImJSzcJRUCZmas6UigwE7f4IjJuQs+JvQ== +"@vue/babel-helper-vue-jsx-merge-props@^1.0.0-beta.3": + version "1.0.0-beta.3" + resolved "https://registry.npmjs.org/@vue/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-1.0.0-beta.3.tgz#e4c2e7125b3e0d2a9d493e457850b2abb0fd3cad" + integrity sha512-cbFQnd3dDPsfWuxbWW2phynX2zsckwC4GfAkcE1QH1lZL2ZAD2V97xY3BmvTowMkjeFObRKQt1P3KKA6AoB0hQ== -"@vue/babel-plugin-transform-vue-jsx@^1.0.0-beta.2": - version "1.0.0-beta.2" - resolved "https://registry.npmjs.org/@vue/babel-plugin-transform-vue-jsx/-/babel-plugin-transform-vue-jsx-1.0.0-beta.2.tgz#6f7903fe66a34a02163f418c426cf419e862d97e" - integrity sha512-fvAymRZAPHitomRE+jIipWRj0STXNSMqeOSdOFu9Ffjqg9WGOxSdCjORxexManfZ2y5QDv7gzI1xfgprsK3nlw== +"@vue/babel-plugin-transform-vue-jsx@^1.0.0-beta.3": + version "1.0.0-beta.3" + resolved "https://registry.npmjs.org/@vue/babel-plugin-transform-vue-jsx/-/babel-plugin-transform-vue-jsx-1.0.0-beta.3.tgz#a1a44e801d8ed615e49f145ef1b3eaca2c16e2e6" + integrity sha512-yn+j2B/2aEagaxXrMSK3qcAJnlidfXg9v+qmytqrjUXc4zfi8QVC/b4zCev1FDmTip06/cs/csENA4law6Xhpg== dependencies: "@babel/helper-module-imports" "^7.0.0" "@babel/plugin-syntax-jsx" "^7.2.0" - "@vue/babel-helper-vue-jsx-merge-props" "^1.0.0-beta.2" + "@vue/babel-helper-vue-jsx-merge-props" "^1.0.0-beta.3" html-tags "^2.0.0" lodash.kebabcase "^4.1.1" svg-tags "^1.0.0" -"@vue/babel-preset-jsx@^1.0.0-beta.2": - version "1.0.0-beta.2" - resolved "https://registry.npmjs.org/@vue/babel-preset-jsx/-/babel-preset-jsx-1.0.0-beta.2.tgz#3e5dc2b73da58391c1c7327c2bd2ef154fe4e46e" - integrity sha512-nZoAKBR/h6iPMQ66ieQcIdlpPBmqhtUUcgjBS541jIVxSog1rwzrc00jlsuecLonzUMWPU0PabyitsG74vhN1w== +"@vue/babel-preset-jsx@^1.0.0-beta.3": + version "1.0.0-beta.3" + resolved "https://registry.npmjs.org/@vue/babel-preset-jsx/-/babel-preset-jsx-1.0.0-beta.3.tgz#15c584bd62c0286a80f0196749ae38cde5cd703b" + integrity sha512-qMKGRorTI/0nE83nLEM7MyQiBZUqc62sZyjkBdVaaU7S61MHI8RKHPtbLMMZlWXb2NCJ0fQci8xJWUK5JE+TFA== dependencies: - "@vue/babel-helper-vue-jsx-merge-props" "^1.0.0-beta.2" - "@vue/babel-plugin-transform-vue-jsx" "^1.0.0-beta.2" - "@vue/babel-sugar-functional-vue" "^1.0.0-beta.2" - "@vue/babel-sugar-inject-h" "^1.0.0-beta.2" - "@vue/babel-sugar-v-model" "^1.0.0-beta.2" - "@vue/babel-sugar-v-on" "^1.0.0-beta.2" + "@vue/babel-helper-vue-jsx-merge-props" "^1.0.0-beta.3" + "@vue/babel-plugin-transform-vue-jsx" "^1.0.0-beta.3" + "@vue/babel-sugar-functional-vue" "^1.0.0-beta.3" + "@vue/babel-sugar-inject-h" "^1.0.0-beta.3" + "@vue/babel-sugar-v-model" "^1.0.0-beta.3" + "@vue/babel-sugar-v-on" "^1.0.0-beta.3" -"@vue/babel-sugar-functional-vue@^1.0.0-beta.2": - version "1.0.0-beta.2" - resolved "https://registry.npmjs.org/@vue/babel-sugar-functional-vue/-/babel-sugar-functional-vue-1.0.0-beta.2.tgz#8831f686e7614f282d5170b902483ef538deef38" - integrity sha512-5qvi4hmExgjtrESDk0vflL69dIxkDAukJcYH9o4663E8Nh12Jpbmr+Ja8WmgkAPtTVhk90UVcVUFCCZLHBmhkQ== +"@vue/babel-sugar-functional-vue@^1.0.0-beta.3": + version "1.0.0-beta.3" + resolved "https://registry.npmjs.org/@vue/babel-sugar-functional-vue/-/babel-sugar-functional-vue-1.0.0-beta.3.tgz#41a855786971dacbbe8044858eefe98de089bf12" + integrity sha512-CBIa0sQWn3vfBS2asfTgv0WwdyKvNTKtE/cCfulZ7MiewLBh0RlvvSmdK9BIMTiHErdeZNSGUGlU6JuSHLyYkQ== dependencies: "@babel/plugin-syntax-jsx" "^7.2.0" -"@vue/babel-sugar-inject-h@^1.0.0-beta.2": - version "1.0.0-beta.2" - resolved "https://registry.npmjs.org/@vue/babel-sugar-inject-h/-/babel-sugar-inject-h-1.0.0-beta.2.tgz#5f92f994bf4b4126fad8633f554e8a426b51b413" - integrity sha512-qGXZ6yE+1trk82xCVJ9j3shsgI+R2ePj3+o8b2Ee7JNaRqQvMfTwpgx5BRlk4q1+CTjvYexdqBS+q4Kg7sSxcg== +"@vue/babel-sugar-inject-h@^1.0.0-beta.3": + version "1.0.0-beta.3" + resolved "https://registry.npmjs.org/@vue/babel-sugar-inject-h/-/babel-sugar-inject-h-1.0.0-beta.3.tgz#be1d00b74a1a89fed35a9b1415a738c36f125966" + integrity sha512-HKMBMmFfdK9GBp3rX2bHIwILBdgc5F3ahmCB72keJxzaAQrgDAnD+ho70exUge+inAGlNF34WsQcGPElTf9QZg== dependencies: "@babel/plugin-syntax-jsx" "^7.2.0" -"@vue/babel-sugar-v-model@^1.0.0-beta.2": - version "1.0.0-beta.2" - resolved "https://registry.npmjs.org/@vue/babel-sugar-v-model/-/babel-sugar-v-model-1.0.0-beta.2.tgz#051d3ae3ef5e70d514e09058ec5790f6a42e8c28" - integrity sha512-63US3IMEtATJzzK2le/Na53Sk2bp3LHfwZ8eMFwbTaz6e2qeV9frBl3ZYaha64ghT4IDSbrDXUmm0J09EAzFfA== +"@vue/babel-sugar-v-model@^1.0.0-beta.3": + version "1.0.0-beta.3" + resolved "https://registry.npmjs.org/@vue/babel-sugar-v-model/-/babel-sugar-v-model-1.0.0-beta.3.tgz#ea935b0e08bf58c125a1349b819156059590993c" + integrity sha512-et39eTEh7zW4wfZoSl9Jf0/n2r9OTT8U02LtSbXsjgYcqaDQFusN0+n7tw4bnOqvnnSVjEp7bVsQCWwykC3Wgg== dependencies: "@babel/plugin-syntax-jsx" "^7.2.0" - "@vue/babel-helper-vue-jsx-merge-props" "^1.0.0-beta.2" - "@vue/babel-plugin-transform-vue-jsx" "^1.0.0-beta.2" + "@vue/babel-helper-vue-jsx-merge-props" "^1.0.0-beta.3" + "@vue/babel-plugin-transform-vue-jsx" "^1.0.0-beta.3" camelcase "^5.0.0" html-tags "^2.0.0" svg-tags "^1.0.0" -"@vue/babel-sugar-v-on@^1.0.0-beta.2": - version "1.0.0-beta.2" - resolved "https://registry.npmjs.org/@vue/babel-sugar-v-on/-/babel-sugar-v-on-1.0.0-beta.2.tgz#3e2d122e229b10017f091d178346b601d9245260" - integrity sha512-XH/m3k11EKdMY0MrTg4+hQv8BFM8juzHT95chYkgxDmvDdVJnSCuf9+mcysEJttWD4PVuUGN7EHoIWsIhC0dRw== +"@vue/babel-sugar-v-on@^1.0.0-beta.3": + version "1.0.0-beta.3" + resolved "https://registry.npmjs.org/@vue/babel-sugar-v-on/-/babel-sugar-v-on-1.0.0-beta.3.tgz#2f5fedb43883f603fe76010f253b85c7465855fe" + integrity sha512-F+GapxCiy50jf2Q2B4exw+KYBzlGdeKMAMW1Dbvb0Oa59SA0CH6tsUOIAsXb0A05jwwg/of0LaVeo+4aLefVxQ== dependencies: "@babel/plugin-syntax-jsx" "^7.2.0" - "@vue/babel-plugin-transform-vue-jsx" "^1.0.0-beta.2" + "@vue/babel-plugin-transform-vue-jsx" "^1.0.0-beta.3" camelcase "^5.0.0" "@vue/component-compiler-utils@^2.4.0", "@vue/component-compiler-utils@^2.5.1": @@ -3022,7 +3027,7 @@ cheerio@^1.0.0-rc.2: lodash "^4.15.0" parse5 "^3.0.1" -chokidar@*, chokidar@^2.0.2, chokidar@^2.0.4, chokidar@^2.1.2: +chokidar@*, chokidar@^2.0.2, chokidar@^2.0.4: version "2.1.2" resolved "https://registry.npmjs.org/chokidar/-/chokidar-2.1.2.tgz#9c23ea40b01638439e0513864d362aeacc5ad058" integrity sha512-IwXUx0FXc5ibYmPC2XeEj5mpXoV66sR+t3jqu2NS2GYwCktt3KF1/Qqjws/NkegajBA4RbZ5+DDwlOiJsxDHEg== @@ -3041,6 +3046,25 @@ chokidar@*, chokidar@^2.0.2, chokidar@^2.0.4, chokidar@^2.1.2: optionalDependencies: fsevents "^1.2.7" +chokidar@^2.1.4: + version "2.1.4" + resolved "https://registry.npmjs.org/chokidar/-/chokidar-2.1.4.tgz#244a65d68beedf1078c2f193cf2735c2cfdc7da2" + integrity sha512-ZVuFiB9IGOHqu+Jh7B7fSTmzsfDmUtC6yqd/V72UPQeXbNHONbMV0chOXtLXjsP3NvdUsHTNMg02NtXPDaSmNQ== + dependencies: + anymatch "^2.0.0" + async-each "^1.0.1" + braces "^2.3.2" + glob-parent "^3.1.0" + inherits "^2.0.3" + is-binary-path "^1.0.0" + is-glob "^4.0.0" + normalize-path "^3.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.2.1" + upath "^1.1.1" + optionalDependencies: + fsevents "^1.2.7" + chownr@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494" @@ -11037,7 +11061,7 @@ unset-value@^1.0.0: has-value "^0.3.1" isobject "^3.0.0" -upath@^1.1.0, upath@^1.1.2: +upath@^1.1.0, upath@^1.1.1, upath@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz#3db658600edaeeccbe6db5e684d67ee8c2acd068" integrity sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q== From 39bbe46ecb9c7c790362fbc76546e7d8f31606ff Mon Sep 17 00:00:00 2001 From: Pim Date: Sat, 23 Mar 2019 07:46:00 +0100 Subject: [PATCH 02/11] fix(cli): catch all possible errors thrown from proper-filelock (#5347) --- packages/utils/src/locking.js | 52 ++++++++++++++++--- packages/utils/test/locking.test.js | 80 ++++++++++++++++++++++++++--- 2 files changed, 116 insertions(+), 16 deletions(-) diff --git a/packages/utils/src/locking.js b/packages/utils/src/locking.js index d0ee5f0f07..c9b7fc15ba 100644 --- a/packages/utils/src/locking.js +++ b/packages/utils/src/locking.js @@ -35,16 +35,33 @@ export async function getLockPath(config) { export async function lock({ id, dir, root, options }) { const lockPath = await getLockPath({ id, dir, root }) - const locked = await properlock.check(lockPath) - if (locked) { - consola.fatal(`A lock with id '${id}' already exists on ${dir}`) + try { + const locked = await properlock.check(lockPath) + if (locked) { + consola.fatal(`A lock with id '${id}' already exists on ${dir}`) + } + } catch (e) { + consola.debug(`Check for an existing lock with id '${id}' on ${dir} failed`, e) } - options = getLockOptions(options) - const release = await properlock.lock(lockPath, options) + let lockWasCompromised = false + let release + + try { + options = getLockOptions(options) + + const onCompromised = options.onCompromised + options.onCompromised = (err) => { + onCompromised(err) + lockWasCompromised = true + } + + release = await properlock.lock(lockPath, options) + } catch (e) {} if (!release) { consola.warn(`Unable to get a lock with id '${id}' on ${dir} (but will continue)`) + return false } if (!lockPaths.size) { @@ -59,8 +76,27 @@ export async function lock({ id, dir, root, options }) { lockPaths.add(lockPath) return async function lockRelease() { - await release() - await fs.remove(lockPath) - lockPaths.delete(lockPath) + try { + await fs.remove(lockPath) + lockPaths.delete(lockPath) + + // release as last so the lockPath is still removed + // when it fails on a compromised lock + await release() + } catch (e) { + if (!lockWasCompromised || !e.message.includes('already released')) { + consola.debug(e) + return + } + + // proper-lockfile doesnt remove lockDir when lock is compromised + // removing it here could cause the 'other' process to throw an error + // as well, but in our case its much more likely the lock was + // compromised due to mtime update timeouts + const lockDir = `${lockPath}.lock` + if (await fs.exists(lockDir)) { + await fs.remove(lockDir) + } + } } } diff --git a/packages/utils/test/locking.test.js b/packages/utils/test/locking.test.js index 225c64157c..52acfd6ddb 100644 --- a/packages/utils/test/locking.test.js +++ b/packages/utils/test/locking.test.js @@ -61,7 +61,7 @@ describe('util: locking', () => { }) test('lock creates a lock and returns a release fn', async () => { - properlock.lock.mockImplementationOnce(() => true) + properlock.lock.mockReturnValue(true) const fn = await lock(lockConfig) @@ -75,7 +75,7 @@ describe('util: locking', () => { }) test('lock throws error when lock already exists', async () => { - properlock.check.mockImplementationOnce(() => true) + properlock.check.mockReturnValue(true) await lock(lockConfig) expect(properlock.check).toHaveBeenCalledTimes(1) @@ -84,7 +84,19 @@ describe('util: locking', () => { }) test('lock logs warning when it couldnt get a lock', async () => { - properlock.lock.mockImplementationOnce(() => false) + properlock.lock.mockReturnValue(false) + + const fn = await lock(lockConfig) + expect(fn).toBe(false) + expect(properlock.lock).toHaveBeenCalledTimes(1) + expect(consola.warn).toHaveBeenCalledTimes(1) + expect(consola.warn).toHaveBeenCalledWith(`Unable to get a lock with id '${lockConfig.id}' on ${lockConfig.dir} (but will continue)`) + }) + + test('lock logs warning when proper.lock threw error', async () => { + properlock.lock.mockImplementation(() => { + throw new Error('test error') + }) await lock(lockConfig) expect(properlock.lock).toHaveBeenCalledTimes(1) @@ -94,7 +106,7 @@ describe('util: locking', () => { test('lock returns a release method for unlocking both lockfile as lockPath', async () => { const release = jest.fn() - properlock.lock.mockImplementationOnce(() => release) + properlock.lock.mockImplementation(() => release) const fn = await lock(lockConfig) await fn() @@ -105,7 +117,7 @@ describe('util: locking', () => { test('lock release also cleansup onExit set', async () => { const release = jest.fn() - properlock.lock.mockImplementationOnce(() => release) + properlock.lock.mockImplementation(() => release) const fn = await lock(lockConfig) expect(lockPaths.size).toBe(1) @@ -114,8 +126,58 @@ describe('util: locking', () => { expect(lockPaths.size).toBe(0) }) + test('lock release only logs error when error thrown', async () => { + const release = jest.fn(() => { + throw new Error('test error') + }) + properlock.lock.mockImplementation(() => release) + + const fn = await lock(lockConfig) + await expect(fn()).resolves.not.toThrow() + + expect(consola.debug).toHaveBeenCalledTimes(1) + }) + + test('lock check only logs error when error thrown', async () => { + const testError = new Error('check error') + properlock.lock.mockImplementation(() => () => {}) + properlock.check.mockImplementation(() => { + throw testError + }) + + const fn = await lock(lockConfig) + expect(fn).toEqual(expect.any(Function)) + + expect(consola.debug).toHaveBeenCalledTimes(1) + expect(consola.debug).toHaveBeenCalledWith(`Check for an existing lock with id '${lockConfig.id}' on ${lockConfig.dir} failed`, testError) + }) + + test('lock release doesnt log error when error thrown because lock compromised', async () => { + fs.exists.mockReturnValue(true) + const testError = new Error('Lock is already released') + const release = jest.fn(() => { + throw testError + }) + + properlock.lock.mockImplementation((path, options) => { + options.onCompromised() + return release + }) + + const fn = await lock({ + ...lockConfig, + options: { + // overwrite default compromised which calls consola.warn + onCompromised() {} + } + }) + + await expect(fn()).resolves.not.toThrow() + expect(consola.warn).not.toHaveBeenCalled() + }) + test('lock sets exit listener once to remove lockPaths', async () => { - properlock.lock.mockImplementationOnce(() => true) + properlock.lock.mockReturnValue(true) await lock(lockConfig) await lock(lockConfig) @@ -124,8 +186,10 @@ describe('util: locking', () => { }) test('exit listener removes all lockPaths when called', async () => { + properlock.lock.mockReturnValue(true) + let callback - onExit.mockImplementationOnce(cb => (callback = cb)) + onExit.mockImplementation(cb => (callback = cb)) const lockConfig2 = Object.assign({}, lockConfig, { id: 'id2' }) @@ -145,7 +209,7 @@ describe('util: locking', () => { }) test('lock uses setLockOptions to set defaults', async () => { - const spy = properlock.lock.mockImplementationOnce(() => true) + const spy = properlock.lock.mockReturnValue(true) await lock(lockConfig) From 439b914fd05efd4c197bdf607ff3c296f22adea6 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 23 Mar 2019 11:18:18 +0430 Subject: [PATCH 03/11] fix: fail in case of missing core-js dependency (#5342) --- packages/builder/src/builder.js | 2 +- packages/builder/test/builder.build.test.js | 2 +- packages/vue-app/package.json | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/builder.js b/packages/builder/src/builder.js index e4ebf4d3a2..ec6956abde 100644 --- a/packages/builder/src/builder.js +++ b/packages/builder/src/builder.js @@ -222,7 +222,7 @@ export default class Builder { 'Using npm:\n', `npm i ${dependencyFixes.join(' ')}\n` ) - throw new Error('Missing Template Dependencies') + throw new Error('Missing App Dependencies') } } diff --git a/packages/builder/test/builder.build.test.js b/packages/builder/test/builder.build.test.js index 8c16aea08b..9274ee73fe 100644 --- a/packages/builder/test/builder.build.test.js +++ b/packages/builder/test/builder.build.test.js @@ -263,7 +263,7 @@ describe('builder: builder build', () => { .mockReturnValueOnce({ version: 'alpha' }) .mockReturnValueOnce(undefined) - expect(() => builder.validateTemplate()).toThrow('Missing Template Dependencies') + expect(() => builder.validateTemplate()).toThrow('Missing App Dependencies') expect(nuxt.resolver.requireModule).toBeCalledTimes(2) expect(nuxt.resolver.requireModule).nthCalledWith(1, 'join(vue, package.json)') diff --git a/packages/vue-app/package.json b/packages/vue-app/package.json index 4bb821abbf..ae8b26aa08 100644 --- a/packages/vue-app/package.json +++ b/packages/vue-app/package.json @@ -12,6 +12,7 @@ "main": "dist/vue-app.js", "typings": "types/index.d.ts", "dependencies": { + "core-js": "^2.6.5", "node-fetch": "^2.3.0", "unfetch": "^4.1.0", "vue": "^2.6.10", From 10812e3082198171071d8d8622d1f11fe220adbc Mon Sep 17 00:00:00 2001 From: Dmitry Molotkov Date: Sat, 23 Mar 2019 09:50:33 +0300 Subject: [PATCH 04/11] examples(with-element-ui): fix package scripts (#5349) --- examples/with-element-ui/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/with-element-ui/package.json b/examples/with-element-ui/package.json index 6e1108f59d..6dd5c6c8cc 100644 --- a/examples/with-element-ui/package.json +++ b/examples/with-element-ui/package.json @@ -3,14 +3,14 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "element-ui": "^2", - "nuxt": "latest", - "post-update": "yarn upgrade --latest" + "element-ui": "^2.6.3", + "nuxt": "latest" }, "scripts": { "dev": "nuxt", "build": "nuxt build", - "start": "nuxt start" + "start": "nuxt start", + "post-update": "yarn upgrade --latest" }, "devDependencies": { "node-sass": "^4.6.0", From ce66a8cbeea5ac830ac99e14c78757f664f48272 Mon Sep 17 00:00:00 2001 From: Dmitry Molotkov Date: Sat, 23 Mar 2019 09:51:32 +0300 Subject: [PATCH 05/11] examples(with-buefy): update example (#5348) --- examples/with-buefy/assets/logo.png | Bin 4252 -> 0 bytes examples/with-buefy/components/card.vue | 42 +++++++++++++++ examples/with-buefy/nuxt.config.js | 5 +- examples/with-buefy/package.json | 7 +-- examples/with-buefy/pages/about.vue | 3 -- examples/with-buefy/pages/index.vue | 65 +++++++++++++++--------- examples/with-buefy/plugins/buefy.js | 4 -- 7 files changed, 87 insertions(+), 39 deletions(-) delete mode 100644 examples/with-buefy/assets/logo.png create mode 100644 examples/with-buefy/components/card.vue delete mode 100644 examples/with-buefy/pages/about.vue delete mode 100644 examples/with-buefy/plugins/buefy.js diff --git a/examples/with-buefy/assets/logo.png b/examples/with-buefy/assets/logo.png deleted file mode 100644 index 7f238b598c85d618ae0c601fec86455a2a1ed4e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4252 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 +
+
+
+

+ {{ title }} +

+
+
+
+ +
+
+
+ +
+
+
+ + + diff --git a/examples/with-buefy/nuxt.config.js b/examples/with-buefy/nuxt.config.js index 06cc234cad..663560b91f 100644 --- a/examples/with-buefy/nuxt.config.js +++ b/examples/with-buefy/nuxt.config.js @@ -3,8 +3,9 @@ export default { ** Customize the progress bar color */ loading: { color: '#3B8070' }, - mode: 'spa', - plugins: ['~plugins/buefy'], + modules: [ + 'nuxt-buefy' + ], router: { linkActiveClass: 'is-active' } diff --git a/examples/with-buefy/package.json b/examples/with-buefy/package.json index 126b946569..6e5c6241e8 100644 --- a/examples/with-buefy/package.json +++ b/examples/with-buefy/package.json @@ -10,12 +10,7 @@ "post-update": "yarn upgrade --latest" }, "dependencies": { - "buefy": "^0.5.4", "nuxt": "latest", - "vue": "~2.4.4" - }, - "devDependencies": { - "node-sass": "^4.6.0", - "sass-loader": "^6.0.6" + "nuxt-buefy": "latest" } } diff --git a/examples/with-buefy/pages/about.vue b/examples/with-buefy/pages/about.vue deleted file mode 100644 index 484c798b82..0000000000 --- a/examples/with-buefy/pages/about.vue +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/examples/with-buefy/pages/index.vue b/examples/with-buefy/pages/index.vue index 443f64cb5a..dafce719a3 100644 --- a/examples/with-buefy/pages/index.vue +++ b/examples/with-buefy/pages/index.vue @@ -1,28 +1,45 @@ - + diff --git a/examples/with-buefy/plugins/buefy.js b/examples/with-buefy/plugins/buefy.js deleted file mode 100644 index 9fc091d0b9..0000000000 --- a/examples/with-buefy/plugins/buefy.js +++ /dev/null @@ -1,4 +0,0 @@ -import Vue from 'vue' -import Buefy from 'buefy' - -Vue.use(Buefy) From a6ee8bfea07a0bfaf46ac5f6db1125af1472a766 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" Date: Sat, 23 Mar 2019 11:22:12 +0430 Subject: [PATCH 06/11] chore(deps): update all non-major dependencies (#5346) --- packages/builder/package.json | 2 +- packages/typescript/package.json | 2 +- packages/webpack/package.json | 2 +- yarn.lock | 24 ++++++++++++------------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/builder/package.json b/packages/builder/package.json index 677abd4b66..ff51967878 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -11,7 +11,7 @@ "@nuxt/devalue": "^1.2.2", "@nuxt/utils": "2.5.1", "@nuxt/vue-app": "2.5.1", - "chokidar": "^2.1.4", + "chokidar": "^2.1.5", "consola": "^2.5.7", "fs-extra": "^7.0.1", "glob": "^7.1.3", diff --git a/packages/typescript/package.json b/packages/typescript/package.json index d0299a78ad..4878086cef 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -13,7 +13,7 @@ "@types/etag": "^1.8.0", "@types/express": "^4.16.1", "@types/html-minifier": "^3.5.3", - "@types/node": "^11.11.5", + "@types/node": "^11.11.6", "@types/optimize-css-assets-webpack-plugin": "^1.3.4", "@types/serve-static": "^1.13.2", "@types/terser-webpack-plugin": "^1.2.1", diff --git a/packages/webpack/package.json b/packages/webpack/package.json index 50592f2ed5..918ad515a0 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -20,7 +20,7 @@ "css-loader": "^2.1.1", "cssnano": "^4.1.10", "eventsource-polyfill": "^0.9.6", - "extract-css-chunks-webpack-plugin": "^4.0.1", + "extract-css-chunks-webpack-plugin": "^4.0.2", "file-loader": "^3.0.1", "fs-extra": "^7.0.1", "glob": "^7.1.3", diff --git a/yarn.lock b/yarn.lock index 494e7e31f4..0589a41a36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1689,10 +1689,10 @@ resolved "https://registry.npmjs.org/@types/node/-/node-11.11.4.tgz#8808bd5a82bbf6f5d412eff1c228d178e7c24bb3" integrity sha512-02tIL+QIi/RW4E5xILdoAMjeJ9kYq5t5S2vciUdFPXv/ikFTb0zK8q9vXkg4+WAJuYXGiVT1H28AkD2C+IkXVw== -"@types/node@^11.11.5": - version "11.11.5" - resolved "https://registry.npmjs.org/@types/node/-/node-11.11.5.tgz#0c57e12eb44d44e5b6735593925286553ee7cebf" - integrity sha512-pz6wNe/XwyesgfVX7P6B0hY3TnTAYXk6KSTLdpQfbuq3be+hnMoCuFzE+yLTskPdBwmNiGRL2TAsnF09aRugvQ== +"@types/node@^11.11.6": + version "11.11.6" + resolved "https://registry.npmjs.org/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a" + integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== "@types/optimize-css-assets-webpack-plugin@^1.3.4": version "1.3.4" @@ -3046,10 +3046,10 @@ chokidar@*, chokidar@^2.0.2, chokidar@^2.0.4: optionalDependencies: fsevents "^1.2.7" -chokidar@^2.1.4: - version "2.1.4" - resolved "https://registry.npmjs.org/chokidar/-/chokidar-2.1.4.tgz#244a65d68beedf1078c2f193cf2735c2cfdc7da2" - integrity sha512-ZVuFiB9IGOHqu+Jh7B7fSTmzsfDmUtC6yqd/V72UPQeXbNHONbMV0chOXtLXjsP3NvdUsHTNMg02NtXPDaSmNQ== +chokidar@^2.1.5: + version "2.1.5" + resolved "https://registry.npmjs.org/chokidar/-/chokidar-2.1.5.tgz#0ae8434d962281a5f56c72869e79cb6d9d86ad4d" + integrity sha512-i0TprVWp+Kj4WRPtInjexJ8Q+BqTE909VpH8xVhXrJkoc5QC8VO9TryGOqTr+2hljzc1sC62t22h5tZePodM/A== dependencies: anymatch "^2.0.0" async-each "^1.0.1" @@ -4790,10 +4790,10 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -extract-css-chunks-webpack-plugin@^4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/extract-css-chunks-webpack-plugin/-/extract-css-chunks-webpack-plugin-4.0.1.tgz#8a25ecf89e4a31d74351e487e616ecc79e873052" - integrity sha512-axin0Qz65T4ZQl8FEGW1ZN31kwUJOO7CoiWv0aTupYjmmQdtr56qsW061MuLglzTNwDKTcSe7KbtuzMZ5uc3Cw== +extract-css-chunks-webpack-plugin@^4.0.2: + version "4.0.2" + resolved "https://registry.npmjs.org/extract-css-chunks-webpack-plugin/-/extract-css-chunks-webpack-plugin-4.0.2.tgz#67c1de090079247b9eb4f9d179cd2717ca43c361" + integrity sha512-svwrtf8iENEm5DRhzJp2qpfvapEsVEkrElqUqz8/ZtyfvKA8uT6y4GneOgKBCKK6oh+iVPSHZ+FrI89sxG6EOQ== dependencies: loader-utils "^1.1.0" lodash "^4.17.11" From 95f2a125cf218aaff1259031532d075affc9eefe Mon Sep 17 00:00:00 2001 From: Dmitry Molotkov Date: Sat, 23 Mar 2019 09:55:22 +0300 Subject: [PATCH 07/11] examples(vue-apollo): update to @nuxtjs/apollo 4.x (#5345) --- examples/vue-apollo/apollo/network-interfaces/default.js | 5 ----- examples/vue-apollo/nuxt.config.js | 6 ++++-- examples/vue-apollo/package.json | 4 +++- 3 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 examples/vue-apollo/apollo/network-interfaces/default.js diff --git a/examples/vue-apollo/apollo/network-interfaces/default.js b/examples/vue-apollo/apollo/network-interfaces/default.js deleted file mode 100644 index 7b6d3f6c14..0000000000 --- a/examples/vue-apollo/apollo/network-interfaces/default.js +++ /dev/null @@ -1,5 +0,0 @@ -import { createNetworkInterface } from 'apollo-client' - -export default (ctx) => { - return createNetworkInterface({ uri: 'https://api.graph.cool/simple/v1/cj1dqiyvqqnmj0113yuqamkuu' }) -} diff --git a/examples/vue-apollo/nuxt.config.js b/examples/vue-apollo/nuxt.config.js index 1530134236..ed54e7faed 100644 --- a/examples/vue-apollo/nuxt.config.js +++ b/examples/vue-apollo/nuxt.config.js @@ -1,8 +1,10 @@ export default { modules: ['@nuxtjs/apollo'], apollo: { - networkInterfaces: { - default: '~/apollo/network-interfaces/default.js' + clientConfigs: { + default: { + httpEndpoint: 'https://api.graph.cool/simple/v1/cj1dqiyvqqnmj0113yuqamkuu' + } } } } diff --git a/examples/vue-apollo/package.json b/examples/vue-apollo/package.json index 704507342c..fe23a6fba7 100644 --- a/examples/vue-apollo/package.json +++ b/examples/vue-apollo/package.json @@ -1,7 +1,9 @@ { "name": "example-vue-apollo", "dependencies": { - "@nuxtjs/apollo": "^2.1.1", + "@nuxtjs/apollo": "^4.0.0-rc.4", + "core-js": "^2.6.5", + "node-fetch": "^2.3.0", "nuxt": "latest" }, "scripts": { From caf5198430b9698290106b5a79db1ae03582c56c Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 23 Mar 2019 11:32:55 +0430 Subject: [PATCH 08/11] fix(builder): await for renderer to load resources (#5341) --- packages/vue-renderer/src/renderer.js | 2 +- packages/webpack/src/builder.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vue-renderer/src/renderer.js b/packages/vue-renderer/src/renderer.js index 8239855f62..107144834d 100644 --- a/packages/vue-renderer/src/renderer.js +++ b/packages/vue-renderer/src/renderer.js @@ -140,7 +140,7 @@ export default class VueRenderer { // Try once to load SSR resources from fs await this.loadResources(fs) - // Without using `nuxt start` (Programmatic, Tests and Generate) + // Without using `nuxt start` (programmatic, tests and generate) if (!this.context.options._start) { this.context.nuxt.hook('build:resources', () => this.loadResources(fs)) return diff --git a/packages/webpack/src/builder.js b/packages/webpack/src/builder.js index 7f7251a9a8..3a5f4c6485 100644 --- a/packages/webpack/src/builder.js +++ b/packages/webpack/src/builder.js @@ -173,6 +173,9 @@ export class WebpackBundler { // Actual error will be printed by webpack throw new Error('Nuxt Build Error') } + + // Await for renderer to load resources (programmatic, tests and generate) + await nuxt.callHook('build:resources') } async webpackDev(compiler) { From 535327c4f15c9b75e5014c69f3761b4cdde4b026 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 23 Mar 2019 11:33:08 +0430 Subject: [PATCH 09/11] refactor(vue-renderer): improve ready status error (#5339) --- packages/vue-renderer/src/renderer.js | 57 ++++++++++++++++----------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/packages/vue-renderer/src/renderer.js b/packages/vue-renderer/src/renderer.js index 107144834d..b6d385857f 100644 --- a/packages/vue-renderer/src/renderer.js +++ b/packages/vue-renderer/src/renderer.js @@ -33,6 +33,10 @@ export default class VueRenderer { spaTemplate: undefined, errorTemplate: this.parseTemplate('Nuxt.js Internal Server Error') }) + + // Default status + this._state = 'created' + this._error = null } get assetsMapping() { @@ -120,12 +124,25 @@ export default class VueRenderer { return context.renderResourceHints() } - async ready() { - if (this._readyCalled) { - return this + ready() { + if (!this._readyPromise) { + this._state = 'loading' + this._readyPromise = this._ready() + .then(() => { + this._state = 'ready' + return this + }) + .catch((error) => { + this._state = 'error' + this._error = error + throw error + }) } - this._readyCalled = true + return this._readyPromise + } + + async _ready() { // Resolve dist path this.distPath = path.resolve(this.context.options.buildDir, 'dist', 'server') @@ -156,8 +173,6 @@ export default class VueRenderer { `No build files found in ${this.distPath}.\nUse either \`nuxt build\` or \`builder.build()\` or start nuxt in development mode.` ) } - - return this } async loadResources(_fs) { @@ -186,7 +201,6 @@ export default class VueRenderer { // Skip unavailable resources if (!resource) { - consola.debug('Resource not available:', resourceName) continue } @@ -212,9 +226,6 @@ export default class VueRenderer { this.createRenderer() } - // Call resourcesLoaded hook - consola.debug('Resources loaded:', updated.join(',')) - return this.context.nuxt.callHook('render:resourcesLoaded', this.context.resources) } @@ -437,23 +448,23 @@ export default class VueRenderer { } } - _throwNotReadyError() { - const error = new Error() - - error.statusCode = 500 - if (!this._readyCalled) { - error.message = 'Nuxt is not initialized! `nuxt.ready()` should be called.' - } else { - error.message = `SSR renderer is not initialized! Please check ${this.distPath} existence.` - } - throw error - } - async renderRoute(url, context = {}) { /* istanbul ignore if */ if (!this.isReady) { + // Production if (!this.context.options.dev) { - return this._throwNotReadyError() + switch (this._state) { + case 'created': + throw new Error('Renderer ready() is not called! Please ensure `nuxt.ready()` is called and awaited.') + case 'loading': + throw new Error(`Renderer is loading.`) + case 'error': + throw this._error + case 'ready': + throw new Error(`Renderer is loaded but not all resources are unavailable! Please check ${this.distPath} existence.`) + default: + throw new Error('Renderer is in unknown state!') + } } // Tell nuxt middleware to render UI return false From 71054e5f6118a64e927c05e25ce72909505472d3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" Date: Sat, 23 Mar 2019 12:25:40 +0430 Subject: [PATCH 10/11] chore(deps): update dependency @nuxt/loading-screen to ^0.2.0 (#5353) --- distributions/nuxt-ts/package.json | 2 +- distributions/nuxt/package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/distributions/nuxt-ts/package.json b/distributions/nuxt-ts/package.json index 5d1d3feb07..abf1a07074 100644 --- a/distributions/nuxt-ts/package.json +++ b/distributions/nuxt-ts/package.json @@ -60,7 +60,7 @@ "@nuxt/cli": "2.5.1", "@nuxt/core": "2.5.1", "@nuxt/generator": "2.5.1", - "@nuxt/loading-screen": "^0.1.3", + "@nuxt/loading-screen": "^0.2.0", "@nuxt/opencollective": "^0.2.1", "@nuxt/typescript": "2.5.1", "@nuxt/webpack": "2.5.1" diff --git a/distributions/nuxt/package.json b/distributions/nuxt/package.json index 2bb2d601ae..292b981bdc 100644 --- a/distributions/nuxt/package.json +++ b/distributions/nuxt/package.json @@ -58,7 +58,7 @@ "@nuxt/cli": "2.5.1", "@nuxt/core": "2.5.1", "@nuxt/generator": "2.5.1", - "@nuxt/loading-screen": "^0.1.3", + "@nuxt/loading-screen": "^0.2.0", "@nuxt/opencollective": "^0.2.1", "@nuxt/webpack": "2.5.1" }, diff --git a/yarn.lock b/yarn.lock index 0589a41a36..fadeecf992 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1461,10 +1461,10 @@ error-stack-parser "^2.0.0" string-width "^2.0.0" -"@nuxt/loading-screen@^0.1.3": - version "0.1.3" - resolved "https://registry.npmjs.org/@nuxt/loading-screen/-/loading-screen-0.1.3.tgz#5061d067e56b2191941f616afbabe5fcfbff6800" - integrity sha512-DEI1r2kNgWhQVosHmihxhC9aYU6sHeTIFZ4Dg0pgHrfe51A2C4Th+G9G+aouqG3XSpC5OKZZ9SKqs+A6j8hMDQ== +"@nuxt/loading-screen@^0.2.0": + version "0.2.0" + resolved "https://registry.npmjs.org/@nuxt/loading-screen/-/loading-screen-0.2.0.tgz#fbdfd75814a9935f1827574f2b4c924ac3de81c9" + integrity sha512-QprkUsdOMqwQuw4OeQUX/Fj4LOyLSAAi0aa6mxxpITjfLScTp6Bx2Z+flG0cU19w0L2WSZtdqfQtjY6tYaTVuw== dependencies: connect "^3.6.6" fs-extra "^7.0.1" From 77dcfe6ee8df8b85856d869b680cfec956e516db Mon Sep 17 00:00:00 2001 From: Johan Roxendal Date: Sat, 23 Mar 2019 09:40:38 +0100 Subject: [PATCH 11/11] fix(vue-app): decode uri in `getlocation` (#5337) --- packages/vue-app/template/utils.js | 4 ++-- test/unit/unicode-base.test.js | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/vue-app/template/utils.js b/packages/vue-app/template/utils.js index f9f1d91958..4647f830d7 100644 --- a/packages/vue-app/template/utils.js +++ b/packages/vue-app/template/utils.js @@ -259,14 +259,14 @@ export function promisify(fn, context) { // Imported from vue-router export function getLocation(base, mode) { - let path = window.location.pathname + let path = decodeURI(window.location.pathname) if (mode === 'hash') { return window.location.hash.replace(/^#\//, '') } if (base && path.indexOf(base) === 0) { path = path.slice(base.length) } - return decodeURI(path || '/') + window.location.search + window.location.hash + return (path || '/') + window.location.search + window.location.hash } export function urlJoin() { diff --git a/test/unit/unicode-base.test.js b/test/unit/unicode-base.test.js index c6da4a7d8f..bebef4ff4d 100644 --- a/test/unit/unicode-base.test.js +++ b/test/unit/unicode-base.test.js @@ -19,8 +19,7 @@ describe('unicode-base', () => { const window = await nuxt.server.renderAndGetWindow(url('/รถ/')) const html = window.document.body.innerHTML - // important to have the actual page transition classes here -> page works, no hydration error - expect(html).toContain('

Unicode base works!

') + expect(html).toContain('

Unicode base works!

') }) // Close server and ask nuxt to stop listening to file changes