Skip to content

Remove troublesome deps and punt on the automatic meetup work #795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/community-meta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"license": "MIT",
"version": "1.0.0",
"dependencies": {
"ical-utils": "^1.0.15",
"moment": "2.24.0",
"moment-timezone": "0.5.28"
},
Expand Down
161 changes: 82 additions & 79 deletions packages/community-meta/scripts/generateRichMeetupData.js
Original file line number Diff line number Diff line change
@@ -1,96 +1,99 @@
// @ts-check

const { join } = require('path')
const { writeFileSync } = require('fs')
const { meetups } = require('./meetups')
const xml2js = require('xml2js')
const nodeFetch = require('node-fetch').default
const icalToolkit = require('ical-utils')
const { format } = require('prettier')
const moment = require('moment')
require('moment-timezone')
// Given that COVID dropped meetups, lets disable this
// until things pick up again in 2021

const chalk = require('chalk').default
const { join } = require("path")
const { writeFileSync } = require("fs")
const { meetups } = require("./meetups")
// const xml2js = require("xml2js")
// const nodeFetch = require("node-fetch").default
// const icalToolkit = require("ical-utils")
const { format } = require("prettier")
// const moment = require("moment")
// require("moment-timezone")

const tick = chalk.bold.greenBright('✓')
const cross = chalk.bold.redBright('⤫')
const chalk = require("chalk").default

const tick = chalk.bold.greenBright("✓")
const cross = chalk.bold.redBright("⤫")

const go = async () => {
let meetupDeets = []
console.log('Looking at meetups: ')
console.log("Looking at meetups: ")

for (const meetup of meetups) {
if (meetup !== meetups[0]) process.stdout.write(', ')
if (meetup !== meetups[0]) process.stdout.write(", ")

const meetupURL = meetup.meetup || meetup.url
if (meetupURL.includes('meetup.com')) {
try {
const meetupID = meetupURL.split('/').pop()
process.stdout.write(meetupID)

const icalResponse = await nodeFetch(`https://www.meetup.com/${meetupID}/events/ical/`)
const icalText = await icalResponse.text()
const ical = await icalToolkit.parseToJSON(icalText)

const upcomingEvent = ical.events[0]
if (!upcomingEvent) {
process.stdout.write(' -')
meetupDeets.push({ meetup })

continue
}

const id = upcomingEvent.uid.split('_')[1].split('@')[0]
const title = upcomingEvent.summary.replace(/\\,/g, ',')
const location = upcomingEvent.location.replace(/\\,/g, ',')
const textDescription = upcomingEvent.description.replace(/\\,/g, ',').replace(/\\n/g, '<br />')
const date = moment(upcomingEvent.start.value).tz(upcomingEvent.start.tzid)
const url = upcomingEvent.additionalTags.URL

let richDescription = '<p>' + upcomingEvent.description + '</p>'

// Best to not assume meetup.com's long term health, and it's rss
const rssResponse = await nodeFetch(`https://www.meetup.com/${meetupID}/events/rss/`)
const rssText = await rssResponse.text()
const rss = await xml2js.parseStringPromise(rssText)

// const removeDoubleLinks =

const upcoming = rss.rss.channel[0].item[0]

if (upcoming.title[0] === title) {
richDescription = upcoming.description[0]
}

const linkifiedRegex = new RegExp(`<a href="[^>]+" class="linkified">`, "g")
let filteredRichText = richDescription.replace(linkifiedRegex, "").replace(new RegExp("</a></a>"), "</a>")

const event = {
id,
url,
date,
location,
textDescription,
richDescription: filteredRichText,
title,
}

meetupDeets.push({ meetup, event })
process.stdout.write(' ' + tick)
} catch (error) {
console.log(error)
meetupDeets.push({ meetup })
process.stdout.write(' ' + cross)
}
} else {
process.stdout.write(meetup.title)
meetupDeets.push({ meetup })
}
// if (meetupURL.includes('meetup.com')) {
// try {
// const meetupID = meetupURL.split('/').pop()
// process.stdout.write(meetupID)

// const icalResponse = await nodeFetch(`https://www.meetup.com/${meetupID}/events/ical/`)
// const icalText = await icalResponse.text()
// const ical = await icalToolkit.parseToJSON(icalText)

// const upcomingEvent = ical.events[0]
// if (!upcomingEvent) {
// process.stdout.write(' -')
// meetupDeets.push({ meetup })

// continue
// }

// const id = upcomingEvent.uid.split('_')[1].split('@')[0]
// const title = upcomingEvent.summary.replace(/\\,/g, ',')
// const location = upcomingEvent.location.replace(/\\,/g, ',')
// const textDescription = upcomingEvent.description.replace(/\\,/g, ',').replace(/\\n/g, '<br />')
// const date = moment(upcomingEvent.start.value).tz(upcomingEvent.start.tzid)
// const url = upcomingEvent.additionalTags.URL

// let richDescription = '<p>' + upcomingEvent.description + '</p>'

// // Best to not assume meetup.com's long term health, and it's rss
// const rssResponse = await nodeFetch(`https://www.meetup.com/${meetupID}/events/rss/`)
// const rssText = await rssResponse.text()
// const rss = await xml2js.parseStringPromise(rssText)

// // const removeDoubleLinks =

// const upcoming = rss.rss.channel[0].item[0]

// if (upcoming.title[0] === title) {
// richDescription = upcoming.description[0]
// }

// const linkifiedRegex = new RegExp(`<a href="[^>]+" class="linkified">`, "g")
// let filteredRichText = richDescription.replace(linkifiedRegex, "").replace(new RegExp("</a></a>"), "</a>")

// const event = {
// id,
// url,
// date,
// location,
// textDescription,
// richDescription: filteredRichText,
// title,
// }

// meetupDeets.push({ meetup, event })
// process.stdout.write(' ' + tick)
// } catch (error) {
// console.log(error)
// meetupDeets.push({ meetup })
// process.stdout.write(' ' + cross)
// }
// } else {
process.stdout.write(meetup.title)
meetupDeets.push({ meetup })
// }
}

if (meetups.length !== meetupDeets.length) throw new Error('\n\nMeetup Deets was not the same length\n\n')
if (meetups.length !== meetupDeets.length) throw new Error("\n\nMeetup Deets was not the same length\n\n")

const path = join(__dirname, '..', 'generated', 'meetups.json')
const path = join(__dirname, "..", "generated", "meetups.json")
writeFileSync(path, format(JSON.stringify(meetupDeets), { filepath: path }))
}

Expand Down
7 changes: 6 additions & 1 deletion packages/typescriptlang-org/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ module.exports = {

plugins: [
// SCSS provides inheritance for CSS and which pays the price for the dep
"gatsby-plugin-sass",
{
resolve: `gatsby-plugin-sass`,
options: {
implementation: require("sass"),
},
},
// PWA metadata
{
resolve: `gatsby-plugin-manifest`,
Expand Down
6 changes: 2 additions & 4 deletions packages/typescriptlang-org/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
"@types/node-fetch": "^2.5.3",
"@types/react-helmet": "^5.0.15",
"@typescript/twoslash": "0.6.2",
"@uifabric/fluent-theme": "^7.1.22",
"@uifabric/react-cards": "^0.109.23",
"canvas": "^2.6.1",
"gatsby": "^2.19.18",
"gatsby-plugin-catch-links": "^2.1.25",
Expand All @@ -50,18 +48,18 @@
"gatsby-source-filesystem": "^2.1.48",
"gatsby-transformer-remark": "^2.6.52",
"jsdom": "^16.2.0",
"node-sass": "^4.13.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-helmet": "^5.2.1",
"react-intl": "^3.12.0",
"rehype-shiki": "^0.0.7",
"sass": "^1.26.10",
"ts-debounce": "^2.0.1",
"ts-node": "^8.6.2",
"typescript": "*",
"typescript-playground": "0.1.0",
"typescript-sandbox": "0.1.0",
"xml2json": "^0.12.0"
"xml-js": "^1.6.11"
},
"devDependencies": {
"@babel/plugin-syntax-optional-chaining": "^7.8.3",
Expand Down
23 changes: 14 additions & 9 deletions packages/typescriptlang-org/scripts/createLighthouseJSON.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
const nodeFetch = require("node-fetch").default
const { writeFileSync } = require("fs")
const { join } = require("path")
const parser = require("xml2json")
const parser = require("xml-js")

const prNumber = process.env.PR_NUMBER || "245"
const prNumber = process.env.PR_NUMBER || "789"

const go = async () => {
const sitemap =
"https://typescript-v2-" + prNumber + ".ortam.now.sh/sitemap.xml"

const sitemap = `https://typescript-v2-${prNumber}.vercel.app/sitemap.xml`
try {
const packageJSON = await nodeFetch(sitemap)

const contents = await packageJSON.text()
const sitemapJSON = JSON.parse(
parser.xml2json(contents, { compact: true, spaces: 4 })
)

const sitemapJSON = JSON.parse(parser.toJson(contents))
/** @type {string[]} */
const grabbedURLs = sitemapJSON.urlset.url.map(u => u.loc)

const urls = grabbedURLs
.filter(Boolean)
.map(url => {
// from "https://www.typescriptlang.org/v2/docs/handbook/advanced-types.html",
// to "https://typescript-v2-" + prNumber + ".ortam.now.sh/docs/handbook/advanced-types.html",
return url.replace(
// to "https://typescript-v2-" + prNumber + ".vercel.app/docs/handbook/advanced-types.html",

return url._text.replace(
"https://www.typescriptlang.org/",
"https://typescript-v2-" + prNumber + ".ortam.now.sh/"
"https://typescript-v2-" + prNumber + ".vercel.app/"
)
})
.reverse()
Expand Down Expand Up @@ -62,8 +65,10 @@ const go = async () => {
}

console.log(`Looking at ${json.ci.collect.url.length} urls`)
console.log(`- ${json.ci.collect.url.join("\n - ")}`)
writeFileSync(lighthouseFiles, JSON.stringify(json))
} catch (error) {
console.log(error)
console.log(
"Failed to generate lighthouse JSON, this is fine if you are not an orta"
)
Expand Down
5 changes: 2 additions & 3 deletions packages/typescriptlang-org/src/templates/pages/community.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const Comm: React.FC<Props> = props => {
</div>


<div className="raised main-content-block container community">
{/* <div className="raised main-content-block container community" style={{ display: "none" }}>
<h3 className="centered-highlight">Upcoming Events</h3>
<div className="events">
<Row>
Expand All @@ -188,8 +188,7 @@ export const Comm: React.FC<Props> = props => {
))}
</Row>
</div>
</div>

</div> */}

<div className="raised main-content-block container community">
<h3 className="centered-highlight">Meetups</h3>
Expand Down
Loading