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.
Files changed (132) hide show
  1. package/README.md +97 -6
  2. package/dist/ui/assets/index-B6zdwEnG.css +1 -0
  3. package/dist/ui/assets/index-Cy0oNmul.js +442 -0
  4. package/dist/ui/assets/socket-DwLPrgsr.js +1 -0
  5. package/dist/ui/assets/socket-K5ttLD2q.js +65 -0
  6. package/dist/ui/brand/apple-touch-icon.png +0 -0
  7. package/dist/ui/brand/favicon-16.png +0 -0
  8. package/dist/ui/brand/favicon-32.png +0 -0
  9. package/dist/ui/brand/favicon-light-16.png +0 -0
  10. package/dist/ui/brand/favicon-light-32.png +0 -0
  11. package/dist/ui/brand/favicon.ico +0 -0
  12. package/dist/ui/brand/icon-192.png +0 -0
  13. package/dist/ui/brand/icon-48.png +0 -0
  14. package/dist/ui/brand/icon-512.png +0 -0
  15. package/dist/ui/brand/icon-64-light.png +0 -0
  16. package/dist/ui/brand/icon-64.png +0 -0
  17. package/dist/ui/brand/logo-dark.png +0 -0
  18. package/dist/ui/brand/logo-light.png +0 -0
  19. package/dist/ui/brand/mark-dark.png +0 -0
  20. package/dist/ui/brand/mark-light.png +0 -0
  21. package/dist/ui/index.html +71 -0
  22. package/install.ps1 +188 -1
  23. package/install.sh +254 -29
  24. package/package.json +17 -5
  25. package/src/cli/dash.js +110 -0
  26. package/src/cli/index.js +237 -106
  27. package/src/cli/managers/domain-manager.js +60 -40
  28. package/src/cli/managers/ssl-manager.js +47 -330
  29. package/src/cli/menu.js +156 -0
  30. package/src/cli/menus/cleanup.js +205 -0
  31. package/src/cli/menus/dashboard.js +93 -2
  32. package/src/cli/menus/runtime.js +236 -0
  33. package/src/cli/menus/service.js +764 -0
  34. package/src/cli/menus/settings.js +176 -8
  35. package/src/cli/menus/uninstall.js +167 -0
  36. package/src/cli/menus/update.js +221 -65
  37. package/src/core/acme-challenge.js +273 -0
  38. package/src/core/cert-operations.js +189 -0
  39. package/src/{dashboard/lib → core}/cert-reader.js +2 -2
  40. package/src/core/cert-renewal.js +494 -0
  41. package/src/core/channels/discord.js +77 -0
  42. package/src/core/channels/telegram.js +120 -0
  43. package/src/core/cleanup.js +600 -0
  44. package/src/core/config.js +169 -2
  45. package/src/core/daemon/ipc.js +292 -0
  46. package/src/core/daemon/lock.js +294 -0
  47. package/src/core/daemon/run.js +241 -0
  48. package/src/core/daemon/stopRequest.js +162 -0
  49. package/src/core/db.js +44 -8
  50. package/src/core/deploy/apps.js +491 -0
  51. package/src/core/deploy/domainLink.js +200 -0
  52. package/src/core/deploy/engine.js +973 -0
  53. package/src/core/deploy/ezfile.js +361 -0
  54. package/src/core/deploy/github.js +239 -0
  55. package/src/core/deploy/githubApi.js +261 -0
  56. package/src/core/deploy/hookServer.js +325 -0
  57. package/src/core/deploy/hubCommands.js +267 -0
  58. package/src/core/deploy/launcher.js +57 -0
  59. package/src/core/deploy/status.js +91 -0
  60. package/src/core/deploy/store.js +398 -0
  61. package/src/core/domainNotifier.js +364 -0
  62. package/src/core/domains-db.js +234 -0
  63. package/src/core/events.js +222 -0
  64. package/src/core/hub/agent.js +842 -0
  65. package/src/core/hubLink.js +306 -0
  66. package/src/core/hubPermissions.js +430 -0
  67. package/src/core/installSource.js +162 -0
  68. package/src/core/jobs/bus.js +120 -0
  69. package/src/core/jobs/index.js +371 -0
  70. package/src/core/jobs/monitors.js +368 -0
  71. package/src/core/jobs/owner.js +217 -0
  72. package/src/core/jobs/revisionWatcher.js +106 -0
  73. package/src/core/nginx-apply.js +213 -0
  74. package/src/core/nginx-conf-generator.js +253 -17
  75. package/src/{dashboard/lib → core}/nginx-service.js +18 -9
  76. package/src/core/notifications/claim.js +214 -0
  77. package/src/core/notifications/dispatch.js +154 -0
  78. package/src/core/notifier.js +103 -0
  79. package/src/core/passwords.js +172 -0
  80. package/src/core/permissions.js +8 -4
  81. package/src/core/platform.js +709 -2
  82. package/src/core/probeCache.js +258 -0
  83. package/src/core/purge.js +372 -0
  84. package/src/core/runner.js +488 -0
  85. package/src/core/service/acl.js +226 -0
  86. package/src/core/service/dataDir.js +345 -0
  87. package/src/core/service/index.js +1128 -0
  88. package/src/core/service/legacy.js +218 -0
  89. package/src/core/service/runtime.js +446 -0
  90. package/src/core/service/runtimeUpdate.js +800 -0
  91. package/src/core/service/systemd.js +458 -0
  92. package/src/core/service/windowsPersonal.js +530 -0
  93. package/src/core/service/windowsService.js +576 -0
  94. package/src/core/service/winsw.js +260 -0
  95. package/src/core/setupCode.js +331 -0
  96. package/src/core/shell.js +128 -13
  97. package/src/core/ssl-issuer.js +627 -0
  98. package/src/core/updater.js +295 -0
  99. package/src/core/validators.js +99 -0
  100. package/src/dashboard/controllers/authController.js +316 -0
  101. package/src/dashboard/controllers/deploymentsController.js +479 -0
  102. package/src/dashboard/controllers/domainsController.js +403 -0
  103. package/src/dashboard/controllers/hubController.js +135 -0
  104. package/src/dashboard/controllers/nginxController.js +146 -0
  105. package/src/dashboard/controllers/processesController.js +368 -0
  106. package/src/dashboard/controllers/settingsController.js +503 -0
  107. package/src/dashboard/controllers/sslController.js +452 -0
  108. package/src/dashboard/lib/daemonBridge.js +163 -0
  109. package/src/dashboard/lib/localRequest.js +235 -0
  110. package/src/dashboard/lib/loginRateLimit.js +119 -0
  111. package/src/dashboard/lib/requireAuth.js +80 -0
  112. package/src/dashboard/public/img/icon.png +0 -0
  113. package/src/dashboard/public/img/icon_b.png +0 -0
  114. package/src/dashboard/public/js/app.js +595 -19
  115. package/src/dashboard/routes/auth.js +14 -33
  116. package/src/dashboard/routes/deployments.js +46 -0
  117. package/src/dashboard/routes/domains.js +20 -363
  118. package/src/dashboard/routes/hub.js +22 -0
  119. package/src/dashboard/routes/nginx.js +22 -146
  120. package/src/dashboard/routes/processes.js +29 -0
  121. package/src/dashboard/routes/settings.js +25 -232
  122. package/src/dashboard/routes/ssl.js +18 -276
  123. package/src/dashboard/server.js +279 -165
  124. package/src/dashboard/socketManager.js +246 -0
  125. package/src/dashboard/views/index.ejs +1 -0
  126. package/src/dashboard/views/partials/domain-form.ejs +64 -1
  127. package/src/dashboard/views/partials/login.ejs +69 -8
  128. package/src/dashboard/views/partials/processes-panel.ejs +261 -0
  129. package/src/dashboard/views/partials/settings-panel.ejs +549 -118
  130. package/src/dashboard/views/partials/sidebar.ejs +3 -1
  131. package/src/dashboard/lib/domains-db.js +0 -51
  132. /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, '&amp;')
22
+ .replace(/</g, '&lt;')
23
+ .replace(/>/g, '&gt;');
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
+ }