Skip to content

Commit d15bb46

Browse files
Add funding.yaml for FLOSS fund with initial data (#64)
Co-authored-by: conradolandia <[email protected]>
1 parent f3f0569 commit d15bb46

File tree

7 files changed

+620
-71
lines changed

7 files changed

+620
-71
lines changed

package-lock.json

Lines changed: 74 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"generate-og-images": "node scripts/generate-og-images.js",
77
"generate-contrib-data": "node scripts/generate-contrib-data.js",
88
"generate-hubspot-data": "node scripts/generate-hubspot-data.js",
9-
"prebuild": "npm run generate-og-images && npm run generate-contrib-data && npm run generate-hubspot-data",
9+
"generate-funding-schema": "node scripts/generate-funding-schema.js",
10+
"prebuild": "npm run generate-og-images && npm run generate-contrib-data && npm run generate-hubspot-data && npm run generate-funding-schema",
1011
"dev": "npm run prebuild && npx vite dev",
1112
"build": "npm run prebuild && npx vite build",
1213
"preview": "npx vite preview",
@@ -19,6 +20,7 @@
1920
"@sveltejs/vite-plugin-svelte": "^3.1.2",
2021
"@tailwindcss/typography": "^0.5.15",
2122
"@types/three": "^0.169.0",
23+
"ajv": "^8.17.1",
2224
"autoprefixer": "^10.4.20",
2325
"chart.js": "^4.4.7",
2426
"cookie": "^1.0.2",

scripts/generate-funding-schema.js

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Generate the funding schema from the src/lib/config/data/funding.yaml file and save it to the funding.json file in the project root
2+
3+
import Ajv from "ajv";
4+
import { promises as fs } from "fs";
5+
import yaml from "js-yaml";
6+
import path from "path";
7+
import { exists } from "./utils.js";
8+
9+
const FUNDING_SCHEMA_URL = "https://fundingjson.org/schema/v1.0.0/funding.schema.json";
10+
11+
/**
12+
* Fetch the funding.json schema from the official URL
13+
*/
14+
async function fetchFundingSchema() {
15+
try {
16+
console.log("Fetching funding.json schema...");
17+
const response = await fetch(FUNDING_SCHEMA_URL);
18+
19+
if (!response.ok) {
20+
throw new Error(`Failed to fetch schema: ${response.status} ${response.statusText}`);
21+
}
22+
23+
return await response.json();
24+
} catch (error) {
25+
console.error("Error fetching funding schema:", error);
26+
throw error;
27+
}
28+
}
29+
30+
/**
31+
* JSON Schema validator
32+
*/
33+
async function validateFundingData(data, schema) {
34+
const ajv = new Ajv();
35+
const validate = ajv.compile(schema);
36+
const isValid = validate(data);
37+
38+
if (!isValid) {
39+
return validate.errors.map(error => `${error.instancePath} ${error.message}`);
40+
}
41+
42+
return [];
43+
}
44+
45+
/**
46+
* Load and parse the funding YAML file
47+
*/
48+
async function loadFundingYaml() {
49+
try {
50+
console.log("Loading funding.yaml file...");
51+
const yamlPath = path.join(process.cwd(), "src", "lib", "config", "data", "funding.yaml");
52+
53+
if (!(await exists(yamlPath))) {
54+
throw new Error(`Funding YAML file not found at: ${yamlPath}`);
55+
}
56+
57+
const yamlContent = await fs.readFile(yamlPath, 'utf8');
58+
const data = yaml.load(yamlContent);
59+
60+
console.log("Successfully parsed funding.yaml");
61+
return data;
62+
} catch (error) {
63+
console.error("Error loading funding YAML:", error);
64+
throw error;
65+
}
66+
}
67+
68+
/**
69+
* Main function to generate the funding.json file
70+
*/
71+
async function generateFundingSchema() {
72+
try {
73+
// Load the YAML data
74+
const fundingData = await loadFundingYaml();
75+
76+
// Fetch and validate against schema
77+
const schema = await fetchFundingSchema();
78+
console.log("Validating funding data against schema...");
79+
80+
const validationErrors = await validateFundingData(fundingData, schema);
81+
82+
if (validationErrors.length > 0) {
83+
console.error("Schema validation failed:");
84+
validationErrors.forEach(error => console.error(` 🚩 ${error}`));
85+
throw new Error("Funding data does not comply with schema");
86+
}
87+
88+
console.log("✅ Funding data is valid according to schema");
89+
90+
// Ensure the output directory exists
91+
const outputDir = path.join(process.cwd(), "static");
92+
if (!(await exists(outputDir))) {
93+
await fs.mkdir(outputDir, { recursive: true });
94+
}
95+
96+
// Write the JSON file
97+
const outputPath = path.join(outputDir, "funding.json");
98+
await fs.writeFile(outputPath, JSON.stringify(fundingData, null, 2));
99+
100+
console.log("✅ Funding schema has been successfully generated and saved to:", outputPath);
101+
} catch (error) {
102+
console.error("Error generating funding schema:", error);
103+
process.exit(1);
104+
}
105+
}
106+
107+
// Execute the script
108+
generateFundingSchema();

src/lib/config/data/funding.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
version: 'v1.0.0'
2+
entity:
3+
type: 'organisation'
4+
role: 'other'
5+
name: 'Spyder'
6+
7+
description: 'The Spyder organization, a project of the NumFOCUS nonprofit'
8+
webpageUrl:
9+
url: 'https://www.spyder-ide.org'
10+
projects:
11+
- guid: 'spyder-ide'
12+
name: 'Spyder'
13+
description: 'The scientific Python development environment'
14+
webpageUrl:
15+
url: 'https://www.spyder-ide.org'
16+
repositoryUrl:
17+
url: 'https://github.com/spyder-ide'
18+
wellKnown: ''
19+
licenses: ['spdx:MIT']
20+
tags: ['python', 'qt', 'anaconda', 'pyqt5', 'ide', 'language-server-protocol', 'spyder', 'anaconda-distribution', 'winpython']
21+
- guid: 'python-lsp'
22+
name: 'Python LSP Server'
23+
description: 'The python-language-server project, maintained by the Spyder IDE team and the community'
24+
webpageUrl:
25+
url: 'https://github.com/python-lsp'
26+
repositoryUrl:
27+
url: 'https://github.com/python-lsp/python-lsp-server'
28+
wellKnown: ''
29+
licenses: ['spdx:MIT']
30+
tags: ['python', 'language-server-protocol', 'lsp', 'ide', 'spyder']
31+
funding:
32+
channels:
33+
- guid: 'hubspot'
34+
type: 'payment-provider'
35+
address: 'https://numfocus.org/donate-for-spyder'
36+
description: 'Spyder HubSpot donation page with NumFOCUS'
37+
- guid: 'numfocus'
38+
type: 'other'
39+
address: '[email protected]'
40+
description: 'Contact NumFOCUS to coordinate a direct donation'
41+
plans:
42+
- guid: 'general-fund-onetime'
43+
status: 'active'
44+
name: 'Support Spyder'
45+
description: 'Support the Spyder project as a whole, with the money used where it is needed most.'
46+
amount: 0
47+
currency: 'USD'
48+
frequency: 'one-time'
49+
channels: ['hubspot']
50+
- guid: 'general-fund-monthly'
51+
status: 'active'
52+
name: 'Support Spyder'
53+
description: 'Support the Spyder project as a whole with a monthly donation, with the money used where it is needed most.'
54+
amount: 0
55+
currency: 'USD'
56+
frequency: 'monthly'
57+
channels: ['hubspot']
58+
- guid: 'individual'
59+
status: 'active'
60+
name: 'Individual Donation'
61+
description: 'Support us with a monthly donation and help us continue our activities.'
62+
amount: 5
63+
currency: 'USD'
64+
frequency: 'monthly'
65+
channels: ['hubspot']
66+
- guid: 'company'
67+
status: 'active'
68+
name: 'Company Sponsor'
69+
description: 'Become a sponsor and get your logo on our README on Github with a link to your site.'
70+
amount: 100
71+
currency: 'USD'
72+
frequency: 'monthly'
73+
channels: ['hubspot']
74+
- guid: 'junior-dev'
75+
status: 'active'
76+
name: 'Part Time Junior Developer'
77+
description: 'Help pay a Junior Developer to work part time on the Spyder IDE.'
78+
amount: 500
79+
currency: 'USD'
80+
frequency: 'monthly'
81+
channels: ['hubspot']
82+
history:
83+
- year: 2024
84+
income: 150000
85+
expenses: 150000
86+
taxes: 0
87+
currency: 'USD'
88+
description: ''

static/data/github-contributors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"type": "User",
4242
"user_view_type": "public",
4343
"site_admin": false,
44-
"contributions": 2500
44+
"contributions": 2504
4545
},
4646
{
4747
"login": "PierreRaybaut",

0 commit comments

Comments
 (0)