-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
84 lines (72 loc) · 2.1 KB
/
init.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const { exec } = require("node:child_process");
const fs = require("node:fs");
const name = process.argv[2];
const description = process.argv.splice(3).join(" ");
if (!name) throw new SyntaxError("Incorrect Usage: `npm run init (One Word Name For Project) (Project Description)`");
if (!description) console.log("\x1b[33mWARNING:", "\x1b[0mNo Description Set\n");
const status = (type, data) => console.log(data ? type + ": " + data : type);
const emptyConsoleLine = () => console.log("");
process.on("exit", () => {
emptyConsoleLine();
status("Completed Initialization");
emptyConsoleLine();
console.log(`Make Sure To:
- \x1b[36mFill README.md
\x1b[0m- \x1b[36mSetup Docs Replacements in \x1b[32mtypedoc.json
\x1b[0m- \x1b[36mWrite \x1b[1mCode \x1b[0m\x1b[36mIn \x1b[32msrc
\x1b[0m- \x1b[36mWrite \x1b[1mTests \x1b[0m\x1b[36mIn \x1b[32mtest
\x1b[0mRun \x1b[32mnpm run ready \x1b[0mwhen you're ready to publish the package`);
emptyConsoleLine();
});
status("Setting Up", "package.json");
const package_json = JSON.parse(fs.readFileSync("./package.json"));
package_json.name = `@djs-user/${name.toLowerCase()}`;
package_json.description = description;
fs.writeFileSync("./package.json", JSON.stringify(package_json));
status("Setting Up", ".gitignore");
fs.writeFileSync(
"./.gitignore",
`dist
node_modules
test
init.js
SETUP.md`
);
status("Setting Up", "TypeDoc Config");
fs.writeFileSync(
"./typedoc.json",
`{
"$schema": "https://typedoc.org/schema.json",
"entryPoints": ["./src"],
"out": "docs",
"name": "Discord.js User | ${name}",
"includeVersion": true,
"readme": "./README.md",
"commentStyle": "all",
"tsconfig": "./tsconfig.json",
"replaceText": {
"inCodeCommentText": true,
"inCodeCommentTags": true,
"inIncludedFiles": true,
"replacements": [
{
"pattern": "testRegex",
"flags": "gi",
"replace": "test regex replacement"
}
]
}
}
`
);
status("Setting Up", "README");
fs.writeFileSync(
"./README.md",
`# Discord.js User | ${name}
${description}`
);
emptyConsoleLine();
status("Completing Initiation", "Readying Data");
exec("npm run ready", err => {
if (err) throw err;
});