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
package/src/core/shell.js
CHANGED
|
@@ -6,17 +6,22 @@
|
|
|
6
6
|
* All modules must use this utility instead of calling child_process APIs directly.
|
|
7
7
|
*
|
|
8
8
|
* Exported functions:
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* - getShell() — Returns OS-resolved shell descriptor { shell, flag }
|
|
10
|
+
* - run(cmd, options) — Executes a command and captures output; never throws
|
|
11
|
+
* - runLive(cmd, options) — Executes a command, streaming output to the terminal; never throws
|
|
12
|
+
* - runInteractive(cmd, options) — Executes a command with full stdio inheritance, for commands that prompt; never throws
|
|
13
|
+
* - runWithStdin(cmd, argsArray, stdinData) — Spawns a process with stdin piping; never throws
|
|
14
|
+
* - runCommandLine(cmd, options) — Runs a command line a USER wrote, in the platform's default shell; never throws
|
|
13
15
|
*
|
|
14
16
|
* CommandResult shape (returned by run()):
|
|
15
|
-
*
|
|
17
|
+
* { success: boolean, stdout: string, stderr: string, exitCode: number|null, command: string }
|
|
16
18
|
*
|
|
17
19
|
* CommandOptions (accepted by run() and runLive()):
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
+
* { timeout?: number, cwd?: string }
|
|
21
|
+
* Defaults: timeout = 30 000 ms, cwd = process.cwd()
|
|
22
|
+
*
|
|
23
|
+
* run() additionally accepts `env` (merged over process.env) and `onData`
|
|
24
|
+
* (called with each chunk of output as it arrives).
|
|
20
25
|
*/
|
|
21
26
|
|
|
22
27
|
import { spawn } from 'child_process';
|
|
@@ -55,23 +60,48 @@ export function getShell() {
|
|
|
55
60
|
* @param {{ timeout?: number, cwd?: string }} [options]
|
|
56
61
|
* @param {number} [options.timeout=30000] - Milliseconds before the process is killed.
|
|
57
62
|
* @param {string} [options.cwd=process.cwd()] - Working directory for the child process.
|
|
63
|
+
* @param {Object} [options.env] - Extra environment variables, merged over process.env.
|
|
64
|
+
* @param {(chunk: string, stream: 'stdout'|'stderr') => void} [options.onData] - Receives output as it arrives.
|
|
58
65
|
* @returns {Promise<{ success: boolean, stdout: string, stderr: string, exitCode: number|null, command: string }>}
|
|
59
66
|
*/
|
|
60
67
|
export function run(cmd, options = {}) {
|
|
61
|
-
const { timeout = 30000, cwd = process.cwd() } = options;
|
|
68
|
+
const { timeout = 30000, cwd = process.cwd(), env = null, onData = null } = options;
|
|
62
69
|
const { shell, flag } = getShell();
|
|
63
70
|
|
|
71
|
+
return capture((spawnOptions) => spawn(shell, [flag, cmd], spawnOptions), { cmd, timeout, cwd, env, onData });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Shared body of run() and runCommandLine(): spawn, collect output, enforce
|
|
76
|
+
* the timeout, and always resolve with a CommandResult.
|
|
77
|
+
*
|
|
78
|
+
* @param {(spawnOptions: Object) => import('child_process').ChildProcess} spawnChild
|
|
79
|
+
* @param {{ cmd: string, timeout: number, cwd: string, env: Object|null, onData: Function|null }} opts
|
|
80
|
+
*/
|
|
81
|
+
function capture(spawnChild, { cmd, timeout, cwd, env, onData }) {
|
|
64
82
|
return new Promise((resolve) => {
|
|
65
83
|
const ac = new AbortController();
|
|
66
84
|
const timer = setTimeout(() => ac.abort(), timeout);
|
|
67
85
|
|
|
68
|
-
const child =
|
|
86
|
+
const child = spawnChild({
|
|
87
|
+
cwd,
|
|
88
|
+
signal: ac.signal,
|
|
89
|
+
encoding: 'utf8',
|
|
90
|
+
windowsHide: true,
|
|
91
|
+
...(env ? { env: { ...process.env, ...env } } : {}),
|
|
92
|
+
});
|
|
69
93
|
|
|
70
94
|
let stdoutBuf = '';
|
|
71
95
|
let stderrBuf = '';
|
|
72
96
|
|
|
73
|
-
|
|
74
|
-
|
|
97
|
+
// A listener that throws must not lose the command's result.
|
|
98
|
+
const tell = (chunk, stream) => {
|
|
99
|
+
if (!onData) return;
|
|
100
|
+
try { onData(stripAnsi(String(chunk)), stream); } catch { /* ignore */ }
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
child.stdout.on('data', (chunk) => { stdoutBuf += chunk; tell(chunk, 'stdout'); });
|
|
104
|
+
child.stderr.on('data', (chunk) => { stderrBuf += chunk; tell(chunk, 'stderr'); });
|
|
75
105
|
|
|
76
106
|
child.on('close', (exitCode) => {
|
|
77
107
|
clearTimeout(timer);
|
|
@@ -107,6 +137,35 @@ export function run(cmd, options = {}) {
|
|
|
107
137
|
});
|
|
108
138
|
}
|
|
109
139
|
|
|
140
|
+
// ─── runCommandLine ───────────────────────────────────────────────────────────
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Runs a command line that a USER wrote — an `install`, `build` or hook command
|
|
144
|
+
* from a project's ez.json — in the platform's default shell.
|
|
145
|
+
*
|
|
146
|
+
* This is not run(): run() uses PowerShell on Windows, where `a && b` is a
|
|
147
|
+
* syntax error before PowerShell 7, and almost every build command anyone
|
|
148
|
+
* writes contains `&&`. `shell: true` gives `/bin/sh -c` on Linux and
|
|
149
|
+
* `cmd.exe /d /s /c` on Windows, which is the shell npm scripts themselves run
|
|
150
|
+
* in — so a command that works in `package.json` works here unchanged.
|
|
151
|
+
*
|
|
152
|
+
* Never throws. Same CommandResult as run(). On a timeout the shell is killed;
|
|
153
|
+
* a grandchild it started may outlive it, which is why the default is long
|
|
154
|
+
* rather than tight.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} cmd - The command line, exactly as written.
|
|
157
|
+
* @param {Object} [options]
|
|
158
|
+
* @param {number} [options.timeout=900000] - Milliseconds before the shell is killed (15 minutes).
|
|
159
|
+
* @param {string} [options.cwd=process.cwd()]
|
|
160
|
+
* @param {Object} [options.env] - Extra environment variables, merged over process.env.
|
|
161
|
+
* @param {(chunk: string, stream: 'stdout'|'stderr') => void} [options.onData]
|
|
162
|
+
* @returns {Promise<{ success: boolean, stdout: string, stderr: string, exitCode: number|null, command: string }>}
|
|
163
|
+
*/
|
|
164
|
+
export function runCommandLine(cmd, options = {}) {
|
|
165
|
+
const { timeout = 900000, cwd = process.cwd(), env = null, onData = null } = options;
|
|
166
|
+
return capture((spawnOptions) => spawn(cmd, [], { ...spawnOptions, shell: true }), { cmd, timeout, cwd, env, onData });
|
|
167
|
+
}
|
|
168
|
+
|
|
110
169
|
// ─── runLive ──────────────────────────────────────────────────────────────────
|
|
111
170
|
|
|
112
171
|
/**
|
|
@@ -155,8 +214,13 @@ export function runLive(cmd, options = {}) {
|
|
|
155
214
|
|
|
156
215
|
/**
|
|
157
216
|
* Executes a shell command with full stdio inheritance (stdin/stdout/stderr all
|
|
158
|
-
* pass through to the terminal)
|
|
159
|
-
*
|
|
217
|
+
* pass through to the terminal), for commands that must prompt the user
|
|
218
|
+
* themselves — `sudo -v` on Linux, and `schtasks /RP *` on Windows, where
|
|
219
|
+
* Windows collects the account password so that Easy DevOps never handles it.
|
|
220
|
+
*
|
|
221
|
+
* The implementation is platform-agnostic; the caller is responsible for
|
|
222
|
+
* checking that a real terminal exists (`process.stdin.isTTY`), since there is
|
|
223
|
+
* nothing to prompt on in a dashboard request or a PM2-managed process.
|
|
160
224
|
*
|
|
161
225
|
* Never throws.
|
|
162
226
|
*
|
|
@@ -185,3 +249,54 @@ export function runInteractive(cmd, options = {}) {
|
|
|
185
249
|
});
|
|
186
250
|
});
|
|
187
251
|
}
|
|
252
|
+
|
|
253
|
+
// ─── runWithStdin ─────────────────────────────────────────────────────────────
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Spawns a process directly (no shell wrapper) and pipes data to its stdin.
|
|
257
|
+
* Intended for commands like `sudo -S` that read input from stdin.
|
|
258
|
+
*
|
|
259
|
+
* Never throws. The returned Promise always resolves with a CommandResult.
|
|
260
|
+
*
|
|
261
|
+
* @param {string} cmd - The executable to spawn (e.g. 'sudo').
|
|
262
|
+
* @param {string[]} argsArray - Arguments passed directly to the executable.
|
|
263
|
+
* @param {string} [stdinData=''] - String to pipe to the process stdin.
|
|
264
|
+
* @returns {Promise<{ success: boolean, stdout: string, stderr: string, exitCode: number|null, command: string }>}
|
|
265
|
+
*/
|
|
266
|
+
export function runWithStdin(cmd, argsArray, stdinData = '') {
|
|
267
|
+
return new Promise((resolve) => {
|
|
268
|
+
const child = spawn(cmd, argsArray, {
|
|
269
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
270
|
+
windowsHide: true,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
let stdoutBuf = '';
|
|
274
|
+
let stderrBuf = '';
|
|
275
|
+
|
|
276
|
+
child.stdout.on('data', (chunk) => { stdoutBuf += chunk; });
|
|
277
|
+
child.stderr.on('data', (chunk) => { stderrBuf += chunk; });
|
|
278
|
+
|
|
279
|
+
child.stdin.write(stdinData);
|
|
280
|
+
child.stdin.end();
|
|
281
|
+
|
|
282
|
+
child.on('close', (exitCode) => {
|
|
283
|
+
resolve({
|
|
284
|
+
success: exitCode === 0,
|
|
285
|
+
stdout: stripAnsi(stdoutBuf).trim(),
|
|
286
|
+
stderr: stripAnsi(stderrBuf).trim(),
|
|
287
|
+
exitCode,
|
|
288
|
+
command: cmd,
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
child.on('error', (err) => {
|
|
293
|
+
resolve({
|
|
294
|
+
success: false,
|
|
295
|
+
stdout: '',
|
|
296
|
+
stderr: err.message,
|
|
297
|
+
exitCode: null,
|
|
298
|
+
command: cmd,
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
}
|