From 49a2188885982e2a35738e7c5c788d82d725174f Mon Sep 17 00:00:00 2001 From: Meng Ye <4025839+jk2K@users.noreply.github.com> Date: Sun, 19 Nov 2023 11:39:10 +0800 Subject: [PATCH] fix: local build error, fix crunchbase api error Signed-off-by: jk2K <4025839+jk2K@users.noreply.github.com> --- .yarnrc.yml | 2 +- package.json | 4 ++-- specs/main.spec.js | 3 ++- tools/crunchbase.js | 16 ++++++++-------- tools/renderItems.js | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.yarnrc.yml b/.yarnrc.yml index 4dce263e..f2e1cfec 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1,3 +1,3 @@ enableProgressBars: false -yarnPath: .yarn/releases/yarn-3.2.1.cjs +yarnPath: .yarn/releases/yarn-4.0.2.cjs diff --git a/package.json b/package.json index 7b264b2d..d19913ab 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "lodash": "^4.17.21", "node-emoji": "^1.11.0", "oauth-1.0a": "^2.2.6", - "puppeteer": "^14.2.1", + "puppeteer": "^21.5.2", "query-string": "^7.1.1", "relative-date": "1.1.3", "sanitize-html": "^2.7.0", @@ -93,5 +93,5 @@ "type": "git", "url": "https://github.com/cncf/landscapeapp" }, - "packageManager": "yarn@3.2.1" + "packageManager": "yarn@4.0.2" } diff --git a/specs/main.spec.js b/specs/main.spec.js index b4ba0fc9..7a473029 100644 --- a/specs/main.spec.js +++ b/specs/main.spec.js @@ -28,7 +28,8 @@ jest.setTimeout(process.env.SHOW_BROWSER ? 30000 : 30000); async function makePage(initialUrl) { try { - browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox'], headless: !process.env.SHOW_BROWSER}); + const headlessParam = process.env.SHOW_BROWSER ? false: "new"; + browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox'], headless: headlessParam}); const page = await browser.newPage(); await page.goto(initialUrl); await page.setViewport({ width, height }); diff --git a/tools/crunchbase.js b/tools/crunchbase.js index e2b1d97a..48f72c9b 100644 --- a/tools/crunchbase.js +++ b/tools/crunchbase.js @@ -153,22 +153,22 @@ const fetchData = module.exports.fetchData = async function(name) { } return result1; } - let acquisitions = result.cards.acquiree_acquisitions.map(mapAcquisitions).filter( (x) => !!x); + let acquisitions = _.get(result, 'cards.acquiree_acquisitions', []).map(mapAcquisitions).filter( (x) => !!x); const limit = 100; let lastPage = result; - while (lastPage.cards.acquiree_acquisitions.length === limit) { + while (_.get(lastPage, 'cards.acquiree_acquisitions', []).length === limit) { lastPage = await CrunchbaseClient.request({ path: `entities/organizations/${name}/cards/acquiree_acquisitions`, - params: {after_id: lastPage.cards.acquiree_acquisitions[limit - 1].identifier.uuid} + params: {after_id: _.get(lastPage, 'cards.acquiree_acquisitions', [])[limit - 1].identifier.uuid} }); - acquisitions = acquisitions.concat(lastPage.cards.acquiree_acquisitions.map(mapAcquisitions)); + acquisitions = acquisitions.concat(_.get(lastPage, 'cards.acquiree_acquisitions', []).map(mapAcquisitions)); } acquisitions = _.orderBy(acquisitions, ['date', 'acquiree']); let parents = []; let lastOrganization = result; - while (lastOrganization.cards.parent_organization[0]) { - const parentOrganization = lastOrganization.cards.parent_organization[0].identifier.permalink + while (_.get(lastOrganization, 'cards.parent_organization', [])[0]) { + const parentOrganization = _.get(lastOrganization, 'cards.parent_organization', [])[0].identifier.permalink if (parents.map(p => p.identifier.permalink).includes(parentOrganization)) { const { permalink } = lastOrganization.properties.identifier throw new Error(`Circular dependency detected: ${permalink} and ${parentOrganization} are parents of each other`) @@ -184,10 +184,10 @@ const fetchData = module.exports.fetchData = async function(name) { const totalFunding = firstWithTotalFunding ? + firstWithTotalFunding.funding_total.value_usd.toFixed() : undefined; const getAddressPart = function(part) { - if (!result.cards.headquarters_address[0]) { + if (!_.get(result, 'cards.headquarters_address', [])[0]) { return " N/A"; } - return (result.cards.headquarters_address[0].location_identifiers.filter( (x) => x.location_type === part)[0] || {}).value + return (_.get(result, 'cards.headquarters_address', [])[0].location_identifiers.filter( (x) => x.location_type === part)[0] || {}).value } diff --git a/tools/renderItems.js b/tools/renderItems.js index 2cd9da3b..13e289f2 100644 --- a/tools/renderItems.js +++ b/tools/renderItems.js @@ -115,7 +115,7 @@ async function main() { } const fonts = await fs.readFile('src/fonts.css', 'utf-8'); - const resizerScript = await fs.readFile(require.resolve('iframe-resizer/js/iframeResizer.contentWindow.min.js'), 'utf-8'); + const resizerScript = await fs.readFile(require.resolve('iframe-resizer/js/iframeResizer.contentWindow.js'), 'utf-8'); const description = `${settings.global.meta.description}. Updated: ${process.env.lastUpdated}`; const favicon = '/favicon.png';