logggggoff 1.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/README.md +21 -0
- package/index.js +150 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# logggggoff
|
|
2
|
+
|
|
3
|
+
A colorful, cross-platform CLI tool designed to help list running processes, categorized.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Lists all running processes
|
|
7
|
+
- Supports "single process shutdown"
|
|
8
|
+
- Supports "Graceful shutdown"
|
|
9
|
+
- Supports Windows, macOS and Linux
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g logggggoff
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
Displays options for the package:
|
|
19
|
+
```bash
|
|
20
|
+
logggggoff
|
|
21
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const psList = require('ps-list');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const { exec } = require('child_process');
|
|
5
|
+
const commander = require('commander');
|
|
6
|
+
const program = new commander.Command();
|
|
7
|
+
// Process type categories with colors
|
|
8
|
+
const PROCESS_TYPES = {
|
|
9
|
+
Browser: {
|
|
10
|
+
color: chalk.cyan,
|
|
11
|
+
matches: ['chrome', 'firefox', 'safari', 'msedge', 'edge', 'opera']
|
|
12
|
+
},
|
|
13
|
+
'Editor/IDE': {
|
|
14
|
+
color: chalk.magenta,
|
|
15
|
+
matches: ['code', 'visual studio code', 'sublime text', 'atom', 'notepad++', 'webstorm', 'pycharm', 'intellij idea', 'notepad', 'textedit']
|
|
16
|
+
},
|
|
17
|
+
Office: {
|
|
18
|
+
color: chalk.yellow,
|
|
19
|
+
matches: ['excel', 'word', 'powerpoint', 'outlook', 'onenote', 'teams', 'slack', 'zoom', 'skype']
|
|
20
|
+
},
|
|
21
|
+
System: {
|
|
22
|
+
color: chalk.gray,
|
|
23
|
+
matches: ['cmd.exe', 'node.exe', 'bash', 'zsh', 'system', 'idle', 'svchost.exe', 'explorer.exe', 'finder', 'dock', 'kernel_task']
|
|
24
|
+
},
|
|
25
|
+
Other: {
|
|
26
|
+
color: chalk.white,
|
|
27
|
+
matches: [] // Default for anything not matched
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
// Simple descriptions for common processes
|
|
31
|
+
const PROCESS_DESCRIPTIONS = {
|
|
32
|
+
'chrome': 'Google Chrome web browser.',
|
|
33
|
+
'firefox': 'Mozilla Firefox web browser.',
|
|
34
|
+
'safari': 'Apple Safari web browser.',
|
|
35
|
+
'msedge': 'Microsoft Edge web browser.',
|
|
36
|
+
'edge': 'Microsoft Edge web browser.',
|
|
37
|
+
'opera': 'Opera web browser.',
|
|
38
|
+
'code': 'Visual Studio Code editor.',
|
|
39
|
+
'visual studio code': 'Visual Studio Code editor.',
|
|
40
|
+
'sublime text': 'Sublime Text editor.',
|
|
41
|
+
'atom': 'Atom text editor.',
|
|
42
|
+
'notepad++': 'Notepad++ text editor.',
|
|
43
|
+
'webstorm': 'WebStorm IDE for web development.',
|
|
44
|
+
'pycharm': 'PyCharm IDE for Python development.',
|
|
45
|
+
'intellij idea': 'IntelliJ IDEA for Java/general development.',
|
|
46
|
+
'excel': 'Microsoft Excel spreadsheet software.',
|
|
47
|
+
'word': 'Microsoft Word document editor.',
|
|
48
|
+
'powerpoint': 'Microsoft PowerPoint presentation software.',
|
|
49
|
+
'outlook': 'Microsoft Outlook email client.',
|
|
50
|
+
'onenote': 'Microsoft OneNote note-taking app.',
|
|
51
|
+
'teams': 'Microsoft Teams collaboration platform.',
|
|
52
|
+
'slack': 'Slack messaging and collaboration tool.',
|
|
53
|
+
'zoom': 'Zoom video conferencing app.',
|
|
54
|
+
'skype': 'Skype communication app.',
|
|
55
|
+
'notepad': 'Basic Windows text editor.',
|
|
56
|
+
'textedit': 'Basic macOS text editor.',
|
|
57
|
+
'cmd.exe': 'Windows Command Prompt.',
|
|
58
|
+
'node.exe': 'Node.js runtime environment.',
|
|
59
|
+
'bash': 'Unix shell for command-line tasks.',
|
|
60
|
+
'zsh': 'Z Shell, an enhanced Unix shell.',
|
|
61
|
+
'system': 'Core macOS system process.',
|
|
62
|
+
'idle': 'System idle process (low CPU usage).',
|
|
63
|
+
'svchost.exe': 'Windows service host process.',
|
|
64
|
+
'explorer.exe': 'Windows File Explorer.',
|
|
65
|
+
'finder': 'macOS file management app.',
|
|
66
|
+
'dock': 'macOS Dock for app launching.',
|
|
67
|
+
'kernel_task': 'macOS kernel management process.'
|
|
68
|
+
};
|
|
69
|
+
function getProcessType(name) {
|
|
70
|
+
const lowerName = name.toLowerCase();
|
|
71
|
+
for (const [type, { matches }] of Object.entries(PROCESS_TYPES)) {
|
|
72
|
+
if (matches.some(match => lowerName.includes(match))) {
|
|
73
|
+
return type;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return 'Other';
|
|
77
|
+
}
|
|
78
|
+
function getProcessDescription(name) {
|
|
79
|
+
const lowerName = name.toLowerCase();
|
|
80
|
+
for (const [key, desc] of Object.entries(PROCESS_DESCRIPTIONS)) {
|
|
81
|
+
if (lowerName.includes(key)) return desc;
|
|
82
|
+
}
|
|
83
|
+
return 'A running process (purpose unknown).';
|
|
84
|
+
}
|
|
85
|
+
async function getAllProcesses() {
|
|
86
|
+
const tasks = await psList();
|
|
87
|
+
return tasks.filter(task => task.name !== process.argv[1]); // Exclude logggggoff itself
|
|
88
|
+
}
|
|
89
|
+
function closeApp(pid) {
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
const command = process.platform === 'win32'
|
|
92
|
+
? `taskkill /PID ${pid}`
|
|
93
|
+
: `kill -TERM ${pid}`;
|
|
94
|
+
exec(command, (error) => {
|
|
95
|
+
if (error) reject(error);
|
|
96
|
+
else resolve();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async function listProcesses() {
|
|
101
|
+
console.log(chalk.bgMagenta.white.bold('Logggggoff Process List'));
|
|
102
|
+
const processes = await getAllProcesses();
|
|
103
|
+
if (processes.length === 0) {
|
|
104
|
+
console.log(chalk.yellow('No processes detected.'));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
console.log(chalk.green('\nRunning Processes:'));
|
|
108
|
+
processes.forEach((proc, i) => {
|
|
109
|
+
const type = getProcessType(proc.name);
|
|
110
|
+
const colorFn = PROCESS_TYPES[type].color;
|
|
111
|
+
console.log(colorFn(`${i + 1}. ${proc.name} (PID: ${proc.pid}) - ${getProcessDescription(proc.name)} [${type}]`));
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
async function killSpecificProcess(pid) {
|
|
115
|
+
console.log(chalk.bgMagenta.white.bold(` :rocket: Killing Process ${pid}... `));
|
|
116
|
+
try {
|
|
117
|
+
await closeApp(pid);
|
|
118
|
+
console.log(chalk.green(`✓ Process ${pid} closed`));
|
|
119
|
+
} catch (err) {
|
|
120
|
+
console.error(chalk.red(`Failed to close process ${pid}: ${err.message}`));
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Set up commander
|
|
125
|
+
program
|
|
126
|
+
.version('1.0.0')
|
|
127
|
+
.description('A colorful, cross-platform CLI tool to list processes or terminate a specific process by PID');
|
|
128
|
+
program
|
|
129
|
+
.command('list')
|
|
130
|
+
.description('Display all running processes with descriptions and types')
|
|
131
|
+
.action(() => {
|
|
132
|
+
listProcesses().catch(err => {
|
|
133
|
+
console.error(chalk.red('Error:', err.message));
|
|
134
|
+
process.exit(1);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
program
|
|
138
|
+
.command('<pid> run')
|
|
139
|
+
.description('Kill a specific process by PID (e.g., logggggoff 525 run)')
|
|
140
|
+
.action((pid) => {
|
|
141
|
+
killSpecificProcess(pid).catch(err => {
|
|
142
|
+
console.error(chalk.red('Error:', err.message));
|
|
143
|
+
process.exit(1);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
// Parse arguments; default to 'list' if no command is provided
|
|
147
|
+
program.parse(process.argv);
|
|
148
|
+
if (!process.argv.slice(2).length) {
|
|
149
|
+
program.parse(['', '', 'list']);
|
|
150
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "logggggoff",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A colorful, cross-platform CLI tool designed to help list running processes, categorized.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"logggggoff": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/TheRiseCollection/logg-off-plugin.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"cli",
|
|
18
|
+
"logoff",
|
|
19
|
+
"productivity",
|
|
20
|
+
"shutdown",
|
|
21
|
+
"cross-platform"
|
|
22
|
+
],
|
|
23
|
+
"author": "Joshua Paulsen",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/TheRiseCollection/logg-off-plugin/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/TheRiseCollection/logg-off-plugin#readme",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"chalk": "^4.1.2",
|
|
31
|
+
"inquirer": "^8.2.4",
|
|
32
|
+
"performance-now": "^2.1.0",
|
|
33
|
+
"child_process": "latest",
|
|
34
|
+
"commander": "^9.4.1",
|
|
35
|
+
"ps-list": "^7.2.0"
|
|
36
|
+
}
|
|
37
|
+
}
|