blaze-performance-tester 3.2.13 → 3.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +37 -15
- package/package.json +4 -3
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env ts-node
|
|
2
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5416,6 +5417,7 @@ import { createRequire as createRequire3 } from "module";
|
|
|
5416
5417
|
import * as path from "path";
|
|
5417
5418
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
5418
5419
|
import * as fs from "fs";
|
|
5420
|
+
import { GoogleGenAI } from "@google/genai";
|
|
5419
5421
|
|
|
5420
5422
|
// src/LogAnalyzer.ts
|
|
5421
5423
|
var LogAnalyzer = class {
|
|
@@ -5708,21 +5710,41 @@ async function executeTestPipeline(config) {
|
|
|
5708
5710
|
console.log("Pipeline run complete. Parameter tracking successfully mitigated breaking changes.");
|
|
5709
5711
|
}
|
|
5710
5712
|
}
|
|
5711
|
-
async function generateTestScriptFromPrompt(prompt) {
|
|
5712
|
-
console.log(
|
|
5713
|
-
|
|
5714
|
-
const
|
|
5715
|
-
|
|
5713
|
+
async function generateTestScriptFromPrompt(prompt, config) {
|
|
5714
|
+
console.log(`\u{1F916} Connecting to Gemini to generate script for: "${prompt}"...`);
|
|
5715
|
+
const ai = new GoogleGenAI({});
|
|
5716
|
+
const systemInstruction = `You are an expert code generation assistant for the "blaze-performance-tester" framework.
|
|
5717
|
+
Generate a valid TypeScript performance test script based on the user's prompt and provided configuration options.
|
|
5718
|
+
The output must contain ONLY valid TypeScript code without any extra markdown conversational wrappers if possible, or wrapped cleanly.
|
|
5719
|
+
Include:
|
|
5720
|
+
1. Import statement: import { step } from 'blaze-performance-tester';
|
|
5721
|
+
2. An options export object containing: threads, duration, rampUp, rampDown.
|
|
5722
|
+
3. A default async function scenario() using await step(...) with the correct fetch request based on the user's instructions.`;
|
|
5723
|
+
const fullPrompt = `User Prompt: ${prompt}
|
|
5724
|
+
Configuration Options:
|
|
5725
|
+
- threads: ${config.threads}
|
|
5726
|
+
- duration: ${config.durationSec}
|
|
5727
|
+
- rampUp: ${config.rampUpSec}
|
|
5728
|
+
- rampDown: ${config.rampDownSec}
|
|
5716
5729
|
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5730
|
+
Generate the complete TypeScript test script now.`;
|
|
5731
|
+
try {
|
|
5732
|
+
const response = await ai.models.generateContent({
|
|
5733
|
+
model: "gemini-2.5-flash",
|
|
5734
|
+
contents: fullPrompt,
|
|
5735
|
+
config: {
|
|
5736
|
+
systemInstruction
|
|
5737
|
+
}
|
|
5738
|
+
});
|
|
5739
|
+
let generatedCode = response.text || "";
|
|
5740
|
+
generatedCode = generatedCode.replace(/^```(?:typescript|ts)?\n?/i, "");
|
|
5741
|
+
generatedCode = generatedCode.replace(/\n?```$/i, "");
|
|
5742
|
+
generatedCode = generatedCode.trim();
|
|
5743
|
+
return generatedCode;
|
|
5744
|
+
} catch (error) {
|
|
5745
|
+
console.error("\u274C Error generating script with Gemini API:", error);
|
|
5746
|
+
throw error;
|
|
5747
|
+
}
|
|
5726
5748
|
}
|
|
5727
5749
|
async function runCli() {
|
|
5728
5750
|
const argv = await yargs_default(hideBin(process.argv)).usage("Usage: blaze-performance-tester <script-path> [options]").option("prompt", {
|
|
@@ -5738,7 +5760,7 @@ async function runCli() {
|
|
|
5738
5760
|
if (argv.prompt) {
|
|
5739
5761
|
const promptText = argv.prompt;
|
|
5740
5762
|
try {
|
|
5741
|
-
const scriptContent = await generateTestScriptFromPrompt(promptText);
|
|
5763
|
+
const scriptContent = await generateTestScriptFromPrompt(promptText, config);
|
|
5742
5764
|
const dir = path.dirname(config.targetScript);
|
|
5743
5765
|
if (!fs.existsSync(dir)) {
|
|
5744
5766
|
fs.mkdirSync(dir, { recursive: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blaze-performance-tester",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.16",
|
|
4
4
|
"description": "A high-performance, multi-threaded load testing engine built with Rust and QuickJS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,13 +17,14 @@
|
|
|
17
17
|
"*.node",
|
|
18
18
|
"blaze.win32-x64-msvc.node"
|
|
19
19
|
],
|
|
20
|
-
|
|
20
|
+
"scripts": {
|
|
21
21
|
"prebuild": "node -e \"if (!fs.existsSync('dist')) fs.mkdirSync('dist')\"",
|
|
22
22
|
"build:rust": "napi build --platform --release --js index.js --dts index.d.ts dist",
|
|
23
|
-
"build:cli": "esbuild cli.ts --bundle --platform=node --format=esm --outfile=dist/cli.js",
|
|
23
|
+
"build:cli": "esbuild cli.ts --bundle --platform=node --format=esm --outfile=dist/cli.js --external:@google/genai --banner:js=\"import { createRequire } from 'module'; const require = createRequire(import.meta.url);\"",
|
|
24
24
|
"build": "npm run prebuild && npm run build:rust && npm run build:cli"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"@google/genai": "^2.12.0",
|
|
27
28
|
"yargs": "^18.0.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|