diff --git a/resources/linux/x86_64/k6 b/resources/linux/x86_64/k6 new file mode 100755 index 00000000..72b5ad20 Binary files /dev/null and b/resources/linux/x86_64/k6 differ diff --git a/resources/mac/arm64/k6 b/resources/mac/arm64/k6 new file mode 100755 index 00000000..6d415fc8 Binary files /dev/null and b/resources/mac/arm64/k6 differ diff --git a/resources/mac/x86_64/k6 b/resources/mac/x86_64/k6 new file mode 100755 index 00000000..04153b75 Binary files /dev/null and b/resources/mac/x86_64/k6 differ diff --git a/resources/win/x86_64/k6.exe b/resources/win/x86_64/k6.exe new file mode 100755 index 00000000..e9d7c3b2 Binary files /dev/null and b/resources/win/x86_64/k6.exe differ diff --git a/src/script.ts b/src/script.ts index b4be2a00..628fb533 100644 --- a/src/script.ts +++ b/src/script.ts @@ -4,6 +4,7 @@ import { readFile, writeFile } from 'fs/promises' import path from 'path' import readline from 'readline/promises' import { K6Log } from './types' +import { getArch, getPlatform } from './utils/electron' export type K6Process = ChildProcessWithoutNullStreams @@ -35,8 +36,27 @@ export const runScript = async ( HTTPS_PROXY: 'http://localhost:8080', } + let k6Path: string + + // if we are in dev server we take resources directly, otherwise look in the app resources folder. + if (MAIN_WINDOW_VITE_DEV_SERVER_URL) { + k6Path = path.join( + app.getAppPath(), + 'resources', + getPlatform(), + getArch(), + 'k6' + ) + } else { + // only the architecture directory will be in resources on the packaged app + k6Path = path.join(process.resourcesPath, getArch(), 'k6') + } + + // add .exe on windows + k6Path += getPlatform() === 'win' ? '.exe' : '' + const k6 = spawn( - 'k6', + k6Path, [ 'run', modifiedScriptPath, diff --git a/src/views/Generator/RulePreview/RulePreview.tsx b/src/views/Generator/RulePreview/RulePreview.tsx index 29924dd5..639e21f8 100644 --- a/src/views/Generator/RulePreview/RulePreview.tsx +++ b/src/views/Generator/RulePreview/RulePreview.tsx @@ -1,6 +1,6 @@ import { CorrelationPreview } from './CorrelationPreview' import { exhaustive } from '@/utils/typescript' -import { TestRule } from '@/types/rules' +import { TestRule } from '@/schemas/rules' export function RulePreview({ rule }: { rule: TestRule }) { switch (rule.type) {