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.
Files changed (126) 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 +15 -4
  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 +92 -1
  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/cleanup.js +600 -0
  42. package/src/core/config.js +169 -2
  43. package/src/core/daemon/ipc.js +292 -0
  44. package/src/core/daemon/lock.js +294 -0
  45. package/src/core/daemon/run.js +241 -0
  46. package/src/core/daemon/stopRequest.js +162 -0
  47. package/src/core/db.js +37 -8
  48. package/src/core/deploy/apps.js +491 -0
  49. package/src/core/deploy/domainLink.js +200 -0
  50. package/src/core/deploy/engine.js +973 -0
  51. package/src/core/deploy/ezfile.js +361 -0
  52. package/src/core/deploy/github.js +239 -0
  53. package/src/core/deploy/githubApi.js +261 -0
  54. package/src/core/deploy/hookServer.js +325 -0
  55. package/src/core/deploy/hubCommands.js +267 -0
  56. package/src/core/deploy/launcher.js +57 -0
  57. package/src/core/deploy/status.js +91 -0
  58. package/src/core/deploy/store.js +398 -0
  59. package/src/core/domainNotifier.js +94 -28
  60. package/src/core/domains-db.js +234 -0
  61. package/src/core/events.js +94 -2
  62. package/src/core/hub/agent.js +842 -0
  63. package/src/core/hubLink.js +306 -0
  64. package/src/core/hubPermissions.js +430 -0
  65. package/src/core/installSource.js +162 -0
  66. package/src/core/jobs/bus.js +120 -0
  67. package/src/core/jobs/index.js +371 -0
  68. package/src/core/jobs/monitors.js +368 -0
  69. package/src/core/jobs/owner.js +217 -0
  70. package/src/core/jobs/revisionWatcher.js +106 -0
  71. package/src/core/nginx-apply.js +213 -0
  72. package/src/core/nginx-conf-generator.js +253 -17
  73. package/src/{dashboard/lib → core}/nginx-service.js +18 -9
  74. package/src/core/notifications/claim.js +214 -0
  75. package/src/core/notifications/dispatch.js +154 -0
  76. package/src/core/notifier.js +31 -1
  77. package/src/core/passwords.js +172 -0
  78. package/src/core/permissions.js +8 -4
  79. package/src/core/platform.js +709 -2
  80. package/src/core/probeCache.js +258 -0
  81. package/src/core/purge.js +372 -0
  82. package/src/core/runner.js +488 -0
  83. package/src/core/service/acl.js +226 -0
  84. package/src/core/service/dataDir.js +345 -0
  85. package/src/core/service/index.js +1128 -0
  86. package/src/core/service/legacy.js +218 -0
  87. package/src/core/service/runtime.js +446 -0
  88. package/src/core/service/runtimeUpdate.js +800 -0
  89. package/src/core/service/systemd.js +458 -0
  90. package/src/core/service/windowsPersonal.js +530 -0
  91. package/src/core/service/windowsService.js +576 -0
  92. package/src/core/service/winsw.js +260 -0
  93. package/src/core/setupCode.js +331 -0
  94. package/src/core/shell.js +70 -7
  95. package/src/core/ssl-issuer.js +627 -0
  96. package/src/core/updater.js +295 -0
  97. package/src/core/validators.js +99 -0
  98. package/src/dashboard/controllers/authController.js +302 -15
  99. package/src/dashboard/controllers/deploymentsController.js +479 -0
  100. package/src/dashboard/controllers/domainsController.js +39 -52
  101. package/src/dashboard/controllers/hubController.js +135 -0
  102. package/src/dashboard/controllers/nginxController.js +21 -3
  103. package/src/dashboard/controllers/processesController.js +368 -0
  104. package/src/dashboard/controllers/settingsController.js +180 -12
  105. package/src/dashboard/controllers/sslController.js +171 -10
  106. package/src/dashboard/lib/daemonBridge.js +163 -0
  107. package/src/dashboard/lib/localRequest.js +235 -0
  108. package/src/dashboard/lib/loginRateLimit.js +119 -0
  109. package/src/dashboard/lib/requireAuth.js +80 -0
  110. package/src/dashboard/public/js/app.js +489 -19
  111. package/src/dashboard/routes/auth.js +10 -10
  112. package/src/dashboard/routes/deployments.js +46 -0
  113. package/src/dashboard/routes/domains.js +9 -0
  114. package/src/dashboard/routes/hub.js +22 -0
  115. package/src/dashboard/routes/nginx.js +9 -0
  116. package/src/dashboard/routes/processes.js +29 -0
  117. package/src/dashboard/routes/settings.js +9 -0
  118. package/src/dashboard/routes/ssl.js +9 -0
  119. package/src/dashboard/server.js +288 -21
  120. package/src/dashboard/socketManager.js +171 -207
  121. package/src/dashboard/views/index.ejs +1 -0
  122. package/src/dashboard/views/partials/login.ejs +68 -7
  123. package/src/dashboard/views/partials/processes-panel.ejs +261 -0
  124. package/src/dashboard/views/partials/settings-panel.ejs +287 -0
  125. package/src/dashboard/views/partials/sidebar.ejs +2 -0
  126. 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 (Linux only); never throws
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 = spawn(shell, [flag, cmd], { cwd, signal: ac.signal, encoding: 'utf8', windowsHide: true });
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
- child.stdout.on('data', (chunk) => { stdoutBuf += chunk; });
75
- child.stderr.on('data', (chunk) => { stderrBuf += chunk; });
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). Intended for Linux-only interactive commands
160
- * such as `sudo -v` that need to read a password from the user.
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
  *