From 05b3677427766a3c3bc4bab7be4d3583d9174697 Mon Sep 17 00:00:00 2001 From: Kim T Date: Wed, 18 Sep 2024 20:39:20 -0700 Subject: [PATCH] Remove log file and scan directory instead --- .github/workflows/validate.yml | 5 ++--- src/validate.ts | 21 +++------------------ 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 54a8bdd..7b8b7ed 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -28,13 +28,12 @@ jobs: CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | for file in ${CHANGED_FILES}; do - node build/validate.js $file + node ./build/validate.js $file done - cat downloads/log.txt - name: VirusTotal Scan uses: crazy-max/ghaction-virustotal@v4 with: vt_api_key: ${{ secrets.VT_API_KEY }} request_rate: 4 - files: cat downloads/log.txt + files: ./downloads/ diff --git a/src/validate.ts b/src/validate.ts index 1c5fd68..d97d44b 100644 --- a/src/validate.ts +++ b/src/validate.ts @@ -1,20 +1,9 @@ -import { - apiBuffer, - dirCreate, - dirExists, - fileCreate, - fileExists, - fileReadString, - pathGetExt, - PluginFile, - PluginFiles, -} from '@studiorack/core'; +import { apiBuffer, dirCreate, dirExists, fileCreate, pathGetExt, PluginFile, PluginFiles } from '@studiorack/core'; import { validatePluginYaml } from './sources/local.js'; import chalk from 'chalk'; import path from 'path'; -const DIR_DOWNLOADS = 'downloads'; -const DIR_LOG = path.join(DIR_DOWNLOADS, 'log.txt'); +const DIR_DOWNLOADS: string = 'downloads'; const filepath: string = process.argv[2]; const ext: string = pathGetExt(filepath); @@ -22,11 +11,9 @@ const ext: string = pathGetExt(filepath); if (ext === 'yaml') { // Ensure directory and log file exist if (!dirExists(DIR_DOWNLOADS)) dirCreate(DIR_DOWNLOADS); - if (!fileExists(DIR_LOG)) fileCreate(DIR_LOG, ''); // Validate the schema and fields const { plugin } = validatePluginYaml(filepath); - let log: string = fileReadString(DIR_LOG); // Download files and compare for (const type in plugin.files) { @@ -39,9 +26,7 @@ if (ext === 'yaml') { } else { console.log(chalk.red(`X ${pluginFile.url} size needs updating to ${pluginFileBuffer.length}`)); } - // Add file to log for virus scanning + // Add file to downloads for virus scanning fileCreate(pluginFileLocalPath, pluginFileBuffer); - log += pluginFileLocalPath + '\n'; } - fileCreate(DIR_LOG, log); }