splithub 0.1.9 → 0.2.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/dist/chunk-3DUWIEHB.js +561 -0
- package/dist/chunk-3DUWIEHB.js.map +1 -0
- package/dist/chunk-3VACHXWE.js +319 -0
- package/dist/chunk-3VACHXWE.js.map +1 -0
- package/dist/chunk-3VY5CP3E.js +383 -0
- package/dist/chunk-3VY5CP3E.js.map +1 -0
- package/dist/chunk-74NI7BED.js +58 -0
- package/dist/chunk-74NI7BED.js.map +1 -0
- package/dist/chunk-A2RCSPG6.js +184 -0
- package/dist/chunk-A2RCSPG6.js.map +1 -0
- package/dist/chunk-AJO3C4BS.js +97 -0
- package/dist/chunk-AJO3C4BS.js.map +1 -0
- package/dist/chunk-C5S7RPYM.js +54 -0
- package/dist/chunk-C5S7RPYM.js.map +1 -0
- package/dist/chunk-EUF75FUC.js +160 -0
- package/dist/chunk-EUF75FUC.js.map +1 -0
- package/dist/chunk-EYYLDI5J.js +195 -0
- package/dist/chunk-EYYLDI5J.js.map +1 -0
- package/dist/chunk-GVARYUL3.js +28 -0
- package/dist/chunk-GVARYUL3.js.map +1 -0
- package/dist/chunk-HSH4ZI2V.js +72 -0
- package/dist/chunk-HSH4ZI2V.js.map +1 -0
- package/dist/chunk-PLXDG4B5.js +134 -0
- package/dist/chunk-PLXDG4B5.js.map +1 -0
- package/dist/chunk-PWSRKABE.js +113 -0
- package/dist/chunk-PWSRKABE.js.map +1 -0
- package/dist/chunk-QOXGIB3R.js +393 -0
- package/dist/chunk-QOXGIB3R.js.map +1 -0
- package/dist/chunk-UUTLLC54.js +158 -0
- package/dist/chunk-UUTLLC54.js.map +1 -0
- package/dist/chunk-V3DLUVOE.js +112 -0
- package/dist/chunk-V3DLUVOE.js.map +1 -0
- package/dist/chunk-YSXW2HN6.js +104 -0
- package/dist/chunk-YSXW2HN6.js.map +1 -0
- package/dist/ci-ZQZ6RBUJ.js +16 -0
- package/dist/ci-ZQZ6RBUJ.js.map +1 -0
- package/dist/create-K75OY6XK.js +18 -0
- package/dist/create-K75OY6XK.js.map +1 -0
- package/dist/dev-WQWFEA6I.js +11 -0
- package/dist/dev-WQWFEA6I.js.map +1 -0
- package/dist/doctor-MFYBZUKO.js +13 -0
- package/dist/doctor-MFYBZUKO.js.map +1 -0
- package/dist/holdout-PECSNGAD.js +44 -0
- package/dist/holdout-PECSNGAD.js.map +1 -0
- package/dist/index.js +84 -2239
- package/dist/index.js.map +1 -1
- package/dist/init-QAAM2GQ7.js +15 -0
- package/dist/init-QAAM2GQ7.js.map +1 -0
- package/dist/lifecycle-56HM7ITG.js +12 -0
- package/dist/lifecycle-56HM7ITG.js.map +1 -0
- package/dist/login-TTWSQ7XS.js +18 -0
- package/dist/login-TTWSQ7XS.js.map +1 -0
- package/dist/menu-UQX3K5QR.js +162 -0
- package/dist/menu-UQX3K5QR.js.map +1 -0
- package/dist/plan-BSFSMKTU.js +135 -0
- package/dist/plan-BSFSMKTU.js.map +1 -0
- package/dist/push-YVS25VVD.js +16 -0
- package/dist/push-YVS25VVD.js.map +1 -0
- package/dist/refs-ZDNH6NRK.js +44 -0
- package/dist/refs-ZDNH6NRK.js.map +1 -0
- package/dist/remove-KFQUK367.js +54 -0
- package/dist/remove-KFQUK367.js.map +1 -0
- package/dist/report-TF2BLJMC.js +64 -0
- package/dist/report-TF2BLJMC.js.map +1 -0
- package/dist/results-TLV5KJWO.js +17 -0
- package/dist/results-TLV5KJWO.js.map +1 -0
- package/dist/review-EIZDOGDC.js +34 -0
- package/dist/review-EIZDOGDC.js.map +1 -0
- package/dist/ship-4YX2WCBP.js +450 -0
- package/dist/ship-4YX2WCBP.js.map +1 -0
- package/dist/skills-HWQT3DTJ.js +13 -0
- package/dist/skills-HWQT3DTJ.js.map +1 -0
- package/dist/status-CWI7ZCYJ.js +11 -0
- package/dist/status-CWI7ZCYJ.js.map +1 -0
- package/package.json +22 -5
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/errors.ts
|
|
4
|
+
var CliError = class extends Error {
|
|
5
|
+
constructor(code, message, hint) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "CliError";
|
|
8
|
+
this.code = code;
|
|
9
|
+
if (hint) this.hint = hint;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
function fail(code, message, hint) {
|
|
13
|
+
throw new CliError(code, message, hint);
|
|
14
|
+
}
|
|
15
|
+
function errorJson(error) {
|
|
16
|
+
if (error instanceof CliError) return { error: error.message, code: error.code, ...error.hint ? { hint: error.hint } : {} };
|
|
17
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
18
|
+
const code = error?.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" || error?.code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE" ? "USAGE" : "INTERNAL";
|
|
19
|
+
return { error: message, code };
|
|
20
|
+
}
|
|
21
|
+
function printJson(value) {
|
|
22
|
+
console.log(JSON.stringify(value));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/ui.ts
|
|
26
|
+
var enabled = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
27
|
+
var wrap = (open, close) => (s) => enabled ? `\x1B[${open}m${s}\x1B[${close}m` : s;
|
|
28
|
+
var c = {
|
|
29
|
+
bold: wrap(1, 22),
|
|
30
|
+
dim: wrap(2, 22),
|
|
31
|
+
red: wrap(31, 39),
|
|
32
|
+
green: wrap(32, 39),
|
|
33
|
+
yellow: wrap(33, 39),
|
|
34
|
+
blue: wrap(34, 39),
|
|
35
|
+
magenta: wrap(35, 39),
|
|
36
|
+
cyan: wrap(36, 39)
|
|
37
|
+
};
|
|
38
|
+
function table(headers, rows) {
|
|
39
|
+
const widths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => strip(r[i] ?? "").length)));
|
|
40
|
+
const line = (cells) => cells.map((cell, i) => cell + " ".repeat(widths[i] - strip(cell).length)).join(" ");
|
|
41
|
+
return [c.dim(line(headers)), ...rows.map(line)].join("\n");
|
|
42
|
+
}
|
|
43
|
+
function strip(s) {
|
|
44
|
+
return s.replace(/\u001b\[\d+m/g, "");
|
|
45
|
+
}
|
|
46
|
+
function pct(x, signed = false) {
|
|
47
|
+
if (x === null || x === void 0 || !Number.isFinite(x)) return "\u2013";
|
|
48
|
+
const v = (x * 100).toFixed(1);
|
|
49
|
+
return signed && x >= 0 ? `+${v}%` : `${v}%`;
|
|
50
|
+
}
|
|
51
|
+
function statusColor(status) {
|
|
52
|
+
switch (status) {
|
|
53
|
+
case "running":
|
|
54
|
+
return c.green(status);
|
|
55
|
+
case "paused":
|
|
56
|
+
return c.yellow(status);
|
|
57
|
+
case "finished":
|
|
58
|
+
return c.blue(status);
|
|
59
|
+
default:
|
|
60
|
+
return c.dim(status);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function verdictIcon(status) {
|
|
64
|
+
switch (status) {
|
|
65
|
+
case "winner_found":
|
|
66
|
+
return "\u2605";
|
|
67
|
+
case "srm_detected":
|
|
68
|
+
return "!";
|
|
69
|
+
case "guardrail_breached":
|
|
70
|
+
return "\u2716";
|
|
71
|
+
case "insufficient_sample":
|
|
72
|
+
return "\u2026";
|
|
73
|
+
case "no_significant_difference":
|
|
74
|
+
return "=";
|
|
75
|
+
default:
|
|
76
|
+
return "\xB7";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function bar(value, max, width = 20, paint = c.green) {
|
|
80
|
+
const n = max > 0 ? Math.max(0, Math.min(width, Math.round(value / max * width))) : 0;
|
|
81
|
+
return paint("\u2588".repeat(n)) + c.dim("\u2591".repeat(width - n));
|
|
82
|
+
}
|
|
83
|
+
function verdictColor(status, text) {
|
|
84
|
+
switch (status) {
|
|
85
|
+
case "winner_found":
|
|
86
|
+
return c.green(text);
|
|
87
|
+
case "srm_detected":
|
|
88
|
+
case "guardrail_breached":
|
|
89
|
+
return c.red(text);
|
|
90
|
+
case "insufficient_sample":
|
|
91
|
+
return c.yellow(text);
|
|
92
|
+
case "no_significant_difference":
|
|
93
|
+
return c.cyan(text);
|
|
94
|
+
default:
|
|
95
|
+
return c.dim(text);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
CliError,
|
|
101
|
+
fail,
|
|
102
|
+
errorJson,
|
|
103
|
+
printJson,
|
|
104
|
+
c,
|
|
105
|
+
table,
|
|
106
|
+
pct,
|
|
107
|
+
statusColor,
|
|
108
|
+
verdictIcon,
|
|
109
|
+
bar,
|
|
110
|
+
verdictColor
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=chunk-V3DLUVOE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/ui.ts"],"sourcesContent":["// Errors with a stable code. With --json the CLI prints `{ error, code, hint? }` on one\n// line to stdout, so agents and the MCP server branch on `code`, never on the wording.\n\nexport const ERROR_CODES = [\n 'USAGE',\n 'INVALID_FLAG',\n 'NO_CONFIG',\n 'CONFIG_PARSE',\n 'CONFIG_WRITE',\n 'CONFIG_UNSAFE',\n 'EXPERIMENT_EXISTS',\n 'EXPERIMENT_NOT_FOUND',\n 'VARIANT_NOT_FOUND',\n 'GOAL_NOT_FOUND',\n 'NOT_CLOUD',\n 'NOT_LOGGED_IN',\n 'INSUFFICIENT_SCOPE',\n 'API_ERROR',\n 'UNREACHABLE',\n 'TYPESCRIPT_MISSING',\n 'INTERNAL',\n] as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[number];\n\nexport class CliError extends Error {\n readonly code: ErrorCode;\n readonly hint?: string;\n constructor(code: ErrorCode, message: string, hint?: string) {\n super(message);\n this.name = 'CliError';\n this.code = code;\n if (hint) this.hint = hint;\n }\n}\n\nexport function fail(code: ErrorCode, message: string, hint?: string): never {\n throw new CliError(code, message, hint);\n}\n\n/** The one-line JSON body for an error (unknown errors become INTERNAL, or USAGE for parseArgs). */\nexport function errorJson(error: unknown): { error: string; code: ErrorCode; hint?: string } {\n if (error instanceof CliError) return { error: error.message, code: error.code, ...(error.hint ? { hint: error.hint } : {}) };\n const message = error instanceof Error ? error.message : String(error);\n const code: ErrorCode = (error as { code?: unknown } | null)?.code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION' || (error as { code?: unknown } | null)?.code === 'ERR_PARSE_ARGS_INVALID_OPTION_VALUE' ? 'USAGE' : 'INTERNAL';\n return { error: message, code };\n}\n\n/** Machine output: always one line. */\nexport function printJson(value: unknown): void {\n console.log(JSON.stringify(value));\n}\n","const enabled = process.stdout.isTTY && !process.env.NO_COLOR;\nconst wrap = (open: number, close: number) => (s: string) => (enabled ? `\\u001b[${open}m${s}\\u001b[${close}m` : s);\n\nexport const c = {\n bold: wrap(1, 22),\n dim: wrap(2, 22),\n red: wrap(31, 39),\n green: wrap(32, 39),\n yellow: wrap(33, 39),\n blue: wrap(34, 39),\n magenta: wrap(35, 39),\n cyan: wrap(36, 39),\n};\n\nexport function table(headers: string[], rows: string[][]): string {\n const widths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => strip(r[i] ?? '').length)));\n const line = (cells: string[]) => cells.map((cell, i) => cell + ' '.repeat(widths[i]! - strip(cell).length)).join(' ');\n return [c.dim(line(headers)), ...rows.map(line)].join('\\n');\n}\n\nexport function strip(s: string): string {\n // eslint-disable-next-line no-control-regex\n return s.replace(/\\u001b\\[\\d+m/g, '');\n}\n\nexport function pct(x: number | null | undefined, signed = false): string {\n if (x === null || x === undefined || !Number.isFinite(x)) return '–';\n const v = (x * 100).toFixed(1);\n return signed && x >= 0 ? `+${v}%` : `${v}%`;\n}\n\nexport function statusColor(status: string): string {\n switch (status) {\n case 'running':\n return c.green(status);\n case 'paused':\n return c.yellow(status);\n case 'finished':\n return c.blue(status);\n default:\n return c.dim(status);\n }\n}\n\n/** One plain glyph per verdict (no emoji: terminals and CI logs render these everywhere). */\nexport function verdictIcon(status: string | null | undefined): string {\n switch (status) {\n case 'winner_found':\n return '★';\n case 'srm_detected':\n return '!';\n case 'guardrail_breached':\n return '✖';\n case 'insufficient_sample':\n return '…';\n case 'no_significant_difference':\n return '=';\n default:\n return '·';\n }\n}\n\n/** A horizontal bar: filled blocks for value / max, dim blocks for the rest. */\nexport function bar(value: number, max: number, width = 20, paint: (s: string) => string = c.green): string {\n const n = max > 0 ? Math.max(0, Math.min(width, Math.round((value / max) * width))) : 0;\n return paint('█'.repeat(n)) + c.dim('░'.repeat(width - n));\n}\n\nexport function verdictColor(status: string | null, text: string): string {\n switch (status) {\n case 'winner_found':\n return c.green(text);\n case 'srm_detected':\n case 'guardrail_breached':\n return c.red(text);\n case 'insufficient_sample':\n return c.yellow(text);\n case 'no_significant_difference':\n return c.cyan(text);\n default:\n return c.dim(text);\n }\n}\n"],"mappings":";;;AAyBO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAGlC,YAAY,MAAiB,SAAiB,MAAe;AAC3D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,QAAI,KAAM,MAAK,OAAO;AAAA,EACxB;AACF;AAEO,SAAS,KAAK,MAAiB,SAAiB,MAAsB;AAC3E,QAAM,IAAI,SAAS,MAAM,SAAS,IAAI;AACxC;AAGO,SAAS,UAAU,OAAmE;AAC3F,MAAI,iBAAiB,SAAU,QAAO,EAAE,OAAO,MAAM,SAAS,MAAM,MAAM,MAAM,GAAI,MAAM,OAAO,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC,EAAG;AAC5H,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,QAAM,OAAmB,OAAqC,SAAS,mCAAoC,OAAqC,SAAS,wCAAwC,UAAU;AAC3M,SAAO,EAAE,OAAO,SAAS,KAAK;AAChC;AAGO,SAAS,UAAU,OAAsB;AAC9C,UAAQ,IAAI,KAAK,UAAU,KAAK,CAAC;AACnC;;;ACnDA,IAAM,UAAU,QAAQ,OAAO,SAAS,CAAC,QAAQ,I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AE,MAAM,MAAM;AAAA,IACvB,KAAK;AACH,aAAO,EAAE,OAAO,MAAM;AAAA,IACxB,KAAK;AACH,aAAO,EAAE,KAAK,MAAM;AAAA,IACtB;AACE,aAAO,EAAE,IAAI,MAAM;AAAA,EACvB;AACF;AAGO,SAAS,YAAY,QAA2C;AACrE,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAGO,SAAS,IAAI,OAAe,KAAa,QAAQ,IAAI,QAA+B,EAAE,OAAe;AAC1G,QAAM,IAAI,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,KAAK,MAAO,QAAQ,MAAO,KAAK,CAAC,CAAC,IAAI;AACtF,SAAO,MAAM,SAAI,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,SAAI,OAAO,QAAQ,CAAC,CAAC;AAC3D;AAEO,SAAS,aAAa,QAAuB,MAAsB;AACxE,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO,EAAE,MAAM,IAAI;AAAA,IACrB,KAAK;AAAA,IACL,KAAK;AACH,aAAO,EAAE,IAAI,IAAI;AAAA,IACnB,KAAK;AACH,aAAO,EAAE,OAAO,IAAI;AAAA,IACtB,KAAK;AACH,aAAO,EAAE,KAAK,IAAI;AAAA,IACpB;AACE,aAAO,EAAE,IAAI,IAAI;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
findRefs
|
|
4
|
+
} from "./chunk-GVARYUL3.js";
|
|
5
|
+
import {
|
|
6
|
+
loadConfig
|
|
7
|
+
} from "./chunk-3VY5CP3E.js";
|
|
8
|
+
import {
|
|
9
|
+
resolveTarget
|
|
10
|
+
} from "./chunk-EUF75FUC.js";
|
|
11
|
+
import {
|
|
12
|
+
detectProject,
|
|
13
|
+
grepFiles,
|
|
14
|
+
listSourceFiles
|
|
15
|
+
} from "./chunk-PLXDG4B5.js";
|
|
16
|
+
import {
|
|
17
|
+
c,
|
|
18
|
+
printJson
|
|
19
|
+
} from "./chunk-V3DLUVOE.js";
|
|
20
|
+
|
|
21
|
+
// src/commands/doctor.ts
|
|
22
|
+
import { existsSync, readFileSync } from "fs";
|
|
23
|
+
import { join, relative } from "path";
|
|
24
|
+
async function doctor(flags) {
|
|
25
|
+
const checks = [];
|
|
26
|
+
const add = (level, message) => checks.push({ level, message });
|
|
27
|
+
const project = detectProject();
|
|
28
|
+
add("ok", `project "${project.name}" \xB7 ${project.framework} \xB7 ${project.packageManager}`);
|
|
29
|
+
if (!project.configFile) {
|
|
30
|
+
add("error", "splithub.config.ts not found. Run `npx splithub init`.");
|
|
31
|
+
return report(checks, flags);
|
|
32
|
+
}
|
|
33
|
+
add("ok", `config: ${relative(project.root, project.configFile)}`);
|
|
34
|
+
let config;
|
|
35
|
+
try {
|
|
36
|
+
config = await loadConfig(project.configFile);
|
|
37
|
+
add("ok", `config loads \xB7 ${config.experiments.length} experiment(s) \xB7 storage ${config.storage.mode}`);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
add("error", `config does not load: ${error instanceof Error ? error.message : String(error)}`);
|
|
40
|
+
return report(checks, flags);
|
|
41
|
+
}
|
|
42
|
+
const files = listSourceFiles(project.root);
|
|
43
|
+
const providerHits = grepFiles(files, "SplitHubProvider").concat(grepFiles(files, "SplitHubNextProvider"));
|
|
44
|
+
if (providerHits.length === 0) add("error", "no <SplitHubProvider> found in source. Wrap your app once.");
|
|
45
|
+
else add("ok", `provider in ${relative(project.root, providerHits[0])}`);
|
|
46
|
+
if (project.framework === "next") {
|
|
47
|
+
const mw = ["middleware.ts", "src/middleware.ts", "middleware.js", "src/middleware.js"].map((f) => join(project.root, f)).find((f) => existsSync(f));
|
|
48
|
+
const hasRedirects = config.experiments.some((e) => e.kind === "redirect");
|
|
49
|
+
if (!mw) add(hasRedirects ? "error" : "warn", "no middleware.ts: visitor cookie is not set on the server (SSR may flicker)" + (hasRedirects ? "; redirect experiments will not run" : ""));
|
|
50
|
+
else if (!readFileSync(mw, "utf8").includes("splithubMiddleware")) add("warn", `${relative(project.root, mw)} does not call splithubMiddleware()`);
|
|
51
|
+
else add("ok", `middleware: ${relative(project.root, mw)}`);
|
|
52
|
+
if (config.storage.mode === "self" && project.appDir) {
|
|
53
|
+
const catchAll = join(project.root, project.appDir, "api/splithub/[[...path]]/route.ts");
|
|
54
|
+
const plain = join(project.root, project.appDir, "api/splithub/route.ts");
|
|
55
|
+
if (existsSync(catchAll)) add("ok", `ingest route: ${relative(project.root, catchAll)}`);
|
|
56
|
+
else if (existsSync(plain)) add("error", `${relative(project.root, plain)} only serves POST /api/splithub; move it to api/splithub/[[...path]]/route.ts so /status and /results work`);
|
|
57
|
+
else add("error", `self mode but ${relative(project.root, catchAll)} is missing (ingest endpoint)`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const exp of config.experiments) {
|
|
61
|
+
const label = `${exp.key} (${exp.kind}, ${exp.status})`;
|
|
62
|
+
if (!exp.goal) add(exp.status === "running" ? "error" : "warn", `${label}: no goal; the verdict cannot be computed`);
|
|
63
|
+
if (exp.kind !== "redirect") {
|
|
64
|
+
const used = findRefs(project.root, config, exp.key, files).refs.filter((r) => r.match === "experiment").length;
|
|
65
|
+
if (used === 0) add(exp.status === "running" ? "error" : "warn", `${label}: not referenced in code (useValue/useVariant/<Experiment id>)`);
|
|
66
|
+
}
|
|
67
|
+
if (exp.status === "running" && exp.variants.every((v) => v.weight === 0)) add("error", `${label}: all weights are 0`);
|
|
68
|
+
}
|
|
69
|
+
for (const goal of config.goals) {
|
|
70
|
+
if (goal.type === "event" && grepFiles(files, `'${goal.key}'`).length + grepFiles(files, `"${goal.key}"`).length === 0) {
|
|
71
|
+
add("warn", `goal "${goal.key}": track('${goal.key}') is never called`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const target = resolveTarget(flags, project);
|
|
75
|
+
try {
|
|
76
|
+
const ctrl = new AbortController();
|
|
77
|
+
const t = setTimeout(() => ctrl.abort(), 2500);
|
|
78
|
+
const res = await fetch(`${target.url}/health`, { signal: ctrl.signal });
|
|
79
|
+
clearTimeout(t);
|
|
80
|
+
add(res.ok ? "ok" : "warn", `endpoint ${target.url}/health \u2192 ${res.status}`);
|
|
81
|
+
} catch {
|
|
82
|
+
add("warn", `endpoint ${target.url} not reachable (is the dev server running?)`);
|
|
83
|
+
}
|
|
84
|
+
return report(checks, flags);
|
|
85
|
+
}
|
|
86
|
+
function report(checks, flags) {
|
|
87
|
+
const errors = checks.filter((x) => x.level === "error").length;
|
|
88
|
+
if (flags.json) {
|
|
89
|
+
printJson({ ok: errors === 0, errors, warnings: checks.filter((x) => x.level === "warn").length, checks });
|
|
90
|
+
} else {
|
|
91
|
+
for (const x of checks) {
|
|
92
|
+
const icon = x.level === "ok" ? c.green("\u2714") : x.level === "warn" ? c.yellow("!") : c.red("\u2716");
|
|
93
|
+
console.log(`${icon} ${x.message}`);
|
|
94
|
+
}
|
|
95
|
+
console.log();
|
|
96
|
+
console.log(errors === 0 ? c.green("All good.") : c.red(`${errors} problem(s) to fix.`));
|
|
97
|
+
}
|
|
98
|
+
if (errors > 0) process.exitCode = 1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
doctor
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=chunk-YSXW2HN6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/doctor.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { resolveTarget } from '../api';\nimport { loadConfig } from '../config-file';\nimport { printJson } from '../errors';\nimport { detectProject, grepFiles, listSourceFiles } from '../project';\nimport { findRefs } from '../refs';\nimport { c } from '../ui';\nimport type { Flags } from './init';\n\ntype Level = 'ok' | 'warn' | 'error';\ninterface Check {\n level: Level;\n message: string;\n}\n\nexport async function doctor(flags: Flags): Promise<void> {\n const checks: Check[] = [];\n const add = (level: Level, message: string) => checks.push({ level, message });\n const project = detectProject();\n\n add('ok', `project \"${project.name}\" · ${project.framework} · ${project.packageManager}`);\n\n if (!project.configFile) {\n add('error', 'splithub.config.ts not found. Run `npx splithub init`.');\n return report(checks, flags);\n }\n add('ok', `config: ${relative(project.root, project.configFile)}`);\n\n let config;\n try {\n config = await loadConfig(project.configFile);\n add('ok', `config loads · ${config.experiments.length} experiment(s) · storage ${config.storage.mode}`);\n } catch (error) {\n add('error', `config does not load: ${error instanceof Error ? error.message : String(error)}`);\n return report(checks, flags);\n }\n\n const files = listSourceFiles(project.root);\n const providerHits = grepFiles(files, 'SplitHubProvider').concat(grepFiles(files, 'SplitHubNextProvider'));\n if (providerHits.length === 0) add('error', 'no <SplitHubProvider> found in source. Wrap your app once.');\n else add('ok', `provider in ${relative(project.root, providerHits[0]!)}`);\n\n if (project.framework === 'next') {\n const mw = ['middleware.ts', 'src/middleware.ts', 'middleware.js', 'src/middleware.js'].map((f) => join(project.root, f)).find((f) => existsSync(f));\n const hasRedirects = config.experiments.some((e) => e.kind === 'redirect');\n if (!mw) add(hasRedirects ? 'error' : 'warn', 'no middleware.ts: visitor cookie is not set on the server (SSR may flicker)' + (hasRedirects ? '; redirect experiments will not run' : ''));\n else if (!readFileSync(mw, 'utf8').includes('splithubMiddleware')) add('warn', `${relative(project.root, mw)} does not call splithubMiddleware()`);\n else add('ok', `middleware: ${relative(project.root, mw)}`);\n if (config.storage.mode === 'self' && project.appDir) {\n const catchAll = join(project.root, project.appDir, 'api/splithub/[[...path]]/route.ts');\n const plain = join(project.root, project.appDir, 'api/splithub/route.ts');\n if (existsSync(catchAll)) add('ok', `ingest route: ${relative(project.root, catchAll)}`);\n else if (existsSync(plain)) add('error', `${relative(project.root, plain)} only serves POST /api/splithub; move it to api/splithub/[[...path]]/route.ts so /status and /results work`);\n else add('error', `self mode but ${relative(project.root, catchAll)} is missing (ingest endpoint)`);\n }\n }\n\n for (const exp of config.experiments) {\n const label = `${exp.key} (${exp.kind}, ${exp.status})`;\n if (!exp.goal) add(exp.status === 'running' ? 'error' : 'warn', `${label}: no goal; the verdict cannot be computed`);\n if (exp.kind !== 'redirect') {\n const used = findRefs(project.root, config, exp.key, files).refs.filter((r) => r.match === 'experiment').length;\n if (used === 0) add(exp.status === 'running' ? 'error' : 'warn', `${label}: not referenced in code (useValue/useVariant/<Experiment id>)`);\n }\n if (exp.status === 'running' && exp.variants.every((v) => v.weight === 0)) add('error', `${label}: all weights are 0`);\n }\n for (const goal of config.goals) {\n if (goal.type === 'event' && grepFiles(files, `'${goal.key}'`).length + grepFiles(files, `\"${goal.key}\"`).length === 0) {\n add('warn', `goal \"${goal.key}\": track('${goal.key}') is never called`);\n }\n }\n\n const target = resolveTarget(flags, project);\n try {\n const ctrl = new AbortController();\n const t = setTimeout(() => ctrl.abort(), 2500);\n const res = await fetch(`${target.url}/health`, { signal: ctrl.signal });\n clearTimeout(t);\n add(res.ok ? 'ok' : 'warn', `endpoint ${target.url}/health → ${res.status}`);\n } catch {\n add('warn', `endpoint ${target.url} not reachable (is the dev server running?)`);\n }\n\n return report(checks, flags);\n}\n\nfunction report(checks: Check[], flags: Flags): void {\n const errors = checks.filter((x) => x.level === 'error').length;\n if (flags.json) {\n printJson({ ok: errors === 0, errors, warnings: checks.filter((x) => x.level === 'warn').length, checks });\n } else {\n for (const x of checks) {\n const icon = x.level === 'ok' ? c.green('✔') : x.level === 'warn' ? c.yellow('!') : c.red('✖');\n console.log(`${icon} ${x.message}`);\n }\n console.log();\n console.log(errors === 0 ? c.green('All good.') : c.red(`${errors} problem(s) to fix.`));\n }\n if (errors > 0) process.exitCode = 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,oBAAoB;AACzC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W,IAAI,EAAE,MAAM,WAAW,IAAI,EAAE,IAAI,GAAG,MAAM,qBAAqB,CAAC;AAAA,EACzF;AACA,MAAI,SAAS,EAAG,SAAQ,WAAW;AACrC;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CLI,
|
|
4
|
+
ciInit,
|
|
5
|
+
workflowTemplate,
|
|
6
|
+
writeWorkflow
|
|
7
|
+
} from "./chunk-EYYLDI5J.js";
|
|
8
|
+
import "./chunk-PLXDG4B5.js";
|
|
9
|
+
import "./chunk-V3DLUVOE.js";
|
|
10
|
+
export {
|
|
11
|
+
CLI,
|
|
12
|
+
ciInit,
|
|
13
|
+
workflowTemplate,
|
|
14
|
+
writeWorkflow
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=ci-ZQZ6RBUJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
create,
|
|
4
|
+
parseExtras,
|
|
5
|
+
parseLimits,
|
|
6
|
+
parseWeights
|
|
7
|
+
} from "./chunk-3VACHXWE.js";
|
|
8
|
+
import "./chunk-3VY5CP3E.js";
|
|
9
|
+
import "./chunk-3DUWIEHB.js";
|
|
10
|
+
import "./chunk-PLXDG4B5.js";
|
|
11
|
+
import "./chunk-V3DLUVOE.js";
|
|
12
|
+
export {
|
|
13
|
+
create,
|
|
14
|
+
parseExtras,
|
|
15
|
+
parseLimits,
|
|
16
|
+
parseWeights
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=create-K75OY6XK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
doctor
|
|
4
|
+
} from "./chunk-YSXW2HN6.js";
|
|
5
|
+
import "./chunk-GVARYUL3.js";
|
|
6
|
+
import "./chunk-3VY5CP3E.js";
|
|
7
|
+
import "./chunk-EUF75FUC.js";
|
|
8
|
+
import "./chunk-PLXDG4B5.js";
|
|
9
|
+
import "./chunk-V3DLUVOE.js";
|
|
10
|
+
export {
|
|
11
|
+
doctor
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=doctor-MFYBZUKO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
loadConfig,
|
|
4
|
+
readSource,
|
|
5
|
+
setTopLevel,
|
|
6
|
+
writeConfigChecked
|
|
7
|
+
} from "./chunk-3VY5CP3E.js";
|
|
8
|
+
import {
|
|
9
|
+
requireConfig
|
|
10
|
+
} from "./chunk-PLXDG4B5.js";
|
|
11
|
+
import {
|
|
12
|
+
c,
|
|
13
|
+
fail,
|
|
14
|
+
printJson
|
|
15
|
+
} from "./chunk-V3DLUVOE.js";
|
|
16
|
+
|
|
17
|
+
// src/commands/holdout.ts
|
|
18
|
+
import { relative } from "path";
|
|
19
|
+
async function holdout(action, value, flags) {
|
|
20
|
+
if (action !== "set" && action !== "off") fail("USAGE", "Use npx splithub holdout set <percent> or npx splithub holdout off.");
|
|
21
|
+
const project = requireConfig();
|
|
22
|
+
const config = await loadConfig(project.configFile);
|
|
23
|
+
const percent = action === "off" ? 0 : Number(value);
|
|
24
|
+
if (action === "set" && (!Number.isFinite(percent) || percent <= 0 || percent > 50)) fail("INVALID_FLAG", `Holdout "${value ?? ""}" must be a percent above 0 and at most 50.`, "Most teams keep 5-10% out.");
|
|
25
|
+
const goal = typeof flags.goal === "string" ? flags.goal : void 0;
|
|
26
|
+
if (goal && !config.goals.some((g) => g.key === goal)) fail("GOAL_NOT_FOUND", `There's no goal "${goal}" in the config.`);
|
|
27
|
+
const original = readSource(project.configFile);
|
|
28
|
+
const text = percent === 0 ? null : `{ percent: ${percent}${goal ? `, goal: '${goal}'` : ""} }`;
|
|
29
|
+
await writeConfigChecked(project.configFile, original, setTopLevel(original, "holdout", text), (loaded) => {
|
|
30
|
+
const h = loaded.holdout;
|
|
31
|
+
return percent === 0 ? h ? "the holdout is still there" : null : h?.percent === percent ? null : "the holdout did not load back";
|
|
32
|
+
});
|
|
33
|
+
const out = { holdout: percent === 0 ? null : { percent, goal: goal ?? null }, configFile: relative(project.root, project.configFile), next: config.storage.mode === "cloud" ? "npx splithub push" : "deploy the app" };
|
|
34
|
+
if (flags.json) {
|
|
35
|
+
printJson(out);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
console.log(percent === 0 ? `${c.green("\u2714")} holdout off` : `${c.green("\u2714")} ${percent}% of visitors stay out of every test; status shows them as "Holdout: long-term impact".`);
|
|
39
|
+
console.log(c.dim(`Next: ${out.next}.`));
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
holdout
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=holdout-PECSNGAD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/holdout.ts"],"sourcesContent":["// `splithub holdout set <percent> [--goal g]` / `splithub holdout off`: a share of visitors\n// that never sees any test, compared with everyone else as `__holdout` (long-term impact).\nimport { relative } from 'node:path';\nimport { loadConfig, readSource, setTopLevel, writeConfigChecked } from '../config-file';\nimport { fail, printJson } from '../errors';\nimport { requireConfig } from '../project';\nimport { c } from '../ui';\nimport type { Flags } from './init';\n\nexport async function holdout(action: string | undefined, value: string | undefined, flags: Flags): Promise<void> {\n if (action !== 'set' && action !== 'off') fail('USAGE', 'Use npx splithub holdout set <percent> or npx splithub holdout off.');\n const project = requireConfig();\n const config = await loadConfig(project.configFile);\n const percent = action === 'off' ? 0 : Number(value);\n if (action === 'set' && (!Number.isFinite(percent) || percent <= 0 || percent > 50)) fail('INVALID_FLAG', `Holdout \"${value ?? ''}\" must be a percent above 0 and at most 50.`, 'Most teams keep 5-10% out.');\n const goal = typeof flags.goal === 'string' ? flags.goal : undefined;\n if (goal && !config.goals.some((g) => g.key === goal)) fail('GOAL_NOT_FOUND', `There's no goal \"${goal}\" in the config.`);\n\n const original = readSource(project.configFile);\n const text = percent === 0 ? null : `{ percent: ${percent}${goal ? `, goal: '${goal}'` : ''} }`;\n await writeConfigChecked(project.configFile, original, setTopLevel(original, 'holdout', text), (loaded) => {\n const h = (loaded as { holdout?: { percent: number } | null }).holdout;\n return percent === 0 ? (h ? 'the holdout is still there' : null) : h?.percent === percent ? null : 'the holdout did not load back';\n });\n const out = { holdout: percent === 0 ? null : { percent, goal: goal ?? null }, configFile: relative(project.root, project.configFile), next: config.storage.mode === 'cloud' ? 'npx splithub push' : 'deploy the app' };\n if (flags.json) {\n printJson(out);\n return;\n }\n console.log(percent === 0 ? `${c.green('✔')} holdout off` : `${c.green('✔')} ${percent}% of visitors stay out of every test; status shows them as \"Holdout: long-term impact\".`);\n console.log(c.dim(`Next: ${out.next}.`));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAEA,SAAS,gBAAgB;AAOzB,eAAsB,QAAQ,QAA4B,OAA2B,OAA6B;AAChH,MAAI,WAAW,SAAS,WAAW,MAAO,MAAK,SAAS,qEAAqE;AAC7H,QAAM,UAAU,cAAc;AAC9B,QAAM,SAAS,MAAM,WAAW,QAAQ,UAAU;AAClD,QAAM,UAAU,WAAW,QAAQ,IAAI,OAAO,KAAK;AACnD,MAAI,WAAW,UAAU,CAAC,OAAO,SAAS,OAAO,KAAK,WAAW,KAAK,UAAU,IAAK,MAAK,gBAAgB,YAAY,SAAS,EAAE,+CAA+C,4BAA4B;AAC5M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