ninedeploy 0.10.5 → 0.16.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 (149) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1 -0
  3. package/dist/client.d.ts +34 -0
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +81 -22
  6. package/dist/client.js.map +1 -1
  7. package/dist/commands/backupPolicy.d.ts +29 -0
  8. package/dist/commands/backupPolicy.d.ts.map +1 -0
  9. package/dist/commands/backupPolicy.js +111 -0
  10. package/dist/commands/backupPolicy.js.map +1 -0
  11. package/dist/commands/certificates.d.ts +18 -7
  12. package/dist/commands/certificates.d.ts.map +1 -1
  13. package/dist/commands/certificates.js +121 -1
  14. package/dist/commands/certificates.js.map +1 -1
  15. package/dist/commands/databaseAccess.d.ts +37 -0
  16. package/dist/commands/databaseAccess.d.ts.map +1 -0
  17. package/dist/commands/databaseAccess.js +306 -0
  18. package/dist/commands/databaseAccess.js.map +1 -0
  19. package/dist/commands/deploy.d.ts.map +1 -1
  20. package/dist/commands/deploy.js +28 -7
  21. package/dist/commands/deploy.js.map +1 -1
  22. package/dist/commands/githubApps.d.ts +40 -0
  23. package/dist/commands/githubApps.d.ts.map +1 -0
  24. package/dist/commands/githubApps.js +278 -0
  25. package/dist/commands/githubApps.js.map +1 -0
  26. package/dist/commands/housekeeping.d.ts +7 -0
  27. package/dist/commands/housekeeping.d.ts.map +1 -1
  28. package/dist/commands/housekeeping.js +16 -0
  29. package/dist/commands/housekeeping.js.map +1 -1
  30. package/dist/commands/logs.d.ts.map +1 -1
  31. package/dist/commands/logs.js +17 -2
  32. package/dist/commands/logs.js.map +1 -1
  33. package/dist/commands/manage.d.ts +26 -10
  34. package/dist/commands/manage.d.ts.map +1 -1
  35. package/dist/commands/manage.js +219 -65
  36. package/dist/commands/manage.js.map +1 -1
  37. package/dist/commands/manifest.d.ts.map +1 -1
  38. package/dist/commands/manifest.js +9 -1
  39. package/dist/commands/manifest.js.map +1 -1
  40. package/dist/commands/misc.d.ts +4 -2
  41. package/dist/commands/misc.d.ts.map +1 -1
  42. package/dist/commands/misc.js +25 -11
  43. package/dist/commands/misc.js.map +1 -1
  44. package/dist/commands/multiNode.d.ts +55 -0
  45. package/dist/commands/multiNode.d.ts.map +1 -0
  46. package/dist/commands/multiNode.js +438 -0
  47. package/dist/commands/multiNode.js.map +1 -0
  48. package/dist/commands/notifications.d.ts +1 -1
  49. package/dist/commands/operations.d.ts +89 -0
  50. package/dist/commands/operations.d.ts.map +1 -0
  51. package/dist/commands/operations.js +468 -0
  52. package/dist/commands/operations.js.map +1 -0
  53. package/dist/commands/panelBackup.d.ts +28 -0
  54. package/dist/commands/panelBackup.d.ts.map +1 -0
  55. package/dist/commands/panelBackup.js +153 -0
  56. package/dist/commands/panelBackup.js.map +1 -0
  57. package/dist/commands/plugins.d.ts +1 -1
  58. package/dist/commands/plugins.d.ts.map +1 -1
  59. package/dist/commands/plugins.js +7 -3
  60. package/dist/commands/plugins.js.map +1 -1
  61. package/dist/commands/proxyConfig.d.ts +16 -0
  62. package/dist/commands/proxyConfig.d.ts.map +1 -0
  63. package/dist/commands/proxyConfig.js +122 -0
  64. package/dist/commands/proxyConfig.js.map +1 -0
  65. package/dist/commands/secretProviders.d.ts +59 -0
  66. package/dist/commands/secretProviders.d.ts.map +1 -0
  67. package/dist/commands/secretProviders.js +212 -0
  68. package/dist/commands/secretProviders.js.map +1 -0
  69. package/dist/commands/services.d.ts.map +1 -1
  70. package/dist/commands/services.js +3 -5
  71. package/dist/commands/services.js.map +1 -1
  72. package/dist/commands/setup.d.ts +3 -1
  73. package/dist/commands/setup.d.ts.map +1 -1
  74. package/dist/commands/setup.js +19 -3
  75. package/dist/commands/setup.js.map +1 -1
  76. package/dist/commands/sources.d.ts +10 -3
  77. package/dist/commands/sources.d.ts.map +1 -1
  78. package/dist/commands/sources.js +116 -18
  79. package/dist/commands/sources.js.map +1 -1
  80. package/dist/commands/templates.d.ts.map +1 -1
  81. package/dist/commands/templates.js +8 -1
  82. package/dist/commands/templates.js.map +1 -1
  83. package/dist/config.d.ts.map +1 -1
  84. package/dist/config.js +2 -1
  85. package/dist/config.js.map +1 -1
  86. package/dist/index.js +427 -23
  87. package/dist/index.js.map +1 -1
  88. package/dist/lib/format.d.ts.map +1 -1
  89. package/dist/lib/format.js +5 -4
  90. package/dist/lib/format.js.map +1 -1
  91. package/dist/lib/panelBackupFile.d.ts +3 -0
  92. package/dist/lib/panelBackupFile.d.ts.map +1 -0
  93. package/dist/lib/panelBackupFile.js +71 -0
  94. package/dist/lib/panelBackupFile.js.map +1 -0
  95. package/dist/lib/serverRunner.d.ts +6 -0
  96. package/dist/lib/serverRunner.d.ts.map +1 -1
  97. package/dist/lib/serverRunner.js +18 -3
  98. package/dist/lib/serverRunner.js.map +1 -1
  99. package/dist/prompts.d.ts.map +1 -1
  100. package/dist/prompts.js +9 -2
  101. package/dist/prompts.js.map +1 -1
  102. package/package.json +6 -5
  103. package/src/client.ts +137 -0
  104. package/src/commands/backupPolicy.ts +123 -0
  105. package/src/commands/branding.ts +83 -0
  106. package/src/commands/buildCache.ts +72 -0
  107. package/src/commands/certificates.ts +208 -0
  108. package/src/commands/communityTemplates.ts +97 -0
  109. package/src/commands/configCenter.ts +71 -0
  110. package/src/commands/configPresets.ts +215 -0
  111. package/src/commands/databaseAccess.ts +333 -0
  112. package/src/commands/demo.ts +22 -0
  113. package/src/commands/deploy.ts +284 -0
  114. package/src/commands/doctor.ts +170 -0
  115. package/src/commands/domains.ts +170 -0
  116. package/src/commands/egress.ts +135 -0
  117. package/src/commands/emailTemplates.ts +112 -0
  118. package/src/commands/firewall.ts +82 -0
  119. package/src/commands/githubApps.ts +292 -0
  120. package/src/commands/housekeeping.ts +106 -0
  121. package/src/commands/login.ts +58 -0
  122. package/src/commands/logs.ts +91 -0
  123. package/src/commands/manage.ts +714 -0
  124. package/src/commands/manifest.ts +314 -0
  125. package/src/commands/metrics.ts +69 -0
  126. package/src/commands/misc.ts +307 -0
  127. package/src/commands/multiNode.ts +442 -0
  128. package/src/commands/notifications.ts +174 -0
  129. package/src/commands/operations.ts +519 -0
  130. package/src/commands/panelBackup.ts +167 -0
  131. package/src/commands/pgbouncer.ts +65 -0
  132. package/src/commands/plugins.ts +123 -0
  133. package/src/commands/proxyConfig.ts +117 -0
  134. package/src/commands/secretProviders.ts +228 -0
  135. package/src/commands/server.ts +126 -0
  136. package/src/commands/services.ts +249 -0
  137. package/src/commands/setup.ts +94 -0
  138. package/src/commands/sources.ts +317 -0
  139. package/src/commands/sso.ts +106 -0
  140. package/src/commands/templates.ts +158 -0
  141. package/src/commands/token.ts +66 -0
  142. package/src/commands/webhooks.ts +93 -0
  143. package/src/commands/workspaces.ts +63 -0
  144. package/src/config.ts +53 -0
  145. package/src/index.ts +1273 -0
  146. package/src/lib/format.ts +182 -0
  147. package/src/lib/panelBackupFile.ts +67 -0
  148. package/src/lib/serverRunner.ts +223 -0
  149. package/src/prompts.ts +238 -0
package/src/prompts.ts ADDED
@@ -0,0 +1,238 @@
1
+ import process from 'node:process';
2
+
3
+ /**
4
+ * Line framing for stdin: a chunk may carry SEVERAL lines (a paste, or piped
5
+ * input in CI) and a line may be split across chunks. Complete lines queue in
6
+ * `lineBuffer` in FIFO order; the incomplete tail stays in `pendingTail` until
7
+ * its newline arrives or stdin ends. prompt()/promptHidden() pull from the
8
+ * queue, so a pasted block answers successive prompts in order instead of
9
+ * collapsing into one value with embedded newlines (r024).
10
+ *
11
+ * Exactly ONE 'data' listener is wired per stdin stream: chunks route to the
12
+ * active hidden prompt (raw keystrokes) or to the line framer — never both,
13
+ * or a pasted line would be delivered twice. When `process.stdin` itself is
14
+ * swapped (test suites install a fresh fake per case), the listeners and the
15
+ * stream-lifecycle state are re-armed on the next call.
16
+ */
17
+ let lineBuffer: string[] = [];
18
+ let pendingTail = '';
19
+ let eof = false;
20
+ let wiredStdin: unknown = null;
21
+ /** The exact handler references `attach()` registered on the current stdin. */
22
+ let wiredData: ((chunk: string) => void) | null = null;
23
+ let wiredEnd: (() => void) | null = null;
24
+
25
+ interface LineWaiter {
26
+ deliver: (line: string) => void;
27
+ }
28
+
29
+ const lineWaiters: LineWaiter[] = [];
30
+ /** At most one hidden prompt at a time; it consumes live keystrokes. */
31
+ let hiddenWaiter: ((chunk: string) => boolean | void) | null = null;
32
+ /** EOF handler while a hidden prompt is active (resolves what was typed). */
33
+ let hiddenOnEnd: (() => void) | null = null;
34
+
35
+ function handleData(chunk: string): void {
36
+ pendingTail += chunk;
37
+ const lines = pendingTail.split(/\r?\n/);
38
+ pendingTail = lines.pop() ?? '';
39
+ lineBuffer.push(...lines);
40
+ flushLineWaiters();
41
+ }
42
+
43
+ function handleEnd(): void {
44
+ eof = true;
45
+ // A final line without its newline (piped input that omits it) still counts.
46
+ if (pendingTail !== '') {
47
+ lineBuffer.push(pendingTail);
48
+ pendingTail = '';
49
+ }
50
+ flushLineWaiters();
51
+ }
52
+
53
+ function flushLineWaiters(): void {
54
+ while (lineWaiters.length > 0 && (lineBuffer.length > 0 || eof)) {
55
+ const waiter = lineWaiters.shift()!;
56
+ waiter.deliver(lineBuffer.length > 0 ? lineBuffer.shift()! : '');
57
+ }
58
+ }
59
+
60
+ function detach(oldStdin: NodeJS.ReadStream): void {
61
+ // Remove the same function references `attach()` registered — removing
62
+ // different closures would be a silent no-op and leave live listeners on a
63
+ // swapped-out stream.
64
+ if (wiredData) oldStdin.removeListener('data', wiredData);
65
+ if (wiredEnd) oldStdin.removeListener('end', wiredEnd);
66
+ wiredData = null;
67
+ wiredEnd = null;
68
+ }
69
+
70
+ /**
71
+ * Wire the framer onto the CURRENT process.stdin. Re-arms when the stream
72
+ * object changes (fresh fake per test case); a no-op otherwise, so the real
73
+ * runtime keeps its queue and listeners across successive prompts.
74
+ */
75
+ function attach(): void {
76
+ const stdin = process.stdin;
77
+ if (wiredStdin === stdin) return;
78
+ if (wiredStdin) detach(wiredStdin as NodeJS.ReadStream);
79
+ wiredStdin = stdin;
80
+ // A different stream object is a fresh lifecycle.
81
+ lineBuffer = [];
82
+ pendingTail = '';
83
+ eof = false;
84
+ hiddenWaiter = null;
85
+ hiddenOnEnd = null;
86
+ stdin.setEncoding('utf8');
87
+ let skipLeadingLf = false;
88
+ wiredData = (chunk: string) => {
89
+ if (skipLeadingLf && chunk.length > 0) {
90
+ skipLeadingLf = false;
91
+ if (chunk.startsWith('\n')) chunk = chunk.slice(1);
92
+ }
93
+ if (hiddenWaiter) skipLeadingLf = hiddenWaiter(chunk) === true;
94
+ else handleData(chunk);
95
+ };
96
+ wiredEnd = () => {
97
+ if (hiddenOnEnd) hiddenOnEnd();
98
+ else handleEnd();
99
+ };
100
+ stdin.on('data', wiredData);
101
+ stdin.once('end', wiredEnd);
102
+ stdin.resume();
103
+ }
104
+
105
+ /** Shift one buffered line, or null when the queue is empty. */
106
+ function takeLine(): string | null {
107
+ return lineBuffer.length > 0 ? lineBuffer.shift()! : null;
108
+ }
109
+
110
+ /** Read a single line from stdin with normal echo. Honors an optional default. */
111
+ export function prompt(message: string, defaultValue?: string): Promise<string> {
112
+ return new Promise((resolve) => {
113
+ attach();
114
+ process.stdin.resume();
115
+ const deliver = (line: string): void => {
116
+ const t = line.trim();
117
+ resolve(t.length ? t : (defaultValue ?? ''));
118
+ };
119
+ const buffered = takeLine();
120
+ if (buffered !== null) {
121
+ deliver(buffered);
122
+ return;
123
+ }
124
+ if (eof) {
125
+ deliver('');
126
+ return;
127
+ }
128
+ lineWaiters.push({ deliver });
129
+ process.stdout.write(defaultValue ? `${message} [${defaultValue}]: ` : `${message}: `);
130
+ });
131
+ }
132
+
133
+ /** Read a single line from stdin without echoing (for passwords / secrets). */
134
+ export function promptHidden(message: string): Promise<string> {
135
+ return new Promise((resolve) => {
136
+ attach();
137
+ process.stdin.resume();
138
+ // A line already framed by a paste/piped write satisfies the prompt
139
+ // without entering raw mode. Stars preserve the historical echo.
140
+ const buffered = takeLine();
141
+ if (buffered !== null) {
142
+ process.stdout.write(`${'*'.repeat(buffered.length)}\n`);
143
+ resolve(buffered);
144
+ return;
145
+ }
146
+ if (eof) {
147
+ process.stdout.write('\n');
148
+ resolve('');
149
+ return;
150
+ }
151
+ const stdin = process.stdin;
152
+ const isTTY = typeof stdin.setRawMode === 'function';
153
+ let data = '';
154
+ const cleanup = (): void => {
155
+ if (isTTY) stdin.setRawMode(false);
156
+ stdin.pause();
157
+ hiddenWaiter = null;
158
+ hiddenOnEnd = null;
159
+ };
160
+ // Escape-sequence decoding state, carried across chunks: terminal control
161
+ // keys (arrows, Home, F1…) arrive as e.g. \x1b[A or \x1bOP — without
162
+ // decoding them, the printable bytes of the sequence would leak into the
163
+ // stored value.
164
+ let escaped = false;
165
+ let inCsi = false;
166
+ hiddenWaiter = (chunk: string) => {
167
+ for (let i = 0; i < chunk.length; i++) {
168
+ const code = chunk.charCodeAt(i);
169
+ if (escaped) {
170
+ escaped = false;
171
+ if (code >= 32 && code <= 126) {
172
+ // '[' opens a CSI sequence; any other printable byte opens a
173
+ // two-byte SS3-style sequence (function keys). Swallow the whole
174
+ // sequence. A control byte instead means the bare Escape key was
175
+ // pressed — fall through so Enter/Ctrl-C still work.
176
+ if (code === 91) inCsi = true;
177
+ continue;
178
+ }
179
+ }
180
+ if (inCsi) {
181
+ // CSI sequences end with a final byte in 0x40–0x7E.
182
+ if (code >= 64 && code <= 126) inCsi = false;
183
+ continue;
184
+ }
185
+ if (code === 27) {
186
+ escaped = true;
187
+ } else if (code === 13 || code === 10) {
188
+ // Enter — deliver the hidden value; the rest of the chunk is the
189
+ // paste tail and must feed the line queue, not vanish (r024). A CRLF
190
+ // paste leaves a leading \n on that tail, which the framer would
191
+ // split into a spurious empty first line and shift every later
192
+ // answer — strip it here.
193
+ let rest = chunk.slice(i + 1);
194
+ if (code === 13 && rest.charCodeAt(0) === 10) rest = rest.slice(1);
195
+ cleanup();
196
+ process.stdout.write('\n');
197
+ resolve(data);
198
+ if (rest !== '') handleData(rest);
199
+ // Carry a split CRLF across chunks without queuing an empty answer.
200
+ return code === 13 && i === chunk.length - 1;
201
+ } else if (code === 3) {
202
+ // Ctrl-C: standard "interrupted" exit code (130 = 128 + SIGINT);
203
+ // cleanup first so raw mode is restored before exiting.
204
+ cleanup();
205
+ process.stdout.write('\n');
206
+ process.exit(130);
207
+ } else if (code === 127 || code === 8) {
208
+ // Backspace
209
+ if (data.length > 0) {
210
+ data = data.slice(0, -1);
211
+ process.stdout.write('\b \b');
212
+ }
213
+ } else if (code >= 32 && code !== 127) {
214
+ data += chunk[i]!;
215
+ process.stdout.write('*');
216
+ }
217
+ }
218
+ };
219
+ hiddenOnEnd = (): void => {
220
+ // EOF (piped stdin): resolve with whatever was typed so far.
221
+ const typed = data;
222
+ const tail = pendingTail;
223
+ pendingTail = '';
224
+ cleanup();
225
+ eof = true;
226
+ if (typed !== '') {
227
+ process.stdout.write(`${'*'.repeat(typed.length)}\n`);
228
+ resolve(typed);
229
+ } else {
230
+ process.stdout.write('\n');
231
+ resolve('');
232
+ }
233
+ if (tail !== '') handleData(tail);
234
+ };
235
+ process.stdout.write(`${message}: `);
236
+ if (isTTY) stdin.setRawMode(true);
237
+ });
238
+ }