@lordbex/thelounge 4.4.3-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.
Files changed (141) hide show
  1. package/README.md +31 -7
  2. package/dist/defaults/config.js +31 -2
  3. package/dist/package.json +94 -91
  4. package/dist/server/client.js +188 -194
  5. package/dist/server/clientManager.js +75 -72
  6. package/dist/server/command-line/index.js +44 -43
  7. package/dist/server/command-line/install.js +37 -70
  8. package/dist/server/command-line/outdated.js +12 -17
  9. package/dist/server/command-line/start.js +25 -26
  10. package/dist/server/command-line/storage.js +26 -31
  11. package/dist/server/command-line/uninstall.js +16 -23
  12. package/dist/server/command-line/upgrade.js +20 -26
  13. package/dist/server/command-line/users/add.js +33 -40
  14. package/dist/server/command-line/users/edit.js +18 -24
  15. package/dist/server/command-line/users/index.js +12 -16
  16. package/dist/server/command-line/users/list.js +11 -39
  17. package/dist/server/command-line/users/remove.js +16 -22
  18. package/dist/server/command-line/users/reset.js +34 -35
  19. package/dist/server/command-line/utils.js +231 -87
  20. package/dist/server/config.js +61 -52
  21. package/dist/server/helper.js +29 -28
  22. package/dist/server/identification.js +39 -34
  23. package/dist/server/index.js +1 -3
  24. package/dist/server/log.js +19 -16
  25. package/dist/server/models/chan.js +36 -33
  26. package/dist/server/models/msg.js +15 -19
  27. package/dist/server/models/network.js +102 -104
  28. package/dist/server/models/prefix.js +4 -7
  29. package/dist/server/models/user.js +5 -10
  30. package/dist/server/path-helper.js +8 -0
  31. package/dist/server/plugins/auth/ldap.js +177 -112
  32. package/dist/server/plugins/auth/local.js +10 -15
  33. package/dist/server/plugins/auth.js +6 -35
  34. package/dist/server/plugins/changelog.js +30 -27
  35. package/dist/server/plugins/clientCertificate.js +33 -37
  36. package/dist/server/plugins/dev-server.js +15 -21
  37. package/dist/server/plugins/inputs/action.js +9 -14
  38. package/dist/server/plugins/inputs/away.js +1 -3
  39. package/dist/server/plugins/inputs/ban.js +9 -14
  40. package/dist/server/plugins/inputs/blow.js +9 -14
  41. package/dist/server/plugins/inputs/connect.js +5 -10
  42. package/dist/server/plugins/inputs/ctcp.js +7 -12
  43. package/dist/server/plugins/inputs/disconnect.js +1 -3
  44. package/dist/server/plugins/inputs/ignore.js +23 -29
  45. package/dist/server/plugins/inputs/ignorelist.js +12 -18
  46. package/dist/server/plugins/inputs/index.js +8 -34
  47. package/dist/server/plugins/inputs/invite.js +7 -12
  48. package/dist/server/plugins/inputs/kick.js +7 -12
  49. package/dist/server/plugins/inputs/kill.js +1 -3
  50. package/dist/server/plugins/inputs/list.js +1 -3
  51. package/dist/server/plugins/inputs/mode.js +10 -15
  52. package/dist/server/plugins/inputs/msg.js +13 -18
  53. package/dist/server/plugins/inputs/mute.js +9 -15
  54. package/dist/server/plugins/inputs/nick.js +9 -14
  55. package/dist/server/plugins/inputs/notice.js +5 -7
  56. package/dist/server/plugins/inputs/part.js +11 -16
  57. package/dist/server/plugins/inputs/quit.js +7 -13
  58. package/dist/server/plugins/inputs/rainbow.js +55 -0
  59. package/dist/server/plugins/inputs/raw.js +1 -3
  60. package/dist/server/plugins/inputs/rejoin.js +7 -12
  61. package/dist/server/plugins/inputs/topic.js +7 -12
  62. package/dist/server/plugins/inputs/whois.js +1 -3
  63. package/dist/server/plugins/irc-events/away.js +14 -20
  64. package/dist/server/plugins/irc-events/cap.js +16 -22
  65. package/dist/server/plugins/irc-events/chghost.js +14 -13
  66. package/dist/server/plugins/irc-events/connection.js +61 -63
  67. package/dist/server/plugins/irc-events/ctcp.js +22 -28
  68. package/dist/server/plugins/irc-events/error.js +20 -26
  69. package/dist/server/plugins/irc-events/help.js +7 -13
  70. package/dist/server/plugins/irc-events/info.js +7 -13
  71. package/dist/server/plugins/irc-events/invite.js +7 -13
  72. package/dist/server/plugins/irc-events/join.js +30 -27
  73. package/dist/server/plugins/irc-events/kick.js +21 -17
  74. package/dist/server/plugins/irc-events/link.js +122 -109
  75. package/dist/server/plugins/irc-events/list.js +23 -26
  76. package/dist/server/plugins/irc-events/message.js +46 -52
  77. package/dist/server/plugins/irc-events/mode.js +66 -63
  78. package/dist/server/plugins/irc-events/modelist.js +29 -35
  79. package/dist/server/plugins/irc-events/motd.js +10 -16
  80. package/dist/server/plugins/irc-events/names.js +3 -6
  81. package/dist/server/plugins/irc-events/nick.js +26 -23
  82. package/dist/server/plugins/irc-events/part.js +19 -15
  83. package/dist/server/plugins/irc-events/quit.js +17 -14
  84. package/dist/server/plugins/irc-events/sasl.js +9 -15
  85. package/dist/server/plugins/irc-events/spgroups.js +38 -0
  86. package/dist/server/plugins/irc-events/spjoin.js +52 -0
  87. package/dist/server/plugins/irc-events/topic.js +12 -18
  88. package/dist/server/plugins/irc-events/unhandled.js +12 -12
  89. package/dist/server/plugins/irc-events/welcome.js +7 -13
  90. package/dist/server/plugins/irc-events/whois.js +20 -24
  91. package/dist/server/plugins/massEventAggregator.js +214 -0
  92. package/dist/server/plugins/messageStorage/sqlite.js +322 -141
  93. package/dist/server/plugins/messageStorage/text.js +21 -26
  94. package/dist/server/plugins/packages/index.js +105 -74
  95. package/dist/server/plugins/packages/publicClient.js +7 -16
  96. package/dist/server/plugins/packages/themes.js +11 -16
  97. package/dist/server/plugins/storage.js +28 -33
  98. package/dist/server/plugins/sts.js +12 -17
  99. package/dist/server/plugins/uploader.js +40 -43
  100. package/dist/server/plugins/webpush.js +23 -51
  101. package/dist/server/server.js +318 -271
  102. package/dist/server/storageCleaner.js +29 -37
  103. package/dist/server/utils/fish.js +349 -389
  104. package/dist/shared/irc.js +3 -6
  105. package/dist/shared/linkify.js +7 -14
  106. package/dist/shared/types/chan.js +6 -9
  107. package/dist/shared/types/changelog.js +1 -2
  108. package/dist/shared/types/config.js +1 -2
  109. package/dist/shared/types/mention.js +1 -2
  110. package/dist/shared/types/msg.js +3 -5
  111. package/dist/shared/types/network.js +1 -2
  112. package/dist/shared/types/storage.js +1 -2
  113. package/dist/shared/types/user.js +1 -2
  114. package/index.js +14 -10
  115. package/package.json +94 -91
  116. package/public/css/style.css +9 -6
  117. package/public/css/style.css.map +1 -1
  118. package/public/fonts/font-awesome/fa-brands-400.ttf +0 -0
  119. package/public/fonts/font-awesome/fa-brands-400.woff2 +0 -0
  120. package/public/fonts/font-awesome/fa-duotone-900.ttf +0 -0
  121. package/public/fonts/font-awesome/fa-duotone-900.woff2 +0 -0
  122. package/public/fonts/font-awesome/fa-light-300.ttf +0 -0
  123. package/public/fonts/font-awesome/fa-light-300.woff2 +0 -0
  124. package/public/fonts/font-awesome/fa-regular-400.ttf +0 -0
  125. package/public/fonts/font-awesome/fa-regular-400.woff2 +0 -0
  126. package/public/fonts/font-awesome/fa-solid-900.ttf +0 -0
  127. package/public/fonts/font-awesome/fa-solid-900.woff2 +0 -0
  128. package/public/fonts/font-awesome/fa-thin-100.ttf +0 -0
  129. package/public/fonts/font-awesome/fa-thin-100.woff2 +0 -0
  130. package/public/fonts/font-awesome/fa-v4compatibility.ttf +0 -0
  131. package/public/fonts/font-awesome/fa-v4compatibility.woff2 +0 -0
  132. package/public/js/bundle.js +1 -1
  133. package/public/js/bundle.js.map +1 -1
  134. package/public/js/bundle.vendor.js +1 -1
  135. package/public/js/bundle.vendor.js.LICENSE.txt +24 -6
  136. package/public/js/bundle.vendor.js.map +1 -1
  137. package/public/js/loading-error-handlers.js +1 -1
  138. package/public/service-worker.js +1 -1
  139. package/public/themes/default.css +1 -1
  140. package/public/themes/morning.css +1 -1
  141. package/dist/webpack.config.js +0 -224
@@ -1,64 +1,63 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const log_1 = __importDefault(require("../../log"));
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const commander_1 = require("commander");
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", utils_1.default.extraHelp)
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 (!fs_1.default.existsSync(config_1.default.getUsersPath())) {
21
- log_1.default.error(`${config_1.default.getUsersPath()} does not exist.`);
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
- // eslint-disable-next-line @typescript-eslint/no-var-requires
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
- log_1.default.error(`User ${chalk_1.default.bold(name)} does not exist.`);
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
- log_1.default.prompt({
40
- text: "Enter new password:",
41
- silent: true,
42
- }, function (err, password) {
43
- if (err) {
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
- const pathReal = config_1.default.getUserConfigPath(name);
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(fs_1.default.readFileSync(pathReal, "utf-8"));
53
- user.password = helper_1.default.password.hash(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
- fs_1.default.writeFileSync(pathTemp, newUser, {
57
+ fs.writeFileSync(pathTemp, newUser, {
59
58
  mode: 0o600,
60
59
  });
61
- fs_1.default.renameSync(pathTemp, pathReal);
62
- log_1.default.info(`Successfully reset password for ${chalk_1.default.bold(name)}.`);
60
+ fs.renameSync(pathTemp, pathReal);
61
+ log.info(`Successfully reset password for ${colors.bold(name)}.`);
63
62
  }
64
- exports.default = program;
63
+ export default program;
@@ -1,47 +1,45 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const lodash_1 = __importDefault(require("lodash"));
7
- const log_1 = __importDefault(require("../log"));
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const fs_1 = __importDefault(require("fs"));
10
- const helper_1 = __importDefault(require("../helper"));
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 ${chalk_1.default.green(helper_1.default.expandHome(Utils.defaultHome()))}`,
18
+ ` THELOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green(Helper.expandHome(Utils.defaultHome()))}`,
21
19
  "",
22
- ].forEach((e) => log_1.default.raw(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 = fs_1.default.readFileSync(distConfig, "utf-8").trim();
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 path_1.default.resolve(path_1.default.join(__dirname, "..", "..", ...fileName));
34
+ return path.resolve(path.join(__dirname, "..", "..", ...fileName));
36
35
  }
37
36
  // e.g. /thelounge/dist/server/command-line/utils.ts
38
- return path_1.default.resolve(path_1.default.join(__dirname, "..", "..", "..", ...fileName));
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 (lodash_1.default.has(memo, key)) {
86
- log_1.default.warn(`Configuration key ${chalk_1.default.bold(key)} was already specified, ignoring...`);
83
+ if (_.has(memo, key)) {
84
+ log.warn(`Configuration key ${colors.bold(key)} was already specified, ignoring...`);
87
85
  }
88
86
  else {
89
- memo = lodash_1.default.set(memo, key, parsedValue);
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 yarn = require.resolve("yarn/bin/yarn.js");
96
- const packagesPath = config_1.default.getPackagesPath();
97
- const cachePath = path_1.default.join(packagesPath, "package_manager_cache");
98
- const staticParameters = [
99
- "--cache-folder",
100
- cachePath,
101
- "--cwd",
102
- packagesPath,
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
- // We only ever operate in production mode
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 add = (0, child_process_1.spawn)(process.execPath, [yarn, command, ...staticParameters, ...parameters], { env: env });
121
- add.stdout.on("data", (data) => {
122
- data.toString()
123
- .trim()
124
- .split("\n")
125
- .forEach((line) => {
126
- try {
127
- const json = JSON.parse(line);
128
- if (json.type === "success") {
129
- success = true;
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
- catch (e) {
133
- // Stdout buffer has limitations and yarn may print
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
- add.stderr.on("data", (data) => {
140
- data.toString()
141
- .trim()
142
- .split("\n")
143
- .forEach((line) => {
144
- try {
145
- const json = JSON.parse(line);
146
- switch (json.type) {
147
- case "error":
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
- catch (e) {
158
- // we simply fall through and log at debug... chances are there's nothing the user can do about it
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
- log_1.default.debug(line);
162
- });
205
+ }
163
206
  });
164
- add.on("error", (e) => {
165
- log_1.default.error(`${e.message}:`, e.stack || "");
166
- process.exit(1);
207
+ proc.on("error", (e) => {
208
+ log.error(`${e.message}:`, e.stack || "");
209
+ reject(new Error(e.message));
167
210
  });
168
- add.on("close", (code) => {
169
- if (!success || code !== 0) {
170
- return reject(code);
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
- exports.default = Utils;
321
+ export default Utils;