@ir-kit/create-k6 0.1.0

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ahmed Rowaihi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # `@ir-kit/create-k6`
2
+
3
+ Wizard scaffolder for the [`@ir-kit/k6`](https://github.com/ir-kit/ir-kit/tree/main/packages/k6/framework) stack. Run `npm create @ir-kit/k6` (or the pnpm / yarn equivalent) to generate a typed client from your OpenAPI spec and a starter `loadtest.ts` in one shot.
4
+
5
+ ## Use
6
+
7
+ ```sh
8
+ npm create @ir-kit/k6@latest
9
+ # pnpm create @ir-kit/k6
10
+ # yarn create @ir-kit/k6
11
+ ```
12
+
13
+ The wizard asks for:
14
+
15
+ - OpenAPI spec source (path or URL)
16
+ - Output directory
17
+ - Whether to scaffold a per-tag scenario folder
18
+
19
+ It writes:
20
+
21
+ - `src/gen/` — typed k6 client + types + faker data builders
22
+ - `loadtests/` (optional) — one starter file per OpenAPI tag
23
+ - `package.json` with the right `@ir-kit/k6` + `@ir-kit/k6-toolkit` deps
24
+
25
+ ## What you get
26
+
27
+ ```ts
28
+ // loadtests/smoke.ts
29
+ import { defineLoadTest, flow, smoke, useAuth } from "@ir-kit/k6";
30
+ import { client } from "../src/gen";
31
+
32
+ export const options = smoke();
33
+
34
+ export default defineLoadTest({
35
+ setup: () => useAuth({ bearer: "token" }),
36
+ scenarios: flow().step("list pets", () => client.listPets()),
37
+ });
38
+ ```
39
+
40
+ ## Status
41
+
42
+ `0.1.0` — first release under the `@ir-kit/*` scope. Replaces the legacy `@ahmedrowaihi/create-k6` (deprecated).
43
+
44
+ ## Repo
45
+
46
+ Source at [ir-kit/ir-kit](https://github.com/ir-kit/ir-kit/tree/main/packages/k6/create).
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { runWizard } from "./wizard.js";
3
+ runWizard(process.cwd()).catch((err) => {
4
+ const msg = err instanceof Error ? err.message : String(err);
5
+ console.error(`create-k6 failed: ${msg}`);
6
+ process.exit(1);
7
+ });
8
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC9C,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7D,OAAO,CAAC,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { runWizard } from "./wizard.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { runWizard } from "./wizard.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function runWizard(cwd?: string): Promise<void>;
2
+ //# sourceMappingURL=wizard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wizard.d.ts","sourceRoot":"","sources":["../src/wizard.ts"],"names":[],"mappings":"AAoBA,wBAAsB,SAAS,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0B1E"}
package/dist/wizard.js ADDED
@@ -0,0 +1,108 @@
1
+ import { cancel, confirm, intro, isCancel, outro, select, text, } from "@clack/prompts";
2
+ import { init } from "@ir-kit/k6-toolkit";
3
+ export async function runWizard(cwd = process.cwd()) {
4
+ intro("create-k6 — scaffold a load-test project");
5
+ const answers = await collectAnswers(cwd);
6
+ if (!answers)
7
+ return;
8
+ const result = await init({
9
+ cwd: answers.cwd,
10
+ input: answers.spec,
11
+ output: answers.output,
12
+ auth: answers.auth,
13
+ scenarios: answers.scenarios,
14
+ scaffold: answers.scaffoldStubs,
15
+ noOverwrite: true,
16
+ });
17
+ const stubCount = result.generated.files.filter((f) => f.path.startsWith("loadtests/")).length;
18
+ const summary = [
19
+ `Wrote ${result.generated.files.length} files to ${answers.output}.`,
20
+ `Loadtest entry: ${answers.cwd}/loadtest.ts`,
21
+ stubCount > 0 ? `Per-op stubs: ${stubCount}` : null,
22
+ "Next: edit loadtest.ts, then run it via @ir-kit/k6-toolkit `runK6()`.",
23
+ ].filter(Boolean);
24
+ outro(summary.join("\n"));
25
+ }
26
+ async function collectAnswers(cwd) {
27
+ const spec = await text({
28
+ message: "Path or URL to your OpenAPI spec?",
29
+ placeholder: "./openapi.yaml or https://api.example.com/openapi.yaml",
30
+ validate: (v) => (v && v.trim().length ? undefined : "Required"),
31
+ });
32
+ if (isCancel(spec))
33
+ return bail();
34
+ const output = await text({
35
+ message: "Where should the typed client land?",
36
+ initialValue: "./src/gen",
37
+ validate: (v) => (v && v.trim().length ? undefined : "Required"),
38
+ });
39
+ if (isCancel(output))
40
+ return bail();
41
+ const auth = (await select({
42
+ message: "Auth flavor for the loadtest starter?",
43
+ options: [
44
+ { value: "none", label: "None — public API or custom middleware later" },
45
+ { value: "bearer", label: "Bearer token from env var (API_TOKEN)" },
46
+ { value: "basic", label: "HTTP Basic (API_USER / API_PASS env)" },
47
+ { value: "apiKey", label: "API key header (X-API-Key from API_KEY env)" },
48
+ { value: "session", label: "Cookie/session — fill in signIn() yourself" },
49
+ ],
50
+ initialValue: "none",
51
+ }));
52
+ if (isCancel(auth))
53
+ return bail();
54
+ const shape = (await select({
55
+ message: "Single test or multiple named scenarios?",
56
+ options: [
57
+ { value: "single", label: "Single test (one pace + one flow)" },
58
+ {
59
+ value: "scenarios",
60
+ label: "Multiple named scenarios (browse / write / …)",
61
+ },
62
+ ],
63
+ initialValue: "single",
64
+ }));
65
+ if (isCancel(shape))
66
+ return bail();
67
+ let scenarios;
68
+ if (shape === "scenarios") {
69
+ const raw = await text({
70
+ message: "Scenario names (comma-separated)?",
71
+ placeholder: "browse, write",
72
+ validate: (v) => {
73
+ const parsed = parseScenarioNames(v ?? "");
74
+ if (!parsed.length)
75
+ return "Provide at least one name";
76
+ return undefined;
77
+ },
78
+ });
79
+ if (isCancel(raw))
80
+ return bail();
81
+ scenarios = parseScenarioNames(raw);
82
+ }
83
+ const scaffoldStubs = await confirm({
84
+ message: "Also emit one stub loadtest per spec operation?",
85
+ initialValue: false,
86
+ });
87
+ if (isCancel(scaffoldStubs))
88
+ return bail();
89
+ return {
90
+ cwd,
91
+ spec: spec,
92
+ output: output,
93
+ auth: auth,
94
+ scenarios,
95
+ scaffoldStubs: scaffoldStubs,
96
+ };
97
+ }
98
+ function parseScenarioNames(raw) {
99
+ return raw
100
+ .split(",")
101
+ .map((s) => s.trim())
102
+ .filter(Boolean);
103
+ }
104
+ function bail() {
105
+ cancel("Aborted.");
106
+ return null;
107
+ }
108
+ //# sourceMappingURL=wizard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wizard.js","sourceRoot":"","sources":["../src/wizard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,IAAI,GACL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAmB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAW3D,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IACzD,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAElD,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC1C,IAAI,CAAC,OAAO;QAAE,OAAO;IAErB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC;QACxB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,KAAK,EAAE,OAAO,CAAC,IAAI;QACnB,MAAM,EAAE,OAAO,CAA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,EAAE,CAAC,CAAC,EAAE,EAAE;gBACd,MAAM,MAAM,GAAG,kBAAkB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC3C,IAAI,CAAC,MAAM,CAAC,MAAM;oBAAE,OAAO,2BAA2B,CAAC;gBACvD,OAAO,SAAS,CAAC;YACnB,CAAC;SACF,CAAC,CAAC;QACH,IAAI,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,EAAE,CAAC;QACjC,SAAS,GAAG,kBAAkB,CAAC,GAAa,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC;QAClC,OAAO,EAAE,iDAAiD;QAC1D,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,aAAa,CAAC;QAAE,OAAO,IAAI,EAAE,CAAC;IAE3C,OAAO;QACL,GAAG;QACH,IAAI,EAAE,IAAc;QACpB,MAAM,EAAE,MAAgB;QACxB,IAAI,EAAE,IAAkB;QACxB,SAAS;QACT,aAAa,EAAE,aAAwB;KACxC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACrC,OAAO,GAAG;SACP,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,IAAI;IACX,MAAM,CAAC,UAAU,CAAC,CAAC;IACnB,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@ir-kit/create-k6",
3
+ "version": "0.1.0",
4
+ "description": "Wizard scaffolder for the @ir-kit/k6 stack. Run `npm create @ir-kit/k6` to generate a typed client from your OpenAPI spec and a starter loadtest.ts in one shot.",
5
+ "keywords": [
6
+ "k6",
7
+ "load-testing",
8
+ "scaffold",
9
+ "wizard",
10
+ "openapi"
11
+ ],
12
+ "homepage": "https://github.com/ir-kit/ir-kit/tree/main/packages/k6/create",
13
+ "bugs": {
14
+ "url": "https://github.com/ir-kit/ir-kit/issues"
15
+ },
16
+ "license": "MIT",
17
+ "author": {
18
+ "name": "Ahmed Rowaihi",
19
+ "email": "ahmedrowaihi@gmail.com"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/ir-kit/ir-kit.git",
24
+ "directory": "packages/k6/create"
25
+ },
26
+ "type": "module",
27
+ "sideEffects": false,
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "bin": {
31
+ "create-k6": "./dist/bin.js"
32
+ },
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "README.md",
43
+ "LICENSE.md"
44
+ ],
45
+ "publishConfig": {
46
+ "access": "public",
47
+ "provenance": true
48
+ },
49
+ "dependencies": {
50
+ "@clack/prompts": "^1.3.0",
51
+ "@ir-kit/k6-toolkit": "0.1.0"
52
+ },
53
+ "devDependencies": {
54
+ "@types/node": "^22",
55
+ "vitest": "^4.0.0",
56
+ "@ir-kit/tsconfig": "0.0.0"
57
+ },
58
+ "engines": {
59
+ "node": ">=20.19.0"
60
+ },
61
+ "scripts": {
62
+ "build": "tsc -p tsconfig.build.json && chmod +x dist/bin.js",
63
+ "dev": "tsc -p tsconfig.build.json --watch",
64
+ "typecheck": "tsc --noEmit",
65
+ "test": "vitest run --passWithNoTests"
66
+ }
67
+ }