Skip to content

Commit

Permalink
Merge pull request #29 from gatsby-uc/filter-dprecated
Browse files Browse the repository at this point in the history
fix: filter out deprecated packages
  • Loading branch information
moonmeister authored Nov 7, 2024
2 parents 949542a + 5e47513 commit a4fab2f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 40 deletions.
35 changes: 13 additions & 22 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
const adapter = require('gatsby-adapter-netlify').default;

const adapter = require("gatsby-adapter-netlify").default;
require('dotenv').config();

require('dotenv').config()

const {
GA_MEASUREMENT_ID,
GITHUB_TOKEN,
SUPABASE_API_URL,
SUPABASE_ANON_KEY
} = process.env;
const { GA_MEASUREMENT_ID, GITHUB_TOKEN, SUPABASE_API_URL, SUPABASE_ANON_KEY } = process.env;

const otherPlugins = [];
GA_MEASUREMENT_ID &&
Expand Down Expand Up @@ -55,29 +49,27 @@ module.exports = {
types: [
{
type: 'Package',
query: (client) => client.from('packages').select('*'),
query: (client) => client.from('packages').select('*').eq('deprecated', false),
},
{
type: 'PackageScore',
query: (client) => client.from('package-scores').select('*'),
}
]
},
],
},
},
{
resolve: 'gatsby-source-npmsio',
options: {
packages: [
"gatsby-plugin-fastify",
]
packages: ['gatsby-plugin-fastify'],
},
},
{
resolve: `gatsby-source-github-contributors`,
options: {
repo: "gatsby-uc/plugins",
token: GITHUB_TOKEN
}
repo: 'gatsby-uc/plugins',
token: GITHUB_TOKEN,
},
},
'gatsby-transformer-sharp',
'gatsby-transformer-json',
Expand All @@ -96,14 +88,13 @@ module.exports = {
},
},


{
resolve: 'gatsby-plugin-react-svg',
options: {
rule: {
include: /\.svg$/
}
}
include: /\.svg$/,
},
},
},

// 3rd party plugins
Expand Down
29 changes: 11 additions & 18 deletions src/data/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,30 @@ const SUPABASE_ANON_KEY = process.env.SUPABASE_ANON_KEY;
const SUPABASE_SECRET_KEY = process.env.SUPABASE_SECRET_KEY;

if (SUPABASE_API_URL == undefined) {
throw new Error("SUPABASE_API_URL required")
throw new Error('SUPABASE_API_URL required');
}

if (SUPABASE_ANON_KEY == undefined) {
throw new Error("SUPABASE_ANON_KEY required")
throw new Error('SUPABASE_ANON_KEY required');
}

if (SUPABASE_SECRET_KEY == undefined) {
throw new Error("SUPABASE_SECRET_KEY required")
throw new Error('SUPABASE_SECRET_KEY required');
}

export const publicClient = createClient(
SUPABASE_API_URL,
SUPABASE_ANON_KEY
);
export const publicClient = createClient(SUPABASE_API_URL, SUPABASE_ANON_KEY);

export const serverClient = createClient(
SUPABASE_API_URL,
SUPABASE_SECRET_KEY
);
export const serverClient = createClient(SUPABASE_API_URL, SUPABASE_SECRET_KEY);

type Package = {
name: string;
};

export async function getPackages(supabase: SupabaseClient) {
const { data: packages, error } = await supabase.from('packages').select('name')
const { data: packages, error } = await supabase
.from('packages')
.select('name')
.eq('deprecated', false);

if (error) {
throw new Error(error.message);
Expand All @@ -60,9 +57,7 @@ export type PackageScoreRow = {
};

export async function upsertNpmsData(supabase: SupabaseClient, ...rows: NpmsDataRow[]) {
const { data, error } = await supabase
.from('npms-data-log')
.upsert(rows);
const { data, error } = await supabase.from('npms-data-log').upsert(rows);

if (error) {
throw new Error(error.message);
Expand All @@ -72,9 +67,7 @@ export async function upsertNpmsData(supabase: SupabaseClient, ...rows: NpmsData
}

export async function upsertPackageScores(supabase: SupabaseClient, ...rows: PackageScoreRow[]) {
const { data, error } = await supabase
.from('package-scores')
.upsert(rows);
const { data, error } = await supabase.from('package-scores').upsert(rows);

if (error) {
throw new Error(error.message);
Expand Down

0 comments on commit a4fab2f

Please sign in to comment.