@@ -19,36 +19,27 @@ export type CreateFlowContext = {
1919 readonly projectsRoot ?: string | undefined
2020}
2121
22- type TokenQuote = "'" | "\""
23-
24- type TokenizerState = {
25- current : string
26- escaping : boolean
27- quote : TokenQuote | null
28- readonly tokens : Array < string >
29- }
30-
3122export type CreateFlowView = {
3223 readonly step : number
3324 readonly buffer : string
3425 readonly values : Partial < CreateInputs >
3526}
3627
37- export type AdvanceCreateFlowResult =
28+ type AdvanceCreateFlowResult =
3829 | { readonly _tag : "Continue" ; readonly view : CreateFlowView }
3930 | { readonly _tag : "Error" ; readonly error : ParseError }
4031 | { readonly _tag : "Complete" ; readonly inputs : CreateInputs }
4132
42- type AdvanceCreateFlowOptions = {
43- readonly quickCreate ?: boolean
44- }
45-
4633type AdvanceCreateFlowHandlers = {
4734 readonly onComplete : ( inputs : CreateInputs ) => void
4835 readonly onContinue : ( view : CreateFlowView ) => void
4936 readonly onError : ( error : ParseError ) => void
5037}
5138
39+ type AdvanceCreateFlowOptions = {
40+ readonly quickCreate ?: boolean
41+ }
42+
5243const trimLeftSlash = ( value : string ) : string => {
5344 let start = 0
5445 while ( start < value . length && value [ start ] === "/" ) {
@@ -154,22 +145,21 @@ const createParseError = (reason: string): ParseError => ({
154145 reason
155146} )
156147
157- const pushCreateToken = ( state : TokenizerState ) : void => {
148+ type CreateTokenizeState = {
149+ current : string
150+ escaping : boolean
151+ quote : "'" | "\"" | null
152+ readonly tokens : Array < string >
153+ }
154+
155+ const pushCreateToken = ( state : CreateTokenizeState ) : void => {
158156 if ( state . current . length > 0 ) {
159157 state . tokens . push ( state . current )
160158 state . current = ""
161159 }
162160}
163161
164- const consumeQuotedCreateTokenChar = ( state : TokenizerState , char : string ) : void => {
165- if ( char === state . quote ) {
166- state . quote = null
167- return
168- }
169- state . current += char
170- }
171-
172- const consumeCreateTokenChar = ( state : TokenizerState , char : string ) : void => {
162+ const consumeCreateTokenChar = ( state : CreateTokenizeState , char : string ) : void => {
173163 if ( state . escaping ) {
174164 state . current += char
175165 state . escaping = false
@@ -180,7 +170,11 @@ const consumeCreateTokenChar = (state: TokenizerState, char: string): void => {
180170 return
181171 }
182172 if ( state . quote !== null ) {
183- consumeQuotedCreateTokenChar ( state , char )
173+ if ( char === state . quote ) {
174+ state . quote = null
175+ return
176+ }
177+ state . current += char
184178 return
185179 }
186180 if ( char === "'" || char === "\"" ) {
@@ -197,7 +191,7 @@ const consumeCreateTokenChar = (state: TokenizerState, char: string): void => {
197191const tokenizeCreateCommandLine = (
198192 input : string
199193) : Either . Either < ReadonlyArray < string > , ParseError > => {
200- const state : TokenizerState = { current : "" , escaping : false , quote : null , tokens : [ ] }
194+ const state : CreateTokenizeState = { current : "" , escaping : false , quote : null , tokens : [ ] }
201195
202196 for ( const char of input . trim ( ) ) {
203197 consumeCreateTokenChar ( state , char )
@@ -259,22 +253,40 @@ const normalizeCreateTokens = (
259253 return Either . right ( withoutBinary )
260254}
261255
256+ type RawCreateOptions = Parameters < typeof buildCreateCommand > [ 0 ]
257+
258+ const cpuLimitCreateInput = ( raw : RawCreateOptions , command : CreateCommand ) : Partial < CreateInputs > =>
259+ raw . cpuLimit === undefined ? { } : { cpuLimit : command . config . cpuLimit ?? "" }
260+
261+ const ramLimitCreateInput = ( raw : RawCreateOptions , command : CreateCommand ) : Partial < CreateInputs > =>
262+ raw . ramLimit === undefined ? { } : { ramLimit : command . config . ramLimit ?? "" }
263+
264+ const runUpCreateInput = ( raw : RawCreateOptions , command : CreateCommand ) : Partial < CreateInputs > =>
265+ raw . up === undefined ? { } : { runUp : command . runUp }
266+
267+ const playwrightCreateInput = ( raw : RawCreateOptions , command : CreateCommand ) : Partial < CreateInputs > =>
268+ raw . enableMcpPlaywright === undefined ? { } : { enableMcpPlaywright : command . config . enableMcpPlaywright }
269+
270+ const forceCreateInput = ( raw : RawCreateOptions , command : CreateCommand ) : Partial < CreateInputs > =>
271+ raw . force === undefined ? { } : { force : command . force }
272+
273+ const forceEnvCreateInput = ( raw : RawCreateOptions , command : CreateCommand ) : Partial < CreateInputs > =>
274+ raw . forceEnv === undefined ? { } : { forceEnv : command . forceEnv }
275+
262276const createInputsFromCommand = (
263277 repoUrl : string ,
264- raw : Parameters < typeof buildCreateCommand > [ 0 ] ,
278+ raw : RawCreateOptions ,
265279 command : CreateCommand
266280) : Partial < CreateInputs > => ( {
267281 repoUrl,
268282 repoRef : command . config . repoRef ,
269283 outDir : command . outDir ,
270- ...( raw . cpuLimit === undefined ? { } : { cpuLimit : command . config . cpuLimit ?? "" } ) ,
271- ...( raw . ramLimit === undefined ? { } : { ramLimit : command . config . ramLimit ?? "" } ) ,
272- ...( raw . up === undefined ? { } : { runUp : command . runUp } ) ,
273- ...( raw . enableMcpPlaywright === undefined
274- ? { }
275- : { enableMcpPlaywright : command . config . enableMcpPlaywright } ) ,
276- ...( raw . force === undefined ? { } : { force : command . force } ) ,
277- ...( raw . forceEnv === undefined ? { } : { forceEnv : command . forceEnv } )
284+ ...cpuLimitCreateInput ( raw , command ) ,
285+ ...ramLimitCreateInput ( raw , command ) ,
286+ ...runUpCreateInput ( raw , command ) ,
287+ ...playwrightCreateInput ( raw , command ) ,
288+ ...forceCreateInput ( raw , command ) ,
289+ ...forceEnvCreateInput ( raw , command )
278290} )
279291
280292const parseRepoStepInput = (
@@ -304,7 +316,10 @@ const parseRepoStepInput = (
304316 } )
305317}
306318
307- const createStepApplied = ( ) : Either . Either < true , ParseError > => Either . right ( true )
319+ const createStepApplied = ( ) : Either . Either < true , ParseError > => {
320+ const applied = true
321+ return Either . right ( applied )
322+ }
308323
309324const hasOwn = ( values : Partial < CreateInputs > , key : keyof CreateInputs ) : boolean =>
310325 Object . prototype . hasOwnProperty . call ( values , key )
0 commit comments