@@ -98,9 +98,26 @@ func CreateModuleAction(c *cli.Context) error {
98
98
if err != nil {
99
99
return err
100
100
}
101
- // Check to make sure the user doesn't accidentally overwrite a module manifest
101
+
102
+ shouldWriteNewEmptyManifest := true
103
+
104
+ // If a meta.json exists in the current directory, we have a slightly different creation flow
105
+ // in order to minimize user frustration. We will continue the creation if the args passed to create
106
+ // match the values in the meta.json
102
107
if _ , err := os .Stat (defaultManifestFilename ); err == nil {
103
- return errors .New ("another module's meta.json already exists in the current directory. Delete it and try again" )
108
+ modManifest , err := loadManifest (defaultManifestFilename )
109
+ if err != nil {
110
+ return errors .New ("another meta.json already exists in the current directory. Delete it and try again" )
111
+ }
112
+ manifestModuleID , err := parseModuleID (modManifest .ModuleID )
113
+ if err != nil ||
114
+ manifestModuleID .name != moduleNameArg ||
115
+ (manifestModuleID .prefix != org .GetId () && manifestModuleID .prefix != org .GetPublicNamespace ()) {
116
+ return errors .Errorf ("a different module's meta.json already exists in the current directory. " +
117
+ "Either delete that meta.json, or edit its module_id (%q) to match the args passed to this command" ,
118
+ modManifest .ModuleID )
119
+ }
120
+ shouldWriteNewEmptyManifest = false
104
121
}
105
122
106
123
response , err := client .createModule (moduleNameArg , org .GetId ())
@@ -117,20 +134,22 @@ func CreateModuleAction(c *cli.Context) error {
117
134
if response .GetUrl () != "" {
118
135
printf (c .App .Writer , "You can view it here: %s" , response .GetUrl ())
119
136
}
120
- emptyManifest := moduleManifest {
121
- ModuleID : returnedModuleID .String (),
122
- Visibility : moduleVisibilityPrivate ,
123
- // This is done so that the json has an empty example
124
- Models : []ModuleComponent {
125
- {},
126
- },
127
- // TODO(RSDK-5608) don't auto populate until we are ready to release the build subcommand
128
- // Build: defaultBuildInfo,
129
- }
130
- if err := writeManifest (defaultManifestFilename , emptyManifest ); err != nil {
131
- return err
137
+
138
+ if shouldWriteNewEmptyManifest {
139
+ emptyManifest := moduleManifest {
140
+ ModuleID : returnedModuleID .String (),
141
+ Visibility : moduleVisibilityPrivate ,
142
+ // This is done so that the json has an empty example
143
+ Models : []ModuleComponent {
144
+ {},
145
+ },
146
+ }
147
+ if err := writeManifest (defaultManifestFilename , emptyManifest ); err != nil {
148
+ return err
149
+ }
150
+
151
+ printf (c .App .Writer , "Configuration for the module has been written to meta.json" )
132
152
}
133
- printf (c .App .Writer , "Configuration for the module has been written to meta.json" )
134
153
return nil
135
154
}
136
155
0 commit comments