diff --git a/src/scripts/configs.ts b/src/scripts/configs.ts index 0d8a2d55c..9640f181e 100644 --- a/src/scripts/configs.ts +++ b/src/scripts/configs.ts @@ -1,6 +1,8 @@ import path from 'path'; -export const streamStartDate = 1729500000; // should be timestamp of deploying funding pot contract in secs +export const streamStartDate = 1730196000; // Oct 29, 2024, 10am GMT +export const streamEndDate = 1793268000; // Oct 29, 2026, 10am GMT +export const streamCliff = 31536000; // 1 year in secs = 365 * 24 * 60 * 60 // The URL of the GitHub repository containing the reports export const repoUrl = 'https://github.com/InverterNetwork/funding-pot.git'; diff --git a/src/scripts/helpers.ts b/src/scripts/helpers.ts index 564cb3d62..4a5a2708d 100644 --- a/src/scripts/helpers.ts +++ b/src/scripts/helpers.ts @@ -1,13 +1,12 @@ /* eslint-disable no-console */ import fs from 'fs-extra'; -import { streamStartDate } from './configs'; +import { streamCliff, streamEndDate, streamStartDate } from './configs'; import { AppDataSource } from '../orm'; import { EarlyAccessRound } from '../entities/earlyAccessRound'; import { QfRound } from '../entities/qfRound'; const SIX_MONTH_IN_SEC = 15768000; const ONE_YEAR_IN_SEC = 31536000; -const TWO_YEARS_IN_SEC = 63072000; // Function to ensure directory exists or create it export function ensureDirectoryExists(dirPath: string) { @@ -27,8 +26,8 @@ export function toScreamingSnakeCase(str: string): string { export function getStreamDetails(isEarlyAccess: boolean) { return { START: streamStartDate, - CLIFF: isEarlyAccess ? ONE_YEAR_IN_SEC : SIX_MONTH_IN_SEC, - END: streamStartDate + (isEarlyAccess ? TWO_YEARS_IN_SEC : ONE_YEAR_IN_SEC), + CLIFF: isEarlyAccess ? streamCliff : SIX_MONTH_IN_SEC, + END: isEarlyAccess ? streamEndDate : streamStartDate + ONE_YEAR_IN_SEC, }; } diff --git a/src/scripts/runFundingPotService.ts b/src/scripts/runFundingPotService.ts index 0cbceec1f..63f26ad11 100644 --- a/src/scripts/runFundingPotService.ts +++ b/src/scripts/runFundingPotService.ts @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import { exec } from 'child_process'; +import { spawn } from 'child_process'; import path from 'path'; import fs from 'fs-extra'; import simpleGit from 'simple-git'; @@ -175,19 +175,29 @@ function execShellCommand(command: string, workingDir: string): Promise { return new Promise((resolve, reject) => { console.info(`Executing command: "${command}" in ${workingDir}...`); - exec(command, { cwd: workingDir }, (error, stdout, stderr) => { - if (error) { - console.error(`Error executing command: ${error.message}`); - return reject(error); - } + // Split the command into the command and its arguments + const [cmd, ...args] = command.split(' '); - if (stderr) { - console.error(`stderr: ${stderr}`); - return reject(new Error(stderr)); - } + // Use spawn to execute the command + const process = spawn(cmd, args, { cwd: workingDir }); + + // Stream stdout in real-time + process.stdout.on('data', data => { + console.log(`stdout: ${data}`); + }); - console.log(`stdout: ${stdout}`); - resolve(); + // Stream stderr in real-time + process.stderr.on('data', data => { + console.error(`stderr: ${data}`); + }); + + // Handle the process exit event + process.on('close', code => { + if (code === 0) { + resolve(); + } else { + reject(new Error(`Command failed with exit code ${code}`)); + } }); }); }