mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 08:20:14 +01:00
ci(backend-review.yml): add linter step to the backend review workflow (#625)
* ci(backend-review.yml): add linter step to the backend review workflow * chore(backend-review.yml): remove prettier from lint-action configuration * chore: apply new linting workflow * chore(lint-staged.config.js): reorder lint-staged tasks for JavaScript and TypeScript files * chore(eslint): update ignorePatterns in .eslintrc.js chore(lint-action): remove prettier option in backend-review.yml chore(package.json): add lint and lint:fix scripts * chore(lint-staged.config.js): remove prettier --write command for js, jsx, ts, tsx files * chore(titleConvo.js): remove unnecessary console.log statement chore(titleConvo.js): add missing comma in options object * chore: apply linting to all files * chore(lint-staged.config.js): update lint-staged configuration to include prettier formatting
This commit is contained in:
parent
637bb6bc11
commit
e5336039fc
231 changed files with 1688 additions and 1526 deletions
|
|
@ -1,8 +1,8 @@
|
|||
const connectDb = require("@librechat/backend/lib/db/connectDb");
|
||||
const migrateDb = require("@librechat/backend/lib/db/migrateDb");
|
||||
const { registerUser } = require("@librechat/backend/server/services/auth.service");
|
||||
const { askQuestion } = require("./helpers");
|
||||
const User = require("@librechat/backend/models/User");
|
||||
const connectDb = require('@librechat/backend/lib/db/connectDb');
|
||||
const migrateDb = require('@librechat/backend/lib/db/migrateDb');
|
||||
const { registerUser } = require('@librechat/backend/server/services/auth.service');
|
||||
const { askQuestion } = require('./helpers');
|
||||
const User = require('@librechat/backend/models/User');
|
||||
|
||||
const silentExit = (code = 0) => {
|
||||
console.log = () => {};
|
||||
|
|
@ -130,6 +130,6 @@ const silentExit = (code = 0) => {
|
|||
}
|
||||
|
||||
// Done!
|
||||
console.green("User created successfully!")
|
||||
console.green('User created successfully!')
|
||||
silentExit(0);
|
||||
})();
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
* Helper functions
|
||||
* This allows us to give the console some colour when running in a terminal
|
||||
*/
|
||||
const readline = require("readline");
|
||||
const readline = require('readline');
|
||||
|
||||
const askQuestion = (query) => {
|
||||
const rl = readline.createInterface({
|
||||
|
|
@ -11,10 +11,10 @@ const askQuestion = (query) => {
|
|||
});
|
||||
|
||||
return new Promise((resolve) =>
|
||||
rl.question("\x1b[36m" + query + "\n> " + "\x1b[0m", (ans) => {
|
||||
rl.question('\x1b[36m' + query + '\n> ' + '\x1b[0m', (ans) => {
|
||||
rl.close();
|
||||
resolve(ans);
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -58,29 +58,29 @@ let env = {};
|
|||
|
||||
// Ask for the app title
|
||||
const title = await askQuestion(
|
||||
'Enter the app title (default: "LibreChat"): '
|
||||
'Enter the app title (default: "LibreChat"): ',
|
||||
);
|
||||
env['APP_TITLE'] = title || 'LibreChat';
|
||||
|
||||
// Ask for OPENAI_API_KEY
|
||||
const key = await askQuestion(
|
||||
'Enter your OPENAI_API_KEY (default: "user_provided"): '
|
||||
'Enter your OPENAI_API_KEY (default: "user_provided"): ',
|
||||
);
|
||||
env['OPENAI_API_KEY'] = key || 'user_provided';
|
||||
|
||||
// GPT4???
|
||||
const gpt4 = await askQuestion(
|
||||
'Do you have access to the GPT4 api (y/n)? Default: n'
|
||||
'Do you have access to the GPT4 api (y/n)? Default: n',
|
||||
);
|
||||
if (gpt4 == 'y' || gpt4 == 'yes') {
|
||||
env['OPENAI_MODELS'] = "gpt-3.5-turbo,gpt-3.5-turbo-0301,text-davinci-003,gpt-4,gpt-4-0314"
|
||||
env['OPENAI_MODELS'] = 'gpt-3.5-turbo,gpt-3.5-turbo-0301,text-davinci-003,gpt-4,gpt-4-0314'
|
||||
} else {
|
||||
env['OPENAI_MODELS'] = "gpt-3.5-turbo,gpt-3.5-turbo-0301,text-davinci-003"
|
||||
env['OPENAI_MODELS'] = 'gpt-3.5-turbo,gpt-3.5-turbo-0301,text-davinci-003'
|
||||
}
|
||||
|
||||
// Ask about mongodb
|
||||
const mongodb = await askQuestion(
|
||||
'What is your mongodb url? (default: mongodb://127.0.0.1:27017/LibreChat)'
|
||||
'What is your mongodb url? (default: mongodb://127.0.0.1:27017/LibreChat)',
|
||||
);
|
||||
env['MONGO_URI'] = mongodb || 'mongodb://127.0.0.1:27017/LibreChat';
|
||||
// Very basic check to make sure they entered a url
|
||||
|
|
@ -90,7 +90,7 @@ let env = {};
|
|||
|
||||
// Lets ask about open registration
|
||||
const openReg = await askQuestion(
|
||||
'Do you want to allow user registration (y/n)? Default: y'
|
||||
'Do you want to allow user registration (y/n)? Default: y',
|
||||
);
|
||||
if (openReg === 'n' || openReg === 'no') {
|
||||
env['ALLOW_REGISTRATION'] = 'false';
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Env {
|
|||
} else {
|
||||
console.warn('The default .env file was not found');
|
||||
}
|
||||
|
||||
|
||||
const environment = this.currentEnvironment();
|
||||
|
||||
// Load the environment specific env file
|
||||
|
|
@ -95,8 +95,8 @@ class Env {
|
|||
/**
|
||||
* Resolve the location of the env file
|
||||
*
|
||||
* @param {String} envFile
|
||||
* @returns
|
||||
* @param {String} envFile
|
||||
* @returns
|
||||
*/
|
||||
resolve(envFile) {
|
||||
return path.resolve(process.cwd(), envFile);
|
||||
|
|
@ -157,7 +157,7 @@ class Env {
|
|||
}
|
||||
// Skip lines with quotes and numbers already
|
||||
// Todo: this could be one regex
|
||||
const wrappedValue = value.includes(' ') && ! value.includes('"') && ! value.includes("'") && !/\d/.test(value) ? `"${value}"` : value;
|
||||
const wrappedValue = value.includes(' ') && ! value.includes('"') && ! value.includes('\'') && !/\d/.test(value) ? `"${value}"` : value;
|
||||
return `${key}=${wrappedValue}`;
|
||||
});
|
||||
|
||||
|
|
@ -165,12 +165,11 @@ class Env {
|
|||
fs.writeFileSync(filePath, updatedContent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate Secure Random Strings
|
||||
*
|
||||
* @param {Number} length The length of the random string
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
generateSecureRandomString(length = 32) {
|
||||
return crypto.randomBytes(length).toString('hex');
|
||||
|
|
@ -186,8 +185,8 @@ class Env {
|
|||
/**
|
||||
* Get an environment variable
|
||||
*
|
||||
* @param {String} variable
|
||||
* @returns
|
||||
* @param {String} variable
|
||||
* @returns
|
||||
*/
|
||||
get(variable) {
|
||||
return process.env[variable];
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ if (!fs.existsSync(clientEnvPath)) {
|
|||
/**
|
||||
* Refactor the ENV if it has a prod_/dev_ version
|
||||
*
|
||||
* @param {*} varDev
|
||||
* @param {*} varProd
|
||||
* @param {*} varName
|
||||
* @param {*} varDev
|
||||
* @param {*} varProd
|
||||
* @param {*} varName
|
||||
*/
|
||||
function refactorPairedEnvVar(varDev, varProd, varName) {
|
||||
// Lets validate if either of these are undefined, if so lets use the non-undefined one
|
||||
|
|
@ -103,7 +103,7 @@ const removeEnvs = {
|
|||
'# Don\'t forget to set Node env to development in the Server configuration section above': 'remove',
|
||||
'# if you want to run in dev mode': 'remove',
|
||||
'# Change these values to domain if deploying:': 'remove',
|
||||
'# Set Node env to development if running in dev mode.': 'remove'
|
||||
'# Set Node env to development if running in dev mode.': 'remove',
|
||||
}
|
||||
loader.writeEnvFile(rootEnvPath, removeEnvs)
|
||||
|
||||
|
|
@ -119,13 +119,13 @@ loader.addSecureEnvVar(rootEnvPath, 'CREDS_IV', 16);
|
|||
loader.addSecureEnvVar(rootEnvPath, 'JWT_SECRET', 32);
|
||||
|
||||
// Lets update the openai key name, not the best spot in the env file but who cares ¯\_(ツ)_/¯
|
||||
loader.writeEnvFile(rootEnvPath, {'OPENAI_API_KEY': initEnv['OPENAI_KEY']})
|
||||
loader.writeEnvFile(rootEnvPath, { 'OPENAI_API_KEY': initEnv['OPENAI_KEY'] })
|
||||
|
||||
// TODO: we need to copy over the value of: APP_TITLE
|
||||
fs.appendFileSync(rootEnvPath, '\n\n##########################\n# Frontend Vite Variables:\n##########################\n');
|
||||
const frontend = {
|
||||
'APP_TITLE': initEnv['VITE_APP_TITLE'] || '"LibreChat"',
|
||||
'ALLOW_REGISTRATION': 'true'
|
||||
'ALLOW_REGISTRATION': 'true',
|
||||
}
|
||||
loader.writeEnvFile(rootEnvPath, frontend)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue