Feature: add ability to paste .env, .yml or .json secrets for upload and also fix upload when keys conflict but are not on current page

This commit is contained in:
Scott Wilson
2024-11-12 10:21:07 -08:00
parent 0e946f73bd
commit 7138b392f2
12 changed files with 364 additions and 57 deletions
@@ -6,7 +6,7 @@ const LINE =
* @param {ArrayBuffer} src - source buffer
* @returns {String} text - text of buffer
*/
export function parseDotEnv(src: ArrayBuffer) {
export function parseDotEnv(src: ArrayBuffer | string) {
const object: {
[key: string]: { value: string; comments: string[] };
} = {};
@@ -0,0 +1,11 @@
export const parseJson = (src: ArrayBuffer | string) => {
const file = src.toString();
const formatedData: Record<string, string> = JSON.parse(file);
const env: Record<string, { value: string; comments: string[] }> = {};
Object.keys(formatedData).forEach((key) => {
if (typeof formatedData[key] === "string") {
env[key] = { value: formatedData[key], comments: [] };
}
});
return env;
};