Skip to content

Commit

Permalink
Merge branch 'main' into 90-add-linting-action
Browse files Browse the repository at this point in the history
  • Loading branch information
JayRovacsek authored Jul 27, 2024
2 parents 74c583b + a263ff6 commit 02b5169
Show file tree
Hide file tree
Showing 29 changed files with 4,776 additions and 7,466 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
run: npm ci
- run: npm run fetchEvents
- run: npm run build
- name: Commit events-data.js
- name: Commit events-data.ts
run: |
git status
git config --global user.name 'Newwwie Bot'
git config --global user.email '[email protected]'
git add src/js/events/events-data.js
git add src/js/events/events-data.ts
git add dist
git commit -m "Get latest set of Meetup events"
git push
5 changes: 3 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src/js/events/events-data.js
src/js/communities/communities-data.js
src/js/events/events-data.ts
src/js/communities/community-data.ts
dist/
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<img
<img
align="right"
width="1600px"
alt="Newwwie Logo"
src="newwwie-logo.svg?sanitize=true"
src="newwwie-logo.svg?sanitize=true"
/>

# Contributing to Newwwie Website
Expand Down Expand Up @@ -161,9 +161,9 @@ We are still working on having hack days where we can meetup in person and hack

Pulls from the Meetup API based on a list of approved Meetup Group IDs.

[`fetch-events/meetups.js`](fetch-events/meetups.js)
[`fetch-events/meetups.json`](fetch-events/meetups.json)

You can [edit it directly on the Github Website](https://github.com/newwwie/newwwie.com/edit/main/fetch-events/meetups.js)
You can [edit it directly on the Github Website](https://github.com/newwwie/newwwie.com/edit/main/fetch-events/meetups.json)

## Communities page

Expand All @@ -173,9 +173,9 @@ https://newwwie.com/#community

If you would like to get added, the content is in:

[`src/js/communities/community-data.js`](src/js/communities/community-data.js)
[`src/js/communities/community-data.ts`](src/js/communities/community-data.ts)

You can [edit it directly on the Github Website](https://github.com/newwwie/newwwie.com/edit/main/src/js/communities/community-data.js)
You can [edit it directly on the Github Website](https://github.com/newwwie/newwwie.com/edit/main/src/js/communities/community-data.ts)

Here is an example of a high quality entry:

Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<img
<img
align="right"
width="1600px"
alt="Newwwie Logo"
src="newwwie-logo.svg?sanitize=true"
src="newwwie-logo.svg?sanitize=true"
/>

# newwwie.com
Expand All @@ -20,6 +20,16 @@ npm install
npm run dev
```

### Typescript

This repository uses typescript for source files. Currently some typescript errors remain, though at some point (after existing issues in [#119](https://github.com/newwwie/newwwie.com/issues/119) are resolved) webpack will be configured to not build in the presence of typescript errors.

```sh
npm run typecheck -- --watch
```

## Contributing

For more information please see our [Contributing Guide](CONTRIBUTING.md)

This includes adding meetup groups and community listings.
5 changes: 0 additions & 5 deletions babel.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion dist/css/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js/main.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions fetch-events/event-data-template.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{#- Template format for the generated event file -#}
// Auto Generated on {{ generationTime }}
import { type EventItem } from "./types";

export const events: readonly EventItem[] = {{ sortedEvents | dump(2) | safe }};
62 changes: 62 additions & 0 deletions fetch-events/fetch-events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import _ from "lodash";
import axios from "axios";
import dayjs from "dayjs";
import path from "path";
import { readFileSync, writeFileSync } from "fs";
import { renderString } from "nunjucks";

import { EventItem } from "../src/js/events/types";
import { GroupEdge, GroupResponse, MEETUP_GQL_QUERY } from "./types";
import { Meetups } from "./meetups.json";

const MEETUP_GQL_URL = "https://www.meetup.com/gql";
const END_DATE_RANGE = dayjs().add(3, "month").toISOString(); // Retrieve up to three months from the current date
const EVENT_OUTPUT_FILE = path.join(__dirname, "../src/js/events/events-data.ts");
const EVENT_TEMPLATE_FILE = path.join(__dirname, "./event-data-template.njk");

const buildGraphQLQuery = (groupName: string) => ({
query: MEETUP_GQL_QUERY,
variables: {
groupName,
endDateRange: END_DATE_RANGE,
},
});

const getGroupEvents = async (groupName: string): Promise<EventItem[]> => {
console.log(`Fetching events for "${groupName}"`);
const query = buildGraphQLQuery(groupName);
const events = (await axios.post(MEETUP_GQL_URL, JSON.stringify(query))).data as GroupResponse;

// Transform the response
const { unifiedEvents, ...group } = events.data.groupByUrlname || {};

console.log(`Finished fetching events for "${groupName}"`);
return (
unifiedEvents?.edges?.map((edge: GroupEdge) => ({
event: edge.node,
group,
})) || []
);
};

(async () => {
try {
console.log("Fetching events");
const events = await Promise.all(Meetups.map((eventName: string) => getGroupEvents(eventName)));

const sortedEvents = _.sortBy(events.flat(), (event: EventItem) => event.event.dateTime);

console.log("Rendering the events file");
const template = readFileSync(EVENT_TEMPLATE_FILE, "utf-8");
const rendered = renderString(template, {
generationTime: dayjs().toISOString(),
sortedEvents,
});

writeFileSync(EVENT_OUTPUT_FILE, rendered);

console.log("Fetch events complete");
} catch (err) {
console.error(`Error fetching events: ${err}`);
}
})();
47 changes: 0 additions & 47 deletions fetch-events/index.js

This file was deleted.

Loading

0 comments on commit 02b5169

Please sign in to comment.