forked from altmp/altv-hub
-
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
Showing
5 changed files
with
177 additions
and
5 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 |
---|---|---|
|
@@ -17,15 +17,15 @@ jobs: | |
node-version: 13 | ||
# Runs a set of commands using the runners shell | ||
- name: Create a file. | ||
run: | | ||
echo "test" > test.txt | ||
ls | ||
run: npm install | ||
- name: Build Files | ||
run: npm run build | ||
- name: Commit files | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add . | ||
git commit -m "Add changes" -a | ||
git add ./dist | ||
git commit -m "Updated Resource List" -a | ||
- name: Push changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
|
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 @@ | ||
node_modules/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
{ | ||
"name": "altv-hub", | ||
"version": "0.0.1", | ||
"description": "alt:V Hub is a reference point to post your resources for other users to explore.\r Simply create a pull request with a folder for your github username and a json file with your resource information.", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"build": "node ./src/index.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/altmp/altv-hub.git" | ||
}, | ||
"author": "stuyk", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/altmp/altv-hub/issues" | ||
}, | ||
"homepage": "https://github.com/altmp/altv-hub#readme", | ||
"dependencies": { | ||
"glob": "^7.1.6", | ||
"node-fetch": "^2.6.0", | ||
"walk": "^2.3.14" | ||
} | ||
} |
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,44 @@ | ||
const fetch = require("node-fetch"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const walk = require("walk"); | ||
const files = []; | ||
|
||
const walker = walk.walk("resources", { followLinks: false }); | ||
|
||
walker.on("file", (root, stat, next) => { | ||
files.push({ | ||
author: root.replace("resources\\", ""), | ||
filePath: path.join(root, stat.name), | ||
}); | ||
next(); | ||
}); | ||
|
||
walker.on("end", async () => { | ||
const finalizedFiles = []; | ||
|
||
for (let i = 0; i < files.length; i++) { | ||
let fileData = JSON.parse(fs.readFileSync(files[i].filePath).toString()); | ||
fileData.author = files[i].author; | ||
|
||
const repoPath = fileData.url.replace("https://github.com/", ""); | ||
const response = await fetch(`https://api.github.com/repos/${repoPath}`); | ||
const repoDataString = await response.text(); | ||
const repoData = JSON.parse(repoDataString); | ||
|
||
fileData.updated = repoData.updated_at; | ||
fileData.creation = repoData.created_at; | ||
fileData.pushed = repoData.pushed_at; | ||
fileData.stars = repoData.stargazers_count; | ||
finalizedFiles.push(fileData); | ||
} | ||
|
||
if (!fs.existsSync(path.join(__dirname, "../", "/dist"))) { | ||
fs.mkdirSync(path.join(__dirname, "../", "/dist")); | ||
} | ||
|
||
fs.writeFileSync( | ||
path.join(__dirname, "../", "/dist/resources.json"), | ||
JSON.stringify(finalizedFiles) | ||
); | ||
}); |