easy-devops 1.2.0 → 1.3.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 +97 -6
- package/dist/ui/assets/index-B6zdwEnG.css +1 -0
- package/dist/ui/assets/index-Cy0oNmul.js +442 -0
- package/dist/ui/assets/socket-DwLPrgsr.js +1 -0
- package/dist/ui/assets/socket-K5ttLD2q.js +65 -0
- package/dist/ui/brand/apple-touch-icon.png +0 -0
- package/dist/ui/brand/favicon-16.png +0 -0
- package/dist/ui/brand/favicon-32.png +0 -0
- package/dist/ui/brand/favicon-light-16.png +0 -0
- package/dist/ui/brand/favicon-light-32.png +0 -0
- package/dist/ui/brand/favicon.ico +0 -0
- package/dist/ui/brand/icon-192.png +0 -0
- package/dist/ui/brand/icon-48.png +0 -0
- package/dist/ui/brand/icon-512.png +0 -0
- package/dist/ui/brand/icon-64-light.png +0 -0
- package/dist/ui/brand/icon-64.png +0 -0
- package/dist/ui/brand/logo-dark.png +0 -0
- package/dist/ui/brand/logo-light.png +0 -0
- package/dist/ui/brand/mark-dark.png +0 -0
- package/dist/ui/brand/mark-light.png +0 -0
- package/dist/ui/index.html +71 -0
- package/install.ps1 +188 -1
- package/install.sh +254 -29
- package/package.json +17 -5
- package/src/cli/dash.js +110 -0
- package/src/cli/index.js +237 -106
- package/src/cli/managers/domain-manager.js +60 -40
- package/src/cli/managers/ssl-manager.js +47 -330
- package/src/cli/menu.js +156 -0
- package/src/cli/menus/cleanup.js +205 -0
- package/src/cli/menus/dashboard.js +93 -2
- package/src/cli/menus/runtime.js +236 -0
- package/src/cli/menus/service.js +764 -0
- package/src/cli/menus/settings.js +176 -8
- package/src/cli/menus/uninstall.js +167 -0
- package/src/cli/menus/update.js +221 -65
- package/src/core/acme-challenge.js +273 -0
- package/src/core/cert-operations.js +189 -0
- package/src/{dashboard/lib → core}/cert-reader.js +2 -2
- package/src/core/cert-renewal.js +494 -0
- package/src/core/channels/discord.js +77 -0
- package/src/core/channels/telegram.js +120 -0
- package/src/core/cleanup.js +600 -0
- package/src/core/config.js +169 -2
- package/src/core/daemon/ipc.js +292 -0
- package/src/core/daemon/lock.js +294 -0
- package/src/core/daemon/run.js +241 -0
- package/src/core/daemon/stopRequest.js +162 -0
- package/src/core/db.js +44 -8
- package/src/core/deploy/apps.js +491 -0
- package/src/core/deploy/domainLink.js +200 -0
- package/src/core/deploy/engine.js +973 -0
- package/src/core/deploy/ezfile.js +361 -0
- package/src/core/deploy/github.js +239 -0
- package/src/core/deploy/githubApi.js +261 -0
- package/src/core/deploy/hookServer.js +325 -0
- package/src/core/deploy/hubCommands.js +267 -0
- package/src/core/deploy/launcher.js +57 -0
- package/src/core/deploy/status.js +91 -0
- package/src/core/deploy/store.js +398 -0
- package/src/core/domainNotifier.js +364 -0
- package/src/core/domains-db.js +234 -0
- package/src/core/events.js +222 -0
- package/src/core/hub/agent.js +842 -0
- package/src/core/hubLink.js +306 -0
- package/src/core/hubPermissions.js +430 -0
- package/src/core/installSource.js +162 -0
- package/src/core/jobs/bus.js +120 -0
- package/src/core/jobs/index.js +371 -0
- package/src/core/jobs/monitors.js +368 -0
- package/src/core/jobs/owner.js +217 -0
- package/src/core/jobs/revisionWatcher.js +106 -0
- package/src/core/nginx-apply.js +213 -0
- package/src/core/nginx-conf-generator.js +253 -17
- package/src/{dashboard/lib → core}/nginx-service.js +18 -9
- package/src/core/notifications/claim.js +214 -0
- package/src/core/notifications/dispatch.js +154 -0
- package/src/core/notifier.js +103 -0
- package/src/core/passwords.js +172 -0
- package/src/core/permissions.js +8 -4
- package/src/core/platform.js +709 -2
- package/src/core/probeCache.js +258 -0
- package/src/core/purge.js +372 -0
- package/src/core/runner.js +488 -0
- package/src/core/service/acl.js +226 -0
- package/src/core/service/dataDir.js +345 -0
- package/src/core/service/index.js +1128 -0
- package/src/core/service/legacy.js +218 -0
- package/src/core/service/runtime.js +446 -0
- package/src/core/service/runtimeUpdate.js +800 -0
- package/src/core/service/systemd.js +458 -0
- package/src/core/service/windowsPersonal.js +530 -0
- package/src/core/service/windowsService.js +576 -0
- package/src/core/service/winsw.js +260 -0
- package/src/core/setupCode.js +331 -0
- package/src/core/shell.js +128 -13
- package/src/core/ssl-issuer.js +627 -0
- package/src/core/updater.js +295 -0
- package/src/core/validators.js +99 -0
- package/src/dashboard/controllers/authController.js +316 -0
- package/src/dashboard/controllers/deploymentsController.js +479 -0
- package/src/dashboard/controllers/domainsController.js +403 -0
- package/src/dashboard/controllers/hubController.js +135 -0
- package/src/dashboard/controllers/nginxController.js +146 -0
- package/src/dashboard/controllers/processesController.js +368 -0
- package/src/dashboard/controllers/settingsController.js +503 -0
- package/src/dashboard/controllers/sslController.js +452 -0
- package/src/dashboard/lib/daemonBridge.js +163 -0
- package/src/dashboard/lib/localRequest.js +235 -0
- package/src/dashboard/lib/loginRateLimit.js +119 -0
- package/src/dashboard/lib/requireAuth.js +80 -0
- package/src/dashboard/public/img/icon.png +0 -0
- package/src/dashboard/public/img/icon_b.png +0 -0
- package/src/dashboard/public/js/app.js +595 -19
- package/src/dashboard/routes/auth.js +14 -33
- package/src/dashboard/routes/deployments.js +46 -0
- package/src/dashboard/routes/domains.js +20 -363
- package/src/dashboard/routes/hub.js +22 -0
- package/src/dashboard/routes/nginx.js +22 -146
- package/src/dashboard/routes/processes.js +29 -0
- package/src/dashboard/routes/settings.js +25 -232
- package/src/dashboard/routes/ssl.js +18 -276
- package/src/dashboard/server.js +279 -165
- package/src/dashboard/socketManager.js +246 -0
- package/src/dashboard/views/index.ejs +1 -0
- package/src/dashboard/views/partials/domain-form.ejs +64 -1
- package/src/dashboard/views/partials/login.ejs +69 -8
- package/src/dashboard/views/partials/processes-panel.ejs +261 -0
- package/src/dashboard/views/partials/settings-panel.ejs +549 -118
- package/src/dashboard/views/partials/sidebar.ejs +3 -1
- package/src/dashboard/lib/domains-db.js +0 -51
- /package/src/{dashboard/routes → core/channels}/.gitkeep +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discord Notification Channel
|
|
3
|
+
*
|
|
4
|
+
* Sends notifications to Discord via webhook using discord.js.
|
|
5
|
+
* This module conforms to the channel interface defined in notifier.js:
|
|
6
|
+
* - Exports async function send(event, channelConfig)
|
|
7
|
+
* - channelConfig must contain { webhookUrl }
|
|
8
|
+
*
|
|
9
|
+
* NO IMPORTS from other project files.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { WebhookClient, EmbedBuilder } from 'discord.js';
|
|
13
|
+
|
|
14
|
+
const SEVERITY_COLORS = {
|
|
15
|
+
danger: 0xE74C3C, // red
|
|
16
|
+
warning: 0xFFFF00, // yellow
|
|
17
|
+
};
|
|
18
|
+
const DEFAULT_COLOR = 0x3498DB; // blue
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Convert event type to a human-readable title.
|
|
22
|
+
* e.g., 'domain_added' -> 'Domain Added'
|
|
23
|
+
* @param {string} type - Event type
|
|
24
|
+
* @returns {string} Formatted title
|
|
25
|
+
*/
|
|
26
|
+
function toTitle(type) {
|
|
27
|
+
if (!type) return 'Notification';
|
|
28
|
+
return type.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Send a notification to Discord via webhook.
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} event - The notification event
|
|
35
|
+
* @param {string} event.type - Event type for embed title
|
|
36
|
+
* @param {string} [event.message] - Message to include in description
|
|
37
|
+
* @param {string} [event.severity] - 'danger' (red) or 'warning' (yellow)
|
|
38
|
+
* @param {string} [event.domain] - Domain to include in description
|
|
39
|
+
* @param {string} [event.timestamp] - ISO timestamp (defaults to now)
|
|
40
|
+
* @param {Object} channelConfig - Channel configuration
|
|
41
|
+
* @param {string} channelConfig.webhookUrl - Discord webhook URL
|
|
42
|
+
* @param {string} [channelConfig.message] - Optional prefix to prepend to message
|
|
43
|
+
* @returns {Promise<void>}
|
|
44
|
+
*/
|
|
45
|
+
export async function send(event, channelConfig) {
|
|
46
|
+
// Early return if not configured - no throw, just exit silently
|
|
47
|
+
if (!channelConfig?.webhookUrl) return;
|
|
48
|
+
|
|
49
|
+
// Determine embed colour based on severity
|
|
50
|
+
const color = SEVERITY_COLORS[event?.severity] ?? DEFAULT_COLOR;
|
|
51
|
+
|
|
52
|
+
// Build description from available fields
|
|
53
|
+
const lines = [];
|
|
54
|
+
if (event?.message) lines.push(event.message);
|
|
55
|
+
if (event?.domain) lines.push(`Domain: \`${event.domain}\``);
|
|
56
|
+
const description = lines.join('\n') || 'No additional details.';
|
|
57
|
+
|
|
58
|
+
// Build Discord embed using EmbedBuilder
|
|
59
|
+
const embed = new EmbedBuilder()
|
|
60
|
+
.setAuthor({ name: 'Easy DevOps', iconURL: 'https://raw.githubusercontent.com/omar00050/Easy-DevOps/main/src/dashboard/public/img/icon_b.png' })
|
|
61
|
+
.setTitle(toTitle(event?.type))
|
|
62
|
+
.setDescription(description)
|
|
63
|
+
.setColor(color)
|
|
64
|
+
.setFooter({ text: 'Easy DevOps' })
|
|
65
|
+
.setTimestamp(event?.timestamp ? new Date(event.timestamp) : new Date());
|
|
66
|
+
|
|
67
|
+
// Send via WebhookClient
|
|
68
|
+
// The message prefix (e.g. role mention) goes in `content`, not the embed,
|
|
69
|
+
// because Discord only resolves mentions in message content, not inside embeds.
|
|
70
|
+
const webhook = new WebhookClient({ url: channelConfig.webhookUrl });
|
|
71
|
+
await webhook.send({
|
|
72
|
+
content: channelConfig.message || undefined,
|
|
73
|
+
embeds: [embed],
|
|
74
|
+
username: 'Easy DevOps logs',
|
|
75
|
+
avatarURL: 'https://raw.githubusercontent.com/omar00050/Easy-DevOps/main/src/dashboard/public/img/icon_b.png',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Notification Channel
|
|
3
|
+
*
|
|
4
|
+
* Sends notifications to Telegram via Bot API.
|
|
5
|
+
* This module conforms to the channel interface defined in notifier.js:
|
|
6
|
+
* - Exports async function send(event, channelConfig)
|
|
7
|
+
* - channelConfig must contain { botToken, chatId }
|
|
8
|
+
*
|
|
9
|
+
* NO IMPORTS: fetch is global in Node 18+. This module does not import
|
|
10
|
+
* from notifier.js or any other project files.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Escape HTML special characters for Telegram HTML parse mode.
|
|
15
|
+
* @param {string} str - String to escape
|
|
16
|
+
* @returns {string} HTML-safe string
|
|
17
|
+
*/
|
|
18
|
+
function escapeHtml(str) {
|
|
19
|
+
if (!str) return '';
|
|
20
|
+
return str
|
|
21
|
+
.replace(/&/g, '&')
|
|
22
|
+
.replace(/</g, '<')
|
|
23
|
+
.replace(/>/g, '>');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Convert event type to a human-readable title.
|
|
28
|
+
* e.g., 'domain_added' -> 'Domain Added'
|
|
29
|
+
* @param {string} type - Event type
|
|
30
|
+
* @returns {string} Formatted title
|
|
31
|
+
*/
|
|
32
|
+
function toTitle(type) {
|
|
33
|
+
if (!type) return 'Notification';
|
|
34
|
+
return type.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get severity emoji prefix for Telegram messages.
|
|
39
|
+
* @param {string} severity - 'danger', 'warning', or undefined/other
|
|
40
|
+
* @returns {string} Emoji prefix or empty string
|
|
41
|
+
*/
|
|
42
|
+
function severityPrefix(severity) {
|
|
43
|
+
if (severity === 'danger') return '\uD83D\uDD34 DANGER';
|
|
44
|
+
if (severity === 'warning') return '\u26A0\uFE0F WARNING';
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Send a notification to Telegram via Bot API.
|
|
50
|
+
*
|
|
51
|
+
* @param {Object} event - The notification event
|
|
52
|
+
* @param {string} event.type - Event type for message title
|
|
53
|
+
* @param {string} [event.message] - Message to include
|
|
54
|
+
* @param {string} [event.severity] - 'danger' or 'warning'
|
|
55
|
+
* @param {string} [event.domain] - Domain to include
|
|
56
|
+
* @param {string} [event.timestamp] - ISO timestamp (defaults to now)
|
|
57
|
+
* @param {Object} channelConfig - Channel configuration
|
|
58
|
+
* @param {string} channelConfig.botToken - Telegram bot token
|
|
59
|
+
* @param {string} channelConfig.chatId - Telegram chat ID
|
|
60
|
+
* @param {string} [channelConfig.message] - Optional prefix to prepend to message
|
|
61
|
+
* @returns {Promise<void>}
|
|
62
|
+
*/
|
|
63
|
+
export async function send(event, channelConfig) {
|
|
64
|
+
// Early return if not configured - no throw, just exit silently
|
|
65
|
+
if (!channelConfig?.botToken || !channelConfig?.chatId) return;
|
|
66
|
+
try {
|
|
67
|
+
// Prepend message prefix if configured
|
|
68
|
+
if (channelConfig?.message) {
|
|
69
|
+
event = {
|
|
70
|
+
...event,
|
|
71
|
+
message: channelConfig.message + '\n' + (event.message || '')
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Build message text using HTML formatting
|
|
76
|
+
const lines = [];
|
|
77
|
+
|
|
78
|
+
// Add severity prefix if present
|
|
79
|
+
const prefix = severityPrefix(event?.severity);
|
|
80
|
+
if (prefix) lines.push(`<b>${prefix}</b>`);
|
|
81
|
+
|
|
82
|
+
// Add event type as title
|
|
83
|
+
lines.push(`<b>${escapeHtml(toTitle(event?.type))}</b>`);
|
|
84
|
+
|
|
85
|
+
// Add message body if present (HTML escaped)
|
|
86
|
+
if (event?.message) {
|
|
87
|
+
lines.push(escapeHtml(event.message));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Add domain if present (as inline code)
|
|
91
|
+
if (event?.domain) {
|
|
92
|
+
lines.push(`Domain: <code>${escapeHtml(event.domain)}</code>`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const text = lines.join('\n');
|
|
96
|
+
|
|
97
|
+
// Build Telegram Bot API URL
|
|
98
|
+
const url = `https://api.telegram.org/bot${channelConfig.botToken}/sendMessage`;
|
|
99
|
+
|
|
100
|
+
// POST to Telegram API using built-in fetch (Node 18+)
|
|
101
|
+
const res = await fetch(url, {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
headers: { 'Content-Type': 'application/json' },
|
|
104
|
+
body: JSON.stringify({
|
|
105
|
+
chat_id: channelConfig.chatId,
|
|
106
|
+
text,
|
|
107
|
+
parse_mode: 'HTML',
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
110
|
+
// Throw on non-2xx response
|
|
111
|
+
if (!res.ok) {
|
|
112
|
+
throw new Error(`Telegram API returned ${res.status} ${res.statusText}`);
|
|
113
|
+
}
|
|
114
|
+
} catch (err) {
|
|
115
|
+
// Redact bot token from error message to prevent credential leakage
|
|
116
|
+
const safeMsg = err.message.replace(/bot[^/]+\//g, 'bot[REDACTED]/');
|
|
117
|
+
console.error('[telegram] send failed:', safeMsg);
|
|
118
|
+
// DO NOT re-throw - channel isolation guarantees other channels still work
|
|
119
|
+
}
|
|
120
|
+
}
|