🍴 Meu Garfo é uma visualização em grafo dos CNPJs
cuducos.tngl.io/meu-garfo
1const fs = require('fs');
2const path = require('path');
3
4const config = {
5 graphApi: process.env.GRAPH_API_URL || 'https://grafo.minhareceita.org',
6 jsonApi: process.env.JSON_API_URL || 'https://minhareceita.org',
7};
8
9const distPath = path.join(__dirname, 'dist');
10const templatePath = path.join(__dirname, 'index.html.template');
11const outputPath = path.join(distPath, 'index.html');
12
13try {
14 if (!fs.existsSync(distPath)) {
15 fs.mkdirSync(distPath);
16 }
17
18 let template = fs.readFileSync(templatePath, 'utf8');
19
20 const result = template
21 .replace('{{GRAPH_API_URL}}', config.graphApi)
22 .replace('{{JSON_API_URL}}', config.jsonApi);
23
24 fs.writeFileSync(outputPath, result);
25 console.log(`Configured dist/index.html with:`);
26 console.log(` GRAPH_API_URL: ${config.graphApi}`);
27 console.log(` JSON_API_URL: ${config.jsonApi}`);
28} catch (err) {
29 console.error('Error configuring index.html:', err.message);
30 process.exit(1);
31}