ubuntu-service 1.0.0 → 3.1.1

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/LICENSE CHANGED
@@ -1,15 +1,15 @@
1
- ISC License
2
-
3
- Copyright (c) 2026 KeshavSoft
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1
+ ISC License
2
+
3
+ Copyright (c) 2026 KeshavSoft
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,117 +1,129 @@
1
- # ubuntu-service
2
-
3
- [![npm version](https://img.shields.io/badge/npm-v1.0.0-blue.svg)](https://www.npmjs.com/package/ubuntu-service)
4
- [![License: ISC](https://img.shields.io/badge/License-ISC-green.svg)](https://opensource.org/licenses/ISC)
5
- [![Organization](https://img.shields.io/badge/org-KeshavSoft-purple.svg)](https://github.com/keshavsoft)
6
- [![Node](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org)
7
- [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-success.svg)](https://github.com/keshavsoft/ubuntu-service)
8
-
9
- > **Context-aware single service manager for Ubuntu VPS.**
10
- > Automatically identifies the systemd service associated with your current working directory (`process.cwd()`), inspects its status, restarts it, and displays its logs. Zero memory needed—run right after `git pull`.
11
-
12
- ---
13
-
14
- ## 🎯 The Philosophy: Singular vs. Plural
15
-
16
- | Repository | Focus | Scope | Question Answered |
17
- | :--- | :--- | :--- | :--- |
18
- | **`ubuntu-services`** *(Plural)* | Fleet / Inventory | All services on the OS | *"What is everything running on my Ubuntu VPS? Are there broken folders?"* |
19
- | **`ubuntu-service`** *(Singular)* | Atomic / Current App | Single service for current directory | *"What service runs THIS folder, and let me restart only this service right now."* |
20
-
21
- ---
22
-
23
- ## 💡 The Everyday VPS Problem
24
-
25
- When deploying code on an Ubuntu server:
26
- ```bash
27
- root@server6358:~/KeshavSoft/appointment-notifier# git pull
28
- Updating cced23f..34bc3e5
29
- Fast-forward
30
- ...
31
- ```
32
-
33
- Now you need to restart the application. But:
34
- * *What is the exact systemd unit name for this directory?*
35
- * Is it `appointment.service`? `appointment-notifier.service`? `appointment.keshavsoft.com.service`?
36
- * Instead of grepping `/etc/systemd/system/` or rebooting the server:
37
-
38
- Simply run:
39
- ```bash
40
- us restart
41
- ```
42
-
43
- ---
44
-
45
- ## ⚡ Quick Start
46
-
47
- Run directly with zero installation via `npx`:
48
-
49
- ```bash
50
- # Stand in any project directory on your Ubuntu VPS
51
- cd /root/KeshavSoft/appointment-notifier
52
-
53
- # 1. Inspect the service running this directory
54
- npx ubuntu-service
55
- # Or with short alias:
56
- us
57
-
58
- # 2. Restart ONLY this service
59
- us restart
60
-
61
- # 3. View live systemd logs
62
- us logs -n 50
63
-
64
- # 4. Output only the unit name (e.g. for scripts or CI)
65
- us name
66
- ```
67
-
68
- ---
69
-
70
- ## 📖 CLI Commands
71
-
72
- | Command | Description |
73
- | :--- | :--- |
74
- | `us` / `npx ubuntu-service` | Shows service card: unit name, state, PID, memory, port, working directory |
75
- | `us restart` | Restarts only the service attached to the current directory and verifies status |
76
- | `us status` | Detailed status inspection for the current service |
77
- | `us logs [-n <count>]` | Fetches live `journalctl` logs for this specific service |
78
- | `us name` | Prints only the unit name (e.g. `appointment.keshavsoft.com.service`) |
79
- | `us port` | Prints only the detected port (e.g. `3000`) |
80
-
81
- ### Flags & Options
82
-
83
- * `--dir <path>`: Target a specific folder instead of `process.cwd()`
84
- * `--systemd-dir <path>`: Custom systemd directory (useful for testing)
85
- * `-n, --lines <count>`: Number of log lines to retrieve (default: 25)
86
- * `--json`: Output machine-readable JSON
87
- * `-h, --help`: Display help screen
88
-
89
- ---
90
-
91
- ## 🏗️ Architecture
92
-
93
- ```text
94
- ubuntu-service/
95
- ├── bin/
96
- │ └── index.js # Executable entrypoint (`ubuntu-service`, `us`)
97
- ├── src/
98
- │ ├── index.js # Orchestrator (delegates to latest v1)
99
- │ ├── cli.js # CLI Orchestrator
100
- │ └── v1/
101
- │ ├── index.js # Public API exports
102
- │ ├── detector.js # Context detection (CWD to systemd unit mapping)
103
- │ ├── parser.js # Systemd .service INI & port parser
104
- │ ├── systemctl.js # Native systemctl & journalctl execution
105
- │ ├── actions.js # Business actions (inspect, restart, logs)
106
- │ └── cli.js # Terminal UI & formatting
107
- ├── test/ # Automated test suite (node --test)
108
- ├── docs/ # GitHub Pages portal & live terminal simulator
109
- ├── package.json # Whitelisted files: ["bin", "src"], zero dependencies
110
- └── LICENSE # ISC License
111
- ```
112
-
113
- ---
114
-
115
- ## 🛡️ License
116
-
117
- ISC License — [KeshavSoft](https://github.com/keshavsoft)
1
+ # ubuntu-service
2
+
3
+ [![npm version](https://img.shields.io/badge/npm-v1.2.1-blue.svg)](https://www.npmjs.com/package/ubuntu-service)
4
+ [![License: ISC](https://img.shields.io/badge/License-ISC-green.svg)](https://opensource.org/licenses/ISC)
5
+ [![Docs](https://img.shields.io/badge/docs-GitHub_Pages-sky.svg)](https://keshavsoft.github.io/ubuntu-service-docs/service/)
6
+ [![Suite Hub](https://img.shields.io/badge/suite-ubuntu--service-orange.svg)](https://keshavsoft.github.io/ubuntu-service-docs/)
7
+ [![Organization](https://img.shields.io/badge/org-KeshavSoft-purple.svg)](https://github.com/keshavsoft)
8
+ [![Node](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org)
9
+
10
+ > **Context-aware single service manager for Ubuntu VPS.**
11
+ > Automatically identifies the systemd service associated with your current working directory (`process.cwd()`), inspects its status, restarts it, and displays its logs. Zero memory needed—run right after `git pull`.
12
+
13
+ ---
14
+
15
+ ## 🌐 Documentation & Suite Links
16
+
17
+ - **Dedicated Documentation:** [https://keshavsoft.github.io/ubuntu-service-docs/service/](https://keshavsoft.github.io/ubuntu-service-docs/service/)
18
+ - **Full Suite Hub:** [https://keshavsoft.github.io/ubuntu-service-docs/](https://keshavsoft.github.io/ubuntu-service-docs/)
19
+ - **All 8 Repositories in Family:** [https://keshavsoft.github.io/ubuntu-service-docs/repos/](https://keshavsoft.github.io/ubuntu-service-docs/repos/)
20
+ - **Sub-packages:**
21
+ - `ubuntu-service-detect`: [npm](https://www.npmjs.com/package/ubuntu-service-detect) | [docs](https://keshavsoft.github.io/ubuntu-service-docs/detect/) | [repo](https://github.com/keshavsoft/ubuntu-service-detect)
22
+ - `ubuntu-service-restart`: [npm](https://www.npmjs.com/package/ubuntu-service-restart) | [docs](https://keshavsoft.github.io/ubuntu-service-docs/restart/) | [repo](https://github.com/keshavsoft/ubuntu-service-restart)
23
+
24
+ ---
25
+
26
+ ## 🎯 The Philosophy: Singular vs. Plural
27
+
28
+ | Repository | Focus | Scope | Question Answered |
29
+ | :--- | :--- | :--- | :--- |
30
+ | **`ubuntu-services`** *(Plural)* | Fleet / Inventory | All services on the OS | *"What is everything running on my Ubuntu VPS? Are there broken folders?"* |
31
+ | **`ubuntu-service`** *(Singular)* | Atomic / Current App | Single service for current directory | *"What service runs THIS folder, and let me restart only this service right now."* |
32
+
33
+ ---
34
+
35
+ ## 💡 The Everyday VPS Problem
36
+
37
+ When deploying code on an Ubuntu server:
38
+ ```bash
39
+ root@server6358:~/KeshavSoft/appointment-notifier# git pull
40
+ Updating cced23f..34bc3e5
41
+ Fast-forward
42
+ ...
43
+ ```
44
+
45
+ Now you need to restart the application. But:
46
+ * *What is the exact systemd unit name for this directory?*
47
+ * Is it `appointment.service`? `appointment-notifier.service`? `appointment.keshavsoft.com.service`?
48
+ * Instead of grepping `/etc/systemd/system/` or rebooting the server:
49
+
50
+ Simply run:
51
+ ```bash
52
+ us restart
53
+ ```
54
+
55
+ ---
56
+
57
+ ## ⚡ Quick Start
58
+
59
+ Run directly with zero installation via `npx`:
60
+
61
+ ```bash
62
+ # Stand in any project directory on your Ubuntu VPS
63
+ cd /root/KeshavSoft/appointment-notifier
64
+
65
+ # 1. Inspect the service running this directory
66
+ npx ubuntu-service
67
+ # Or with short alias:
68
+ us
69
+
70
+ # 2. Restart ONLY this service
71
+ us restart
72
+
73
+ # 3. View live systemd logs
74
+ us logs -n 50
75
+
76
+ # 4. Output only the unit name (e.g. for scripts or CI)
77
+ us name
78
+ ```
79
+
80
+ ---
81
+
82
+ ## 📖 CLI Commands
83
+
84
+ | Command | Description |
85
+ | :--- | :--- |
86
+ | `us` / `npx ubuntu-service` | Shows service card: unit name, state, PID, memory, port, working directory |
87
+ | `us restart` | Restarts only the service attached to the current directory and verifies status |
88
+ | `us status` | Detailed status inspection for the current service |
89
+ | `us logs [-n <count>]` | Fetches live `journalctl` logs for this specific service |
90
+ | `us name` | Prints only the unit name (e.g. `appointment.keshavsoft.com.service`) |
91
+ | `us port` | Prints only the detected port (e.g. `3000`) |
92
+
93
+ ### Flags & Options
94
+
95
+ * `--dir <path>`: Target a specific folder instead of `process.cwd()`
96
+ * `--systemd-dir <path>`: Custom systemd directory (useful for testing)
97
+ * `-n, --lines <count>`: Number of log lines to retrieve (default: 25)
98
+ * `--json`: Output machine-readable JSON
99
+ * `-h, --help`: Display help screen
100
+
101
+ ---
102
+
103
+ ## 🏗️ Architecture
104
+
105
+ ```text
106
+ ubuntu-service/
107
+ ├── bin/
108
+ │ └── index.js # Executable entrypoint (`ubuntu-service`, `us`)
109
+ ├── src/
110
+ │ ├── index.js # Orchestrator (delegates to latest v1)
111
+ │ ├── cli.js # CLI Orchestrator
112
+ │ └── v1/
113
+ │ ├── index.js # Public API exports
114
+ │ ├── detector.js # Context detection (CWD to systemd unit mapping)
115
+ │ ├── parser.js # Systemd .service INI & port parser
116
+ │ ├── systemctl.js # Native systemctl & journalctl execution
117
+ │ ├── actions.js # Business actions (inspect, restart, logs)
118
+ │ └── cli.js # Terminal UI & formatting
119
+ ├── test/ # Automated test suite (node --test)
120
+ ├── docs/ # GitHub Pages portal & live terminal simulator
121
+ ├── package.json # Whitelisted files: ["bin", "src"], zero dependencies
122
+ └── LICENSE # ISC License
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 🛡️ License
128
+
129
+ ISC License — [KeshavSoft](https://github.com/keshavsoft)
package/bin/index.js CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env node
2
-
3
- import { runCli } from "../src/cli.js";
4
-
5
- const exitCode = runCli(process.argv.slice(2));
6
- if (typeof exitCode === "number") {
7
- process.exitCode = exitCode;
8
- }
1
+ #!/usr/bin/env node
2
+
3
+ import { runCli } from "../src/cli.js";
4
+
5
+ const exitCode = runCli(process.argv.slice(2));
6
+ if (typeof exitCode === "number") {
7
+ process.exitCode = exitCode;
8
+ }
package/package.json CHANGED
@@ -1,47 +1,50 @@
1
- {
2
- "name": "ubuntu-service",
3
- "version": "1.0.0",
4
- "description": "Context-aware CLI to identify, inspect, restart, and view logs of the single systemd service running in the current directory on an Ubuntu VPS.",
5
- "type": "module",
6
- "main": "./src/index.js",
7
- "exports": {
8
- ".": "./src/index.js",
9
- "./v1": "./src/v1/index.js"
10
- },
11
- "bin": {
12
- "ubuntu-service": "bin/index.js",
13
- "us": "bin/index.js"
14
- },
15
- "files": [
16
- "bin",
17
- "src"
18
- ],
19
- "scripts": {
20
- "start": "node bin/index.js",
21
- "cli": "node bin/index.js",
22
- "test": "node --test"
23
- },
24
- "keywords": [
25
- "ubuntu",
26
- "systemd",
27
- "service",
28
- "vps",
29
- "process",
30
- "restart",
31
- "cwd",
32
- "caddy"
33
- ],
34
- "author": "KeshavSoft",
35
- "license": "ISC",
36
- "repository": {
37
- "type": "git",
38
- "url": "git+https://github.com/keshavsoft/ubuntu-service.git"
39
- },
40
- "bugs": {
41
- "url": "https://github.com/keshavsoft/ubuntu-service/issues"
42
- },
43
- "homepage": "https://keshavsoft.github.io/ubuntu-service/",
44
- "engines": {
45
- "node": ">=18.0.0"
46
- }
47
- }
1
+ {
2
+ "name": "ubuntu-service",
3
+ "version": "3.1.1",
4
+ "description": "Single-domain systemd service inspector for an Ubuntu VPS (v3 requires an explicit domain parameter).",
5
+ "type": "module",
6
+ "main": "./src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js"
9
+ },
10
+ "bin": {
11
+ "ubuntu-service": "bin/index.js",
12
+ "us": "bin/index.js"
13
+ },
14
+ "files": [
15
+ "bin",
16
+ "src"
17
+ ],
18
+ "scripts": {
19
+ "start": "node bin/index.js",
20
+ "cli": "node bin/index.js",
21
+ "test": "node --test"
22
+ },
23
+ "dependencies": {
24
+ "ubuntu-service-detect": "^1.0.0",
25
+ "ubuntu-service-restart": "^1.0.0"
26
+ },
27
+ "keywords": [
28
+ "ubuntu",
29
+ "systemd",
30
+ "service",
31
+ "vps",
32
+ "process",
33
+ "restart",
34
+ "cwd",
35
+ "caddy"
36
+ ],
37
+ "author": "KeshavSoft",
38
+ "license": "ISC",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/keshavsoft/ubuntu-service.git"
42
+ },
43
+ "bugs": {
44
+ "url": "https://github.com/keshavsoft/ubuntu-service/issues"
45
+ },
46
+ "homepage": "https://keshavsoft.github.io/ubuntu-service/",
47
+ "engines": {
48
+ "node": ">=18.0.0"
49
+ }
50
+ }
package/src/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- // Orchestrator: delegates CLI execution directly to latest version (v1)
2
- export { runCli, printHelp } from "./v1/cli.js";
1
+ // Orchestrator: delegates CLI execution directly to latest version (v3)
2
+ export { runCli, printHelp } from "./v3/cli.js";
package/src/index.js CHANGED
@@ -1,3 +1,3 @@
1
- // Orchestrator: delegates directly to latest version (v1)
2
- export * from "./v1/index.js";
3
- export { default } from "./v1/index.js";
1
+ // Orchestrator: delegates directly to latest version (v3)
2
+ export * from "./v3/index.js";
3
+ export { default } from "./v3/index.js";
@@ -1,58 +1,49 @@
1
- import { findServiceForDirectory } from "./detector.js";
2
- import { getServiceLiveStatus, restartService, getServiceLogs } from "./systemctl.js";
3
-
4
- /**
5
- * High-level action to inspect the service for the current or target directory.
6
- */
7
- export function inspectCurrentService(targetDir = process.cwd(), options = {}) {
8
- const detected = findServiceForDirectory(targetDir, options);
9
- if (!detected.found) {
10
- return detected;
11
- }
12
-
13
- const liveStatus = getServiceLiveStatus(detected.unitName);
14
- return {
15
- ...detected,
16
- liveStatus
17
- };
18
- }
19
-
20
- /**
21
- * High-level action to restart the service associated with current or target directory.
22
- */
23
- export function restartCurrentService(targetDir = process.cwd(), options = {}) {
24
- const detected = findServiceForDirectory(targetDir, options);
25
- if (!detected.found) {
26
- return {
27
- success: false,
28
- error: detected.message,
29
- targetDir
30
- };
31
- }
32
-
33
- const restartResult = restartService(detected.unitName);
34
- return {
35
- ...detected,
36
- restartResult
37
- };
38
- }
39
-
40
- /**
41
- * High-level action to get logs of the service associated with current or target directory.
42
- */
43
- export function getCurrentServiceLogs(targetDir = process.cwd(), lines = 25, options = {}) {
44
- const detected = findServiceForDirectory(targetDir, options);
45
- if (!detected.found) {
46
- return {
47
- success: false,
48
- error: detected.message,
49
- targetDir
50
- };
51
- }
52
-
53
- const logsResult = getServiceLogs(detected.unitName, lines);
54
- return {
55
- ...detected,
56
- logsResult
57
- };
58
- }
1
+ import { findServiceForDirectory } from "ubuntu-service-detect";
2
+ import { getServiceLiveStatus, restartService, getServiceLogs } from "ubuntu-service-restart";
3
+
4
+ export function inspectCurrentService(targetDir = process.cwd(), options = {}) {
5
+ const detected = findServiceForDirectory(targetDir, options);
6
+ if (!detected.found) {
7
+ return detected;
8
+ }
9
+
10
+ const liveStatus = getServiceLiveStatus(detected.unitName);
11
+ return {
12
+ ...detected,
13
+ liveStatus
14
+ };
15
+ }
16
+
17
+ export function restartCurrentService(targetDir = process.cwd(), options = {}) {
18
+ const detected = findServiceForDirectory(targetDir, options);
19
+ if (!detected.found) {
20
+ return {
21
+ success: false,
22
+ error: detected.message,
23
+ targetDir
24
+ };
25
+ }
26
+
27
+ const restartResult = restartService(detected.unitName);
28
+ return {
29
+ ...detected,
30
+ restartResult
31
+ };
32
+ }
33
+
34
+ export function getCurrentServiceLogs(targetDir = process.cwd(), lines = 25, options = {}) {
35
+ const detected = findServiceForDirectory(targetDir, options);
36
+ if (!detected.found) {
37
+ return {
38
+ success: false,
39
+ error: detected.message,
40
+ targetDir
41
+ };
42
+ }
43
+
44
+ const logsResult = getServiceLogs(detected.unitName, lines);
45
+ return {
46
+ ...detected,
47
+ logsResult
48
+ };
49
+ }