const { execSync } = require("child_process");
const path = require("path");
const fs = require("fs");
const cmd = `curl -s https://doraemon.quantgroups.cn/ack/namespace/list?env=all`;
const filePath = path.resolve("src/components/qaTool/", "qa.api.js");
function getEnvList() {
  const result = JSON.parse(execSync(cmd).toString());
  if (result && result.data) {
    const esTxt = `/* eslint-disable */\nexport default ${JSON.stringify(result.data)};`;
    fs.writeFileSync(filePath, esTxt);
    console.log("inject [qaEnvInfo] to src/components/qaTool/qa.api.js");
  }
}

module.exports = getEnvList;
