🌳
pt0/deployF/k8sF/ctxF/appCfgCtxF.mts
1import { type importMetaUrlType } from "../../../ptDirF.mts";
4import type { NodePortsCfg } from "./klusterCtxF.mts";
6import type { Ptenv } from "../../../sharedF/ptenvF.mts";
8export type GqlTestDiagnostics = {timedOut?: boolean, gqlRequestSent?: boolean, gqlRespHadError?: boolean, gqlRespErrSnip?: string}
10export type HealthgqlTestResult = {
11 resultsH: Record<string, boolean>
12 responsesH?: Record<string, unknown>
13 diagnosticsH?: Record<string, GqlTestDiagnostics>
14 hostname?: string
15 gqlPath?: string
18export type HealthgqlTestFnc = (opts: {
19 ptenv: Ptenv
20 devHost: string
21 deployedHostname: string | null
22}) => Promise<HealthgqlTestResult>
24export type AppCfgCore = {
25 action?: string
26 name?: string
27 importMetaUrl?: importMetaUrlType
28 appPath?: string
29 cluster_name?: string
32export type DockerBuildCfg = {
33 dockreg_host?: string
34 dockLanHost?: string
35 git_sha?: string
36 buildSha?: string
37 git_repo_name?: string
38 gitsshHost?: string
39 gitsshRepoPath?: string
40 gitsshHttpsHostname?: string
41 dockerFilesA?: object[]
42 dockerBuilder?: () => Promise<object[]>
43 kanikoClusterName?: string
44 kanikoLocalContext?: boolean
45 imageReused?: boolean
46 bundle?: boolean
47 nativeInstallPackages?: string[]
50export type K8sDeployCfg = {
51 svcPortNo?: number
52 testSvcPortNo?: number
53 secretNames?: string[]
54 envConf?: object
55 resourceTmpl?: object
56 ingressAnnotationsH?: Record<string, string>
57 allKlusters?: Record<string, object>
58 allNodePorts?: Record<string, NodePortsCfg>
61export type HealthTestCfg = {
62 deployedBaseUrl?: string
63 healthgqlTestFnc?: HealthgqlTestFnc
64 healthgqlTestPath?: string
65 healthgqlTestEnvH?: Record<string, string>
66 healthgqlDevHost?: string
67 pubEnvRequiredKeys?: string[]
68 mkTestGqlFetch?: (ptenv: Ptenv) => Promise<{
69 fetch: (opts: {baseUrl: string, query: string, variables?: Record<string, unknown>, gqUserTok?: string}) => Promise<{data?: Record<string, unknown>, errors?: unknown[]}>
70 mapKey: (plainKey: string) => string
71 }>
74export type CodeAnalysisCfg = {
75 getVirtualPathsFnc?: () => Promise<string[]>
76 inclPtPathA?: string[]
77 inclContentH?: Record<string, string>
78 inclServer?: boolean
79 epPtPathsA?: string[]
80 usesExplicitEpPtPaths?: boolean
81 forbidImportWordsA?: string[]
82 forbidInsensStrA?: string[]
83 madgeH?: Record<string, string[]>
84 madgeEpPtPathsA?: string[]
87export type HostnameCfg = {
88 wcHostname?: string
89 nonWcHostname?: string
90 kube_extHostname?: string
91 testAgainstHn?: string
92 cfProxied?: boolean
93 hostedAtUrl?: string
96export type AppCfgMisc = {
97 prebuildEnvConfH?: Record<string, string>
98 nextBuildHeapMb?: number
99 kanikoCpuLimit?: string
100 defaultSsTz?: string
101 publicJsonH?: object
102 ptSubdir?: string
103 monorSubdir?: string
104 deployEp?: string
105 dbQsCfg?: object
106 existingGitSha?: string
107 shouldStorBktForImmut?: (props: any) => Promise<Record<string, boolean>>
108 appMarker?: string
109 sharedImageEps?: string[]
112/** App deployment config - changes per-entrypoint */
113export type AppCfg = AppCfgCore & DockerBuildCfg & K8sDeployCfg & HealthTestCfg & CodeAnalysisCfg & HostnameCfg & AppCfgMisc
115/** @deprecated Use AppCfg instead */
116export type appCfgType = object & {
117 readonly __brand: unique symbol
118 importMetaUrl: importMetaUrlType
119 appPath: string
124const _appCfgCtx = genContext<AppCfg>()
125export const appCfgCtx = {
126 getStore: () => _appCfgCtx.getStore(),
127 enterWith: (cfg: AppCfg) => { _appCfgCtx.enterWith(cfg); captureSaveExampleMeta(cfg as Record<string, unknown>) },
128 run: (cfg: AppCfg, fn: () => Promise<unknown>) => _appCfgCtx.run(cfg, fn),
131/** Get appCfg with action always populated (backward compat) */
132export const getAppCfg = (): AppCfg => {
133 const store = appCfgCtx.getStore() ?? {}
134 return {...store, action: store.action ?? getAction()}
137/** Get appCfg, throwing if context not set */
138export const getReqAppCfg = (): AppCfg => {
139 const store = appCfgCtx.getStore()
141 return {...store, action: store.action ?? getAction()}