vps-deployer 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/LICENSE +21 -0
- package/README.md +151 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +39 -0
- package/dist/app.js.map +1 -0
- package/dist/db/db.d.ts +5 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +100 -0
- package/dist/db/db.js.map +1 -0
- package/dist/helpers/arg.helper.d.ts +7 -0
- package/dist/helpers/arg.helper.d.ts.map +1 -0
- package/dist/helpers/arg.helper.js +28 -0
- package/dist/helpers/arg.helper.js.map +1 -0
- package/dist/helpers/cmd_executer.helper.d.ts +7 -0
- package/dist/helpers/cmd_executer.helper.d.ts.map +1 -0
- package/dist/helpers/cmd_executer.helper.js +88 -0
- package/dist/helpers/cmd_executer.helper.js.map +1 -0
- package/dist/helpers/common.helper.d.ts +2 -0
- package/dist/helpers/common.helper.d.ts.map +1 -0
- package/dist/helpers/common.helper.js +15 -0
- package/dist/helpers/common.helper.js.map +1 -0
- package/dist/helpers/config_files.helper.d.ts +2 -0
- package/dist/helpers/config_files.helper.d.ts.map +1 -0
- package/dist/helpers/config_files.helper.js +44 -0
- package/dist/helpers/config_files.helper.js.map +1 -0
- package/dist/helpers/create_systemd_service.helper.d.ts +9 -0
- package/dist/helpers/create_systemd_service.helper.d.ts.map +1 -0
- package/dist/helpers/create_systemd_service.helper.js +40 -0
- package/dist/helpers/create_systemd_service.helper.js.map +1 -0
- package/dist/helpers/date.helper.d.ts +2 -0
- package/dist/helpers/date.helper.d.ts.map +1 -0
- package/dist/helpers/date.helper.js +18 -0
- package/dist/helpers/date.helper.js.map +1 -0
- package/dist/helpers/email.helper.d.ts +11 -0
- package/dist/helpers/email.helper.d.ts.map +1 -0
- package/dist/helpers/email.helper.js +144 -0
- package/dist/helpers/email.helper.js.map +1 -0
- package/dist/helpers/logging.helper.d.ts +9 -0
- package/dist/helpers/logging.helper.d.ts.map +1 -0
- package/dist/helpers/logging.helper.js +32 -0
- package/dist/helpers/logging.helper.js.map +1 -0
- package/dist/helpers/remove_systemd_service.helper.d.ts +2 -0
- package/dist/helpers/remove_systemd_service.helper.d.ts.map +1 -0
- package/dist/helpers/remove_systemd_service.helper.js +21 -0
- package/dist/helpers/remove_systemd_service.helper.js.map +1 -0
- package/dist/helpers/start_systemd_service.helper.d.ts +2 -0
- package/dist/helpers/start_systemd_service.helper.d.ts.map +1 -0
- package/dist/helpers/start_systemd_service.helper.js +26 -0
- package/dist/helpers/start_systemd_service.helper.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +132 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/auth.middleware.d.ts +3 -0
- package/dist/middleware/auth.middleware.d.ts.map +1 -0
- package/dist/middleware/auth.middleware.js +7 -0
- package/dist/middleware/auth.middleware.js.map +1 -0
- package/dist/modules/auth/auth.route.d.ts +3 -0
- package/dist/modules/auth/auth.route.d.ts.map +1 -0
- package/dist/modules/auth/auth.route.js +16 -0
- package/dist/modules/auth/auth.route.js.map +1 -0
- package/dist/modules/auth/controllers/auth.controller.d.ts +6 -0
- package/dist/modules/auth/controllers/auth.controller.d.ts.map +1 -0
- package/dist/modules/auth/controllers/auth.controller.js +123 -0
- package/dist/modules/auth/controllers/auth.controller.js.map +1 -0
- package/dist/modules/auth/views/login.pug +254 -0
- package/dist/modules/auth/views/register.pug +298 -0
- package/dist/modules/common/views/404.pug +21 -0
- package/dist/modules/dashboard/dashboard.route.d.ts +3 -0
- package/dist/modules/dashboard/dashboard.route.d.ts.map +1 -0
- package/dist/modules/dashboard/dashboard.route.js +29 -0
- package/dist/modules/dashboard/dashboard.route.js.map +1 -0
- package/dist/modules/dashboard/views/dash.pug +149 -0
- package/dist/modules/dashboard/views/layout.pug +94 -0
- package/dist/modules/deployer/controllers/deployer.controller.d.ts +6 -0
- package/dist/modules/deployer/controllers/deployer.controller.d.ts.map +1 -0
- package/dist/modules/deployer/controllers/deployer.controller.js +119 -0
- package/dist/modules/deployer/controllers/deployer.controller.js.map +1 -0
- package/dist/modules/deployer/deployer.route.d.ts +3 -0
- package/dist/modules/deployer/deployer.route.d.ts.map +1 -0
- package/dist/modules/deployer/deployer.route.js +13 -0
- package/dist/modules/deployer/deployer.route.js.map +1 -0
- package/dist/modules/deployer/helper/deployer.d.ts +9 -0
- package/dist/modules/deployer/helper/deployer.d.ts.map +1 -0
- package/dist/modules/deployer/helper/deployer.js +89 -0
- package/dist/modules/deployer/helper/deployer.js.map +1 -0
- package/dist/modules/deployer/views/details.pug +157 -0
- package/dist/modules/deployer/views/index.pug +108 -0
- package/dist/modules/project/controllers/projects.controller.d.ts +12 -0
- package/dist/modules/project/controllers/projects.controller.d.ts.map +1 -0
- package/dist/modules/project/controllers/projects.controller.js +267 -0
- package/dist/modules/project/controllers/projects.controller.js.map +1 -0
- package/dist/modules/project/helper/project_file_sys.helper.d.ts +7 -0
- package/dist/modules/project/helper/project_file_sys.helper.d.ts.map +1 -0
- package/dist/modules/project/helper/project_file_sys.helper.js +93 -0
- package/dist/modules/project/helper/project_file_sys.helper.js.map +1 -0
- package/dist/modules/project/project.route.d.ts +3 -0
- package/dist/modules/project/project.route.d.ts.map +1 -0
- package/dist/modules/project/project.route.js +17 -0
- package/dist/modules/project/project.route.js.map +1 -0
- package/dist/modules/project/views/create.pug +189 -0
- package/dist/modules/project/views/details.pug +238 -0
- package/dist/modules/project/views/index.pug +114 -0
- package/dist/modules/settings/controllers/setting.controller.d.ts +5 -0
- package/dist/modules/settings/controllers/setting.controller.d.ts.map +1 -0
- package/dist/modules/settings/controllers/setting.controller.js +193 -0
- package/dist/modules/settings/controllers/setting.controller.js.map +1 -0
- package/dist/modules/settings/settings.route.d.ts +3 -0
- package/dist/modules/settings/settings.route.d.ts.map +1 -0
- package/dist/modules/settings/settings.route.js +10 -0
- package/dist/modules/settings/settings.route.js.map +1 -0
- package/dist/modules/settings/views/index.pug +173 -0
- package/dist/modules/webhook/controllers/webhook.controller.d.ts +3 -0
- package/dist/modules/webhook/controllers/webhook.controller.d.ts.map +1 -0
- package/dist/modules/webhook/controllers/webhook.controller.js +72 -0
- package/dist/modules/webhook/controllers/webhook.controller.js.map +1 -0
- package/dist/modules/webhook/webhook.route.d.ts +3 -0
- package/dist/modules/webhook/webhook.route.d.ts.map +1 -0
- package/dist/modules/webhook/webhook.route.js +6 -0
- package/dist/modules/webhook/webhook.route.js.map +1 -0
- package/dist/utils/app_config.d.ts +3 -0
- package/dist/utils/app_config.d.ts.map +1 -0
- package/dist/utils/app_config.js +5 -0
- package/dist/utils/app_config.js.map +1 -0
- package/dist/utils/cli.d.ts +2 -0
- package/dist/utils/cli.d.ts.map +1 -0
- package/dist/utils/cli.js +68 -0
- package/dist/utils/cli.js.map +1 -0
- package/package.json +80 -0
- package/public/favicon.svg +18 -0
- package/public/js/deploy.js +36 -0
- package/public/js/deployment-details.js +56 -0
- package/public/js/login.js +21 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import nodemailer from "nodemailer";
|
|
2
|
+
import { getDB } from "../../../db/db.js";
|
|
3
|
+
import { convertDateToIST } from "../../../helpers/date.helper.js";
|
|
4
|
+
export const viewSettings = (_req, res) => {
|
|
5
|
+
const db = getDB();
|
|
6
|
+
const user = db.prepare("SELECT * FROM user LIMIT 1").get();
|
|
7
|
+
const email = db.prepare("SELECT * FROM email LIMIT 1").get();
|
|
8
|
+
return res.render("settings/views/index", {
|
|
9
|
+
user: user || {},
|
|
10
|
+
email: email || {},
|
|
11
|
+
convertDateToIST,
|
|
12
|
+
active: "settings",
|
|
13
|
+
error: null,
|
|
14
|
+
success: null,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
// UPSERT EMAIL CONFIG
|
|
18
|
+
export const upsertEmail = (req, res) => {
|
|
19
|
+
const { username, password, smtp, smtp_port, from } = req.body;
|
|
20
|
+
const db = getDB();
|
|
21
|
+
try {
|
|
22
|
+
const existing = db.prepare("SELECT id FROM email LIMIT 1").get();
|
|
23
|
+
if (existing) {
|
|
24
|
+
db.prepare(`
|
|
25
|
+
UPDATE email
|
|
26
|
+
SET username=?, password=?, smtp=?, smtp_port=?, "from"=?
|
|
27
|
+
`).run(username, password, smtp, smtp_port, from);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
db.prepare(`
|
|
31
|
+
INSERT INTO email (username, password, smtp, smtp_port, "from")
|
|
32
|
+
VALUES (?, ?, ?, ?, ?)
|
|
33
|
+
`).run(username, password, smtp, smtp_port, from);
|
|
34
|
+
}
|
|
35
|
+
const user = db.prepare("SELECT * FROM user LIMIT 1").get();
|
|
36
|
+
const emailData = db.prepare("SELECT * FROM email LIMIT 1").get();
|
|
37
|
+
return res.render("settings/views/index", {
|
|
38
|
+
user: user || {},
|
|
39
|
+
email: emailData || {},
|
|
40
|
+
convertDateToIST,
|
|
41
|
+
active: "settings",
|
|
42
|
+
success: "Email settings saved successfully",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const user = db.prepare("SELECT * FROM user LIMIT 1").get();
|
|
47
|
+
const emailData = db.prepare("SELECT * FROM email LIMIT 1").get();
|
|
48
|
+
return res.render("settings/views/index", {
|
|
49
|
+
user: user || {},
|
|
50
|
+
email: emailData || {},
|
|
51
|
+
convertDateToIST,
|
|
52
|
+
active: "settings",
|
|
53
|
+
error: error.message || "Failed to save email settings",
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
// TEST EMAIL
|
|
58
|
+
export const sendTestEmail = async (_req, res) => {
|
|
59
|
+
const db = getDB();
|
|
60
|
+
const emailConfig = db.prepare("SELECT * FROM email LIMIT 1").get();
|
|
61
|
+
const user = db.prepare("SELECT * FROM user LIMIT 1").get();
|
|
62
|
+
if (!emailConfig || !user) {
|
|
63
|
+
return res.render("settings/views/index", {
|
|
64
|
+
user: user || {},
|
|
65
|
+
email: emailConfig || {},
|
|
66
|
+
convertDateToIST,
|
|
67
|
+
active: "settings",
|
|
68
|
+
error: "Email settings not configured",
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const transporter = nodemailer.createTransport({
|
|
73
|
+
host: emailConfig.smtp,
|
|
74
|
+
port: emailConfig.smtp_port,
|
|
75
|
+
secure: false,
|
|
76
|
+
auth: {
|
|
77
|
+
user: emailConfig.username,
|
|
78
|
+
pass: emailConfig.password,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
await transporter.sendMail({
|
|
82
|
+
from: emailConfig.from,
|
|
83
|
+
to: user.email,
|
|
84
|
+
subject: "Test Email - VPS Deployer",
|
|
85
|
+
html: `<!DOCTYPE html>
|
|
86
|
+
<html>
|
|
87
|
+
<head>
|
|
88
|
+
<meta charset="UTF-8">
|
|
89
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
90
|
+
<title>VPS Deployer - Test Email</title>
|
|
91
|
+
</head>
|
|
92
|
+
<body style="margin: 0; padding: 0; background-color: #f5f7fa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;">
|
|
93
|
+
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: #f5f7fa;">
|
|
94
|
+
<tr>
|
|
95
|
+
<td align="center" style="padding: 40px 20px;">
|
|
96
|
+
<!-- Main Container -->
|
|
97
|
+
<table width="100%" max-width="500" cellpadding="0" cellspacing="0" border="0" style="max-width: 500px; width: 100%; background-color: #ffffff; border-radius: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);">
|
|
98
|
+
|
|
99
|
+
<!-- Header with SVG Logo -->
|
|
100
|
+
<tr>
|
|
101
|
+
<td align="center" style="padding: 40px 40px 20px 40px;">
|
|
102
|
+
<h1 style="margin: 20px 0 0 0; font-size: 24px; font-weight: 600; color: #1a1f36;">VPS Deployer</h1>
|
|
103
|
+
<p style="margin: 8px 0 0 0; font-size: 14px; color: #6c757d;">Test Email</p>
|
|
104
|
+
</td>
|
|
105
|
+
</tr>
|
|
106
|
+
|
|
107
|
+
<!-- Divider -->
|
|
108
|
+
<tr>
|
|
109
|
+
<td align="center" style="padding: 0 40px;">
|
|
110
|
+
<hr style="border: none; height: 1px; background-color: #e9ecef; margin: 0;">
|
|
111
|
+
</td>
|
|
112
|
+
</tr>
|
|
113
|
+
|
|
114
|
+
<!-- Body Content -->
|
|
115
|
+
<tr>
|
|
116
|
+
<td style="padding: 30px 40px;">
|
|
117
|
+
<p style="margin: 0 0 10px 0; font-size: 16px; color: #1a1f36; line-height: 1.5;">
|
|
118
|
+
Hello <strong style="color: #0066ff;">${user.username}</strong>,
|
|
119
|
+
</p>
|
|
120
|
+
|
|
121
|
+
<p style="margin: 0 0 20px 0; font-size: 15px; color: #4a5568; line-height: 1.6;">
|
|
122
|
+
This is a test email from <strong>VPS Deployer</strong>. Your email configuration is working correctly!
|
|
123
|
+
</p>
|
|
124
|
+
|
|
125
|
+
<!-- Success Checkmark -->
|
|
126
|
+
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: #f0f9f0; border-radius: 8px; border-left: 4px solid #10b981;">
|
|
127
|
+
<tr>
|
|
128
|
+
<td style="padding: 16px 20px;">
|
|
129
|
+
<table cellpadding="0" cellspacing="0" border="0">
|
|
130
|
+
<tr>
|
|
131
|
+
<td style="vertical-align: middle;">
|
|
132
|
+
<span style="font-size: 20px; margin-right: 12px;">✅</span>
|
|
133
|
+
</td>
|
|
134
|
+
<td style="vertical-align: middle;">
|
|
135
|
+
<span style="font-size: 14px; color: #0a6e2f; font-weight: 500;">Email configuration verified successfully!</span>
|
|
136
|
+
</td>
|
|
137
|
+
</tr>
|
|
138
|
+
</table>
|
|
139
|
+
</td>
|
|
140
|
+
</tr>
|
|
141
|
+
</table>
|
|
142
|
+
</td>
|
|
143
|
+
</tr>
|
|
144
|
+
|
|
145
|
+
<!-- Divider -->
|
|
146
|
+
<tr>
|
|
147
|
+
<td align="center" style="padding: 0 40px;">
|
|
148
|
+
<hr style="border: none; height: 1px; background-color: #e9ecef; margin: 0;">
|
|
149
|
+
</td>
|
|
150
|
+
</tr>
|
|
151
|
+
|
|
152
|
+
<!-- Footer -->
|
|
153
|
+
<tr>
|
|
154
|
+
<td style="padding: 25px 40px 35px 40px;">
|
|
155
|
+
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
|
156
|
+
<tr>
|
|
157
|
+
<td align="center">
|
|
158
|
+
<p style="margin: 0 0 8px 0; font-size: 12px; color: #9ca3af;">
|
|
159
|
+
VPS Deployer — Deployment Made Easy
|
|
160
|
+
</p>
|
|
161
|
+
|
|
162
|
+
</td>
|
|
163
|
+
</tr>
|
|
164
|
+
</table>
|
|
165
|
+
</td>
|
|
166
|
+
</tr>
|
|
167
|
+
|
|
168
|
+
</table>
|
|
169
|
+
</td>
|
|
170
|
+
</tr>
|
|
171
|
+
</table>
|
|
172
|
+
</body>
|
|
173
|
+
</html>`,
|
|
174
|
+
});
|
|
175
|
+
return res.render("settings/views/index", {
|
|
176
|
+
user: user || {},
|
|
177
|
+
email: emailConfig || {},
|
|
178
|
+
convertDateToIST,
|
|
179
|
+
active: "settings",
|
|
180
|
+
success: "Test email sent successfully",
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
catch (err) {
|
|
184
|
+
return res.render("settings/views/index", {
|
|
185
|
+
user: user || {},
|
|
186
|
+
email: emailConfig || {},
|
|
187
|
+
convertDateToIST,
|
|
188
|
+
active: "settings",
|
|
189
|
+
error: err.message || "Failed to send test email",
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=setting.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setting.controller.js","sourceRoot":"","sources":["../../../../src/modules/settings/controllers/setting.controller.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,E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B,gBAAgB;YAChB,MAAM,EAAE,UAAU;YAClB,KAAK,EAAE,GAAG,CAAC,OAAO,IAAI,2BAA2B;SAClD,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.route.d.ts","sourceRoot":"","sources":["../../../src/modules/settings/settings.route.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,MAAM,4CAAW,CAAC;AAQxB,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import { viewSettings, upsertEmail, sendTestEmail, } from "./controllers/setting.controller.js";
|
|
3
|
+
import { requireAuth } from "../../middleware/auth.middleware.js";
|
|
4
|
+
const router = Router();
|
|
5
|
+
router.use(requireAuth);
|
|
6
|
+
router.get("/settings", viewSettings);
|
|
7
|
+
router.post("/settings/email", upsertEmail);
|
|
8
|
+
router.post("/settings/email/test", sendTestEmail);
|
|
9
|
+
export default router;
|
|
10
|
+
//# sourceMappingURL=settings.route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.route.js","sourceRoot":"","sources":["../../../src/modules/settings/settings.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EACL,YAAY,EACZ,WAAW,EACX,aAAa,GACd,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;AAExB,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAExB,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AACtC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;AAC5C,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE,aAAa,CAAC,CAAC;AAEnD,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
extends ../../dashboard/views/layout.pug
|
|
2
|
+
|
|
3
|
+
block content
|
|
4
|
+
// Page Header
|
|
5
|
+
.d-flex.justify-content-between.align-items-center.mb-4
|
|
6
|
+
div
|
|
7
|
+
h2.mb-1 Settings
|
|
8
|
+
p.text-muted.mb-0 Manage your account and email configuration
|
|
9
|
+
div
|
|
10
|
+
i.bi.bi-gear.text-muted(style="font-size: 1.5rem;")
|
|
11
|
+
|
|
12
|
+
// Flash Messages
|
|
13
|
+
if error
|
|
14
|
+
.alert.alert-danger.alert-dismissible.fade-show.d-flex.align-items-center.mb-4(role="alert")
|
|
15
|
+
i.bi.bi-exclamation-triangle-fill.me-2
|
|
16
|
+
span.flex-grow-1 #{error}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if success
|
|
20
|
+
.alert.alert-success.alert-dismissible.fade-show.d-flex.align-items-center.mb-4(role="alert")
|
|
21
|
+
i.bi.bi-check-circle-fill.me-2
|
|
22
|
+
span.flex-grow-1 #{success}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
.row
|
|
26
|
+
.col-lg-6.mb-4
|
|
27
|
+
// ================= USER INFO =================
|
|
28
|
+
.card.border-0.shadow-sm.h-100
|
|
29
|
+
.card-header.bg-white.border-bottom-0.pt-3
|
|
30
|
+
.d-flex.align-items-center
|
|
31
|
+
i.bi.bi-person-circle.text-primary.me-2(style="font-size: 1.25rem;")
|
|
32
|
+
h5.mb-0 User Details
|
|
33
|
+
.card-body
|
|
34
|
+
.mb-3.pb-2.border-bottom
|
|
35
|
+
.d-flex.justify-content-between
|
|
36
|
+
small.text-muted Username
|
|
37
|
+
strong.text-dark #{user.username}
|
|
38
|
+
.mb-3.pb-2.border-bottom
|
|
39
|
+
.d-flex.justify-content-between
|
|
40
|
+
small.text-muted Email
|
|
41
|
+
strong.text-dark #{user.email}
|
|
42
|
+
.mb-3.pb-2.border-bottom
|
|
43
|
+
.d-flex.justify-content-between
|
|
44
|
+
small.text-muted Created At
|
|
45
|
+
strong.text-dark #{convertDateToIST(user.created_at)}
|
|
46
|
+
.mb-3
|
|
47
|
+
.d-flex.justify-content-between
|
|
48
|
+
small.text-muted Last Logged In
|
|
49
|
+
strong.text-dark #{convertDateToIST(user.last_logged_in)}
|
|
50
|
+
|
|
51
|
+
.col-lg-6.mb-4
|
|
52
|
+
// ================= QUICK ACTIONS =================
|
|
53
|
+
.card.border-0.shadow-sm.h-100
|
|
54
|
+
.card-header.bg-white.border-bottom-0.pt-3
|
|
55
|
+
.d-flex.align-items-center
|
|
56
|
+
i.bi.bi-envelope-paper.text-primary.me-2(style="font-size: 1.25rem;")
|
|
57
|
+
h5.mb-0 Email Actions
|
|
58
|
+
.card-body.d-flex.align-items-center.justify-content-center.flex-column
|
|
59
|
+
form(method="POST", action="/settings/email/test", style="width: 100%;")
|
|
60
|
+
button.btn.btn-outline-success.w-100(type="submit")
|
|
61
|
+
i.bi.bi-envelope-paper-fill.me-2
|
|
62
|
+
| Send Test Email
|
|
63
|
+
small.text-muted.mt-3.d-block.text-center Verify your email configuration
|
|
64
|
+
|
|
65
|
+
// ================= EMAIL CONFIG =================
|
|
66
|
+
.card.border-0.shadow-sm
|
|
67
|
+
.card-header.bg-white.border-bottom-0.pt-3
|
|
68
|
+
.d-flex.align-items-center
|
|
69
|
+
i.bi.bi-envelope-gear.text-primary.me-2(style="font-size: 1.25rem;")
|
|
70
|
+
h5.mb-0 Email Configuration
|
|
71
|
+
.card-body
|
|
72
|
+
form(method="POST", action="/settings/email")
|
|
73
|
+
.row
|
|
74
|
+
.col-md-6.mb-3
|
|
75
|
+
label.form-label.fw-semibold(for="email-username")
|
|
76
|
+
i.bi.bi-person.me-1
|
|
77
|
+
| Username
|
|
78
|
+
input.form-control(
|
|
79
|
+
type="text",
|
|
80
|
+
id="email-username",
|
|
81
|
+
name="username",
|
|
82
|
+
value=email.username,
|
|
83
|
+
placeholder="smtp username"
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
.col-md-6.mb-3
|
|
87
|
+
label.form-label.fw-semibold(for="email-password")
|
|
88
|
+
i.bi.bi-lock.me-1
|
|
89
|
+
| Password
|
|
90
|
+
input.form-control(
|
|
91
|
+
type="password",
|
|
92
|
+
id="email-password",
|
|
93
|
+
name="password",
|
|
94
|
+
value=email.password,
|
|
95
|
+
placeholder="••••••••"
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
.row
|
|
99
|
+
.col-md-6.mb-3
|
|
100
|
+
label.form-label.fw-semibold(for="email-smtp")
|
|
101
|
+
i.bi.bi-server.me-1
|
|
102
|
+
| SMTP Host
|
|
103
|
+
input.form-control(
|
|
104
|
+
type="text",
|
|
105
|
+
id="email-smtp",
|
|
106
|
+
name="smtp",
|
|
107
|
+
value=email.smtp,
|
|
108
|
+
placeholder="smtp.gmail.com"
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
.col-md-6.mb-3
|
|
112
|
+
label.form-label.fw-semibold(for="email-port")
|
|
113
|
+
i.bi.bi-plug.me-1
|
|
114
|
+
| SMTP Port
|
|
115
|
+
input.form-control(
|
|
116
|
+
type="number",
|
|
117
|
+
id="email-port",
|
|
118
|
+
name="smtp_port",
|
|
119
|
+
value=email.smtp_port,
|
|
120
|
+
placeholder="587"
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
.mb-3
|
|
124
|
+
label.form-label.fw-semibold(for="email-from")
|
|
125
|
+
i.bi.bi-envelope.me-1
|
|
126
|
+
| From Email
|
|
127
|
+
input.form-control(
|
|
128
|
+
type="text",
|
|
129
|
+
id="email-from",
|
|
130
|
+
name="from",
|
|
131
|
+
value=email.from,
|
|
132
|
+
placeholder="noreply@example.com"
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
hr.my-4
|
|
136
|
+
|
|
137
|
+
.d-flex.justify-content-end
|
|
138
|
+
button.btn.btn-primary(type="submit")
|
|
139
|
+
i.bi.bi-save.me-2
|
|
140
|
+
| Save Configuration
|
|
141
|
+
|
|
142
|
+
// Additional styles
|
|
143
|
+
style.
|
|
144
|
+
.card {
|
|
145
|
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.card:hover {
|
|
149
|
+
transform: translateY(-2px);
|
|
150
|
+
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08) !important;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.form-control:focus {
|
|
154
|
+
border-color: #0066ff;
|
|
155
|
+
box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.alert {
|
|
159
|
+
border-radius: 8px;
|
|
160
|
+
border: none;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.alert-danger {
|
|
164
|
+
background: #fff5f5;
|
|
165
|
+
color: #c62828;
|
|
166
|
+
border-left: 4px solid #c62828;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.alert-success {
|
|
170
|
+
background: #f0f9f0;
|
|
171
|
+
color: #2e7d32;
|
|
172
|
+
border-left: 4px solid #2e7d32;
|
|
173
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.controller.d.ts","sourceRoot":"","sources":["../../../../src/modules/webhook/controllers/webhook.controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMjD,eAAO,MAAM,aAAa,GAAI,KAAK,OAAO,EAAE,KAAK,QAAQ,uCA4FxD,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
import { getDB } from "../../../db/db.js";
|
|
3
|
+
import { triggerDeployment } from "../../deployer/helper/deployer.js";
|
|
4
|
+
import { sendDeploymentEmail } from "../../../helpers/email.helper.js";
|
|
5
|
+
export const githubWebhook = (req, res) => {
|
|
6
|
+
const signature = req.headers["x-hub-signature-256"];
|
|
7
|
+
const event = req.headers["x-github-event"];
|
|
8
|
+
if (!signature) {
|
|
9
|
+
return res.status(401).send("Missing signature");
|
|
10
|
+
}
|
|
11
|
+
const payload = JSON.stringify(req.body);
|
|
12
|
+
const db = getDB();
|
|
13
|
+
// get project using webhook (we assume route has projectId)
|
|
14
|
+
const { projectId } = req.params;
|
|
15
|
+
const project = db
|
|
16
|
+
.prepare(`SELECT * FROM project WHERE id = ?`)
|
|
17
|
+
.get(projectId);
|
|
18
|
+
if (!project) {
|
|
19
|
+
return res.status(404).send("Project not found");
|
|
20
|
+
}
|
|
21
|
+
// verify signature
|
|
22
|
+
const expected = `sha256=` +
|
|
23
|
+
crypto
|
|
24
|
+
.createHmac("sha256", project.webhook_secret)
|
|
25
|
+
.update(payload)
|
|
26
|
+
.digest("hex");
|
|
27
|
+
if (!crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))) {
|
|
28
|
+
return res.status(401).send("Invalid signature");
|
|
29
|
+
}
|
|
30
|
+
// only handle push events
|
|
31
|
+
if (event !== "push") {
|
|
32
|
+
return res.status(200).send("Ignored");
|
|
33
|
+
}
|
|
34
|
+
const branch = req.body.ref?.replace("refs/heads/", "");
|
|
35
|
+
if (branch !== project.branch_name) {
|
|
36
|
+
return res.status(200).send("Branch mismatch, ignored");
|
|
37
|
+
}
|
|
38
|
+
// check auto deploy
|
|
39
|
+
if (project.auto_deploy !== 1) {
|
|
40
|
+
return res.status(200).send("Auto deploy disabled");
|
|
41
|
+
}
|
|
42
|
+
// create deployment
|
|
43
|
+
const deployId = crypto.randomUUID();
|
|
44
|
+
db.prepare(`
|
|
45
|
+
INSERT INTO deployment (id, proj_id, status)
|
|
46
|
+
VALUES (?, ?, 'running')
|
|
47
|
+
`).run(deployId, project.id);
|
|
48
|
+
// get commands
|
|
49
|
+
const commands = db
|
|
50
|
+
.prepare(`
|
|
51
|
+
SELECT cmd FROM project_commands
|
|
52
|
+
WHERE proj_id = ?
|
|
53
|
+
ORDER BY seq_no ASC
|
|
54
|
+
`)
|
|
55
|
+
.all(project.id).map((c) => c.cmd);
|
|
56
|
+
if (commands.length === 0) {
|
|
57
|
+
return res.status(400).send("No commands configured");
|
|
58
|
+
}
|
|
59
|
+
// enqueue
|
|
60
|
+
triggerDeployment(deployId, project.id, commands);
|
|
61
|
+
if (project.receive_email_notf === 1) {
|
|
62
|
+
sendDeploymentEmail({
|
|
63
|
+
project,
|
|
64
|
+
deployId,
|
|
65
|
+
branch,
|
|
66
|
+
commit: req.body.head_commit?.message || "No message",
|
|
67
|
+
author: req.body.head_commit?.author?.name || "Unknown",
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return res.status(200).send("Deployment triggered");
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=webhook.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.controller.js","sourceRoot":"","sources":["../../../../src/modules/webhook/controllers/webhook.controller.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;IAC3D,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAW,CAAC;IAC/D,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAW,CAAC;IAEtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI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ook.route.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,4CAAW,CAAA;AAIvB,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.route.js","sourceRoot":"","sources":["../../../src/modules/webhook/webhook.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEpE,MAAM,MAAM,GAAG,MAAM,EAAE,CAAA;AAEvB,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,aAAa,CAAC,CAAC;AAElD,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app_config.d.ts","sourceRoot":"","sources":["../../src/utils/app_config.ts"],"names":[],"mappings":";AAQA,wBAAwC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app_config.js","sourceRoot":"","sources":["../../src/utils/app_config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,UAAU,GAAG,EAElB,CAAA;AAED,eAAe,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,OAAO,QAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAC,UAAU,EAAC,MAAM,EAAC,KAAK,EAAC,OAAO,EAAC,QAAQ,EAAE,OAAO,CA2DvG,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { removeSystemdService } from "../helpers/remove_systemd_service.helper.js";
|
|
4
|
+
import { startSystemdService } from "../helpers/start_systemd_service.helper.js";
|
|
5
|
+
const checkDirExists = (dirPath) => {
|
|
6
|
+
return fs.existsSync(dirPath);
|
|
7
|
+
};
|
|
8
|
+
const checkArgsValidation = (path, port, sessionKey) => {
|
|
9
|
+
if (sessionKey.trim().length <= 6)
|
|
10
|
+
throw new Error('Session key length should be >=6');
|
|
11
|
+
const pathExists = checkDirExists(path);
|
|
12
|
+
if (!pathExists)
|
|
13
|
+
throw new Error(`given DIR:${path} dosent exists, make sure you create it before calling the tool`);
|
|
14
|
+
if (Number.isNaN(port) || port >= 50000 || port <= 1024)
|
|
15
|
+
throw new Error(`${port} is not a valid port curr limitation is 1024-50000.`);
|
|
16
|
+
};
|
|
17
|
+
export const getArgs = () => {
|
|
18
|
+
const program = new Command();
|
|
19
|
+
program
|
|
20
|
+
.description("a utility that helps u auto deploy things")
|
|
21
|
+
.version("1.0.0")
|
|
22
|
+
.requiredOption("-w, --working-dir <dir>", "sets the working directory where all the projects will be fetched")
|
|
23
|
+
.requiredOption("-p, --port <port>", "sets the port of the server")
|
|
24
|
+
.requiredOption("-s, --session-key <sessKey>", "sets the session key of the server")
|
|
25
|
+
.option("--dev", "run in development mode (foreground, no systemd)")
|
|
26
|
+
.addOption(new Option('--daemon').hideHelp())
|
|
27
|
+
.action(() => { });
|
|
28
|
+
program
|
|
29
|
+
.command("start")
|
|
30
|
+
.description("enable and start the vps-deployer systemd service (runs as daemon)")
|
|
31
|
+
.action(() => {
|
|
32
|
+
if (process.getuid && process.getuid() !== 0) {
|
|
33
|
+
console.error("This command must be run as root. Use sudo.");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
startSystemdService("vps-deployer");
|
|
38
|
+
console.log("vps-deployer service started. Check logs: journalctl -u vps-deployer -f");
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.error(`Failed to start service: ${err.message}`);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
program
|
|
47
|
+
.command("uninstall")
|
|
48
|
+
.description("stop, disable, and remove the vps-deployer systemd service [Dosen't delete the working folder]")
|
|
49
|
+
.action(() => {
|
|
50
|
+
if (process.getuid && process.getuid() !== 0) {
|
|
51
|
+
console.error("This command must be run as root. Use sudo.");
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
removeSystemdService("vps-deployer");
|
|
55
|
+
console.log("vps-deployer service removed.");
|
|
56
|
+
process.exit(0);
|
|
57
|
+
});
|
|
58
|
+
program.parse();
|
|
59
|
+
const requiredOptions = program.opts();
|
|
60
|
+
const workingDir = requiredOptions["workingDir"].toString();
|
|
61
|
+
const port = Number.parseInt(requiredOptions["port"], 10);
|
|
62
|
+
const sessionKey = requiredOptions['sessionKey'].toString();
|
|
63
|
+
const isDev = requiredOptions.dev ?? false;
|
|
64
|
+
const isDaemon = requiredOptions.daemon ?? false;
|
|
65
|
+
checkArgsValidation(workingDir, port, sessionKey);
|
|
66
|
+
return [workingDir, port, sessionKey, isDev, isDaemon];
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEjF,MAAM,cAAc,GAAG,CAAC,OAAe,EAAW,EAAE;IAClD,OAAO,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,IAAY,EAAC,UAAiB,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