infra-kit 0.1.134 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{boot-YCABHUPP.js → boot-MTVHM4N7.js} +2 -2
- package/dist/{chunk-TFHVQOVF.js → chunk-4MRYIYJP.js} +2 -2
- package/dist/chunk-E2NWNNC6.js +2 -0
- package/dist/chunk-E2NWNNC6.js.map +7 -0
- package/dist/{chunk-3OMHS5RE.js → chunk-E2SEBLGJ.js} +2 -2
- package/dist/chunk-KZP2SY37.js +4 -0
- package/dist/chunk-KZP2SY37.js.map +7 -0
- package/dist/{chunk-27PDA2PN.js → chunk-NC2TIQ3M.js} +2 -2
- package/dist/chunk-RLZ5IB2E.js +238 -0
- package/dist/chunk-RLZ5IB2E.js.map +7 -0
- package/dist/chunk-TI33V5G2.js +6 -0
- package/dist/chunk-TI33V5G2.js.map +7 -0
- package/dist/{chunk-FAR2L74S.js → chunk-TPVXMJ7N.js} +1 -1
- package/dist/cli.js +10 -8
- package/dist/cli.js.map +4 -4
- package/dist/dev-server.js +23 -20
- package/dist/dev-server.js.map +4 -4
- package/dist/dev-wizard-run-5HQOGE3R.js +2 -0
- package/dist/dev-wizard-run-5HQOGE3R.js.map +7 -0
- package/dist/mcp.js +1 -1
- package/dist/mcp.js.map +3 -3
- package/dist/persistent-ink-dev-ui-KOI44ZVT.js +2 -0
- package/dist/persistent-ink-dev-ui-KOI44ZVT.js.map +7 -0
- package/dist/safe-stderr-HXDR2DNJ.js +2 -0
- package/dist/update-check.js +1 -1
- package/package.json +3 -14
- package/dist/chunk-2YHPK2VY.js +0 -221
- package/dist/chunk-2YHPK2VY.js.map +0 -7
- package/dist/chunk-3F7XYJWY.js +0 -3
- package/dist/chunk-3F7XYJWY.js.map +0 -7
- package/dist/chunk-DOG3OPNW.js +0 -2
- package/dist/chunk-DOG3OPNW.js.map +0 -7
- package/dist/chunk-JD5T4VCB.js +0 -6
- package/dist/chunk-JD5T4VCB.js.map +0 -7
- package/dist/chunk-LTKR3F4N.js +0 -2
- package/dist/chunk-LTKR3F4N.js.map +0 -7
- package/dist/chunk-TUVUKM4K.js +0 -2
- package/dist/chunk-TUVUKM4K.js.map +0 -7
- package/dist/chunk-Z6KTUVIC.js +0 -2
- package/dist/chunk-Z6KTUVIC.js.map +0 -7
- package/dist/dev-wizard-run-HGQO6FZV.js +0 -2
- package/dist/dev-wizard-run-HGQO6FZV.js.map +0 -7
- package/dist/entry/index.d.ts +0 -4
- package/dist/entry/vite.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/lib/package-config/package-config-schema.d.ts +0 -35
- package/dist/lib/package-config/package-config.d.ts +0 -99
- package/dist/lib/release-slug/release-slug.d.ts +0 -43
- package/dist/lib/vendor/config-schema.d.ts +0 -58
- package/dist/lib/vite/vite.d.ts +0 -168
- package/dist/persistent-ink-dev-ui-FUJQDFNY.js +0 -8
- package/dist/persistent-ink-dev-ui-FUJQDFNY.js.map +0 -7
- package/dist/vite.js +0 -2
- package/dist/vite.js.map +0 -7
- /package/dist/{boot-YCABHUPP.js.map → boot-MTVHM4N7.js.map} +0 -0
- /package/dist/{chunk-TFHVQOVF.js.map → chunk-4MRYIYJP.js.map} +0 -0
- /package/dist/{chunk-3OMHS5RE.js.map → chunk-E2SEBLGJ.js.map} +0 -0
- /package/dist/{chunk-27PDA2PN.js.map → chunk-NC2TIQ3M.js.map} +0 -0
- /package/dist/{chunk-FAR2L74S.js.map → chunk-TPVXMJ7N.js.map} +0 -0
- /package/dist/{index.js.map → safe-stderr-HXDR2DNJ.js.map} +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/lib/package-config/package-config.ts", "../src/lib/vendor/config-schema.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Validation rules for a single workspace package, declared in its\n * `infra-kit.config.js`. Every field is optional: a key left unset falls back to\n * the active baseline ({@link DEFAULT_RULES} for packages, {@link ROOT_DEFAULT_RULES}\n * for the monorepo root), and a key set replaces that default wholesale (per-key,\n * no array concatenation) so a package can opt out with an explicit empty array.\n *\n * Most packages need none of these \u2014 the standard rules live in the baseline, so\n * a typical config is just `defineConfig(() => ({}))`.\n *\n * @example\n * // infra-kit.config.js\n * import { defineConfig } from 'infra-kit'\n *\n * export default defineConfig(() => ({}))\n */\nexport interface InfraKitPackageConfig {\n /** Scripts that must be present in the package's package.json `scripts` map. */\n requiredScripts?: string[]\n /** Files (relative to the package root) that must exist on disk. */\n requiredFiles?: string[]\n /** Turborepo expectations \u2014 only meaningful where a turbo.json lives (the root). */\n turbo?: {\n /** Tasks that must be defined in turbo.json `tasks`. */\n requiredTasks?: string[]\n }\n /** Local-dev configuration. Accepted-and-inert to the audit; consumed by the dev server. */\n dev?: InfraKitDev\n}\n\n/** A proxy route's allowed backend source. */\nexport type InfraKitDevProxySource = 'local' | 'cloud'\n\nexport interface InfraKitDevProxyRoute {\n /** Backend package this route targets when resolved locally. */\n packageName: string\n /** Capabilities this route can resolve to. Must be non-empty. */\n from: InfraKitDevProxySource[]\n /**\n * Source used when a local backend for this package isn't active. Required when\n * `from` lists more than one source; redundant (and omitted) for a single-source\n * route. When set, must be one of `from`.\n */\n default?: InfraKitDevProxySource\n}\n\nexport interface InfraKitDevProxy {\n /** URL templates. Placeholders like `<release>`/`<packageName>`/`<env>` are substituted at dev time. */\n templates: {\n local: string\n cloud: string\n }\n /** Path-prefix (e.g. `/api`, `/api/v1`, `/media`) \u2192 route definition. */\n routes: Record<string, InfraKitDevProxyRoute>\n}\n\nexport interface InfraKitDev {\n proxy?: InfraKitDevProxy\n}\n\n/**\n * Accepted shapes for a package config's default export \u2014 mirrors Vite's\n * `defineConfig` input: a plain object, a sync factory, or an async factory.\n */\nexport type InfraKitPackageConfigInput =\n InfraKitPackageConfig | (() => InfraKitPackageConfig) | (() => Promise<InfraKitPackageConfig>)\n\n/**\n * Identity helper that gives `infra-kit.config.js` authors full type inference\n * and editor autocomplete without changing the value \u2014 exactly like Vite's\n * `defineConfig`. Resolution of the factory form happens in the loader, not here.\n *\n * @example\n * export default defineConfig(() => ({}))\n *\n * @example\n * export default defineConfig(() => ({ requiredScripts: [] }))\n */\nexport const defineConfig = (config: InfraKitPackageConfigInput): InfraKitPackageConfigInput => {\n return config\n}\n\n/** Fully-resolved rules with every defaultable field present. */\nexport interface ResolvedPackageRules {\n requiredScripts: string[]\n requiredFiles: string[]\n turboTasks: string[]\n}\n\n/**\n * Baseline rules for a standard TypeScript workspace package, applied to any key\n * a package leaves unset. These are the \"under the hood\" defaults so a conforming\n * package's config can stay empty; non-standard packages override the relevant key.\n */\nexport const DEFAULT_RULES: Readonly<ResolvedPackageRules> = {\n requiredScripts: ['build', 'ts-check', 'eslint-check', 'prettier-check', 'test'],\n requiredFiles: ['tsconfig.json', 'eslint.config.js', 'readme.md'],\n turboTasks: [],\n}\n\n/**\n * Baseline rules for the monorepo root (`infra-kit audit --root`). Checks the\n * root commands, the workspace/turbo files, and that the turbo pipeline defines\n * the expected tasks \u2014 so the root's own config can also stay empty.\n */\nexport const ROOT_DEFAULT_RULES: Readonly<ResolvedPackageRules> = {\n requiredScripts: ['build', 'dev', 'test', 'qa', 'infra-kit-check', 'fix'],\n requiredFiles: ['turbo.json', 'pnpm-workspace.yaml'],\n turboTasks: ['build', 'test', 'ts-check', 'eslint-check', 'prettier-check', 'infra-kit-check'],\n}\n\n/**\n * Merge a parsed package config over a baseline. Each key is replaced wholesale\n * when the package provides it, otherwise the baseline value is used.\n *\n * @example\n * resolvePackageConfig({ requiredScripts: [] })\n * // => { requiredScripts: [], requiredFiles: [...DEFAULT_RULES.requiredFiles], turboTasks: [] }\n */\nexport const resolvePackageConfig = (\n config: InfraKitPackageConfig,\n baseline: Readonly<ResolvedPackageRules> = DEFAULT_RULES,\n): ResolvedPackageRules => {\n return {\n requiredScripts: config.requiredScripts ?? [...baseline.requiredScripts],\n requiredFiles: config.requiredFiles ?? [...baseline.requiredFiles],\n turboTasks: config.turbo?.requiredTasks ?? [...baseline.turboTasks],\n }\n}\n", "import { z } from 'zod'\n\n/**\n * Pure (node-free) vendor config schema + authoring helper. Kept separate from\n * `config.ts` (which imports node builtins for the runtime loader) so the public\n * lib entry can re-export `defineVendorConfig` without dragging node types into\n * the emitted `.d.ts`.\n */\n\n/**\n * Filename a source repo provides at its root to declare WHAT `vendor sync`\n * copies (`copy[]`). Lives ONLY on the write path \u2014 `vendor check` never loads it.\n * WHERE/WHICH to stamp (`workspaceDir` + `targets`) is machine-local and lives in\n * the user-global factory config (`~/.infra-kit/vendor.json`).\n */\nexport const VENDOR_CONFIG_FILE = 'vendor.config.ts'\n\n/**\n * A non-empty, repo-relative path with no `..` segments and no absolute prefix\n * (POSIX `/`, UNC/`\\`, or a Windows drive like `C:`). Containment guard for\n * vendor copy items so a malicious/typo config can't read or write outside the\n * source/target repo roots. Kept as a string/regex check (no `node:path`) to\n * respect this file's node-free constraint \u2014 `sync-ops.ts` does the resolved\n * runtime containment assert as defense in depth.\n */\nconst safeRelPath = z.string().refine(\n (p) => {\n const isAbsolute = /^(?:[/\\\\]|[a-z]:)/i.test(p)\n const hasDotDotSegment = p.split(/[\\\\/]/).includes('..')\n\n return !isAbsolute && !hasDotDotSegment && p.trim().length > 0\n },\n { message: 'must be a non-empty repo-relative path without \"..\" segments' },\n)\n\n/**\n * One item to sync from the source repo into each target. `vendored: true` marks\n * workspace packages that must land under `vendor/` (the single-source-of-truth\n * code); everything else is root-level tooling that stays at the repo root.\n */\nexport const vendorCopyItemSchema = z.object({\n name: z.string(),\n source: safeRelPath,\n target: safeRelPath,\n type: z.enum(['file', 'directory']),\n vendored: z.boolean().optional(),\n})\n\nexport const vendorConfigSchema = z\n .object({\n /** Files/dirs to copy. Items with `vendored: true` land under `vendor/`. */\n copy: z.array(vendorCopyItemSchema),\n })\n // Reject stray keys so a leftover `targets` (now machine-local, in\n // ~/.infra-kit/vendor.json) yields a clear \"unrecognized key\" error rather\n // than being silently ignored.\n .strict()\n\nexport type VendorCopyItem = z.infer<typeof vendorCopyItemSchema>\nexport type VendorConfig = z.infer<typeof vendorConfigSchema>\n\n/**\n * Identity helper for authoring a type-safe `vendor.config.ts` in a source repo.\n * Re-exported from the public lib entry so a source repo can\n * `import { defineVendorConfig } from 'infra-kit'`.\n *\n * NOTE: a `vendor.config.ts` must be type-strippable \u2014 Node's native type\n * stripping (Node >= 24) loads it without a build step, which forbids `enum`,\n * `namespace`, and parameter properties.\n *\n * @example\n * export default defineVendorConfig({\n * copy: [{ name: 'Configs', source: 'vendor/configs', target: 'vendor/configs', type: 'directory', vendored: true }],\n * })\n */\nexport const defineVendorConfig = (config: VendorConfig): VendorConfig => {\n return config\n}\n"],
|
|
5
|
-
"mappings": "AA8EO,IAAMA,EAAgBC,GACpBA,EAeIC,EAAgD,CAC3D,gBAAiB,CAAC,QAAS,WAAY,eAAgB,iBAAkB,MAAM,EAC/E,cAAe,CAAC,gBAAiB,mBAAoB,WAAW,EAChE,WAAY,CAAC,CACf,EAOaC,EAAqD,CAChE,gBAAiB,CAAC,QAAS,MAAO,OAAQ,KAAM,kBAAmB,KAAK,EACxE,cAAe,CAAC,aAAc,qBAAqB,EACnD,WAAY,CAAC,QAAS,OAAQ,WAAY,eAAgB,iBAAkB,iBAAiB,CAC/F,EAUaC,EAAuB,CAClCH,EACAI,EAA2CH,KAEpC,CACL,gBAAiBD,EAAO,iBAAmB,CAAC,GAAGI,EAAS,eAAe,EACvE,cAAeJ,EAAO,eAAiB,CAAC,GAAGI,EAAS,aAAa,EACjE,WAAYJ,EAAO,OAAO,eAAiB,CAAC,GAAGI,EAAS,UAAU,CACpE,GC/HF,OAAS,KAAAC,MAAS,MAeX,IAAMC,EAAqB,mBAU5BC,EAAcF,EAAE,OAAO,EAAE,OAC5BG,GAAM,CACL,IAAMC,EAAa,qBAAqB,KAAKD,CAAC,EACxCE,EAAmBF,EAAE,MAAM,OAAO,EAAE,SAAS,IAAI,EAEvD,MAAO,CAACC,GAAc,CAACC,GAAoBF,EAAE,KAAK,EAAE,OAAS,CAC/D,EACA,CAAE,QAAS,8DAA+D,CAC5E,EAOaG,EAAuBN,EAAE,OAAO,CAC3C,KAAMA,EAAE,OAAO,EACf,OAAQE,EACR,OAAQA,EACR,KAAMF,EAAE,KAAK,CAAC,OAAQ,WAAW,CAAC,EAClC,SAAUA,EAAE,QAAQ,EAAE,SAAS,CACjC,CAAC,EAEYO,EAAqBP,EAC/B,OAAO,CAEN,KAAMA,EAAE,MAAMM,CAAoB,CACpC,CAAC,EAIA,OAAO,EAmBGE,EAAsBC,GAC1BA",
|
|
6
|
-
"names": ["defineConfig", "config", "DEFAULT_RULES", "ROOT_DEFAULT_RULES", "resolvePackageConfig", "baseline", "z", "VENDOR_CONFIG_FILE", "safeRelPath", "p", "isAbsolute", "hasDotDotSegment", "vendorCopyItemSchema", "vendorConfigSchema", "defineVendorConfig", "config"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-TFHVQOVF.js";import{I as k,Q as w,v as d,w as v,x,y}from"./chunk-3F7XYJWY.js";import{e as W}from"./chunk-CHETBZ6M.js";import{c as b}from"./chunk-TUVUKM4K.js";import"./chunk-LTKR3F4N.js";import R from"@inquirer/checkbox";import N from"@inquirer/confirm";import $,{Separator as O}from"@inquirer/select";import B from"node:path";import h from"node:process";var f=e=>e.split("/")[0],z=e=>new Map(e.apps.map(r=>[r.name,r])),S=(e,r)=>{let a={},s=!1;for(let t of e.backends){let n=t.localCapable&&t.ownerApp!=null&&r.has(t.ownerApp);n||(s=!0);for(let o of t.routes)a[o]=n?"local":"cloud"}return{overrides:a,anyCloud:s}},M=(e,r)=>{let a=z(r),s=e.targets.filter(c=>c.endsWith("/ui")),t=new Set(e.targets.filter(c=>c.endsWith("/api")).map(f)),n={},o=!1;for(let c of s){let u=a.get(f(c)),{overrides:p,anyCloud:i}=u?S(u,t):{overrides:{},anyCloud:!1};i&&(o=!0),n[c]=Object.keys(p).length>0?{proxy:p}:{}}for(let c of t)n[`${c}/api`]??={};return{presetDef:{apps:n,cmux:e.cmux},anyCloudRoute:o,targetKeys:Object.keys(n).sort()}},C=(e,r,a)=>{let s=z(a),t=[...new Set(e.targetKeys.map(f))].sort(),n=new Set(e.targetKeys),o=t.every(u=>{let p=s.get(u);if(!p)return!1;let i=!p.hasUi||n.has(`${u}/ui`),m=!p.hasApi||n.has(`${u}/api`);return i&&m}),c=[`--app=${t.join(",")}`];return r.watch&&c.push("--watch"),r.cmux&&c.push("--cmux"),{flags:c.join(" "),exact:o}};var g={output:h.stderr,clearPromptOnDone:!0},j={select:e=>$({message:e.message,choices:e.choices,default:e.default},g),checkbox:e=>R({message:e.message,choices:e.choices},g),confirm:e=>N({message:e.message,default:e.default},g)},q=(e,r)=>{let a=new Map;for(let[s,t]of Object.entries(e)){let n=a.get(t.packageName),o=t.from.includes("local");n?(n.routes.push(s),n.localCapable=n.localCapable||o):a.set(t.packageName,{packageName:t.packageName,routes:[s],localCapable:o,ownerApp:r.get(t.packageName)})}return[...a.values()]},K=async e=>{let r=x(e),a=y(e),s=await w(),t=new Map(r.map(i=>[i.packageName,i.name])),n=new Map(r.map(i=>[i.name,i.packageName])),o=new Set(a.map(i=>i.name)),c=new Set(r.map(i=>i.name)),u=[...new Set([...c,...o])].sort();return{apps:await Promise.all(u.map(async i=>{let m=o.has(i),P=m?(await b(B.join(e,"apps",i,"ui")))?.proxy?.routes:void 0;return{name:i,hasApi:c.has(i),hasUi:m,apiPackage:n.get(i),backends:P?q(P,t):[]}})),presets:Object.keys(s.devServersPresets??{}),environments:s.environments}},U=e=>{let r=[];for(let a of e.apps){if(a.hasUi){let s=a.backends.flatMap(n=>n.routes),t=s.length>0?`frontend \u2014 proxies ${[...s].sort().join(", ")}`:"frontend";r.push({name:`${a.name}/ui`,value:`${a.name}/ui`,description:t})}a.hasApi&&r.push({name:`${a.name}/api`,value:`${a.name}/api`,description:"backend"})}return r},_=e=>{let r={api:e.apps.filter(t=>t.hasApi).map(t=>t.name),ui:e.apps.filter(t=>t.hasUi).map(t=>t.name)},a={},s=new Map;for(let t of e.apps){t.apiPackage!=null&&(a[t.name]=t.apiPackage);for(let n of t.backends)for(let o of n.routes)s.set(`${t.name} ${o}`,n.packageName)}return{discovered:r,apiPkgByApp:a,routePkg:(t,n)=>s.get(`${t} ${n}`)}},I=(e,r)=>k({__wizard__:e},_(r)).map(a=>a.message),A=async(e,r)=>{if(r.apps.length===0)return d.warn("No apps discovered to run."),null;let a=await e.checkbox({message:"\u{1F4E6} Which packages?",choices:U(r)});if(a.length===0)return d.warn("No packages selected."),null;let s=await e.confirm({message:"\u{1F440} Rebuild & restart on save (watch)?",default:!1}),t=await e.confirm({message:"\u{1F9E9} Run each app in its own cmux pane?",default:!1}),n={targets:a,watch:s,cmux:t},o=M(n,r);o.anyCloudRoute&&(n.env=await e.select({message:"\u2601\uFE0F Point cloud routes at which environment?",choices:r.environments.map(p=>({name:p,value:p}))}),h.env[W]=n.env);let c=I(o.presetDef,r);if(c.length>0){d.warn("\u26A0\uFE0F Proxy audit found issues with this selection:");for(let p of c)d.warn(` \u2022 ${p}`);return null}E(o,n,r);let u=o.targetKeys.filter(p=>p.endsWith("/api")).map(p=>p.split("/")[0]);return t&&u.length>0?{include:u,presetDef:o.presetDef,watch:s,cmux:!0}:(t&&d.info("\u2139\uFE0F cmux needs at least one local backend (panes are backend-only) \u2014 running in-process instead."),{presetDef:o.presetDef,watch:s,cmux:!1})},E=(e,r,a)=>{l.setInteractive();let s=C(e,r,a);l.addOption(s.flags,!0),l.print(),s.exact||d.info("\u2139\uFE0F This part-level selection has no exact single-flag form \u2014 save it as a devPreset to reproduce it.")},T=async(e,r)=>{let a=await e.confirm({message:"\u{1F440} Rebuild & restart on save (watch)?",default:!1});return l.setInteractive(),l.addOption(r,!0),a&&l.addOption("--watch",!0),l.print(),{preset:r,watch:a,cmux:!1}},D=" manual",F=async(e,r)=>{if(r.presets.length===0)return A(e,r);let a=await e.select({message:"\u{1F680} Start from a preset, or configure manually?",choices:[...r.presets.map(s=>({name:s,value:s})),new O(" "),{name:"Manual (custom)\u2026",value:D}]});return a===D?A(e,r):T(e,a)},se=async(e=j,r=v(h.cwd()))=>F(e,await K(r));export{D as MANUAL_CHOICE,I as auditManualPlan,j as defaultPrompts,K as gatherWizardModel,se as runDevWizard,F as runWizardFlow};
|
|
2
|
-
//# sourceMappingURL=dev-wizard-run-HGQO6FZV.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/dev/dev-wizard-run.ts", "../src/dev/dev-wizard.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Impure driver for the interactive `infra-kit dev` wizard: filesystem/config discovery, the inquirer\n * prompt flow (step-0 preset-or-manual, then the manual matrix), the pre-flight proxy audit, and the\n * `commandEcho` teaching line. The pure answer\u2192plan mapping lives in {@link file://./dev-wizard.ts}.\n *\n * Prompts are behind the injectable {@link WizardPrompts} seam so the flow is testable without a TTY.\n * This module is reached ONLY from the bare-invocation TTY branch of the entry point; every flagged /\n * non-TTY / `--json` / MCP invocation bypasses it entirely.\n */\nimport inquirerCheckbox from '@inquirer/checkbox'\nimport inquirerConfirm from '@inquirer/confirm'\nimport inquirerSelect, { Separator } from '@inquirer/select'\nimport path from 'node:path'\nimport process from 'node:process'\n\nimport { discoverApiApps, discoverUiApps, findMonorepoRoot } from 'src/dev/discovery'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { INFRA_KIT_ENV_VAR } from 'src/lib/constants'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport type { DevPreset } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport { loadDev } from 'src/lib/vite/vite'\n\nimport { deriveManualPlan, equivalentCommand } from './dev-wizard.js'\nimport type { DerivedPlan, ManualSelection, ProxyBackend, WizardApp, WizardModel } from './dev-wizard.js'\nimport { validatePresetProxy } from './presets.js'\nimport type { DiscoveredParts, PresetProxyContext } from './presets.js'\n\n/** A wizard prompt choice \u2014 all values are strings, so the seam needs no generics. */\nexport interface WizardChoice {\n name: string\n value: string\n description?: string\n checked?: boolean\n disabled?: boolean | string\n}\n\n/**\n * Injectable prompt seam (a string-valued subset of `@inquirer/*`). The default implementation\n * ({@link defaultPrompts}) delegates to the real prompts, rendering to stderr so the dev-server's\n * stdout stays clean. Tests pass a scripted object.\n */\nexport interface WizardPrompts {\n select: (cfg: { message: string; choices: (WizardChoice | Separator)[]; default?: string }) => Promise<string>\n checkbox: (cfg: { message: string; choices: WizardChoice[] }) => Promise<string[]>\n confirm: (cfg: { message: string; default?: boolean }) => Promise<boolean>\n}\n\n/**\n * Shared `@inquirer/*` context. Rendered to stderr (mirrors the bare-`infra-kit` command palette).\n *\n * `clearPromptOnDone` erases each answered prompt instead of leaving a `\u2714 <question> <answer>` line\n * behind, so the wizard collapses to nothing once it finishes and the dev-server's ready header lands\n * at the top of a clean screen. The choices are not lost: {@link echoManual} / {@link runPresetBranch}\n * print the equivalent flag command, which is the durable record of what was picked.\n */\nconst promptContext = { output: process.stderr, clearPromptOnDone: true }\n\n/** Real `@inquirer/*` prompts, rendered to stderr and erased once answered. */\nexport const defaultPrompts: WizardPrompts = {\n select: (cfg) => {\n return inquirerSelect({ message: cfg.message, choices: cfg.choices, default: cfg.default }, promptContext)\n },\n checkbox: (cfg) => {\n return inquirerCheckbox({ message: cfg.message, choices: cfg.choices }, promptContext)\n },\n confirm: (cfg) => {\n return inquirerConfirm({ message: cfg.message, default: cfg.default }, promptContext)\n },\n}\n\n/** What the wizard hands back to the entry point (merged into `DevServerOptions`), or null on cancel. */\nexport interface WizardResult {\n /** Named preset (preset branch) \u2014 passed through as `options.preset`. */\n preset?: string\n /** In-memory preset (manual branch, non-cmux) \u2014 passed through as `options.presetDef`. */\n presetDef?: DevPreset\n /**\n * App-name include list for the cmux path only: which discovered API apps get a pane. Paired with\n * `presetDef`, which tells each pane the exact parts to run. An app selected UI-only gets no pane\n * (cmux panes are opened per API app). Unset for the non-cmux manual path.\n */\n include?: string[]\n watch: boolean\n cmux: boolean\n}\n\n/** Group one frontend's `dev.proxy.routes` into {@link ProxyBackend}s keyed by backend package. */\nconst groupBackends = (\n routes: Record<string, { packageName: string; from: readonly string[] }>,\n ownerByPkg: Map<string, string>,\n): ProxyBackend[] => {\n const byPkg = new Map<string, ProxyBackend>()\n\n for (const [route, def] of Object.entries(routes)) {\n const existing = byPkg.get(def.packageName)\n const localCapable = def.from.includes('local')\n\n if (existing) {\n existing.routes.push(route)\n existing.localCapable = existing.localCapable || localCapable\n } else {\n byPkg.set(def.packageName, {\n packageName: def.packageName,\n routes: [route],\n localCapable,\n ownerApp: ownerByPkg.get(def.packageName),\n })\n }\n }\n\n return [...byPkg.values()]\n}\n\n/** Discover apps + configs and assemble the {@link WizardModel} (backends resolved per frontend). */\nexport const gatherWizardModel = async (root: string): Promise<WizardModel> => {\n const apiApps = discoverApiApps(root)\n const uiApps = discoverUiApps(root)\n const config = await getInfraKitConfig()\n\n const ownerByPkg = new Map(\n apiApps.map((a) => {\n return [a.packageName, a.name] as const\n }),\n )\n const apiPkgByName = new Map(\n apiApps.map((a) => {\n return [a.name, a.packageName] as const\n }),\n )\n const uiNames = new Set(\n uiApps.map((a) => {\n return a.name\n }),\n )\n const apiNames = new Set(\n apiApps.map((a) => {\n return a.name\n }),\n )\n const allNames = [...new Set([...apiNames, ...uiNames])].sort()\n\n const apps: WizardApp[] = await Promise.all(\n allNames.map(async (name): Promise<WizardApp> => {\n const hasUi = uiNames.has(name)\n const routes = hasUi ? (await loadDev(path.join(root, 'apps', name, 'ui')))?.proxy?.routes : undefined\n\n return {\n name,\n hasApi: apiNames.has(name),\n hasUi,\n apiPackage: apiPkgByName.get(name),\n backends: routes ? groupBackends(routes, ownerByPkg) : [],\n }\n }),\n )\n\n return { apps, presets: Object.keys(config.devServersPresets ?? {}), environments: config.environments }\n}\n\n/**\n * Build the flat `<app>/<part>` checkbox choices, grouped per app as `ui` then `api`. A frontend choice\n * carries a description of the routes it proxies, so ticking the matching api part reads as \"run that\n * route locally\". This is the checkbox the user directly picks their targets from.\n *\n * Nothing starts checked: the manual branch is opt-in, so a run only ever launches what was explicitly\n * ticked. Pre-checking every part would make the fast path (accept the defaults) boot the whole monorepo\n * \u2014 the exact opposite of why someone reached for \"Manual\" over a preset.\n */\nconst buildPartChoices = (model: WizardModel): WizardChoice[] => {\n const choices: WizardChoice[] = []\n\n for (const app of model.apps) {\n if (app.hasUi) {\n const routes = app.backends.flatMap((b) => {\n return b.routes\n })\n const description = routes.length > 0 ? `frontend \u2014 proxies ${[...routes].sort().join(', ')}` : 'frontend'\n\n choices.push({ name: `${app.name}/ui`, value: `${app.name}/ui`, description })\n }\n if (app.hasApi) {\n choices.push({ name: `${app.name}/api`, value: `${app.name}/api`, description: 'backend' })\n }\n }\n\n return choices\n}\n\n/** Build the audit context from the gathered model (no re-reading of configs). */\nconst buildAuditContext = (model: WizardModel): PresetProxyContext => {\n const discovered: DiscoveredParts = {\n api: model.apps\n .filter((a) => {\n return a.hasApi\n })\n .map((a) => {\n return a.name\n }),\n ui: model.apps\n .filter((a) => {\n return a.hasUi\n })\n .map((a) => {\n return a.name\n }),\n }\n const apiPkgByApp: Record<string, string> = {}\n const routeToPkg = new Map<string, string>()\n\n for (const app of model.apps) {\n // Map EVERY discovered api app to its own api package \u2014 including api-only apps a frontend proxies\n // to cross-app \u2014 so `launchedPkgs` in validatePresetProxy is faithful (mirrors preset-proxy-check.ts).\n // Deriving this from proxy backends alone would miss api-only owners and false-positive the audit.\n if (app.apiPackage != null) apiPkgByApp[app.name] = app.apiPackage\n for (const b of app.backends) {\n for (const route of b.routes) {\n routeToPkg.set(`${app.name} ${route}`, b.packageName)\n }\n }\n }\n\n return {\n discovered,\n apiPkgByApp,\n routePkg: (app, route) => {\n return routeToPkg.get(`${app} ${route}`)\n },\n }\n}\n\n/**\n * Run the assembled plan through the SAME proxy-locality rule the root audit uses. Returns issue\n * messages (empty when clean). Catches a `local` override whose backend won't launch \u2014 the wizard's\n * derivation launches owners, so a hit means the backend has no discoverable owning app.\n */\nexport const auditManualPlan = (presetDef: DevPreset, model: WizardModel): string[] => {\n return validatePresetProxy({ __wizard__: presetDef }, buildAuditContext(model)).map((i) => {\n return i.message\n })\n}\n\n/** The manual-branch flow: app + per-app proxy + env + watch + cmux \u2192 audited plan \u2192 echo. */\nconst runManualBranch = async (prompts: WizardPrompts, model: WizardModel): Promise<WizardResult | null> => {\n if (model.apps.length === 0) {\n logger.warn('No apps discovered to run.')\n\n return null\n }\n\n const selectedTargets = await prompts.checkbox({ message: '\uD83D\uDCE6 Which packages?', choices: buildPartChoices(model) })\n\n if (selectedTargets.length === 0) {\n logger.warn('No packages selected.')\n\n return null\n }\n\n const watch = await prompts.confirm({ message: '\uD83D\uDC40 Rebuild & restart on save (watch)?', default: false })\n const cmux = await prompts.confirm({ message: '\uD83E\uDDE9 Run each app in its own cmux pane?', default: false })\n\n const selection: ManualSelection = { targets: selectedTargets, watch, cmux }\n const plan = deriveManualPlan(selection, model)\n\n if (plan.anyCloudRoute) {\n selection.env = await prompts.select({\n message: '\u2601\uFE0F Point cloud routes at which environment?',\n choices: model.environments.map((e) => {\n return { name: e, value: e }\n }),\n })\n process.env[INFRA_KIT_ENV_VAR] = selection.env\n }\n\n const issues = auditManualPlan(plan.presetDef, model)\n\n if (issues.length > 0) {\n logger.warn('\u26A0\uFE0F Proxy audit found issues with this selection:')\n for (const issue of issues) {\n logger.warn(` \u2022 ${issue}`)\n }\n\n return null\n }\n\n echoManual(plan, selection, model)\n\n // cmux opens one pane per selected API app. `include` picks WHICH apps get a pane; `presetDef` tells\n // each pane exactly which of its parts to run. Without the latter a pane runs `--app=<name>`, which\n // expands to every part the app has \u2014 silently starting a UI the user just unticked.\n const apiApps = plan.targetKeys\n .filter((k) => {\n return k.endsWith('/api')\n })\n .map((k) => {\n return k.split('/')[0]!\n })\n\n // An empty include would collapse to `null` in `normalizeAppInclude` and make cmux run EVERY api app,\n // so a cmux run with no selected backends (e.g. an all-frontend selection) falls back to in-process.\n if (cmux && apiApps.length > 0) {\n return { include: apiApps, presetDef: plan.presetDef, watch, cmux: true }\n }\n\n if (cmux) {\n logger.info('\u2139\uFE0F cmux needs at least one local backend (panes are backend-only) \u2014 running in-process instead.')\n }\n\n return { presetDef: plan.presetDef, watch, cmux: false }\n}\n\n/** Print the equivalent flag command (and, for a part-level selection, the save-as-preset hint). */\nconst echoManual = (plan: DerivedPlan, selection: ManualSelection, model: WizardModel): void => {\n commandEcho.setInteractive()\n\n const eq = equivalentCommand(plan, selection, model)\n\n commandEcho.addOption(eq.flags, true)\n commandEcho.print()\n\n if (!eq.exact) {\n logger.info('\u2139\uFE0F This part-level selection has no exact single-flag form \u2014 save it as a devPreset to reproduce it.')\n }\n}\n\n/** The preset-branch flow: run a named preset, asking only whether to watch (presets can't encode it). */\nconst runPresetBranch = async (prompts: WizardPrompts, preset: string): Promise<WizardResult> => {\n const watch = await prompts.confirm({ message: '\uD83D\uDC40 Rebuild & restart on save (watch)?', default: false })\n\n commandEcho.setInteractive()\n commandEcho.addOption(preset, true)\n if (watch) commandEcho.addOption('--watch', true)\n commandEcho.print()\n\n return { preset, watch, cmux: false }\n}\n\n/** Sentinel value for the \"Manual (custom)\" step-0 choice (a preset name can never be empty). */\nexport const MANUAL_CHOICE = ' manual'\n\n/**\n * Drive the wizard's branch flow over an ALREADY-gathered model (no disk/config access). Split from\n * {@link runDevWizard} so the flow is unit-testable with scripted prompts + a fixture model.\n */\nexport const runWizardFlow = async (prompts: WizardPrompts, model: WizardModel): Promise<WizardResult | null> => {\n if (model.presets.length === 0) {\n return runManualBranch(prompts, model)\n }\n\n const choice = await prompts.select({\n message: '\uD83D\uDE80 Start from a preset, or configure manually?',\n choices: [\n ...model.presets.map((p) => {\n return { name: p, value: p }\n }),\n new Separator(' '),\n { name: 'Manual (custom)\u2026', value: MANUAL_CHOICE },\n ],\n })\n\n return choice === MANUAL_CHOICE ? runManualBranch(prompts, model) : runPresetBranch(prompts, choice)\n}\n\n/**\n * Gather the model from disk/config, then drive the wizard flow, returning the resolved run options (or\n * null on cancel / empty selection). The entry point calls this on a bare TTY `infra-kit dev`.\n */\nexport const runDevWizard = async (\n prompts: WizardPrompts = defaultPrompts,\n root: string = findMonorepoRoot(process.cwd()),\n): Promise<WizardResult | null> => {\n return runWizardFlow(prompts, await gatherWizardModel(root))\n}\n", "/**\n * Pure core of the interactive `infra-kit dev` wizard (the no-args, TTY path).\n *\n * The wizard is FRONTEND-CENTRIC: you pick apps to run, and for each frontend you choose, per backend\n * it proxies to, whether that backend runs LOCALLY (its `/api` is launched \u2192 the route resolves local)\n * or stays CLOUD (not launched \u2192 the route proxies to the `<env>` cloud target). A backend runs iff a\n * frontend points at it locally, or its app is selected and not demoted to cloud. This module turns\n * those answers into an in-memory {@link DevPreset} the runner consumes verbatim (part-level targets\n * that the app-name-only `--app` include cannot express) \u2014 and is side-effect-free so the mapping is\n * fully unit-testable. The impure I/O (discovery, inquirer prompts, audit, launch) lives in\n * {@link file://./dev-wizard-run.ts}.\n */\nimport type { DevPreset, ProxySource } from 'src/lib/infra-kit-config'\n\n/**\n * One backend a frontend's proxy routes can be pointed at, grouped by the backend package. A frontend\n * that maps `/api` and `/media` to the same package yields ONE {@link ProxyBackend} with both routes \u2014\n * launching the package flips every one of its `local`-capable routes together (see `pickSource`).\n */\nexport interface ProxyBackend {\n /** Backend package name (a route's `packageName`). */\n packageName: string\n /** Route paths that resolve to this package (for display + the audit's per-route overrides). */\n routes: string[]\n /** True when at least one of `routes` lists `local` in its `from` capabilities \u2014 i.e. it is toggleable. A `false` backend is fixed-cloud, shown as info. */\n localCapable: boolean\n /** App folder whose `api` package is {@link packageName}, or undefined when no discovered app owns it (a `local` choice then has nothing to launch \u2014 the audit flags it). */\n ownerApp?: string\n}\n\n/** A discovered app as the wizard sees it: which parts exist + which backends its frontend proxies to. */\nexport interface WizardApp {\n /** App folder name (e.g. `client`). */\n name: string\n /** Has `apps/<app>/api` (a launchable backend). */\n hasApi: boolean\n /** Has `apps/<app>/ui` (a launchable frontend). */\n hasUi: boolean\n /**\n * This app's OWN `api` package name (from `apps/<app>/api`), or undefined when it has no api. Carried\n * so the audit can build a faithful `app \u2192 apiPackage` map for EVERY discovered api app \u2014 including\n * api-only apps a frontend proxies to cross-app \u2014 mirroring the root audit (`preset-proxy-check.ts`).\n */\n apiPackage?: string\n /** Backends this app's frontend proxies to (empty for api-only apps or a frontend with no `dev.proxy`). */\n backends: ProxyBackend[]\n}\n\n/** Everything the wizard needs, gathered impurely by {@link file://./dev-wizard-run.ts}. */\nexport interface WizardModel {\n /** All discovered apps (api and/or ui), sorted by name. */\n apps: WizardApp[]\n /** `devServersPresets` names (drives the preset-or-manual step-0). */\n presets: string[]\n /** Configured `environments` (the cloud-env `select` options). */\n environments: string[]\n}\n\n/** The manual-branch answers collected from the prompts, fed to {@link deriveManualPlan}. */\nexport interface ManualSelection {\n /**\n * The `<app>/<part>` target keys the user ticked directly (e.g. `client/ui`, `client/api`). A frontend's\n * proxy route resolves LOCAL iff the backend's owner-api part is in this set \u2014 otherwise CLOUD \u2014 so the\n * part checkbox IS the local/cloud decision; there is no separate per-backend question.\n */\n targets: string[]\n /** Chosen cloud env for cloud routes (undefined when nothing resolves cloud). */\n env?: string\n /** Rebuild + restart on save. */\n watch: boolean\n /** One cmux pane per app. */\n cmux: boolean\n}\n\n/** The resolved run plan derived from a {@link ManualSelection}. */\nexport interface DerivedPlan {\n /** In-memory preset handed to the runner (`options.presetDef`). */\n presetDef: DevPreset\n /** At least one route resolves to cloud \u2192 an env must be chosen (pre-flight gate). */\n anyCloudRoute: boolean\n /** Resolved `<app>/<part>` target keys, sorted \u2014 for the echo + audit display. */\n targetKeys: string[]\n}\n\n/** App folder name from an `<app>/<part>` target key. */\nconst appOf = (key: string): string => {\n return key.split('/')[0]!\n}\n\n/** Index a model's apps by folder name for O(1) lookup. */\nconst byName = (model: WizardModel): Map<string, WizardApp> => {\n return new Map(\n model.apps.map((a) => {\n return [a.name, a]\n }),\n )\n}\n\n/**\n * Resolve ONE selected frontend's proxy routes against the set of api parts the user ticked: a route is\n * `local` iff its backend is `localCapable` AND that backend's owner-api part was selected \u2014 otherwise\n * `cloud`. Kept separate from {@link deriveManualPlan} so the per-app override loop stays flat.\n */\nconst resolveUiProxy = (\n app: WizardApp,\n selectedApiApps: ReadonlySet<string>,\n): { overrides: Record<string, ProxySource>; anyCloud: boolean } => {\n const overrides: Record<string, ProxySource> = {}\n let anyCloud = false\n\n for (const backend of app.backends) {\n const isLocal = backend.localCapable && backend.ownerApp != null && selectedApiApps.has(backend.ownerApp)\n\n if (!isLocal) anyCloud = true\n for (const route of backend.routes) {\n overrides[route] = isLocal ? 'local' : 'cloud'\n }\n }\n\n return { overrides, anyCloud }\n}\n\n/**\n * Turn a part-level {@link ManualSelection} into an in-memory {@link DevPreset}. Because the user picks\n * `<app>/<part>` targets directly, the mapping is straightforward:\n * - every selected `<app>/ui` runs that frontend;\n * - every selected `<app>/api` runs that backend locally;\n * - each frontend's proxy route resolves `local` iff the backend's owner-api part was also selected\n * (even cross-app), else `cloud` \u2014 i.e. ticking the api part IS the local choice.\n *\n * @example\n * // client frontend only (its /api left unticked \u2192 its proxy route resolves to cloud):\n * deriveManualPlan(\n * { targets: ['client/ui'], watch: false, cmux: false },\n * { apps: [{ name: 'client', hasApi: true, hasUi: true,\n * backends: [{ packageName: 'client-api', routes: ['/api'], localCapable: true, ownerApp: 'client' }] }],\n * presets: [], environments: ['dev'] },\n * ).targetKeys // => ['client/ui']\n */\nexport const deriveManualPlan = (selection: ManualSelection, model: WizardModel): DerivedPlan => {\n const apps = byName(model)\n const uiKeys = selection.targets.filter((t) => {\n return t.endsWith('/ui')\n })\n const apiApps = new Set(\n selection.targets\n .filter((t) => {\n return t.endsWith('/api')\n })\n .map(appOf),\n )\n\n const presetApps: Record<string, { proxy?: Record<string, ProxySource> }> = {}\n let anyCloud = false\n\n for (const key of uiKeys) {\n const app = apps.get(appOf(key))\n const { overrides, anyCloud: cloud } = app ? resolveUiProxy(app, apiApps) : { overrides: {}, anyCloud: false }\n\n if (cloud) anyCloud = true\n presetApps[key] = Object.keys(overrides).length > 0 ? { proxy: overrides } : {}\n }\n for (const name of apiApps) {\n presetApps[`${name}/api`] ??= {}\n }\n\n return {\n presetDef: { apps: presetApps, cmux: selection.cmux },\n anyCloudRoute: anyCloud,\n targetKeys: Object.keys(presetApps).sort(),\n }\n}\n\n/** The equivalent non-interactive command, plus whether it reproduces the selection exactly. */\nexport interface EquivalentCommand {\n /** The `--app=\u2026`-form flag string (no leading `infra-kit dev`). */\n flags: string\n /**\n * True when `--app` reproduces the plan exactly \u2014 i.e. every involved app runs ALL the parts it has.\n * False for a part-level selection (e.g. frontend-only), which `--app` (app-name granularity) cannot\n * express; the caller then hints \"save as a preset\" for exact reproduction.\n */\n exact: boolean\n}\n\n/**\n * Build the equivalent `infra-kit dev --app=\u2026 [--watch] [--cmux]` flag string for a derived plan.\n * `exact` is true only when the target set covers every part each involved app HAS (a whole-app\n * selection), since `--app` filters by app name, not part.\n */\nexport const equivalentCommand = (\n plan: DerivedPlan,\n selection: ManualSelection,\n model: WizardModel,\n): EquivalentCommand => {\n const apps = byName(model)\n const involved = [...new Set(plan.targetKeys.map(appOf))].sort()\n const present = new Set(plan.targetKeys)\n\n const exact = involved.every((name) => {\n const app = apps.get(name)\n\n if (!app) return false\n\n const uiOk = !app.hasUi || present.has(`${name}/ui`)\n const apiOk = !app.hasApi || present.has(`${name}/api`)\n\n return uiOk && apiOk\n })\n\n const parts = [`--app=${involved.join(',')}`]\n\n if (selection.watch) parts.push('--watch')\n if (selection.cmux) parts.push('--cmux')\n\n return { flags: parts.join(' '), exact }\n}\n"],
|
|
5
|
-
"mappings": "qNASA,OAAOA,MAAsB,qBAC7B,OAAOC,MAAqB,oBAC5B,OAAOC,GAAkB,aAAAC,MAAiB,mBAC1C,OAAOC,MAAU,YACjB,OAAOC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cpB,EAAS,MAAMhC,EAAkBC,CAAI,CAAC",
|
|
6
|
-
"names": ["inquirerCheckbox", "inquirerConfirm", "inquirerSelect", "Separator", "path", "process", "appOf", "key", "byName", "model", "a", "resolveUiProxy", "app", "selectedApiApps", "overrides", "anyCloud", "backend", "isLocal", "route", "deriveManualPlan", "selection", "apps", "uiKeys", "t", "apiApps", "presetApps", "cloud", "name", "equivalentCommand", "plan", "involved", "present", "exact", "uiOk", "apiOk", "parts", "promptContext", "process", "defaultPrompts", "cfg", "inquirerSelect", "inquirerCheckbox", "inquirerConfirm", "groupBackends", "routes", "ownerByPkg", "byPkg", "route", "def", "existing", "localCapable", "gatherWizardModel", "root", "apiApps", "discoverApiApps", "uiApps", "discoverUiApps", "config", "getInfraKitConfig", "a", "apiPkgByName", "uiNames", "apiNames", "allNames", "name", "hasUi", "loadDev", "path", "buildPartChoices", "model", "choices", "app", "b", "description", "buildAuditContext", "discovered", "apiPkgByApp", "routeToPkg", "auditManualPlan", "presetDef", "validatePresetProxy", "i", "runManualBranch", "prompts", "logger", "selectedTargets", "watch", "cmux", "selection", "plan", "deriveManualPlan", "e", "INFRA_KIT_ENV_VAR", "issues", "issue", "echoManual", "k", "commandEcho", "eq", "equivalentCommand", "runPresetBranch", "preset", "MANUAL_CHOICE", "runWizardFlow", "choice", "p", "Separator", "runDevWizard", "findMonorepoRoot"]
|
|
7
|
-
}
|
package/dist/entry/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { defineConfig } from '../lib/package-config/package-config';
|
|
2
|
-
export type { InfraKitDev, InfraKitDevProxy, InfraKitDevProxyRoute, InfraKitDevProxySource, InfraKitPackageConfig, InfraKitPackageConfigInput, } from '../lib/package-config/package-config';
|
|
3
|
-
export { defineVendorConfig } from '../lib/vendor/config-schema';
|
|
4
|
-
export type { VendorConfig, VendorCopyItem } from '../lib/vendor/config-schema';
|
package/dist/entry/vite.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* Schema for the resolved (post-factory) package config object. `strictObject`
|
|
4
|
-
* rejects unknown keys so typos in `infra-kit.config.ts` surface as validation
|
|
5
|
-
* errors instead of being silently ignored.
|
|
6
|
-
*
|
|
7
|
-
* Kept in its own module — separate from the public `defineConfig`/types entry —
|
|
8
|
-
* so the published `infra-kit` type surface stays free of a `zod` import.
|
|
9
|
-
*/
|
|
10
|
-
export declare const packageConfigSchema: z.ZodObject<{
|
|
11
|
-
requiredScripts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
|
-
requiredFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
-
turbo: z.ZodOptional<z.ZodObject<{
|
|
14
|
-
requiredTasks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
15
|
-
}, z.core.$strict>>;
|
|
16
|
-
dev: z.ZodOptional<z.ZodObject<{
|
|
17
|
-
proxy: z.ZodOptional<z.ZodObject<{
|
|
18
|
-
templates: z.ZodObject<{
|
|
19
|
-
local: z.ZodString;
|
|
20
|
-
cloud: z.ZodString;
|
|
21
|
-
}, z.core.$strict>;
|
|
22
|
-
routes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
23
|
-
packageName: z.ZodString;
|
|
24
|
-
from: z.ZodArray<z.ZodEnum<{
|
|
25
|
-
local: "local";
|
|
26
|
-
cloud: "cloud";
|
|
27
|
-
}>>;
|
|
28
|
-
default: z.ZodOptional<z.ZodEnum<{
|
|
29
|
-
local: "local";
|
|
30
|
-
cloud: "cloud";
|
|
31
|
-
}>>;
|
|
32
|
-
}, z.core.$strict>>;
|
|
33
|
-
}, z.core.$strict>>;
|
|
34
|
-
}, z.core.$strict>>;
|
|
35
|
-
}, z.core.$strict>;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation rules for a single workspace package, declared in its
|
|
3
|
-
* `infra-kit.config.js`. Every field is optional: a key left unset falls back to
|
|
4
|
-
* the active baseline ({@link DEFAULT_RULES} for packages, {@link ROOT_DEFAULT_RULES}
|
|
5
|
-
* for the monorepo root), and a key set replaces that default wholesale (per-key,
|
|
6
|
-
* no array concatenation) so a package can opt out with an explicit empty array.
|
|
7
|
-
*
|
|
8
|
-
* Most packages need none of these — the standard rules live in the baseline, so
|
|
9
|
-
* a typical config is just `defineConfig(() => ({}))`.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* // infra-kit.config.js
|
|
13
|
-
* import { defineConfig } from 'infra-kit'
|
|
14
|
-
*
|
|
15
|
-
* export default defineConfig(() => ({}))
|
|
16
|
-
*/
|
|
17
|
-
export interface InfraKitPackageConfig {
|
|
18
|
-
/** Scripts that must be present in the package's package.json `scripts` map. */
|
|
19
|
-
requiredScripts?: string[];
|
|
20
|
-
/** Files (relative to the package root) that must exist on disk. */
|
|
21
|
-
requiredFiles?: string[];
|
|
22
|
-
/** Turborepo expectations — only meaningful where a turbo.json lives (the root). */
|
|
23
|
-
turbo?: {
|
|
24
|
-
/** Tasks that must be defined in turbo.json `tasks`. */
|
|
25
|
-
requiredTasks?: string[];
|
|
26
|
-
};
|
|
27
|
-
/** Local-dev configuration. Accepted-and-inert to the audit; consumed by the dev server. */
|
|
28
|
-
dev?: InfraKitDev;
|
|
29
|
-
}
|
|
30
|
-
/** A proxy route's allowed backend source. */
|
|
31
|
-
export type InfraKitDevProxySource = 'local' | 'cloud';
|
|
32
|
-
export interface InfraKitDevProxyRoute {
|
|
33
|
-
/** Backend package this route targets when resolved locally. */
|
|
34
|
-
packageName: string;
|
|
35
|
-
/** Capabilities this route can resolve to. Must be non-empty. */
|
|
36
|
-
from: InfraKitDevProxySource[];
|
|
37
|
-
/**
|
|
38
|
-
* Source used when a local backend for this package isn't active. Required when
|
|
39
|
-
* `from` lists more than one source; redundant (and omitted) for a single-source
|
|
40
|
-
* route. When set, must be one of `from`.
|
|
41
|
-
*/
|
|
42
|
-
default?: InfraKitDevProxySource;
|
|
43
|
-
}
|
|
44
|
-
export interface InfraKitDevProxy {
|
|
45
|
-
/** URL templates. Placeholders like `<release>`/`<packageName>`/`<env>` are substituted at dev time. */
|
|
46
|
-
templates: {
|
|
47
|
-
local: string;
|
|
48
|
-
cloud: string;
|
|
49
|
-
};
|
|
50
|
-
/** Path-prefix (e.g. `/api`, `/api/v1`, `/media`) → route definition. */
|
|
51
|
-
routes: Record<string, InfraKitDevProxyRoute>;
|
|
52
|
-
}
|
|
53
|
-
export interface InfraKitDev {
|
|
54
|
-
proxy?: InfraKitDevProxy;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Accepted shapes for a package config's default export — mirrors Vite's
|
|
58
|
-
* `defineConfig` input: a plain object, a sync factory, or an async factory.
|
|
59
|
-
*/
|
|
60
|
-
export type InfraKitPackageConfigInput = InfraKitPackageConfig | (() => InfraKitPackageConfig) | (() => Promise<InfraKitPackageConfig>);
|
|
61
|
-
/**
|
|
62
|
-
* Identity helper that gives `infra-kit.config.js` authors full type inference
|
|
63
|
-
* and editor autocomplete without changing the value — exactly like Vite's
|
|
64
|
-
* `defineConfig`. Resolution of the factory form happens in the loader, not here.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* export default defineConfig(() => ({}))
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* export default defineConfig(() => ({ requiredScripts: [] }))
|
|
71
|
-
*/
|
|
72
|
-
export declare const defineConfig: (config: InfraKitPackageConfigInput) => InfraKitPackageConfigInput;
|
|
73
|
-
/** Fully-resolved rules with every defaultable field present. */
|
|
74
|
-
export interface ResolvedPackageRules {
|
|
75
|
-
requiredScripts: string[];
|
|
76
|
-
requiredFiles: string[];
|
|
77
|
-
turboTasks: string[];
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Baseline rules for a standard TypeScript workspace package, applied to any key
|
|
81
|
-
* a package leaves unset. These are the "under the hood" defaults so a conforming
|
|
82
|
-
* package's config can stay empty; non-standard packages override the relevant key.
|
|
83
|
-
*/
|
|
84
|
-
export declare const DEFAULT_RULES: Readonly<ResolvedPackageRules>;
|
|
85
|
-
/**
|
|
86
|
-
* Baseline rules for the monorepo root (`infra-kit audit --root`). Checks the
|
|
87
|
-
* root commands, the workspace/turbo files, and that the turbo pipeline defines
|
|
88
|
-
* the expected tasks — so the root's own config can also stay empty.
|
|
89
|
-
*/
|
|
90
|
-
export declare const ROOT_DEFAULT_RULES: Readonly<ResolvedPackageRules>;
|
|
91
|
-
/**
|
|
92
|
-
* Merge a parsed package config over a baseline. Each key is replaced wholesale
|
|
93
|
-
* when the package provides it, otherwise the baseline value is used.
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* resolvePackageConfig({ requiredScripts: [] })
|
|
97
|
-
* // => { requiredScripts: [], requiredFiles: [...DEFAULT_RULES.requiredFiles], turboTasks: [] }
|
|
98
|
-
*/
|
|
99
|
-
export declare const resolvePackageConfig: (config: InfraKitPackageConfig, baseline?: Readonly<ResolvedPackageRules>) => ResolvedPackageRules;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared, dependency-light release-slug helper.
|
|
3
|
-
*
|
|
4
|
-
* Extracted from `lib/vite/vite.ts` so BOTH the published `infra-kit/vite` helper
|
|
5
|
-
* (which re-exports it) and the dev-server's dev-context fragment writer derive the
|
|
6
|
-
* `<release>` hostname segment from ONE implementation — the recorded slug and the
|
|
7
|
-
* helper-computed slug can never drift. Pure (regex only, no imports) so importing it
|
|
8
|
-
* into the lightweight `infra-kit/vite` bundle stays cheap.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Slugify an arbitrary string into a single DNS label: lowercase, collapse every
|
|
12
|
-
* non-alphanumeric run to `-`, and drop leading/trailing separators. Returns `''`
|
|
13
|
-
* when the input carries no alphanumeric run (the caller must treat that as "no label").
|
|
14
|
-
*
|
|
15
|
-
* portless rejects any hostname outside `[a-z0-9.-]`, so every segment fed into a
|
|
16
|
-
* `<release>.<packageName>.localhost` alias must pass through here. A scoped npm name
|
|
17
|
-
* (`@hulyo/client-ui`) is the motivating case: registering it raw fails with
|
|
18
|
-
* `Invalid hostname`, and because the driver swallows that into a best-effort `false`,
|
|
19
|
-
* the whole hero-URL path degrades silently to `localhost:<port>`.
|
|
20
|
-
*
|
|
21
|
-
* Distinct from {@link slugifyRelease}: this does NOT strip a git-flow prefix, so a
|
|
22
|
-
* package legitimately named `fix-utils` keeps its `fix-` prefix.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* slugifyHostLabel('@hulyo/client-ui') // => 'hulyo-client-ui'
|
|
26
|
-
* slugifyHostLabel('backend-api') // => 'backend-api'
|
|
27
|
-
*/
|
|
28
|
-
export declare const slugifyHostLabel: (label: string) => string;
|
|
29
|
-
/**
|
|
30
|
-
* Slugify a git branch into a `<release>` token: strip a leading git-flow prefix
|
|
31
|
-
* (`feature/`, `release/`, …), then reduce the remainder to a single DNS label.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* slugifyRelease('release/2.4') // => '2-4'
|
|
35
|
-
* slugifyRelease('feature/HUL-123') // => 'hul-123'
|
|
36
|
-
*/
|
|
37
|
-
export declare const slugifyRelease: (branch: string) => string;
|
|
38
|
-
/**
|
|
39
|
-
* The `<release>` label used when no git branch resolves (outside a repo, or a branch that slugifies to
|
|
40
|
-
* nothing). Both the dev-server's alias writer and `infra-kit/vite`'s template interpolation fall back
|
|
41
|
-
* to this SAME constant — a divergence here would emit a hostname no alias backs.
|
|
42
|
-
*/
|
|
43
|
-
export declare const DEFAULT_RELEASE_SLUG = "local";
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* Pure (node-free) vendor config schema + authoring helper. Kept separate from
|
|
4
|
-
* `config.ts` (which imports node builtins for the runtime loader) so the public
|
|
5
|
-
* lib entry can re-export `defineVendorConfig` without dragging node types into
|
|
6
|
-
* the emitted `.d.ts`.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Filename a source repo provides at its root to declare WHAT `vendor sync`
|
|
10
|
-
* copies (`copy[]`). Lives ONLY on the write path — `vendor check` never loads it.
|
|
11
|
-
* WHERE/WHICH to stamp (`workspaceDir` + `targets`) is machine-local and lives in
|
|
12
|
-
* the user-global factory config (`~/.infra-kit/vendor.json`).
|
|
13
|
-
*/
|
|
14
|
-
export declare const VENDOR_CONFIG_FILE = "vendor.config.ts";
|
|
15
|
-
/**
|
|
16
|
-
* One item to sync from the source repo into each target. `vendored: true` marks
|
|
17
|
-
* workspace packages that must land under `vendor/` (the single-source-of-truth
|
|
18
|
-
* code); everything else is root-level tooling that stays at the repo root.
|
|
19
|
-
*/
|
|
20
|
-
export declare const vendorCopyItemSchema: z.ZodObject<{
|
|
21
|
-
name: z.ZodString;
|
|
22
|
-
source: z.ZodString;
|
|
23
|
-
target: z.ZodString;
|
|
24
|
-
type: z.ZodEnum<{
|
|
25
|
-
file: "file";
|
|
26
|
-
directory: "directory";
|
|
27
|
-
}>;
|
|
28
|
-
vendored: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
-
}, z.core.$strip>;
|
|
30
|
-
export declare const vendorConfigSchema: z.ZodObject<{
|
|
31
|
-
copy: z.ZodArray<z.ZodObject<{
|
|
32
|
-
name: z.ZodString;
|
|
33
|
-
source: z.ZodString;
|
|
34
|
-
target: z.ZodString;
|
|
35
|
-
type: z.ZodEnum<{
|
|
36
|
-
file: "file";
|
|
37
|
-
directory: "directory";
|
|
38
|
-
}>;
|
|
39
|
-
vendored: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
-
}, z.core.$strip>>;
|
|
41
|
-
}, z.core.$strict>;
|
|
42
|
-
export type VendorCopyItem = z.infer<typeof vendorCopyItemSchema>;
|
|
43
|
-
export type VendorConfig = z.infer<typeof vendorConfigSchema>;
|
|
44
|
-
/**
|
|
45
|
-
* Identity helper for authoring a type-safe `vendor.config.ts` in a source repo.
|
|
46
|
-
* Re-exported from the public lib entry so a source repo can
|
|
47
|
-
* `import { defineVendorConfig } from 'infra-kit'`.
|
|
48
|
-
*
|
|
49
|
-
* NOTE: a `vendor.config.ts` must be type-strippable — Node's native type
|
|
50
|
-
* stripping (Node >= 24) loads it without a build step, which forbids `enum`,
|
|
51
|
-
* `namespace`, and parameter properties.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* export default defineVendorConfig({
|
|
55
|
-
* copy: [{ name: 'Configs', source: 'vendor/configs', target: 'vendor/configs', type: 'directory', vendored: true }],
|
|
56
|
-
* })
|
|
57
|
-
*/
|
|
58
|
-
export declare const defineVendorConfig: (config: VendorConfig) => VendorConfig;
|
package/dist/lib/vite/vite.d.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import type { InfraKitDev, InfraKitDevProxy } from '../package-config/package-config';
|
|
2
|
-
import { slugifyRelease } from '../release-slug/release-slug';
|
|
3
|
-
/**
|
|
4
|
-
* A single Vite `server.proxy` entry. `changeOrigin` is always set. `cookieDomainRewrite` is cloud-only
|
|
5
|
-
* (it keeps an HTTPS cloud BE's cookies usable from a local FE). `secure: false` appears on BOTH sources
|
|
6
|
-
* but for different reasons: a cloud target may serve a cert the local store rejects, and a local target
|
|
7
|
-
* is served by portless from its own private CA — set there only for a loopback host (see
|
|
8
|
-
* {@link isLoopbackTarget}). `headers` is present only when HTTP Basic Auth is injected (see
|
|
9
|
-
* {@link buildBasicAuthHeader}) — it carries the `Authorization` header applied
|
|
10
|
-
* uniformly to every route so upstream environments behind auth (e2e/staging)
|
|
11
|
-
* stay reachable.
|
|
12
|
-
*/
|
|
13
|
-
export interface InfraKitViteProxyEntry {
|
|
14
|
-
target: string;
|
|
15
|
-
changeOrigin: true;
|
|
16
|
-
secure?: false;
|
|
17
|
-
cookieDomainRewrite?: 'localhost';
|
|
18
|
-
headers?: Record<string, string>;
|
|
19
|
-
}
|
|
20
|
-
/** A Vite `server.proxy`-shaped map: path-prefix → proxy entry. */
|
|
21
|
-
export type InfraKitViteProxy = Record<string, InfraKitViteProxyEntry>;
|
|
22
|
-
/** Explicit HTTP Basic Auth credentials, overriding the `E2E__BASIC_AUTH_*` env vars. */
|
|
23
|
-
export interface InfraKitBasicAuth {
|
|
24
|
-
username: string;
|
|
25
|
-
password: string;
|
|
26
|
-
}
|
|
27
|
-
export interface InfraKitDevOptions {
|
|
28
|
-
/** Package dir whose `infra-kit.config.ts` is loaded. Defaults to `process.cwd()`. */
|
|
29
|
-
cwd?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Explicit HTTP Basic Auth credentials injected into every proxy route as an
|
|
32
|
-
* `Authorization` header. Takes precedence over the `E2E__BASIC_AUTH_USERNAME`
|
|
33
|
-
* / `E2E__BASIC_AUTH_PASSWORD` env vars. Omit to use the env-based default.
|
|
34
|
-
*/
|
|
35
|
-
basicAuth?: InfraKitBasicAuth;
|
|
36
|
-
/**
|
|
37
|
-
* Vite's `command`. Pass it (`defineConfig(async ({ command }) => ({ server: await infraKitDev({ command }) }))`)
|
|
38
|
-
* so `build` is a no-op: `server` is irrelevant to a build and proxy resolution would otherwise
|
|
39
|
-
* fail-fast on a cloud route with no sourced env. Omit (or `'serve'`) for the dev-server config.
|
|
40
|
-
*/
|
|
41
|
-
command?: 'build' | 'serve';
|
|
42
|
-
/**
|
|
43
|
-
* Explicit dev-server port. Omit for a **per-worktree dynamic** free port (a fresh OS-assigned
|
|
44
|
-
* port) so N simultaneous git worktrees never collide on Vite's default `5173`; Vite prints the
|
|
45
|
-
* chosen URL. Pass a fixed number only when an external contract pins the port.
|
|
46
|
-
*/
|
|
47
|
-
port?: number;
|
|
48
|
-
/**
|
|
49
|
-
* Interface the dev server binds. Defaults to {@link LOOPBACK_V4} so a portless alias can reach it
|
|
50
|
-
* (Vite's own `localhost` default binds `[::1]` only, which the proxy cannot dial). Override when
|
|
51
|
-
* the dev server must be reachable off the loopback — `'0.0.0.0'` or `true` inside a container, on
|
|
52
|
-
* a LAN, or for an e2e runner on another host.
|
|
53
|
-
*/
|
|
54
|
-
host?: string | boolean;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Re-exported from the shared, dependency-light `lib/release-slug` module so the
|
|
58
|
-
* published `infra-kit/vite` surface (`entry/vite.ts:7`) is unchanged while the
|
|
59
|
-
* dev-server's fragment writer derives `<release>` from the SAME implementation
|
|
60
|
-
* (no slug drift). See {@link slugifyRelease}.
|
|
61
|
-
*/
|
|
62
|
-
export { slugifyRelease };
|
|
63
|
-
interface ResolveProxyArgs {
|
|
64
|
-
proxy: InfraKitDevProxy;
|
|
65
|
-
localSet: ReadonlySet<string>;
|
|
66
|
-
env: string | undefined;
|
|
67
|
-
getRelease: () => string;
|
|
68
|
-
/** Pre-computed `Authorization` header value applied uniformly to every route. */
|
|
69
|
-
authHeader?: string;
|
|
70
|
-
/** Per-package runtime data (recorded release/port) from the dev-context merge. */
|
|
71
|
-
localInfo?: ReadonlyMap<string, LocalPackageInfo>;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Pure resolver: turn a `dev.proxy` config + resolved inputs (local set, env,
|
|
75
|
-
* lazy release) into a Vite `server.proxy` map. Side-effect-free so the
|
|
76
|
-
* resolution shape is fully unit-testable. When `authHeader` is set, every route
|
|
77
|
-
* entry gets a matching `headers.Authorization`; otherwise no `headers` key.
|
|
78
|
-
*/
|
|
79
|
-
export declare const resolveProxyConfig: ({ proxy, localSet, env, getRelease, authHeader, localInfo, }: ResolveProxyArgs) => InfraKitViteProxy;
|
|
80
|
-
/**
|
|
81
|
-
* Load a package's `infra-kit.config.ts` and return its `dev` block, or
|
|
82
|
-
* `undefined` when the config or the `dev` key is absent. The `.ts` config is
|
|
83
|
-
* evaluated via Node's native type stripping (Node >= 24) — the same mechanism
|
|
84
|
-
* the CLI's config loader uses. Cache-busted by mtime so repeated dev-server
|
|
85
|
-
* reloads pick up edits.
|
|
86
|
-
*/
|
|
87
|
-
export declare const loadDev: (cwd: string) => Promise<InfraKitDev | undefined>;
|
|
88
|
-
/** Per-package runtime data merged from the dev-context fragment directory. */
|
|
89
|
-
export interface LocalPackageInfo {
|
|
90
|
-
/** The real bound port the runner recorded. Provenance only — the proxy target is the alias host. */
|
|
91
|
-
port: number;
|
|
92
|
-
/**
|
|
93
|
-
* The authoritative local target (`https://<release>.<packageName>.localhost`), published by the
|
|
94
|
-
* runner. Present → {@link resolveLocalTarget} uses it verbatim and consults no template. Absent →
|
|
95
|
-
* the fragment came from an old CLI and the legacy template path runs.
|
|
96
|
-
*/
|
|
97
|
-
origin?: string;
|
|
98
|
-
/** LEGACY (no `origin`): the runner-recorded release slug, preferred over the helper's git derivation. */
|
|
99
|
-
release?: string;
|
|
100
|
-
/** LEGACY (no `origin`): `<release>.<packageName>.localhost`, present only when an alias was registered. */
|
|
101
|
-
alias?: string;
|
|
102
|
-
/** LEGACY (no `origin`): the port {@link alias} resolves on. `80` (the default) is implicit in the template. */
|
|
103
|
-
proxyPort?: number;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* The locally-running package set plus a `package → { port, release }` map merged
|
|
107
|
-
* from the dev-context fragments. `packages` feeds `pickSource`; `info` lets a
|
|
108
|
-
* `local` route emit the per-package recorded release (see {@link resolveRoute}).
|
|
109
|
-
*/
|
|
110
|
-
export interface LocalContext {
|
|
111
|
-
packages: ReadonlySet<string>;
|
|
112
|
-
info: ReadonlyMap<string, LocalPackageInfo>;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Read the locally-running package context, searched upward from `cwd`. Prefers
|
|
116
|
-
* the `.infra-kit/dev-context/` fragment DIRECTORY (merged via
|
|
117
|
-
* {@link readFragmentDir}); when it is absent, falls back to the legacy single
|
|
118
|
-
* `.infra-kit/dev-context.json` file (read as before — no per-package release);
|
|
119
|
-
* when neither exists → empty context (frontend-only, every route resolves cloud).
|
|
120
|
-
*/
|
|
121
|
-
export declare const readLocalContext: (cwd: string) => LocalContext;
|
|
122
|
-
/**
|
|
123
|
-
* Read the set of locally-running packages (searched upward from `cwd`). Thin
|
|
124
|
-
* wrapper over {@link readLocalContext} preserving the historical `Set`-returning
|
|
125
|
-
* contract. Absent dev-context → empty set (frontend-only cloud resolution).
|
|
126
|
-
*/
|
|
127
|
-
export declare const readLocalSet: (cwd: string) => ReadonlySet<string>;
|
|
128
|
-
/**
|
|
129
|
-
* Vite's `server.hmr` override, pointing the HMR client at the alias instead of at the raw dev-server port.
|
|
130
|
-
* The page is loaded over `https://<alias>`, so its websocket must be `wss://` on the same origin or the
|
|
131
|
-
* browser blocks it as mixed content; `clientPort` is the proxy's implicit `:443`, not vite's bound port.
|
|
132
|
-
*/
|
|
133
|
-
export interface InfraKitViteHmr {
|
|
134
|
-
protocol: 'wss';
|
|
135
|
-
host: string;
|
|
136
|
-
clientPort: number;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Resolve a package's `dev` block into a ready-made Vite `server` config: a per-worktree dev-server
|
|
140
|
-
* `port` plus the `proxy` map. Loads the package's `infra-kit.config.ts`, merges the local dev set
|
|
141
|
-
* from the `.infra-kit/dev-context/` fragment directory, and interpolates the local/cloud templates.
|
|
142
|
-
* `<env>` comes from `INFRA_KIT_ENV`; `<release>` from each package's runner-recorded fragment when
|
|
143
|
-
* present, else the slugified git branch (computed lazily, only when a local route needs it).
|
|
144
|
-
*
|
|
145
|
-
* `port` defaults to a fresh OS-assigned free port so simultaneous git worktrees never collide on
|
|
146
|
-
* Vite's `5173` (override via `options.port`). `host` defaults to {@link LOOPBACK_V4} so the portless
|
|
147
|
-
* alias can actually reach it (override via `options.host` for containers/LAN). `hmr` is emitted only
|
|
148
|
-
* when `infra-kit dev` registered an alias for this UI, so a bare `vite dev` keeps vite's own HMR
|
|
149
|
-
* defaults. Pass `command` so `build` is a no-op (empty proxy, no port) — a build ignores `server` and
|
|
150
|
-
* proxy resolution would otherwise fail-fast on a cloud route with no sourced env.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* // vite.config.ts — the whole `server` field is the helper's output
|
|
154
|
-
* import { infraKitDev } from 'infra-kit/vite'
|
|
155
|
-
* export default defineConfig(async ({ command }) => ({ server: await infraKitDev({ command }) }))
|
|
156
|
-
*/
|
|
157
|
-
export declare const infraKitDev: (options?: InfraKitDevOptions) => Promise<{
|
|
158
|
-
port?: number;
|
|
159
|
-
host?: string | boolean;
|
|
160
|
-
strictPort?: boolean;
|
|
161
|
-
hmr?: InfraKitViteHmr;
|
|
162
|
-
proxy: InfraKitViteProxy;
|
|
163
|
-
}>;
|
|
164
|
-
/**
|
|
165
|
-
* Convenience wrapper returning just the proxy map (for spreading into
|
|
166
|
-
* `server.proxy` directly). Equivalent to `(await infraKitDev(options)).proxy`.
|
|
167
|
-
*/
|
|
168
|
-
export declare const infraKitProxy: (options?: InfraKitDevOptions) => Promise<InfraKitViteProxy>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{a as h,c as f}from"./chunk-JD5T4VCB.js";import{a as c}from"./chunk-FAR2L74S.js";import{render as W}from"ink";import A from"node:process";import{Box as m,Static as z,Text as l}from"ink";import{useEffect as F,useState as O}from"react";import{jsx as d,jsxs as R}from"react/jsx-runtime";var y=r=>{let{phase:e,narration:t,readyLines:i}=r,[s,a]=O(0);return F(()=>{if(i)return;let n=setInterval(()=>{a(o=>o+1)},T);return()=>{clearInterval(n)}},[i]),i?d(z,{items:i,children:(n,o)=>d(l,{children:n},o)}):R(m,{flexDirection:"column",children:[R(m,{children:[d(l,{color:"cyan",children:L[s%L.length]}),d(l,{dimColor:!0,children:` ${e}`})]}),t?d(l,{dimColor:!0,children:t}):null]})},L=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],T=80;import{Box as C,Static as E,Text as x}from"ink";import{Fragment as U,jsx as u,jsxs as N}from"react/jsx-runtime";var S=r=>{let{headerLines:e,logLines:t,footerLines:i}=r,s=[...e,...t],a=P(i,r.maxFooterLines);return N(U,{children:[u(E,{items:s,children:(n,o)=>u(x,{children:n},o)}),u(C,{flexDirection:"column",children:a.map((n,o)=>u(x,{children:n},o))})]})},P=(r,e)=>{if(e==null||e<1||r.length<=e)return r;let t=r.slice(0,e-1);return[...t,` \u2026 +${r.length-t.length} more`]};import H from"node:process";var _="\x1B[2K";var b="\x1B[?25h",I=(r,e)=>`\x1B[${r};${e}r`,w=()=>"\x1B[r",v=(r,e)=>`\x1B[${r};${e}H`,k=r=>r<=0?"":`${`
|
|
2
|
-
`.repeat(r)}\x1B[${r}A`,g=(r,e)=>{if(r.length===0)return"";let t=e-r.length+1;return`\x1B7${r.map((s,a)=>`${v(t+a,1)}${_}${s}`).join("")}\x1B8`},$=(r,e)=>e-r<1?"":`${k(r)}${I(1,e-r)}`;var p=class{renderer;stdout;verbose;footerLines=[];installed=!1;resizeBound=!1;constructor(e){this.verbose=e.verbose,this.stdout=e.stdout??H.stdout,this.renderer=new f({appendLog:e.appendLog,verbose:this.verbose,isTTY:!!this.stdout.isTTY,write:t=>{this.stdout.write(t)}})}logFn=(e,t="info")=>{this.log(e,t)};rows(){let e=this.stdout.rows;return e!=null&&e>0?e:24}writeLines(e){for(let t of e)this.stdout.write(`${t}
|
|
3
|
-
`)}narrate(e){this.renderer.teeOnly(e,"info"),this.verbose&&this.stdout.write(`${e}
|
|
4
|
-
`)}log(e,t="info"){(t!=="debug"||this.verbose)&&this.stdout.write(`${e}
|
|
5
|
-
`),this.renderer.teeOnly(e,t)}bootStep(e){this.narrate(e)}stopSpinner(){}applyRegion(){let e=this.rows(),t=$(this.footerLines.length,e);return t===""?!1:(this.stdout.write(`${t}${g(this.footerLines,e)}`),!0)}bindResize(){this.resizeBound||typeof this.stdout.on!="function"||(this.stdout.on("resize",this.onResize),this.resizeBound=!0)}ready(e){this.footerLines=this.renderer.formatReadyLines(e);for(let t of this.footerLines)this.renderer.teeOnly(t,"info");if(!this.stdout.isTTY){this.writeLines(this.footerLines);return}if(!this.applyRegion()){this.writeLines(this.footerLines);return}this.installed=!0,this.bindResize()}event(e){let t=` ${h(new Date)} ${e.tag} ${e.text}`;this.stdout.write(`${t}
|
|
6
|
-
`),this.renderer.teeOnly(`${e.tag} ${e.text}`,"info")}refresh(e){this.footerLines=this.renderer.formatReadyLines(e),this.installed&&this.stdout.write(g(this.footerLines,this.rows()))}onResize=()=>{this.installed&&(this.applyRegion()||this.dispose())};dispose(){if(this.resizeBound&&typeof this.stdout.off=="function"&&(this.stdout.off("resize",this.onResize),this.resizeBound=!1),this.installed){let e=this.rows();this.stdout.write(`${w()}${v(e,1)}
|
|
7
|
-
${b}`),this.installed=!1}}};import{jsx as D}from"react/jsx-runtime";var B=class{renderer;renderFn;stdout;verbose;now;appendLog;instance=null;finalized=!1;handoff=null;persistent=!1;phase="";narration="";headerLines=[];logLines=[];footerLines=[];constructor(e){this.verbose=e.verbose??!1,this.renderFn=e.render??W,this.stdout=e.stdout??c(A.stdout),this.appendLog=e.appendLog,this.now=e.now??(()=>new Date),this.renderer=new f({appendLog:e.appendLog,verbose:this.verbose,isTTY:!0,write:t=>{this.stdout.write(t)},now:this.now})}logFn=(e,t="info")=>{this.log(e,t)};renderBoot(e){let t=D(y,{phase:this.phase,narration:this.narration,readyLines:e});if(this.instance){this.instance.rerender(t);return}this.instance=this.renderFn(t,{stdout:this.stdout,exitOnCtrlC:!1,patchConsole:!1})}unmount(){this.instance&&(this.instance.unmount(),this.instance=null)}narrate(e){if(this.handoff){this.handoff.narrate(e);return}if(this.renderer.teeOnly(e,"info"),this.persistent){this.verbose&&(this.logLines.push(e),this.rerenderPersistent());return}this.finalized||(this.narration=e,this.instance&&this.renderBoot())}log(e,t="info"){if(this.handoff){this.handoff.log(e,t);return}let i=t!=="debug"||this.verbose;if(this.persistent){this.renderer.teeOnly(e,t),i&&(this.logLines.push(e),this.rerenderPersistent());return}i&&this.unmount(),this.renderer.log(e,t)}bootStep(e){this.renderer.teeOnly(e,"info"),!this.finalized&&(this.phase=e,this.renderBoot())}stopSpinner(){this.persistent||this.unmount()}ready(e){if(e.hasUiChild){this.readyHandoff(e);return}this.readyPersistent(e)}readyHandoff(e){this.finalized=!0,this.unmount(),this.handoff=new p({appendLog:this.appendLog,verbose:this.verbose,stdout:this.stdout}),this.handoff.ready(e)}readyPersistent(e){this.headerLines=this.renderer.formatHeaderLines(e),this.footerLines=this.renderer.formatFooterLines(e),this.logLines=[];for(let t of this.headerLines)this.renderer.teeOnly(t,"info");this.finalized=!0,this.persistent=!0,typeof this.stdout.on=="function"&&this.stdout.on("resize",this.onResize),this.rerenderPersistent()}maxFooterLines(){return Math.max(3,(this.stdout.rows??24)-6)}rerenderPersistent(){let e=D(S,{headerLines:this.headerLines,logLines:this.logLines,footerLines:this.footerLines,maxFooterLines:this.maxFooterLines()});if(this.instance){this.instance.rerender(e);return}this.instance=this.renderFn(e,{stdout:this.stdout,exitOnCtrlC:!1,patchConsole:!1})}onResize=()=>{this.persistent&&this.rerenderPersistent()};event(e){if(this.handoff){this.handoff.event(e);return}if(this.persistent){let t=` ${h(this.now())} ${e.tag} ${e.text}`;this.renderer.teeOnly(`${e.tag} ${e.text}`,"info"),this.logLines.push(t),this.rerenderPersistent();return}this.unmount(),this.renderer.event(e)}refresh(e){if(this.handoff){this.handoff.refresh(e);return}this.persistent&&(this.footerLines=this.renderer.formatFooterLines(e),this.rerenderPersistent())}dispose(){if(this.handoff){this.handoff.dispose(),this.handoff=null;return}this.persistent&&(this.rerenderPersistent(),typeof this.stdout.off=="function"&&this.stdout.off("resize",this.onResize)),this.finalized=!0,this.persistent=!1,this.unmount()}};export{B as PersistentInkDevUi};
|
|
8
|
-
//# sourceMappingURL=persistent-ink-dev-ui-FUJQDFNY.js.map
|