@lordbex/thelounge 4.4.4-blowfish → 4.5.0-blowfish-pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/defaults/config.js +31 -2
- package/dist/package.json +93 -91
- package/dist/server/client.js +188 -194
- package/dist/server/clientManager.js +65 -63
- package/dist/server/command-line/index.js +44 -43
- package/dist/server/command-line/install.js +37 -70
- package/dist/server/command-line/outdated.js +12 -17
- package/dist/server/command-line/start.js +25 -26
- package/dist/server/command-line/storage.js +26 -31
- package/dist/server/command-line/uninstall.js +16 -23
- package/dist/server/command-line/upgrade.js +20 -26
- package/dist/server/command-line/users/add.js +33 -40
- package/dist/server/command-line/users/edit.js +18 -24
- package/dist/server/command-line/users/index.js +12 -16
- package/dist/server/command-line/users/list.js +11 -39
- package/dist/server/command-line/users/remove.js +16 -22
- package/dist/server/command-line/users/reset.js +34 -35
- package/dist/server/command-line/utils.js +231 -87
- package/dist/server/config.js +61 -52
- package/dist/server/helper.js +29 -28
- package/dist/server/identification.js +39 -34
- package/dist/server/index.js +1 -3
- package/dist/server/log.js +19 -16
- package/dist/server/models/chan.js +36 -33
- package/dist/server/models/msg.js +15 -19
- package/dist/server/models/network.js +88 -86
- package/dist/server/models/prefix.js +4 -7
- package/dist/server/models/user.js +5 -10
- package/dist/server/path-helper.js +8 -0
- package/dist/server/plugins/auth/ldap.js +177 -112
- package/dist/server/plugins/auth/local.js +10 -15
- package/dist/server/plugins/auth.js +6 -35
- package/dist/server/plugins/changelog.js +30 -27
- package/dist/server/plugins/clientCertificate.js +33 -37
- package/dist/server/plugins/dev-server.js +15 -21
- package/dist/server/plugins/inputs/action.js +9 -14
- package/dist/server/plugins/inputs/away.js +1 -3
- package/dist/server/plugins/inputs/ban.js +9 -14
- package/dist/server/plugins/inputs/blow.js +9 -14
- package/dist/server/plugins/inputs/connect.js +5 -10
- package/dist/server/plugins/inputs/ctcp.js +7 -12
- package/dist/server/plugins/inputs/disconnect.js +1 -3
- package/dist/server/plugins/inputs/ignore.js +23 -29
- package/dist/server/plugins/inputs/ignorelist.js +12 -18
- package/dist/server/plugins/inputs/index.js +8 -34
- package/dist/server/plugins/inputs/invite.js +7 -12
- package/dist/server/plugins/inputs/kick.js +7 -12
- package/dist/server/plugins/inputs/kill.js +1 -3
- package/dist/server/plugins/inputs/list.js +1 -3
- package/dist/server/plugins/inputs/mode.js +10 -15
- package/dist/server/plugins/inputs/msg.js +13 -18
- package/dist/server/plugins/inputs/mute.js +9 -15
- package/dist/server/plugins/inputs/nick.js +9 -14
- package/dist/server/plugins/inputs/notice.js +5 -7
- package/dist/server/plugins/inputs/part.js +11 -16
- package/dist/server/plugins/inputs/quit.js +7 -13
- package/dist/server/plugins/inputs/rainbow.js +55 -0
- package/dist/server/plugins/inputs/raw.js +1 -3
- package/dist/server/plugins/inputs/rejoin.js +7 -12
- package/dist/server/plugins/inputs/topic.js +7 -12
- package/dist/server/plugins/inputs/whois.js +1 -3
- package/dist/server/plugins/irc-events/away.js +14 -20
- package/dist/server/plugins/irc-events/cap.js +16 -22
- package/dist/server/plugins/irc-events/chghost.js +14 -13
- package/dist/server/plugins/irc-events/connection.js +61 -63
- package/dist/server/plugins/irc-events/ctcp.js +22 -28
- package/dist/server/plugins/irc-events/error.js +20 -26
- package/dist/server/plugins/irc-events/help.js +7 -13
- package/dist/server/plugins/irc-events/info.js +7 -13
- package/dist/server/plugins/irc-events/invite.js +7 -13
- package/dist/server/plugins/irc-events/join.js +30 -27
- package/dist/server/plugins/irc-events/kick.js +21 -17
- package/dist/server/plugins/irc-events/link.js +75 -96
- package/dist/server/plugins/irc-events/list.js +23 -26
- package/dist/server/plugins/irc-events/message.js +46 -52
- package/dist/server/plugins/irc-events/mode.js +66 -63
- package/dist/server/plugins/irc-events/modelist.js +29 -35
- package/dist/server/plugins/irc-events/motd.js +10 -16
- package/dist/server/plugins/irc-events/names.js +3 -6
- package/dist/server/plugins/irc-events/nick.js +26 -23
- package/dist/server/plugins/irc-events/part.js +19 -15
- package/dist/server/plugins/irc-events/quit.js +17 -14
- package/dist/server/plugins/irc-events/sasl.js +9 -15
- package/dist/server/plugins/irc-events/spgroups.js +38 -0
- package/dist/server/plugins/irc-events/spjoin.js +52 -0
- package/dist/server/plugins/irc-events/topic.js +12 -18
- package/dist/server/plugins/irc-events/unhandled.js +12 -12
- package/dist/server/plugins/irc-events/welcome.js +7 -13
- package/dist/server/plugins/irc-events/whois.js +20 -24
- package/dist/server/plugins/massEventAggregator.js +214 -0
- package/dist/server/plugins/messageStorage/sqlite.js +322 -141
- package/dist/server/plugins/messageStorage/text.js +21 -26
- package/dist/server/plugins/packages/index.js +105 -74
- package/dist/server/plugins/packages/publicClient.js +7 -16
- package/dist/server/plugins/packages/themes.js +11 -16
- package/dist/server/plugins/storage.js +28 -33
- package/dist/server/plugins/sts.js +12 -17
- package/dist/server/plugins/uploader.js +40 -43
- package/dist/server/plugins/webpush.js +23 -51
- package/dist/server/server.js +318 -271
- package/dist/server/storageCleaner.js +29 -37
- package/dist/server/utils/fish.js +7 -14
- package/dist/shared/irc.js +3 -6
- package/dist/shared/linkify.js +7 -14
- package/dist/shared/types/chan.js +6 -9
- package/dist/shared/types/changelog.js +1 -2
- package/dist/shared/types/config.js +1 -2
- package/dist/shared/types/mention.js +1 -2
- package/dist/shared/types/msg.js +3 -5
- package/dist/shared/types/network.js +1 -2
- package/dist/shared/types/storage.js +1 -2
- package/dist/shared/types/user.js +1 -2
- package/index.js +14 -10
- package/package.json +93 -91
- package/public/css/style.css +9 -6
- package/public/css/style.css.map +1 -1
- package/public/fonts/font-awesome/fa-brands-400.ttf +0 -0
- package/public/fonts/font-awesome/fa-brands-400.woff2 +0 -0
- package/public/fonts/font-awesome/fa-duotone-900.ttf +0 -0
- package/public/fonts/font-awesome/fa-duotone-900.woff2 +0 -0
- package/public/fonts/font-awesome/fa-light-300.ttf +0 -0
- package/public/fonts/font-awesome/fa-light-300.woff2 +0 -0
- package/public/fonts/font-awesome/fa-regular-400.ttf +0 -0
- package/public/fonts/font-awesome/fa-regular-400.woff2 +0 -0
- package/public/fonts/font-awesome/fa-solid-900.ttf +0 -0
- package/public/fonts/font-awesome/fa-solid-900.woff2 +0 -0
- package/public/fonts/font-awesome/fa-thin-100.ttf +0 -0
- package/public/fonts/font-awesome/fa-thin-100.woff2 +0 -0
- package/public/fonts/font-awesome/fa-v4compatibility.ttf +0 -0
- package/public/fonts/font-awesome/fa-v4compatibility.woff2 +0 -0
- package/public/js/bundle.js +1 -1
- package/public/js/bundle.js.map +1 -1
- package/public/js/bundle.vendor.js +1 -1
- package/public/js/bundle.vendor.js.LICENSE.txt +24 -6
- package/public/js/bundle.vendor.js.map +1 -1
- package/public/service-worker.js +1 -1
- package/public/themes/default.css +1 -1
- package/public/themes/morning.css +1 -1
- package/dist/webpack.config.js +0 -224
|
@@ -1,64 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const helper_1 = __importDefault(require("../../helper"));
|
|
11
|
-
const config_1 = __importDefault(require("../../config"));
|
|
12
|
-
const utils_1 = __importDefault(require("../utils"));
|
|
13
|
-
const program = new commander_1.Command("reset");
|
|
1
|
+
import log from "../../log.js";
|
|
2
|
+
import colors from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import Helper from "../../helper.js";
|
|
6
|
+
import Config from "../../config.js";
|
|
7
|
+
import Utils from "../utils.js";
|
|
8
|
+
const program = new Command("reset");
|
|
14
9
|
program
|
|
15
10
|
.description("Reset user password")
|
|
16
|
-
.on("--help",
|
|
11
|
+
.on("--help", Utils.extraHelp)
|
|
17
12
|
.argument("<name>", "name of the user")
|
|
18
13
|
.option("--password [password]", "new password, will be prompted if not specified")
|
|
19
|
-
.action(function (name, cmdObj) {
|
|
20
|
-
if (!
|
|
21
|
-
|
|
14
|
+
.action(async function (name, cmdObj) {
|
|
15
|
+
if (!fs.existsSync(Config.getUsersPath())) {
|
|
16
|
+
log.error(`${Config.getUsersPath()} does not exist.`);
|
|
22
17
|
return;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
const ClientManager = require("../../clientManager").default;
|
|
19
|
+
const { default: ClientManager } = await import("../../clientManager.js");
|
|
26
20
|
const users = new ClientManager().getUsers();
|
|
27
21
|
if (users === undefined) {
|
|
28
22
|
// There was an error, already logged
|
|
29
23
|
return;
|
|
30
24
|
}
|
|
31
25
|
if (!users.includes(name)) {
|
|
32
|
-
|
|
26
|
+
log.error(`User ${colors.bold(name)} does not exist.`);
|
|
33
27
|
return;
|
|
34
28
|
}
|
|
35
29
|
if (cmdObj.password) {
|
|
36
30
|
change(name, cmdObj.password);
|
|
37
31
|
return;
|
|
38
32
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
33
|
+
try {
|
|
34
|
+
const password = await log.prompt({
|
|
35
|
+
text: "Enter new password:",
|
|
36
|
+
silent: true,
|
|
37
|
+
});
|
|
46
38
|
change(name, password);
|
|
47
|
-
}
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
log.error("Error during prompt:", String(err));
|
|
42
|
+
}
|
|
48
43
|
});
|
|
49
44
|
function change(name, password) {
|
|
50
|
-
|
|
45
|
+
if (!password) {
|
|
46
|
+
log.error("Password cannot be empty.");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const pathReal = Config.getUserConfigPath(name);
|
|
51
50
|
const pathTemp = pathReal + ".tmp";
|
|
52
|
-
const user = JSON.parse(
|
|
53
|
-
user.password =
|
|
51
|
+
const user = JSON.parse(fs.readFileSync(pathReal, "utf-8"));
|
|
52
|
+
user.password = Helper.password.hash(password);
|
|
54
53
|
user.sessions = {};
|
|
55
54
|
const newUser = JSON.stringify(user, null, "\t");
|
|
56
55
|
// Write to a temp file first, in case the write fails
|
|
57
56
|
// we do not lose the original file (for example when disk is full)
|
|
58
|
-
|
|
57
|
+
fs.writeFileSync(pathTemp, newUser, {
|
|
59
58
|
mode: 0o600,
|
|
60
59
|
});
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
fs.renameSync(pathTemp, pathReal);
|
|
61
|
+
log.info(`Successfully reset password for ${colors.bold(name)}.`);
|
|
63
62
|
}
|
|
64
|
-
|
|
63
|
+
export default program;
|
|
@@ -1,47 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const config_1 = __importDefault(require("../config"));
|
|
12
|
-
const path_1 = __importDefault(require("path"));
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import log from "../log.js";
|
|
3
|
+
import colors from "chalk";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import Helper from "../helper.js";
|
|
6
|
+
import Config from "../config.js";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
import { getDirname } from "../path-helper.js";
|
|
14
11
|
let home;
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
15
13
|
class Utils {
|
|
16
14
|
static extraHelp() {
|
|
17
15
|
[
|
|
18
16
|
"",
|
|
19
17
|
"Environment variable:",
|
|
20
|
-
` THELOUNGE_HOME Path for all configuration files and folders. Defaults to ${
|
|
18
|
+
` THELOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green(Helper.expandHome(Utils.defaultHome()))}`,
|
|
21
19
|
"",
|
|
22
|
-
].forEach((e) =>
|
|
20
|
+
].forEach((e) => log.raw(e));
|
|
23
21
|
}
|
|
24
22
|
static defaultHome() {
|
|
25
23
|
if (home) {
|
|
26
24
|
return home;
|
|
27
25
|
}
|
|
28
26
|
const distConfig = Utils.getFileFromRelativeToRoot(".thelounge_home");
|
|
29
|
-
home =
|
|
27
|
+
home = fs.readFileSync(distConfig, "utf-8").trim();
|
|
30
28
|
return home;
|
|
31
29
|
}
|
|
32
30
|
static getFileFromRelativeToRoot(...fileName) {
|
|
31
|
+
const __dirname = getDirname(import.meta.url);
|
|
33
32
|
// e.g. /thelounge/server/command-line/utils.ts
|
|
34
33
|
if (process.env.NODE_ENV === "test" || process.env.NODE_ENV === "development") {
|
|
35
|
-
return
|
|
34
|
+
return path.resolve(path.join(__dirname, "..", "..", ...fileName));
|
|
36
35
|
}
|
|
37
36
|
// e.g. /thelounge/dist/server/command-line/utils.ts
|
|
38
|
-
return
|
|
37
|
+
return path.resolve(path.join(__dirname, "..", "..", "..", ...fileName));
|
|
39
38
|
}
|
|
40
39
|
// Parses CLI options such as `-c public=true`, `-c debug.raw=true`, etc.
|
|
41
40
|
static parseConfigOptions(val, memo) {
|
|
42
41
|
// Invalid option that is not of format `key=value`, do nothing
|
|
43
42
|
if (!val.includes("=")) {
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
45
43
|
return memo;
|
|
46
44
|
}
|
|
47
45
|
const parseValue = (value) => {
|
|
@@ -82,96 +80,242 @@ class Utils {
|
|
|
82
80
|
const key = val.slice(0, position);
|
|
83
81
|
const value = val.slice(position + 1);
|
|
84
82
|
const parsedValue = parseValue(value);
|
|
85
|
-
if (
|
|
86
|
-
|
|
83
|
+
if (_.has(memo, key)) {
|
|
84
|
+
log.warn(`Configuration key ${colors.bold(key)} was already specified, ignoring...`);
|
|
87
85
|
}
|
|
88
86
|
else {
|
|
89
|
-
memo =
|
|
87
|
+
memo = _.set(memo, key, parsedValue);
|
|
90
88
|
}
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
92
89
|
return memo;
|
|
93
90
|
}
|
|
91
|
+
// Cache for detected package manager
|
|
92
|
+
static #detectedPM = null;
|
|
93
|
+
static #detectPackageManager() {
|
|
94
|
+
if (this.#detectedPM) {
|
|
95
|
+
return this.#detectedPM;
|
|
96
|
+
}
|
|
97
|
+
// Try to find yarn first (check version)
|
|
98
|
+
try {
|
|
99
|
+
const yarnVersion = require("child_process")
|
|
100
|
+
.execSync("yarn --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] })
|
|
101
|
+
.trim();
|
|
102
|
+
if (yarnVersion.startsWith("1.")) {
|
|
103
|
+
log.debug(`Detected Yarn Classic v${yarnVersion}`);
|
|
104
|
+
this.#detectedPM = { name: "yarn1" };
|
|
105
|
+
return this.#detectedPM;
|
|
106
|
+
}
|
|
107
|
+
else if (yarnVersion.startsWith("4.") ||
|
|
108
|
+
yarnVersion.startsWith("3.") ||
|
|
109
|
+
yarnVersion.startsWith("2.")) {
|
|
110
|
+
log.debug(`Detected Yarn Berry v${yarnVersion}`);
|
|
111
|
+
this.#detectedPM = { name: "yarn4" };
|
|
112
|
+
return this.#detectedPM;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// Yarn not available
|
|
117
|
+
}
|
|
118
|
+
// Try npm (bundled with Node.js, should always be available)
|
|
119
|
+
try {
|
|
120
|
+
const npmVersion = require("child_process")
|
|
121
|
+
.execSync("npm --version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] })
|
|
122
|
+
.trim();
|
|
123
|
+
log.debug(`Detected npm v${npmVersion}`);
|
|
124
|
+
this.#detectedPM = { name: "npm" };
|
|
125
|
+
return this.#detectedPM;
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// npm not available
|
|
129
|
+
}
|
|
130
|
+
// Default to npm and hope for the best
|
|
131
|
+
log.warn("Could not detect package manager, defaulting to npm");
|
|
132
|
+
this.#detectedPM = { name: "npm" };
|
|
133
|
+
return this.#detectedPM;
|
|
134
|
+
}
|
|
94
135
|
static executeYarnCommand(command, ...parameters) {
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
"--json",
|
|
104
|
-
"--ignore-scripts",
|
|
105
|
-
"--non-interactive",
|
|
106
|
-
];
|
|
136
|
+
const packagesPath = Config.getPackagesPath();
|
|
137
|
+
const cachePath = path.join(packagesPath, "package_manager_cache");
|
|
138
|
+
// Ensure directories exist
|
|
139
|
+
fs.mkdirSync(cachePath, { recursive: true });
|
|
140
|
+
fs.mkdirSync(path.join(packagesPath, "node_modules"), { recursive: true });
|
|
141
|
+
const pm = this.#detectPackageManager();
|
|
142
|
+
let executable;
|
|
143
|
+
let args;
|
|
107
144
|
const env = {
|
|
108
|
-
|
|
145
|
+
...process.env,
|
|
109
146
|
NODE_ENV: "production",
|
|
110
|
-
// If The Lounge runs from a user that does not have a home directory,
|
|
111
|
-
// yarn may fail when it tries to read certain folders,
|
|
112
|
-
// we give it an existing folder so the reads do not throw a permission error.
|
|
113
|
-
// Yarn uses os.homedir() to figure out the path, which internally reads
|
|
114
|
-
// from the $HOME env on unix. On Windows it uses $USERPROFILE, but
|
|
115
|
-
// the user folder should always exist on Windows, so we don't set it.
|
|
116
147
|
HOME: cachePath,
|
|
117
148
|
};
|
|
149
|
+
if (pm.name === "npm") {
|
|
150
|
+
executable = "npm";
|
|
151
|
+
args = this.#buildNpmArgs(command, parameters, packagesPath, cachePath);
|
|
152
|
+
}
|
|
153
|
+
else if (pm.name === "yarn1") {
|
|
154
|
+
executable = "yarn";
|
|
155
|
+
args = this.#buildYarn1Args(command, parameters, packagesPath, cachePath);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// yarn4/berry
|
|
159
|
+
executable = "yarn";
|
|
160
|
+
args = this.#buildYarn4Args(command, parameters, packagesPath);
|
|
161
|
+
}
|
|
118
162
|
return new Promise((resolve, reject) => {
|
|
119
163
|
let success = false;
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
164
|
+
const isOutdated = command === "outdated";
|
|
165
|
+
log.debug(`Running: ${executable} ${args.join(" ")}`);
|
|
166
|
+
const proc = spawn(executable, args, {
|
|
167
|
+
env: env,
|
|
168
|
+
shell: true,
|
|
169
|
+
cwd: pm.name === "yarn4" ? packagesPath : undefined,
|
|
170
|
+
});
|
|
171
|
+
proc.stdout.on("data", (data) => {
|
|
172
|
+
const output = data.toString().trim();
|
|
173
|
+
if (output) {
|
|
174
|
+
// For yarn1 JSON output, check for success type
|
|
175
|
+
if (pm.name === "yarn1") {
|
|
176
|
+
try {
|
|
177
|
+
const lines = output.split("\n");
|
|
178
|
+
for (const line of lines) {
|
|
179
|
+
const json = JSON.parse(line);
|
|
180
|
+
if (json.type === "success") {
|
|
181
|
+
success = true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// Not JSON, just log it
|
|
130
187
|
}
|
|
131
188
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
// big package trees, for example in the upgrade command
|
|
135
|
-
// See https://github.com/thelounge/thelounge/issues/3679
|
|
136
|
-
}
|
|
137
|
-
});
|
|
189
|
+
log.debug(output);
|
|
190
|
+
}
|
|
138
191
|
});
|
|
139
|
-
|
|
140
|
-
data.toString()
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
log_1.default.error(json.data);
|
|
149
|
-
break;
|
|
150
|
-
case "warning":
|
|
151
|
-
// this includes pointless things like "ignored scripts due to flag"
|
|
152
|
-
// so let's hide it
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
return;
|
|
192
|
+
proc.stderr.on("data", (data) => {
|
|
193
|
+
const output = data.toString().trim();
|
|
194
|
+
if (output) {
|
|
195
|
+
// Filter out noise
|
|
196
|
+
if (output.includes("WARN") || output.includes("warning")) {
|
|
197
|
+
log.debug(output);
|
|
198
|
+
}
|
|
199
|
+
else if (output.includes("ERR!") || output.includes("error")) {
|
|
200
|
+
log.error(output);
|
|
156
201
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
// as it includes things like deprecation warnings, but we might want to know as developers
|
|
202
|
+
else {
|
|
203
|
+
log.debug(output);
|
|
160
204
|
}
|
|
161
|
-
|
|
162
|
-
});
|
|
205
|
+
}
|
|
163
206
|
});
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
207
|
+
proc.on("error", (e) => {
|
|
208
|
+
log.error(`${e.message}:`, e.stack || "");
|
|
209
|
+
reject(new Error(e.message));
|
|
167
210
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
211
|
+
proc.on("close", (code) => {
|
|
212
|
+
// Handle exit codes
|
|
213
|
+
if (code === 0) {
|
|
214
|
+
success = true;
|
|
215
|
+
}
|
|
216
|
+
else if (isOutdated && code === 1) {
|
|
217
|
+
// outdated commands return 1 when packages are outdated
|
|
218
|
+
success = true;
|
|
219
|
+
}
|
|
220
|
+
if (!success) {
|
|
221
|
+
return reject(new Error(`Process exited with code ${code}`));
|
|
171
222
|
}
|
|
172
223
|
resolve(true);
|
|
173
224
|
});
|
|
174
225
|
});
|
|
175
226
|
}
|
|
227
|
+
static #buildNpmArgs(command, parameters, packagesPath, cachePath) {
|
|
228
|
+
let npmCommand = command;
|
|
229
|
+
const args = [];
|
|
230
|
+
switch (command) {
|
|
231
|
+
case "add":
|
|
232
|
+
npmCommand = "install";
|
|
233
|
+
for (const param of parameters) {
|
|
234
|
+
if (param === "--exact") {
|
|
235
|
+
args.push("--save-exact");
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
args.push(param);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
break;
|
|
242
|
+
case "remove":
|
|
243
|
+
npmCommand = "uninstall";
|
|
244
|
+
args.push(...parameters);
|
|
245
|
+
break;
|
|
246
|
+
case "upgrade":
|
|
247
|
+
npmCommand = "update";
|
|
248
|
+
args.push(...parameters);
|
|
249
|
+
break;
|
|
250
|
+
default:
|
|
251
|
+
args.push(...parameters);
|
|
252
|
+
}
|
|
253
|
+
return [
|
|
254
|
+
npmCommand,
|
|
255
|
+
"--prefix",
|
|
256
|
+
packagesPath,
|
|
257
|
+
"--cache",
|
|
258
|
+
cachePath,
|
|
259
|
+
"--ignore-scripts",
|
|
260
|
+
...args,
|
|
261
|
+
];
|
|
262
|
+
}
|
|
263
|
+
static #buildYarn1Args(command, parameters, packagesPath, cachePath) {
|
|
264
|
+
const args = [
|
|
265
|
+
command,
|
|
266
|
+
"--cache-folder",
|
|
267
|
+
cachePath,
|
|
268
|
+
"--cwd",
|
|
269
|
+
packagesPath,
|
|
270
|
+
"--json",
|
|
271
|
+
"--ignore-scripts",
|
|
272
|
+
"--non-interactive",
|
|
273
|
+
...parameters,
|
|
274
|
+
];
|
|
275
|
+
return args;
|
|
276
|
+
}
|
|
277
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
278
|
+
static #buildYarn4Args(command, parameters, packagesPath) {
|
|
279
|
+
// Yarn 4 (Berry) has different syntax
|
|
280
|
+
// It uses the cwd option via process.cwd() or --cwd flag
|
|
281
|
+
let yarnCommand = command;
|
|
282
|
+
const args = [];
|
|
283
|
+
switch (command) {
|
|
284
|
+
case "add":
|
|
285
|
+
yarnCommand = "add";
|
|
286
|
+
for (const param of parameters) {
|
|
287
|
+
if (param === "--exact") {
|
|
288
|
+
args.push("--exact");
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
args.push(param);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
case "remove":
|
|
296
|
+
yarnCommand = "remove";
|
|
297
|
+
args.push(...parameters);
|
|
298
|
+
break;
|
|
299
|
+
case "upgrade":
|
|
300
|
+
yarnCommand = "up";
|
|
301
|
+
args.push(...parameters);
|
|
302
|
+
break;
|
|
303
|
+
case "outdated":
|
|
304
|
+
// Yarn 4 has yarn npm audit but no direct outdated equivalent
|
|
305
|
+
// Use yarn info to check versions - but for simplicity just return success
|
|
306
|
+
// The outdated check is not critical functionality
|
|
307
|
+
yarnCommand = "info";
|
|
308
|
+
args.push("--name-only");
|
|
309
|
+
break;
|
|
310
|
+
case "install":
|
|
311
|
+
yarnCommand = "install";
|
|
312
|
+
args.push(...parameters);
|
|
313
|
+
break;
|
|
314
|
+
default:
|
|
315
|
+
args.push(...parameters);
|
|
316
|
+
}
|
|
317
|
+
// Yarn 4 uses mode flag instead of ignore-scripts
|
|
318
|
+
return [yarnCommand, "--mode=skip-build", ...args];
|
|
319
|
+
}
|
|
176
320
|
}
|
|
177
|
-
|
|
321
|
+
export default Utils;
|