@@ -200,6 +200,69 @@ const resolvePaths = (
200200 }
201201 } )
202202
203+ type CreateBehavior = {
204+ readonly runUp : boolean
205+ readonly openSsh : boolean
206+ readonly force : boolean
207+ readonly forceEnv : boolean
208+ readonly enableMcpPlaywright : boolean
209+ }
210+
211+ const resolveCreateBehavior = ( raw : RawOptions ) : CreateBehavior => ( {
212+ runUp : raw . up ?? true ,
213+ openSsh : raw . openSsh ?? false ,
214+ force : raw . force ?? false ,
215+ forceEnv : raw . forceEnv ?? false ,
216+ enableMcpPlaywright : raw . enableMcpPlaywright ?? false
217+ } )
218+
219+ type BuildTemplateConfigInput = {
220+ readonly repo : RepoBasics
221+ readonly names : NameConfig
222+ readonly paths : PathConfig
223+ readonly dockerNetworkMode : CreateCommand [ "config" ] [ "dockerNetworkMode" ]
224+ readonly dockerSharedNetworkName : string
225+ readonly gitTokenLabel : string | undefined
226+ readonly codexAuthLabel : string | undefined
227+ readonly claudeAuthLabel : string | undefined
228+ readonly enableMcpPlaywright : boolean
229+ }
230+
231+ const buildTemplateConfig = ( {
232+ claudeAuthLabel,
233+ codexAuthLabel,
234+ dockerNetworkMode,
235+ dockerSharedNetworkName,
236+ enableMcpPlaywright,
237+ gitTokenLabel,
238+ names,
239+ paths,
240+ repo
241+ } : BuildTemplateConfigInput ) : CreateCommand [ "config" ] => ( {
242+ containerName : names . containerName ,
243+ serviceName : names . serviceName ,
244+ sshUser : repo . sshUser ,
245+ sshPort : repo . sshPort ,
246+ repoUrl : repo . repoUrl ,
247+ repoRef : repo . repoRef ,
248+ gitTokenLabel,
249+ codexAuthLabel,
250+ claudeAuthLabel,
251+ targetDir : repo . targetDir ,
252+ volumeName : names . volumeName ,
253+ dockerGitPath : paths . dockerGitPath ,
254+ authorizedKeysPath : paths . authorizedKeysPath ,
255+ envGlobalPath : paths . envGlobalPath ,
256+ envProjectPath : paths . envProjectPath ,
257+ codexAuthPath : paths . codexAuthPath ,
258+ codexSharedAuthPath : paths . codexSharedAuthPath ,
259+ codexHome : paths . codexHome ,
260+ dockerNetworkMode,
261+ dockerSharedNetworkName,
262+ enableMcpPlaywright,
263+ pnpmVersion : defaultTemplateConfig . pnpmVersion
264+ } )
265+
203266// CHANGE: build a typed create command from raw options (CLI or API)
204267// WHY: share deterministic command construction across CLI and server
205268// QUOTE(ТЗ): "В lib ты оставляешь бизнес логику, а все CLI морду хранишь в app"
@@ -217,11 +280,7 @@ export const buildCreateCommand = (
217280 const repo = yield * _ ( resolveRepoBasics ( raw ) )
218281 const names = yield * _ ( resolveNames ( raw , repo . projectSlug ) )
219282 const paths = yield * _ ( resolvePaths ( raw , repo . repoPath ) )
220- const runUp = raw . up ?? true
221- const openSsh = raw . openSsh ?? false
222- const force = raw . force ?? false
223- const forceEnv = raw . forceEnv ?? false
224- const enableMcpPlaywright = raw . enableMcpPlaywright ?? false
283+ const behavior = resolveCreateBehavior ( raw )
225284 const gitTokenLabel = normalizeGitTokenLabel ( raw . gitTokenLabel )
226285 const codexAuthLabel = normalizeAuthLabel ( raw . codexTokenLabel )
227286 const claudeAuthLabel = normalizeAuthLabel ( raw . claudeTokenLabel )
@@ -233,34 +292,21 @@ export const buildCreateCommand = (
233292 return {
234293 _tag : "Create" ,
235294 outDir : paths . outDir ,
236- runUp,
237- openSsh,
238- force,
239- forceEnv,
295+ runUp : behavior . runUp ,
296+ openSsh : behavior . openSsh ,
297+ force : behavior . force ,
298+ forceEnv : behavior . forceEnv ,
240299 waitForClone : false ,
241- config : {
242- containerName : names . containerName ,
243- serviceName : names . serviceName ,
244- sshUser : repo . sshUser ,
245- sshPort : repo . sshPort ,
246- repoUrl : repo . repoUrl ,
247- repoRef : repo . repoRef ,
300+ config : buildTemplateConfig ( {
301+ repo,
302+ names,
303+ paths,
304+ dockerNetworkMode,
305+ dockerSharedNetworkName,
248306 gitTokenLabel,
249307 codexAuthLabel,
250308 claudeAuthLabel,
251- targetDir : repo . targetDir ,
252- volumeName : names . volumeName ,
253- dockerGitPath : paths . dockerGitPath ,
254- authorizedKeysPath : paths . authorizedKeysPath ,
255- envGlobalPath : paths . envGlobalPath ,
256- envProjectPath : paths . envProjectPath ,
257- codexAuthPath : paths . codexAuthPath ,
258- codexSharedAuthPath : paths . codexSharedAuthPath ,
259- codexHome : paths . codexHome ,
260- dockerNetworkMode,
261- dockerSharedNetworkName,
262- enableMcpPlaywright,
263- pnpmVersion : defaultTemplateConfig . pnpmVersion
264- }
309+ enableMcpPlaywright : behavior . enableMcpPlaywright
310+ } )
265311 }
266312 } )
0 commit comments