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,222 @@
1
+ /**
2
+ * Structured Event Type Factory
3
+ *
4
+ * This module provides factory functions for creating notification event objects
5
+ * with guaranteed field shapes. Used by socketManager.js for browser notifications
6
+ * and by notifier.js for external channel dispatch (Discord, Telegram, etc.).
7
+ *
8
+ * HARD CONSTRAINT: Zero imports — pure data construction, no side effects.
9
+ * This ensures the module is safe to import anywhere without pulling in
10
+ * platform-specific or heavyweight dependencies.
11
+ *
12
+ * FIELD CONTRACT (verified against notifier.js:sendNotification):
13
+ * - type: string (e.g., 'nginx_down', 'cert_expiry', 'domain_health')
14
+ * - subtype: string (optional, e.g., 'down', 'recovery')
15
+ * - message: string (human-readable description)
16
+ * - severity: 'danger' | 'warning' | 'success' | undefined
17
+ * - domain: string (optional, for domain-specific events)
18
+ * - timestamp: number (epoch ms)
19
+ * - id: string (unique event identifier)
20
+ */
21
+
22
+ /**
23
+ * Create an nginx-down notification event.
24
+ * Emitted when nginx service status shows running: false.
25
+ *
26
+ * @returns {Object} Event object with nginx-down notification data
27
+ */
28
+ export function createNginxDownEvent() {
29
+ return {
30
+ id: `nginx-down-${Date.now()}`,
31
+ type: 'nginx_down',
32
+ subtype: 'down',
33
+ severity: 'danger',
34
+ message: '🔴 Nginx is not running',
35
+ timestamp: Date.now(),
36
+ };
37
+ }
38
+
39
+ /**
40
+ * Create an nginx-recovered notification event.
41
+ * Emitted when nginx transitions from down → up.
42
+ *
43
+ * @returns {Object} Event object with nginx-recovered notification data
44
+ */
45
+ export function createNginxRecoveredEvent() {
46
+ return {
47
+ id: `nginx-recovered-${Date.now()}`,
48
+ type: 'nginx_down',
49
+ subtype: 'recovery',
50
+ severity: 'success',
51
+ message: '✅ Nginx is running again',
52
+ timestamp: Date.now(),
53
+ };
54
+ }
55
+
56
+ /**
57
+ * Create a certificate expiry notification event.
58
+ * Emitted when an SSL certificate is approaching expiration (< 30 days).
59
+ *
60
+ * @param {string} domain - The domain name for the certificate
61
+ * @param {number} daysLeft - Number of days until expiration
62
+ * @returns {Object} Event object with cert-expiry notification data
63
+ */
64
+ export function createCertExpiryEvent(domain, daysLeft, options = {}) {
65
+ const severity = daysLeft < 10 ? 'danger' : 'warning';
66
+ // A DNS-01 certificate (every wildcard is one) needs a TXT record added by
67
+ // hand, so it is never renewed automatically. Saying so in the warning is
68
+ // what stops the operator from assuming auto-renewal has it covered.
69
+ const manual = options.manualRenewal
70
+ ? ' — DNS-validated, so it must be renewed manually'
71
+ : '';
72
+ return {
73
+ id: `cert-expiry-${domain}-${Date.now()}`,
74
+ type: 'cert_expiry',
75
+ severity,
76
+ message: `🔒 SSL cert for ${domain} expires in ${daysLeft} day${daysLeft === 1 ? '' : 's'}${manual}`,
77
+ domain,
78
+ timestamp: Date.now(),
79
+ };
80
+ }
81
+
82
+ /**
83
+ * Create a certificate-renewed notification event.
84
+ * Emitted when the background job renews a certificate on its own.
85
+ *
86
+ * Shares the `cert_expiry` type so it follows the same per-domain channel
87
+ * routing as the expiry warning it resolves; `subtype` tells them apart.
88
+ *
89
+ * @param {string} domain - The domain name for the certificate
90
+ * @param {string} [summary] - One-line description of how the renewal ran
91
+ * @returns {Object} Event object with cert-renewed notification data
92
+ */
93
+ export function createCertRenewedEvent(domain, summary = '') {
94
+ return {
95
+ id: `cert-renewed-${domain}-${Date.now()}`,
96
+ type: 'cert_expiry',
97
+ subtype: 'renewed',
98
+ severity: 'success',
99
+ message: `✅ SSL cert for ${domain} was renewed automatically${summary ? ` (${summary})` : ''}`,
100
+ domain,
101
+ timestamp: Date.now(),
102
+ };
103
+ }
104
+
105
+ /**
106
+ * Create a certificate-renewal-failed notification event.
107
+ * Emitted when an automatic renewal attempt did not produce a certificate.
108
+ *
109
+ * @param {string} domain - The domain name for the certificate
110
+ * @param {number|null} daysLeft - Days until the current certificate expires
111
+ * @param {string} reason - Why the attempt failed
112
+ * @returns {Object} Event object with cert-renew-failed notification data
113
+ */
114
+ export function createCertRenewFailedEvent(domain, daysLeft, reason) {
115
+ const left = typeof daysLeft === 'number'
116
+ ? ` (${daysLeft} day${daysLeft === 1 ? '' : 's'} left)`
117
+ : '';
118
+ return {
119
+ id: `cert-renew-failed-${domain}-${Date.now()}`,
120
+ type: 'cert_expiry',
121
+ subtype: 'renew_failed',
122
+ severity: 'danger',
123
+ message: `🔴 Automatic SSL renewal failed for ${domain}${left}: ${reason}`,
124
+ domain,
125
+ timestamp: Date.now(),
126
+ };
127
+ }
128
+
129
+ /**
130
+ * Create a deployment notification event.
131
+ * Emitted by core/deploy/engine.js when a deployment or a rollback finishes.
132
+ *
133
+ * @param {string} app - The app id
134
+ * @param {'success'|'failed'|'rolled_back'} outcome
135
+ * @param {Object} [detail]
136
+ * @param {string} [detail.sha] - Commit that was deployed (shortened in the message)
137
+ * @param {string} [detail.reason] - Why it failed, when it did
138
+ * @param {boolean} [detail.rollback] - True when the run itself was a manual rollback
139
+ * @returns {Object} Event object with deployment notification data
140
+ */
141
+ export function createDeployEvent(app, outcome, detail = {}) {
142
+ const short = detail.sha ? ` (${String(detail.sha).slice(0, 7)})` : '';
143
+ const what = detail.rollback ? 'Rollback of' : 'Deployment of';
144
+
145
+ let severity = 'success';
146
+ let message = `🚀 ${what} ${app}${short} succeeded`;
147
+
148
+ if (outcome === 'rolled_back') {
149
+ severity = 'warning';
150
+ message = `↩️ Deployment of ${app}${short} failed and the previous release was restored`;
151
+ } else if (outcome === 'failed') {
152
+ severity = 'danger';
153
+ message = `🔴 ${what} ${app}${short} failed`;
154
+ }
155
+ if (outcome !== 'success' && detail.reason) message += `: ${detail.reason}`;
156
+
157
+ return {
158
+ id: `deploy-${app}-${Date.now()}`,
159
+ type: 'deploy',
160
+ subtype: outcome,
161
+ severity,
162
+ message,
163
+ app,
164
+ timestamp: Date.now(),
165
+ };
166
+ }
167
+
168
+ /**
169
+ * Create a domain health DOWN notification event.
170
+ * Emitted when a domain backend health check fails.
171
+ *
172
+ * @param {string} domain - The domain name
173
+ * @param {number} port - The backend port
174
+ * @returns {Object} Event object with domain health notification data
175
+ */
176
+ export function createDomainDownEvent(domain, port) {
177
+ return {
178
+ id: `domain-down-${domain}-${Date.now()}`,
179
+ type: 'domain_health',
180
+ subtype: 'down',
181
+ severity: 'danger',
182
+ message: `🔴 ${domain} (port ${port}) is not responding`,
183
+ domain,
184
+ timestamp: Date.now(),
185
+ };
186
+ }
187
+
188
+ /**
189
+ * Create a domain health RECOVERY notification event.
190
+ * Emitted when a domain backend transitions from down → up.
191
+ *
192
+ * @param {string} domain - The domain name
193
+ * @param {number} port - The backend port
194
+ * @returns {Object} Event object with domain recovery notification data
195
+ */
196
+ export function createDomainRecoveredEvent(domain, port) {
197
+ return {
198
+ id: `domain-recovered-${domain}-${Date.now()}`,
199
+ type: 'domain_health',
200
+ subtype: 'recovery',
201
+ severity: 'success',
202
+ message: `✅ ${domain} (port ${port}) is back online`,
203
+ domain,
204
+ timestamp: Date.now(),
205
+ };
206
+ }
207
+
208
+ /**
209
+ * Create a domain health notification event (legacy wrapper).
210
+ * Emitted when a domain backend health check passes or fails.
211
+ * DEPRECATED: Use createDomainDownEvent or createDomainRecoveredEvent instead.
212
+ *
213
+ * @param {string} domain - The domain name
214
+ * @param {boolean} up - Whether the domain backend is responding
215
+ * @returns {Object} Event object with domain health notification data
216
+ */
217
+ export function createDomainHealthEvent(domain, up) {
218
+ if (up) {
219
+ return createDomainRecoveredEvent(domain, '?');
220
+ }
221
+ return createDomainDownEvent(domain, '?');
222
+ }