Comment out yaml fo rnow

This commit is contained in:
Vladyslav Matsiiako
2023-01-09 23:33:36 -08:00
parent 266d8b7775
commit c2a03e4e0c

View File

@@ -1,8 +1,8 @@
import YAML from 'yaml'; // import YAML from 'yaml';
import { YAMLSeq } from 'yaml/types' // import { YAMLSeq } from 'yaml/types';
import { envMapping } from "../../../public/data/frequentConstants"; // import { envMapping } from "../../../public/data/frequentConstants";
import checkOverrides from './checkOverrides'; // import checkOverrides from './checkOverrides';
interface SecretDataProps { interface SecretDataProps {
@@ -22,31 +22,32 @@ interface SecretDataProps {
* @returns * @returns
*/ */
const downloadYaml = async ({ data, env }: { data: SecretDataProps[]; env: string; }) => { const downloadYaml = async ({ data, env }: { data: SecretDataProps[]; env: string; }) => {
if (!data) return; // if (!data) return;
const doc = new YAML.Document(); // const doc = new YAML.Document();
doc.contents = new YAMLSeq() // doc.contents = new YAMLSeq();
const secrets = await checkOverrides({ data }); // const secrets = await checkOverrides({ data });
secrets.forEach((secret) => { // secrets.forEach((secret) => {
const pair = YAML.createNode({ [secret.key]: secret.value }); // const pair = YAML.createNode({ [secret.key]: secret.value });
pair.commentBefore = secret.comment // pair.commentBefore = secret.comment
.split('\n') // .split('\n')
.map((line) => (line ? ' '.concat(line) : '')) // .map((line) => (line ? ' '.concat(line) : ''))
.join('\n'); // .join('\n');
doc.add(pair); // doc.add(pair);
}); // });
const file = doc // const file = doc
.toString() // .toString()
.split('\n') // .split('\n')
.map((line) => (line.startsWith('-') ? line.replace('- ', '') : line)) // .map((line) => (line.startsWith('-') ? line.replace('- ', '') : line))
.join('\n'); // .join('\n');
const blob = new Blob([file]); // const blob = new Blob([file]);
const fileDownloadUrl = URL.createObjectURL(blob); // const fileDownloadUrl = URL.createObjectURL(blob);
const alink = document.createElement('a'); // const alink = document.createElement('a');
alink.href = fileDownloadUrl; // alink.href = fileDownloadUrl;
alink.download = envMapping[env] + '.yml'; // alink.download = envMapping[env] + '.yml';
alink.click(); // alink.click();
return;
} }
export default downloadYaml; export default downloadYaml;