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 fs from "fs/promises";
|
||||
import path from "path";
|
||||
import {Command} from "commander";
|
||||
|
||||
import Config from "../config";
|
||||
import log from "../log";
|
||||
import Utils from "./utils";
|
||||
|
||||
const program = new Command("uninstall");
|
||||
|
@ -10,11 +13,6 @@ program
|
|||
.description("Uninstall a theme or a package")
|
||||
.on("--help", Utils.extraHelp)
|
||||
.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 packages = JSON.parse(fs.readFileSync(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 log from "../log";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import colors from "chalk";
|
||||
import {Command} from "commander";
|
||||
|
||||
import Config from "../config";
|
||||
import log from "../log";
|
||||
import Utils from "./utils";
|
||||
|
||||
const program = new Command("upgrade");
|
||||
|
@ -11,9 +13,6 @@ program
|
|||
.description("Upgrade installed themes and packages to their latest versions")
|
||||
.on("--help", Utils.extraHelp)
|
||||
.action(function (packages) {
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
// Get paths to the location of packages directory
|
||||
const packagesConfig = path.join(Config.getPackagesPath(), "package.json");
|
||||
const packagesList = JSON.parse(fs.readFileSync(packagesConfig, "utf-8")).dependencies;
|
||||
|
|
|
@ -5,6 +5,7 @@ import fs from "fs";
|
|||
import Helper from "../../helper";
|
||||
import Config from "../../config";
|
||||
import Utils from "../utils";
|
||||
import ClientManager from "../../clientManager";
|
||||
|
||||
const program = new Command("add");
|
||||
program
|
||||
|
@ -19,8 +20,6 @@ program
|
|||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const ClientManager = require("../../clientManager").default;
|
||||
const manager = new ClientManager();
|
||||
const users = manager.getUsers();
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import colors from "chalk";
|
|||
import fs from "fs";
|
||||
import Config from "../../config";
|
||||
import Utils from "../utils";
|
||||
import ClientManager from "../../clientManager";
|
||||
|
||||
const program = new Command("edit");
|
||||
program
|
||||
|
@ -17,8 +18,6 @@ program
|
|||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const ClientManager = require("../../clientManager").default;
|
||||
const users = new ClientManager().getUsers();
|
||||
|
||||
if (users === undefined) {
|
||||
|
|
|
@ -2,13 +2,13 @@ import log from "../../log";
|
|||
import colors from "chalk";
|
||||
import {Command} from "commander";
|
||||
import Utils from "../utils";
|
||||
import ClientManager from "../../clientManager";
|
||||
|
||||
const program = new Command("list");
|
||||
program
|
||||
.description("List all users")
|
||||
.on("--help", Utils.extraHelp)
|
||||
.action(async function () {
|
||||
const ClientManager = (await import("../../clientManager")).default;
|
||||
.action(function () {
|
||||
const users = new ClientManager().getUsers();
|
||||
|
||||
if (users === undefined) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import {Command} from "commander";
|
|||
import fs from "fs";
|
||||
import Config from "../../config";
|
||||
import Utils from "../utils";
|
||||
import ClientManager from "../../clientManager";
|
||||
|
||||
const program = new Command("remove");
|
||||
program
|
||||
|
@ -16,8 +17,6 @@ program
|
|||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const ClientManager = require("../../clientManager").default;
|
||||
const manager = new ClientManager();
|
||||
|
||||
try {
|
||||
|
|
|
@ -5,6 +5,7 @@ import fs from "fs";
|
|||
import Helper from "../../helper";
|
||||
import Config from "../../config";
|
||||
import Utils from "../utils";
|
||||
import ClientManager from "../../clientManager";
|
||||
|
||||
const program = new Command("reset");
|
||||
program
|
||||
|
@ -18,8 +19,6 @@ program
|
|||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const ClientManager = require("../../clientManager").default;
|
||||
const users = new ClientManager().getUsers();
|
||||
|
||||
if (users === undefined) {
|
||||
|
@ -52,7 +51,7 @@ program
|
|||
);
|
||||
});
|
||||
|
||||
function change(name, password) {
|
||||
function change(name: string, password: string) {
|
||||
const pathReal = Config.getUserConfigPath(name);
|
||||
const pathTemp = pathReal + ".tmp";
|
||||
const user = JSON.parse(fs.readFileSync(pathReal, "utf-8"));
|
||||
|
|
Loading…
Reference in a new issue