easy-devops 0.2.7 → 1.0.1
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 -53
- package/install.sh +34 -12
- package/package.json +11 -12
- package/{cli → src/cli}/index.js +28 -6
- package/{cli → src/cli}/managers/domain-manager.js +143 -35
- package/{cli → src/cli}/managers/nginx-manager.js +43 -10
- package/src/cli/managers/ssl-manager.js +678 -0
- package/{cli → src/cli}/menus/dashboard.js +1 -1
- package/{cli → src/cli}/menus/settings.js +27 -8
- package/{cli → src/cli}/menus/update.js +1 -1
- package/{core → src/core}/config.js +5 -2
- package/{core → src/core}/db.js +1 -1
- package/{core → src/core}/detector.js +50 -87
- package/{core → src/core}/nginx-conf-generator.js +101 -64
- package/src/core/platform.js +61 -0
- package/{core → src/core}/shell.js +38 -2
- package/src/core/validators.js +96 -0
- package/{dashboard → src/dashboard}/lib/cert-reader.js +5 -5
- package/{dashboard → src/dashboard}/lib/nginx-service.js +47 -77
- package/src/dashboard/public/img/icon.png +0 -0
- package/src/dashboard/public/img/icon_b.png +0 -0
- package/{dashboard → src/dashboard}/public/js/app.js +206 -30
- package/{dashboard → src/dashboard}/routes/domains.js +96 -72
- package/{dashboard → src/dashboard}/routes/settings.js +19 -11
- package/src/dashboard/routes/ssl.js +281 -0
- package/src/dashboard/views/index.ejs +652 -0
- package/src/dashboard/views/partials/domain-form.ejs +356 -0
- package/src/dashboard/views/partials/domains-panel.ejs +101 -0
- package/src/dashboard/views/partials/login.ejs +167 -0
- package/src/dashboard/views/partials/nginx-panel.ejs +153 -0
- package/src/dashboard/views/partials/overview.ejs +142 -0
- package/src/dashboard/views/partials/settings-panel.ejs +68 -0
- package/src/dashboard/views/partials/sidebar.ejs +96 -0
- package/src/dashboard/views/partials/ssl-panel.ejs +176 -0
- package/{lib → src/lib}/installer/nvm-bootstrap.sh +8 -8
- package/{lib → src/lib}/installer/picker.sh +33 -16
- package/cli/managers/ssl-manager.js +0 -963
- package/dashboard/routes/ssl.js +0 -140
- package/dashboard/views/index.ejs +0 -327
- package/dashboard/views/partials/domain-form.ejs +0 -257
- package/dashboard/views/partials/domains-panel.ejs +0 -66
- package/dashboard/views/partials/login.ejs +0 -50
- package/dashboard/views/partials/nginx-panel.ejs +0 -90
- package/dashboard/views/partials/overview.ejs +0 -67
- package/dashboard/views/partials/settings-panel.ejs +0 -37
- package/dashboard/views/partials/sidebar.ejs +0 -45
- package/dashboard/views/partials/ssl-panel.ejs +0 -95
- /package/{cli → src/cli}/managers/node-manager.js +0 -0
- /package/{cli → src/cli}/menus/.gitkeep +0 -0
- /package/{cli → src/cli}/menus/domains.js +0 -0
- /package/{cli → src/cli}/menus/nginx.js +0 -0
- /package/{cli → src/cli}/menus/nodejs.js +0 -0
- /package/{cli → src/cli}/menus/ssl.js +0 -0
- /package/{dashboard → src/dashboard}/lib/.gitkeep +0 -0
- /package/{dashboard → src/dashboard}/lib/domains-db.js +0 -0
- /package/{dashboard → src/dashboard}/lib/nginx-conf-generator.js +0 -0
- /package/{dashboard → src/dashboard}/routes/.gitkeep +0 -0
- /package/{dashboard → src/dashboard}/routes/auth.js +0 -0
- /package/{dashboard → src/dashboard}/routes/nginx.js +0 -0
- /package/{dashboard → src/dashboard}/server.js +0 -0
- /package/{lib → src/lib}/installer/.gitkeep +0 -0
- /package/{lib → src/lib}/installer/detect.sh +0 -0
- /package/{lib → src/lib}/installer/node-versions.sh +0 -0
- /package/{lib → src/lib}/installer/progress.sh +0 -0
- /package/{lib → src/lib}/installer/winget-install.ps1 +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<!-- SSL Page -->
|
|
2
|
+
<div v-show="page === 'ssl'" class="w-full">
|
|
3
|
+
<div class="flex items-center justify-between mb-8">
|
|
4
|
+
<div>
|
|
5
|
+
<h2 class="text-2xl font-bold tracking-tight text-foreground">SSL Certificates</h2>
|
|
6
|
+
<p class="text-muted font-medium text-sm mt-1">Let's Encrypt certificates managed dynamically</p>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="flex gap-3">
|
|
9
|
+
<button @click="ssl.showCreateForm = !ssl.showCreateForm; ssl.createResult = null; ssl.createError = null" class="btn btn-secondary btn-sm">
|
|
10
|
+
{{ ssl.showCreateForm ? 'Cancel' : 'New Certificate' }}
|
|
11
|
+
</button>
|
|
12
|
+
<button @click="renewAll" :disabled="ssl.renewingDomain !== null" class="btn btn-primary btn-sm">
|
|
13
|
+
<svg v-if="ssl.renewingDomain === 'all'" class="w-3 h-3 animate-spin mr-1.5 inline-block" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>
|
|
14
|
+
{{ ssl.renewingDomain === 'all' ? 'Renewing All...' : 'Renew Expiring' }}
|
|
15
|
+
</button>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<!-- New Certificate inline form (Modal/Drawer block logic reused) -->
|
|
20
|
+
<transition name="modal">
|
|
21
|
+
<div v-if="ssl.showCreateForm" class="mb-8 stat-card overflow-hidden relative">
|
|
22
|
+
<div class="absolute top-0 left-0 w-full h-1 bg-primary/40"></div>
|
|
23
|
+
|
|
24
|
+
<div class="p-5 border-b border-border bg-black/5 dark:bg-white/5">
|
|
25
|
+
<h3 class="font-bold text-[15px] text-foreground tracking-tight">Create New Certificate</h3>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="p-5 bg-background">
|
|
28
|
+
<!-- Error / Result Alerts -->
|
|
29
|
+
<div v-if="ssl.createResult" class="mb-5 p-4 rounded-[12px] bg-green-500/10 border border-green-500/20 text-[13px] shadow-sm">
|
|
30
|
+
<p class="text-green-500 font-bold mb-1">Certificate created successfully</p>
|
|
31
|
+
<p class="text-muted font-mono"><span class="form-label inline mr-2 text-[10px]">Cert</span> {{ ssl.createResult.certPath }}</p>
|
|
32
|
+
<p class="text-muted font-mono"><span class="form-label inline mr-2 text-[10px]">Key</span> {{ ssl.createResult.keyPath }}</p>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div v-if="ssl.createError" class="mb-5 p-4 rounded-[12px] bg-red-500/10 border border-red-500/20 text-[13px] space-y-1.5 shadow-sm">
|
|
36
|
+
<p class="text-red-500 font-bold text-sm mb-1">Certificate creation failed</p>
|
|
37
|
+
<p class="text-muted"><span class="form-label inline mr-2 text-[10px]">Step</span> {{ ssl.createError.step }}</p>
|
|
38
|
+
<p class="text-muted"><span class="form-label inline mr-2 text-[10px]">Cause</span> {{ ssl.createError.cause }}</p>
|
|
39
|
+
<p class="text-muted"><span class="form-label inline mr-2 text-[10px]">Note</span> {{ ssl.createError.consequence }}</p>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<!-- DNS waiting state -->
|
|
43
|
+
<div v-if="ssl.dnsWaiting" class="p-4 rounded-[12px] bg-amber-500/10 border border-amber-500/20 text-sm shadow-sm space-y-3">
|
|
44
|
+
<p class="text-amber-500 font-bold">Add this DNS TXT record, then click Continue</p>
|
|
45
|
+
<div class="space-y-1 font-mono text-xs p-3 bg-black/5 dark:bg-white/5 border border-border/50 rounded-[10px]">
|
|
46
|
+
<p class="text-muted">Name: <span class="text-foreground">{{ ssl.dnsWaiting.txtName }}</span></p>
|
|
47
|
+
<p class="text-muted">Value: <span class="text-foreground border border-border/30 px-1 py-0.5 rounded break-all select-all">{{ ssl.dnsWaiting.txtValue }}</span></p>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="flex gap-2 pt-2">
|
|
50
|
+
<button @click="confirmDns()" :disabled="ssl.dnsConfirming" class="btn btn-primary min-w-[120px]">
|
|
51
|
+
{{ ssl.dnsConfirming ? 'Verifying...' : "I've added the TXT record" }}
|
|
52
|
+
</button>
|
|
53
|
+
<button @click="cancelDns()" :disabled="ssl.dnsConfirming" class="btn btn-secondary">Cancel</button>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<!-- Input form -->
|
|
58
|
+
<div v-if="!ssl.dnsWaiting">
|
|
59
|
+
<div class="flex flex-col sm:flex-row sm:items-center gap-6 mb-6 pb-6 border-b border-border/50">
|
|
60
|
+
<label class="flex items-start gap-3 cursor-pointer group">
|
|
61
|
+
<input type="radio" v-model="ssl.createMethod" value="http" class="w-4 h-4 mt-0.5 text-primary bg-input border-border focus:ring-primary focus:ring-offset-background" />
|
|
62
|
+
<div class="flex flex-col">
|
|
63
|
+
<span class="text-[13px] font-bold text-foreground group-hover:text-primary transition-colors">HTTP Challenge</span>
|
|
64
|
+
<span class="text-[11px] font-medium text-muted mt-0.5">DNS A record must point to this server</span>
|
|
65
|
+
</div>
|
|
66
|
+
</label>
|
|
67
|
+
<label class="flex items-start gap-3 cursor-pointer group">
|
|
68
|
+
<input type="radio" v-model="ssl.createMethod" value="dns" class="w-4 h-4 mt-0.5 text-primary bg-input border-border focus:ring-primary focus:ring-offset-background" />
|
|
69
|
+
<div class="flex flex-col">
|
|
70
|
+
<span class="text-[13px] font-bold text-foreground group-hover:text-primary transition-colors">DNS Challenge</span>
|
|
71
|
+
<span class="text-[11px] font-medium text-muted mt-0.5">Requires adding a TXT record to your DNS provider</span>
|
|
72
|
+
</div>
|
|
73
|
+
</label>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-6 items-end">
|
|
77
|
+
<div class="w-full">
|
|
78
|
+
<label class="form-label">Email (Let's Encrypt)</label>
|
|
79
|
+
<input v-model="ssl.createEmail" type="email" class="form-input" placeholder="admin@example.com" />
|
|
80
|
+
</div>
|
|
81
|
+
<div class="w-full">
|
|
82
|
+
<label class="form-label">Domain Name</label>
|
|
83
|
+
<input v-model="ssl.createDomain" @keyup.enter="createCert()" class="form-input" placeholder="example.com" />
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div class="flex items-center gap-4 py-1">
|
|
87
|
+
<label class="relative inline-flex items-center cursor-pointer flex-shrink-0">
|
|
88
|
+
<input type="checkbox" v-model="ssl.createWww" class="sr-only peer" />
|
|
89
|
+
<div class="w-10 h-5 bg-black/20 dark:bg-white/10 border border-border peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-primary"></div>
|
|
90
|
+
</label>
|
|
91
|
+
<span class="text-[13px] font-bold text-foreground">Include www</span>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div class="flex justify-end pt-2">
|
|
95
|
+
<button @click="createCert()" :disabled="ssl.creating || !ssl.createDomain.trim() || !ssl.createEmail.trim()" class="btn btn-primary min-w-[120px]">
|
|
96
|
+
<svg v-if="ssl.creating" class="w-4 h-4 animate-spin inline-block mr-1.5" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>
|
|
97
|
+
{{ ssl.creating ? 'Working...' : 'Create Certificate' }}
|
|
98
|
+
</button>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</transition>
|
|
105
|
+
|
|
106
|
+
<div v-if="ssl.error" class="mb-6 p-4 rounded-[12px] bg-red-500/10 border border-red-500/20 text-red-500 text-[13px] font-bold shadow-sm">
|
|
107
|
+
{{ ssl.error }}
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div v-if="ssl.loading" class="text-muted text-sm flex items-center gap-3">
|
|
111
|
+
<div class="w-full flex flex-col gap-2">
|
|
112
|
+
<div class="h-16 w-full animate-pulse-fx stat-card"></div>
|
|
113
|
+
<div class="h-16 w-full animate-pulse-fx stat-card"></div>
|
|
114
|
+
<div class="h-16 w-full animate-pulse-fx stat-card"></div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<div v-else-if="ssl.certs.length === 0" class="stat-card p-16 text-center relative overflow-hidden">
|
|
119
|
+
<div class="absolute top-0 left-0 w-full h-1 bg-primary/40"></div>
|
|
120
|
+
<div class="flex justify-center mb-4">
|
|
121
|
+
<div class="w-16 h-16 rounded-[16px] flex items-center justify-center text-primary shadow-lg" style="background: rgba(var(--color-primary-rgb), 0.1); color: var(--color-primary);">
|
|
122
|
+
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"></path></svg>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
<h3 class="text-lg font-semibold text-foreground tracking-tight">No SSL Certificates</h3>
|
|
126
|
+
<p class="text-muted text-sm mt-2 max-w-sm mx-auto">It's highly recommended to generate an SSL certificate to secure your proxies.</p>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div v-else class="stat-card overflow-hidden flex flex-col">
|
|
130
|
+
<!-- Header pseudo-row -->
|
|
131
|
+
<div class="flex items-center px-6 py-3 border-b border-border bg-black/5 dark:bg-white/5">
|
|
132
|
+
<div class="w-8 shrink-0"></div> <!-- for status dot -->
|
|
133
|
+
<div class="flex-1 form-label !mb-0 text-left text-[11px] font-bold">Domain Name</div>
|
|
134
|
+
<div class="w-32 form-label !mb-0 text-left text-[11px] font-bold">Expiry</div>
|
|
135
|
+
<div class="w-32 form-label !mb-0 text-left text-[11px] font-bold">Time Left</div>
|
|
136
|
+
<div class="w-24 form-label !mb-0 text-left text-[11px] font-bold">Status</div>
|
|
137
|
+
<div class="w-32 form-label !mb-0 text-right text-[11px] font-bold pr-2">Action</div>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<!-- Rows -->
|
|
141
|
+
<div v-for="cert in ssl.certs" :key="cert.domain" class="domain-row group">
|
|
142
|
+
<!-- Status Dot based on expiry -->
|
|
143
|
+
<div class="w-8 shrink-0 flex items-center justify-center -ml-1">
|
|
144
|
+
<div class="status-dot" :class="cert.daysLeft > 10 ? 'active' : 'inactive'"></div>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<!-- Domain -->
|
|
148
|
+
<div class="flex-1 min-w-0 pr-4">
|
|
149
|
+
<div class="font-mono text-[14px] font-semibold text-foreground truncate select-all">{{ cert.domain }}</div>
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
<!-- Expiry Date -->
|
|
153
|
+
<div class="w-32 shrink-0 truncate text-[13px] text-muted">
|
|
154
|
+
{{ cert.expiry ? new Date(cert.expiry).toLocaleDateString() : '—' }}
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<!-- Days Left -->
|
|
158
|
+
<div class="w-32 shrink-0 truncate text-[14px] font-mono font-bold" :class="certDaysColor(cert)">
|
|
159
|
+
{{ cert.daysLeft !== null ? cert.daysLeft + 'd' : '—' }}
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
<!-- Badges -->
|
|
163
|
+
<div class="w-24 shrink-0">
|
|
164
|
+
<span class="badge" :class="'badge-' + certBadgeType(cert)">{{ certStatus(cert) }}</span>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<!-- Actions -->
|
|
168
|
+
<div class="w-32 flex justify-end shrink-0 domain-actions">
|
|
169
|
+
<button @click="renewCert(cert.domain)" :disabled="ssl.renewingDomain !== null" class="btn btn-secondary btn-sm h-8" :class="{ 'opacity-50': ssl.renewingDomain !== null }">
|
|
170
|
+
<svg v-if="ssl.renewingDomain === cert.domain" class="w-3 h-3 animate-spin mr-1 inline-block" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>
|
|
171
|
+
{{ ssl.renewingDomain === cert.domain ? 'Working' : 'Renew' }}
|
|
172
|
+
</button>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
@@ -17,9 +17,9 @@ bootstrap_nvm() {
|
|
|
17
17
|
# Step 1: Install nvm if not already present
|
|
18
18
|
# ------------------------------------------------------------------
|
|
19
19
|
if [ -f "$nvm_dir/nvm.sh" ]; then
|
|
20
|
-
|
|
20
|
+
printf ' nvm already installed at %s — skipping download\n' "$nvm_dir"
|
|
21
21
|
else
|
|
22
|
-
|
|
22
|
+
printf ' Downloading and installing nvm…\n'
|
|
23
23
|
|
|
24
24
|
local install_ok=false
|
|
25
25
|
if command -v curl >/dev/null 2>&1; then
|
|
@@ -34,14 +34,14 @@ bootstrap_nvm() {
|
|
|
34
34
|
fi
|
|
35
35
|
|
|
36
36
|
if [ "$install_ok" = "false" ]; then
|
|
37
|
-
|
|
38
|
-
printf '
|
|
37
|
+
printf 'Error: nvm download failed\n' >&2
|
|
38
|
+
printf 'Manual recovery:\n' >&2
|
|
39
39
|
printf ' curl -o- %s | bash\n' "$nvm_install_url" >&2
|
|
40
40
|
printf ' Then run: source ~/.nvm/nvm.sh\n' >&2
|
|
41
41
|
return 1
|
|
42
42
|
fi
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
printf ' nvm installed at %s\n' "$nvm_dir"
|
|
45
45
|
fi
|
|
46
46
|
|
|
47
47
|
# ------------------------------------------------------------------
|
|
@@ -66,12 +66,12 @@ bootstrap_nvm() {
|
|
|
66
66
|
fi
|
|
67
67
|
|
|
68
68
|
if ! command -v nvm >/dev/null 2>&1; then
|
|
69
|
-
|
|
70
|
-
printf '
|
|
69
|
+
printf 'Error: nvm command not available after install\n' >&2
|
|
70
|
+
printf 'Manual recovery:\n' >&2
|
|
71
71
|
printf ' source ~/.nvm/nvm.sh\n' >&2
|
|
72
72
|
printf ' Then re-run: bash install.sh\n' >&2
|
|
73
73
|
return 1
|
|
74
74
|
fi
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
printf ' nvm is active in this session\n'
|
|
77
77
|
}
|
|
@@ -60,19 +60,24 @@ _pick_tty() {
|
|
|
60
60
|
RESET="\033[0m"
|
|
61
61
|
HIGHLIGHT="\033[7m"
|
|
62
62
|
|
|
63
|
-
#
|
|
64
|
-
printf '\033[?25l'
|
|
65
|
-
|
|
66
|
-
# Save terminal state and restore on exit
|
|
63
|
+
# Save terminal state — guard against stty failures (e.g. dumb terminals)
|
|
67
64
|
local old_stty
|
|
68
65
|
old_stty="$(stty -g 2>/dev/null || true)"
|
|
69
66
|
|
|
70
|
-
# Cleanup
|
|
67
|
+
# Cleanup: restore terminal state and show cursor
|
|
71
68
|
_tty_cleanup() {
|
|
72
|
-
stty "$old_stty" 2>/dev/null || true
|
|
69
|
+
[ -n "$old_stty" ] && stty "$old_stty" 2>/dev/null || true
|
|
73
70
|
printf '\033[?25h' # show cursor
|
|
74
71
|
}
|
|
75
|
-
|
|
72
|
+
|
|
73
|
+
# Use a flag instead of `return` inside the trap handler.
|
|
74
|
+
# `return` in a trap does not exit the outer function in bash —
|
|
75
|
+
# it only returns from the trap handler itself.
|
|
76
|
+
local _cancelled=false
|
|
77
|
+
trap '_tty_cleanup; _cancelled=true' INT TERM
|
|
78
|
+
|
|
79
|
+
# Hide cursor only if the terminal supports it
|
|
80
|
+
printf '\033[?25l' 2>/dev/null || true
|
|
76
81
|
|
|
77
82
|
printf '\nSelect a Node.js version (up/down arrows, Enter to confirm, q to quit):\n\n'
|
|
78
83
|
|
|
@@ -90,12 +95,22 @@ _pick_tty() {
|
|
|
90
95
|
stty raw -echo 2>/dev/null || true
|
|
91
96
|
|
|
92
97
|
while true; do
|
|
98
|
+
# Check cancellation flag (set by INT/TERM trap)
|
|
99
|
+
if [ "$_cancelled" = "true" ]; then
|
|
100
|
+
break
|
|
101
|
+
fi
|
|
102
|
+
|
|
93
103
|
local ch seq1 seq2
|
|
94
|
-
IFS= read -r -
|
|
104
|
+
IFS= read -r -n1 ch < /dev/tty 2>/dev/null || ch=""
|
|
105
|
+
|
|
106
|
+
# Check flag again after read (signal may have arrived during read)
|
|
107
|
+
if [ "$_cancelled" = "true" ]; then
|
|
108
|
+
break
|
|
109
|
+
fi
|
|
95
110
|
|
|
96
111
|
if [ "$ch" = $'\x1b' ]; then
|
|
97
|
-
IFS= read -r -
|
|
98
|
-
IFS= read -r -
|
|
112
|
+
IFS= read -r -n1 -t 0.1 seq1 < /dev/tty 2>/dev/null || seq1=""
|
|
113
|
+
IFS= read -r -n1 -t 0.1 seq2 < /dev/tty 2>/dev/null || seq2=""
|
|
99
114
|
if [ "$seq1" = "[" ]; then
|
|
100
115
|
case "$seq2" in
|
|
101
116
|
A) [ "$selected" -gt 0 ] && selected=$(( selected - 1 )) ;;
|
|
@@ -105,13 +120,11 @@ _pick_tty() {
|
|
|
105
120
|
elif [ "$ch" = $'\n' ] || [ "$ch" = $'\r' ] || [ -z "$ch" ]; then
|
|
106
121
|
break
|
|
107
122
|
elif [ "$ch" = "q" ] || [ "$ch" = "Q" ]; then
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
printf '\n'
|
|
111
|
-
return 2
|
|
123
|
+
_cancelled=true
|
|
124
|
+
break
|
|
112
125
|
fi
|
|
113
126
|
|
|
114
|
-
# Redraw: move cursor up count lines
|
|
127
|
+
# Redraw: move cursor up count lines, clear each line, redraw
|
|
115
128
|
local k
|
|
116
129
|
for (( k=0; k<count; k++ )); do
|
|
117
130
|
printf "${CLEAR_LINE}\033[1A"
|
|
@@ -130,6 +143,10 @@ _pick_tty() {
|
|
|
130
143
|
trap - INT TERM
|
|
131
144
|
printf '\n'
|
|
132
145
|
|
|
146
|
+
if [ "$_cancelled" = "true" ]; then
|
|
147
|
+
return 2
|
|
148
|
+
fi
|
|
149
|
+
|
|
133
150
|
PICKED_VERSION="$(printf '%s' "${NODE_RELEASES[$selected]}" | cut -d'|' -f1)"
|
|
134
151
|
}
|
|
135
152
|
|
|
@@ -147,7 +164,7 @@ _pick_numbered() {
|
|
|
147
164
|
local choice
|
|
148
165
|
while true; do
|
|
149
166
|
printf 'Enter number (1-%d), or q to quit: ' "$count"
|
|
150
|
-
IFS= read -r choice
|
|
167
|
+
IFS= read -r choice < /dev/tty
|
|
151
168
|
if [ "$choice" = "q" ] || [ "$choice" = "Q" ]; then
|
|
152
169
|
return 2
|
|
153
170
|
fi
|