Skip to content

Commit

Permalink
Remove log file and scan directory instead
Browse files Browse the repository at this point in the history
  • Loading branch information
kmturley committed Sep 19, 2024
1 parent 2ec4bdc commit 05b3677
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
21 changes: 3 additions & 18 deletions src/validate.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
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);

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) {
Expand All @@ -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);
}

0 comments on commit 05b3677

Please sign in to comment.