-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.js
56 lines (46 loc) · 1.62 KB
/
template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env node
// Usage: npx create-trident-app
const spawn = require("cross-spawn");
const fs = require("fs");
const path = require("path");
const chalk = require("chalk");
// Create a project directory with the project name.
const currentDir = process.cwd();
const projectDir = currentDir;
fs.mkdirSync(projectDir, { recursive: true });
const templateDir = path.resolve(__dirname, "template");
fs.cpSync(templateDir, projectDir, { recursive: true });
const projectPackageJson = require(path.join(projectDir, "package.json"));
// Update the project's package.json with the new project name
projectPackageJson.name = "my-trident-bot";
fs.writeFileSync(
path.join(projectDir, "package.json"),
JSON.stringify(projectPackageJson, null, 2)
);
// Run `npm install` in the project directory to install
// the dependencies. We are using a third-party library
// called `cross-spawn` for cross-platform support.
// (Node has issues spawning child processes in Windows).
spawn.sync("npm", ["install"], { stdio: "inherit" });
console.log(chalk.bold.blue(`Trident.js starter template deployed!`));
console.log(chalk.bold.green(`What's next?`));
console.log(
chalk.default.whiteBright.bold(
"1. Navigate to your .env file and paste in your discord bot token (https://discord.com/developers)"
)
);
console.log(
chalk.default.whiteBright.bold(
"2. Start the bot with npm run start (or node index.js)"
)
);
console.log(
chalk.default.whiteBright.bold(
"3. Add the bot to your server and try out the /ping command"
)
);
console.log(
chalk.default.whiteBright.bold(
"4. Try adding your own commands in the commands folder"
)
);