mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-02 05:42:20 +02:00
Fix package commands by adding .argument() call
This commit is contained in:
parent
21b52a99a0
commit
afba008363
|
@ -171,7 +171,7 @@ async function navigate(routeName: string, params: any = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchToChannel(channel: ClientChan) {
|
function switchToChannel(channel: ClientChan) {
|
||||||
return void navigate("RoutedChat", {id: channel.id});
|
void navigate("RoutedChat", {id: channel.id});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("serviceWorker" in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import socket from "../socket";
|
||||||
import {switchToChannel, navigate} from "../router";
|
import {switchToChannel, navigate} from "../router";
|
||||||
import {store} from "../store";
|
import {store} from "../store";
|
||||||
|
|
||||||
socket.on("quit", function (data) {
|
socket.on("quit", async function (data) {
|
||||||
// If we're in a channel, and it's on the network that is being removed,
|
// If we're in a channel, and it's on the network that is being removed,
|
||||||
// then open another channel window
|
// then open another channel window
|
||||||
const isCurrentNetworkBeingRemoved =
|
const isCurrentNetworkBeingRemoved =
|
||||||
|
@ -17,6 +17,6 @@ socket.on("quit", function (data) {
|
||||||
if (store.state.networks.length > 0) {
|
if (store.state.networks.length > 0) {
|
||||||
switchToChannel(store.state.networks[0].channels[0]);
|
switchToChannel(store.state.networks[0].channels[0]);
|
||||||
} else {
|
} else {
|
||||||
navigate("Connect");
|
await navigate("Connect");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,9 +9,10 @@ import {Command} from "commander";
|
||||||
const program = new Command("install");
|
const program = new Command("install");
|
||||||
program
|
program
|
||||||
.usage("install <package>")
|
.usage("install <package>")
|
||||||
|
.argument("<package>", "package to install")
|
||||||
.description("Install a theme or a package")
|
.description("Install a theme or a package")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(async function (packageName) {
|
.action(async function (packageName: string) {
|
||||||
const fs = await import("fs");
|
const fs = await import("fs");
|
||||||
const fspromises = fs.promises;
|
const fspromises = fs.promises;
|
||||||
const path = await import("path");
|
const path = await import("path");
|
||||||
|
@ -31,7 +32,7 @@ program
|
||||||
isLocalFile = true;
|
isLocalFile = true;
|
||||||
readFile = fspromises
|
readFile = fspromises
|
||||||
.readFile(path.join(packageName.substr("file:".length), "package.json"), "utf-8")
|
.readFile(path.join(packageName.substr("file:".length), "package.json"), "utf-8")
|
||||||
.then((data) => JSON.parse(data));
|
.then((data) => JSON.parse(data) as typeof packageJson);
|
||||||
} else {
|
} else {
|
||||||
const split = packageName.split("@");
|
const split = packageName.split("@");
|
||||||
packageName = split[0];
|
packageName = split[0];
|
||||||
|
|
|
@ -7,10 +7,13 @@ import Utils from "./utils";
|
||||||
const program = new Command("uninstall");
|
const program = new Command("uninstall");
|
||||||
program
|
program
|
||||||
.usage("uninstall <package>")
|
.usage("uninstall <package>")
|
||||||
|
.argument("<package>", "The package to uninstall")
|
||||||
.description("Uninstall a theme or a package")
|
.description("Uninstall a theme or a package")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function (packageName) {
|
.action(function (packageName: string) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const packagesConfig = path.join(Config.getPackagesPath(), "package.json");
|
const packagesConfig = path.join(Config.getPackagesPath(), "package.json");
|
||||||
|
@ -20,20 +23,22 @@ program
|
||||||
!packages.dependencies ||
|
!packages.dependencies ||
|
||||||
!Object.prototype.hasOwnProperty.call(packages.dependencies, packageName)
|
!Object.prototype.hasOwnProperty.call(packages.dependencies, packageName)
|
||||||
) {
|
) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||||
log.warn(`${colors.green(packageName)} is not installed.`);
|
log.warn(`${colors.green(packageName)} is not installed.`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(`Uninstalling ${colors.green(packageName)}...`);
|
log.info(`Uninstalling ${colors.green(packageName)}...`);
|
||||||
|
|
||||||
return Utils.executeYarnCommand("remove", packageName)
|
try {
|
||||||
.then(() => {
|
void Utils.executeYarnCommand("remove", packageName).then(() => {
|
||||||
log.info(`${colors.green(packageName)} has been successfully uninstalled.`);
|
log.info(`${colors.green(packageName)} has been successfully uninstalled.`);
|
||||||
})
|
|
||||||
.catch((code) => {
|
|
||||||
log.error(`Failed to uninstall ${colors.green(packageName)}. Exit code: ${code}`);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
});
|
||||||
|
} catch (code_1) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||||
|
log.error(`Failed to uninstall ${colors.green(packageName)}. Exit code: ${code_1}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default program;
|
export default program;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import Utils from "./utils";
|
||||||
const program = new Command("upgrade");
|
const program = new Command("upgrade");
|
||||||
program
|
program
|
||||||
.usage("upgrade [packages...]")
|
.usage("upgrade [packages...]")
|
||||||
|
.arguments("[packages...]")
|
||||||
.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) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ program
|
||||||
.description("List all users")
|
.description("List all users")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function () {
|
.action(function () {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const ClientManager = require("../../clientManager");
|
const ClientManager = require("../../clientManager");
|
||||||
const users = new ClientManager().getUsers();
|
const users = new ClientManager().getUsers();
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ program
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const ClientManager = require("../../clientManager");
|
const ClientManager = require("../../clientManager");
|
||||||
const manager = new ClientManager();
|
const manager = new ClientManager();
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ program
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const ClientManager = require("../../clientManager");
|
const ClientManager = require("../../clientManager");
|
||||||
const users = new ClientManager().getUsers();
|
const users = new ClientManager().getUsers();
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import {IrcEventHandler} from "../../client";
|
import {IrcEventHandler} from "../../client";
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ import _ from "lodash";
|
||||||
import {IrcEventHandler} from "../../client";
|
import {IrcEventHandler} from "../../client";
|
||||||
|
|
||||||
import Msg, {MessageType} from "../../models/msg";
|
import Msg, {MessageType} from "../../models/msg";
|
||||||
import User from "../../models/user";
|
|
||||||
|
|
||||||
export default <IrcEventHandler>function (irc, network) {
|
export default <IrcEventHandler>function (irc, network) {
|
||||||
const client = this;
|
const client = this;
|
||||||
|
@ -35,6 +34,7 @@ export default <IrcEventHandler>function (irc, network) {
|
||||||
|
|
||||||
const msg = new Msg({
|
const msg = new Msg({
|
||||||
type: MessageType.MODE_CHANNEL,
|
type: MessageType.MODE_CHANNEL,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||||
text: `${data.raw_modes} ${data.raw_params.join(" ")}`,
|
text: `${data.raw_modes} ${data.raw_params.join(" ")}`,
|
||||||
});
|
});
|
||||||
targetChan.pushMessage(client, msg);
|
targetChan.pushMessage(client, msg);
|
||||||
|
|
|
@ -13,6 +13,7 @@ export default <IrcEventHandler>function (irc, network) {
|
||||||
|
|
||||||
const lobby = network.channels[0];
|
const lobby = network.channels[0];
|
||||||
const msg = new Msg({
|
const msg = new Msg({
|
||||||
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||||
text: `You're now known as ${data.new_nick}`,
|
text: `You're now known as ${data.new_nick}`,
|
||||||
});
|
});
|
||||||
lobby.pushMessage(client, msg, true);
|
lobby.pushMessage(client, msg, true);
|
||||||
|
|
2
src/types/modules/irc-framework.d.ts
vendored
2
src/types/modules/irc-framework.d.ts
vendored
|
@ -1,5 +1,5 @@
|
||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
// @eslint-disable
|
// eslint-disable
|
||||||
|
|
||||||
// https://raw.githubusercontent.com/eternagame/HTML-Chat/vue-rewrite/src/app/types/modules/irc-framework/irc-framework.d.ts
|
// https://raw.githubusercontent.com/eternagame/HTML-Chat/vue-rewrite/src/app/types/modules/irc-framework/irc-framework.d.ts
|
||||||
// TODO: Fix this
|
// TODO: Fix this
|
||||||
|
|
8
src/types/socket-events.d.ts
vendored
8
src/types/socket-events.d.ts
vendored
|
@ -1,6 +1,7 @@
|
||||||
import {ClientNetwork} from "../../client/js/types";
|
import {ClientMessage, ClientNetwork} from "../../client/js/types";
|
||||||
import {Mention} from "../client";
|
import {Mention} from "../client";
|
||||||
import Msg from "../models/msg";
|
import Msg from "../models/msg";
|
||||||
|
import Network from "../models/network";
|
||||||
import {ChangelogData} from "../plugins/changelog";
|
import {ChangelogData} from "../plugins/changelog";
|
||||||
import {ClientConfiguration} from "../server";
|
import {ClientConfiguration} from "../server";
|
||||||
|
|
||||||
|
@ -37,7 +38,6 @@ interface ServerToClientEvents {
|
||||||
"mentions:list": (data: Mention[]) => void;
|
"mentions:list": (data: Mention[]) => void;
|
||||||
|
|
||||||
"setting:new": ({name: string, value: any}) => void;
|
"setting:new": ({name: string, value: any}) => void;
|
||||||
|
|
||||||
"setting:all": (settings: {[key: string]: any}) => void;
|
"setting:all": (settings: {[key: string]: any}) => void;
|
||||||
|
|
||||||
more: ({
|
more: ({
|
||||||
|
@ -61,6 +61,10 @@ interface ServerToClientEvents {
|
||||||
networks: ClientNetwork[];
|
networks: ClientNetwork[];
|
||||||
token: string;
|
token: string;
|
||||||
}) => void;
|
}) => void;
|
||||||
|
|
||||||
|
"search:results": (response: {results: ClientMessage[]}) => void;
|
||||||
|
|
||||||
|
quit: ({network}: {network: string}) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ClientToServerEvents {
|
interface ClientToServerEvents {
|
||||||
|
|
2
test/fixtures/.thelounge/sts-policies.json
vendored
2
test/fixtures/.thelounge/sts-policies.json
vendored
|
@ -3,6 +3,6 @@
|
||||||
"host": "irc.example.com",
|
"host": "irc.example.com",
|
||||||
"port": 7000,
|
"port": 7000,
|
||||||
"duration": 3600,
|
"duration": 3600,
|
||||||
"expires": 1654030206992
|
"expires": 1654030493590
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import {expect} from "chai";
|
import {expect} from "chai";
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import util from "util";
|
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import Network from "../src/models/network";
|
import Network from "../src/models/network";
|
||||||
import Chan from "../src/models/chan";
|
import Chan from "../src/models/chan";
|
||||||
import {EventEmitter} from "events";
|
import {EventEmitter} from "events";
|
||||||
|
import {Message} from "../src/models/msg";
|
||||||
|
|
||||||
class MockClient extends EventEmitter {
|
class MockClient extends EventEmitter {
|
||||||
config: {
|
config: {
|
||||||
|
@ -29,7 +29,7 @@ class MockClient extends EventEmitter {
|
||||||
previews: [],
|
previews: [],
|
||||||
},
|
},
|
||||||
opts
|
opts
|
||||||
);
|
) as Message;
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue