Skip to content

Commit ad54f38

Browse files
author
Snowflake107
committed
finalize v2.0.0
1 parent 78cb4e5 commit ad54f38

File tree

4 files changed

+41
-16
lines changed

4 files changed

+41
-16
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
11
# Create Discord App
2-
Super fast discord bot project generator.
2+
A Simple CLI to generate discord bot projects easily!
3+
4+
# Example
5+
```sh
6+
$ npx create-discord-app .
7+
```
8+
9+
# Specific dir
10+
```sh
11+
$ npx create-discord-app --create --dir=dirName
12+
```
13+
14+
# Join Our Discord Server
15+
[![](https://i.imgur.com/f6hNUfc.png)](https://discord.gg/2SUybzb)

command.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ const help = `
1111
${chalk.whiteBright("--discord")} : Shows discord support server invite
1212
${chalk.whiteBright("--help")} : Shows help menu
1313
${chalk.whiteBright("--version")} : Shows CDA version
14+
${chalk.whiteBright("--create")} : Create Project
1415
15-
16-
Example: ${chalk.gray("$")} ${chalk.blueBright("create-discord-app .")}
16+
Examples:
17+
${chalk.gray("$")} ${chalk.blueBright("create-discord-app .")}
18+
${chalk.gray("$")} ${chalk.blueBright("create-discord-app --create --dir=projectDirName")}
1719
`;
1820

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

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

5558
const lang = () => {
5659
let l;
@@ -60,9 +63,6 @@ module.exports = async (args) => {
6063
case "typescript":
6164
l = "node";
6265
break;
63-
case "python":
64-
l = "py";
65-
break;
6666
default:
6767
l = null;
6868
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "create-discord-app",
33
"version": "2.0.0",
4-
"description": "Discord bot project generator.",
4+
"description": "A Simple CLI to generate discord bot projects easily!",
55
"main": "index.js",
66
"preferGlobal": true,
77
"bin": {

src/create.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ class Create {
1212
this.source = source;
1313
}
1414

15+
initGit() {
16+
const commands = ["git init", "git add .", "git commit -m \"initial commit\""];
17+
const finalizingLoader = ora(chalk.blueBright("Finalizing...")).start();
18+
19+
for (const command of commands) {
20+
try {
21+
cp.execSync(this.path === "." ? command : `cd ${this.path} && ${command}`);
22+
} catch(e) { /* Do nothing */ }
23+
}
24+
25+
finalizingLoader.succeed(chalk.greenBright("Successfully created discord bot project!"))
26+
}
27+
1528
async init(token = null, ops = { language: null }) {
1629
if (!this.source) return console.log(symbols.error, chalk.redBright("No source file(s) specified!"));
1730
let path = this.path === "." ? process.cwd() : `${process.cwd()}/${this.path}`;
@@ -28,14 +41,16 @@ class Create {
2841
}
2942

3043
copyFileLoader.succeed(chalk.cyanBright("Finished copying files!"));
31-
const finalizingLoader = ora(chalk.blueBright("Finalizing...")).start();
44+
const depInstaller = ora(chalk.blueBright("Installing dependencies...")).start();
3245

3346
const command = this.getInstallCommand(ops.language);
34-
if (!command) return finalizingLoader.warn(chalk.yellowBright("Generated project but couldn't install dependencies, please try again manually!"));
47+
if (!command) return depInstaller.warn(chalk.yellowBright("Generated project but couldn't install dependencies, please try again manually!"));
48+
49+
cp.exec(this.path === "." ? command : `cd ${this.path} && ${command}`, (error) => {
50+
if (error) return depInstaller.warn(chalk.yellowBright("Generated project but couldn't install dependencies, please try again manually!"));
51+
depInstaller.succeed(chalk.greenBright("Successfully Installed dependencies!"));
3552

36-
cp.exec(command, (error) => {
37-
if (error) return finalizingLoader.warn(chalk.yellowBright("Generated project but couldn't install dependencies, please try again manually!"));
38-
return finalizingLoader.succeed(chalk.greenBright("Successfully created discord bot project!"));
53+
return this.initGit();
3954
});
4055
});
4156
}
@@ -47,9 +62,6 @@ class Create {
4762
case "js":
4863
cmd = "npm i";
4964
break;
50-
case "py":
51-
cmd = "pip3 install -r requirements.txt";
52-
break;
5365
default:
5466
cmd = null;
5567
}

0 commit comments

Comments
 (0)