blaze-performance-tester 3.2.8 → 3.2.10
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 +50 -2
- package/dist/index.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env ts-node
|
|
2
2
|
|
|
3
3
|
// cli.ts
|
|
4
|
+
import yargs from "yargs";
|
|
5
|
+
import { hideBin } from "yargs/helpers";
|
|
4
6
|
import { createRequire } from "module";
|
|
5
7
|
import * as path from "path";
|
|
6
8
|
import { fileURLToPath } from "url";
|
|
@@ -293,13 +295,56 @@ async function executeTestPipeline(config) {
|
|
|
293
295
|
console.log("Pipeline run complete. Parameter tracking successfully mitigated breaking changes.");
|
|
294
296
|
}
|
|
295
297
|
}
|
|
296
|
-
async function
|
|
298
|
+
async function generateTestScriptFromPrompt(prompt) {
|
|
299
|
+
console.log(`
|
|
300
|
+
[AI] Translating natural language to Blaze performance script...`);
|
|
301
|
+
const generatedCode = `// Auto-generated by Blaze Performance Tester
|
|
302
|
+
// Prompt: ${prompt}
|
|
303
|
+
|
|
304
|
+
import { step } from 'blaze-performance-tester';
|
|
305
|
+
|
|
306
|
+
export default async function scenario() {
|
|
307
|
+
await step('Scenario Execution', async () => {
|
|
308
|
+
// Add generated API calls or interactions here
|
|
309
|
+
console.log("Executing auto-generated step based on prompt.");
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
`;
|
|
313
|
+
return generatedCode;
|
|
314
|
+
}
|
|
315
|
+
async function runCli() {
|
|
316
|
+
const argv = await yargs(hideBin(process.argv)).usage("Usage: blaze-performance-tester <script-path> [options]").option("prompt", {
|
|
317
|
+
describe: "Natural language scenario to generate the test script",
|
|
318
|
+
type: "string"
|
|
319
|
+
}).option("threads", { type: "number", description: "Number of concurrent threads" }).option("duration", { type: "number", description: "Test duration in seconds" }).option("ramp-up", { type: "number", description: "Ramp-up time in seconds" }).option("ramp-down", { type: "number", description: "Ramp-down time in seconds" }).help(false).strict(false).argv;
|
|
297
320
|
const args = process.argv.slice(2);
|
|
298
321
|
if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
|
|
299
322
|
printUsage();
|
|
300
323
|
return;
|
|
301
324
|
}
|
|
302
325
|
const config = parseArguments(args);
|
|
326
|
+
if (argv.prompt) {
|
|
327
|
+
const promptText = argv.prompt;
|
|
328
|
+
try {
|
|
329
|
+
const scriptContent = await generateTestScriptFromPrompt(promptText);
|
|
330
|
+
const dir = path.dirname(config.targetScript);
|
|
331
|
+
if (!fs.existsSync(dir)) {
|
|
332
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
333
|
+
}
|
|
334
|
+
fs.writeFileSync(config.targetScript, scriptContent, "utf-8");
|
|
335
|
+
console.log(`[Success] Test script generated at: ${config.targetScript}
|
|
336
|
+
`);
|
|
337
|
+
} catch (error) {
|
|
338
|
+
console.error(`[Error] Failed to generate script from prompt:`, error);
|
|
339
|
+
process.exit(1);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (!fs.existsSync(config.targetScript)) {
|
|
343
|
+
console.error(`[Error] Test script not found at ${config.targetScript}.`);
|
|
344
|
+
process.exit(1);
|
|
345
|
+
}
|
|
346
|
+
console.log(`Starting performance test using script: ${config.targetScript}`);
|
|
347
|
+
console.log(`Params -> Threads: ${config.threads || 1}, Duration: ${config.durationSec || 0}s`);
|
|
303
348
|
if (config.isCorrelate) {
|
|
304
349
|
await executeTestPipeline(config);
|
|
305
350
|
}
|
|
@@ -1461,4 +1506,7 @@ function printUsage() {
|
|
|
1461
1506
|
Options:
|
|
1462
1507
|
--threads <count> | --duration <seconds> | --baseline <json_file> | --output <html_file>`);
|
|
1463
1508
|
}
|
|
1464
|
-
|
|
1509
|
+
runCli().catch(console.error);
|
|
1510
|
+
export {
|
|
1511
|
+
runCli
|
|
1512
|
+
};
|
|
Binary file
|