Skip to content

Commit

Permalink
Upgrade prettier (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins authored Jan 4, 2025
1 parent bf7df41 commit 2c6e55a
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 84 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,package-lock.json,.*rc,*.yml,*.yaml}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
18 changes: 9 additions & 9 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ const airtableBase = Airtable.base(airtableMetadata.baseId);
// load the airtable data we'll need
const airtableEvents = await getAirtableEvents(
airtableBase,
airtableMetadata.eventsId
airtableMetadata.eventsId,
);
const airtableSpeakers = await getAirtableSpeakers(
airtableBase,
airtableMetadata.speakersId
airtableMetadata.speakersId,
);
const airtableSponsors = await getAirtableSponsors(
airtableBase,
airtableMetadata.sponsorsId
airtableMetadata.sponsorsId,
);

console.log("gathering existing website data...");
Expand All @@ -84,7 +84,7 @@ const websiteSponsors = await getWebsiteSponsors(config.seattlejsProjectPath);
// only used to prompt the user for which event they want to modify
const eventMap = mapAirtableEventsToWebsiteEvents(
airtableEvents,
websiteEvents
websiteEvents,
);

const targetEvent = await getTargetEvent(eventMap);
Expand All @@ -95,19 +95,19 @@ if (!targetEvent.website) {
const { newPhotos, updatedSpeakers } = reconcileSpeakers(
targetEvent,
airtableSpeakers,
websiteSpeakers
websiteSpeakers,
);

const { updatedTalks, removedTalks } = reconcileTalks(
targetEvent,
airtableSpeakers,
websiteTalks
websiteTalks,
);

const { newLogos, updatedSponsors } = reconcileSponsors(
targetEvent,
airtableSponsors,
websiteSponsors
websiteSponsors,
);

reconcileEvents(targetEvent, websiteEvents);
Expand All @@ -116,14 +116,14 @@ const confirmation = await confirmUpdate(
updatedSpeakers,
updatedTalks,
removedTalks,
updatedSponsors
updatedSponsors,
);
if (confirmation) {
await exportData(websiteSpeakers, "speakers", config.seattlejsProjectPath);
const existingPhotos = await exportImages(
newPhotos,
"speakers",
config.seattlejsProjectPath
config.seattlejsProjectPath,
);
await exportData(websiteTalks, "talks", config.seattlejsProjectPath);

Expand Down
19 changes: 10 additions & 9 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"eslint-plugin-promise": "^6.1.1",
"lodash": "^4.17.21",
"mocha": "^10.2.0",
"prettier": "2.8.3",
"prettier": "^3.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.3"
},
Expand Down
10 changes: 5 additions & 5 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
/** mutates the events json data to include any event updates */
export const reconcileEvents = (
event: WebsiteAirtablePair,
websiteEvents: WebsiteEvent[]
websiteEvents: WebsiteEvent[],
): void => {
const existingEventIndex = websiteEvents.findIndex(
(webEvent) => webEvent.id == event.website.id
(webEvent) => webEvent.id == event.website.id,
);
if (existingEventIndex > 0) {
// the event exists, need to replace it with the updated one,
Expand All @@ -24,14 +24,14 @@ export const reconcileEvents = (
};

export const makeWebsiteEvent = (
airtableEvent: Record<FieldSet>
airtableEvent: Record<FieldSet>,
): WebsiteEvent => {
const name = (airtableEvent.get("Name") as string) || "";
const date = (airtableEvent.get("Date") as string) || "";
const description = (airtableEvent.get("Description") as string) || "";
const id = makeEventId(name);
const link = (airtableEvent.get("Link") as string) || "";
console.log("makeWebsiteEvent", {id, link});
console.log("makeWebsiteEvent", { id, link });
const event: WebsiteEvent = {
id: id,
link,
Expand All @@ -48,7 +48,7 @@ export const makeWebsiteEvent = (
* and the value is an object with the corresponding airtable and website events */
export const mapAirtableEventsToWebsiteEvents = (
airtableEvents: Record<FieldSet>[],
websiteEvents: WebsiteEvent[]
websiteEvents: WebsiteEvent[],
): WebsiteAirtableMap => {
const result: WebsiteAirtableMap = {};
for (const event of airtableEvents) {
Expand Down
4 changes: 2 additions & 2 deletions src/normalizers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const getFileExtension = (fileName) => {
};

export const normalizeTalkType = (
talkType: string
talkType: string,
): "regular" | "lightning" => {
if (talkType.toLowerCase().includes("regular")) {
return "regular";
Expand All @@ -71,7 +71,7 @@ export const normalizeTalkType = (
};

export const handleTalkTopics = (
talkTopics: string | undefined | ""
talkTopics: string | undefined | "",
): string[] => {
if (talkTopics === "") {
return [];
Expand Down
6 changes: 3 additions & 3 deletions src/repos/airtable-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ const getSeattleJsBaseId = async (token: string): Promise<string> => {
};

export const getAirtableMetadata = async (
token: string
token: string,
): Promise<AirtableMetadata> => {
const baseId = await getSeattleJsBaseId(token);
const tables = await getAirtableTables(baseId, token);
const eventsTable = tables.find((table) => table.name === EVENTS_TABLE_NAME);
const speakersTable = tables.find(
(table) => table.name === SPEAKERS_TABLE_NAME
(table) => table.name === SPEAKERS_TABLE_NAME,
);
const sponsorsTable = tables.find(
(table) => table.name === SPONSORS_TABLE_NAME
(table) => table.name === SPONSORS_TABLE_NAME,
);
const ids: AirtableMetadata = {
baseId: baseId,
Expand Down
12 changes: 6 additions & 6 deletions src/repos/user-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const getDateMonthsInFuture = (monthsInFuture: number): Date => {
};

export const getTargetEvent = async (
events: WebsiteAirtableMap
events: WebsiteAirtableMap,
): Promise<WebsiteAirtablePair> => {
// reduce number of events to limit, taking most recent
const someMonthsAgo = getDateMonthsAgo(MONTHS_PRIOR_LIMIT);
Expand Down Expand Up @@ -57,14 +57,14 @@ export const confirmUpdate = async (
updatedSpeakers: WebsiteSpeaker[],
updatedTalks: WebsiteTalk[],
removedTalks: string[],
updatedSponsors: WebsiteSponsor[]
updatedSponsors: WebsiteSponsor[],
): Promise<boolean> => {
const confirmMessage = [
"Confirm update:\n",
`${updatedTalks.length} new talks\n`,
`${removedTalks.length} removed talks ${ removedTalks.length ? `(${removedTalks})` : ''}\n`,
`${removedTalks.length} removed talks ${removedTalks.length ? `(${removedTalks})` : ""}\n`,
`${updatedSponsors.length} new sponsors\n`,
`${updatedSpeakers.length} new speakers\n`
`${updatedSpeakers.length} new speakers\n`,
];
const res = await prompts({
type: "confirm",
Expand Down Expand Up @@ -109,7 +109,7 @@ export const promptForApiToken = async (retries = 1): Promise<string> => {
};

export const promptForSeattlejsProjectPath = async (
retries = 1
retries = 1,
): Promise<string> => {
while (retries >= 0) {
retries--;
Expand All @@ -124,6 +124,6 @@ export const promptForSeattlejsProjectPath = async (
}
}
throw new Error(
"please provide a path to a valid seattlejs.com repo or fork"
"please provide a path to a valid seattlejs.com repo or fork",
);
};
12 changes: 6 additions & 6 deletions src/repos/website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const JSON_FILES = {
};

export const validateSeattleJsProjectPath = async (
projectPath: string
projectPath: string,
): Promise<boolean> => {
for (const [type, file] of Object.entries(JSON_FILES)) {
const fullPath = path.join(projectPath, file);
Expand All @@ -40,23 +40,23 @@ const parseJSONFile = async (filePath: string): Promise<any> => {
};

export const getWebsiteEvents = async (
projectPath: string
projectPath: string,
): Promise<WebsiteEvent[]> => {
return parseJSONFile(path.join(projectPath, JSON_FILES["events"]));
};

export const getWebsiteSpeakers = async (
projectPath: string
projectPath: string,
): Promise<WebsiteSpeaker[]> => {
return parseJSONFile(path.join(projectPath, JSON_FILES["speakers"]));
};
export const getWebsiteTalks = async (
projectPath: string
projectPath: string,
): Promise<WebsiteTalk[]> => {
return parseJSONFile(path.join(projectPath, JSON_FILES["talks"]));
};
export const getWebsiteSponsors = async (
projectPath: string
projectPath: string,
): Promise<WebsiteSponsor[]> => {
return parseJSONFile(path.join(projectPath, JSON_FILES["sponsors"]));
};
Expand Down Expand Up @@ -84,7 +84,7 @@ export const exportImages = async (imageObjects, type, projectPath) => {
const filePath = path.join(
projectPath,
IMAGE_DIRS[type],
imageObj.filename
imageObj.filename,
);
const imageExists = await exists(filePath);
if (!imageExists) {
Expand Down
8 changes: 4 additions & 4 deletions src/speakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
export const reconcileSpeakers = (
event: WebsiteAirtablePair,
airtableSpeakers: Record<FieldSet>[],
websiteSpeakers: WebsiteSpeaker[]
websiteSpeakers: WebsiteSpeaker[],
): {
updatedSpeakers: WebsiteSpeaker[];
newPhotos: AirtablePhoto[];
Expand All @@ -26,7 +26,7 @@ export const reconcileSpeakers = (
// get the speakers for the passed event
const airtableEventSpeakers = getEventSpeakers(
event.airtable,
airtableSpeakers
airtableSpeakers,
);
for (const speaker of airtableEventSpeakers) {
// make speaker object and get photo uri
Expand All @@ -49,7 +49,7 @@ export const reconcileSpeakers = (

/** make a website speaker from an airtable speaker */
const makeWebsiteSpeaker = (
airtableSpeaker: Record<FieldSet>
airtableSpeaker: Record<FieldSet>,
): { speaker: WebsiteSpeaker; speakerPhoto: AirtablePhoto } => {
const speaker = {} as WebsiteSpeaker;
const name = airtableSpeaker.get("Full Name");
Expand Down Expand Up @@ -79,7 +79,7 @@ const makeWebsiteSpeaker = (
*/
export const getEventSpeakers = (
airtableEvent,
airtableSpeakers
airtableSpeakers,
): Record<FieldSet>[] => {
const speakerRecords = [];
const speakerIds = (airtableEvent.get("Speakers") as string[]) || [];
Expand Down
8 changes: 4 additions & 4 deletions src/sponsors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { normalizeSponsorName, getFileExtension } from "./normalizers.js";
export const reconcileSponsors = (
event: WebsiteAirtablePair,
airtableSponsors: Record<FieldSet>[],
websiteSponsors: WebsiteSponsor[]
websiteSponsors: WebsiteSponsor[],
): {
newLogos: AirtablePhoto[];
updatedSponsors: WebsiteSponsor[];
Expand All @@ -28,7 +28,7 @@ export const reconcileSponsors = (
if (airtableEventSponsorIds) {
for (const airtableId of airtableEventSponsorIds) {
airtableEventSponsors.push(
airtableSponsors.find((sponsor) => sponsor.id == airtableId)
airtableSponsors.find((sponsor) => sponsor.id == airtableId),
);
}
}
Expand Down Expand Up @@ -57,12 +57,12 @@ export const reconcileSponsors = (
};

const makeWebsiteSponsor = (
airtableSponsor: Record<FieldSet>
airtableSponsor: Record<FieldSet>,
): {
sponsor: WebsiteSponsor;
logo: AirtablePhoto;
} => {
const airtableName = airtableSponsor.get("Name") as string
const airtableName = airtableSponsor.get("Name") as string;
const name = normalizeSponsorName(airtableName);
const sponsor = {} as WebsiteSponsor;
sponsor.id = name;
Expand Down
Loading

0 comments on commit 2c6e55a

Please sign in to comment.