easy-devops 1.2.1 → 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 +15 -4
- 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 +92 -1
- 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/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 +37 -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 +94 -28
- package/src/core/domains-db.js +234 -0
- package/src/core/events.js +94 -2
- 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 +31 -1
- 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 +70 -7
- 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 +302 -15
- package/src/dashboard/controllers/deploymentsController.js +479 -0
- package/src/dashboard/controllers/domainsController.js +39 -52
- package/src/dashboard/controllers/hubController.js +135 -0
- package/src/dashboard/controllers/nginxController.js +21 -3
- package/src/dashboard/controllers/processesController.js +368 -0
- package/src/dashboard/controllers/settingsController.js +180 -12
- package/src/dashboard/controllers/sslController.js +171 -10
- 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/js/app.js +489 -19
- package/src/dashboard/routes/auth.js +10 -10
- package/src/dashboard/routes/deployments.js +46 -0
- package/src/dashboard/routes/domains.js +9 -0
- package/src/dashboard/routes/hub.js +22 -0
- package/src/dashboard/routes/nginx.js +9 -0
- package/src/dashboard/routes/processes.js +29 -0
- package/src/dashboard/routes/settings.js +9 -0
- package/src/dashboard/routes/ssl.js +9 -0
- package/src/dashboard/server.js +288 -21
- package/src/dashboard/socketManager.js +171 -207
- package/src/dashboard/views/index.ejs +1 -0
- package/src/dashboard/views/partials/login.ejs +68 -7
- package/src/dashboard/views/partials/processes-panel.ejs +261 -0
- package/src/dashboard/views/partials/settings-panel.ejs +287 -0
- package/src/dashboard/views/partials/sidebar.ejs +2 -0
- package/src/dashboard/lib/domains-db.js +0 -51
package/src/core/shell.js
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* - getShell() — Returns OS-resolved shell descriptor { shell, flag }
|
|
10
10
|
* - run(cmd, options) — Executes a command and captures output; never throws
|
|
11
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
|
|
12
|
+
* - runInteractive(cmd, options) — Executes a command with full stdio inheritance, for commands that prompt; never throws
|
|
13
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
|
|
14
15
|
*
|
|
15
16
|
* CommandResult shape (returned by run()):
|
|
16
17
|
* { success: boolean, stdout: string, stderr: string, exitCode: number|null, command: string }
|
|
@@ -18,6 +19,9 @@
|
|
|
18
19
|
* CommandOptions (accepted by run() and runLive()):
|
|
19
20
|
* { timeout?: number, cwd?: string }
|
|
20
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).
|
|
21
25
|
*/
|
|
22
26
|
|
|
23
27
|
import { spawn } from 'child_process';
|
|
@@ -56,23 +60,48 @@ export function getShell() {
|
|
|
56
60
|
* @param {{ timeout?: number, cwd?: string }} [options]
|
|
57
61
|
* @param {number} [options.timeout=30000] - Milliseconds before the process is killed.
|
|
58
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.
|
|
59
65
|
* @returns {Promise<{ success: boolean, stdout: string, stderr: string, exitCode: number|null, command: string }>}
|
|
60
66
|
*/
|
|
61
67
|
export function run(cmd, options = {}) {
|
|
62
|
-
const { timeout = 30000, cwd = process.cwd() } = options;
|
|
68
|
+
const { timeout = 30000, cwd = process.cwd(), env = null, onData = null } = options;
|
|
63
69
|
const { shell, flag } = getShell();
|
|
64
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 }) {
|
|
65
82
|
return new Promise((resolve) => {
|
|
66
83
|
const ac = new AbortController();
|
|
67
84
|
const timer = setTimeout(() => ac.abort(), timeout);
|
|
68
85
|
|
|
69
|
-
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
|
+
});
|
|
70
93
|
|
|
71
94
|
let stdoutBuf = '';
|
|
72
95
|
let stderrBuf = '';
|
|
73
96
|
|
|
74
|
-
|
|
75
|
-
|
|
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'); });
|
|
76
105
|
|
|
77
106
|
child.on('close', (exitCode) => {
|
|
78
107
|
clearTimeout(timer);
|
|
@@ -108,6 +137,35 @@ export function run(cmd, options = {}) {
|
|
|
108
137
|
});
|
|
109
138
|
}
|
|
110
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
|
+
|
|
111
169
|
// ─── runLive ──────────────────────────────────────────────────────────────────
|
|
112
170
|
|
|
113
171
|
/**
|
|
@@ -156,8 +214,13 @@ export function runLive(cmd, options = {}) {
|
|
|
156
214
|
|
|
157
215
|
/**
|
|
158
216
|
* Executes a shell command with full stdio inheritance (stdin/stdout/stderr all
|
|
159
|
-
* pass through to the terminal)
|
|
160
|
-
*
|
|
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.
|
|
161
224
|
*
|
|
162
225
|
* Never throws.
|
|
163
226
|
*
|