Append and delete Main.yaml
@@ -262,6 +262,27 @@ func runNew(args newArgs) error {
return fmt.Errorf("saving project: %w", err)
}
+ if proj.Runtime.Name() == "yaml" {
+ projFile := filepath.Join(root, "Pulumi.yaml")
+ f, err := ioutil.ReadFile(projFile)
+ if err != nil {
+ return fmt.Errorf("Could not find Pulumi.yaml: %w", err)
+ }
+ mainFile := filepath.Join(root, "Main.yaml")
+ m, err := ioutil.ReadFile(mainFile)
+ if err == nil {
+ combined := append(f, '\n')
+ combined = append(f, m...)
+ ioutil.WriteFile(projFile, combined, 0600)
+ err = os.Remove(mainFile)
+ if err != nil {
+ return fmt.Errorf("Could not remove Main.yaml: %w", err)
+ }
+ } else if !os.IsNotExist(err) {
+ return fmt.Errorf("Could not get Main.yaml", err)
+ }
+ }
+
// Create the stack, if needed.
if !args.generateOnly && s == nil {
if s, err = promptAndCreateStack(args.prompt,
