use_platform env
This commit is contained in:
parent
aa8de1af3d
commit
558bbdedd4
3 changed files with 27 additions and 5 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { readUsePlatform } from "../util/paths";
|
||||
import { usePlatform } from "./flags";
|
||||
|
||||
interface ControlPlaneEnv {
|
||||
|
|
@ -52,11 +53,17 @@ const LOCAL_ENV: ControlPlaneEnv = {
|
|||
APP_URL: "http://localhost:3000/",
|
||||
};
|
||||
|
||||
export const controlPlaneEnv =
|
||||
process.env.CONTROL_PLANE_ENV === "local"
|
||||
function getControlPlaneEnv(): ControlPlaneEnv {
|
||||
const usePlatformFileEnv = readUsePlatform();
|
||||
const env = usePlatformFileEnv || process.env.CONTROL_PLANE_ENV;
|
||||
|
||||
return env === "local"
|
||||
? LOCAL_ENV
|
||||
: process.env.CONTROL_PLANE_ENV === "staging"
|
||||
: env === "staging"
|
||||
? STAGING_ENV
|
||||
: process.env.CONTROL_PLANE_ENV === "test" || usePlatform()
|
||||
: env === "test" || usePlatform()
|
||||
? TEST_ENV
|
||||
: PRODUCTION_ENV;
|
||||
}
|
||||
|
||||
export const controlPlaneEnv = getControlPlaneEnv();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
import { usePlatformPathExists } from "../util/paths";
|
||||
import { readUsePlatform, usePlatformPathExists } from "../util/paths";
|
||||
|
||||
export function usePlatform(): boolean {
|
||||
return usePlatformPathExists();
|
||||
}
|
||||
|
||||
export function getEnvFromUsePlatformFile(): string | undefined {
|
||||
const contents = readUsePlatform();
|
||||
if (contents && contents.trim().length > 0) {
|
||||
return contents.trim();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,6 +306,13 @@ export function usePlatformPathExists(): boolean {
|
|||
return fs.existsSync(sPath);
|
||||
}
|
||||
|
||||
export function readUsePlatform(): string | undefined {
|
||||
const sPath = path.join(getContinueGlobalPath(), ".use_platform");
|
||||
if (fs.existsSync(sPath)) {
|
||||
return fs.readFileSync(sPath, "utf8");
|
||||
}
|
||||
}
|
||||
|
||||
export function getConfigJsonPathForRemote(
|
||||
remoteConfigServerUrl: string,
|
||||
): string {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue