-
Notifications
You must be signed in to change notification settings - Fork 4
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
14 changed files
with
281 additions
and
140 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
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
File renamed without 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,30 @@ | ||
"use strict"; | ||
// < Project Heimir by Alex Arbuckle > // | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// import < | ||
const cron = require('node-cron'); | ||
const archiveManager_1 = __importDefault(require("./src/managers/archiveManager")); | ||
// | ||
(() => __awaiter(void 0, void 0, void 0, function* () { | ||
const archiveHandler = new archiveManager_1.default({ | ||
// githubUsers : await axiosGet(archiveConfig.urlGitHubUsers) | ||
githubUsers: ['lxRbckl', 'ala2q6'] | ||
}); | ||
yield archiveHandler.setArchive(yield archiveHandler.getArchive()); | ||
// cron.schedule('0 0 * * *', async () => { | ||
// let archive: Archive = await archiver.getArchive(); | ||
// await archiver.setArchive(archive); | ||
// }); | ||
}))(); |
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 @@ | ||
"use strict"; | ||
// import < | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// > | ||
const archiveManagerConfig = { | ||
branch: 'V2', | ||
owner: 'lxRbckl', | ||
repository: 'Project-Heimir', | ||
file: 'data/repositoryArchive.json', | ||
token: '', | ||
urlGitHubUsers: '' | ||
}; | ||
// export < | ||
exports.default = archiveManagerConfig; | ||
// > |
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,58 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// imports < | ||
const lxrbckl_1 = require("lxrbckl"); | ||
const archiveManagerConfig_1 = __importDefault(require("../config/archiveManagerConfig")); | ||
// > | ||
class archiveManager { | ||
constructor({ githubUsers }) { | ||
this._githubUsers = githubUsers; | ||
this._octokit = new lxrbckl_1.octokit({ | ||
owner: archiveManagerConfig_1.default.owner, | ||
token: archiveManagerConfig_1.default.token | ||
}); | ||
} | ||
setArchive(archive) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this._octokit.respositorySet({ | ||
data: archive, | ||
file: archiveManagerConfig_1.default.file, | ||
branch: archiveManagerConfig_1.default.branch, | ||
repository: archiveManagerConfig_1.default.repository | ||
}); | ||
}); | ||
} | ||
getArchive() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
var archive = {}; | ||
for (const u of this._githubUsers) { | ||
const endpointRepos = `GET /users/${u}/repos`; | ||
for (const r of yield this._octokit.request({ endpoint: endpointRepos })) { | ||
const endpointLanguages = `GET /repos/${u}/${r.name}/languages`; | ||
const languages = yield this._octokit.request({ endpoint: endpointLanguages }); | ||
archive[r.name] = { | ||
'topics': r.topics, | ||
'owner': r.owner.login, | ||
'languages': Object.keys(languages), | ||
'url': `https://github.com/${u}/${r.name}`, | ||
'description': (r.description).split('.')[0] | ||
}; | ||
} | ||
} | ||
return archive; | ||
}); | ||
} | ||
} | ||
exports.default = archiveManager; |
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
File renamed without 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,31 @@ | ||
// import < | ||
|
||
|
||
// > | ||
|
||
|
||
const archiveManagerConfig: { | ||
|
||
file: string, | ||
owner: string, | ||
token: string, | ||
branch: string, | ||
repository: string, | ||
urlGitHubUsers: string | ||
|
||
} = { | ||
|
||
branch : 'V2', | ||
owner : 'lxRbckl', | ||
repository : 'Project-Heimir', | ||
file : 'data/repositoryArchive.json', | ||
token : '', | ||
urlGitHubUsers : '' | ||
|
||
} | ||
|
||
|
||
// export < | ||
export default archiveManagerConfig; | ||
|
||
// > |
This file was deleted.
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,85 @@ | ||
// imports < | ||
import { octokit } from 'lxrbckl'; | ||
|
||
import archiveConfig from '../config/archiveManagerConfig'; | ||
import { | ||
|
||
Archive, | ||
ConstructorParams | ||
|
||
} from '../types/archiveManager'; | ||
|
||
// > | ||
|
||
|
||
export default class archiveManager { | ||
|
||
|
||
private _octokit: octokit; | ||
|
||
private readonly _githubUsers: string[]; | ||
|
||
|
||
constructor({ | ||
|
||
githubUsers | ||
|
||
}: ConstructorParams) { | ||
|
||
this._githubUsers = githubUsers; | ||
|
||
this._octokit = new octokit({ | ||
|
||
owner : archiveConfig.owner, | ||
token : archiveConfig.token | ||
|
||
}); | ||
|
||
} | ||
|
||
|
||
async setArchive(archive: Archive) { | ||
|
||
await this._octokit.respositorySet({ | ||
|
||
data : archive, | ||
file : archiveConfig.file, | ||
branch : archiveConfig.branch, | ||
repository : archiveConfig.repository | ||
|
||
}); | ||
|
||
} | ||
|
||
|
||
async getArchive(): Promise<Archive> { | ||
|
||
var archive: Archive = {}; | ||
for (const u of this._githubUsers) { | ||
|
||
const endpointRepos: string = `GET /users/${u}/repos`; | ||
for (const r of await this._octokit.request({endpoint : endpointRepos})) { | ||
|
||
const endpointLanguages: string = `GET /repos/${u}/${r.name}/languages`; | ||
const languages: string[] = await this._octokit.request({endpoint : endpointLanguages}); | ||
|
||
archive[r.name] = { | ||
|
||
'topics' : r.topics, | ||
'owner' : r.owner.login, | ||
'languages' : Object.keys(languages), | ||
'url' : `https://github.com/${u}/${r.name}`, | ||
'description' : (r.description).split('.')[0] | ||
|
||
}; | ||
|
||
} | ||
|
||
} | ||
|
||
return archive; | ||
|
||
} | ||
|
||
|
||
} |
Oops, something went wrong.