{"size": 940, "ext": "js", "max_stars_repo_path": "tests/DemoFunc/scripts/yaml-to-js.js", "max_stars_repo_name": "flyweightcloud/openroute", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/DemoFunc/scripts/yaml-to-js.js", "max_issues_repo_name": "flyweightcloud/openroute", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/DemoFunc/scripts/yaml-to-js.js", "max_forks_repo_name": "flyweightcloud/openroute", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.6470588235, "max_line_length": 132, "alphanum_fraction": 0.5670212766}

const glob = require("glob");
const yaml = require('js-yaml');
const fs = require('fs/promises')


function findAllYaml() {
    return new Promise((resolve, reject) => {
        glob("**/*.yaml", {nodir: true}, (err, files) => {
            if (err) return reject(err)
            resolve(files)
        })
    })
}

async function main() {
    let files = await findAllYaml()
    for (let i=0; i < files.length; i++) {
        const file = files[i]
        const out = file.replace(/yaml$/, 'ts')
        const doc = yaml.load(await fs.readFile(file, 'utf-8'))
        const content = "// Do not edit this file, it was created from a YAML file\nexport default " + JSON.stringify(doc, null, 2);
        await fs.writeFile(out, content)
        console.log(`Converted ${file} <=> ${out}`)
    }
}


main().then(() => {
    console.log('YAML to JS Conversion complete')
}).catch((err) => {
    console.log("err:", err)
    process.exit(1)
})