Skip to content

Commit

Permalink
beta
Browse files Browse the repository at this point in the history
  • Loading branch information
lxRbckl committed Jul 14, 2024
1 parent d893fc0 commit 9214236
Show file tree
Hide file tree
Showing 14 changed files with 281 additions and 140 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM node:19.5.0


# referencing docker compose <
ENV owner ${owner}
ENV tokenOctokit ${tokenOctokit}
ENV linkGithubUsers ${linkGithubUsers}
ENV linkOctokitConfig ${linkOctokitConfig}
ENV octokitFile ${octokitFile}
ENV octokitToken ${octokitToken}
ENV octokitOwner ${octokitOwner}
ENV octokitBranch ${octokitBranch}
ENV urlGitHubUsers ${linkGithubUsers}

# >

Expand Down
34 changes: 13 additions & 21 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,30 @@

// import <
const cron = require('node-cron');
import { axiosGet } from 'lxrbckl';

import { Archive } from './src/types/archiveManager';
import archiveManager from './src/services/archiveManager';
import archiveManager from './src/managers/archiveManager';
import archiveConfig from './src/config/archiveManagerConfig';

//


// env <
const owner: string = process.env.owner!;
const tokenOctokit: string = process.env.tokenOctokit!;
const linkGithubUsers: string = process.env.linkGithubUsers!;
const linkOctokitConfig: string = process.env.linkOctokitConfig!;

// >


(async () => {

var archiver: archiveManager = new archiveManager(
const archiveHandler: archiveManager = new archiveManager({

owner,
tokenOctokit,
linkGithubUsers,
linkOctokitConfig
// githubUsers : await axiosGet(archiveConfig.urlGitHubUsers)
githubUsers : ['lxRbckl', 'ala2q6']

);
});

cron.schedule('0 0 * * *', async () => {
await archiveHandler.setArchive(await archiveHandler.getArchive());

let a: Archive = await archiver.getArchive();
await archiver.setArchive(a);
// cron.schedule('0 0 * * *', async () => {

});
// let archive: Archive = await archiver.getArchive();
// await archiver.setArchive(archive);

// });

})();
File renamed without changes.
30 changes: 30 additions & 0 deletions dist/app.js
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);
// });
}))();
15 changes: 15 additions & 0 deletions dist/src/config/archiveManagerConfig.js
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;
// >
58 changes: 58 additions & 0 deletions dist/src/managers/archiveManager.js
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;
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"homepage": "https://github.com/lxRbckl/Project-Heimir#readme",
"dependencies": {
"@types/node": "^20.14.2",
"lxrbckl": "^8.9.6",
"lxrbckl": "^9.3.1",
"node-cron": "^3.0.3"
}
}
File renamed without changes.
31 changes: 31 additions & 0 deletions src/config/archiveManagerConfig.ts
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;

// >
7 changes: 0 additions & 7 deletions src/data/octokitConfig.json

This file was deleted.

85 changes: 85 additions & 0 deletions src/managers/archiveManager.ts
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;

}


}
Loading

0 comments on commit 9214236

Please sign in to comment.