CHANGE_
This commit is contained in:
parent
d60bfdeb13
commit
86cd662522
@ -1 +1,3 @@
|
|||||||
API_URL=https://venbait.in/nhance/dev/employeeRest/
|
API_URL=https://venbait.in/nhance/dev/employeeRest/
|
||||||
|
BASE_HREF=/nhance/app/dev/
|
||||||
|
ENV=development
|
||||||
@ -1 +1,3 @@
|
|||||||
API_URL=https://venbait.in/nhance/dev/employeeRest/
|
API_URL=https://venbait.in/nhance/uat/employeeRest/
|
||||||
|
BASE_HREF=/nhance/app/uat/
|
||||||
|
ENV=production
|
||||||
3
.env.test
Normal file
3
.env.test
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
API_URL=https://venbait.in/nhance/test/employeeRest/
|
||||||
|
BASE_HREF=/nhance/app/test/
|
||||||
|
ENV=test
|
||||||
34
build_web_dev.sh
Executable file
34
build_web_dev.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Define the path to the .env.development file
|
||||||
|
ENV_FILE_PATH=".env.development"
|
||||||
|
|
||||||
|
# Check if the .env.development file exists
|
||||||
|
if [ ! -f $ENV_FILE_PATH ]; then
|
||||||
|
echo "$ENV_FILE_PATH does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy the .env.development file to .env
|
||||||
|
cp $ENV_FILE_PATH .env
|
||||||
|
|
||||||
|
# Check if the BASE_HREF variable exists in the .env file
|
||||||
|
if ! grep -q BASE_HREF .env; then
|
||||||
|
echo "BASE_HREF not found in .env file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract the BASE_HREF value
|
||||||
|
BASE_HREF=$(grep BASE_HREF .env | cut -d '=' -f2)
|
||||||
|
|
||||||
|
# Check if the BASE_HREF value is empty
|
||||||
|
if [ -z "$BASE_HREF" ]; then
|
||||||
|
echo "BASE_HREF value is empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build the web app for development with base href
|
||||||
|
flutter build web --release --base-href "$BASE_HREF"
|
||||||
|
|
||||||
|
# Optionally, remove the .env file after the build
|
||||||
|
# rm .env
|
||||||
34
build_web_production.sh
Executable file
34
build_web_production.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Define the path to the .env file for production
|
||||||
|
ENV_FILE_PATH=".env.production"
|
||||||
|
|
||||||
|
# Check if the .env file exists
|
||||||
|
if [ ! -f $ENV_FILE_PATH ]; then
|
||||||
|
echo "$ENV_FILE_PATH does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy the .env file for production to .env
|
||||||
|
cp $ENV_FILE_PATH .env
|
||||||
|
|
||||||
|
# Check if the BASE_HREF variable exists in the .env file
|
||||||
|
if ! grep -q BASE_HREF .env; then
|
||||||
|
echo "BASE_HREF not found in .env file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract the BASE_HREF value
|
||||||
|
BASE_HREF=$(grep BASE_HREF .env | cut -d '=' -f2)
|
||||||
|
|
||||||
|
# Check if the BASE_HREF value is empty
|
||||||
|
if [ -z "$BASE_HREF" ]; then
|
||||||
|
echo "BASE_HREF value is empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build the web app for production environment with base href
|
||||||
|
flutter build web --release --base-href "$BASE_HREF"
|
||||||
|
|
||||||
|
# Optionally, remove the .env file after the build
|
||||||
|
# rm .env
|
||||||
34
build_web_test.sh
Executable file
34
build_web_test.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Define the path to the .env file for testing
|
||||||
|
ENV_FILE_PATH=".env.test"
|
||||||
|
|
||||||
|
# Check if the .env file exists
|
||||||
|
if [ ! -f $ENV_FILE_PATH ]; then
|
||||||
|
echo "$ENV_FILE_PATH does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy the .env file for testing to .env
|
||||||
|
cp $ENV_FILE_PATH .env
|
||||||
|
|
||||||
|
# Check if the BASE_HREF variable exists in the .env file
|
||||||
|
if ! grep -q BASE_HREF .env; then
|
||||||
|
echo "BASE_HREF not found in .env file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract the BASE_HREF value
|
||||||
|
BASE_HREF=$(grep BASE_HREF .env | cut -d '=' -f2)
|
||||||
|
|
||||||
|
# Check if the BASE_HREF value is empty
|
||||||
|
if [ -z "$BASE_HREF" ]; then
|
||||||
|
echo "BASE_HREF value is empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build the web app for test environment with base href
|
||||||
|
flutter build web --release --base-href "$BASE_HREF"
|
||||||
|
|
||||||
|
# Optionally, remove the .env file after the build
|
||||||
|
# rm .env
|
||||||
@ -16,6 +16,7 @@ import 'package:nhancepolicy/hrPolicyDetails.dart';
|
|||||||
import 'package:nhancepolicy/oldPolicy.dart';
|
import 'package:nhancepolicy/oldPolicy.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
|
// await dotenv.load(fileName: Environment.fileName);
|
||||||
await dotenv.load(fileName: Environment.fileName);
|
await dotenv.load(fileName: Environment.fileName);
|
||||||
|
|
||||||
runApp(MaterialApp(
|
runApp(MaterialApp(
|
||||||
|
|||||||
@ -3,14 +3,29 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|||||||
|
|
||||||
class Environment {
|
class Environment {
|
||||||
static String get fileName {
|
static String get fileName {
|
||||||
if (kReleaseMode) {
|
const bool isProduction =
|
||||||
return '.env.production';
|
bool.fromEnvironment('dart.vm.product', defaultValue: false);
|
||||||
}
|
const bool isTest =
|
||||||
|
bool.fromEnvironment('dart.vm.environment', defaultValue: false);
|
||||||
|
|
||||||
|
if (isProduction) {
|
||||||
|
return '.env.production';
|
||||||
|
} else if (isTest) {
|
||||||
|
return '.env.test';
|
||||||
|
} else {
|
||||||
return '.env.development';
|
return '.env.development';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static String get apiUrl {
|
static String get apiUrl {
|
||||||
return dotenv.env['API_URL'] ?? 'API_URL not found!';
|
return dotenv.env['API_URL'] ?? 'API_URL not found!';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String get baseHref {
|
||||||
|
return dotenv.env['BASE_HREF'] ?? 'BASE_HREF not found!';
|
||||||
|
}
|
||||||
|
|
||||||
|
static String get env {
|
||||||
|
return dotenv.env['ENV'] ?? 'ENV not found!';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user