From 0b832893bf924f4e9706422b87d93f992f7506ce Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Wed, 14 Aug 2024 17:20:43 +1000 Subject: [PATCH] fix(@dpc-sdp/ripple-tide-api): :alien: cheerio default export has been removed --- jest.config.js | 4 +- .../nuxt-ripple/server/plugins/prefetch.ts | 4 +- packages/ripple-tide-api/package.json | 4 +- .../src/utils/markup-transpiler/index.ts | 4 +- pnpm-lock.yaml | 90 +++++++++++++++---- 5 files changed, 83 insertions(+), 23 deletions(-) diff --git a/jest.config.js b/jest.config.js index 4729fb4e4a..eac7da33c3 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,7 +13,9 @@ module.exports = { '^.+\\.ts$': '/node_modules/ts-jest', '.*\\.vue$': '/node_modules/@vue/vue3-jest' }, - transformIgnorePatterns: ['node_modules/(?!.pnpm)(?!(ripple-*|lodash-es)/)'], + transformIgnorePatterns: [ + 'node_modules/(?!.pnpm)(?!(ripple-*|lodash-es|cheerio)/)' + ], extensionsToTreatAsEsm: ['.ts'], moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', diff --git a/packages/nuxt-ripple/server/plugins/prefetch.ts b/packages/nuxt-ripple/server/plugins/prefetch.ts index d1d9f851f0..edc060719a 100644 --- a/packages/nuxt-ripple/server/plugins/prefetch.ts +++ b/packages/nuxt-ripple/server/plugins/prefetch.ts @@ -1,4 +1,4 @@ -import * as cheerio from 'cheerio' +import { load } from 'cheerio' import type { NitroApp } from 'nitropack' // fix type stub - See https://github.com/nuxt/nuxt/issues/18556 @@ -17,7 +17,7 @@ export default defineNitroPlugin((nitroApp) => { // https://github.com/nuxt/nuxt/issues/18376 html.head = html.head.map((head) => { - const $ = cheerio.load(head) + const $ = load(head) $('link[rel=prefetch]').each(function () { $(this).remove() }) diff --git a/packages/ripple-tide-api/package.json b/packages/ripple-tide-api/package.json index 17c097757f..d61082c2a1 100644 --- a/packages/ripple-tide-api/package.json +++ b/packages/ripple-tide-api/package.json @@ -26,7 +26,7 @@ "@nuxt/kit": "3.11.2", "axios": "^1.3.4", "change-case": "^4.1.2", - "cheerio": "^1.0.0-rc.10", + "cheerio": "^1.0.0", "h3": "^1.9.0", "js-yaml": "^4.1.0", "jsonapi-parse": "^2.0.1", @@ -41,7 +41,7 @@ }, "devDependencies": { "@nuxt/schema": "3.11.2", - "@types/cheerio": "^0.22.31", + "@types/cheerio": "^0.22.35", "axios-mock-adapter": "^1.21.3", "defu": "^6.1.2", "rimraf": "^4.4.1" diff --git a/packages/ripple-tide-api/src/utils/markup-transpiler/index.ts b/packages/ripple-tide-api/src/utils/markup-transpiler/index.ts index 0951befc75..6da8b383c4 100644 --- a/packages/ripple-tide-api/src/utils/markup-transpiler/index.ts +++ b/packages/ripple-tide-api/src/utils/markup-transpiler/index.ts @@ -1,4 +1,4 @@ -import cheerio from 'cheerio' +import { load } from 'cheerio' import defaultPlugins from './default-plugins.js' // A markup transpiler for converting HTML into Vue template by giving plugins. @@ -10,7 +10,7 @@ const markupTranspiler = ( if (!html) { return '' } - const $ = cheerio.load(html, options) + const $ = load(html, options) const $body = $('body') let markupData = {} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2a3bf72abb..ca1b0530d1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -596,8 +596,8 @@ importers: specifier: ^4.1.2 version: 4.1.2 cheerio: - specifier: ^1.0.0-rc.10 - version: 1.0.0-rc.12 + specifier: ^1.0.0 + version: 1.0.0 h3: specifier: ^1.9.0 version: 1.10.1 @@ -636,7 +636,7 @@ importers: specifier: 3.11.2 version: 3.11.2(rollup@4.14.3) '@types/cheerio': - specifier: ^0.22.31 + specifier: ^0.22.35 version: 0.22.35 axios-mock-adapter: specifier: ^1.21.3 @@ -6918,9 +6918,9 @@ packages: cheerio-select@2.1.0: resolution: {integrity: sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==} - cheerio@1.0.0-rc.12: - resolution: {integrity: sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==} - engines: {node: '>= 6'} + cheerio@1.0.0: + resolution: {integrity: sha512-quS9HgjQpdaXOvsZz82Oz7uxtXiy6UIsIQcpBj7HRw2M63Skasm9qlDocAM7jNuaxdhpPU7c4kJN+gA5MCu4ww==} + engines: {node: '>=18.17'} chokidar@3.5.3: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} @@ -7993,6 +7993,9 @@ packages: domutils@3.0.1: resolution: {integrity: sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==} + domutils@3.1.0: + resolution: {integrity: sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==} + dot-case@2.1.1: resolution: {integrity: sha512-HnM6ZlFqcajLsyudHq7LeeLDr2rFAVYtDv/hV5qchQEidSck8j9OPUsXY9KwJv/lHMtYlX4DjRQqwFYa+0r8Ug==} @@ -8086,6 +8089,9 @@ packages: resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==} engines: {node: '>= 0.8'} + encoding-sniffer@0.2.0: + resolution: {integrity: sha512-ju7Wq1kg04I3HtiYIOrUrdfdDvkyO9s5XM8QAj/bN61Yo/Vb4vgJxy5vi4Yxk01gWHbrofpPtpxM8bKger9jhg==} + encoding@0.1.13: resolution: {integrity: sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==} @@ -9395,6 +9401,9 @@ packages: htmlparser2@8.0.1: resolution: {integrity: sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==} + htmlparser2@9.1.0: + resolution: {integrity: sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==} + http-cache-semantics@4.1.1: resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==} @@ -12060,6 +12069,9 @@ packages: parse5-htmlparser2-tree-adapter@7.0.0: resolution: {integrity: sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==} + parse5-parser-stream@7.1.2: + resolution: {integrity: sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==} + parse5@7.1.2: resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==} @@ -14795,6 +14807,10 @@ packages: resolution: {integrity: sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==} engines: {node: '>=14.0'} + undici@6.19.7: + resolution: {integrity: sha512-HR3W/bMGPSr90i8AAp2C4DM3wChFdJPLrWYpIS++LxS8K+W535qftjt+4MyjNYHeWabMj1nvtmLIi7l++iq91A==} + engines: {node: '>=18.17'} + unenv@1.9.0: resolution: {integrity: sha512-QKnFNznRxmbOF1hDgzpqrlIf6NC5sbZ2OJ+5Wl3OX8uM+LUJXbj4TXvLJCtwbPTmbMHCLIz6JLKNinNsMShK9g==} @@ -15395,8 +15411,8 @@ packages: peerDependencies: typescript: '*' - vue-component-type-helpers@2.0.28: - resolution: {integrity: sha512-hoK0UsKXrXDY9zdpdk+drqOqYHpPhbmfQUJ2mFYK57+l73mQxcYyCteQsolllwGaxhWihT077+OA/FR5ZPTceg==} + vue-component-type-helpers@2.0.29: + resolution: {integrity: sha512-58i+ZhUAUpwQ+9h5Hck0D+jr1qbYl4voRt5KffBx8qzELViQ4XdT/Tuo+mzq8u63teAG8K0lLaOiL5ofqW38rg==} vue-demi@0.14.6: resolution: {integrity: sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==} @@ -15566,10 +15582,18 @@ packages: resolution: {integrity: sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==} engines: {node: '>=12'} + whatwg-encoding@3.1.1: + resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} + engines: {node: '>=18'} + whatwg-mimetype@3.0.0: resolution: {integrity: sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==} engines: {node: '>=12'} + whatwg-mimetype@4.0.0: + resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==} + engines: {node: '>=18'} + whatwg-url@11.0.0: resolution: {integrity: sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==} engines: {node: '>=12'} @@ -22091,7 +22115,7 @@ snapshots: ts-dedent: 2.2.0 type-fest: 2.19.0 vue: 3.4.23(typescript@5.1.3) - vue-component-type-helpers: 2.0.28 + vue-component-type-helpers: 2.0.29 transitivePeerDependencies: - encoding - supports-color @@ -24847,17 +24871,21 @@ snapshots: css-what: 6.1.0 domelementtype: 2.3.0 domhandler: 5.0.3 - domutils: 3.0.1 + domutils: 3.1.0 - cheerio@1.0.0-rc.12: + cheerio@1.0.0: dependencies: cheerio-select: 2.1.0 dom-serializer: 2.0.0 domhandler: 5.0.3 - domutils: 3.0.1 - htmlparser2: 8.0.1 + domutils: 3.1.0 + encoding-sniffer: 0.2.0 + htmlparser2: 9.1.0 parse5: 7.1.2(patch_hash=we4prwxijorghvcqg5y46szn5m) parse5-htmlparser2-tree-adapter: 7.0.0(patch_hash=pbfyvtlxq7sl6kts5un2uoamka) + parse5-parser-stream: 7.1.2 + undici: 6.19.7 + whatwg-mimetype: 4.0.0 chokidar@3.5.3: dependencies: @@ -25481,7 +25509,7 @@ snapshots: boolbase: 1.0.0 css-what: 6.1.0 domhandler: 5.0.3 - domutils: 3.0.1 + domutils: 3.1.0 nth-check: 2.1.1 css-tree@1.0.0-alpha.37: @@ -26043,6 +26071,12 @@ snapshots: domelementtype: 2.3.0 domhandler: 5.0.3 + domutils@3.1.0: + dependencies: + dom-serializer: 2.0.0 + domelementtype: 2.3.0 + domhandler: 5.0.3 + dot-case@2.1.1: dependencies: no-case: 2.3.2 @@ -26118,6 +26152,11 @@ snapshots: encodeurl@1.0.2: {} + encoding-sniffer@0.2.0: + dependencies: + iconv-lite: 0.6.3 + whatwg-encoding: 3.1.1 + encoding@0.1.13: dependencies: iconv-lite: 0.6.3 @@ -27932,6 +27971,13 @@ snapshots: domutils: 3.0.1 entities: 4.5.0 + htmlparser2@9.1.0: + dependencies: + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.1.0 + entities: 4.5.0 + http-cache-semantics@4.1.1: {} http-encoding@1.5.1: @@ -30209,7 +30255,7 @@ snapshots: metaparser@1.0.7: dependencies: async: 3.2.4 - cheerio: 1.0.0-rc.12 + cheerio: 1.0.0 mkdirp: 2.1.6 underscore: 1.13.6 @@ -31977,6 +32023,10 @@ snapshots: domhandler: 5.0.3 parse5: 7.1.2(patch_hash=we4prwxijorghvcqg5y46szn5m) + parse5-parser-stream@7.1.2: + dependencies: + parse5: 7.1.2(patch_hash=we4prwxijorghvcqg5y46szn5m) + parse5@7.1.2(patch_hash=we4prwxijorghvcqg5y46szn5m): dependencies: entities: 4.5.0 @@ -35144,6 +35194,8 @@ snapshots: dependencies: '@fastify/busboy': 2.1.0 + undici@6.19.7: {} + unenv@1.9.0: dependencies: consola: 3.2.3 @@ -35915,7 +35967,7 @@ snapshots: typesafe-path: 0.2.2 typescript: 5.1.3 - vue-component-type-helpers@2.0.28: {} + vue-component-type-helpers@2.0.29: {} vue-demi@0.14.6(vue@3.4.23(typescript@5.1.3)): dependencies: @@ -36133,8 +36185,14 @@ snapshots: dependencies: iconv-lite: 0.6.3 + whatwg-encoding@3.1.1: + dependencies: + iconv-lite: 0.6.3 + whatwg-mimetype@3.0.0: {} + whatwg-mimetype@4.0.0: {} + whatwg-url@11.0.0: dependencies: tr46: 3.0.0