-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 39c86f0
Showing
14 changed files
with
526 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GH_TOKEN= | ||
CURSEFORGE_TOKEN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
on: | ||
push: | ||
branches: | ||
- master | ||
schedule: | ||
# Run every day at 00:00 UTC | ||
- cron: '0 0 * * *' | ||
# Allow manual running as well | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v1 | ||
- run: bun install | ||
name: Install dependencies | ||
- run: bun run index.ts | ||
name: Update things | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} | ||
# Commit any changes back to the project | ||
- run: git config --global user.email "[email protected]" | ||
- run: git config --global user.name "Michael Hillcox" | ||
- run: git add . | ||
# Check if there are any changes to commit | ||
- run: git diff --quiet --exit-code || git commit -m "Update things" | ||
- run: git push | ||
name: Push changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore | ||
|
||
# Logs | ||
|
||
logs | ||
_.log | ||
npm-debug.log_ | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Caches | ||
|
||
.cache | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
|
||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | ||
|
||
# Runtime data | ||
|
||
pids | ||
_.pid | ||
_.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
|
||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
|
||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
|
||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
|
||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
|
||
bower_components | ||
|
||
# node-waf configuration | ||
|
||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
|
||
build/Release | ||
|
||
# Dependency directories | ||
|
||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
|
||
web_modules/ | ||
|
||
# TypeScript cache | ||
|
||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
|
||
.npm | ||
|
||
# Optional eslint cache | ||
|
||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
|
||
.stylelintcache | ||
|
||
# Microbundle cache | ||
|
||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
|
||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
|
||
*.tgz | ||
|
||
# Yarn Integrity file | ||
|
||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
|
||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
|
||
.parcel-cache | ||
|
||
# Next.js build output | ||
|
||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
|
||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
|
||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
|
||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
|
||
# public | ||
|
||
# vuepress build output | ||
|
||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
|
||
.temp | ||
|
||
# Docusaurus cache and generated files | ||
|
||
.docusaurus | ||
|
||
# Serverless directories | ||
|
||
.serverless/ | ||
|
||
# FuseBox cache | ||
|
||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
|
||
.dynamodb/ | ||
|
||
# TernJS port file | ||
|
||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
|
||
.vscode-test | ||
|
||
# yarn v2 | ||
|
||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# IntelliJ based IDEs | ||
.idea | ||
|
||
# Finder (MacOS) folder config | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# nanite-meta | ||
|
||
To install dependencies: | ||
|
||
```bash | ||
bun install | ||
``` | ||
|
||
To run: | ||
|
||
```bash | ||
bun run index.ts | ||
``` | ||
|
||
This project was created using `bun init` in bun v1.0.19. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "nanite-meta", | ||
"module": "index.ts", | ||
"devDependencies": { | ||
"bun-types": "latest" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"type": "module", | ||
"dependencies": { | ||
"@octokit/rest": "^20.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { CommonProvider } from "../types/EnrichedMetaSpec"; | ||
import { semverSortMinecraft } from "../utils"; | ||
|
||
const url = `https://api.curseforge.com/v1/`; | ||
|
||
export async function getCurseProjectData(id: string): Promise<CommonProvider | null> { | ||
const modRequest = await fetcher(`${url}mods/${id}`); | ||
|
||
if (modRequest.status !== 200) { | ||
console.log(`Failed to fetch Curse data for ${id} due to a status code of ${modRequest.status}`) | ||
return null; | ||
} | ||
|
||
let modData: any = await modRequest.json(); | ||
if (!modData?.data?.slug) { | ||
console.log(`No slug found for Curse project ${id}`); | ||
return null; | ||
} | ||
|
||
modData = modData.data; | ||
|
||
return { | ||
title: modData.name, | ||
description: modData.summary, | ||
image: modData.logo?.url ?? null, | ||
minecraftVersions: ([...new Set(modData.latestFilesIndexes.map((e: any) => e.gameVersion))] as string[]) | ||
.sort(semverSortMinecraft), | ||
webUrl: modData.links?.websiteUrl ?? `https://www.curseforge.com/minecraft/mc-mods/${modData.slug}`, | ||
updatedAt: modData.dateModified, | ||
downloads: modData.downloadCount, | ||
} | ||
} | ||
|
||
async function fetcher(request: string | URL | Request, init?: RequestInit): Promise<Response> { | ||
return fetch(request, { | ||
...init, | ||
headers: { | ||
...init?.headers, | ||
'Accept':'application/json', | ||
'x-api-key': process.env.CURSEFORGE_TOKEN ?? "", | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { CommonProvider } from "../types/EnrichedMetaSpec"; | ||
import { semverSortMinecraft } from "../utils"; | ||
|
||
const modrinthApi = "https://api.modrinth.com/v2/"; | ||
|
||
export async function getModrinthData(id: string): Promise<CommonProvider | null> { | ||
const request = await fetch(`${modrinthApi}project/${id}`); | ||
if (request.status !== 200) { | ||
console.log(`Failed to fetch Modrinth data for ${id} due to a status code of ${request.status}`) | ||
return null; | ||
} | ||
|
||
const data: any = await request.json(); | ||
if (!data?.slug) { | ||
console.log(`No slug found for Modrinth project ${id}`); | ||
return null; | ||
} | ||
|
||
return { | ||
title: data.title, | ||
description: data.description, | ||
image: data.icon_url, | ||
minecraftVersions: data.game_versions.sort(semverSortMinecraft), | ||
webUrl: `https://modrinth.com/mod/${data.slug}`, | ||
updatedAt: data.updated, | ||
downloads: data.downloads, | ||
} | ||
} |
Oops, something went wrong.