@quangnv13/nonstop 1.0.3 → 1.0.4
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/dist/ui.js +54 -36
- package/package.json +1 -1
package/dist/ui.js
CHANGED
|
@@ -172,10 +172,15 @@ async function launchControlCenter() {
|
|
|
172
172
|
let config = (0, config_js_1.loadConfigFromDisk)();
|
|
173
173
|
const isTTY = process.stdin.isTTY;
|
|
174
174
|
const wasRaw = process.stdin.isRaw;
|
|
175
|
-
|
|
175
|
+
let rl;
|
|
176
176
|
try {
|
|
177
177
|
if ((0, config_js_1.getMissingConfigFields)(config).length > 0) {
|
|
178
|
-
|
|
178
|
+
const result = await runSetupWizard(config);
|
|
179
|
+
config = result.config;
|
|
180
|
+
rl = result.rl;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stdout });
|
|
179
184
|
}
|
|
180
185
|
let lastSelection = 0;
|
|
181
186
|
while (true) {
|
|
@@ -230,7 +235,12 @@ async function launchControlCenter() {
|
|
|
230
235
|
}
|
|
231
236
|
}
|
|
232
237
|
finally {
|
|
233
|
-
rl
|
|
238
|
+
if (rl) {
|
|
239
|
+
try {
|
|
240
|
+
rl.close();
|
|
241
|
+
}
|
|
242
|
+
catch { /* ignore */ }
|
|
243
|
+
}
|
|
234
244
|
process.stdout.write('\u001b[?25h');
|
|
235
245
|
if (isTTY) {
|
|
236
246
|
try {
|
|
@@ -242,8 +252,7 @@ async function launchControlCenter() {
|
|
|
242
252
|
console.log(chalk_1.default.gray('Đã thoát nonstop client.'));
|
|
243
253
|
}
|
|
244
254
|
}
|
|
245
|
-
async function runSetupWizard(currentConfig
|
|
246
|
-
rl.pause();
|
|
255
|
+
async function runSetupWizard(currentConfig) {
|
|
247
256
|
const language = await runSelectionMenu(() => {
|
|
248
257
|
console.log(titleBox('Thiết lập nonstop'));
|
|
249
258
|
console.log(chalk_1.default.gray(' Chọn ngôn ngữ / Choose language:'));
|
|
@@ -251,39 +260,48 @@ async function runSetupWizard(currentConfig, rl) {
|
|
|
251
260
|
{ label: 'Tiếng Việt (vi)', value: 'vi' },
|
|
252
261
|
{ label: 'English (en)', value: 'en' }
|
|
253
262
|
], currentConfig.language === 'en' ? 1 : 0);
|
|
254
|
-
rl.resume();
|
|
255
263
|
const t = (0, i18n_js_1.createTranslator)(language);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const telegramBotToken = await askWithDefault(rl, t('wizard.token'), currentConfig.telegramBotToken);
|
|
260
|
-
const adminUsername = await askWithDefault(rl, t('wizard.admin'), currentConfig.adminUsername);
|
|
261
|
-
const clientName = await askWithDefault(rl, t('wizard.clientName'), currentConfig.clientName);
|
|
262
|
-
rl.pause();
|
|
263
|
-
const startupMode = await runSelectionMenu(() => {
|
|
264
|
+
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stdout });
|
|
265
|
+
try {
|
|
266
|
+
clearScreen();
|
|
264
267
|
console.log(titleBox(t('wizard.title')));
|
|
265
|
-
console.log(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
268
|
+
console.log('');
|
|
269
|
+
const telegramBotToken = await askWithDefault(rl, t('wizard.token'), currentConfig.telegramBotToken);
|
|
270
|
+
const adminUsername = await askWithDefault(rl, t('wizard.admin'), currentConfig.adminUsername);
|
|
271
|
+
const clientName = await askWithDefault(rl, t('wizard.clientName'), currentConfig.clientName);
|
|
272
|
+
rl.pause();
|
|
273
|
+
const startupMode = await runSelectionMenu(() => {
|
|
274
|
+
console.log(titleBox(t('wizard.title')));
|
|
275
|
+
console.log(chalk_1.default.gray(` ${t('wizard.startupMode')}:`));
|
|
276
|
+
}, [
|
|
277
|
+
{ label: `Tắt (disabled)`, value: 'disabled' },
|
|
278
|
+
{ label: `Chạy nền (background)`, value: 'background' },
|
|
279
|
+
{ label: `Mở giao diện (open-ui)`, value: 'open-ui' }
|
|
280
|
+
], 0);
|
|
281
|
+
rl.resume();
|
|
282
|
+
const nextConfig = {
|
|
283
|
+
...currentConfig,
|
|
284
|
+
language,
|
|
285
|
+
telegramBotToken,
|
|
286
|
+
adminUsername,
|
|
287
|
+
telegramUsername: adminUsername,
|
|
288
|
+
clientName,
|
|
289
|
+
startupMode
|
|
290
|
+
};
|
|
291
|
+
(0, config_js_1.saveConfigToDisk)(nextConfig);
|
|
292
|
+
clearScreen();
|
|
293
|
+
console.log(titleBox(t('wizard.title')));
|
|
294
|
+
console.log(`\n${chalk_1.default.green(t('wizard.complete'))}`);
|
|
295
|
+
await pause(rl);
|
|
296
|
+
return { config: nextConfig, rl };
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
try {
|
|
300
|
+
rl.close();
|
|
301
|
+
}
|
|
302
|
+
catch { /* ignore */ }
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
287
305
|
}
|
|
288
306
|
async function handleToggleRuntime(config, rl) {
|
|
289
307
|
const status = (0, runtime_manager_js_1.getRuntimeStatus)();
|