fixed bug with spreadsheet import

This commit is contained in:
GotthardG
2024-12-10 15:18:48 +01:00
parent 996fc66d76
commit e28c8b05d4
25 changed files with 819 additions and 70 deletions

View File

@ -1,16 +1,28 @@
// fetch-and-generate-openapi.js
import fs from 'fs';
import https from 'https'; // Use https instead of http
import https from 'https';
import { exec } from 'child_process';
import chokidar from 'chokidar';
import path from 'path';
import util from 'util';
const OPENAPI_URL = 'https://127.0.0.1:8000/openapi.json';
const SCHEMA_PATH = path.resolve('./src/openapi.json');
const OUTPUT_DIRECTORY = path.resolve('./openapi');
const SSL_KEY_PATH = path.resolve('../backend/ssl/key.pem'); // Path to SSL key
const SSL_CERT_PATH = path.resolve('../backend/ssl/cert.pem'); // Path to SSL certificate
// Determine the environment
const environment = process.env.NODE_ENV || 'development';
const configFile = `config_${environment}.json`;
// Load the appropriate configuration
let config;
try {
config = JSON.parse(fs.readFileSync(path.resolve('../', configFile), 'utf8'));
} catch (error) {
console.error(`❌ Error reading configuration file: ${error.message}`);
process.exit(1);
}
const OPENAPI_URL = config.OPENAPI_URL;
const SCHEMA_PATH = path.resolve(config.SCHEMA_PATH);
const OUTPUT_DIRECTORY = path.resolve(config.OUTPUT_DIRECTORY);
const SSL_KEY_PATH = path.resolve(config.SSL_KEY_PATH);
const SSL_CERT_PATH = path.resolve(config.SSL_CERT_PATH);
console.log(`Using SCHEMA_PATH: ${SCHEMA_PATH}`);
console.log(`Using OUTPUT_DIRECTORY: ${OUTPUT_DIRECTORY}`);
@ -70,7 +82,6 @@ async function fetchAndGenerate() {
await fs.promises.rm(OUTPUT_DIRECTORY, { recursive: true, force: true });
console.log(`✅ Output directory cleaned at ${OUTPUT_DIRECTORY}`);
// Verify directory removal
if (fs.existsSync(OUTPUT_DIRECTORY)) {
console.error(`❌ Output directory still exists: ${OUTPUT_DIRECTORY}`);
} else {
@ -81,7 +92,6 @@ async function fetchAndGenerate() {
console.log(`Executing debug command: ${command}`);
const { stdout, stderr } = await execPromisified(command);
console.log("🔍 Inside exec callback");
if (stderr) {
console.error(`⚠️ stderr while generating services: ${stderr}`);
} else {
@ -99,13 +109,13 @@ async function fetchAndGenerate() {
}
}
const backendDirectory = '/Users/gotthardg/PycharmProjects/heidi-v2/backend/app';
const backendDirectory = path.resolve('/Users/gotthardg/PycharmProjects/heidi-v2/backend/app');
console.log(`👀 Watching for changes in ${backendDirectory}`);
const watcher = chokidar.watch(backendDirectory, { persistent: true, ignored: [SCHEMA_PATH, OUTPUT_DIRECTORY] });
watcher
.on('add', debounce(fetchAndGenerate, debounceDelay))
.on('change', debounce(fetchAndGenerate, debounceDelay)) // Corrected typo here
.on('change', debounce(fetchAndGenerate, debounceDelay))
.on('unlink', debounce(fetchAndGenerate, debounceDelay));
console.log(`👀 Watching for changes in ${backendDirectory}`);