splithub 0.5.0 → 0.5.1
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/{analytics-BS3Z6HEF.js → analytics-3TFARFQE.js} +3 -3
- package/dist/{chunk-45VJUM7P.js → chunk-56WHXKGA.js} +2 -2
- package/dist/{chunk-OX3FZH2C.js → chunk-5Y6HUYA6.js} +4 -3
- package/dist/chunk-5Y6HUYA6.js.map +1 -0
- package/dist/{chunk-OZZDQP37.js → chunk-JZH4ZC2R.js} +3 -3
- package/dist/{chunk-7SLMC74Z.js → chunk-K5GDEVMA.js} +16 -9
- package/dist/chunk-K5GDEVMA.js.map +1 -0
- package/dist/{chunk-XWVEN3MM.js → chunk-LWJSVUMI.js} +2 -2
- package/dist/{chunk-XCWKBO5S.js → chunk-Q4W6H7XO.js} +3 -3
- package/dist/{chunk-TBOAI6R7.js → chunk-SXFGWWE7.js} +2 -2
- package/dist/{chunk-3LVJOBZP.js → chunk-WV6RNTIM.js} +2 -2
- package/dist/{chunk-3LVJOBZP.js.map → chunk-WV6RNTIM.js.map} +1 -1
- package/dist/{chunk-VLHSGWBW.js → chunk-ZHM47JI5.js} +3 -3
- package/dist/{connect-UHAZVDEZ.js → connect-SHXP65T2.js} +5 -5
- package/dist/{create-GJKGCXTJ.js → create-HRROFCS2.js} +3 -3
- package/dist/{doctor-MB3F72TI.js → doctor-GCAMTBJG.js} +4 -4
- package/dist/{holdout-DAYEAW7R.js → holdout-BRW4HAT7.js} +2 -2
- package/dist/index.js +12 -12
- package/dist/{init-ZTGN3IJF.js → init-X2D3YAMU.js} +3 -3
- package/dist/{lifecycle-A6CEBOE4.js → lifecycle-C6RF5MC6.js} +3 -3
- package/dist/{menu-ZQ2XWIW6.js → menu-XMAEYJNC.js} +10 -10
- package/dist/{push-QE4QNPFH.js → push-UJHOXRO3.js} +3 -3
- package/dist/{refs-OHRAWIMW.js → refs-5RMWQPHX.js} +2 -2
- package/dist/{remove-ZQKXHLFS.js → remove-MSEG2USQ.js} +2 -2
- package/dist/{ship-FP4QMHLA.js → ship-6A6EWZEX.js} +2 -2
- package/package.json +3 -3
- package/dist/chunk-7SLMC74Z.js.map +0 -1
- package/dist/chunk-OX3FZH2C.js.map +0 -1
- /package/dist/{analytics-BS3Z6HEF.js.map → analytics-3TFARFQE.js.map} +0 -0
- /package/dist/{chunk-45VJUM7P.js.map → chunk-56WHXKGA.js.map} +0 -0
- /package/dist/{chunk-OZZDQP37.js.map → chunk-JZH4ZC2R.js.map} +0 -0
- /package/dist/{chunk-XWVEN3MM.js.map → chunk-LWJSVUMI.js.map} +0 -0
- /package/dist/{chunk-XCWKBO5S.js.map → chunk-Q4W6H7XO.js.map} +0 -0
- /package/dist/{chunk-TBOAI6R7.js.map → chunk-SXFGWWE7.js.map} +0 -0
- /package/dist/{chunk-VLHSGWBW.js.map → chunk-ZHM47JI5.js.map} +0 -0
- /package/dist/{connect-UHAZVDEZ.js.map → connect-SHXP65T2.js.map} +0 -0
- /package/dist/{create-GJKGCXTJ.js.map → create-HRROFCS2.js.map} +0 -0
- /package/dist/{doctor-MB3F72TI.js.map → doctor-GCAMTBJG.js.map} +0 -0
- /package/dist/{holdout-DAYEAW7R.js.map → holdout-BRW4HAT7.js.map} +0 -0
- /package/dist/{init-ZTGN3IJF.js.map → init-X2D3YAMU.js.map} +0 -0
- /package/dist/{lifecycle-A6CEBOE4.js.map → lifecycle-C6RF5MC6.js.map} +0 -0
- /package/dist/{menu-ZQ2XWIW6.js.map → menu-XMAEYJNC.js.map} +0 -0
- /package/dist/{push-QE4QNPFH.js.map → push-UJHOXRO3.js.map} +0 -0
- /package/dist/{refs-OHRAWIMW.js.map → refs-5RMWQPHX.js.map} +0 -0
- /package/dist/{remove-ZQKXHLFS.js.map → remove-MSEG2USQ.js.map} +0 -0
- /package/dist/{ship-FP4QMHLA.js.map → ship-6A6EWZEX.js.map} +0 -0
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
analytics,
|
|
7
7
|
printLive,
|
|
8
8
|
propertyKind
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZHM47JI5.js";
|
|
10
10
|
import "./chunk-G2URJ423.js";
|
|
11
11
|
import "./chunk-YZPQK4N7.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-K5GDEVMA.js";
|
|
13
13
|
import "./chunk-6K3MHBT7.js";
|
|
14
14
|
import "./chunk-4OQEIP33.js";
|
|
15
15
|
import "./chunk-ZISCJRR5.js";
|
|
@@ -21,4 +21,4 @@ export {
|
|
|
21
21
|
printLive,
|
|
22
22
|
propertyKind
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=analytics-
|
|
24
|
+
//# sourceMappingURL=analytics-3TFARFQE.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
readSource,
|
|
5
5
|
setExperimentStatus,
|
|
6
6
|
writeConfigChecked
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-K5GDEVMA.js";
|
|
8
8
|
import {
|
|
9
9
|
requireConfig
|
|
10
10
|
} from "./chunk-6K3MHBT7.js";
|
|
@@ -51,4 +51,4 @@ async function lifecycle(command, id, flags) {
|
|
|
51
51
|
export {
|
|
52
52
|
lifecycle
|
|
53
53
|
};
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
54
|
+
//# sourceMappingURL=chunk-56WHXKGA.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
loadConfig,
|
|
6
6
|
readSource,
|
|
7
7
|
writeConfigChecked
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-K5GDEVMA.js";
|
|
9
9
|
import {
|
|
10
10
|
detectProject,
|
|
11
11
|
requireConfig
|
|
@@ -124,7 +124,7 @@ async function push(flags) {
|
|
|
124
124
|
if (res.status === 409 && body.code === "key_deleted") fail("KEY_DELETED", `${body.error ?? "A deleted experiment used one of these keys"}. Nothing was pushed.`, "Give the experiment a new key in splithub.config.ts and push again.");
|
|
125
125
|
if (!res.ok) throw apiError(res.status, body, `${target.url}/config responded ${res.status}`);
|
|
126
126
|
let keyWritten = false;
|
|
127
|
-
if (body.publicKey && !config.storage.key) {
|
|
127
|
+
if (body.publicKey && /^pk_[A-Za-z0-9_]+$/.test(body.publicKey) && !config.storage.key) {
|
|
128
128
|
const source = readSource(project.configFile);
|
|
129
129
|
const updated = source.replace(/(mode\s*:\s*['"]cloud['"]\s*)(,?)(\s*\})/, (_m, a, _comma, b) => `${a}, key: '${body.publicKey}'${b}`);
|
|
130
130
|
if (updated !== source) {
|
|
@@ -140,6 +140,7 @@ async function push(flags) {
|
|
|
140
140
|
}
|
|
141
141
|
console.log(`${c.green("\u2714")} pushed ${c.bold(String(body.project))} v${body.version} \xB7 ${body.experiments} experiment(s) \u2192 ${target.url}`);
|
|
142
142
|
if (body.kept?.length) console.log(c.yellow(`! kept in the cloud, not in ${out.configFile}: ${body.kept.join(", ")}. They go on as they are; npx splithub push --prune removes them.`));
|
|
143
|
+
if (body.propertiesSkipped) console.log(c.yellow(`! ${body.hint ?? "Analytics properties were left as they are: changing them needs analytics:write."}`));
|
|
143
144
|
if (adopted.length) console.log(`${c.green("\u2714")} written into ${out.configFile} from the dashboard: ${adopted.join(", ")} (wire them in code if they are value/component experiments)`);
|
|
144
145
|
if (body.publicKey) {
|
|
145
146
|
console.log(keyWritten ? `${c.green("\u2714")} public key written to ${out.configFile}` : `${c.dim("public key:")} ${body.publicKey}`);
|
|
@@ -200,4 +201,4 @@ export {
|
|
|
200
201
|
push,
|
|
201
202
|
pull
|
|
202
203
|
};
|
|
203
|
-
//# sourceMappingURL=chunk-
|
|
204
|
+
//# sourceMappingURL=chunk-5Y6HUYA6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/push.ts"],"sourcesContent":["import type { SplitHubConfig } from '@splithub/core';\nimport { relative } from 'node:path';\nimport { apiError, cloudTarget, requireCloudToken } from '../api';\nimport { hasExperiment, insertExperiment, loadConfig, readSource, writeConfigChecked } from '../config-file';\nimport { fail, printJson } from '../errors';\nimport { detectProject, requireConfig } from '../project';\nimport { c } from '../ui';\nimport type { Flags } from './init';\n\nexport interface CloudExperiment {\n key: string;\n kind: 'component' | 'value' | 'redirect' | 'mvt';\n status: 'draft' | 'running' | 'paused' | 'finished';\n goal: string | null;\n match: string | null;\n name?: string;\n description: string | null;\n variants: Array<{ key: string; weight: number; value?: unknown; to?: string; levels?: Record<string, string> }>;\n /** Multivariate: the factors whose combinations the variants are. */\n factors?: Array<{ key: string; levels: string[] }>;\n flow?: unknown;\n traffic?: number;\n maxExposures?: number | null;\n minDays?: number | null;\n goodSample?: number | null;\n schedule?: { startAt?: string | null; endAt?: string | null } | null;\n}\n\ninterface PushResponse {\n ok: boolean;\n project: string;\n version: number;\n pushedAt: string;\n publicKey: string;\n experiments: number;\n /** Experiments created in the dashboard that the local file does not have yet. */\n cloudOnly?: CloudExperiment[];\n /** Experiments from an earlier push that the file lacks, left in the cloud as they are; `--prune` removes them. */\n kept?: string[];\n /** The file's analytics properties were not applied: the key or member lacks analytics:write. */\n propertiesSkipped?: boolean;\n hint?: string;\n}\n\n/** Write dashboard-created experiments into the local config file. Returns the keys written. */\n/** Factor → level → value, read back from the combinations the cloud generated. */\nfunction factorsOf(e: CloudExperiment): Record<string, Record<string, string>> {\n const out: Record<string, Record<string, string>> = {};\n for (const f of e.factors ?? []) {\n out[f.key] = {};\n for (const level of f.levels) {\n const combo = e.variants.find((v) => v.levels?.[f.key] === level);\n const value = (combo?.value as Record<string, unknown> | undefined)?.[f.key];\n out[f.key]![level] = typeof value === 'string' ? value : value === undefined ? level : JSON.stringify(value);\n }\n }\n return out;\n}\n\nasync function adoptCloudExperiments(file: string, cloudOnly: CloudExperiment[] | undefined): Promise<string[]> {\n if (!cloudOnly || cloudOnly.length === 0) return [];\n const original = readSource(file);\n let source = original;\n const written: string[] = [];\n for (const e of cloudOnly) {\n if (hasExperiment(source, e.key)) continue;\n const total = e.variants.reduce((s, v) => s + v.weight, 0) || 1;\n source = insertExperiment(source, {\n key: e.key,\n kind: e.kind,\n status: e.status,\n goal: e.goal ?? undefined,\n match: e.match ?? undefined,\n name: e.name,\n description: e.description ?? undefined,\n flow: e.flow ?? undefined,\n traffic: e.traffic,\n maxExposures: e.maxExposures ?? undefined,\n minDays: e.minDays ?? undefined,\n goodSample: e.goodSample ?? undefined,\n schedule: e.schedule ?? undefined,\n variants: e.variants.map((v) => ({ key: v.key, weight: Math.round((v.weight / total) * 100), value: typeof v.value === 'string' ? v.value : v.value === undefined ? undefined : JSON.stringify(v.value), to: v.to })),\n ...(e.kind === 'mvt' && e.factors ? { factors: factorsOf(e) } : {}),\n });\n written.push(e.key);\n }\n if (written.length) {\n await writeConfigChecked(file, original, source, (config) => {\n const missing = written.filter((k) => !config.experiments.some((x) => x.key === k));\n return missing.length ? `${missing.join(', ')} did not load back` : null;\n });\n }\n return written;\n}\n\ntype LocalExperiment = SplitHubConfig['experiments'][number];\n\nexport interface ConfigDiff {\n added: string[];\n removed: string[];\n /** In the cloud only; a push without `--prune` leaves them. */\n kept: string[];\n changed: Array<{ experiment: string; fields: string[] }>;\n}\n\n/** What a push would change in the cloud, by experiment key. */\nexport function configDiff(local: LocalExperiment[], cloud: Array<CloudExperiment & { origin?: string }>, prune = false): ConfigDiff {\n const added = local.filter((e) => !cloud.some((x) => x.key === e.key)).map((e) => e.key);\n const missing = cloud.filter((x) => x.origin !== 'dashboard' && !local.some((e) => e.key === x.key)).map((x) => x.key);\n const removed = prune ? missing : [];\n const kept = prune ? [] : missing;\n const changed: ConfigDiff['changed'] = [];\n for (const e of local) {\n const x = cloud.find((y) => y.key === e.key);\n if (!x) continue;\n const fields: string[] = [];\n if (x.status !== e.status) fields.push('status');\n if ((x.goal ?? null) !== (e.goal ?? null)) fields.push('goal');\n if (x.kind !== e.kind) fields.push('kind');\n if (x.variants.map((v) => `${v.key}:${v.weight}`).join() !== e.variants.map((v) => `${v.key}:${v.weight}`).join()) fields.push('variants');\n if ((x.traffic ?? 1) !== (e.traffic ?? 1)) fields.push('traffic');\n if (fields.length) changed.push({ experiment: e.key, fields });\n }\n return { added, removed, kept, changed };\n}\n\ninterface KeyConflict {\n key: string;\n reason: 'dashboard' | 'old_data';\n exposures?: number;\n}\n\nconst keyList = (v: Flags[string]): string[] => (typeof v === 'string' ? v.split(',').map((k) => k.trim()).filter(Boolean) : []);\n\n/** The cloud already has another test under a pushed key: say which, and the two ways on. */\nfunction keyConflict(conflicts: KeyConflict[]): never {\n const why = conflicts.map((k) => (k.reason === 'dashboard' ? `${k.key} (a different experiment made in the dashboard)` : `${k.key} (an earlier experiment, ${(k.exposures ?? 0).toLocaleString('en-US')} visitors)`));\n const keys = conflicts.map((k) => k.key).join(',');\n fail(\n 'KEY_CONFLICT',\n `These keys already belong to another experiment in the cloud: ${why.join('; ')}. Nothing was pushed.`,\n `New experiment: rename its key, or run npx splithub push --replace ${keys} (the old numbers are cleared). Same experiment: npx splithub push --same ${keys}.`\n );\n}\n\nasync function cloudFetch(url: string, init: RequestInit): Promise<Response> {\n try {\n return await fetch(url, init);\n } catch (error) {\n fail('UNREACHABLE', `Can't reach ${url}: ${error instanceof Error ? error.message : String(error)}.`, 'Check your connection, or --api / SPLITHUB_API.');\n }\n}\n\n/**\n * `splithub push`: upload the normalized splithub.config.ts to SplitHub Cloud.\n * Needs a project API key (sk_...) via --token or SPLITHUB_API_KEY. The first\n * push returns the public key (pk_...) which is written into the config's\n * `storage.key` when it is still empty. `--dry-run` only checks and compares.\n * Experiments the cloud has from an earlier push that the file lacks are kept\n * unless `--prune`.\n */\nexport async function push(flags: Flags): Promise<void> {\n const project = requireConfig();\n const config = await loadConfig(project.configFile);\n if (flags['dry-run']) return dryRun(flags, config);\n if (config.storage.mode !== 'cloud') {\n fail('NOT_CLOUD', `This project stores events itself (storage.mode is \"${config.storage.mode}\"), so there's nothing to push.`, \"Set storage: { mode: 'cloud' } in splithub.config.ts to use SplitHub Cloud.\");\n }\n const target = requireCloudToken(flags);\n\n const res = await cloudFetch(`${target.url}/config`, {\n method: 'PUT',\n headers: { authorization: `Bearer ${target.token}`, 'content-type': 'application/json' },\n body: JSON.stringify({ config, replace: keyList(flags.replace), same: keyList(flags.same), prune: Boolean(flags.prune) }),\n });\n const body = (await res.json().catch(() => ({}))) as Partial<PushResponse> & { error?: string; code?: string; conflicts?: KeyConflict[] };\n if (res.status === 409 && body.code === 'key_conflict' && body.conflicts?.length) keyConflict(body.conflicts);\n if (res.status === 409 && body.code === 'key_deleted') fail('KEY_DELETED', `${body.error ?? 'A deleted experiment used one of these keys'}. Nothing was pushed.`, 'Give the experiment a new key in splithub.config.ts and push again.');\n if (!res.ok) throw apiError(res.status, body, `${target.url}/config responded ${res.status}`);\n\n // Write the public key into the config when it is missing.\n let keyWritten = false;\n // The key goes into a file that is executed; anything but a plain pk_ key stays out.\n if (body.publicKey && /^pk_[A-Za-z0-9_]+$/.test(body.publicKey) && !config.storage.key) {\n const source = readSource(project.configFile);\n const updated = source.replace(/(mode\\s*:\\s*['\"]cloud['\"]\\s*)(,?)(\\s*\\})/, (_m, a: string, _comma: string, b: string) => `${a}, key: '${body.publicKey}'${b}`);\n if (updated !== source) {\n await writeConfigChecked(project.configFile, source, updated, (loaded) => (loaded.storage.mode === 'cloud' && loaded.storage.key === body.publicKey ? null : 'storage.key did not load back'));\n keyWritten = true;\n }\n }\n\n const adopted = await adoptCloudExperiments(project.configFile, body.cloudOnly);\n const out = { ...body, configFile: relative(project.root, project.configFile), keyWritten, adopted };\n if (flags.json) {\n printJson(out);\n return;\n }\n console.log(`${c.green('✔')} pushed ${c.bold(String(body.project))} v${body.version} · ${body.experiments} experiment(s) → ${target.url}`);\n if (body.kept?.length) console.log(c.yellow(`! kept in the cloud, not in ${out.configFile}: ${body.kept.join(', ')}. They go on as they are; npx splithub push --prune removes them.`));\n if (body.propertiesSkipped) console.log(c.yellow(`! ${body.hint ?? 'Analytics properties were left as they are: changing them needs analytics:write.'}`));\n if (adopted.length) console.log(`${c.green('✔')} written into ${out.configFile} from the dashboard: ${adopted.join(', ')} (wire them in code if they are value/component experiments)`);\n if (body.publicKey) {\n console.log(keyWritten ? `${c.green('✔')} public key written to ${out.configFile}` : `${c.dim('public key:')} ${body.publicKey}`);\n if (!keyWritten && !config.storage.key) console.log(c.yellow(`Add it to splithub.config.ts: storage: { mode: 'cloud', key: '${body.publicKey}' }`));\n }\n}\n\n/** `push --dry-run`: the config loads; when connected, what a push would change. Writes nothing. */\nasync function dryRun(flags: Flags, config: SplitHubConfig): Promise<void> {\n const experiments = config.experiments.map((e) => ({ experiment: e.key, kind: e.kind, status: e.status, goal: e.goal ?? null }));\n let diff: ConfigDiff | null = null;\n let cloud: 'compared' | 'not connected' | 'self mode' = config.storage.mode === 'cloud' ? 'not connected' : 'self mode';\n if (config.storage.mode === 'cloud') {\n const target = cloudTarget(flags);\n if (target.token) {\n const res = await cloudFetch(`${target.url}/config`, { headers: { authorization: `Bearer ${target.token}` } });\n const body = (await res.json().catch(() => ({}))) as { config?: { experiments?: CloudExperiment[] } };\n const prune = Boolean(flags.prune);\n if (res.status === 404 || res.status === 409) diff = configDiff(config.experiments, [], prune);\n else if (!res.ok) throw apiError(res.status, body, `${target.url}/config responded ${res.status}`);\n else diff = configDiff(config.experiments, body.config?.experiments ?? [], prune);\n cloud = 'compared';\n }\n }\n const out = { ok: true, dryRun: true, mode: config.storage.mode, project: config.project, experiments, cloud, diff };\n if (flags.json) {\n printJson(out);\n return;\n }\n console.log(`${c.green('✔')} config loads · ${experiments.length} experiment(s) · ${config.storage.mode} mode`);\n if (!diff) console.log(c.dim(cloud === 'self mode' ? 'Self mode: nothing to push.' : 'Not connected, so nothing to compare. Run npx splithub login.'));\n else if (!diff.added.length && !diff.removed.length && !diff.kept.length && !diff.changed.length) console.log(c.dim('The cloud already has this config.'));\n else {\n for (const k of diff.added) console.log(`${c.green('+')} ${k}`);\n for (const k of diff.removed) console.log(`${c.red('-')} ${k}`);\n for (const ch of diff.changed) console.log(`${c.yellow('~')} ${ch.experiment} ${c.dim(`(${ch.fields.join(', ')})`)}`);\n for (const k of diff.kept) console.log(c.dim(`= ${k} (in the cloud only: kept; --prune removes it)`));\n }\n}\n\n/** `splithub pull`: print the config stored in the cloud (for inspection or recovery). */\nexport async function pull(flags: Flags): Promise<void> {\n const target = requireCloudToken(flags);\n const res = await cloudFetch(`${target.url}/config`, { headers: { authorization: `Bearer ${target.token}` } });\n const body = (await res.json().catch(() => ({}))) as { error?: string; config?: { experiments?: Array<CloudExperiment & { origin?: string }> }; version?: number; pushedAt?: string; publicKey?: string };\n if (!res.ok) throw apiError(res.status, body, `${target.url}/config responded ${res.status}`);\n const project = detectProject();\n const dashboardOnes = (body.config?.experiments ?? []).filter((e) => e.origin === 'dashboard');\n const adopted = project.configFile ? await adoptCloudExperiments(project.configFile, dashboardOnes) : [];\n if (flags.json) {\n printJson({ ...body, adopted });\n return;\n }\n console.log(`${c.bold('cloud config')} v${body.version} ${c.dim(`pushed ${body.pushedAt}`)} · public key ${body.publicKey}`);\n if (adopted.length) console.log(`${c.green('✔')} written into ${relative(project.root, project.configFile ?? '')}: ${adopted.join(', ')}`);\n else if (dashboardOnes.length) console.log(c.dim(`dashboard experiments already present locally: ${dashboardOnes.map((e) => e.key).join(', ')}`));\n else console.log(c.dim('no dashboard-created experiments to pull'));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,gBAAgB;AA6CzB,SAAS,UAAU,GAA4D;AAC7E,QAAM,MAA8C,CAAC;AACrD,aAAW,KAAK,EAAE,WAAW,CAAC,GAAG;AAC/B,QAAI,EAAE,GAAG,IAAI,CAAC;AACd,eAAW,SAAS,EAAE,QAAQ;AAC5B,YAAM,QAAQ,EAAE,SAAS,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,KAAK;AAChE,YAAM,QAAS,OAAO,QAAgD,EAAE,GAAG;AAC3E,UAAI,EAAE,GAAG,EAA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ChI,cAAc,OAAQ,SAAQ,IAAI,EAAE,IAAI,kDAAkD,cAAc,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;AAAA,MAC3I,SAAQ,IAAI,EAAE,IAAI,0CAA0C,CAAC;AACpE;","names":[]}
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
isReactNativeApp,
|
|
10
10
|
nativeSdkInstalled,
|
|
11
11
|
nativeSetup
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WV6RNTIM.js";
|
|
13
13
|
import {
|
|
14
14
|
versionReport
|
|
15
15
|
} from "./chunk-HFIBLDUA.js";
|
|
16
16
|
import {
|
|
17
17
|
loadConfig
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-K5GDEVMA.js";
|
|
19
19
|
import {
|
|
20
20
|
detectProject,
|
|
21
21
|
grepFiles,
|
|
@@ -151,4 +151,4 @@ export {
|
|
|
151
151
|
doctor,
|
|
152
152
|
appChecks
|
|
153
153
|
};
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
154
|
+
//# sourceMappingURL=chunk-JZH4ZC2R.js.map
|
|
@@ -243,7 +243,10 @@ ${block}${outerIndent}` : block;
|
|
|
243
243
|
return head + text + source.slice(at);
|
|
244
244
|
}
|
|
245
245
|
function q(s) {
|
|
246
|
-
return `'${s.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n")}'`;
|
|
246
|
+
return `'${s.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r")}'`;
|
|
247
|
+
}
|
|
248
|
+
function num(v) {
|
|
249
|
+
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
247
250
|
}
|
|
248
251
|
function k(s) {
|
|
249
252
|
return /^[a-z_$][\w$]*$/i.test(s) ? s : q(s);
|
|
@@ -262,20 +265,24 @@ function renderExperiment(e, indent = " ") {
|
|
|
262
265
|
}
|
|
263
266
|
lines.push(`${i2}},`);
|
|
264
267
|
} else if (e.kind === "component") {
|
|
265
|
-
lines.push(`${i2}variants: { ${e.variants.map((v) => `${k(v.key)}: ${v.weight}`).join(", ")} },`);
|
|
268
|
+
lines.push(`${i2}variants: { ${e.variants.map((v) => `${k(v.key)}: ${num(v.weight) ?? 1}`).join(", ")} },`);
|
|
266
269
|
} else {
|
|
267
270
|
lines.push(`${i2}variants: {`);
|
|
268
271
|
for (const v of e.variants) {
|
|
269
272
|
const extra = e.kind === "value" ? `value: ${q(v.value ?? "")}` : `to: ${q(v.to ?? "/")}`;
|
|
270
|
-
lines.push(`${i3}${k(v.key)}: { weight: ${v.weight}, ${extra} },`);
|
|
273
|
+
lines.push(`${i3}${k(v.key)}: { weight: ${num(v.weight) ?? 1}, ${extra} },`);
|
|
271
274
|
}
|
|
272
275
|
lines.push(`${i2}},`);
|
|
273
276
|
}
|
|
274
277
|
if (e.goal) lines.push(`${i2}goal: ${q(e.goal)},`);
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
278
|
+
const traffic = num(e.traffic);
|
|
279
|
+
const maxExposures = num(e.maxExposures);
|
|
280
|
+
const minDays = num(e.minDays);
|
|
281
|
+
const goodSample = num(e.goodSample);
|
|
282
|
+
if (traffic !== void 0 && traffic !== 1) lines.push(`${i2}traffic: ${traffic},`);
|
|
283
|
+
if (maxExposures) lines.push(`${i2}maxExposures: ${maxExposures},`);
|
|
284
|
+
if (minDays !== void 0) lines.push(`${i2}minDays: ${minDays},`);
|
|
285
|
+
if (goodSample !== void 0) lines.push(`${i2}goodSample: ${goodSample},`);
|
|
279
286
|
if (e.schedule && (e.schedule.startAt || e.schedule.endAt)) lines.push(`${i2}schedule: { ${[e.schedule.startAt ? `startAt: ${q(e.schedule.startAt)}` : null, e.schedule.endAt ? `endAt: ${q(e.schedule.endAt)}` : null].filter(Boolean).join(", ")} },`);
|
|
280
287
|
if (e.metrics && (e.metrics.secondary?.length || e.metrics.guardrails?.length)) {
|
|
281
288
|
const parts = [];
|
|
@@ -283,7 +290,7 @@ function renderExperiment(e, indent = " ") {
|
|
|
283
290
|
if (e.metrics.guardrails?.length) parts.push(`guardrails: [${e.metrics.guardrails.map((g) => typeof g === "string" ? q(g) : `{ goal: ${q(g.goal)}, worse: ${q(g.worse)} }`).join(", ")}]`);
|
|
284
291
|
lines.push(`${i2}metrics: { ${parts.join(", ")} },`);
|
|
285
292
|
}
|
|
286
|
-
if (e.layer) lines.push(`${i2}layer: { key: ${q(e.layer.key)}, range: [${e.layer.range[0]}, ${e.layer.range[1]}] },`);
|
|
293
|
+
if (e.layer && num(e.layer.range[0]) !== void 0 && num(e.layer.range[1]) !== void 0) lines.push(`${i2}layer: { key: ${q(e.layer.key)}, range: [${e.layer.range[0]}, ${e.layer.range[1]}] },`);
|
|
287
294
|
if (e.name) lines.push(`${i2}name: ${q(e.name)},`);
|
|
288
295
|
if (e.description) lines.push(`${i2}description: ${q(e.description)},`);
|
|
289
296
|
if (e.flow) {
|
|
@@ -436,4 +443,4 @@ export {
|
|
|
436
443
|
readSource,
|
|
437
444
|
writeConfigChecked
|
|
438
445
|
};
|
|
439
|
-
//# sourceMappingURL=chunk-
|
|
446
|
+
//# sourceMappingURL=chunk-K5GDEVMA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config-file.ts"],"sourcesContent":["import { isSplitHubConfig, type ExperimentKind, type ExperimentStatus, type SplitHubConfig } from '@splithub/core';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { CliError, fail } from './errors';\n\n/** Load splithub.config.ts (TypeScript or JS) through jiti. CONFIG_PARSE when it does not load. */\nexport async function loadConfig(file: string): Promise<SplitHubConfig> {\n let mod: unknown;\n try {\n const { createJiti } = await import('jiti');\n const jiti = createJiti(pathToFileURL(file).href, { fsCache: false, moduleCache: false });\n mod = await jiti.import(file, { default: true });\n } catch (error) {\n fail('CONFIG_PARSE', `${basename(file)} doesn't load: ${error instanceof Error ? error.message.split('\\n')[0] : String(error)}`, 'Fix the error in the file, then run npx splithub doctor.');\n }\n if (!isSplitHubConfig(mod)) {\n fail('CONFIG_PARSE', `${basename(file)} must \\`export default defineConfig({...})\\` from @splithub/core.`);\n }\n return mod;\n}\n\n// ---------------------------------------------------------------------------\n// Source scanning. Edits work on a \"masked\" copy of the file where string\n// contents, template literals, regex literals and comments are blanked out\n// (same length, newlines kept), so braces and quotes inside them never count.\n// ---------------------------------------------------------------------------\n\nconst REGEX_BEFORE = new Set(['', '(', ',', '=', ':', '[', '!', '&', '|', '?', '{', '}', ';', '+', '-', '*', '%', '<', '>', '~', '^']);\n\n/** Copy of `source` with strings (contents), templates, regexes and comments blanked. */\nexport function maskSource(source: string): string {\n const out = source.split('');\n const blank = (from: number, to: number) => {\n for (let j = from; j < to && j < out.length; j++) if (out[j] !== '\\n' && out[j] !== '\\r') out[j] = ' ';\n };\n let lastCode = '';\n let i = 0;\n while (i < source.length) {\n const ch = source[i]!;\n const next = source[i + 1];\n if (ch === '/' && next === '/') {\n const end = source.indexOf('\\n', i);\n const stop = end < 0 ? source.length : end;\n blank(i, stop);\n i = stop;\n continue;\n }\n if (ch === '/' && next === '*') {\n const end = source.indexOf('*/', i + 2);\n const stop = end < 0 ? source.length : end + 2;\n blank(i, stop);\n i = stop;\n continue;\n }\n if (ch === \"'\" || ch === '\"') {\n let j = i + 1;\n while (j < source.length && source[j] !== ch && source[j] !== '\\n') j += source[j] === '\\\\' ? 2 : 1;\n blank(i + 1, j);\n i = j + 1;\n lastCode = ch;\n continue;\n }\n if (ch === '`') {\n let j = i + 1;\n let depth = 0;\n while (j < source.length) {\n const c = source[j]!;\n if (c === '\\\\') {\n j += 2;\n continue;\n }\n if (depth === 0 && c === '`') break;\n if (c === '$' && source[j + 1] === '{') {\n depth++;\n j += 2;\n continue;\n }\n if (depth > 0 && c === '{') depth++;\n else if (depth > 0 && c === '}') depth--;\n j++;\n }\n blank(i + 1, j);\n i = j + 1;\n lastCode = '`';\n continue;\n }\n if (ch === '/' && REGEX_BEFORE.has(lastCode)) {\n let j = i + 1;\n let inClass = false;\n while (j < source.length && source[j] !== '\\n') {\n const c = source[j]!;\n if (c === '\\\\') {\n j += 2;\n continue;\n }\n if (c === '[') inClass = true;\n else if (c === ']') inClass = false;\n else if (c === '/' && !inClass) break;\n j++;\n }\n blank(i + 1, j);\n i = j + 1;\n lastCode = '/';\n continue;\n }\n if (!/\\s/.test(ch)) lastCode = /[\\w$)\\]]/.test(ch) ? 'x' : ch;\n i++;\n }\n return out.join('');\n}\n\n/** Index of the bracket closing the one at `open` in masked text, or null. */\nfunction matchingClose(masked: string, open: number): number | null {\n let depth = 0;\n for (let i = open; i < masked.length; i++) {\n const ch = masked[i]!;\n if (ch === '{' || ch === '(' || ch === '[') depth++;\n else if (ch === '}' || ch === ')' || ch === ']') {\n depth--;\n if (depth === 0) return i;\n }\n }\n return null;\n}\n\nexport interface Entry {\n /** Property name; null for spreads and computed keys. */\n key: string | null;\n /** object: `key: { ... }` · expr: any other value (identifier, call, shorthand) · spread: `...x` · computed: `[k]: v`. */\n kind: 'object' | 'expr' | 'spread' | 'computed';\n start: number;\n valueStart: number;\n /** Exclusive end of the value (trailing whitespace excluded). */\n valueEnd: number;\n /** After the trailing comma when there is one, else `valueEnd`. */\n end: number;\n}\n\n/** Top-level properties of the object literal between `open` and `close` (its braces). */\nexport function objectEntries(source: string, masked: string, open: number, close: number): Entry[] {\n const entries: Entry[] = [];\n let i = open + 1;\n const ws = () => {\n while (i < close && /[\\s,]/.test(masked[i]!)) i++;\n };\n // A value runs to the next comma at depth 0 (or the closing brace).\n const valueTo = (from: number): number => {\n let j = from;\n while (j < close) {\n const ch = masked[j]!;\n if (ch === ',') break;\n if (ch === '{' || ch === '(' || ch === '[') {\n const m = matchingClose(masked, j);\n j = m === null ? close : m + 1;\n continue;\n }\n j++;\n }\n return j;\n };\n for (;;) {\n ws();\n if (i >= close) break;\n const start = i;\n let key: string | null = null;\n let kind: Entry['kind'] = 'expr';\n if (masked.startsWith('...', i)) {\n kind = 'spread';\n i += 3;\n } else {\n const ch = masked[i]!;\n if (ch === \"'\" || ch === '\"') {\n const end = masked.indexOf(ch, i + 1);\n key = source.slice(i + 1, end).replace(/\\\\(.)/g, '$1');\n i = end + 1;\n } else if (ch === '[') {\n kind = 'computed';\n const m = matchingClose(masked, i);\n i = m === null ? close : m + 1;\n } else {\n const m = /^[\\w$-]+/.exec(masked.slice(i, close));\n if (!m) break;\n key = m[0];\n i += m[0].length;\n }\n while (i < close && /\\s/.test(masked[i]!)) i++;\n if (masked[i] === ':') i++;\n }\n while (i < close && /\\s/.test(masked[i]!)) i++;\n const valueStart = i;\n const stop = valueTo(i);\n let valueEnd = stop;\n while (valueEnd > valueStart && /\\s/.test(masked[valueEnd - 1]!)) valueEnd--;\n if (kind === 'expr' && masked[valueStart] === '{' && matchingClose(masked, valueStart) === valueEnd - 1) kind = 'object';\n const end = masked[stop] === ',' ? stop + 1 : valueEnd;\n entries.push({ key, kind, start, valueStart, valueEnd, end });\n i = stop;\n }\n return entries;\n}\n\ninterface Located {\n masked: string;\n open: number;\n close: number;\n entries: Entry[];\n}\n\n/** The `experiments: { ... }` object of the config, with its entries. */\nfunction locateExperiments(source: string): Located {\n const masked = maskSource(source);\n let open = -1;\n // Prefer the object passed to defineConfig({ ... }) / export default { ... }.\n const root = /defineConfig\\s*\\(\\s*\\{|export\\s+default\\s+\\{/.exec(masked);\n if (root) {\n const rootOpen = root.index + root[0].length - 1;\n const rootClose = matchingClose(masked, rootOpen);\n if (rootClose !== null) {\n const exp = objectEntries(source, masked, rootOpen, rootClose).find((e) => e.key === 'experiments');\n if (exp && exp.kind !== 'object') {\n fail('CONFIG_UNSAFE', '`experiments` in the config is not written inline, so the CLI cannot edit it safely.', 'Edit the experiments where they are defined, or write them inline as experiments: { ... }.');\n }\n if (exp) open = exp.valueStart;\n }\n }\n if (open < 0) {\n const m = /\\bexperiments\\s*:\\s*\\{/.exec(masked);\n if (!m) fail('CONFIG_UNSAFE', \"Couldn't find `experiments: {` in the config file.\", 'Add experiments: {} to defineConfig({...}) and retry.');\n open = m.index + m[0].length - 1;\n }\n const close = matchingClose(masked, open);\n if (close === null) fail('CONFIG_PARSE', 'The braces after `experiments: {` are not balanced.');\n return { masked, open, close, entries: objectEntries(source, masked, open, close) };\n}\n\nfunction unsafeHint(key: string): string {\n return `Edit \"${key}\" where it is defined (it comes from a spread or an imported constant), then run npx splithub doctor.`;\n}\n\n/** The literal `key: { ... }` entry of an experiment. Throws when it can't be edited safely. */\nfunction experimentEntry(source: string, key: string): Located & { entry: Entry } {\n const loc = locateExperiments(source);\n const entry = loc.entries.find((e) => e.key === key);\n if (!entry) {\n if (loc.entries.some((e) => e.kind === 'spread' || e.kind === 'computed')) {\n fail('CONFIG_UNSAFE', `\"${key}\" isn't written inline in the config (the experiments use a spread), so the CLI can't edit it safely.`, unsafeHint(key));\n }\n fail('EXPERIMENT_NOT_FOUND', `There's no experiment \"${key}\" in the config.`, 'See the ids with npx splithub status.');\n }\n return { ...loc, entry };\n}\n\nexport function hasExperiment(source: string, key: string): boolean {\n try {\n return locateExperiments(source).entries.some((e) => e.key === key);\n } catch {\n return false;\n }\n}\n\n/** Indentation of the line holding `index`. */\nfunction indentAt(source: string, index: number): string {\n const lineStart = source.lastIndexOf('\\n', index - 1) + 1;\n return /^[ \\t]*/.exec(source.slice(lineStart))?.[0] ?? '';\n}\n\n/**\n * Append `render(indent)` as the last property of the object `open..close`,\n * adding the comma the previous property may be missing.\n */\nfunction appendProperty(source: string, masked: string, open: number, close: number, render: (indent: string) => string): string {\n const outerIndent = indentAt(source, open);\n const indent = outerIndent + ' ';\n let last = close - 1;\n while (last > open && /\\s/.test(masked[last]!)) last--;\n const needsComma = last > open && masked[last] !== ',';\n const lineStart = source.lastIndexOf('\\n', close - 1) + 1;\n const closeOnOwnLine = source.slice(lineStart, close).trim() === '';\n const block = `${indent}${render(indent)},\\n`;\n const at = closeOnOwnLine && lineStart > last ? lineStart : close;\n const text = at === close ? `\\n${block}${outerIndent}` : block;\n const comma = needsComma ? ',' : '';\n // Inline object (`{ a: 1 }`): the whitespace before `}` gives way to the new line.\n const head = at === close ? source.slice(0, last + 1) + comma : source.slice(0, last + 1) + comma + source.slice(last + 1, at);\n return head + text + source.slice(at);\n}\n\nexport interface NewExperiment {\n key: string;\n kind: ExperimentKind;\n status: ExperimentStatus;\n variants: Array<{ key: string; weight: number; value?: string; to?: string }>;\n /** Multivariate: factor → level → value; the variants are derived and not written. */\n factors?: Record<string, Record<string, string>>;\n goal?: string;\n match?: string;\n /** Human name shown instead of the key. */\n name?: string;\n description?: string;\n /** Targeting graph from the dashboard, written verbatim as JSON. */\n flow?: unknown;\n traffic?: number;\n maxExposures?: number;\n /** Days before a verdict (0..30); absent means the default of 0 (none). */\n minDays?: number;\n /** Total visitors for a good sample (100..10,000,000); absent means the default of 5000. */\n goodSample?: number;\n schedule?: { startAt?: string | null; endAt?: string | null };\n /** Secondary goals to watch, and guardrails that must not get worse. */\n metrics?: { secondary?: string[]; guardrails?: Array<string | { goal: string; worse: 'lower' | 'higher' }> };\n /** Mutual exclusion layer and its bucket range [start, end). */\n layer?: { key: string; range: [number, number] };\n}\n\n/** Single-quoted string literal. */\nfunction q(s: string): string {\n return `'${s.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\").replace(/\\n/g, '\\\\n').replace(/\\r/g, '\\\\r')}'`;\n}\n\n/** A number literal, or nothing. Values come from the cloud and the file is executed, so never raw text. */\nfunction num(v: unknown): number | undefined {\n return typeof v === 'number' && Number.isFinite(v) ? v : undefined;\n}\n\n/** Object key: bare when it is a valid identifier, quoted otherwise. */\nfunction k(s: string): string {\n return /^[a-z_$][\\w$]*$/i.test(s) ? s : q(s);\n}\n\n/** Render an experiment entry. Every line after the first carries its own indentation. */\nexport function renderExperiment(e: NewExperiment, indent = ' '): string {\n const i2 = indent + ' ';\n const i3 = i2 + ' ';\n const lines: string[] = [`${k(e.key)}: {`];\n lines.push(`${i2}kind: ${q(e.kind)},`);\n lines.push(`${i2}status: ${q(e.status)},`);\n if (e.match) lines.push(`${i2}match: ${q(e.match)},`);\n if (e.kind === 'mvt') {\n lines.push(`${i2}factors: {`);\n for (const [factor, levels] of Object.entries(e.factors ?? {})) {\n lines.push(`${i3}${k(factor)}: { ${Object.entries(levels).map(([l, v]) => `${k(l)}: ${q(v)}`).join(', ')} },`);\n }\n lines.push(`${i2}},`);\n } else if (e.kind === 'component') {\n lines.push(`${i2}variants: { ${e.variants.map((v) => `${k(v.key)}: ${num(v.weight) ?? 1}`).join(', ')} },`);\n } else {\n lines.push(`${i2}variants: {`);\n for (const v of e.variants) {\n const extra = e.kind === 'value' ? `value: ${q(v.value ?? '')}` : `to: ${q(v.to ?? '/')}`;\n lines.push(`${i3}${k(v.key)}: { weight: ${num(v.weight) ?? 1}, ${extra} },`);\n }\n lines.push(`${i2}},`);\n }\n if (e.goal) lines.push(`${i2}goal: ${q(e.goal)},`);\n const traffic = num(e.traffic);\n const maxExposures = num(e.maxExposures);\n const minDays = num(e.minDays);\n const goodSample = num(e.goodSample);\n if (traffic !== undefined && traffic !== 1) lines.push(`${i2}traffic: ${traffic},`);\n if (maxExposures) lines.push(`${i2}maxExposures: ${maxExposures},`);\n if (minDays !== undefined) lines.push(`${i2}minDays: ${minDays},`);\n if (goodSample !== undefined) lines.push(`${i2}goodSample: ${goodSample},`);\n if (e.schedule && (e.schedule.startAt || e.schedule.endAt)) lines.push(`${i2}schedule: { ${[e.schedule.startAt ? `startAt: ${q(e.schedule.startAt)}` : null, e.schedule.endAt ? `endAt: ${q(e.schedule.endAt)}` : null].filter(Boolean).join(', ')} },`);\n if (e.metrics && (e.metrics.secondary?.length || e.metrics.guardrails?.length)) {\n const parts: string[] = [];\n if (e.metrics.secondary?.length) parts.push(`secondary: [${e.metrics.secondary.map(q).join(', ')}]`);\n if (e.metrics.guardrails?.length) parts.push(`guardrails: [${e.metrics.guardrails.map((g) => (typeof g === 'string' ? q(g) : `{ goal: ${q(g.goal)}, worse: ${q(g.worse)} }`)).join(', ')}]`);\n lines.push(`${i2}metrics: { ${parts.join(', ')} },`);\n }\n if (e.layer && num(e.layer.range[0]) !== undefined && num(e.layer.range[1]) !== undefined) lines.push(`${i2}layer: { key: ${q(e.layer.key)}, range: [${e.layer.range[0]}, ${e.layer.range[1]}] },`);\n if (e.name) lines.push(`${i2}name: ${q(e.name)},`);\n if (e.description) lines.push(`${i2}description: ${q(e.description)},`);\n if (e.flow) {\n const json = JSON.stringify(e.flow, null, 2).split('\\n');\n lines.push(`${i2}// targeting graph from the dashboard; edit it there or by hand\\n${i2}flow: ${json.map((l, n) => (n === 0 ? l : i2 + l)).join('\\n')},`);\n }\n lines.push(`${indent}}`);\n return lines.join('\\n');\n}\n\n/** Append a new experiment at the end of the `experiments: { ... }` object. */\nexport function insertExperiment(source: string, e: NewExperiment): string {\n const { masked, open, close, entries } = locateExperiments(source);\n if (entries.some((x) => x.key === e.key)) fail('EXPERIMENT_EXISTS', `There's already an experiment \"${e.key}\".`, 'Pick another id: an old id keeps its history.');\n return appendProperty(source, masked, open, close, (indent) => renderExperiment(e, indent));\n}\n\nexport function setExperimentStatus(source: string, key: string, status: ExperimentStatus): string {\n const { masked, entry } = experimentEntry(source, key);\n if (entry.kind !== 'object') fail('CONFIG_UNSAFE', `\"${key}\" points to a value defined elsewhere, so the CLI can't edit it safely.`, unsafeHint(key));\n const inner = objectEntries(source, masked, entry.valueStart, entry.valueEnd - 1);\n const field = inner.filter((x) => x.key === 'status').pop();\n if (field) {\n const raw = masked.slice(field.valueStart, field.valueEnd);\n if (!/^(['\"])\\s*\\1$/.test(raw)) fail('CONFIG_UNSAFE', `The status of \"${key}\" isn't a plain string, so the CLI can't change it safely.`, `Set status: '${status}' by hand.`);\n const quote = raw[0]!;\n return source.slice(0, field.valueStart) + `${quote}${status}${quote}` + source.slice(field.valueEnd);\n }\n // No status written (or only through a spread): append one, so it wins over any spread.\n return appendProperty(source, masked, entry.valueStart, entry.valueEnd - 1, () => `status: ${q(status)}`);\n}\n\n/** Remove an experiment's entry (and its line) from the config source. */\nexport function removeExperiment(source: string, key: string): string {\n return removeEntry(source, experimentEntry(source, key).entry);\n}\n\n/** Remove a property, its whole line when it stands alone. */\nfunction removeEntry(source: string, entry: Entry): string {\n const lineStart = source.lastIndexOf('\\n', entry.start - 1) + 1;\n const from = source.slice(lineStart, entry.start).trim() === '' ? lineStart : entry.start;\n let to = entry.end;\n const lineEnd = source.indexOf('\\n', to);\n const rest = source.slice(to, lineEnd < 0 ? source.length : lineEnd);\n if (rest.trim() === '' && from === lineStart) to = lineEnd < 0 ? source.length : lineEnd + 1;\n return source.slice(0, from) + source.slice(to);\n}\n\n/** The object passed to defineConfig({ ... }) / export default { ... }. */\nfunction locateRoot(source: string): Located {\n const masked = maskSource(source);\n const root = /defineConfig\\s*\\(\\s*\\{|export\\s+default\\s+\\{/.exec(masked);\n if (!root) fail('CONFIG_UNSAFE', \"Couldn't find defineConfig({ ... }) in the config file.\", 'Make the change by hand in splithub.config.ts.');\n const open = root.index + root[0].length - 1;\n const close = matchingClose(masked, open);\n if (close === null) fail('CONFIG_PARSE', 'The braces of defineConfig({ ... }) are not balanced.');\n return { masked, open, close, entries: objectEntries(source, masked, open, close) };\n}\n\n/** Set a top-level config property (`holdout: { ... }`), replacing it when it is there. */\nexport function setTopLevel(source: string, name: string, valueText: string | null): string {\n const { masked, open, close, entries } = locateRoot(source);\n const entry = entries.find((e) => e.key === name);\n if (valueText === null) return entry ? removeEntry(source, entry) : source;\n if (entry) return source.slice(0, entry.valueStart) + valueText + source.slice(entry.valueEnd);\n return appendProperty(source, masked, open, close, () => `${k(name)}: ${valueText}`);\n}\n\n// ---------------------------------------------------------------------------\n// Analytics properties: `properties: { site: { goals: [...] } }` at the top level\n// ---------------------------------------------------------------------------\n\nexport interface NewProperty {\n key: string;\n status?: 'running' | 'paused';\n name?: string;\n description?: string;\n goals?: string[];\n /** Only `app` is written: `site` is the default, so files stay as they were. */\n kind?: 'site' | 'app';\n}\n\nexport function renderProperty(p: NewProperty): string {\n const parts: string[] = [];\n if (p.kind === 'app') parts.push(`kind: 'app'`);\n if (p.status && p.status !== 'running') parts.push(`status: ${q(p.status)}`);\n if (p.name) parts.push(`name: ${q(p.name)}`);\n if (p.goals?.length) parts.push(`goals: [${p.goals.map(q).join(', ')}]`);\n if (p.description) parts.push(`description: ${q(p.description)}`);\n return `${k(p.key)}: { ${parts.join(', ')}${parts.length ? ' ' : ''}}`.replace('{ }', '{}');\n}\n\n/** The `properties: { ... }` object, created empty when the config has none. */\nfunction locateProperties(source: string): { source: string } & Located {\n let src = source;\n let root = locateRoot(src);\n let entry = root.entries.find((e) => e.key === 'properties');\n if (!entry) {\n src = appendProperty(src, root.masked, root.open, root.close, () => 'properties: {}');\n root = locateRoot(src);\n entry = root.entries.find((e) => e.key === 'properties')!;\n }\n if (entry.kind !== 'object') fail('CONFIG_UNSAFE', '`properties` in the config is not written inline, so the CLI cannot edit it safely.', 'Edit the properties where they are defined.');\n return { source: src, masked: root.masked, open: entry.valueStart, close: entry.valueEnd - 1, entries: objectEntries(src, root.masked, entry.valueStart, entry.valueEnd - 1) };\n}\n\nfunction propertyEntry(source: string, key: string): Located & { entry: Entry } {\n const root = locateRoot(source);\n const props = root.entries.find((e) => e.key === 'properties');\n if (!props || props.kind !== 'object') fail('PROPERTY_NOT_FOUND', `There's no analytics property \"${key}\" in the config.`, 'See the ids with npx splithub analytics.');\n const entries = objectEntries(source, root.masked, props.valueStart, props.valueEnd - 1);\n const entry = entries.find((e) => e.key === key);\n if (!entry) fail('PROPERTY_NOT_FOUND', `There's no analytics property \"${key}\" in the config.`, 'See the ids with npx splithub analytics.');\n return { masked: root.masked, open: props.valueStart, close: props.valueEnd - 1, entries, entry };\n}\n\nexport function insertProperty(source: string, p: NewProperty): string {\n const loc = locateProperties(source);\n if (loc.entries.some((x) => x.key === p.key)) fail('PROPERTY_EXISTS', `There's already an analytics property \"${p.key}\".`, 'Pick another id.');\n return appendProperty(loc.source, loc.masked, loc.open, loc.close, () => renderProperty(p));\n}\n\nexport function setPropertyStatus(source: string, key: string, status: 'running' | 'paused'): string {\n const { masked, entry } = propertyEntry(source, key);\n if (entry.kind !== 'object') fail('CONFIG_UNSAFE', `\"${key}\" points to a value defined elsewhere, so the CLI can't edit it safely.`, `Set status: '${status}' by hand.`);\n const inner = objectEntries(source, masked, entry.valueStart, entry.valueEnd - 1);\n const field = inner.filter((x) => x.key === 'status').pop();\n if (field) {\n const raw = masked.slice(field.valueStart, field.valueEnd);\n if (!/^(['\"])\\s*\\1$/.test(raw)) fail('CONFIG_UNSAFE', `The status of \"${key}\" isn't a plain string, so the CLI can't change it safely.`, `Set status: '${status}' by hand.`);\n const quote = raw[0]!;\n return source.slice(0, field.valueStart) + `${quote}${status}${quote}` + source.slice(field.valueEnd);\n }\n return appendProperty(source, masked, entry.valueStart, entry.valueEnd - 1, () => `status: ${q(status)}`);\n}\n\nexport function removeProperty(source: string, key: string): string {\n return removeEntry(source, propertyEntry(source, key).entry);\n}\n\n/** Make sure `layers: { <key>: {} }` declares a layer. */\nexport function ensureLayer(source: string, key: string): string {\n const { masked, open, close, entries } = locateRoot(source);\n const layers = entries.find((e) => e.key === 'layers');\n if (!layers) return appendProperty(source, masked, open, close, () => `layers: { ${k(key)}: {} }`);\n if (layers.kind !== 'object') fail('CONFIG_UNSAFE', '`layers` in the config is not written inline.', `Add ${key}: {} to layers by hand.`);\n if (objectEntries(source, masked, layers.valueStart, layers.valueEnd - 1).some((e) => e.key === key)) return source;\n return appendProperty(source, masked, layers.valueStart, layers.valueEnd - 1, () => `${k(key)}: {}`);\n}\n\nexport function readSource(file: string): string {\n return readFileSync(file, 'utf8');\n}\n\nexport function writeSource(file: string, source: string): void {\n writeFileSync(file, source, 'utf8');\n}\n\n/**\n * Write the config, load it back and check the change landed. On any problem the\n * original file is restored and CONFIG_WRITE is thrown: the CLI never leaves a broken config.\n */\nexport async function writeConfigChecked(file: string, original: string, updated: string, verify: (config: SplitHubConfig) => string | null): Promise<SplitHubConfig> {\n writeSource(file, updated);\n let problem: string | null = null;\n let config: SplitHubConfig | null = null;\n try {\n config = await loadConfig(file);\n problem = verify(config);\n } catch (error) {\n problem = error instanceof CliError || error instanceof Error ? error.message : String(error);\n }\n if (problem || !config) {\n writeSource(file, original);\n fail('CONFIG_WRITE', `Couldn't update ${basename(file)}: ${problem ?? 'it did not load'}. The file is back as it was.`, 'Make the change by hand in the config, then run npx splithub doctor.');\n }\n return config;\n}\n"],"mappings":";;;;;;;AAAA,SAAS,wBAAyF;AAClG,SAAS,cAAc,qBAAqB;AAC5C,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAI9B,eAAsB,WAAW,MAAuC;AACtE,MAAI;AACJ,MAAI;AACF,UAAM,EAAE,WAAW,IAAI,MAAM,OAAO,MAAM;AAC1C,UAAM,OAAO,WAAW,cAAc,IAAI,EAAE,MAAM,EAAE,SAAS,OAAO,aAAa,MAAM,CAAC;AACxF,UAAM,MAAM,KAAK,OAAO,MAAM,EAAE,SAAS,KAAK,CAAC;AAAA,EACjD,SAAS,OAAO;AACd,SAAK,gBAAgB,GAAG,SAAS,IAAI,CAAC,kBAAkB,iBAAiB,QAAQ,MAAM,QAAQ,MAAM,IAAI,EAAE,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,0DAA0D;AAAA,EAC7L;AACA,MAAI,CAAC,iBAAiB,GAAG,GAAG;AAC1B,SAAK,gBAAgB,GAAG,SAAS,IAAI,CAAC,mEAAmE;AAAA,EAC3G;AACA,SAAO;AACT;AAQA,IAAM,eAAe,oBAAI,IAAI,CAAC,IAAI,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG,CAAC;AAG9H,SAAS,WAAW,QAAwB;AACjD,Q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AAS,WAAW,MAAsB;AAC/C,SAAO,aAAa,MAAM,MAAM;AAClC;AAEO,SAAS,YAAY,MAAc,QAAsB;AAC9D,gBAAc,MAAM,QAAQ,MAAM;AACpC;AAMA,eAAsB,mBAAmB,MAAc,UAAkB,SAAiB,QAA4E;AACpK,cAAY,MAAM,OAAO;AACzB,MAAI,UAAyB;AAC7B,MAAI,SAAgC;AACpC,MAAI;AACF,aAAS,MAAM,WAAW,IAAI;AAC9B,cAAU,OAAO,MAAM;AAAA,EACzB,SAAS,OAAO;AACd,cAAU,iBAAiB,YAAY,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,EAC9F;AACA,MAAI,WAAW,CAAC,QAAQ;AACtB,gBAAY,MAAM,QAAQ;AAC1B,SAAK,gBAAgB,mBAAmB,SAAS,IAAI,CAAC,KAAK,WAAW,iBAAiB,iCAAiC,sEAAsE;AAAA,EAChM;AACA,SAAO;AACT;","names":["end"]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
loadConfig,
|
|
7
7
|
readSource,
|
|
8
8
|
writeConfigChecked
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-K5GDEVMA.js";
|
|
10
10
|
import {
|
|
11
11
|
componentVariantTemplate
|
|
12
12
|
} from "./chunk-OXQZJCAC.js";
|
|
@@ -339,4 +339,4 @@ export {
|
|
|
339
339
|
parseLimits,
|
|
340
340
|
parseExtras
|
|
341
341
|
};
|
|
342
|
-
//# sourceMappingURL=chunk-
|
|
342
|
+
//# sourceMappingURL=chunk-LWJSVUMI.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
analytics
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZHM47JI5.js";
|
|
5
5
|
import {
|
|
6
6
|
domains
|
|
7
7
|
} from "./chunk-CAFWOX3S.js";
|
|
8
8
|
import {
|
|
9
9
|
loadConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-K5GDEVMA.js";
|
|
11
11
|
import {
|
|
12
12
|
detectProject
|
|
13
13
|
} from "./chunk-6K3MHBT7.js";
|
|
@@ -234,4 +234,4 @@ export {
|
|
|
234
234
|
analyticsMenu,
|
|
235
235
|
domainsMenu
|
|
236
236
|
};
|
|
237
|
-
//# sourceMappingURL=chunk-
|
|
237
|
+
//# sourceMappingURL=chunk-Q4W6H7XO.js.map
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
nativeSetup,
|
|
15
15
|
patchAppEntry,
|
|
16
16
|
screenTracking
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-WV6RNTIM.js";
|
|
18
18
|
import {
|
|
19
19
|
deviceLogin
|
|
20
20
|
} from "./chunk-NFZZSF4M.js";
|
|
@@ -507,4 +507,4 @@ export {
|
|
|
507
507
|
importPath,
|
|
508
508
|
init
|
|
509
509
|
};
|
|
510
|
-
//# sourceMappingURL=chunk-
|
|
510
|
+
//# sourceMappingURL=chunk-SXFGWWE7.js.map
|
|
@@ -156,7 +156,7 @@ ${childIndent}<${tracker.name} />${body.slice(at)}`;
|
|
|
156
156
|
var IOS_PACKAGE_URL = "https://github.com/splithub-io/splithub-sdk";
|
|
157
157
|
var ANDROID_ARTIFACT = "io.splithub:splithub";
|
|
158
158
|
var ANDROID_COMPOSE_ARTIFACT = "io.splithub:splithub-compose";
|
|
159
|
-
var NATIVE_SDK_VERSION = "0.5.
|
|
159
|
+
var NATIVE_SDK_VERSION = "0.5.1";
|
|
160
160
|
function nativeSetup(app, publicKey, property = null) {
|
|
161
161
|
const key = publicKey ?? "pk_\u2026";
|
|
162
162
|
const prop = property ?? "sh-\u2026";
|
|
@@ -202,4 +202,4 @@ export {
|
|
|
202
202
|
nativeSetup,
|
|
203
203
|
nativeSdkInstalled
|
|
204
204
|
};
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
205
|
+
//# sourceMappingURL=chunk-WV6RNTIM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/app-setup.ts"],"sourcesContent":["// Apps (React Native / Expo, native iOS and Android) in `splithub init`, `analytics connect` and `doctor`.\n//\n// React Native / Expo: install @splithub/react-native and wrap the app entry (App.tsx, or app/_layout.tsx with\n// Expo Router) in <SplitHubProvider>, with the screen tracker for the navigation library in use. The entry is\n// rewritten with the TypeScript compiler (the project's own, else the CLI's); without it, or when the entry has\n// a shape we do not recognise, the snippet is printed instead. Native projects get install lines only.\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\nimport type { AppKind, ProjectInfo } from './project';\n\nexport const RN_PACKAGE = '@splithub/react-native';\nexport const ASYNC_STORAGE = '@react-native-async-storage/async-storage';\n\n/** How screens are reported: a tracker component per navigation library, or `useScreen()` by hand. */\nexport type ScreenTracking = 'expo-router' | 'react-navigation' | null;\n\nconst TRACKERS: Record<Exclude<ScreenTracking, null>, { name: string }> = {\n 'expo-router': { name: 'ExpoRouterScreens' },\n 'react-navigation': { name: 'NavigationScreens' },\n};\n\nconst providerImport = (tracker: { name: string } | null) => `import { SplitHubProvider${tracker ? `, ${tracker.name}` : ''} } from '${RN_PACKAGE}';`;\n\nexport function screenTracking(project: Pick<ProjectInfo, 'expoRouter' | 'reactNavigation'>): ScreenTracking {\n return project.expoRouter ? 'expo-router' : project.reactNavigation ? 'react-navigation' : null;\n}\n\nexport const isReactNativeApp = (app: AppKind | null): app is 'expo' | 'react-native' => app === 'expo' || app === 'react-native';\nexport const isNativeApp = (app: AppKind | null): app is 'ios' | 'android' => app === 'ios' || app === 'android';\n\n/** npm packages for a React Native app; Expo installs the storage module with `expo install` (the version matching its SDK). */\nexport function appPackages(project: Pick<ProjectInfo, 'app' | 'deps'>): { runtime: string[]; expo: string[] } {\n const storage = project.deps[ASYNC_STORAGE] ? [] : [ASYNC_STORAGE];\n if (project.app === 'expo') return { runtime: [RN_PACKAGE, '@splithub/core'], expo: storage };\n return { runtime: [RN_PACKAGE, '@splithub/core', ...storage], expo: [] };\n}\n\n/** The file that renders the whole app: the root layout with Expo Router, else App.tsx. */\nexport function findAppEntry(root: string, expoRouter: boolean): string | null {\n const names = expoRouter ? ['app/_layout', 'src/app/_layout'] : ['App', 'src/App', 'app/App'];\n for (const name of names) {\n for (const ext of ['.tsx', '.jsx', '.js', '.ts']) {\n const file = join(root, name + ext);\n if (existsSync(file)) return file;\n }\n }\n return null;\n}\n\nexport interface EntryPatch {\n /** The new source; null when nothing changes. */\n source: string | null;\n status: 'added' | 'already' | 'manual';\n /** Whether the screen tracker was placed (false: add it by hand, see the snippet). */\n screens: boolean;\n reason?: string;\n}\n\n/** The provider snippet to paste when the entry cannot be rewritten. */\nexport function appProviderSnippet(configImport: string, screens: ScreenTracking): string {\n const tracker = screens ? TRACKERS[screens] : null;\n const imports = [providerImport(tracker), `import config from '${configImport}';`];\n if (screens === 'expo-router')\n return `// app/_layout.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}>\\n <ExpoRouterScreens />\\n <Stack />\\n</SplitHubProvider>`;\n if (screens === 'react-navigation')\n return `// App.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}>\\n <NavigationContainer>\\n <NavigationScreens />\\n {/* your navigators */}\\n </NavigationContainer>\\n</SplitHubProvider>`;\n return `// App.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}><App /></SplitHubProvider>\\n// screens: useScreen('Home') in each screen (from ${RN_PACKAGE})`;\n}\n\nfunction scriptKind(ts: typeof TS, file: string): TS.ScriptKind {\n if (/\\.tsx$/.test(file)) return ts.ScriptKind.TSX;\n if (/\\.ts$/.test(file)) return ts.ScriptKind.TS;\n return ts.ScriptKind.JSX;\n}\n\ntype Fn = TS.FunctionDeclaration | TS.FunctionExpression | TS.ArrowFunction;\n\n/** The component behind `export default`: a function, `export default App`, or a wrapper call like `Sentry.wrap(App)`. */\nfunction defaultComponent(ts: typeof TS, sf: TS.SourceFile): Fn | null {\n const byName = (name: string): Fn | null => {\n for (const st of sf.statements) {\n if (ts.isFunctionDeclaration(st) && st.name?.text === name) return st;\n if (ts.isVariableStatement(st)) {\n for (const d of st.declarationList.declarations) {\n if (ts.isIdentifier(d.name) && d.name.text === name && d.initializer && (ts.isArrowFunction(d.initializer) || ts.isFunctionExpression(d.initializer))) return d.initializer;\n }\n }\n }\n return null;\n };\n const fromExpr = (e: TS.Expression): Fn | null => {\n if (ts.isArrowFunction(e) || ts.isFunctionExpression(e)) return e;\n if (ts.isIdentifier(e)) return byName(e.text);\n if (ts.isCallExpression(e) && e.arguments[0]) return fromExpr(e.arguments[0]);\n if (ts.isParenthesizedExpression(e)) return fromExpr(e.expression);\n return null;\n };\n for (const st of sf.statements) {\n if (ts.isFunctionDeclaration(st) && st.modifiers?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword)) return st;\n if (ts.isExportAssignment(st) && !st.isExportEquals) return fromExpr(st.expression);\n }\n return null;\n}\n\nconst isJsx = (ts: typeof TS, n: TS.Node) => ts.isJsxElement(n) || ts.isJsxSelfClosingElement(n) || ts.isJsxFragment(n);\n\nfunction indentAt(src: string, pos: number): string {\n const lineStart = src.lastIndexOf('\\n', pos - 1) + 1;\n return /^[ \\t]*/.exec(src.slice(lineStart))![0];\n}\n\n/** Move lines 2..n of `text` by the difference between where its first line starts and where it will start. */\nfunction shift(text: string, fromCol: number, toCol: number): string {\n const d = toCol - fromCol;\n if (d === 0) return text;\n return text\n .split('\\n')\n .map((line, i) => (i === 0 || !line.trim() ? line : d > 0 ? ' '.repeat(d) + line : line.replace(new RegExp(`^[ \\\\t]{0,${-d}}`), '')))\n .join('\\n');\n}\n\n/**\n * Wraps what the entry's default component returns in <SplitHubProvider config={config}> and adds the imports.\n * Pure: the caller reads and writes the file.\n */\nexport function patchAppEntry(ts: typeof TS, file: string, src: string, opts: { configImport: string; screens: ScreenTracking }): EntryPatch {\n if (/<SplitHubProvider\\b/.test(src)) return { source: null, status: 'already', screens: true };\n const sf = ts.createSourceFile(file, src, ts.ScriptTarget.Latest, true, scriptKind(ts, file));\n const fn = defaultComponent(ts, sf);\n if (!fn?.body) return { source: null, status: 'manual', screens: false, reason: 'no default-exported component' };\n\n // The returned JSX: the last top-level `return <…>` of a block body, or an arrow's expression body.\n let outer: TS.Expression | undefined;\n if (ts.isBlock(fn.body)) {\n const ret = [...fn.body.statements].reverse().find((s): s is TS.ReturnStatement => ts.isReturnStatement(s) && Boolean(s.expression));\n outer = ret?.expression;\n } else outer = fn.body;\n let inner = outer;\n while (inner && ts.isParenthesizedExpression(inner)) inner = inner.expression;\n if (!outer || !inner || !isJsx(ts, inner)) return { source: null, status: 'manual', screens: false, reason: 'the component does not return JSX directly' };\n\n const tracker = opts.screens ? TRACKERS[opts.screens] : null;\n const start = inner.getStart(sf);\n let body = src.slice(start, inner.end);\n let screensPlaced = !tracker;\n let trackerLine = '';\n if (tracker && opts.screens === 'react-navigation') {\n // Inside <NavigationContainer>, where its ref context is available.\n let container: TS.JsxElement | undefined;\n const find = (n: TS.Node): void => {\n if (!container && ts.isJsxElement(n) && n.openingElement.tagName.getText(sf) === 'NavigationContainer') container = n;\n else ts.forEachChild(n, find);\n };\n find(inner);\n if (container) {\n const at = container.openingElement.end - start;\n const firstChild = container.children.find((ch) => !(ts.isJsxText(ch) && ch.containsOnlyTriviaWhiteSpaces));\n const childIndent = firstChild ? indentAt(src, firstChild.getStart(sf)) : indentAt(src, container.getStart(sf)) + ' ';\n body = `${body.slice(0, at)}\\n${childIndent}<${tracker.name} />${body.slice(at)}`;\n screensPlaced = true;\n }\n } else if (tracker) {\n trackerLine = `<${tracker.name} />`;\n screensPlaced = true;\n }\n\n const configName = /\\bconfig\\b/.test(src) ? 'splithubConfig' : 'config';\n const base = indentAt(src, outer.getStart(sf));\n const col = start - (src.lastIndexOf('\\n', start - 1) + 1);\n const inside = base + ' ';\n const wrapped = [\n '(',\n `${base} <SplitHubProvider config={${configName}}>`,\n ...(trackerLine ? [`${inside}${trackerLine}`] : []),\n `${inside}${shift(body, col, inside.length)}`,\n `${base} </SplitHubProvider>`,\n `${base})`,\n ].join('\\n');\n let out = src.slice(0, outer.getStart(sf)) + wrapped + src.slice(outer.end);\n\n const imports = [providerImport(tracker && screensPlaced ? tracker : null), `import ${configName} from '${opts.configImport}';`].join('\\n');\n const lastImport = [...sf.statements].filter(ts.isImportDeclaration).pop();\n if (lastImport) out = out.slice(0, lastImport.end) + '\\n' + imports + out.slice(lastImport.end);\n else out = imports + '\\n\\n' + out;\n return { source: out, status: 'added', screens: screensPlaced };\n}\n\n// ---------------------------------------------------------------------------\n// Native SDKs: install lines and a quick start, no patching.\n// ---------------------------------------------------------------------------\n\n// The same values as sdks/ios/README.md, sdks/android/README.md and the dashboard's install tabs.\nexport const IOS_PACKAGE_URL = 'https://github.com/splithub-io/splithub-sdk';\nexport const ANDROID_ARTIFACT = 'io.splithub:splithub';\nexport const ANDROID_COMPOSE_ARTIFACT = 'io.splithub:splithub-compose';\nexport const NATIVE_SDK_VERSION = '0.5.0';\n\nexport function nativeSetup(app: 'ios' | 'android', publicKey: string | null, property: string | null = null): { install: string; quickStart: string } {\n const key = publicKey ?? 'pk_…';\n const prop = property ?? 'sh-…';\n if (app === 'ios')\n return {\n install: `// Xcode: File → Add Package Dependencies → ${IOS_PACKAGE_URL}, then add SplitHub to the target\\n.package(url: \"${IOS_PACKAGE_URL}\", from: \"${NATIVE_SDK_VERSION}\")`,\n quickStart: `import SplitHub\\n\\nSplitHub.start(publicKey: \"${key}\", property: \"${prop}\") // once, at launch\\nlet cta = SplitHub.variant(\"hero-cta\") // \"control\", \"bold\", ...\\nSplitHub.screen(\"Settings\") // each screen\\nSplitHub.track(\"Signup\") // any event; a goal when marked as one`,\n };\n return {\n install: `// app/build.gradle.kts\\nimplementation(\"${ANDROID_ARTIFACT}:${NATIVE_SDK_VERSION}\")\\nimplementation(\"${ANDROID_COMPOSE_ARTIFACT}:${NATIVE_SDK_VERSION}\") // optional: Experiment(id) { variant -> }, TrackScreen(name)`,\n quickStart: `import io.splithub.SplitHub\\n\\nSplitHub.start(this, \"${key}\", property = \"${prop}\") // once, in Application.onCreate\\nval cta = SplitHub.variant(\"hero-cta\") // \"control\", \"bold\", ...\\nSplitHub.screen(\"Settings\") // each screen\\nSplitHub.track(\"Signup\") // any event; a goal when marked as one`,\n };\n}\n\n/** Whether the native project already depends on the SDK (Package.swift, Podfile, project.pbxproj, Gradle files). */\nexport function nativeSdkInstalled(root: string, app: 'ios' | 'android', read: (file: string) => string | null): boolean {\n const files = app === 'ios' ? ['Package.swift', 'Podfile', 'Package.resolved'] : ['build.gradle', 'build.gradle.kts', 'app/build.gradle', 'app/build.gradle.kts', 'gradle/libs.versions.toml'];\n const needle = app === 'ios' ? /splithub/i : /io\\.splithub/;\n return files.some((f) => needle.test(read(join(root, f)) ?? ''));\n}\n"],"mappings":";;;AAMA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAId,IAAM,aAAa;AACnB,IAAM,gBAAgB;AAK7B,IAAM,WAAoE;AAAA,EACxE,eAAe,EAAE,MAAM,oBAAoB;AAAA,EAC3C,oBAAoB,EAAE,MAAM,oBAAoB;AAClD;AAEA,IAAM,iBAAiB,CAAC,YAAqC,4BAA4B,UAAU,KAAK,QAAQ,IAAI,KAAK,EAAE,YAAY,UAAU;AAE1I,SAAS,eAAe,SAA8E;AAC3G,SAAO,QAAQ,aAAa,gBAAgB,QAAQ,kBAAkB,qBAAqB;AAC7F;AAEO,IAAM,mBAAmB,CAAC,QAAwD,QAAQ,UAAU,QAAQ;AAC5G,IAAM,cAAc,CAAC,QAAkD,QAAQ,SAAS,QAAQ;AAGhG,SAAS,YAAY,SAAmF;AAC7G,QAAM,UAAU,QAAQ,KAAK,aAAa,IAAI,CAAC,IAAI,CAAC,aAAa;AACjE,MAAI,QAAQ,QAAQ,OAAQ,QAAO,EAAE,SAAS,CAAC,YAAY,gBAAgB,GAAG,MAAM,QAAQ;AAC5F,SAAO,EAAE,SAAS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CAAC,KAAK,EAAE,CAAC;AACjE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/app-setup.ts"],"sourcesContent":["// Apps (React Native / Expo, native iOS and Android) in `splithub init`, `analytics connect` and `doctor`.\n//\n// React Native / Expo: install @splithub/react-native and wrap the app entry (App.tsx, or app/_layout.tsx with\n// Expo Router) in <SplitHubProvider>, with the screen tracker for the navigation library in use. The entry is\n// rewritten with the TypeScript compiler (the project's own, else the CLI's); without it, or when the entry has\n// a shape we do not recognise, the snippet is printed instead. Native projects get install lines only.\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\nimport type { AppKind, ProjectInfo } from './project';\n\nexport const RN_PACKAGE = '@splithub/react-native';\nexport const ASYNC_STORAGE = '@react-native-async-storage/async-storage';\n\n/** How screens are reported: a tracker component per navigation library, or `useScreen()` by hand. */\nexport type ScreenTracking = 'expo-router' | 'react-navigation' | null;\n\nconst TRACKERS: Record<Exclude<ScreenTracking, null>, { name: string }> = {\n 'expo-router': { name: 'ExpoRouterScreens' },\n 'react-navigation': { name: 'NavigationScreens' },\n};\n\nconst providerImport = (tracker: { name: string } | null) => `import { SplitHubProvider${tracker ? `, ${tracker.name}` : ''} } from '${RN_PACKAGE}';`;\n\nexport function screenTracking(project: Pick<ProjectInfo, 'expoRouter' | 'reactNavigation'>): ScreenTracking {\n return project.expoRouter ? 'expo-router' : project.reactNavigation ? 'react-navigation' : null;\n}\n\nexport const isReactNativeApp = (app: AppKind | null): app is 'expo' | 'react-native' => app === 'expo' || app === 'react-native';\nexport const isNativeApp = (app: AppKind | null): app is 'ios' | 'android' => app === 'ios' || app === 'android';\n\n/** npm packages for a React Native app; Expo installs the storage module with `expo install` (the version matching its SDK). */\nexport function appPackages(project: Pick<ProjectInfo, 'app' | 'deps'>): { runtime: string[]; expo: string[] } {\n const storage = project.deps[ASYNC_STORAGE] ? [] : [ASYNC_STORAGE];\n if (project.app === 'expo') return { runtime: [RN_PACKAGE, '@splithub/core'], expo: storage };\n return { runtime: [RN_PACKAGE, '@splithub/core', ...storage], expo: [] };\n}\n\n/** The file that renders the whole app: the root layout with Expo Router, else App.tsx. */\nexport function findAppEntry(root: string, expoRouter: boolean): string | null {\n const names = expoRouter ? ['app/_layout', 'src/app/_layout'] : ['App', 'src/App', 'app/App'];\n for (const name of names) {\n for (const ext of ['.tsx', '.jsx', '.js', '.ts']) {\n const file = join(root, name + ext);\n if (existsSync(file)) return file;\n }\n }\n return null;\n}\n\nexport interface EntryPatch {\n /** The new source; null when nothing changes. */\n source: string | null;\n status: 'added' | 'already' | 'manual';\n /** Whether the screen tracker was placed (false: add it by hand, see the snippet). */\n screens: boolean;\n reason?: string;\n}\n\n/** The provider snippet to paste when the entry cannot be rewritten. */\nexport function appProviderSnippet(configImport: string, screens: ScreenTracking): string {\n const tracker = screens ? TRACKERS[screens] : null;\n const imports = [providerImport(tracker), `import config from '${configImport}';`];\n if (screens === 'expo-router')\n return `// app/_layout.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}>\\n <ExpoRouterScreens />\\n <Stack />\\n</SplitHubProvider>`;\n if (screens === 'react-navigation')\n return `// App.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}>\\n <NavigationContainer>\\n <NavigationScreens />\\n {/* your navigators */}\\n </NavigationContainer>\\n</SplitHubProvider>`;\n return `// App.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}><App /></SplitHubProvider>\\n// screens: useScreen('Home') in each screen (from ${RN_PACKAGE})`;\n}\n\nfunction scriptKind(ts: typeof TS, file: string): TS.ScriptKind {\n if (/\\.tsx$/.test(file)) return ts.ScriptKind.TSX;\n if (/\\.ts$/.test(file)) return ts.ScriptKind.TS;\n return ts.ScriptKind.JSX;\n}\n\ntype Fn = TS.FunctionDeclaration | TS.FunctionExpression | TS.ArrowFunction;\n\n/** The component behind `export default`: a function, `export default App`, or a wrapper call like `Sentry.wrap(App)`. */\nfunction defaultComponent(ts: typeof TS, sf: TS.SourceFile): Fn | null {\n const byName = (name: string): Fn | null => {\n for (const st of sf.statements) {\n if (ts.isFunctionDeclaration(st) && st.name?.text === name) return st;\n if (ts.isVariableStatement(st)) {\n for (const d of st.declarationList.declarations) {\n if (ts.isIdentifier(d.name) && d.name.text === name && d.initializer && (ts.isArrowFunction(d.initializer) || ts.isFunctionExpression(d.initializer))) return d.initializer;\n }\n }\n }\n return null;\n };\n const fromExpr = (e: TS.Expression): Fn | null => {\n if (ts.isArrowFunction(e) || ts.isFunctionExpression(e)) return e;\n if (ts.isIdentifier(e)) return byName(e.text);\n if (ts.isCallExpression(e) && e.arguments[0]) return fromExpr(e.arguments[0]);\n if (ts.isParenthesizedExpression(e)) return fromExpr(e.expression);\n return null;\n };\n for (const st of sf.statements) {\n if (ts.isFunctionDeclaration(st) && st.modifiers?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword)) return st;\n if (ts.isExportAssignment(st) && !st.isExportEquals) return fromExpr(st.expression);\n }\n return null;\n}\n\nconst isJsx = (ts: typeof TS, n: TS.Node) => ts.isJsxElement(n) || ts.isJsxSelfClosingElement(n) || ts.isJsxFragment(n);\n\nfunction indentAt(src: string, pos: number): string {\n const lineStart = src.lastIndexOf('\\n', pos - 1) + 1;\n return /^[ \\t]*/.exec(src.slice(lineStart))![0];\n}\n\n/** Move lines 2..n of `text` by the difference between where its first line starts and where it will start. */\nfunction shift(text: string, fromCol: number, toCol: number): string {\n const d = toCol - fromCol;\n if (d === 0) return text;\n return text\n .split('\\n')\n .map((line, i) => (i === 0 || !line.trim() ? line : d > 0 ? ' '.repeat(d) + line : line.replace(new RegExp(`^[ \\\\t]{0,${-d}}`), '')))\n .join('\\n');\n}\n\n/**\n * Wraps what the entry's default component returns in <SplitHubProvider config={config}> and adds the imports.\n * Pure: the caller reads and writes the file.\n */\nexport function patchAppEntry(ts: typeof TS, file: string, src: string, opts: { configImport: string; screens: ScreenTracking }): EntryPatch {\n if (/<SplitHubProvider\\b/.test(src)) return { source: null, status: 'already', screens: true };\n const sf = ts.createSourceFile(file, src, ts.ScriptTarget.Latest, true, scriptKind(ts, file));\n const fn = defaultComponent(ts, sf);\n if (!fn?.body) return { source: null, status: 'manual', screens: false, reason: 'no default-exported component' };\n\n // The returned JSX: the last top-level `return <…>` of a block body, or an arrow's expression body.\n let outer: TS.Expression | undefined;\n if (ts.isBlock(fn.body)) {\n const ret = [...fn.body.statements].reverse().find((s): s is TS.ReturnStatement => ts.isReturnStatement(s) && Boolean(s.expression));\n outer = ret?.expression;\n } else outer = fn.body;\n let inner = outer;\n while (inner && ts.isParenthesizedExpression(inner)) inner = inner.expression;\n if (!outer || !inner || !isJsx(ts, inner)) return { source: null, status: 'manual', screens: false, reason: 'the component does not return JSX directly' };\n\n const tracker = opts.screens ? TRACKERS[opts.screens] : null;\n const start = inner.getStart(sf);\n let body = src.slice(start, inner.end);\n let screensPlaced = !tracker;\n let trackerLine = '';\n if (tracker && opts.screens === 'react-navigation') {\n // Inside <NavigationContainer>, where its ref context is available.\n let container: TS.JsxElement | undefined;\n const find = (n: TS.Node): void => {\n if (!container && ts.isJsxElement(n) && n.openingElement.tagName.getText(sf) === 'NavigationContainer') container = n;\n else ts.forEachChild(n, find);\n };\n find(inner);\n if (container) {\n const at = container.openingElement.end - start;\n const firstChild = container.children.find((ch) => !(ts.isJsxText(ch) && ch.containsOnlyTriviaWhiteSpaces));\n const childIndent = firstChild ? indentAt(src, firstChild.getStart(sf)) : indentAt(src, container.getStart(sf)) + ' ';\n body = `${body.slice(0, at)}\\n${childIndent}<${tracker.name} />${body.slice(at)}`;\n screensPlaced = true;\n }\n } else if (tracker) {\n trackerLine = `<${tracker.name} />`;\n screensPlaced = true;\n }\n\n const configName = /\\bconfig\\b/.test(src) ? 'splithubConfig' : 'config';\n const base = indentAt(src, outer.getStart(sf));\n const col = start - (src.lastIndexOf('\\n', start - 1) + 1);\n const inside = base + ' ';\n const wrapped = [\n '(',\n `${base} <SplitHubProvider config={${configName}}>`,\n ...(trackerLine ? [`${inside}${trackerLine}`] : []),\n `${inside}${shift(body, col, inside.length)}`,\n `${base} </SplitHubProvider>`,\n `${base})`,\n ].join('\\n');\n let out = src.slice(0, outer.getStart(sf)) + wrapped + src.slice(outer.end);\n\n const imports = [providerImport(tracker && screensPlaced ? tracker : null), `import ${configName} from '${opts.configImport}';`].join('\\n');\n const lastImport = [...sf.statements].filter(ts.isImportDeclaration).pop();\n if (lastImport) out = out.slice(0, lastImport.end) + '\\n' + imports + out.slice(lastImport.end);\n else out = imports + '\\n\\n' + out;\n return { source: out, status: 'added', screens: screensPlaced };\n}\n\n// ---------------------------------------------------------------------------\n// Native SDKs: install lines and a quick start, no patching.\n// ---------------------------------------------------------------------------\n\n// The same values as sdks/ios/README.md, sdks/android/README.md and the dashboard's install tabs.\nexport const IOS_PACKAGE_URL = 'https://github.com/splithub-io/splithub-sdk';\nexport const ANDROID_ARTIFACT = 'io.splithub:splithub';\nexport const ANDROID_COMPOSE_ARTIFACT = 'io.splithub:splithub-compose';\nexport const NATIVE_SDK_VERSION = '0.5.1';\n\nexport function nativeSetup(app: 'ios' | 'android', publicKey: string | null, property: string | null = null): { install: string; quickStart: string } {\n const key = publicKey ?? 'pk_…';\n const prop = property ?? 'sh-…';\n if (app === 'ios')\n return {\n install: `// Xcode: File → Add Package Dependencies → ${IOS_PACKAGE_URL}, then add SplitHub to the target\\n.package(url: \"${IOS_PACKAGE_URL}\", from: \"${NATIVE_SDK_VERSION}\")`,\n quickStart: `import SplitHub\\n\\nSplitHub.start(publicKey: \"${key}\", property: \"${prop}\") // once, at launch\\nlet cta = SplitHub.variant(\"hero-cta\") // \"control\", \"bold\", ...\\nSplitHub.screen(\"Settings\") // each screen\\nSplitHub.track(\"Signup\") // any event; a goal when marked as one`,\n };\n return {\n install: `// app/build.gradle.kts\\nimplementation(\"${ANDROID_ARTIFACT}:${NATIVE_SDK_VERSION}\")\\nimplementation(\"${ANDROID_COMPOSE_ARTIFACT}:${NATIVE_SDK_VERSION}\") // optional: Experiment(id) { variant -> }, TrackScreen(name)`,\n quickStart: `import io.splithub.SplitHub\\n\\nSplitHub.start(this, \"${key}\", property = \"${prop}\") // once, in Application.onCreate\\nval cta = SplitHub.variant(\"hero-cta\") // \"control\", \"bold\", ...\\nSplitHub.screen(\"Settings\") // each screen\\nSplitHub.track(\"Signup\") // any event; a goal when marked as one`,\n };\n}\n\n/** Whether the native project already depends on the SDK (Package.swift, Podfile, project.pbxproj, Gradle files). */\nexport function nativeSdkInstalled(root: string, app: 'ios' | 'android', read: (file: string) => string | null): boolean {\n const files = app === 'ios' ? ['Package.swift', 'Podfile', 'Package.resolved'] : ['build.gradle', 'build.gradle.kts', 'app/build.gradle', 'app/build.gradle.kts', 'gradle/libs.versions.toml'];\n const needle = app === 'ios' ? /splithub/i : /io\\.splithub/;\n return files.some((f) => needle.test(read(join(root, f)) ?? ''));\n}\n"],"mappings":";;;AAMA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAId,IAAM,aAAa;AACnB,IAAM,gBAAgB;AAK7B,IAAM,WAAoE;AAAA,EACxE,eAAe,EAAE,MAAM,oBAAoB;AAAA,EAC3C,oBAAoB,EAAE,MAAM,oBAAoB;AAClD;AAEA,IAAM,iBAAiB,CAAC,YAAqC,4BAA4B,UAAU,KAAK,QAAQ,IAAI,KAAK,EAAE,YAAY,UAAU;AAE1I,SAAS,eAAe,SAA8E;AAC3G,SAAO,QAAQ,aAAa,gBAAgB,QAAQ,kBAAkB,qBAAqB;AAC7F;AAEO,IAAM,mBAAmB,CAAC,QAAwD,QAAQ,UAAU,QAAQ;AAC5G,IAAM,cAAc,CAAC,QAAkD,QAAQ,SAAS,QAAQ;AAGhG,SAAS,YAAY,SAAmF;AAC7G,QAAM,UAAU,QAAQ,KAAK,aAAa,IAAI,CAAC,IAAI,CAAC,aAAa;AACjE,MAAI,QAAQ,QAAQ,OAAQ,QAAO,EAAE,SAAS,CAAC,YAAY,gBAAgB,GAAG,MAAM,QAAQ;AAC5F,SAAO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MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;AACjE;","names":[]}
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
removeProperty,
|
|
29
29
|
setPropertyStatus,
|
|
30
30
|
writeConfigChecked
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-K5GDEVMA.js";
|
|
32
32
|
import {
|
|
33
33
|
detectProject,
|
|
34
34
|
requireConfig
|
|
@@ -66,7 +66,7 @@ async function analytics(args, flags) {
|
|
|
66
66
|
if (!first) return listProperties(flags);
|
|
67
67
|
if (SUBCOMMANDS.has(first)) {
|
|
68
68
|
if (first === "create") return createProperty(second ?? newPropertyId(), flags);
|
|
69
|
-
if (first === "connect") return (await import("./connect-
|
|
69
|
+
if (first === "connect") return (await import("./connect-SHXP65T2.js")).connect(second, flags);
|
|
70
70
|
if (first === "segments") return segments(args.slice(1), flags);
|
|
71
71
|
if (!second) fail("USAGE", `Which property? npx splithub analytics ${first} <id>`);
|
|
72
72
|
if (first === "events") return rawEvents(second, flags);
|
|
@@ -353,4 +353,4 @@ export {
|
|
|
353
353
|
afterAdded,
|
|
354
354
|
printLive
|
|
355
355
|
};
|
|
356
|
-
//# sourceMappingURL=chunk-
|
|
356
|
+
//# sourceMappingURL=chunk-ZHM47JI5.js.map
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
propertyChoices,
|
|
4
4
|
propertySnippets
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Q4W6H7XO.js";
|
|
6
6
|
import {
|
|
7
7
|
addProperty,
|
|
8
8
|
afterAdded,
|
|
9
9
|
printLive
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZHM47JI5.js";
|
|
11
11
|
import "./chunk-CAFWOX3S.js";
|
|
12
12
|
import "./chunk-G2URJ423.js";
|
|
13
13
|
import {
|
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
RN_PACKAGE,
|
|
18
18
|
isReactNativeApp
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-WV6RNTIM.js";
|
|
20
20
|
import {
|
|
21
21
|
loadConfig
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-K5GDEVMA.js";
|
|
23
23
|
import {
|
|
24
24
|
listSourceFiles,
|
|
25
25
|
requireConfig
|
|
@@ -235,4 +235,4 @@ export {
|
|
|
235
235
|
wireProvider,
|
|
236
236
|
wireSource
|
|
237
237
|
};
|
|
238
|
-
//# sourceMappingURL=connect-
|
|
238
|
+
//# sourceMappingURL=connect-SHXP65T2.js.map
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
parseExtras,
|
|
5
5
|
parseLimits,
|
|
6
6
|
parseWeights
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-LWJSVUMI.js";
|
|
8
|
+
import "./chunk-K5GDEVMA.js";
|
|
9
9
|
import "./chunk-OXQZJCAC.js";
|
|
10
10
|
import "./chunk-6K3MHBT7.js";
|
|
11
11
|
import "./chunk-ZISCJRR5.js";
|
|
@@ -15,4 +15,4 @@ export {
|
|
|
15
15
|
parseLimits,
|
|
16
16
|
parseWeights
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=create-
|
|
18
|
+
//# sourceMappingURL=create-HRROFCS2.js.map
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import {
|
|
3
3
|
appChecks,
|
|
4
4
|
doctor
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-JZH4ZC2R.js";
|
|
6
6
|
import "./chunk-4B2SGVPD.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-WV6RNTIM.js";
|
|
8
8
|
import "./chunk-HFIBLDUA.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-K5GDEVMA.js";
|
|
10
10
|
import "./chunk-6K3MHBT7.js";
|
|
11
11
|
import "./chunk-4OQEIP33.js";
|
|
12
12
|
import "./chunk-ZISCJRR5.js";
|
|
@@ -14,4 +14,4 @@ export {
|
|
|
14
14
|
appChecks,
|
|
15
15
|
doctor
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=doctor-
|
|
17
|
+
//# sourceMappingURL=doctor-GCAMTBJG.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
readSource,
|
|
5
5
|
setTopLevel,
|
|
6
6
|
writeConfigChecked
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-K5GDEVMA.js";
|
|
8
8
|
import {
|
|
9
9
|
requireConfig
|
|
10
10
|
} from "./chunk-6K3MHBT7.js";
|
|
@@ -42,4 +42,4 @@ async function holdout(action, value, flags) {
|
|
|
42
42
|
export {
|
|
43
43
|
holdout
|
|
44
44
|
};
|
|
45
|
-
//# sourceMappingURL=holdout-
|
|
45
|
+
//# sourceMappingURL=holdout-BRW4HAT7.js.map
|
package/dist/index.js
CHANGED
|
@@ -207,19 +207,19 @@ async function main() {
|
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
if (!command) {
|
|
210
|
-
if (process.stdin.isTTY && process.stdout.isTTY && !values.json) return (await import("./menu-
|
|
210
|
+
if (process.stdin.isTTY && process.stdout.isTTY && !values.json) return (await import("./menu-XMAEYJNC.js")).menu(values);
|
|
211
211
|
console.log(HELP.trimEnd());
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
214
|
switch (command) {
|
|
215
215
|
case "init":
|
|
216
|
-
return (await import("./init-
|
|
216
|
+
return (await import("./init-X2D3YAMU.js")).init(values);
|
|
217
217
|
case "create":
|
|
218
|
-
return (await import("./create-
|
|
218
|
+
return (await import("./create-HRROFCS2.js")).create(values);
|
|
219
219
|
case "start":
|
|
220
220
|
case "pause":
|
|
221
221
|
case "finish":
|
|
222
|
-
return (await import("./lifecycle-
|
|
222
|
+
return (await import("./lifecycle-C6RF5MC6.js")).lifecycle(command, arg, values);
|
|
223
223
|
case "status":
|
|
224
224
|
return (await import("./status-SDXLN4SE.js")).status(values);
|
|
225
225
|
case "results":
|
|
@@ -229,21 +229,21 @@ async function main() {
|
|
|
229
229
|
case "plan":
|
|
230
230
|
return (await import("./plan-UHBAQXRB.js")).plan(arg, values);
|
|
231
231
|
case "refs":
|
|
232
|
-
return (await import("./refs-
|
|
232
|
+
return (await import("./refs-5RMWQPHX.js")).refs(arg, values);
|
|
233
233
|
case "remove":
|
|
234
|
-
return (await import("./remove-
|
|
234
|
+
return (await import("./remove-MSEG2USQ.js")).remove(arg, values);
|
|
235
235
|
case "ship":
|
|
236
|
-
return (await import("./ship-
|
|
236
|
+
return (await import("./ship-6A6EWZEX.js")).ship(arg, values);
|
|
237
237
|
case "report":
|
|
238
238
|
return (await import("./report-E6EJECSP.js")).report(values);
|
|
239
239
|
case "ci":
|
|
240
240
|
if (arg !== "init") fail("USAGE", `Unknown "ci ${arg ?? ""}".`, "Run npx splithub ci init.");
|
|
241
241
|
return (await import("./ci-W72GPWEB.js")).ciInit(values);
|
|
242
242
|
case "holdout":
|
|
243
|
-
return (await import("./holdout-
|
|
243
|
+
return (await import("./holdout-BRW4HAT7.js")).holdout(arg, third, values);
|
|
244
244
|
case "analytics":
|
|
245
245
|
case "properties":
|
|
246
|
-
return (await import("./analytics-
|
|
246
|
+
return (await import("./analytics-3TFARFQE.js")).analytics(positionals.slice(1), values);
|
|
247
247
|
case "notes":
|
|
248
248
|
return (await import("./notes-QN5XW2TI.js")).notes(positionals.slice(1), values);
|
|
249
249
|
case "links":
|
|
@@ -257,15 +257,15 @@ async function main() {
|
|
|
257
257
|
case "dev":
|
|
258
258
|
return (await import("./dev-4O4ZVVKH.js")).dev(values);
|
|
259
259
|
case "doctor":
|
|
260
|
-
return (await import("./doctor-
|
|
260
|
+
return (await import("./doctor-GCAMTBJG.js")).doctor(values);
|
|
261
261
|
case "update":
|
|
262
262
|
return (await import("./update-XF7HWJ3A.js")).update(values);
|
|
263
263
|
case "skills":
|
|
264
264
|
return (await import("./skills-4G73YN3S.js")).skills(values);
|
|
265
265
|
case "push":
|
|
266
|
-
return (await import("./push-
|
|
266
|
+
return (await import("./push-UJHOXRO3.js")).push(values);
|
|
267
267
|
case "pull":
|
|
268
|
-
return (await import("./push-
|
|
268
|
+
return (await import("./push-UJHOXRO3.js")).pull(values);
|
|
269
269
|
case "login":
|
|
270
270
|
return (await import("./login-OT77MNKL.js")).login(values);
|
|
271
271
|
case "logout":
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
importPath,
|
|
4
4
|
init
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SXFGWWE7.js";
|
|
6
6
|
import "./chunk-CB2SJFHK.js";
|
|
7
7
|
import "./chunk-5UN2NKIF.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-WV6RNTIM.js";
|
|
9
9
|
import "./chunk-NFZZSF4M.js";
|
|
10
10
|
import "./chunk-XTHEBWKY.js";
|
|
11
11
|
import "./chunk-OXQZJCAC.js";
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
importPath,
|
|
17
17
|
init
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=init-
|
|
19
|
+
//# sourceMappingURL=init-X2D3YAMU.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
lifecycle
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-56WHXKGA.js";
|
|
5
|
+
import "./chunk-K5GDEVMA.js";
|
|
6
6
|
import "./chunk-6K3MHBT7.js";
|
|
7
7
|
import "./chunk-4OQEIP33.js";
|
|
8
8
|
import "./chunk-ZISCJRR5.js";
|
|
9
9
|
export {
|
|
10
10
|
lifecycle
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=lifecycle-
|
|
12
|
+
//# sourceMappingURL=lifecycle-C6RF5MC6.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
pull,
|
|
4
4
|
push
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5Y6HUYA6.js";
|
|
6
6
|
import {
|
|
7
7
|
status
|
|
8
8
|
} from "./chunk-WQETHW5W.js";
|
|
@@ -11,18 +11,18 @@ import {
|
|
|
11
11
|
} from "./chunk-5JKDO4IN.js";
|
|
12
12
|
import {
|
|
13
13
|
init
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-SXFGWWE7.js";
|
|
15
15
|
import "./chunk-CB2SJFHK.js";
|
|
16
16
|
import "./chunk-5UN2NKIF.js";
|
|
17
17
|
import {
|
|
18
18
|
lifecycle
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-56WHXKGA.js";
|
|
20
20
|
import {
|
|
21
21
|
analyticsMenu,
|
|
22
22
|
domainsMenu,
|
|
23
23
|
pickProperty
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-Q4W6H7XO.js";
|
|
25
|
+
import "./chunk-ZHM47JI5.js";
|
|
26
26
|
import "./chunk-CAFWOX3S.js";
|
|
27
27
|
import {
|
|
28
28
|
alerts,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
} from "./chunk-Z2LTGGUG.js";
|
|
35
35
|
import {
|
|
36
36
|
create
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-LWJSVUMI.js";
|
|
38
38
|
import {
|
|
39
39
|
dev
|
|
40
40
|
} from "./chunk-RBV5NIMY.js";
|
|
@@ -49,11 +49,11 @@ import {
|
|
|
49
49
|
import "./chunk-YZPQK4N7.js";
|
|
50
50
|
import {
|
|
51
51
|
doctor
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-JZH4ZC2R.js";
|
|
53
53
|
import "./chunk-4B2SGVPD.js";
|
|
54
|
-
import "./chunk-
|
|
54
|
+
import "./chunk-WV6RNTIM.js";
|
|
55
55
|
import "./chunk-HFIBLDUA.js";
|
|
56
|
-
import "./chunk-
|
|
56
|
+
import "./chunk-K5GDEVMA.js";
|
|
57
57
|
import {
|
|
58
58
|
login,
|
|
59
59
|
logout
|
|
@@ -725,4 +725,4 @@ export {
|
|
|
725
725
|
menuOptions,
|
|
726
726
|
parseFilterInput
|
|
727
727
|
};
|
|
728
|
-
//# sourceMappingURL=menu-
|
|
728
|
+
//# sourceMappingURL=menu-XMAEYJNC.js.map
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
configDiff,
|
|
4
4
|
pull,
|
|
5
5
|
push
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-5Y6HUYA6.js";
|
|
7
|
+
import "./chunk-K5GDEVMA.js";
|
|
8
8
|
import "./chunk-6K3MHBT7.js";
|
|
9
9
|
import "./chunk-4OQEIP33.js";
|
|
10
10
|
import "./chunk-ZISCJRR5.js";
|
|
@@ -13,4 +13,4 @@ export {
|
|
|
13
13
|
pull,
|
|
14
14
|
push
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=push-
|
|
16
|
+
//# sourceMappingURL=push-UJHOXRO3.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-4B2SGVPD.js";
|
|
5
5
|
import {
|
|
6
6
|
loadConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-K5GDEVMA.js";
|
|
8
8
|
import {
|
|
9
9
|
requireConfig
|
|
10
10
|
} from "./chunk-6K3MHBT7.js";
|
|
@@ -41,4 +41,4 @@ Another experiment also measures "${result.goal}": keep its track() calls.`));
|
|
|
41
41
|
export {
|
|
42
42
|
refs
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=refs-
|
|
44
|
+
//# sourceMappingURL=refs-5RMWQPHX.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
readSource,
|
|
8
8
|
removeExperiment,
|
|
9
9
|
writeConfigChecked
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-K5GDEVMA.js";
|
|
11
11
|
import {
|
|
12
12
|
requireConfig
|
|
13
13
|
} from "./chunk-6K3MHBT7.js";
|
|
@@ -52,4 +52,4 @@ export {
|
|
|
52
52
|
remove,
|
|
53
53
|
removeFromConfig
|
|
54
54
|
};
|
|
55
|
-
//# sourceMappingURL=remove-
|
|
55
|
+
//# sourceMappingURL=remove-MSEG2USQ.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
readSource,
|
|
11
11
|
removeExperiment,
|
|
12
12
|
writeConfigChecked
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-K5GDEVMA.js";
|
|
14
14
|
import {
|
|
15
15
|
grepFiles,
|
|
16
16
|
listSourceFiles,
|
|
@@ -443,4 +443,4 @@ async function ship(id, flags) {
|
|
|
443
443
|
export {
|
|
444
444
|
ship
|
|
445
445
|
};
|
|
446
|
-
//# sourceMappingURL=ship-
|
|
446
|
+
//# sourceMappingURL=ship-6A6EWZEX.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "splithub",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Experiments and analytics for your website or app in one command: create an A/B experiment, read a plain verdict, check traffic, funnels and retention. Sets up React Native, Expo, iOS and Android apps too. Works for you and for your coding agent.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"splithub",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@clack/prompts": "^0.9.1",
|
|
54
54
|
"jiti": "^2.4.2",
|
|
55
|
-
"@splithub/core": "0.5.
|
|
56
|
-
"@splithub/node": "0.5.
|
|
55
|
+
"@splithub/core": "0.5.1",
|
|
56
|
+
"@splithub/node": "0.5.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node": "^22.13.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config-file.ts"],"sourcesContent":["import { isSplitHubConfig, type ExperimentKind, type ExperimentStatus, type SplitHubConfig } from '@splithub/core';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { CliError, fail } from './errors';\n\n/** Load splithub.config.ts (TypeScript or JS) through jiti. CONFIG_PARSE when it does not load. */\nexport async function loadConfig(file: string): Promise<SplitHubConfig> {\n let mod: unknown;\n try {\n const { createJiti } = await import('jiti');\n const jiti = createJiti(pathToFileURL(file).href, { fsCache: false, moduleCache: false });\n mod = await jiti.import(file, { default: true });\n } catch (error) {\n fail('CONFIG_PARSE', `${basename(file)} doesn't load: ${error instanceof Error ? error.message.split('\\n')[0] : String(error)}`, 'Fix the error in the file, then run npx splithub doctor.');\n }\n if (!isSplitHubConfig(mod)) {\n fail('CONFIG_PARSE', `${basename(file)} must \\`export default defineConfig({...})\\` from @splithub/core.`);\n }\n return mod;\n}\n\n// ---------------------------------------------------------------------------\n// Source scanning. Edits work on a \"masked\" copy of the file where string\n// contents, template literals, regex literals and comments are blanked out\n// (same length, newlines kept), so braces and quotes inside them never count.\n// ---------------------------------------------------------------------------\n\nconst REGEX_BEFORE = new Set(['', '(', ',', '=', ':', '[', '!', '&', '|', '?', '{', '}', ';', '+', '-', '*', '%', '<', '>', '~', '^']);\n\n/** Copy of `source` with strings (contents), templates, regexes and comments blanked. */\nexport function maskSource(source: string): string {\n const out = source.split('');\n const blank = (from: number, to: number) => {\n for (let j = from; j < to && j < out.length; j++) if (out[j] !== '\\n' && out[j] !== '\\r') out[j] = ' ';\n };\n let lastCode = '';\n let i = 0;\n while (i < source.length) {\n const ch = source[i]!;\n const next = source[i + 1];\n if (ch === '/' && next === '/') {\n const end = source.indexOf('\\n', i);\n const stop = end < 0 ? source.length : end;\n blank(i, stop);\n i = stop;\n continue;\n }\n if (ch === '/' && next === '*') {\n const end = source.indexOf('*/', i + 2);\n const stop = end < 0 ? source.length : end + 2;\n blank(i, stop);\n i = stop;\n continue;\n }\n if (ch === \"'\" || ch === '\"') {\n let j = i + 1;\n while (j < source.length && source[j] !== ch && source[j] !== '\\n') j += source[j] === '\\\\' ? 2 : 1;\n blank(i + 1, j);\n i = j + 1;\n lastCode = ch;\n continue;\n }\n if (ch === '`') {\n let j = i + 1;\n let depth = 0;\n while (j < source.length) {\n const c = source[j]!;\n if (c === '\\\\') {\n j += 2;\n continue;\n }\n if (depth === 0 && c === '`') break;\n if (c === '$' && source[j + 1] === '{') {\n depth++;\n j += 2;\n continue;\n }\n if (depth > 0 && c === '{') depth++;\n else if (depth > 0 && c === '}') depth--;\n j++;\n }\n blank(i + 1, j);\n i = j + 1;\n lastCode = '`';\n continue;\n }\n if (ch === '/' && REGEX_BEFORE.has(lastCode)) {\n let j = i + 1;\n let inClass = false;\n while (j < source.length && source[j] !== '\\n') {\n const c = source[j]!;\n if (c === '\\\\') {\n j += 2;\n continue;\n }\n if (c === '[') inClass = true;\n else if (c === ']') inClass = false;\n else if (c === '/' && !inClass) break;\n j++;\n }\n blank(i + 1, j);\n i = j + 1;\n lastCode = '/';\n continue;\n }\n if (!/\\s/.test(ch)) lastCode = /[\\w$)\\]]/.test(ch) ? 'x' : ch;\n i++;\n }\n return out.join('');\n}\n\n/** Index of the bracket closing the one at `open` in masked text, or null. */\nfunction matchingClose(masked: string, open: number): number | null {\n let depth = 0;\n for (let i = open; i < masked.length; i++) {\n const ch = masked[i]!;\n if (ch === '{' || ch === '(' || ch === '[') depth++;\n else if (ch === '}' || ch === ')' || ch === ']') {\n depth--;\n if (depth === 0) return i;\n }\n }\n return null;\n}\n\nexport interface Entry {\n /** Property name; null for spreads and computed keys. */\n key: string | null;\n /** object: `key: { ... }` · expr: any other value (identifier, call, shorthand) · spread: `...x` · computed: `[k]: v`. */\n kind: 'object' | 'expr' | 'spread' | 'computed';\n start: number;\n valueStart: number;\n /** Exclusive end of the value (trailing whitespace excluded). */\n valueEnd: number;\n /** After the trailing comma when there is one, else `valueEnd`. */\n end: number;\n}\n\n/** Top-level properties of the object literal between `open` and `close` (its braces). */\nexport function objectEntries(source: string, masked: string, open: number, close: number): Entry[] {\n const entries: Entry[] = [];\n let i = open + 1;\n const ws = () => {\n while (i < close && /[\\s,]/.test(masked[i]!)) i++;\n };\n // A value runs to the next comma at depth 0 (or the closing brace).\n const valueTo = (from: number): number => {\n let j = from;\n while (j < close) {\n const ch = masked[j]!;\n if (ch === ',') break;\n if (ch === '{' || ch === '(' || ch === '[') {\n const m = matchingClose(masked, j);\n j = m === null ? close : m + 1;\n continue;\n }\n j++;\n }\n return j;\n };\n for (;;) {\n ws();\n if (i >= close) break;\n const start = i;\n let key: string | null = null;\n let kind: Entry['kind'] = 'expr';\n if (masked.startsWith('...', i)) {\n kind = 'spread';\n i += 3;\n } else {\n const ch = masked[i]!;\n if (ch === \"'\" || ch === '\"') {\n const end = masked.indexOf(ch, i + 1);\n key = source.slice(i + 1, end).replace(/\\\\(.)/g, '$1');\n i = end + 1;\n } else if (ch === '[') {\n kind = 'computed';\n const m = matchingClose(masked, i);\n i = m === null ? close : m + 1;\n } else {\n const m = /^[\\w$-]+/.exec(masked.slice(i, close));\n if (!m) break;\n key = m[0];\n i += m[0].length;\n }\n while (i < close && /\\s/.test(masked[i]!)) i++;\n if (masked[i] === ':') i++;\n }\n while (i < close && /\\s/.test(masked[i]!)) i++;\n const valueStart = i;\n const stop = valueTo(i);\n let valueEnd = stop;\n while (valueEnd > valueStart && /\\s/.test(masked[valueEnd - 1]!)) valueEnd--;\n if (kind === 'expr' && masked[valueStart] === '{' && matchingClose(masked, valueStart) === valueEnd - 1) kind = 'object';\n const end = masked[stop] === ',' ? stop + 1 : valueEnd;\n entries.push({ key, kind, start, valueStart, valueEnd, end });\n i = stop;\n }\n return entries;\n}\n\ninterface Located {\n masked: string;\n open: number;\n close: number;\n entries: Entry[];\n}\n\n/** The `experiments: { ... }` object of the config, with its entries. */\nfunction locateExperiments(source: string): Located {\n const masked = maskSource(source);\n let open = -1;\n // Prefer the object passed to defineConfig({ ... }) / export default { ... }.\n const root = /defineConfig\\s*\\(\\s*\\{|export\\s+default\\s+\\{/.exec(masked);\n if (root) {\n const rootOpen = root.index + root[0].length - 1;\n const rootClose = matchingClose(masked, rootOpen);\n if (rootClose !== null) {\n const exp = objectEntries(source, masked, rootOpen, rootClose).find((e) => e.key === 'experiments');\n if (exp && exp.kind !== 'object') {\n fail('CONFIG_UNSAFE', '`experiments` in the config is not written inline, so the CLI cannot edit it safely.', 'Edit the experiments where they are defined, or write them inline as experiments: { ... }.');\n }\n if (exp) open = exp.valueStart;\n }\n }\n if (open < 0) {\n const m = /\\bexperiments\\s*:\\s*\\{/.exec(masked);\n if (!m) fail('CONFIG_UNSAFE', \"Couldn't find `experiments: {` in the config file.\", 'Add experiments: {} to defineConfig({...}) and retry.');\n open = m.index + m[0].length - 1;\n }\n const close = matchingClose(masked, open);\n if (close === null) fail('CONFIG_PARSE', 'The braces after `experiments: {` are not balanced.');\n return { masked, open, close, entries: objectEntries(source, masked, open, close) };\n}\n\nfunction unsafeHint(key: string): string {\n return `Edit \"${key}\" where it is defined (it comes from a spread or an imported constant), then run npx splithub doctor.`;\n}\n\n/** The literal `key: { ... }` entry of an experiment. Throws when it can't be edited safely. */\nfunction experimentEntry(source: string, key: string): Located & { entry: Entry } {\n const loc = locateExperiments(source);\n const entry = loc.entries.find((e) => e.key === key);\n if (!entry) {\n if (loc.entries.some((e) => e.kind === 'spread' || e.kind === 'computed')) {\n fail('CONFIG_UNSAFE', `\"${key}\" isn't written inline in the config (the experiments use a spread), so the CLI can't edit it safely.`, unsafeHint(key));\n }\n fail('EXPERIMENT_NOT_FOUND', `There's no experiment \"${key}\" in the config.`, 'See the ids with npx splithub status.');\n }\n return { ...loc, entry };\n}\n\nexport function hasExperiment(source: string, key: string): boolean {\n try {\n return locateExperiments(source).entries.some((e) => e.key === key);\n } catch {\n return false;\n }\n}\n\n/** Indentation of the line holding `index`. */\nfunction indentAt(source: string, index: number): string {\n const lineStart = source.lastIndexOf('\\n', index - 1) + 1;\n return /^[ \\t]*/.exec(source.slice(lineStart))?.[0] ?? '';\n}\n\n/**\n * Append `render(indent)` as the last property of the object `open..close`,\n * adding the comma the previous property may be missing.\n */\nfunction appendProperty(source: string, masked: string, open: number, close: number, render: (indent: string) => string): string {\n const outerIndent = indentAt(source, open);\n const indent = outerIndent + ' ';\n let last = close - 1;\n while (last > open && /\\s/.test(masked[last]!)) last--;\n const needsComma = last > open && masked[last] !== ',';\n const lineStart = source.lastIndexOf('\\n', close - 1) + 1;\n const closeOnOwnLine = source.slice(lineStart, close).trim() === '';\n const block = `${indent}${render(indent)},\\n`;\n const at = closeOnOwnLine && lineStart > last ? lineStart : close;\n const text = at === close ? `\\n${block}${outerIndent}` : block;\n const comma = needsComma ? ',' : '';\n // Inline object (`{ a: 1 }`): the whitespace before `}` gives way to the new line.\n const head = at === close ? source.slice(0, last + 1) + comma : source.slice(0, last + 1) + comma + source.slice(last + 1, at);\n return head + text + source.slice(at);\n}\n\nexport interface NewExperiment {\n key: string;\n kind: ExperimentKind;\n status: ExperimentStatus;\n variants: Array<{ key: string; weight: number; value?: string; to?: string }>;\n /** Multivariate: factor → level → value; the variants are derived and not written. */\n factors?: Record<string, Record<string, string>>;\n goal?: string;\n match?: string;\n /** Human name shown instead of the key. */\n name?: string;\n description?: string;\n /** Targeting graph from the dashboard, written verbatim as JSON. */\n flow?: unknown;\n traffic?: number;\n maxExposures?: number;\n /** Days before a verdict (0..30); absent means the default of 0 (none). */\n minDays?: number;\n /** Total visitors for a good sample (100..10,000,000); absent means the default of 5000. */\n goodSample?: number;\n schedule?: { startAt?: string | null; endAt?: string | null };\n /** Secondary goals to watch, and guardrails that must not get worse. */\n metrics?: { secondary?: string[]; guardrails?: Array<string | { goal: string; worse: 'lower' | 'higher' }> };\n /** Mutual exclusion layer and its bucket range [start, end). */\n layer?: { key: string; range: [number, number] };\n}\n\n/** Single-quoted string literal. */\nfunction q(s: string): string {\n return `'${s.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\").replace(/\\n/g, '\\\\n')}'`;\n}\n\n/** Object key: bare when it is a valid identifier, quoted otherwise. */\nfunction k(s: string): string {\n return /^[a-z_$][\\w$]*$/i.test(s) ? s : q(s);\n}\n\n/** Render an experiment entry. Every line after the first carries its own indentation. */\nexport function renderExperiment(e: NewExperiment, indent = ' '): string {\n const i2 = indent + ' ';\n const i3 = i2 + ' ';\n const lines: string[] = [`${k(e.key)}: {`];\n lines.push(`${i2}kind: ${q(e.kind)},`);\n lines.push(`${i2}status: ${q(e.status)},`);\n if (e.match) lines.push(`${i2}match: ${q(e.match)},`);\n if (e.kind === 'mvt') {\n lines.push(`${i2}factors: {`);\n for (const [factor, levels] of Object.entries(e.factors ?? {})) {\n lines.push(`${i3}${k(factor)}: { ${Object.entries(levels).map(([l, v]) => `${k(l)}: ${q(v)}`).join(', ')} },`);\n }\n lines.push(`${i2}},`);\n } else if (e.kind === 'component') {\n lines.push(`${i2}variants: { ${e.variants.map((v) => `${k(v.key)}: ${v.weight}`).join(', ')} },`);\n } else {\n lines.push(`${i2}variants: {`);\n for (const v of e.variants) {\n const extra = e.kind === 'value' ? `value: ${q(v.value ?? '')}` : `to: ${q(v.to ?? '/')}`;\n lines.push(`${i3}${k(v.key)}: { weight: ${v.weight}, ${extra} },`);\n }\n lines.push(`${i2}},`);\n }\n if (e.goal) lines.push(`${i2}goal: ${q(e.goal)},`);\n if (e.traffic !== undefined && e.traffic !== 1) lines.push(`${i2}traffic: ${e.traffic},`);\n if (e.maxExposures) lines.push(`${i2}maxExposures: ${e.maxExposures},`);\n if (e.minDays !== undefined) lines.push(`${i2}minDays: ${e.minDays},`);\n if (e.goodSample !== undefined) lines.push(`${i2}goodSample: ${e.goodSample},`);\n if (e.schedule && (e.schedule.startAt || e.schedule.endAt)) lines.push(`${i2}schedule: { ${[e.schedule.startAt ? `startAt: ${q(e.schedule.startAt)}` : null, e.schedule.endAt ? `endAt: ${q(e.schedule.endAt)}` : null].filter(Boolean).join(', ')} },`);\n if (e.metrics && (e.metrics.secondary?.length || e.metrics.guardrails?.length)) {\n const parts: string[] = [];\n if (e.metrics.secondary?.length) parts.push(`secondary: [${e.metrics.secondary.map(q).join(', ')}]`);\n if (e.metrics.guardrails?.length) parts.push(`guardrails: [${e.metrics.guardrails.map((g) => (typeof g === 'string' ? q(g) : `{ goal: ${q(g.goal)}, worse: ${q(g.worse)} }`)).join(', ')}]`);\n lines.push(`${i2}metrics: { ${parts.join(', ')} },`);\n }\n if (e.layer) lines.push(`${i2}layer: { key: ${q(e.layer.key)}, range: [${e.layer.range[0]}, ${e.layer.range[1]}] },`);\n if (e.name) lines.push(`${i2}name: ${q(e.name)},`);\n if (e.description) lines.push(`${i2}description: ${q(e.description)},`);\n if (e.flow) {\n const json = JSON.stringify(e.flow, null, 2).split('\\n');\n lines.push(`${i2}// targeting graph from the dashboard; edit it there or by hand\\n${i2}flow: ${json.map((l, n) => (n === 0 ? l : i2 + l)).join('\\n')},`);\n }\n lines.push(`${indent}}`);\n return lines.join('\\n');\n}\n\n/** Append a new experiment at the end of the `experiments: { ... }` object. */\nexport function insertExperiment(source: string, e: NewExperiment): string {\n const { masked, open, close, entries } = locateExperiments(source);\n if (entries.some((x) => x.key === e.key)) fail('EXPERIMENT_EXISTS', `There's already an experiment \"${e.key}\".`, 'Pick another id: an old id keeps its history.');\n return appendProperty(source, masked, open, close, (indent) => renderExperiment(e, indent));\n}\n\nexport function setExperimentStatus(source: string, key: string, status: ExperimentStatus): string {\n const { masked, entry } = experimentEntry(source, key);\n if (entry.kind !== 'object') fail('CONFIG_UNSAFE', `\"${key}\" points to a value defined elsewhere, so the CLI can't edit it safely.`, unsafeHint(key));\n const inner = objectEntries(source, masked, entry.valueStart, entry.valueEnd - 1);\n const field = inner.filter((x) => x.key === 'status').pop();\n if (field) {\n const raw = masked.slice(field.valueStart, field.valueEnd);\n if (!/^(['\"])\\s*\\1$/.test(raw)) fail('CONFIG_UNSAFE', `The status of \"${key}\" isn't a plain string, so the CLI can't change it safely.`, `Set status: '${status}' by hand.`);\n const quote = raw[0]!;\n return source.slice(0, field.valueStart) + `${quote}${status}${quote}` + source.slice(field.valueEnd);\n }\n // No status written (or only through a spread): append one, so it wins over any spread.\n return appendProperty(source, masked, entry.valueStart, entry.valueEnd - 1, () => `status: ${q(status)}`);\n}\n\n/** Remove an experiment's entry (and its line) from the config source. */\nexport function removeExperiment(source: string, key: string): string {\n return removeEntry(source, experimentEntry(source, key).entry);\n}\n\n/** Remove a property, its whole line when it stands alone. */\nfunction removeEntry(source: string, entry: Entry): string {\n const lineStart = source.lastIndexOf('\\n', entry.start - 1) + 1;\n const from = source.slice(lineStart, entry.start).trim() === '' ? lineStart : entry.start;\n let to = entry.end;\n const lineEnd = source.indexOf('\\n', to);\n const rest = source.slice(to, lineEnd < 0 ? source.length : lineEnd);\n if (rest.trim() === '' && from === lineStart) to = lineEnd < 0 ? source.length : lineEnd + 1;\n return source.slice(0, from) + source.slice(to);\n}\n\n/** The object passed to defineConfig({ ... }) / export default { ... }. */\nfunction locateRoot(source: string): Located {\n const masked = maskSource(source);\n const root = /defineConfig\\s*\\(\\s*\\{|export\\s+default\\s+\\{/.exec(masked);\n if (!root) fail('CONFIG_UNSAFE', \"Couldn't find defineConfig({ ... }) in the config file.\", 'Make the change by hand in splithub.config.ts.');\n const open = root.index + root[0].length - 1;\n const close = matchingClose(masked, open);\n if (close === null) fail('CONFIG_PARSE', 'The braces of defineConfig({ ... }) are not balanced.');\n return { masked, open, close, entries: objectEntries(source, masked, open, close) };\n}\n\n/** Set a top-level config property (`holdout: { ... }`), replacing it when it is there. */\nexport function setTopLevel(source: string, name: string, valueText: string | null): string {\n const { masked, open, close, entries } = locateRoot(source);\n const entry = entries.find((e) => e.key === name);\n if (valueText === null) return entry ? removeEntry(source, entry) : source;\n if (entry) return source.slice(0, entry.valueStart) + valueText + source.slice(entry.valueEnd);\n return appendProperty(source, masked, open, close, () => `${k(name)}: ${valueText}`);\n}\n\n// ---------------------------------------------------------------------------\n// Analytics properties: `properties: { site: { goals: [...] } }` at the top level\n// ---------------------------------------------------------------------------\n\nexport interface NewProperty {\n key: string;\n status?: 'running' | 'paused';\n name?: string;\n description?: string;\n goals?: string[];\n /** Only `app` is written: `site` is the default, so files stay as they were. */\n kind?: 'site' | 'app';\n}\n\nexport function renderProperty(p: NewProperty): string {\n const parts: string[] = [];\n if (p.kind === 'app') parts.push(`kind: 'app'`);\n if (p.status && p.status !== 'running') parts.push(`status: ${q(p.status)}`);\n if (p.name) parts.push(`name: ${q(p.name)}`);\n if (p.goals?.length) parts.push(`goals: [${p.goals.map(q).join(', ')}]`);\n if (p.description) parts.push(`description: ${q(p.description)}`);\n return `${k(p.key)}: { ${parts.join(', ')}${parts.length ? ' ' : ''}}`.replace('{ }', '{}');\n}\n\n/** The `properties: { ... }` object, created empty when the config has none. */\nfunction locateProperties(source: string): { source: string } & Located {\n let src = source;\n let root = locateRoot(src);\n let entry = root.entries.find((e) => e.key === 'properties');\n if (!entry) {\n src = appendProperty(src, root.masked, root.open, root.close, () => 'properties: {}');\n root = locateRoot(src);\n entry = root.entries.find((e) => e.key === 'properties')!;\n }\n if (entry.kind !== 'object') fail('CONFIG_UNSAFE', '`properties` in the config is not written inline, so the CLI cannot edit it safely.', 'Edit the properties where they are defined.');\n return { source: src, masked: root.masked, open: entry.valueStart, close: entry.valueEnd - 1, entries: objectEntries(src, root.masked, entry.valueStart, entry.valueEnd - 1) };\n}\n\nfunction propertyEntry(source: string, key: string): Located & { entry: Entry } {\n const root = locateRoot(source);\n const props = root.entries.find((e) => e.key === 'properties');\n if (!props || props.kind !== 'object') fail('PROPERTY_NOT_FOUND', `There's no analytics property \"${key}\" in the config.`, 'See the ids with npx splithub analytics.');\n const entries = objectEntries(source, root.masked, props.valueStart, props.valueEnd - 1);\n const entry = entries.find((e) => e.key === key);\n if (!entry) fail('PROPERTY_NOT_FOUND', `There's no analytics property \"${key}\" in the config.`, 'See the ids with npx splithub analytics.');\n return { masked: root.masked, open: props.valueStart, close: props.valueEnd - 1, entries, entry };\n}\n\nexport function insertProperty(source: string, p: NewProperty): string {\n const loc = locateProperties(source);\n if (loc.entries.some((x) => x.key === p.key)) fail('PROPERTY_EXISTS', `There's already an analytics property \"${p.key}\".`, 'Pick another id.');\n return appendProperty(loc.source, loc.masked, loc.open, loc.close, () => renderProperty(p));\n}\n\nexport function setPropertyStatus(source: string, key: string, status: 'running' | 'paused'): string {\n const { masked, entry } = propertyEntry(source, key);\n if (entry.kind !== 'object') fail('CONFIG_UNSAFE', `\"${key}\" points to a value defined elsewhere, so the CLI can't edit it safely.`, `Set status: '${status}' by hand.`);\n const inner = objectEntries(source, masked, entry.valueStart, entry.valueEnd - 1);\n const field = inner.filter((x) => x.key === 'status').pop();\n if (field) {\n const raw = masked.slice(field.valueStart, field.valueEnd);\n if (!/^(['\"])\\s*\\1$/.test(raw)) fail('CONFIG_UNSAFE', `The status of \"${key}\" isn't a plain string, so the CLI can't change it safely.`, `Set status: '${status}' by hand.`);\n const quote = raw[0]!;\n return source.slice(0, field.valueStart) + `${quote}${status}${quote}` + source.slice(field.valueEnd);\n }\n return appendProperty(source, masked, entry.valueStart, entry.valueEnd - 1, () => `status: ${q(status)}`);\n}\n\nexport function removeProperty(source: string, key: string): string {\n return removeEntry(source, propertyEntry(source, key).entry);\n}\n\n/** Make sure `layers: { <key>: {} }` declares a layer. */\nexport function ensureLayer(source: string, key: string): string {\n const { masked, open, close, entries } = locateRoot(source);\n const layers = entries.find((e) => e.key === 'layers');\n if (!layers) return appendProperty(source, masked, open, close, () => `layers: { ${k(key)}: {} }`);\n if (layers.kind !== 'object') fail('CONFIG_UNSAFE', '`layers` in the config is not written inline.', `Add ${key}: {} to layers by hand.`);\n if (objectEntries(source, masked, layers.valueStart, layers.valueEnd - 1).some((e) => e.key === key)) return source;\n return appendProperty(source, masked, layers.valueStart, layers.valueEnd - 1, () => `${k(key)}: {}`);\n}\n\nexport function readSource(file: string): string {\n return readFileSync(file, 'utf8');\n}\n\nexport function writeSource(file: string, source: string): void {\n writeFileSync(file, source, 'utf8');\n}\n\n/**\n * Write the config, load it back and check the change landed. On any problem the\n * original file is restored and CONFIG_WRITE is thrown: the CLI never leaves a broken config.\n */\nexport async function writeConfigChecked(file: string, original: string, updated: string, verify: (config: SplitHubConfig) => string | null): Promise<SplitHubConfig> {\n writeSource(file, updated);\n let problem: string | null = null;\n let config: SplitHubConfig | null = null;\n try {\n config = await loadConfig(file);\n problem = verify(config);\n } catch (error) {\n problem = error instanceof CliError || error instanceof Error ? error.message : String(error);\n }\n if (problem || !config) {\n writeSource(file, original);\n fail('CONFIG_WRITE', `Couldn't update ${basename(file)}: ${problem ?? 'it did not load'}. The file is back as it was.`, 'Make the change by hand in the config, then run npx splithub doctor.');\n }\n return config;\n}\n"],"mappings":";;;;;;;AAAA,SAAS,wBAAyF;AAClG,SAAS,cAAc,qBAAqB;AAC5C,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAI9B,eAAsB,WAAW,MAAuC;AACtE,MAAI;AACJ,MAAI;AACF,UAAM,EAAE,WAAW,IAAI,MAAM,OAAO,MAAM;AAC1C,UAAM,OAAO,WAAW,cAAc,IAAI,EAAE,MAAM,EAAE,SAAS,OAAO,aAAa,MAAM,CAAC;AACxF,UAAM,MAAM,KAAK,OAAO,MAAM,EAAE,SAAS,KAAK,CAAC;AAAA,EACjD,SAAS,OAAO;AACd,SAAK,gBAAgB,GAAG,SAAS,IAAI,CAAC,kBAAkB,iBAAiB,QAAQ,MAAM,QAAQ,MAAM,IAAI,EAAE,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,0DAA0D;AAAA,EAC7L;AACA,MAAI,CAAC,iBAAiB,GAAG,GAAG;AAC1B,SAAK,gBAAgB,GAAG,SAAS,IAAI,CAAC,mEAAmE;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MAAM;AACpC;AAMA,eAAsB,mBAAmB,MAAc,UAAkB,SAAiB,QAA4E;AACpK,cAAY,MAAM,OAAO;AACzB,MAAI,UAAyB;AAC7B,MAAI,SAAgC;AACpC,MAAI;AACF,aAAS,MAAM,WAAW,IAAI;AAC9B,cAAU,OAAO,MAAM;AAAA,EACzB,SAAS,OAAO;AACd,cAAU,iBAAiB,YAAY,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,EAC9F;AACA,MAAI,WAAW,CAAC,QAAQ;AACtB,gBAAY,MAAM,QAAQ;AAC1B,SAAK,gBAAgB,mBAAmB,SAAS,IAAI,CAAC,KAAK,WAAW,iBAAiB,iCAAiC,sEAAsE;AAAA,EAChM;AACA,SAAO;AACT;","names":["end"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/push.ts"],"sourcesContent":["import type { SplitHubConfig } from '@splithub/core';\nimport { relative } from 'node:path';\nimport { apiError, cloudTarget, requireCloudToken } from '../api';\nimport { hasExperiment, insertExperiment, loadConfig, readSource, writeConfigChecked } from '../config-file';\nimport { fail, printJson } from '../errors';\nimport { detectProject, requireConfig } from '../project';\nimport { c } from '../ui';\nimport type { Flags } from './init';\n\nexport interface CloudExperiment {\n key: string;\n kind: 'component' | 'value' | 'redirect' | 'mvt';\n status: 'draft' | 'running' | 'paused' | 'finished';\n goal: string | null;\n match: string | null;\n name?: string;\n description: string | null;\n variants: Array<{ key: string; weight: number; value?: unknown; to?: string; levels?: Record<string, string> }>;\n /** Multivariate: the factors whose combinations the variants are. */\n factors?: Array<{ key: string; levels: string[] }>;\n flow?: unknown;\n traffic?: number;\n maxExposures?: number | null;\n minDays?: number | null;\n goodSample?: number | null;\n schedule?: { startAt?: string | null; endAt?: string | null } | null;\n}\n\ninterface PushResponse {\n ok: boolean;\n project: string;\n version: number;\n pushedAt: string;\n publicKey: string;\n experiments: number;\n /** Experiments created in the dashboard that the local file does not have yet. */\n cloudOnly?: CloudExperiment[];\n /** Experiments from an earlier push that the file lacks, left in the cloud as they are; `--prune` removes them. */\n kept?: string[];\n}\n\n/** Write dashboard-created experiments into the local config file. Returns the keys written. */\n/** Factor → level → value, read back from the combinations the cloud generated. */\nfunction factorsOf(e: CloudExperiment): Record<string, Record<string, string>> {\n const out: Record<string, Record<string, string>> = {};\n for (const f of e.factors ?? []) {\n out[f.key] = {};\n for (const level of f.levels) {\n const combo = e.variants.find((v) => v.levels?.[f.key] === level);\n const value = (combo?.value as Record<string, unknown> | undefined)?.[f.key];\n out[f.key]![level] = typeof value === 'string' ? value : value === undefined ? level : JSON.stringify(value);\n }\n }\n return out;\n}\n\nasync function adoptCloudExperiments(file: string, cloudOnly: CloudExperiment[] | undefined): Promise<string[]> {\n if (!cloudOnly || cloudOnly.length === 0) return [];\n const original = readSource(file);\n let source = original;\n const written: string[] = [];\n for (const e of cloudOnly) {\n if (hasExperiment(source, e.key)) continue;\n const total = e.variants.reduce((s, v) => s + v.weight, 0) || 1;\n source = insertExperiment(source, {\n key: e.key,\n kind: e.kind,\n status: e.status,\n goal: e.goal ?? undefined,\n match: e.match ?? undefined,\n name: e.name,\n description: e.description ?? undefined,\n flow: e.flow ?? undefined,\n traffic: e.traffic,\n maxExposures: e.maxExposures ?? undefined,\n minDays: e.minDays ?? undefined,\n goodSample: e.goodSample ?? undefined,\n schedule: e.schedule ?? undefined,\n variants: e.variants.map((v) => ({ key: v.key, weight: Math.round((v.weight / total) * 100), value: typeof v.value === 'string' ? v.value : v.value === undefined ? undefined : JSON.stringify(v.value), to: v.to })),\n ...(e.kind === 'mvt' && e.factors ? { factors: factorsOf(e) } : {}),\n });\n written.push(e.key);\n }\n if (written.length) {\n await writeConfigChecked(file, original, source, (config) => {\n const missing = written.filter((k) => !config.experiments.some((x) => x.key === k));\n return missing.length ? `${missing.join(', ')} did not load back` : null;\n });\n }\n return written;\n}\n\ntype LocalExperiment = SplitHubConfig['experiments'][number];\n\nexport interface ConfigDiff {\n added: string[];\n removed: string[];\n /** In the cloud only; a push without `--prune` leaves them. */\n kept: string[];\n changed: Array<{ experiment: string; fields: string[] }>;\n}\n\n/** What a push would change in the cloud, by experiment key. */\nexport function configDiff(local: LocalExperiment[], cloud: Array<CloudExperiment & { origin?: string }>, prune = false): ConfigDiff {\n const added = local.filter((e) => !cloud.some((x) => x.key === e.key)).map((e) => e.key);\n const missing = cloud.filter((x) => x.origin !== 'dashboard' && !local.some((e) => e.key === x.key)).map((x) => x.key);\n const removed = prune ? missing : [];\n const kept = prune ? [] : missing;\n const changed: ConfigDiff['changed'] = [];\n for (const e of local) {\n const x = cloud.find((y) => y.key === e.key);\n if (!x) continue;\n const fields: string[] = [];\n if (x.status !== e.status) fields.push('status');\n if ((x.goal ?? null) !== (e.goal ?? null)) fields.push('goal');\n if (x.kind !== e.kind) fields.push('kind');\n if (x.variants.map((v) => `${v.key}:${v.weight}`).join() !== e.variants.map((v) => `${v.key}:${v.weight}`).join()) fields.push('variants');\n if ((x.traffic ?? 1) !== (e.traffic ?? 1)) fields.push('traffic');\n if (fields.length) changed.push({ experiment: e.key, fields });\n }\n return { added, removed, kept, changed };\n}\n\ninterface KeyConflict {\n key: string;\n reason: 'dashboard' | 'old_data';\n exposures?: number;\n}\n\nconst keyList = (v: Flags[string]): string[] => (typeof v === 'string' ? v.split(',').map((k) => k.trim()).filter(Boolean) : []);\n\n/** The cloud already has another test under a pushed key: say which, and the two ways on. */\nfunction keyConflict(conflicts: KeyConflict[]): never {\n const why = conflicts.map((k) => (k.reason === 'dashboard' ? `${k.key} (a different experiment made in the dashboard)` : `${k.key} (an earlier experiment, ${(k.exposures ?? 0).toLocaleString('en-US')} visitors)`));\n const keys = conflicts.map((k) => k.key).join(',');\n fail(\n 'KEY_CONFLICT',\n `These keys already belong to another experiment in the cloud: ${why.join('; ')}. Nothing was pushed.`,\n `New experiment: rename its key, or run npx splithub push --replace ${keys} (the old numbers are cleared). Same experiment: npx splithub push --same ${keys}.`\n );\n}\n\nasync function cloudFetch(url: string, init: RequestInit): Promise<Response> {\n try {\n return await fetch(url, init);\n } catch (error) {\n fail('UNREACHABLE', `Can't reach ${url}: ${error instanceof Error ? error.message : String(error)}.`, 'Check your connection, or --api / SPLITHUB_API.');\n }\n}\n\n/**\n * `splithub push`: upload the normalized splithub.config.ts to SplitHub Cloud.\n * Needs a project API key (sk_...) via --token or SPLITHUB_API_KEY. The first\n * push returns the public key (pk_...) which is written into the config's\n * `storage.key` when it is still empty. `--dry-run` only checks and compares.\n * Experiments the cloud has from an earlier push that the file lacks are kept\n * unless `--prune`.\n */\nexport async function push(flags: Flags): Promise<void> {\n const project = requireConfig();\n const config = await loadConfig(project.configFile);\n if (flags['dry-run']) return dryRun(flags, config);\n if (config.storage.mode !== 'cloud') {\n fail('NOT_CLOUD', `This project stores events itself (storage.mode is \"${config.storage.mode}\"), so there's nothing to push.`, \"Set storage: { mode: 'cloud' } in splithub.config.ts to use SplitHub Cloud.\");\n }\n const target = requireCloudToken(flags);\n\n const res = await cloudFetch(`${target.url}/config`, {\n method: 'PUT',\n headers: { authorization: `Bearer ${target.token}`, 'content-type': 'application/json' },\n body: JSON.stringify({ config, replace: keyList(flags.replace), same: keyList(flags.same), prune: Boolean(flags.prune) }),\n });\n const body = (await res.json().catch(() => ({}))) as Partial<PushResponse> & { error?: string; code?: string; conflicts?: KeyConflict[] };\n if (res.status === 409 && body.code === 'key_conflict' && body.conflicts?.length) keyConflict(body.conflicts);\n if (res.status === 409 && body.code === 'key_deleted') fail('KEY_DELETED', `${body.error ?? 'A deleted experiment used one of these keys'}. Nothing was pushed.`, 'Give the experiment a new key in splithub.config.ts and push again.');\n if (!res.ok) throw apiError(res.status, body, `${target.url}/config responded ${res.status}`);\n\n // Write the public key into the config when it is missing.\n let keyWritten = false;\n if (body.publicKey && !config.storage.key) {\n const source = readSource(project.configFile);\n const updated = source.replace(/(mode\\s*:\\s*['\"]cloud['\"]\\s*)(,?)(\\s*\\})/, (_m, a: string, _comma: string, b: string) => `${a}, key: '${body.publicKey}'${b}`);\n if (updated !== source) {\n await writeConfigChecked(project.configFile, source, updated, (loaded) => (loaded.storage.mode === 'cloud' && loaded.storage.key === body.publicKey ? null : 'storage.key did not load back'));\n keyWritten = true;\n }\n }\n\n const adopted = await adoptCloudExperiments(project.configFile, body.cloudOnly);\n const out = { ...body, configFile: relative(project.root, project.configFile), keyWritten, adopted };\n if (flags.json) {\n printJson(out);\n return;\n }\n console.log(`${c.green('✔')} pushed ${c.bold(String(body.project))} v${body.version} · ${body.experiments} experiment(s) → ${target.url}`);\n if (body.kept?.length) console.log(c.yellow(`! kept in the cloud, not in ${out.configFile}: ${body.kept.join(', ')}. They go on as they are; npx splithub push --prune removes them.`));\n if (adopted.length) console.log(`${c.green('✔')} written into ${out.configFile} from the dashboard: ${adopted.join(', ')} (wire them in code if they are value/component experiments)`);\n if (body.publicKey) {\n console.log(keyWritten ? `${c.green('✔')} public key written to ${out.configFile}` : `${c.dim('public key:')} ${body.publicKey}`);\n if (!keyWritten && !config.storage.key) console.log(c.yellow(`Add it to splithub.config.ts: storage: { mode: 'cloud', key: '${body.publicKey}' }`));\n }\n}\n\n/** `push --dry-run`: the config loads; when connected, what a push would change. Writes nothing. */\nasync function dryRun(flags: Flags, config: SplitHubConfig): Promise<void> {\n const experiments = config.experiments.map((e) => ({ experiment: e.key, kind: e.kind, status: e.status, goal: e.goal ?? null }));\n let diff: ConfigDiff | null = null;\n let cloud: 'compared' | 'not connected' | 'self mode' = config.storage.mode === 'cloud' ? 'not connected' : 'self mode';\n if (config.storage.mode === 'cloud') {\n const target = cloudTarget(flags);\n if (target.token) {\n const res = await cloudFetch(`${target.url}/config`, { headers: { authorization: `Bearer ${target.token}` } });\n const body = (await res.json().catch(() => ({}))) as { config?: { experiments?: CloudExperiment[] } };\n const prune = Boolean(flags.prune);\n if (res.status === 404 || res.status === 409) diff = configDiff(config.experiments, [], prune);\n else if (!res.ok) throw apiError(res.status, body, `${target.url}/config responded ${res.status}`);\n else diff = configDiff(config.experiments, body.config?.experiments ?? [], prune);\n cloud = 'compared';\n }\n }\n const out = { ok: true, dryRun: true, mode: config.storage.mode, project: config.project, experiments, cloud, diff };\n if (flags.json) {\n printJson(out);\n return;\n }\n console.log(`${c.green('✔')} config loads · ${experiments.length} experiment(s) · ${config.storage.mode} mode`);\n if (!diff) console.log(c.dim(cloud === 'self mode' ? 'Self mode: nothing to push.' : 'Not connected, so nothing to compare. Run npx splithub login.'));\n else if (!diff.added.length && !diff.removed.length && !diff.kept.length && !diff.changed.length) console.log(c.dim('The cloud already has this config.'));\n else {\n for (const k of diff.added) console.log(`${c.green('+')} ${k}`);\n for (const k of diff.removed) console.log(`${c.red('-')} ${k}`);\n for (const ch of diff.changed) console.log(`${c.yellow('~')} ${ch.experiment} ${c.dim(`(${ch.fields.join(', ')})`)}`);\n for (const k of diff.kept) console.log(c.dim(`= ${k} (in the cloud only: kept; --prune removes it)`));\n }\n}\n\n/** `splithub pull`: print the config stored in the cloud (for inspection or recovery). */\nexport async function pull(flags: Flags): Promise<void> {\n const target = requireCloudToken(flags);\n const res = await cloudFetch(`${target.url}/config`, { headers: { authorization: `Bearer ${target.token}` } });\n const body = (await res.json().catch(() => ({}))) as { error?: string; config?: { experiments?: Array<CloudExperiment & { origin?: string }> }; version?: number; pushedAt?: string; publicKey?: string };\n if (!res.ok) throw apiError(res.status, body, `${target.url}/config responded ${res.status}`);\n const project = detectProject();\n const dashboardOnes = (body.config?.experiments ?? []).filter((e) => e.origin === 'dashboard');\n const adopted = project.configFile ? await adoptCloudExperiments(project.configFile, dashboardOnes) : [];\n if (flags.json) {\n printJson({ ...body, adopted });\n return;\n }\n console.log(`${c.bold('cloud config')} v${body.version} ${c.dim(`pushed ${body.pushedAt}`)} · public key ${body.publicKey}`);\n if (adopted.length) console.log(`${c.green('✔')} written into ${relative(project.root, project.configFile ?? '')}: ${adopted.join(', ')}`);\n else if (dashboardOnes.length) console.log(c.dim(`dashboard experiments already present locally: ${dashboardOnes.map((e) => e.key).join(', ')}`));\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G,EAAE,KAAK,cAAc,CAAC,KAAK,KAAK,OAAO,IAAI,EAAE,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC,oBAAiB,KAAK,SAAS,EAAE;AAC3H,MAAI,QAAQ,OAAQ,SAAQ,IAAI,GAAG,EAAE,MAAM,QAAG,CAAC,iBAAiB,SAAS,QAAQ,MAAM,QAAQ,cAAc,EAAE,CAAC,KAAK,QAAQ,KAAK,IAAI,CAAC,EAAE;AAAA,WAChI,cAAc,OAAQ,SAAQ,IAAI,EAAE,IAAI,kDAAkD,cAAc,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;AAAA,MAC3I,SAAQ,IAAI,EAAE,IAAI,0CAA0C,CAAC;AACpE;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|