Refactored source/scripts into core/source

This commit is contained in:
Lucas
2026-01-01 21:13:49 -08:00
parent 21d6a6787e
commit afbb4d1352
38 changed files with 43 additions and 43 deletions

View File

@@ -19,7 +19,7 @@ To establish uniformity accross the project, please adhere to these conventions.
- Use the project's official name, not the repository name. Repository names often use lowercase and place dashes in place of spaces. Fallback to **Title Casing** if capitalization is not clear.
- For projects with multiple repositories (EX: one for IOS, Windows, etc) link the repository with the most stars.
- Do not put in a description unless the repo description is inadequate or non-existent, in which case fall back to the organization, their website, or the repo's README. **Do not write your own description, only use text from official sources of the project, and do not modify (EX: shorten) their description.** If you use a custom description make sure to put in the `custom-description` flag so that the stat updator script doesn't overide it.
- For tags, do not use the emoji. Go to [tags.json](/source/data/static/tags.json) and find the id for the tag. Our script will generate it's corresponding emoji when it builds the README.
- For tags, do not use the emoji. Go to [tags.json](/core/data/static/tags.json) and find the id for the tag. Our script will generate it's corresponding emoji when it builds the README.
## How To Contribute
[How to create a pull request.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)

View File

@@ -28,7 +28,7 @@ jobs:
run: pip install -r requirements.txt || true
- name: Run script to check for format errors
run: python ./source/scripts/maintenance/json_formatter.py
run: python ./core/source/maintenance/json_formatter.py
- name: Commit and push changes
run: |

View File

@@ -4,7 +4,7 @@ name: Generate README
on:
# push:
# paths:
# - 'source/data/**'
# - 'core/data/**'
# - 'source/components/**'
workflow_dispatch:
schedule:
@@ -32,7 +32,7 @@ jobs:
run: pip install -r requirements.txt || true
- name: Run script to generate README
run: python ./source/scripts/generation/readme_generator.py
run: python ./core/source/generation/readme_generator.py
- name: Commit and push changes
run: |

View File

@@ -34,7 +34,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python source/scripts/maintenance/status_checker.py
python core/source/maintenance/status_checker.py
- name: Commit changes
run: |

View File

@@ -34,12 +34,12 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python source/scripts/maintenance/stats_updator.py
python core/source/maintenance/stats_updator.py
- name: Commit changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add source/data/dynamic/applications.json
git add core/data/dynamic/applications.json
git commit -m "Auto-update GitHub metadata" || echo "No changes to commit"
git push

View File

@@ -6,7 +6,7 @@ import (
"os"
"strings"
"definitive-opensource/data"
"definitive-opencore/data"
"definitive-opensource/models"
)

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"strings"
"definitive-opensource/data"
"definitive-opencore/data"
)
func selectCategory(scanner *bufio.Scanner) (string, error) {

View File

@@ -4,7 +4,7 @@ import (
"bufio"
"fmt"
"definitive-opensource/data"
"definitive-opencore/data"
)
func selectPlatforms(scanner *bufio.Scanner) ([]string, error) {

View File

@@ -4,7 +4,7 @@ import (
"bufio"
"fmt"
"definitive-opensource/data"
"definitive-opencore/data"
)
func selectTags(scanner *bufio.Scanner) ([]string, error) {

View File

@@ -41,13 +41,13 @@ def format_stars(n):
def generate_contents(platform="all"):
with open("source/data/static/categories.json", "r", encoding="utf-8") as f:
with open("core/data/static/categories.json", "r", encoding="utf-8") as f:
cat_data = json.load(f)
with open("source/data/dynamic/applications.json", "r", encoding="utf-8") as f:
with open("core/data/dynamic/applications.json", "r", encoding="utf-8") as f:
app_data = json.load(f)
with open("source/data/static/tags.json", "r", encoding="utf-8") as f:
with open("core/data/static/tags.json", "r", encoding="utf-8") as f:
tags_data = json.load(f)
with open("source/data/static/platforms.json", "r", encoding="utf-8") as f:
with open("core/data/static/platforms.json", "r", encoding="utf-8") as f:
platforms_data = json.load(f)
categories = cat_data.get("categories", [])

View File

@@ -2,7 +2,7 @@ import json
# Generates mainheader with dynamic project count
def generate_mainheader():
with open("source/data/dynamic/applications.json", "r", encoding="utf-8") as f:
with open("core/data/dynamic/applications.json", "r", encoding="utf-8") as f:
data = json.load(f)
project_count = len(data.get("applications", []))

View File

@@ -6,7 +6,7 @@ def slugify(name):
def generate_table_of_contents():
# Load the categories JSON data
with open("source/data/static/categories.json", "r", encoding="utf-8") as f:
with open("core/data/static/categories.json", "r", encoding="utf-8") as f:
data = json.load(f)
categories = data.get("categories", [])
subcategories = data.get("subcategories", [])

View File

@@ -1,13 +1,13 @@
import json
with open("source/data/dynamic/applications.json") as f:
with open("core/data/dynamic/applications.json") as f:
applications = json.load(f)["applications"]
with open("source/data/static/categories.json") as f:
with open("core/data/static/categories.json") as f:
categories_data = json.load(f)["subcategories"]
valid_categories = {c["id"].lower() for c in categories_data}
with open("source/data/static/platforms.json") as f:
with open("core/data/static/platforms.json") as f:
platforms_data = json.load(f)["platforms"]
valid_platforms = {p["id"].lower() for p in platforms_data}

View File

@@ -4,7 +4,7 @@ import json
from datetime import datetime
import os
with open('source/data/dynamic/applications.json', 'r') as f:
with open('core/data/dynamic/applications.json', 'r') as f:
data = json.load(f)
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
@@ -57,7 +57,7 @@ def update_application_data(app):
for app in data['applications']:
app = update_application_data(app)
with open('source/data/dynamic/applications.json', 'w') as f:
with open('core/data/dynamic/applications.json', 'w') as f:
json.dump(data, f, indent=4)
print("Updated application data successfully!")

View File

@@ -4,7 +4,7 @@ import json
from datetime import datetime, timedelta
import os
INPUT_FILE = "source/data/dynamic/applications.json"
INPUT_FILE = "core/data/dynamic/applications.json"
OUTPUT_FILE = "resources/maintenance/status_maintenance.md"
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")

View File

@@ -391,7 +391,7 @@ def main() -> None:
parser.add_argument(
"--applications-file",
default=str(APPLICATIONS_FILE),
help="Path to applications.json (default: source/data/dynamic/applications.json).",
help="Path to applications.json (default: core/data/dynamic/applications.json).",
)
parser.add_argument(
"--full-details",

View File

@@ -3,7 +3,7 @@ import json
"""
# Load the JSON data from file
with open("source/data/dynamic/applications.json", "r", encoding="utf-8") as file:
with open("core/data/dynamic/applications.json", "r", encoding="utf-8") as file:
data = json.load(file)
# Convert all platform entries to lowercase
@@ -12,7 +12,7 @@ for app in data.get("applications", []):
app["platforms"] = [platform.lower() for platform in app["platforms"]]
# Write the modified data back to the file
with open("source/data/dynamic/applications.json", "w", encoding="utf-8") as file:
with open("core/data/dynamic/applications.json", "w", encoding="utf-8") as file:
json.dump(data, file, indent=4)
print("All platform entries have been converted to lowercase.")
@@ -20,7 +20,7 @@ print("All platform entries have been converted to lowercase.")
"""
# Load the JSON file
with open("source/data/dynamic/applications.json", "r", encoding="utf-8") as file:
with open("core/data/dynamic/applications.json", "r", encoding="utf-8") as file:
data = json.load(file)
# Add "flags" and "stars" properties to each application
@@ -28,14 +28,14 @@ for app in data.get("applications", []):
app["homepage_url"] = ""
# Save the updated JSON back to the file
with open("source/data/dynamic/applications.json", "w", encoding="utf-8") as file:
with open("core/data/dynamic/applications.json", "w", encoding="utf-8") as file:
json.dump(data, file, indent=4, ensure_ascii=False)
print("Operation successful: applications.json updated")
"""
# Load applications.json
with open("source/data/dynamic/applications.json", "r", encoding="utf-8") as f:
with open("core/data/dynamic/applications.json", "r", encoding="utf-8") as f:
data = json.load(f)
# Platforms to check for
@@ -58,5 +58,5 @@ for app in data.get("applications", []):
app["tags"] = sorted(tags)
# Save the updated file
with open("source/data/dynamic/applications.json", "w", encoding="utf-8") as f:
with open("core/data/dynamic/applications.json", "w", encoding="utf-8") as f:
json.dump(data, f, indent=4)

View File

@@ -15,17 +15,17 @@ The place that connects everything related to definitive-opensource.
### Development
- [ARCHITECTURE.md](/resources/dev/ARCHITECTURE.md) - Explains the "backend" of the list
- [source/scripts/generation](/source/scripts/generation) - Contains scripts related to README generation
- [source/scripts/maintenance](/source/scripts/maintenance) - Contains scripts related to maintenance
- [core/source/generation](/core/source/generation) - Contains scripts related to README generation
- [core/source/maintenance](/core/source/maintenance) - Contains scripts related to maintenance
## Data
- [applications.json](/source/data/dynamic/applications.json) - Stores all information related to applications
- [categories.json](/source/data/static/categories.json) - Declares categories and subcategories
- [tags](/source/data/static/tags.json) - Declares tags, their id, and corresponding emoji
- [applications.json](/core/data/dynamic/applications.json) - Stores all information related to applications
- [categories.json](/core/data/static/categories.json) - Declares categories and subcategories
- [tags](/core/data/static/tags.json) - Declares tags, their id, and corresponding emoji
## GitHub Actions
- [generate-readme.yml](/.github/workflows/generate-readme.yml) - Calls the [`readme_generator.py`](/source/scripts/generation/readme_generator.py) to generate READMEs
- [update-stats.yml](/.github/workflows/update-stats.yml) - Calls the [`stats_updator.py`](/source/scripts/maintenance/stats_updator.py.py) to update stats in applications.json
- [generate-readme.yml](/.github/workflows/generate-readme.yml) - Calls the [`readme_generator.py`](/core/source/generation/readme_generator.py) to generate READMEs
- [update-stats.yml](/.github/workflows/update-stats.yml) - Calls the [`stats_updator.py`](/core/source/maintenance/stats_updator.py.py) to update stats in applications.json
## Other Resources
- [DOCS.md](/resources/DOCS.md) - Elaborates tags

View File

@@ -3,15 +3,15 @@
Here's a look at how the "backend" of the list works.
## README Generation
All applications are stored inside [`applications.json`](source/data/dynamic/applications.json). Categories are declared inside [`categories.json`](source/data/static/categories.json). Instead of a nested format with subcategories as on object of it's parent, we've given subcategories a `parent` attribute. There's also a [`tags.json`](source/data/static/tags.json). Instead of putting the emoji inside of the ```tags``` attribute in `applications.json`, the id is used, for example, `commercial` or `disruptive`.. These id's are mapped to their corresponding emoji for when the READMEs are generated and makes``applications.json``` more readable.
All applications are stored inside [`applications.json`](core/data/dynamic/applications.json). Categories are declared inside [`categories.json`](core/data/static/categories.json). Instead of a nested format with subcategories as on object of it's parent, we've given subcategories a `parent` attribute. There's also a [`tags.json`](core/data/static/tags.json). Instead of putting the emoji inside of the ```tags``` attribute in `applications.json`, the id is used, for example, `commercial` or `disruptive`.. These id's are mapped to their corresponding emoji for when the READMEs are generated and makes``applications.json``` more readable.
The generation scripts are inside of the [`source/scripts/generation`](source/scripts/generation) directory. [`mainheader_generator.py`](source/scripts/generation/mainheader_generator.py) generates the very top header with the dynamic project count. Then, depending on the platform being generating, it inserts [`header.md`](source/components/header.md), [`macosheader.md`](source/components/macosheader.md), etc.
The generation scripts are inside of the [`core/source/generation`](core/source/generation) directory. [`mainheader_generator.py`](core/source/generation/mainheader_generator.py) generates the very top header with the dynamic project count. Then, depending on the platform being generating, it inserts [`header.md`](source/components/header.md), [`macosheader.md`](source/components/macosheader.md), etc.
[`tableofcontents_generator.py`](source/scripts/generation/tableofcontents_generator.py) generates the table of contents. It creates one, expandable but hidden by default, with all subsections listed alphabetically. The default TOC shows parent categories alphabetically with subcategories underneath, also alphabetically.
[`tableofcontents_generator.py`](core/source/generation/tableofcontents_generator.py) generates the table of contents. It creates one, expandable but hidden by default, with all subsections listed alphabetically. The default TOC shows parent categories alphabetically with subcategories underneath, also alphabetically.
[`contents_generator.py`](source/scripts/generation/contents_generator.py) generates the actual list.
[`contents_generator.py`](core/source/generation/contents_generator.py) generates the actual list.
Lastly [`readme_generator.py`](source/scripts/generation/readme_generator.py) brings everything together, calling the other scripts to generate one main list, and more for several platforms.
Lastly [`readme_generator.py`](core/source/generation/readme_generator.py) brings everything together, calling the other scripts to generate one main list, and more for several platforms.
## Maintenence
[`applications.json`](source/data/dynamic/applications.json) stores a lot of information that the README does not display such as last commit, language, and license. These are for a future web version of the list that would pull data from the json file. [`stats_updator.py`](source/maintenance/stats_updator.py) runs every midnight and updates all application stats. Each application object in the json file also has a `flags` attribute. For example, the `custom-description` flag tells the stats_updator script to skip updating the description for that app. For more into on flags, consult the [`DOCS.md`](resources/DOCS.md)
[`applications.json`](core/data/dynamic/applications.json) stores a lot of information that the README does not display such as last commit, language, and license. These are for a future web version of the list that would pull data from the json file. [`stats_updator.py`](source/maintenance/stats_updator.py) runs every midnight and updates all application stats. Each application object in the json file also has a `flags` attribute. For example, the `custom-description` flag tells the stats_updator script to skip updating the description for that app. For more into on flags, consult the [`DOCS.md`](resources/DOCS.md)