Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 27 additions & 33 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as request from "request";
import fetch from "node-fetch";
import { FilesBuilder } from "./src/files-builder";
import { ContentGenerate } from "./src/content-generate";
import * as figlet from "figlet";
import figlet from "figlet";
import { GamesType } from "./src/enum/GamesType";
import { terminal as term } from "terminal-kit";

Expand Down Expand Up @@ -44,49 +44,43 @@ export class Main {
* @param gametype
* @return void
*/
public static onEnable = (
public static onEnable = async (
dir: string,
gametype: GamesType
): Promise<void> => {
let json = Main.getNativeLink(gametype);
const jsonUrl = Main.getNativeLink(gametype);

if (!json) return;
if (!jsonUrl) return;

return new Promise((resolve) => {
request.get(json, async (error, response, content) => {
const files = new FilesBuilder(dir);
const json = JSON.parse(content);
try {
const response = await fetch(jsonUrl);
const content = await response.text();
const json = JSON.parse(content);

await files.init();
const files = new FilesBuilder(dir);
await files.init();

files.category(json);
await files.category(json);

await new Promise((resolve) => setTimeout(resolve, 1000));
await new Promise((resolve) => setTimeout(resolve, 1000));

const builder = new ContentGenerate(files).setDocumentationUrl(
Main.getNativeDocsUrl(gametype)
);
const builder = new ContentGenerate(files).setDocumentationUrl(
Main.getNativeDocsUrl(gametype)
);

try {
await builder.generateTemplate(json);
} catch (err) {
term.red(err);
} finally {
resolve();
}
});
});
await builder.generateTemplate(json);
} catch (err) {
term.red(String(err));
}
};

/**
* Folder generate logic
*
* @param response
*
*
* @return void
*/
public static onFolderGenerate = (response: void) => {
term.cyan("Create build directory successfully : " + response);
public static onFolderGenerate = () => {
term.cyan("Create build directory successfully");
};

/**
Expand All @@ -100,12 +94,12 @@ export class Main {
*/
public static onFileUpdate = (
stats: { native: { total: number; current: number } },
filename: String,
nativename: String
filename: string,
nativename: string
): void => {
stats.native.current++;
term.green("[File : " + filename + " ] [Native : " + nativename + " ]\n");
if (stats.native.current == stats.native.total) process.exit();
term.green(`[File: ${filename}] [Native: ${nativename}]\n`);
if (stats.native.current === stats.native.total) process.exit();
};
}

Expand Down
29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@
"description": "",
"main": "main.ts",
"scripts": {
"start": "ts-node main.ts"
"start": "ts-node main.ts",
"dev": "ts-node --watch main.ts",
"build": "tsc",
"clean": "rimraf build dist"
},
"author": "Dylan Malandain",
"license": "MIT",
"devDependencies": {
"@types/node": "^14.14.37",
"ts-node": "^8.1.1",
"typescript": "^3.4.5"
"@types/node": "^24.10.1",
"@types/node-fetch": "^2.6.13",
"rimraf": "^6.1.2",
"ts-node": "^10.9.0",
"typescript": "^5.0.0"
},
"dependencies": {
"@akanass/rx-http-request": "^3.1.0",
"@types/common-tags": "^1.8.1",
"@types/fs-extra": "^7.0.0",
"@types/request": "^2.48.1",
"@types/terminal-kit": "^1.28.0",
"chalk": "^2.4.2",
"@types/fs-extra": "^11.0.0",
"@types/terminal-kit": "^2.5.0",
"chalk": "^5.3.0",
"common-tags": "^1.8.0",
"figlet": "^1.2.4",
"fs-extra": "^8.0.1",
"request": "^2.88.0",
"terminal-kit": "^1.31.6"
"figlet": "^1.7.0",
"fs-extra": "^11.0.0",
"node-fetch": "^3.3.0",
"terminal-kit": "^3.0.0"
}
}
Loading