|
1 | 1 | import { writeFileSync } from "fs"; |
2 | 2 | import { cleanup } from "./cleanup"; |
3 | 3 | import { downloadGitRepo } from "./downloadGitRepo"; |
| 4 | +import { iterateOnDocFiles } from "./iterateOnDocFiles"; |
4 | 5 | import { getAvailableProviders } from "./getAvailableProviders"; |
5 | 6 | import { setOverrides } from "./setOverrides"; |
6 | 7 | import setup = require("./setup"); |
7 | 8 | import { sortObject } from "./sortObject"; |
| 9 | +import { exit } from "process"; |
| 10 | + |
8 | 11 | const configuration = require("./config.json"); |
9 | 12 |
|
10 | 13 | async function main() { |
11 | | - const cap = configuration.total_snippets; |
12 | 14 | const tmpDir = setup.setupWorkspace(); |
13 | 15 | const snips = {}; |
14 | | - getAvailableProviders(tmpDir, snips, downloadGitRepo); |
15 | | - // TODO: find a better way to count up front the number of processed markdown files OR providers |
16 | | - await sleep(600); |
17 | | - while (Object.keys(snips).length < cap) { |
18 | | - console.log(`${Object.keys(snips).length} of ${cap}`); |
19 | | - await sleep(20); |
20 | | - } |
21 | | - console.log(Object.keys(snips).length); |
22 | | - const overrideSnipsIncluded = setOverrides(snips); |
23 | | - const sortedSnips = sortObject(overrideSnipsIncluded); |
24 | | - writeFileSync( |
25 | | - "snippets/terraform.json", |
26 | | - JSON.stringify(sortedSnips, null, 2), |
27 | | - "utf-8", |
28 | | - ); |
29 | | - cleanup(tmpDir); |
30 | | -} |
| 16 | + const providersList = await getAvailableProviders(); |
| 17 | + console.log(providersList); |
| 18 | + exit |
| 19 | + |
| 20 | + // for(let i = 0; i < providersList.length; i++) { |
| 21 | + // const name = providersList[i]; |
| 22 | + // let subtotal = Object.keys(snips).length; |
| 23 | + |
| 24 | + // await downloadGitRepo(tmpDir, name, snips, iterateOnDocFiles); |
| 25 | + |
| 26 | + // subtotal = Object.keys(snips).length - subtotal; |
| 27 | + // console.log(`provider ${i + 1} of ${providersList.length}: ${subtotal} snips\n`) |
| 28 | + |
| 29 | + |
31 | 30 |
|
32 | | -function sleep(ms) { |
33 | | - return new Promise((resolve) => setTimeout(resolve, ms * 100)); |
| 31 | + // getAvailableProviders(tmpDir, snips, downloadGitRepo); |
| 32 | + // // TODO: find a better way to count up front the number of processed markdown files OR providers |
| 33 | + // await sleep(600); |
| 34 | + // while (Object.keys(snips).length < cap) { |
| 35 | + // console.log(`${Object.keys(snips).length} of ${cap}`); |
| 36 | + // await sleep(20); |
| 37 | + // } |
| 38 | + // console.log(Object.keys(snips).length); |
| 39 | + // const overrideSnipsIncluded = setOverrides(snips); |
| 40 | + // const sortedSnips = sortObject(overrideSnipsIncluded); |
| 41 | + // writeFileSync( |
| 42 | + // "snippets/terraform.json", |
| 43 | + // JSON.stringify(sortedSnips, null, 2), |
| 44 | + // "utf-8", |
| 45 | + // ); |
| 46 | + // cleanup(tmpDir); |
34 | 47 | } |
35 | 48 |
|
36 | 49 | main(); |
0 commit comments