Skip to content
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

chore: wrap try/catch around airtable data fetch for better debugging #3779

Merged
merged 1 commit into from
Feb 16, 2024
Merged
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
103 changes: 60 additions & 43 deletions packages/paste-website/scripts/fetch-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,38 @@ const getCategory = (pkgPath) => {

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
const getAllPatterns = async () => {
const patterns = await systemTable
.select({
filterByFormula: 'AND({Component Category} = "pattern", Documentation, status, status != "in development")',
sort: [{ field: "Feature" }],
fields: ["Feature", "status"],
})
.all();
return patterns.map(({ fields }) => fields);
try {
const patterns = await systemTable
.select({
filterByFormula: 'AND({Component Category} = "pattern", Documentation, status, status != "in development")',
sort: [{ field: "Feature" }],
fields: ["Feature", "status"],
})
.all();

return patterns.map(({ fields }) => fields);
} catch (error) {
// eslint-disable-next-line no-console
console.log("getAllPatterns fetch error:", error);
}
};

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
const getAllPageTemplates = async () => {
const patterns = await systemTable
.select({
filterByFormula: 'AND({Component Category} = "page_template", Documentation, status, status != "in development")',
sort: [{ field: "Feature" }],
fields: ["Feature", "status"],
})
.all();
return patterns.map(({ fields }) => fields);
try {
const patterns = await systemTable
.select({
filterByFormula:
'AND({Component Category} = "page_template", Documentation, status, status != "in development")',
sort: [{ field: "Feature" }],
fields: ["Feature", "status"],
})
.all();
return patterns.map(({ fields }) => fields);
} catch (error) {
// eslint-disable-next-line no-console
console.log("getAllPageTemplates fetch error:", error);
}
};

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
Expand Down Expand Up @@ -98,33 +110,38 @@ const getAllPackages = async () => {

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
export const getAllFeatures = async () => {
const features = await systemTable
.select({
filterByFormula: "status",
sort: [{ field: "Feature" }],
fields: [
"Component Category",
"Feature",
"Documentation",
"Figma",
"Design committee review",
"Engineer committee review",
"Code",
"status",
"Product suitability",
],
})
.all();
const items = features.map(({ fields }) => fields);

await fs.mkdir(dataPath, { recursive: true }, (err) => {
if (err) {
// eslint-disable-next-line no-console
console.log(err);
}
});

await fs.writeFile(path.join(dataPath, "feature-data.json"), JSON.stringify(items, null, 2), "utf8");
try {
const features = await systemTable
.select({
filterByFormula: "status",
sort: [{ field: "Feature" }],
fields: [
"Component Category",
"Feature",
"Documentation",
"Figma",
"Design committee review",
"Engineer committee review",
"Code",
"status",
"Product suitability",
],
})
.all();
const items = features.map(({ fields }) => fields);

await fs.mkdir(dataPath, { recursive: true }, (err) => {
if (err) {
// eslint-disable-next-line no-console
console.log(err);
}
});

await fs.writeFile(path.join(dataPath, "feature-data.json"), JSON.stringify(items, null, 2), "utf8");
} catch (error) {
// eslint-disable-next-line no-console
console.log("getAllFeatures fetch error:", error);
}
};

getAllPackages();
Expand Down
Loading