update to env0

This commit is contained in:
sawka 2022-08-22 16:28:14 -07:00
parent db3f780275
commit d61246e8a4
2 changed files with 22 additions and 1 deletions

View File

@ -82,6 +82,7 @@ type RemoteType = {
type RemoteStateType = { type RemoteStateType = {
cwd : string, cwd : string,
env0 : string, // in base64 "env -0" form
}; };
type RemoteInstanceType = { type RemoteInstanceType = {

View File

@ -142,4 +142,24 @@ function genMergeData<ObjType extends IObjType<DataType>, DataType extends IData
objs.replace(newObjs); objs.replace(newObjs);
} }
export {handleJsonFetchResponse, base64ToArray, genMergeData, genMergeSimpleData}; function parseEnv0(envStr64 : string) : Map<string, string> {
let envStr = atob(envStr64);
let parts = envStr.split("\x00");
let rtn : Map<string, string> = new Map();
for (let i=0; i<parts.length; i++) {
let part = parts[i];
if (part == "") {
continue;
}
let eqIdx = part.indexOf("=");
if (eqIdx == -1) {
continue;
}
let varName = part.substr(0, eqIdx);
let varVal = part.substr(eqIdx+1)
rtn.set(varName, varVal)
}
return rtn;
}
export {handleJsonFetchResponse, base64ToArray, genMergeData, genMergeSimpleData, parseEnv0};