@@ -104,6 +104,7 @@ const resolveNames = (
104104 } )
105105
106106type PathConfig = {
107+ readonly dockerGitPath : string
107108 readonly authorizedKeysPath : string
108109 readonly envGlobalPath : string
109110 readonly envProjectPath : string
@@ -113,43 +114,72 @@ type PathConfig = {
113114 readonly outDir : string
114115}
115116
117+ type DefaultPathConfig = {
118+ readonly dockerGitPath : string
119+ readonly authorizedKeysPath : string
120+ readonly envGlobalPath : string
121+ readonly envProjectPath : string
122+ readonly codexAuthPath : string
123+ }
124+
125+ const resolveNormalizedSecretsRoot = ( value : string | undefined ) : string | undefined => {
126+ const trimmed = value ?. trim ( ) ?? ""
127+ return trimmed . length === 0 ? undefined : normalizeSecretsRoot ( trimmed )
128+ }
129+
130+ const buildDefaultPathConfig = (
131+ normalizedSecretsRoot : string | undefined ,
132+ projectSlug : string
133+ ) : DefaultPathConfig =>
134+ normalizedSecretsRoot === undefined
135+ ? {
136+ dockerGitPath : defaultTemplateConfig . dockerGitPath ,
137+ authorizedKeysPath : defaultTemplateConfig . authorizedKeysPath ,
138+ envGlobalPath : defaultTemplateConfig . envGlobalPath ,
139+ envProjectPath : defaultTemplateConfig . envProjectPath ,
140+ codexAuthPath : defaultTemplateConfig . codexAuthPath
141+ }
142+ : {
143+ dockerGitPath : normalizedSecretsRoot ,
144+ authorizedKeysPath : `${ normalizedSecretsRoot } /authorized_keys` ,
145+ envGlobalPath : `${ normalizedSecretsRoot } /global.env` ,
146+ envProjectPath : `${ normalizedSecretsRoot } /${ projectSlug } .env` ,
147+ codexAuthPath : `${ normalizedSecretsRoot } /codex`
148+ }
149+
116150const resolvePaths = (
117151 raw : RawOptions ,
118152 projectSlug : string ,
119153 repoPath : string
120154) : Either . Either < PathConfig , ParseError > =>
121155 Either . gen ( function * ( _ ) {
122- const secretsRoot = raw . secretsRoot ?. trim ( )
123- const normalizedSecretsRoot = secretsRoot === undefined || secretsRoot . length === 0
124- ? undefined
125- : normalizeSecretsRoot ( secretsRoot )
126- const defaultAuthorizedKeysPath = normalizedSecretsRoot === undefined
127- ? defaultTemplateConfig . authorizedKeysPath
128- : `${ normalizedSecretsRoot } /authorized_keys`
129- const defaultEnvGlobalPath = normalizedSecretsRoot === undefined
130- ? defaultTemplateConfig . envGlobalPath
131- : `${ normalizedSecretsRoot } /global.env`
132- const defaultEnvProjectPath = normalizedSecretsRoot === undefined
133- ? defaultTemplateConfig . envProjectPath
134- : `${ normalizedSecretsRoot } /${ projectSlug } .env`
135- const defaultCodexAuthPath = normalizedSecretsRoot === undefined
136- ? defaultTemplateConfig . codexAuthPath
137- : `${ normalizedSecretsRoot } /codex`
156+ const normalizedSecretsRoot = resolveNormalizedSecretsRoot ( raw . secretsRoot )
157+ const defaults = buildDefaultPathConfig ( normalizedSecretsRoot , projectSlug )
158+ const dockerGitPath = defaults . dockerGitPath
138159 const authorizedKeysPath = yield * _ (
139- nonEmpty ( "--authorized-keys" , raw . authorizedKeysPath , defaultAuthorizedKeysPath )
160+ nonEmpty ( "--authorized-keys" , raw . authorizedKeysPath , defaults . authorizedKeysPath )
140161 )
141- const envGlobalPath = yield * _ ( nonEmpty ( "--env-global" , raw . envGlobalPath , defaultEnvGlobalPath ) )
162+ const envGlobalPath = yield * _ ( nonEmpty ( "--env-global" , raw . envGlobalPath , defaults . envGlobalPath ) )
142163 const envProjectPath = yield * _ (
143- nonEmpty ( "--env-project" , raw . envProjectPath , defaultEnvProjectPath )
164+ nonEmpty ( "--env-project" , raw . envProjectPath , defaults . envProjectPath )
144165 )
145166 const codexAuthPath = yield * _ (
146- nonEmpty ( "--codex-auth" , raw . codexAuthPath , defaultCodexAuthPath )
167+ nonEmpty ( "--codex-auth" , raw . codexAuthPath , defaults . codexAuthPath )
147168 )
148169 const codexSharedAuthPath = codexAuthPath
149170 const codexHome = yield * _ ( nonEmpty ( "--codex-home" , raw . codexHome , defaultTemplateConfig . codexHome ) )
150171 const outDir = yield * _ ( nonEmpty ( "--out-dir" , raw . outDir , `.docker-git/${ repoPath } ` ) )
151172
152- return { authorizedKeysPath, envGlobalPath, envProjectPath, codexAuthPath, codexSharedAuthPath, codexHome, outDir }
173+ return {
174+ dockerGitPath,
175+ authorizedKeysPath,
176+ envGlobalPath,
177+ envProjectPath,
178+ codexAuthPath,
179+ codexSharedAuthPath,
180+ codexHome,
181+ outDir
182+ }
153183 } )
154184
155185// CHANGE: build a typed create command from raw options (CLI or API)
@@ -190,6 +220,7 @@ export const buildCreateCommand = (
190220 repoRef : repo . repoRef ,
191221 targetDir : repo . targetDir ,
192222 volumeName : names . volumeName ,
223+ dockerGitPath : paths . dockerGitPath ,
193224 authorizedKeysPath : paths . authorizedKeysPath ,
194225 envGlobalPath : paths . envGlobalPath ,
195226 envProjectPath : paths . envProjectPath ,
0 commit comments