Skip to content

Commit

Permalink
finalize v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowflake107 committed Nov 5, 2020
1 parent 78cb4e5 commit ad54f38
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 16 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# Create Discord App
Super fast discord bot project generator.
A Simple CLI to generate discord bot projects easily!

# Example
```sh
$ npx create-discord-app .
```

# Specific dir
```sh
$ npx create-discord-app --create --dir=dirName
```

# Join Our Discord Server
[![](https://i.imgur.com/f6hNUfc.png)](https://discord.gg/2SUybzb)
12 changes: 6 additions & 6 deletions command.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ const help = `
${chalk.whiteBright("--discord")} : Shows discord support server invite
${chalk.whiteBright("--help")} : Shows help menu
${chalk.whiteBright("--version")} : Shows CDA version
${chalk.whiteBright("--create")} : Create Project
Example: ${chalk.gray("$")} ${chalk.blueBright("create-discord-app .")}
Examples:
${chalk.gray("$")} ${chalk.blueBright("create-discord-app .")}
${chalk.gray("$")} ${chalk.blueBright("create-discord-app --create --dir=projectDirName")}
`;

module.exports = async (args) => {
Expand All @@ -24,6 +26,7 @@ module.exports = async (args) => {
} else if (args.discord) {
console.log(`${chalk.whiteBright("Join Our Discord Server")}: ${chalk.blueBright("https://discord.gg/2SUybzb")}`);
} else if (args.create || (args._[0] && args._[0] === ".")) {
if (args.create && !args.dir) return console.log(chalk.redBright("dir was not specified!"));
const { ok, type, language, lib, token } = await prompt([
prompts.dir,
prompts.type,
Expand All @@ -50,7 +53,7 @@ module.exports = async (args) => {
// none
else return console.log(chalk.redBright("[Error] Couldn't locate template files!"));

const cda = new create(path.join(process.cwd(), args._[0] === "." ? "" : args.dir), projectdir);
const cda = new create(args._[0] === "." ? "" : args.dir, projectdir);

const lang = () => {
let l;
Expand All @@ -60,9 +63,6 @@ module.exports = async (args) => {
case "typescript":
l = "node";
break;
case "python":
l = "py";
break;
default:
l = null;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-discord-app",
"version": "2.0.0",
"description": "Discord bot project generator.",
"description": "A Simple CLI to generate discord bot projects easily!",
"main": "index.js",
"preferGlobal": true,
"bin": {
Expand Down
28 changes: 20 additions & 8 deletions src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ class Create {
this.source = source;
}

initGit() {
const commands = ["git init", "git add .", "git commit -m \"initial commit\""];
const finalizingLoader = ora(chalk.blueBright("Finalizing...")).start();

for (const command of commands) {
try {
cp.execSync(this.path === "." ? command : `cd ${this.path} && ${command}`);
} catch(e) { /* Do nothing */ }
}

finalizingLoader.succeed(chalk.greenBright("Successfully created discord bot project!"))
}

async init(token = null, ops = { language: null }) {
if (!this.source) return console.log(symbols.error, chalk.redBright("No source file(s) specified!"));
let path = this.path === "." ? process.cwd() : `${process.cwd()}/${this.path}`;
Expand All @@ -28,14 +41,16 @@ class Create {
}

copyFileLoader.succeed(chalk.cyanBright("Finished copying files!"));
const finalizingLoader = ora(chalk.blueBright("Finalizing...")).start();
const depInstaller = ora(chalk.blueBright("Installing dependencies...")).start();

const command = this.getInstallCommand(ops.language);
if (!command) return finalizingLoader.warn(chalk.yellowBright("Generated project but couldn't install dependencies, please try again manually!"));
if (!command) return depInstaller.warn(chalk.yellowBright("Generated project but couldn't install dependencies, please try again manually!"));

cp.exec(this.path === "." ? command : `cd ${this.path} && ${command}`, (error) => {
if (error) return depInstaller.warn(chalk.yellowBright("Generated project but couldn't install dependencies, please try again manually!"));
depInstaller.succeed(chalk.greenBright("Successfully Installed dependencies!"));

cp.exec(command, (error) => {
if (error) return finalizingLoader.warn(chalk.yellowBright("Generated project but couldn't install dependencies, please try again manually!"));
return finalizingLoader.succeed(chalk.greenBright("Successfully created discord bot project!"));
return this.initGit();
});
});
}
Expand All @@ -47,9 +62,6 @@ class Create {
case "js":
cmd = "npm i";
break;
case "py":
cmd = "pip3 install -r requirements.txt";
break;
default:
cmd = null;
}
Expand Down

0 comments on commit ad54f38

Please sign in to comment.