mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
chore: Add color to the install script
- This will only work on terminals setup to use color
This commit is contained in:
parent
4c340fd0ba
commit
e726e42cb5
2 changed files with 25 additions and 6 deletions
14
config/color-console.js
Normal file
14
config/color-console.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Console changes
|
||||
* This allows us to give the console some colour when running in a terminal
|
||||
*/
|
||||
|
||||
console.orange = (msg) => console.log('\x1b[33m%s\x1b[0m', msg);
|
||||
console.green = (msg) => console.log('\x1b[32m%s\x1b[0m', msg);
|
||||
console.red = (msg) => console.log('\x1b[31m%s\x1b[0m', msg);
|
||||
console.blue = (msg) => console.log('\x1b[34m%s\x1b[0m', msg);
|
||||
console.purple = (msg) => console.log('\x1b[35m%s\x1b[0m', msg);
|
||||
console.cyan = (msg) => console.log('\x1b[36m%s\x1b[0m', msg);
|
||||
console.yellow = (msg) => console.log('\x1b[33m%s\x1b[0m', msg);
|
||||
console.white = (msg) => console.log('\x1b[37m%s\x1b[0m', msg);
|
||||
console.gray = (msg) => console.log('\x1b[90m%s\x1b[0m', msg);
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
const fs = require('fs');
|
||||
const readline = require('readline');
|
||||
const { exit } = require('process');
|
||||
require('./color-console');
|
||||
|
||||
// Save the original console.log function
|
||||
const originalConsoleWarn = console.warn;
|
||||
|
|
@ -45,7 +46,7 @@ const askQuestion = (query) => {
|
|||
});
|
||||
|
||||
return new Promise((resolve) =>
|
||||
rl.question(query, (ans) => {
|
||||
rl.question("\x1b[34m" + query + "\n> " + "\x1b[0m", (ans) => {
|
||||
rl.close();
|
||||
resolve(ans);
|
||||
})
|
||||
|
|
@ -73,8 +74,11 @@ const askQuestion = (query) => {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
console.log('Welcome to the ChatGPT Clone install script!');
|
||||
console.log('Please answer the following questions to setup your environment.');
|
||||
// Lets colour the console
|
||||
console.purple('=== LibreChat First Install ===');
|
||||
console.cyan('Note: Leave blank to use the default value.');
|
||||
console.log(''); // New line
|
||||
|
||||
// Ask for the app title
|
||||
const title = await askQuestion(
|
||||
'Enter the app title (default: "LibreChat"): '
|
||||
|
|
@ -104,14 +108,15 @@ const askQuestion = (query) => {
|
|||
env['MONGO_URI'] = mongodb || 'mongodb://127.0.0.1:27017/LibreChat';
|
||||
// Very basic check to make sure they entered a url
|
||||
if (!env['MONGO_URI'].includes('://')) {
|
||||
console.warn('Warning: Your mongodb url looks incorrect, please double check it in the `.env` file.');
|
||||
console.orange('Warning: Your mongodb url looks incorrect, please double check it in the `.env` file.');
|
||||
}
|
||||
|
||||
// Update the env file
|
||||
loader.writeEnvFile(rootEnvPath, env);
|
||||
|
||||
// We can ask for more here if we want
|
||||
|
||||
console.log('Environment setup complete.');
|
||||
console.log(''); // New line
|
||||
console.green('Success! Please read our docs if you need help setting up the rest of the app.');
|
||||
console.log(''); // New line
|
||||
})();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue