-
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.
AutoCommit: Bump Repository (Update Repository Files)
- Loading branch information
1 parent
ac2ae92
commit 8c95728
Showing
21 changed files
with
318 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class CommandBuilder { | ||
|
||
static createBuilder(commandName) { | ||
return new CommandBuilder(commandName); | ||
} | ||
|
||
constructor(name) { | ||
this.name = name; | ||
this.args = []; | ||
this.description = ""; | ||
this.callback = () => {}; | ||
} | ||
|
||
setName(name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
setArguments(args) { | ||
this.args = args; | ||
return this; | ||
} | ||
|
||
setDescription(description) { | ||
this.description = description; | ||
return this; | ||
} | ||
|
||
setCallback(callback) { | ||
this.callback = callback; | ||
return this; | ||
} | ||
|
||
toJSON() { | ||
return { | ||
name: this.name, | ||
args: this.args, | ||
description: this.description, | ||
callback: this.callback | ||
}; | ||
} | ||
} | ||
|
||
module.exports = CommandBuilder; |
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,34 @@ | ||
const { Collection } = require("discord.js"); | ||
|
||
function RegisterCommand(program, data) { | ||
|
||
const { name, args, description, callback } = data; | ||
|
||
|
||
if (!description) { | ||
|
||
} | ||
|
||
if (!callback) { | ||
|
||
} | ||
|
||
let l = program.command(name) | ||
.description(description) | ||
.action(callback); | ||
|
||
if (args && args.length) { | ||
for (const arg of args) { | ||
l.argument(arg); | ||
} | ||
} | ||
} | ||
|
||
function RegisterJSONCommand(program, builder) { | ||
RegisterCommand(program, builder.toJSON()); | ||
} | ||
|
||
module.exports = { | ||
RegisterCommand, | ||
RegisterJSONCommand | ||
} |
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,56 @@ | ||
const CommandBuilder = require("../CommandBuilder"); | ||
const Nanospinner = require("nanospinner"); | ||
const spinner = Nanospinner.createSpinner(); | ||
const InitializationTools = require('../../globals/InitializationUtils'); | ||
|
||
const maxSteps = 4; | ||
let currentStep = 1; | ||
|
||
function startStep(text) { | ||
spinner.start({ | ||
text: `${text} (${currentStep}/${maxSteps})` | ||
}); | ||
} | ||
|
||
function step(text) { | ||
currentStep++; | ||
if (currentStep >= maxSteps) | ||
return end(text, true); | ||
spinner.update({ | ||
text: `${text} (${currentStep}/${maxSteps})` | ||
}); | ||
} | ||
|
||
function end(text, success) { | ||
|
||
if (success) { | ||
spinner.success({ | ||
text: `${text} (${currentStep}/${maxSteps})` | ||
}); | ||
} else { | ||
spinner.stop({ | ||
text: `${text} (${currentStep}/${maxSteps})` | ||
}); | ||
} | ||
|
||
} | ||
|
||
module.exports = () => CommandBuilder.createBuilder("init") | ||
.setDescription("Creates a new Redactcord project") | ||
.setCallback(() => { | ||
|
||
startStep("Creating Directories..."); | ||
|
||
InitializationTools.makeDirectories(); | ||
|
||
step("Creating Files"); | ||
|
||
InitializationTools.writeFiles(); | ||
|
||
step("Creating configuraitons"); | ||
|
||
InitializationTools.createConfigurationFiles(); | ||
|
||
step("Done! Created All Files"); | ||
|
||
}); |
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,8 @@ | ||
const { RegisterCommand, RegisterJSONCommand } = require("../CommandsHandler"); | ||
const InitCommand = require("./InitCommand"); | ||
const VersionCommand = require("./VersionCommand") | ||
|
||
module.exports = (program) => { | ||
RegisterJSONCommand(program, VersionCommand()); | ||
RegisterJSONCommand(program, InitCommand()); | ||
} |
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,9 @@ | ||
const CommandBuilder = require("../CommandBuilder") | ||
|
||
module.exports = () => { | ||
return CommandBuilder.createBuilder("version") | ||
.setDescription("Displays CLI Version") | ||
.setCallback(() => { | ||
console.log(require("../../package").version); | ||
}); | ||
} |
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,17 @@ | ||
const { program } = require("commander"); | ||
const { getCommands, ExecuteCommand } = require("./CommandsHandler"); | ||
const RegisterCommands = require("./commands/RegisterCommands"); | ||
|
||
async function init() { | ||
await RegisterCommands(program); | ||
|
||
|
||
} | ||
|
||
function run() { | ||
program.parse(); | ||
} | ||
|
||
init().then(_ => { | ||
run(); | ||
}) |
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,9 @@ | ||
const { program } = require("commander"); | ||
|
||
function command(name, opts) { | ||
return program.command(name, opts); | ||
} | ||
|
||
module.exports = { | ||
command, | ||
} |
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,66 @@ | ||
const { writeFileSync, mkdirSync } = require("fs"); | ||
const path = require("path"); | ||
|
||
const configName = "redact.config.json"; | ||
const environmentName = ".redact.env"; | ||
const files = [ | ||
environmentName, | ||
"src/index.js", | ||
]; | ||
const directories = [ | ||
"src", | ||
"commands", | ||
"events", | ||
]; | ||
|
||
const packageConfig = { | ||
name: path.basename(path.dirname(process.cwd())), | ||
version: "1.0.0", | ||
description: "Generated Bot Project by Redactcord", | ||
main: "src/index.js", | ||
scripts: { | ||
test: "echo No Test script was found & exit 0" | ||
}, | ||
license: "MIT", | ||
author: "", | ||
keywords: ["Bot"] | ||
}; | ||
|
||
const redactconfig = { | ||
$schema: "https://cdn.redact.tools/libs/redactcord/RedactcordConfig.schema.json", | ||
main: "src/index.js", | ||
suspendCommandsLoading: false, | ||
suspendEventsLoading: false, | ||
eventsFolderPath: "events", | ||
commandsFolderPath: "commands", | ||
allowEnvironmentLoading: true, | ||
commands: [] | ||
}; | ||
|
||
function toJson(data) { | ||
return JSON.stringify(data, null, 4); | ||
} | ||
|
||
function createConfigurationFiles() { | ||
writeFileSync(path.join(process.cwd(), "package.json"), toJson(packageConfig)); | ||
writeFileSync(path.join(process.cwd(), "redactcord.config.json"), toJson(redactconfig)); | ||
} | ||
|
||
function writeFiles() { | ||
for (const file of files) { | ||
writeFileSync(path.join(process.cwd(), file), ""); | ||
} | ||
} | ||
|
||
function makeDirectories() { | ||
for (const directory of directories) { | ||
mkdirSync(path.join(process.cwd(), directory), { recursive: true }); | ||
} | ||
} | ||
|
||
module.exports = { | ||
createConfigurationFiles, | ||
writeFiles, | ||
toJson, | ||
makeDirectories | ||
} |
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
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
Oops, something went wrong.