mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-17 04:55:07 +02:00
server/command-line: remove most instances of require
This commit is contained in:
parent
f715c833e7
commit
3caae05114
|
@ -1,7 +1,10 @@
|
||||||
import log from "../log";
|
|
||||||
import colors from "chalk";
|
import colors from "chalk";
|
||||||
|
import fs from "fs/promises";
|
||||||
|
import path from "path";
|
||||||
import {Command} from "commander";
|
import {Command} from "commander";
|
||||||
|
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
|
import log from "../log";
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
|
|
||||||
const program = new Command("uninstall");
|
const program = new Command("uninstall");
|
||||||
|
@ -10,11 +13,6 @@ program
|
||||||
.description("Uninstall a theme or a package")
|
.description("Uninstall a theme or a package")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(async function (packageName: string) {
|
.action(async function (packageName: string) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const fs = require("fs").promises;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
const packagesConfig = path.join(Config.getPackagesPath(), "package.json");
|
const packagesConfig = path.join(Config.getPackagesPath(), "package.json");
|
||||||
// const packages = JSON.parse(fs.readFileSync(packagesConfig, "utf-8"));
|
// const packages = JSON.parse(fs.readFileSync(packagesConfig, "utf-8"));
|
||||||
const packages = JSON.parse(await fs.readFile(packagesConfig, "utf-8"));
|
const packages = JSON.parse(await fs.readFile(packagesConfig, "utf-8"));
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
import fs from "fs";
|
||||||
import log from "../log";
|
import path from "path";
|
||||||
import colors from "chalk";
|
import colors from "chalk";
|
||||||
import {Command} from "commander";
|
import {Command} from "commander";
|
||||||
|
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
|
import log from "../log";
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
|
|
||||||
const program = new Command("upgrade");
|
const program = new Command("upgrade");
|
||||||
|
@ -11,9 +13,6 @@ program
|
||||||
.description("Upgrade installed themes and packages to their latest versions")
|
.description("Upgrade installed themes and packages to their latest versions")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function (packages) {
|
.action(function (packages) {
|
||||||
const fs = require("fs");
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
// Get paths to the location of packages directory
|
// Get paths to the location of packages directory
|
||||||
const packagesConfig = path.join(Config.getPackagesPath(), "package.json");
|
const packagesConfig = path.join(Config.getPackagesPath(), "package.json");
|
||||||
const packagesList = JSON.parse(fs.readFileSync(packagesConfig, "utf-8")).dependencies;
|
const packagesList = JSON.parse(fs.readFileSync(packagesConfig, "utf-8")).dependencies;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import fs from "fs";
|
||||||
import Helper from "../../helper";
|
import Helper from "../../helper";
|
||||||
import Config from "../../config";
|
import Config from "../../config";
|
||||||
import Utils from "../utils";
|
import Utils from "../utils";
|
||||||
|
import ClientManager from "../../clientManager";
|
||||||
|
|
||||||
const program = new Command("add");
|
const program = new Command("add");
|
||||||
program
|
program
|
||||||
|
@ -19,8 +20,6 @@ program
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const ClientManager = require("../../clientManager").default;
|
|
||||||
const manager = new ClientManager();
|
const manager = new ClientManager();
|
||||||
const users = manager.getUsers();
|
const users = manager.getUsers();
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import colors from "chalk";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import Config from "../../config";
|
import Config from "../../config";
|
||||||
import Utils from "../utils";
|
import Utils from "../utils";
|
||||||
|
import ClientManager from "../../clientManager";
|
||||||
|
|
||||||
const program = new Command("edit");
|
const program = new Command("edit");
|
||||||
program
|
program
|
||||||
|
@ -17,8 +18,6 @@ program
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const ClientManager = require("../../clientManager").default;
|
|
||||||
const users = new ClientManager().getUsers();
|
const users = new ClientManager().getUsers();
|
||||||
|
|
||||||
if (users === undefined) {
|
if (users === undefined) {
|
||||||
|
|
|
@ -2,13 +2,13 @@ import log from "../../log";
|
||||||
import colors from "chalk";
|
import colors from "chalk";
|
||||||
import {Command} from "commander";
|
import {Command} from "commander";
|
||||||
import Utils from "../utils";
|
import Utils from "../utils";
|
||||||
|
import ClientManager from "../../clientManager";
|
||||||
|
|
||||||
const program = new Command("list");
|
const program = new Command("list");
|
||||||
program
|
program
|
||||||
.description("List all users")
|
.description("List all users")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(async function () {
|
.action(function () {
|
||||||
const ClientManager = (await import("../../clientManager")).default;
|
|
||||||
const users = new ClientManager().getUsers();
|
const users = new ClientManager().getUsers();
|
||||||
|
|
||||||
if (users === undefined) {
|
if (users === undefined) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {Command} from "commander";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import Config from "../../config";
|
import Config from "../../config";
|
||||||
import Utils from "../utils";
|
import Utils from "../utils";
|
||||||
|
import ClientManager from "../../clientManager";
|
||||||
|
|
||||||
const program = new Command("remove");
|
const program = new Command("remove");
|
||||||
program
|
program
|
||||||
|
@ -16,8 +17,6 @@ program
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const ClientManager = require("../../clientManager").default;
|
|
||||||
const manager = new ClientManager();
|
const manager = new ClientManager();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import fs from "fs";
|
||||||
import Helper from "../../helper";
|
import Helper from "../../helper";
|
||||||
import Config from "../../config";
|
import Config from "../../config";
|
||||||
import Utils from "../utils";
|
import Utils from "../utils";
|
||||||
|
import ClientManager from "../../clientManager";
|
||||||
|
|
||||||
const program = new Command("reset");
|
const program = new Command("reset");
|
||||||
program
|
program
|
||||||
|
@ -18,8 +19,6 @@ program
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const ClientManager = require("../../clientManager").default;
|
|
||||||
const users = new ClientManager().getUsers();
|
const users = new ClientManager().getUsers();
|
||||||
|
|
||||||
if (users === undefined) {
|
if (users === undefined) {
|
||||||
|
@ -52,7 +51,7 @@ program
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
function change(name, password) {
|
function change(name: string, password: string) {
|
||||||
const pathReal = Config.getUserConfigPath(name);
|
const pathReal = Config.getUserConfigPath(name);
|
||||||
const pathTemp = pathReal + ".tmp";
|
const pathTemp = pathReal + ".tmp";
|
||||||
const user = JSON.parse(fs.readFileSync(pathReal, "utf-8"));
|
const user = JSON.parse(fs.readFileSync(pathReal, "utf-8"));
|
||||||
|
|
Loading…
Reference in a new issue