diff --git a/package.json b/package.json index 6547281..37eb8e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/aio-cli-plugin-api-mesh", - "version": "5.6.1", + "version": "5.6.2", "description": "Adobe I/O CLI plugin to develop and manage API mesh sources", "keywords": [ "oclif-plugin" @@ -38,7 +38,7 @@ "version": "oclif-dev readme && git add README.md" }, "dependencies": { - "@adobe-apimesh/mesh-builder": "2.3.1", + "@adobe-apimesh/mesh-builder": "^2.4.0", "@adobe/aio-cli-lib-console": "^5.0.0", "@adobe/aio-lib-core-config": "^5.0.0", "@adobe/aio-lib-core-logging": "^3.0.0", diff --git a/src/commands/api-mesh/__tests__/run.test.js b/src/commands/api-mesh/__tests__/run.test.js index d8151ce..dd560c9 100644 --- a/src/commands/api-mesh/__tests__/run.test.js +++ b/src/commands/api-mesh/__tests__/run.test.js @@ -61,6 +61,7 @@ jest.mock('@adobe-apimesh/mesh-builder', () => { validateMesh: jest.fn().mockResolvedValue({}), buildMesh: jest.fn().mockResolvedValue({}), compileMesh: jest.fn().mockResolvedValue({}), + normalizeMeshConfig: jest.fn().mockResolvedValue({}), }, }; }); diff --git a/src/commands/api-mesh/run.js b/src/commands/api-mesh/run.js index 68a4b3c..bcbbe59 100644 --- a/src/commands/api-mesh/run.js +++ b/src/commands/api-mesh/run.js @@ -42,7 +42,7 @@ const { } = require('../../project'); const { resolveRelativeSources } = require('../../meshArtifact'); -const { validateMesh, buildMesh, compileMesh } = meshBuilder.default; +const { validateMesh, buildMesh, compileMesh, normalizeMeshConfig } = meshBuilder.default; class RunCommand extends Command { static summary = 'Run local development server'; @@ -188,8 +188,9 @@ class RunCommand extends Command { //Generating unique mesh id const meshId = 'testMesh'; - await validateMesh(data.meshConfig); - await buildMesh(meshId, data.meshConfig); + const normalizedMeshConfig = await normalizeMeshConfig(data.meshConfig); + await validateMesh(normalizedMeshConfig); + await buildMesh(meshId, normalizedMeshConfig); await compileMesh(meshId); // Resolve relative sources in built mesh for local development diff --git a/src/utils.js b/src/utils.js index fb0e05e..6890b72 100644 --- a/src/utils.js +++ b/src/utils.js @@ -196,6 +196,21 @@ function getFilesInMeshConfig(data, meshConfigName) { } }); + // Additional Type Defs + const additionalTypeDefs = + typeof data.meshConfig.additionalTypeDefs === 'string' + ? [data.meshConfig.additionalTypeDefs] + : data.meshConfig.additionalTypeDefs; + additionalTypeDefs?.forEach(additionalTypeDef => { + if ( + typeof additionalTypeDef === 'string' && + !fileURLRegex.test(additionalTypeDef) && + (additionalTypeDef.endsWith('.graphql') || additionalTypeDef.endsWith('.gql')) + ) { + filesList.push(additionalTypeDef); + } + }); + // ReplaceField Transform - source level data.meshConfig.sources.transforms?.forEach(transform => { transform.replaceField?.replacements.forEach(replacement => { @@ -398,7 +413,7 @@ function validateFileType(filesList) { filesList.forEach(file => { const extension = path.extname(file); - const isValidFileType = ['.js', '.json', '.graphql'].includes(extension); + const isValidFileType = ['.js', '.json', '.graphql', '.gql'].includes(extension); if (!isValidFileType) { filesWithInvalidTypes.push(path.basename(file)); diff --git a/yarn.lock b/yarn.lock index f71124b..db0114e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,10 +7,10 @@ resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== -"@adobe-apimesh/mesh-builder@2.3.1": - version "2.3.1" - resolved "https://registry.yarnpkg.com/@adobe-apimesh/mesh-builder/-/mesh-builder-2.3.1.tgz#72e0cc90bf145078eeae7597aa8d4551592805b2" - integrity sha512-r0FR2AFYk5ZmIMWivfTmA3D/k3wRJZAFb5ur3mR3+t3LK6z091PfHcm9jBJV2pkNLmJV8C7xy35YMZHJD2O2Jg== +"@adobe-apimesh/mesh-builder@^2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@adobe-apimesh/mesh-builder/-/mesh-builder-2.4.0.tgz#35fc8ae0ecd5617cfdb585cb923bf0112ad4d56f" + integrity sha512-MnvojKskFRY/wVy1Sh5xVOTgA4c3pi8jU9CtihljjrVNqp0DxkKhcCGvD5UJf5gnqOCnyFcEhDQ6CObZP8tEAw== dependencies: "@fastify/request-context" "^4.1.0" eslint "^8.39.0"