mirror of
https://github.com/CompeyDev/create-guilded-bot.git
synced 2024-12-12 12:50:35 +00:00
chore: lint & prettier
This commit is contained in:
parent
e459089280
commit
c49e2244d1
4 changed files with 100 additions and 101 deletions
|
@ -4,7 +4,7 @@ module.exports = {
|
||||||
extends: ["custom"],
|
extends: ["custom"],
|
||||||
settings: {
|
settings: {
|
||||||
next: {
|
next: {
|
||||||
rootDir: ["apps/*/"],
|
rootDir: ["packages/*/"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,92 +11,92 @@ import unzip from "unzip-stream";
|
||||||
import validateClient from "../lib/validateClient";
|
import validateClient from "../lib/validateClient";
|
||||||
|
|
||||||
export default function main(shouldInstall: boolean) {
|
export default function main(shouldInstall: boolean) {
|
||||||
const welcomeASCII = getConstant("welcomeMessage");
|
const welcomeASCII = getConstant("welcomeMessage");
|
||||||
console.log(welcomeASCII);
|
console.log(welcomeASCII);
|
||||||
|
|
||||||
inquirer
|
inquirer
|
||||||
.prompt([
|
.prompt([
|
||||||
{
|
{
|
||||||
type: "input",
|
type: "input",
|
||||||
name: "location",
|
name: "location",
|
||||||
message: "Where should the project be initialized?",
|
message: "Where should the project be initialized?",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "list",
|
type: "list",
|
||||||
name: "flavor",
|
name: "flavor",
|
||||||
message: "Which flavor?",
|
message: "Which flavor?",
|
||||||
choices: ["TypeScript", "JavaScript"],
|
choices: ["TypeScript", "JavaScript"],
|
||||||
filter(val) {
|
filter(val) {
|
||||||
return val.toLowerCase();
|
return val.toLowerCase();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
.then((answers) => {
|
.then((answers) => {
|
||||||
validateClient();
|
validateClient();
|
||||||
mkdir(answers.location, (e) => {
|
mkdir(answers.location, (e) => {
|
||||||
if (e && e.code != "EEXIST") {
|
if (e && e.code != "EEXIST") {
|
||||||
logger.error("Failed to create project directory.");
|
logger.error("Failed to create project directory.");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e) {
|
if (e) {
|
||||||
if (e.code == "EEXIST") {
|
if (e.code == "EEXIST") {
|
||||||
readdir(answers.location, (_, files) => {
|
readdir(answers.location, (_, files) => {
|
||||||
if (files.length) {
|
if (files.length) {
|
||||||
logger.error("Directory not empty.");
|
logger.error("Directory not empty.");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let packageManager = getPackageManager();
|
let packageManager = getPackageManager();
|
||||||
|
|
||||||
const start = async (TEMPLATE_DOWNLOAD_URL: string) => {
|
const start = async (TEMPLATE_DOWNLOAD_URL: string) => {
|
||||||
const download = stream(TEMPLATE_DOWNLOAD_URL, { isStream: true }).pipe(
|
const download = stream(TEMPLATE_DOWNLOAD_URL, { isStream: true }).pipe(
|
||||||
createWriteStream(`${answers.location}/create-guilded-bot_ts.zip`)
|
createWriteStream(`${answers.location}/create-guilded-bot_ts.zip`)
|
||||||
);
|
);
|
||||||
download.on("finish", () => {
|
download.on("finish", () => {
|
||||||
fs.createReadStream(`${answers.location}/create-guilded-bot_ts.zip`)
|
fs.createReadStream(`${answers.location}/create-guilded-bot_ts.zip`)
|
||||||
.pipe(unzip.Extract({ path: `${answers.location}` }))
|
.pipe(unzip.Extract({ path: `${answers.location}` }))
|
||||||
.on("finish", () => {
|
.on("finish", () => {
|
||||||
removeSync(`${answers.location}/create-guilded-bot_ts.zip`);
|
removeSync(`${answers.location}/create-guilded-bot_ts.zip`);
|
||||||
logger.success("🚀 Let's get started.");
|
logger.success("🚀 Let's get started.");
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (answers.flavor == "typescript") {
|
|
||||||
const TEMPLATE_DOWNLOAD_URL =
|
|
||||||
"https://files.devcomp.xyz/r/create-guilded-bot_ts.zip";
|
|
||||||
|
|
||||||
start(TEMPLATE_DOWNLOAD_URL).then(() => {
|
|
||||||
if (shouldInstall) {
|
|
||||||
install(
|
|
||||||
packageManager as "npm" | "pnpm" | "yarn" | null,
|
|
||||||
answers.location
|
|
||||||
);
|
|
||||||
} else if (!shouldInstall) {
|
|
||||||
logger.custom(packageManager, "Skipping installation step.")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (answers.flavor == "javascript") {
|
|
||||||
const TEMPLATE_DOWNLOAD_URL =
|
|
||||||
"https://files.devcomp.xyz/r/create-guilded-bot_js.zip";
|
|
||||||
|
|
||||||
start(TEMPLATE_DOWNLOAD_URL).then(() => {
|
|
||||||
if (shouldInstall) {
|
|
||||||
install(
|
|
||||||
packageManager as "npm" | "pnpm" | "yarn" | null,
|
|
||||||
answers.location
|
|
||||||
);
|
|
||||||
} else if (!shouldInstall) {
|
|
||||||
logger.custom(packageManager, "Skipping installation step.")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (answers.flavor == "typescript") {
|
||||||
|
const TEMPLATE_DOWNLOAD_URL =
|
||||||
|
"https://files.devcomp.xyz/r/create-guilded-bot_ts.zip";
|
||||||
|
|
||||||
|
start(TEMPLATE_DOWNLOAD_URL).then(() => {
|
||||||
|
if (shouldInstall) {
|
||||||
|
install(
|
||||||
|
packageManager as "npm" | "pnpm" | "yarn" | null,
|
||||||
|
answers.location
|
||||||
|
);
|
||||||
|
} else if (!shouldInstall) {
|
||||||
|
logger.custom(packageManager, "Skipping installation step.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (answers.flavor == "javascript") {
|
||||||
|
const TEMPLATE_DOWNLOAD_URL =
|
||||||
|
"https://files.devcomp.xyz/r/create-guilded-bot_js.zip";
|
||||||
|
|
||||||
|
start(TEMPLATE_DOWNLOAD_URL).then(() => {
|
||||||
|
if (shouldInstall) {
|
||||||
|
install(
|
||||||
|
packageManager as "npm" | "pnpm" | "yarn" | null,
|
||||||
|
answers.location
|
||||||
|
);
|
||||||
|
} else if (!shouldInstall) {
|
||||||
|
logger.custom(packageManager, "Skipping installation step.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
import getConstant from "../utils/constants";
|
import getConstant from "../utils/constants";
|
||||||
import interactiveClient from "../lib/interactiveClient";
|
import interactiveClient from "../lib/interactiveClient";
|
||||||
import * as logger from "../utils/logger";
|
import * as logger from "../utils/logger";
|
||||||
import * as globals from "../utils/globals"
|
import * as globals from "../utils/globals";
|
||||||
|
|
||||||
|
|
||||||
const args = process.argv.filter((_, i: number) => {
|
const args = process.argv.filter((_, i: number) => {
|
||||||
return i > 1;
|
return i > 1;
|
||||||
|
@ -12,7 +11,6 @@ const args = process.argv.filter((_, i: number) => {
|
||||||
const weclomeASCII = getConstant("welcomeMessage");
|
const weclomeASCII = getConstant("welcomeMessage");
|
||||||
const helpMenu = getConstant("helpMenu");
|
const helpMenu = getConstant("helpMenu");
|
||||||
|
|
||||||
|
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "-h":
|
case "-h":
|
||||||
|
@ -27,8 +25,8 @@ if (args.length > 0) {
|
||||||
break;
|
break;
|
||||||
case "--no-install":
|
case "--no-install":
|
||||||
case "-n":
|
case "-n":
|
||||||
globals.setGlobal("shouldInstall", false)
|
globals.setGlobal("shouldInstall", false);
|
||||||
interactiveClient(false)
|
interactiveClient(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(weclomeASCII);
|
console.log(weclomeASCII);
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
export let globalsStore = { meta: { created: new Date().getDate() + new Date().getTime() } }
|
export let globalsStore = {
|
||||||
|
meta: { created: new Date().getDate() + new Date().getTime() },
|
||||||
|
};
|
||||||
export function setGlobal(global: string, value: any): void {
|
export function setGlobal(global: string, value: any): void {
|
||||||
globalsStore[global] = value
|
globalsStore[global] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGlobal(global: string): any {
|
export function getGlobal(global: string): any {
|
||||||
return globalsStore[global]
|
return globalsStore[global];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function getGlobals(): {} {
|
export function getGlobals(): {} {
|
||||||
return globalsStore
|
return globalsStore;
|
||||||
}
|
}
|
Loading…
Reference in a new issue