mb-service-linux 2.0.0-dev-20260701-ef3f9ac → 2.0.0

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/CHANGELOG.md CHANGED
@@ -36,6 +36,7 @@ If you like this project and find it useful, please consider giving it a star on
36
36
  - [service]: Check for `package.json` before running package manager `link` and `unlink`.
37
37
  - [service]: Run package manager `link` and `unlink` commands for development links.
38
38
  - [service]: Require root privileges for npm `link` and `unlink` commands on Linux.
39
+ - [service]: Show a `loginctl enable-linger` hint after creating a user-owned service.
39
40
 
40
41
  ### Changed
41
42
 
package/dist/module.js CHANGED
@@ -1,9 +1,25 @@
1
- import { spawnSync } from 'node:child_process';
1
+ import { execFileSync, spawnSync } from 'node:child_process';
2
2
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
3
3
  const HAS_BUN_GLOBAL = typeof Bun !== 'undefined';
4
+ const MB_SERVICE_VERSION = '2.0.0';
4
5
  export function isBun() {
5
6
  return HAS_BUN_GLOBAL || typeof process?.versions?.bun === 'string';
6
7
  }
8
+ export function bunAvailable() {
9
+ if (isBun()) {
10
+ return true;
11
+ }
12
+ const home = process.env.HOME ?? '';
13
+ if (home && existsSync(`${home}/.bun/bin/bun`))
14
+ return true;
15
+ try {
16
+ execFileSync('bun', ['--version'], { stdio: 'ignore' });
17
+ return true;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
7
23
  function isRoot() {
8
24
  return process.getuid?.() === 0;
9
25
  }
@@ -19,6 +35,9 @@ function getServicePath(root) {
19
35
  function getUserServiceDirectory() {
20
36
  return `${process.env.HOME}/.config/systemd/user`;
21
37
  }
38
+ function getDiagnosticUser() {
39
+ return process.env.SUDO_USER ?? process.env.USER ?? 'unknown';
40
+ }
22
41
  function existsServiceFile(root) {
23
42
  return existsSync(getServicePath(root));
24
43
  }
@@ -136,7 +155,16 @@ export function main() {
136
155
  }
137
156
  }
138
157
  function printHelp() {
139
- console.log(`\x1b[90mDetected: isBun=${isBun()} isRoot=${isRoot()} rootServiceFile=${existsServiceFile(true)} userServiceFile=${existsServiceFile(false)}\x1b[0m`);
158
+ console.log(`\x1b[90mEnvironment:\n` +
159
+ ` mb-service version: ${MB_SERVICE_VERSION}\n` +
160
+ ` Runtime: ${isBun() ? 'Bun' : 'Node.js'}\n` +
161
+ ` Node version: ${process.version}${isBun() ? ' (reported by Bun for Node.js compatibility)' : ''}\n` +
162
+ ` Bun available: ${bunAvailable() ? 'yes' : 'no'}\n` +
163
+ ` Bun version: ${process.versions.bun ?? 'not running'}\n` +
164
+ ` Running as root: ${isRoot() ? 'yes' : 'no'}\n` +
165
+ ` Service user: ${getDiagnosticUser()}\n` +
166
+ ` Root service file: ${existsServiceFile(true) ? 'found' : 'not found'}\n` +
167
+ ` User service file: ${existsServiceFile(false) ? 'found' : 'not found'}\x1b[0m`);
140
168
  console.log(`Usage: mb-service [start|stop|restart|logs|status]\n\n` +
141
169
  ` Please provide a command:\n` +
142
170
  ` start start the matterbridge service\n` +
@@ -182,7 +210,7 @@ function createServiceConfig(root) {
182
210
  `StartLimitBurst=5\n` +
183
211
  `[Service]\n` +
184
212
  `Type=simple\n` +
185
- (isBun() ? `ExecStart=%h/.bun/bin/bun --bun %h/.bun/bin/matterbridge --service\n` : `ExecStart=matterbridge --service\n`) +
213
+ (isBun() ? `ExecStart=%h/.bun/bin/bun --bun run %h/.bun/bin/matterbridge --service\n` : `ExecStart=matterbridge --service\n`) +
186
214
  `WorkingDirectory=%h\n` +
187
215
  `StandardOutput=inherit\n` +
188
216
  `StandardError=inherit\n` +
@@ -205,6 +233,9 @@ function createServiceConfig(root) {
205
233
  }
206
234
  writeFileSync(servicePath, root ? rootConfig : userConfig, { mode: 0o644 });
207
235
  console.log(`Service configuration written to ${servicePath} successfully for user ${user}.`);
236
+ if (!root) {
237
+ console.warn(`To keep the user service active after logout, run once: sudo loginctl enable-linger ${user}`);
238
+ }
208
239
  }
209
240
  catch (err) {
210
241
  console.error(`Failed to write service file: ${String(err)}`);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "mb-service-linux",
3
- "version": "2.0.0-dev-20260701-ef3f9ac",
3
+ "version": "2.0.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "mb-service-linux",
9
- "version": "2.0.0-dev-20260701-ef3f9ac",
9
+ "version": "2.0.0",
10
10
  "license": "Apache-2.0",
11
11
  "bin": {
12
12
  "mb-service": "bin/mb-service"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mb-service-linux",
3
- "version": "2.0.0-dev-20260701-ef3f9ac",
3
+ "version": "2.0.0",
4
4
  "description": "Matterbridge service command line interface",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",