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
@@ -1,8 +1,18 @@
1
1
  import chalk from 'chalk';
2
2
  import inquirer from 'inquirer';
3
- import { loadConfig, saveConfig } from '../../core/config.js';
3
+ import {
4
+ loadConfig, saveConfig, AUTH_MODES, BIND_ALL, BIND_LOOPBACK,
5
+ isLoopbackBind, effectiveAuthMode,
6
+ } from '../../core/config.js';
7
+ import {
8
+ hashPassword, validateNewPassword, MIN_PASSWORD_LENGTH,
9
+ } from '../../core/passwords.js';
4
10
  import { dbGet } from '../../core/db.js';
5
11
  import { setupLinuxPermissions, checkPermissionsConfigured } from '../../core/permissions.js';
12
+ import {
13
+ getAutoRenewSettings, normalizeAutoRenewDays, MIN_AUTO_RENEW_DAYS, MAX_AUTO_RENEW_DAYS,
14
+ } from '../../core/cert-renewal.js';
15
+ import { deployRoot, defaultDeployRoot, validateDeployDir } from '../../core/deploy/store.js';
6
16
 
7
17
  export default async function settingsMenu() {
8
18
  // T021: detect missing/corrupted config before loadConfig() creates defaults
@@ -15,8 +25,20 @@ export default async function settingsMenu() {
15
25
 
16
26
  while (true) {
17
27
  // T013: display current values
18
- const passwordDisplay = config.dashboardPassword ? '***' : '(not set)';
28
+ const authMode = effectiveAuthMode(config);
29
+ const hasPassword = Boolean(config.dashboardPasswordHash || config.dashboardPassword);
30
+ const passwordDisplay = hasPassword ? '***' : '(not set)';
31
+ const authDisplay = authMode === AUTH_MODES.NONE
32
+ ? 'none (this machine only)'
33
+ : `password ${passwordDisplay}`;
34
+ const bindDisplay = isLoopbackBind(config.dashboardBindAddress)
35
+ ? `${config.dashboardBindAddress} (this machine only)`
36
+ : `${config.dashboardBindAddress} (all interfaces)`;
19
37
  const emailDisplay = config.acmeEmail || '(not set)';
38
+ const autoRenew = getAutoRenewSettings(config);
39
+ const autoRenewDisplay = autoRenew.enabled
40
+ ? `on, ${autoRenew.days} day${autoRenew.days === 1 ? '' : 's'} before expiry`
41
+ : 'off';
20
42
 
21
43
  const isLinux = process.platform !== 'win32';
22
44
  const permsOk = isLinux ? await checkPermissionsConfigured() : true;
@@ -25,10 +47,13 @@ export default async function settingsMenu() {
25
47
  console.log(chalk.bold('⚙️ Settings'));
26
48
  console.log(chalk.gray('─'.repeat(40)));
27
49
  console.log(` Dashboard Port: ${chalk.cyan(config.dashboardPort)}`);
28
- console.log(` Dashboard Password: ${chalk.cyan(passwordDisplay)}`);
50
+ console.log(` Dashboard Auth: ${chalk.cyan(authDisplay)}`);
51
+ console.log(` Listen On: ${chalk.cyan(bindDisplay)}`);
29
52
  console.log(` Nginx Directory: ${chalk.cyan(config.nginxDir)}`);
30
53
  console.log(` SSL Directory: ${chalk.cyan(config.sslDir)}`);
31
54
  console.log(` ACME Email: ${chalk.cyan(emailDisplay)}`);
55
+ console.log(` SSL Auto-Renew: ${chalk.cyan(autoRenewDisplay)}`);
56
+ console.log(` Deployments Folder: ${chalk.cyan(deployRoot())}`);
32
57
  console.log();
33
58
 
34
59
  // T014: field selection
@@ -38,10 +63,13 @@ export default async function settingsMenu() {
38
63
  message: 'Select a field to edit:',
39
64
  choices: [
40
65
  { name: `Dashboard Port (${config.dashboardPort})`, value: 'dashboardPort' },
41
- { name: `Dashboard Password (${passwordDisplay})`, value: 'dashboardPassword' },
66
+ { name: `Dashboard Auth (${authDisplay})`, value: 'dashboardAuth' },
67
+ { name: `Listen On (${bindDisplay})`, value: 'dashboardBindAddress' },
42
68
  { name: `Nginx Directory (${config.nginxDir})`, value: 'nginxDir' },
43
69
  { name: `SSL Directory (${config.sslDir})`, value: 'sslDir' },
44
70
  { name: `ACME Email (${emailDisplay})`, value: 'acmeEmail' },
71
+ { name: `SSL Auto-Renew (${autoRenewDisplay})`, value: 'sslAutoRenew' },
72
+ { name: `Deployments Folder (${deployRoot()})`, value: 'deployDir' },
45
73
  ...(isLinux ? [{
46
74
  name: permsOk
47
75
  ? '🔓 Linux Permissions ✅ configured'
@@ -85,15 +113,99 @@ export default async function settingsMenu() {
85
113
  config.dashboardPort = parseInt(value, 10);
86
114
  saveConfig(config); // T016
87
115
 
88
- } else if (field === 'dashboardPassword') {
116
+ } else if (field === 'dashboardAuth') {
117
+ // 'none' is only offered when the dashboard cannot be reached from the
118
+ // network. The CLI runs on the machine itself, so the loopback-request
119
+ // half of the rule is satisfied by definition here.
120
+ const loopbackBound = isLoopbackBind(config.dashboardBindAddress);
121
+
122
+ const { mode } = await inquirer.prompt([{
123
+ type: 'list',
124
+ name: 'mode',
125
+ message: 'How should the dashboard authenticate?',
126
+ default: authMode,
127
+ choices: [
128
+ { name: 'Password', value: AUTH_MODES.PASSWORD },
129
+ {
130
+ name: loopbackBound
131
+ ? 'No password (this machine only)'
132
+ : `No password — unavailable while listening on ${config.dashboardBindAddress}`,
133
+ value: AUTH_MODES.NONE,
134
+ disabled: loopbackBound ? false : 'set Listen On to 127.0.0.1 first',
135
+ },
136
+ { name: '← Cancel', value: 'cancel' },
137
+ ],
138
+ }]);
139
+
140
+ if (mode === 'cancel') continue;
141
+
142
+ if (mode === AUTH_MODES.NONE) {
143
+ if (!loopbackBound) {
144
+ console.log(chalk.yellow(`\n Not allowed while listening on ${config.dashboardBindAddress}.`));
145
+ console.log(chalk.gray(' Set "Listen On" to this machine only first.\n'));
146
+ continue;
147
+ }
148
+ config.dashboardAuth = AUTH_MODES.NONE;
149
+ saveConfig(config);
150
+ console.log(chalk.green('\n ✓ The dashboard will no longer ask for a password.'));
151
+ console.log(chalk.gray(' It stays reachable from this machine only.\n'));
152
+ continue;
153
+ }
154
+
89
155
  const { value } = await inquirer.prompt([{
90
156
  type: 'password',
91
157
  name: 'value',
92
- message: 'New dashboard password (leave blank to clear):',
158
+ message: `New dashboard password (at least ${MIN_PASSWORD_LENGTH} characters)${hasPassword ? ', or blank to keep the current one' : ''}:`,
93
159
  mask: '*',
94
160
  }]);
95
- config.dashboardPassword = value;
96
- saveConfig(config); // T016
161
+
162
+ if (!value && hasPassword) {
163
+ // Keep the stored password, just require it again.
164
+ config.dashboardAuth = AUTH_MODES.PASSWORD;
165
+ saveConfig(config);
166
+ console.log(chalk.green('\n ✓ A password is now required.\n'));
167
+ continue;
168
+ }
169
+
170
+ const problem = validateNewPassword(value);
171
+ if (problem) {
172
+ console.log(chalk.red(`\n ${problem}\n`));
173
+ continue;
174
+ }
175
+
176
+ // Hashed, never stored in clear — the same path the dashboard uses.
177
+ config.dashboardPasswordHash = await hashPassword(value);
178
+ config.dashboardPassword = '';
179
+ config.dashboardAuth = AUTH_MODES.PASSWORD;
180
+ saveConfig(config);
181
+ console.log(chalk.green('\n ✓ Password saved.\n'));
182
+
183
+ } else if (field === 'dashboardBindAddress') {
184
+ const { value } = await inquirer.prompt([{
185
+ type: 'list',
186
+ name: 'value',
187
+ message: 'Which interfaces should the dashboard listen on?',
188
+ default: config.dashboardBindAddress,
189
+ choices: [
190
+ { name: `This machine only (${BIND_LOOPBACK})`, value: BIND_LOOPBACK },
191
+ { name: `All interfaces (${BIND_ALL})`, value: BIND_ALL },
192
+ { name: '← Cancel', value: 'cancel' },
193
+ ],
194
+ }]);
195
+
196
+ if (value === 'cancel') continue;
197
+
198
+ // Opening the listener up while there is no password would publish an
199
+ // unauthenticated dashboard to the network.
200
+ if (!isLoopbackBind(value) && authMode === AUTH_MODES.NONE) {
201
+ console.log(chalk.yellow('\n This dashboard has no password, so it can only listen on this machine.'));
202
+ console.log(chalk.gray(' Set a password first (Dashboard Auth), then change this.\n'));
203
+ continue;
204
+ }
205
+
206
+ config.dashboardBindAddress = value;
207
+ saveConfig(config);
208
+ console.log(chalk.green('\n ✓ Saved. Restart the dashboard for it to take effect.\n'));
97
209
 
98
210
  } else if (field === 'acmeEmail') {
99
211
  const { value } = await inquirer.prompt([{
@@ -111,6 +223,62 @@ export default async function settingsMenu() {
111
223
  config.acmeEmail = value;
112
224
  saveConfig(config); // T016
113
225
 
226
+ } else if (field === 'deployDir') {
227
+ // Only NEW apps are created here. Existing apps keep the folder they
228
+ // were created in; moving one is done from the dashboard.
229
+ const { value } = await inquirer.prompt([{
230
+ type: 'input',
231
+ name: 'value',
232
+ message: `Folder for new deployed apps (empty = ${defaultDeployRoot()}):`,
233
+ default: config.deployDir || '',
234
+ validate(input) {
235
+ if (!input.trim()) return true;
236
+ const problem = validateDeployDir(input);
237
+ return problem ? chalk.red(problem) : true;
238
+ },
239
+ }]);
240
+ config.deployDir = value.trim() ? value.trim() : null;
241
+ saveConfig(config);
242
+ console.log(chalk.green(`\n ✓ Saved. New apps will be created in ${deployRoot()}.`));
243
+ console.log(chalk.gray(' Existing apps stay where they are.\n'));
244
+
245
+ } else if (field === 'sslAutoRenew') {
246
+ // The background service renews HTTP-01 certificates on its own. DNS-01
247
+ // certificates (wildcards) need a TXT record added by hand, so they only
248
+ // ever get the expiry warning.
249
+ const { enabled } = await inquirer.prompt([{
250
+ type: 'list',
251
+ name: 'enabled',
252
+ message: 'Renew certificates automatically before they expire?',
253
+ default: autoRenew.enabled,
254
+ choices: [
255
+ { name: 'On — renew HTTP-validated certificates in the background', value: true },
256
+ { name: 'Off — only warn before expiry', value: false },
257
+ ],
258
+ }]);
259
+ config.sslAutoRenew = enabled;
260
+
261
+ if (enabled) {
262
+ const { days } = await inquirer.prompt([{
263
+ type: 'input',
264
+ name: 'days',
265
+ message: `Renew how many days before expiry? (${MIN_AUTO_RENEW_DAYS}-${MAX_AUTO_RENEW_DAYS})`,
266
+ default: String(autoRenew.days),
267
+ validate(input) {
268
+ return normalizeAutoRenewDays(input) !== null
269
+ || chalk.red(`Enter a whole number from ${MIN_AUTO_RENEW_DAYS} to ${MAX_AUTO_RENEW_DAYS}.`);
270
+ },
271
+ }]);
272
+ config.sslAutoRenewDays = normalizeAutoRenewDays(days);
273
+ }
274
+ saveConfig(config);
275
+
276
+ if (enabled && !config.acmeEmail) {
277
+ console.log(chalk.yellow('\n ⚠ Set an ACME email too — renewal cannot run without one.\n'));
278
+ } else {
279
+ console.log(chalk.green('\n ✓ Saved. The background service picks it up on its next check.\n'));
280
+ }
281
+
114
282
  } else {
115
283
  const { value } = await inquirer.prompt([{
116
284
  type: 'input',
@@ -0,0 +1,167 @@
1
+ /**
2
+ * cli/menus/uninstall.js
3
+ *
4
+ * `ezz uninstall --purge` — remove Easy DevOps itself.
5
+ *
6
+ * Without `--purge` this command does nothing except explain the difference
7
+ * between removing the service and removing Easy DevOps. That is deliberate:
8
+ * `uninstall` is a word people type expecting the smaller of the two meanings,
9
+ * and `ezz service uninstall` is almost always what they want. The destructive
10
+ * reading has to be asked for explicitly.
11
+ */
12
+
13
+ import chalk from 'chalk';
14
+ import inquirer from 'inquirer';
15
+ import ora from 'ora';
16
+
17
+ import { getDataDir } from '../../core/platform.js';
18
+ import { loadConfig } from '../../core/config.js';
19
+ import * as purgeCore from '../../core/purge.js';
20
+ import { humanBytes } from '../../core/cleanup.js';
21
+
22
+ /**
23
+ * @param {Object} [opts]
24
+ * @param {boolean} [opts.purge]
25
+ * @param {boolean} [opts.yes]
26
+ * @returns {Promise<number>} Process exit code
27
+ */
28
+ export async function uninstallCommand({ purge = false, yes = false } = {}) {
29
+ if (!purge) {
30
+ console.log();
31
+ console.log(' ' + chalk.bold('Uninstall'));
32
+ console.log(' ' + chalk.gray('-'.repeat(58)));
33
+ console.log();
34
+ console.log(' ' + chalk.white('Two different things are called "uninstall":'));
35
+ console.log();
36
+ console.log(' ' + chalk.white('ezz service uninstall')
37
+ + chalk.gray(' removes the background service only.'));
38
+ console.log(' ' + chalk.gray(' Your data, settings, domains and'));
39
+ console.log(' ' + chalk.gray(' certificates all stay. This is almost'));
40
+ console.log(' ' + chalk.gray(' always the one you want.'));
41
+ console.log();
42
+ console.log(' ' + chalk.white('ezz uninstall --purge')
43
+ + chalk.gray(' removes the service, the pinned runtime and'));
44
+ console.log(' ' + chalk.gray(' the data directory, after exporting a'));
45
+ console.log(' ' + chalk.gray(' backup. nginx, your sites and your'));
46
+ console.log(' ' + chalk.gray(' certificates are kept.'));
47
+ console.log();
48
+ console.log(' ' + chalk.gray('Nothing was changed.'));
49
+ console.log();
50
+ return 0;
51
+ }
52
+
53
+ const dataDir = getDataDir();
54
+ const config = loadConfig();
55
+
56
+ console.log();
57
+ console.log(' ' + chalk.bold('Remove Easy DevOps'));
58
+ console.log(' ' + chalk.gray('-'.repeat(58)));
59
+ console.log();
60
+
61
+ // Certificates are the one genuine question: they are private keys, and
62
+ // whether they are still wanted depends on whether nginx keeps serving the
63
+ // sites that use them. Default keep, as that is the safe reading.
64
+ let certificates = 'keep';
65
+
66
+ if (!yes) {
67
+ const { choice } = await inquirer.prompt([{
68
+ type: 'list',
69
+ name: 'choice',
70
+ message: 'What should happen to the SSL certificates?',
71
+ default: 'keep',
72
+ choices: [
73
+ {
74
+ name: `Keep them (recommended) - nginx keeps serving HTTPS from ${config.sslDir ?? 'the certificate directory'}`,
75
+ value: 'keep',
76
+ },
77
+ {
78
+ name: 'Delete them - only do this if nginx is not serving these sites any more',
79
+ value: 'remove',
80
+ },
81
+ ],
82
+ }]);
83
+ certificates = choice;
84
+ }
85
+
86
+ const outline = purgeCore.plan({ dataDir, certificates, config });
87
+
88
+ console.log();
89
+ console.log(' ' + chalk.bold('This will remove'));
90
+ for (const item of outline.removes) {
91
+ console.log(` ${chalk.yellow('-')} ${item.what} ${chalk.gray(item.path)}`);
92
+ }
93
+ console.log();
94
+ console.log(' ' + chalk.bold('This will keep'));
95
+ for (const item of outline.keeps) {
96
+ console.log(` ${chalk.green('=')} ${item.what} ${chalk.gray(item.path)}`);
97
+ }
98
+ console.log();
99
+ console.log(' ' + chalk.white('A backup of the data directory is exported first, and nothing is'));
100
+ console.log(' ' + chalk.white('removed if that backup fails.'));
101
+ console.log();
102
+
103
+ if (!yes) {
104
+ const { confirm } = await inquirer.prompt([{
105
+ type: 'input',
106
+ name: 'confirm',
107
+ message: 'Type "remove" to go ahead, or anything else to cancel:',
108
+ }]);
109
+
110
+ if (String(confirm).trim().toLowerCase() !== 'remove') {
111
+ console.log(' ' + chalk.gray('Nothing was changed.'));
112
+ console.log();
113
+ return 0;
114
+ }
115
+ }
116
+
117
+ console.log();
118
+ const spinner = ora('Working...').start();
119
+ const result = await purgeCore.purge({
120
+ dataDir,
121
+ certificates,
122
+ log: (line) => { spinner.text = line; },
123
+ });
124
+ spinner.stop();
125
+
126
+ if (result.step === 'backup') {
127
+ console.log(' ' + chalk.red('The backup could not be written, so nothing was removed.'));
128
+ console.log(' ' + result.reason);
129
+ console.log();
130
+ console.log(' ' + chalk.gray(result.hint));
131
+ console.log();
132
+ return 1;
133
+ }
134
+
135
+ console.log(' ' + chalk.green('Backup: ') + chalk.white(result.backup.path)
136
+ + chalk.gray(` (${humanBytes(result.backup.bytes)})`));
137
+ console.log();
138
+
139
+ for (const item of result.removed) {
140
+ console.log(' ' + chalk.gray(`removed ${item.what}: ${item.detail}`));
141
+ }
142
+
143
+ for (const failure of result.failed) {
144
+ console.log(' ' + chalk.yellow(`could not remove ${failure.what}: ${failure.reason}`));
145
+ }
146
+
147
+ console.log();
148
+ if (result.ok) {
149
+ console.log(' ' + chalk.green('Easy DevOps has been removed from this machine.'));
150
+ } else {
151
+ console.log(' ' + chalk.yellow('Easy DevOps was mostly removed; the items above need attention.'));
152
+ }
153
+
154
+ console.log();
155
+ console.log(' ' + chalk.bold('One step left - the package itself:'));
156
+ console.log();
157
+ console.log(' ' + chalk.white(result.finalCommand));
158
+ console.log();
159
+ console.log(' ' + chalk.gray('That cannot be done from here: npm would be deleting the files'));
160
+ console.log(' ' + chalk.gray('this command is running from.'));
161
+ console.log();
162
+ console.log(' ' + chalk.gray(`Your data is still at ${result.backup.path}`));
163
+ console.log(' ' + chalk.gray('Delete it when you are sure you will not want it back.'));
164
+ console.log();
165
+
166
+ return result.ok ? 0 : 1;
167
+ }