diff --git a/packages/cli/generators/relation/index.js b/packages/cli/generators/relation/index.js index 0c7cb5703e50..65512c8316c6 100644 --- a/packages/cli/generators/relation/index.js +++ b/packages/cli/generators/relation/index.js @@ -230,6 +230,27 @@ module.exports = class RelationGenerator extends ArtifactGenerator { /* istanbul ignore next */ return this.exit(err); } + // Check if modelDir contains subdirectories + const subdirectories = await utils.getSubdirectories( + this.artifactInfo.modelDir, + ); + // If subdirectories exist, retrieve models from them + if (subdirectories.length > 0) { + for (const subdirectory of subdirectories) { + try { + const subdirectoryModelList = await utils.getArtifactList( + subdirectory, + 'model', + ); + modelList = modelList.concat(subdirectoryModelList); + } catch (err) { + // Handle errors for subdirectory model retrieval + console.error( + `Error retrieving models from subdirectory ${subdirectory}: ${err}`, + ); + } + } + } let repoList; try { debug(`repository list dir ${this.artifactInfo.repoDir}`);