Skip to content

Commit

Permalink
AutoCommit: Bump Repository (Update Repository Files)
Browse files Browse the repository at this point in the history
  • Loading branch information
thealternatedev committed Oct 25, 2023
1 parent dbc6251 commit ac18c1a
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 43 deletions.
2 changes: 2 additions & 0 deletions bin/commands/RegisterCommands.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const { RegisterCommand, RegisterJSONCommand } = require("../CommandsHandler");
const InitCommand = require("./InitCommand");
const RunCommand = require("./RunCommand");
const TemplateCommand = require("./TemplateCommand");
const VersionCommand = require("./VersionCommand");

module.exports = (program) => {
RegisterJSONCommand(program, VersionCommand());
RegisterJSONCommand(program, InitCommand());
RegisterJSONCommand(program, RunCommand());
RegisterJSONCommand(program, TemplateCommand())
}
39 changes: 39 additions & 0 deletions bin/commands/TemplateCommand.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const CommandBuilder = require("../CommandBuilder");
const Templates = require("@redactcord/templates");
const simpleGit = require("simple-git");
const git = simpleGit.default(process.cwd())

module.exports = () => {
return CommandBuilder.createBuilder("template")
.setDescription("Displays or Creates templates")
.addArgument("[template]")
.setCallback((template) => {
const templates = Templates.TEMPLATES;
if (!template) {

if (!templates.length)
return console.log("No Templates are found at this current time. templates package may have not been updated in the main package");

let tab = ` `;
let string = ``;

for (const template of templates) {
string += `${tab}|-${template}\n`;
}

console.log(string.trim());
} else {

const index = templates.indexOf(template);
if (index == -1)
return console.log("Not Present in the templates list.");
const templateValue = templates[index];
const url = `${Templates.GithubPrefix}${templateValue}`;

git.clone(url, process.cwd()).then((value) => {
console.log("Cloned Template " + templateValue + " to " + process.cwd());
});
}

});
}
92 changes: 56 additions & 36 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
"@types/node": "^20.8.6"
},
"dependencies": {
"@redactcord/templates": "^0.0.1",
"better-sqlite3": "^9.0.0",
"cli-color": "^2.0.3",
"commander": "^11.1.0",
"discord.js": "^14.13.0",
"discord.js": "^14.12.1",
"dotenv": "^16.3.1",
"eval": "^0.1.8",
"figlet": "^1.6.0",
Expand All @@ -42,8 +43,9 @@
"quick.db": "^9.1.7",
"quickmongo": "^5.2.0",
"quickpostgres": "^3.0.2",
"simple-git": "^3.20.0",
"typescript": "^5.2.2",
"watch": "^1.0.2",
"watch": "^0.13.0",
"yaml": "^2.3.3"
}
}
2 changes: 2 additions & 0 deletions packages/templates/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const TEMPLATES: string[];
export const GithubPrefix: string;
4 changes: 4 additions & 0 deletions packages/templates/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
TEMPLATES: [],
GithubPrefix: "https://github.com/"
}
24 changes: 24 additions & 0 deletions packages/templates/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@redactcord/templates",
"version": "0.0.1",
"description": "Provides all template urls for the main package",
"main": "index.js",
"typings": "index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Max Jackson",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/redactdev/redactcord.git"
},
"keywords": [
"urls",
"templates"
],
"bugs": {
"url": "https://github.com/redactdev/redactcord/issues"
},
"homepage": "https://github.com/redactdev/redactcord#readme"
}
12 changes: 8 additions & 4 deletions src/utils/Loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RedactError } from "../error/RedactError";

export class Loader<E> {

public loadFrom(folder: string, deep: boolean = false) {
public loadFrom(folder: string, deep: boolean = false, iscwd: boolean = true) {
const arr: E[] = [];
const hirearchy = readdirSync(folder);

Expand All @@ -17,9 +17,13 @@ export class Loader<E> {
}
else
{
if (!item.endsWith(".js") || !item.endsWith(".ts"))
throw new RedactError("Invalid Extension", "An invalid extension was found in a file name: \"" + item + "\". Make sure it's .ts or .js");
const r = require(path.join(folder, item));
let p = ``;
if (iscwd) {
p += path.join(process.cwd(), folder, item)
} else {
p += path.join(folder, item)
}
const r = require(p);
let clazz: E;
try {
clazz = r();
Expand Down
3 changes: 2 additions & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class CommandsManager extends Loader<RedactCommand> {
}

export class Loader<E> {
public loadFrom(folder: string, deep: boolean = false): E[];
public loadFrom(folder: string, deep: boolean = false, iscwd: boolean = true): E[];
}

export class EventManager extends Loader<Event> {
Expand All @@ -70,6 +70,7 @@ type MessageArguments = string[];

export abstract class RedactCommand {

constructor(commandData: ComandData);
public setRedactClient(redactClient: RedactClient): void;
public getRedactClient(): RedactClient;
public getCommandData(): CommandData;
Expand Down

0 comments on commit ac18c1a

Please sign in to comment.