ToolJet/server/scripts/env-utils.ts
Siddharth Pundir 33e5dfffa5
Feat/ldap group sync (#14655)
* Moving group sync for ldap from env to Ui

* Structring the code

* Resolving conflicts

* Updating the SSO Tag UI

* create app CTA fix

* Updated the length of folder name edit to the 50 character

* Handled empty space name validation in table name

* Fixed the migration for ldap and saml group sync

* Fix UI issue of The menu actions still appear when import app is selected in dashboard

* Trimmmed Extra spaces for name of app folder and workflows

* Handled table name validation

* Fix the create button int table name

* Remove extra spaces for app through import app and git repo

* Fixed the git import app issue

* Change backend validation from 32 to 31 for table name

---------

Co-authored-by: Yukti Goyal <yuktigoyal02@gmail.com>
Co-authored-by: gsmithun4 <gsmithun4@gmail.com>
2026-01-20 23:21:03 +05:30

23 lines
883 B
TypeScript

// server/scripts/env-utils.ts
import * as dotenv from 'dotenv';
import * as fs from 'fs';
import { filePathForEnvVars } from './database-config-utils'; // Assuming this utility is also needed
// A reusable function to load process.env merged with local .env file content
export const loadEnvironmentVariables = (nodeEnv: string): Record<string, any> => {
let envData: Record<string, any> = { ...process.env };
const envVarsFilePath = filePathForEnvVars(nodeEnv);
if (fs.existsSync(envVarsFilePath)) {
try {
const envFileContent = fs.readFileSync(envVarsFilePath, 'utf-8');
const parsedEnvVars = dotenv.parse(envFileContent);
envData = { ...envData, ...parsedEnvVars };
} catch (error) {
console.error('Error reading or parsing .env file for migrations:', error);
}
}
return envData;
};