You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* rough cut of PaaS import
* setup protos
* use fabric for llm invocations
* s/DeriveCompose/GenerateCompose/g
* retry if compose file is not valid yaml
* refactor to expose mockable surveyor interface
* upgrade secret-detector
* fix: correct retry behavior in generateComposeFile and fix test expectations
* remove secrets from config vars before sending to server
* update defang vendor hash
* remove version from generated compose file
* write compose file after generating it
* factor out surveyor package
* avoid proto getter
* handle windows newlines
* avoid stat before write--open with O_CREAT & O_EXCL
* use any instead of interface{}
* refactor extractFirstCodeBlock to return an error if code block is not found or incomplete
* use our http client, and reduce timeout
* refactor SourcePlatform type to support cobra help text
* prefix SourcePlatform
* rename proto enum avlue
* generate cmd ctx
* factor out handleGenerate
* combine new and setup commands
* use init as the primary name for new command
* factor out afterGenerate
* promote const
* remove redundant test if sample exists. cli.InitFromSamples already handles this
* promote default folder derivation
* extract promptForSample
* extract beforeGenerate
* partition sample and generate code paths
* invert handleGenerate so that cloneSample prompts and delegates to ai generate if necessary
* invoke cloneFromSample, aiGenerate, and migrateFromHerok in init
* fold beforeGenerateWithAI back into aiGenerate
* use a constant for tracking event name
* fold beforeGenerateFromSample back into cloneSample
* rename setup pkg to migrate
* move setup code into setup package
* fix panic
* add managed db tags to generate heroku compose file
* improve prompt for heroku auth token
Co-authored-by: Lio李歐 <[email protected]>
* preserve comments when cleaning yaml
* automatically generate heroku token
* interactive login before heroku migration
---------
Co-authored-by: Lio李歐 <[email protected]>
sourcePlatform=migrate.SourcePlatformUnspecified// default to auto-detecting the source platform
46
49
doDebug=false
47
50
hasTty=term.IsTerminal() &&!pkg.GetenvBool("CI")
48
51
hideUpdate=pkg.GetenvBool("DEFANG_HIDE_UPDATE")
@@ -227,7 +230,9 @@ func SetupCommands(ctx context.Context, version string) {
227
230
// Generate Command
228
231
generateCmd.Flags().StringVar(&modelId, "model", modelId, "LLM model to use for generating the code (Pro users only)")
229
232
RootCmd.AddCommand(generateCmd)
230
-
RootCmd.AddCommand(newCmd)
233
+
// new command
234
+
initCmd.PersistentFlags().Var(&sourcePlatform, "from", fmt.Sprintf(`the platform from which to migrate the project; one of %v`, migrate.AllSourcePlatforms))
235
+
RootCmd.AddCommand(initCmd)
231
236
232
237
// Get Services Command
233
238
lsCommand:=makeComposePsCmd()
@@ -507,205 +512,101 @@ var certGenerateCmd = &cobra.Command{
507
512
},
508
513
}
509
514
515
+
funcafterGenerate(ctx context.Context, result setup.SetupResult) {
516
+
term.Info("Code generated successfully in folder", result.Folder)
517
+
editor:=pkg.Getenv("EDITOR", "code")
518
+
cmdd:=exec.Command(editor, result.Folder)
519
+
err:=cmdd.Start()
520
+
iferr!=nil {
521
+
term.Debugf("unable to launch editor %q: %v", editor, err)
522
+
}
523
+
524
+
cd:=""
525
+
ifresult.Folder!="." {
526
+
cd="`cd "+result.Folder+"` and "
527
+
}
528
+
529
+
// Load the project and check for empty environment variables
Message: "Please describe the service you'd like to build:",
580
-
Help: `Here are some example prompts you can use:
581
-
"A simple 'hello world' function"
582
-
"A service with 2 endpoints, one to upload and the other to download a file from AWS S3"
583
-
"A service with a default endpoint that returns an HTML page with a form asking for the user's name and then a POST endpoint to handle the form post when the user clicks the 'submit' button"`,
584
-
},
585
-
Validate: survey.MinLength(5),
586
-
},
587
-
{
588
-
Name: "folder",
589
-
Prompt: &survey.Input{
590
-
Message: "What folder would you like to create the project in?",
591
-
Default: defaultFolder, // dynamically set based on chosen sample
592
-
Help: "The generated code will be in the folder you choose here. If the folder does not exist, it will be created.",
593
-
},
594
-
Validate: survey.Required,
595
-
},
596
-
}
597
-
598
-
ifsample!="" {
599
-
qs=qs[1:] // user picked a sample, so we skip the description question
0 commit comments