|
1 | 1 | // @ts-check
|
2 | 2 |
|
3 |
| -const { join } = require('path') |
4 |
| -const { writeFileSync } = require('fs') |
5 |
| -const { meetups } = require('./meetups') |
6 |
| -const xml2js = require('xml2js') |
7 |
| -const nodeFetch = require('node-fetch').default |
8 |
| -const icalToolkit = require('ical-utils') |
9 |
| -const { format } = require('prettier') |
10 |
| -const moment = require('moment') |
11 |
| -require('moment-timezone') |
| 3 | +// Given that COVID dropped meetups, lets disable this |
| 4 | +// until things pick up again in 2021 |
12 | 5 |
|
13 |
| -const chalk = require('chalk').default |
| 6 | +const { join } = require("path") |
| 7 | +const { writeFileSync } = require("fs") |
| 8 | +const { meetups } = require("./meetups") |
| 9 | +// const xml2js = require("xml2js") |
| 10 | +// const nodeFetch = require("node-fetch").default |
| 11 | +// const icalToolkit = require("ical-utils") |
| 12 | +const { format } = require("prettier") |
| 13 | +// const moment = require("moment") |
| 14 | +// require("moment-timezone") |
14 | 15 |
|
15 |
| -const tick = chalk.bold.greenBright('✓') |
16 |
| -const cross = chalk.bold.redBright('⤫') |
| 16 | +const chalk = require("chalk").default |
| 17 | + |
| 18 | +const tick = chalk.bold.greenBright("✓") |
| 19 | +const cross = chalk.bold.redBright("⤫") |
17 | 20 |
|
18 | 21 | const go = async () => {
|
19 | 22 | let meetupDeets = []
|
20 |
| - console.log('Looking at meetups: ') |
| 23 | + console.log("Looking at meetups: ") |
21 | 24 |
|
22 | 25 | for (const meetup of meetups) {
|
23 |
| - if (meetup !== meetups[0]) process.stdout.write(', ') |
| 26 | + if (meetup !== meetups[0]) process.stdout.write(", ") |
24 | 27 |
|
25 | 28 | const meetupURL = meetup.meetup || meetup.url
|
26 |
| - if (meetupURL.includes('meetup.com')) { |
27 |
| - try { |
28 |
| - const meetupID = meetupURL.split('/').pop() |
29 |
| - process.stdout.write(meetupID) |
30 |
| - |
31 |
| - const icalResponse = await nodeFetch(`https://www.meetup.com/${meetupID}/events/ical/`) |
32 |
| - const icalText = await icalResponse.text() |
33 |
| - const ical = await icalToolkit.parseToJSON(icalText) |
34 |
| - |
35 |
| - const upcomingEvent = ical.events[0] |
36 |
| - if (!upcomingEvent) { |
37 |
| - process.stdout.write(' -') |
38 |
| - meetupDeets.push({ meetup }) |
39 |
| - |
40 |
| - continue |
41 |
| - } |
42 |
| - |
43 |
| - const id = upcomingEvent.uid.split('_')[1].split('@')[0] |
44 |
| - const title = upcomingEvent.summary.replace(/\\,/g, ',') |
45 |
| - const location = upcomingEvent.location.replace(/\\,/g, ',') |
46 |
| - const textDescription = upcomingEvent.description.replace(/\\,/g, ',').replace(/\\n/g, '<br />') |
47 |
| - const date = moment(upcomingEvent.start.value).tz(upcomingEvent.start.tzid) |
48 |
| - const url = upcomingEvent.additionalTags.URL |
49 |
| - |
50 |
| - let richDescription = '<p>' + upcomingEvent.description + '</p>' |
51 |
| - |
52 |
| - // Best to not assume meetup.com's long term health, and it's rss |
53 |
| - const rssResponse = await nodeFetch(`https://www.meetup.com/${meetupID}/events/rss/`) |
54 |
| - const rssText = await rssResponse.text() |
55 |
| - const rss = await xml2js.parseStringPromise(rssText) |
56 |
| - |
57 |
| - // const removeDoubleLinks = |
58 |
| - |
59 |
| - const upcoming = rss.rss.channel[0].item[0] |
60 |
| - |
61 |
| - if (upcoming.title[0] === title) { |
62 |
| - richDescription = upcoming.description[0] |
63 |
| - } |
64 |
| - |
65 |
| - const linkifiedRegex = new RegExp(`<a href="[^>]+" class="linkified">`, "g") |
66 |
| - let filteredRichText = richDescription.replace(linkifiedRegex, "").replace(new RegExp("</a></a>"), "</a>") |
67 |
| - |
68 |
| - const event = { |
69 |
| - id, |
70 |
| - url, |
71 |
| - date, |
72 |
| - location, |
73 |
| - textDescription, |
74 |
| - richDescription: filteredRichText, |
75 |
| - title, |
76 |
| - } |
77 |
| - |
78 |
| - meetupDeets.push({ meetup, event }) |
79 |
| - process.stdout.write(' ' + tick) |
80 |
| - } catch (error) { |
81 |
| - console.log(error) |
82 |
| - meetupDeets.push({ meetup }) |
83 |
| - process.stdout.write(' ' + cross) |
84 |
| - } |
85 |
| - } else { |
86 |
| - process.stdout.write(meetup.title) |
87 |
| - meetupDeets.push({ meetup }) |
88 |
| - } |
| 29 | + // if (meetupURL.includes('meetup.com')) { |
| 30 | + // try { |
| 31 | + // const meetupID = meetupURL.split('/').pop() |
| 32 | + // process.stdout.write(meetupID) |
| 33 | + |
| 34 | + // const icalResponse = await nodeFetch(`https://www.meetup.com/${meetupID}/events/ical/`) |
| 35 | + // const icalText = await icalResponse.text() |
| 36 | + // const ical = await icalToolkit.parseToJSON(icalText) |
| 37 | + |
| 38 | + // const upcomingEvent = ical.events[0] |
| 39 | + // if (!upcomingEvent) { |
| 40 | + // process.stdout.write(' -') |
| 41 | + // meetupDeets.push({ meetup }) |
| 42 | + |
| 43 | + // continue |
| 44 | + // } |
| 45 | + |
| 46 | + // const id = upcomingEvent.uid.split('_')[1].split('@')[0] |
| 47 | + // const title = upcomingEvent.summary.replace(/\\,/g, ',') |
| 48 | + // const location = upcomingEvent.location.replace(/\\,/g, ',') |
| 49 | + // const textDescription = upcomingEvent.description.replace(/\\,/g, ',').replace(/\\n/g, '<br />') |
| 50 | + // const date = moment(upcomingEvent.start.value).tz(upcomingEvent.start.tzid) |
| 51 | + // const url = upcomingEvent.additionalTags.URL |
| 52 | + |
| 53 | + // let richDescription = '<p>' + upcomingEvent.description + '</p>' |
| 54 | + |
| 55 | + // // Best to not assume meetup.com's long term health, and it's rss |
| 56 | + // const rssResponse = await nodeFetch(`https://www.meetup.com/${meetupID}/events/rss/`) |
| 57 | + // const rssText = await rssResponse.text() |
| 58 | + // const rss = await xml2js.parseStringPromise(rssText) |
| 59 | + |
| 60 | + // // const removeDoubleLinks = |
| 61 | + |
| 62 | + // const upcoming = rss.rss.channel[0].item[0] |
| 63 | + |
| 64 | + // if (upcoming.title[0] === title) { |
| 65 | + // richDescription = upcoming.description[0] |
| 66 | + // } |
| 67 | + |
| 68 | + // const linkifiedRegex = new RegExp(`<a href="[^>]+" class="linkified">`, "g") |
| 69 | + // let filteredRichText = richDescription.replace(linkifiedRegex, "").replace(new RegExp("</a></a>"), "</a>") |
| 70 | + |
| 71 | + // const event = { |
| 72 | + // id, |
| 73 | + // url, |
| 74 | + // date, |
| 75 | + // location, |
| 76 | + // textDescription, |
| 77 | + // richDescription: filteredRichText, |
| 78 | + // title, |
| 79 | + // } |
| 80 | + |
| 81 | + // meetupDeets.push({ meetup, event }) |
| 82 | + // process.stdout.write(' ' + tick) |
| 83 | + // } catch (error) { |
| 84 | + // console.log(error) |
| 85 | + // meetupDeets.push({ meetup }) |
| 86 | + // process.stdout.write(' ' + cross) |
| 87 | + // } |
| 88 | + // } else { |
| 89 | + process.stdout.write(meetup.title) |
| 90 | + meetupDeets.push({ meetup }) |
| 91 | + // } |
89 | 92 | }
|
90 | 93 |
|
91 |
| - if (meetups.length !== meetupDeets.length) throw new Error('\n\nMeetup Deets was not the same length\n\n') |
| 94 | + if (meetups.length !== meetupDeets.length) throw new Error("\n\nMeetup Deets was not the same length\n\n") |
92 | 95 |
|
93 |
| - const path = join(__dirname, '..', 'generated', 'meetups.json') |
| 96 | + const path = join(__dirname, "..", "generated", "meetups.json") |
94 | 97 | writeFileSync(path, format(JSON.stringify(meetupDeets), { filepath: path }))
|
95 | 98 | }
|
96 | 99 |
|
|
0 commit comments