From c6b812c0381a5a0eb72254ee4148e296b9784318 Mon Sep 17 00:00:00 2001 From: ajaz Date: Fri, 18 Jul 2025 16:58:48 +0530 Subject: [PATCH 01/18] feat: added active flag --- src/commands/api-mesh/__tests__/get.test.js | 136 +++++++++++++++++++- src/commands/api-mesh/get.js | 31 +++-- src/commands/api-mesh/source/install.js | 2 +- src/lib/smsClient.js | 43 +++++-- src/utils.js | 7 + 5 files changed, 199 insertions(+), 20 deletions(-) diff --git a/src/commands/api-mesh/__tests__/get.test.js b/src/commands/api-mesh/__tests__/get.test.js index 7c9a1370..c608a737 100644 --- a/src/commands/api-mesh/__tests__/get.test.js +++ b/src/commands/api-mesh/__tests__/get.test.js @@ -47,6 +47,7 @@ describe('get command tests', () => { beforeEach(() => { initSdk.mockResolvedValue({ imsOrgId: selectedOrg.id, + imsOrgCode: selectedOrg.code, projectId: selectedProject.id, workspaceId: selectedWorkspace.id, workspaceName: selectedWorkspace.title, @@ -79,7 +80,9 @@ describe('get command tests', () => { }); test('snapshot get command', () => { - expect(GetCommand.description).toMatchInlineSnapshot(`"Get the config of a given mesh"`); + expect(GetCommand.description).toMatchInlineSnapshot( + `"Get the config of a given mesh. Use --active flag to retrieve the last successfully deployed mesh config"`, + ); expect(GetCommand.args).toMatchInlineSnapshot(` [ { @@ -89,6 +92,14 @@ describe('get command tests', () => { `); expect(GetCommand.flags).toMatchInlineSnapshot(` { + "active": { + "allowNo": false, + "char": "a", + "default": false, + "description": "Retrieve the last successfully deployed mesh config", + "parse": [Function], + "type": "boolean", + }, "ignoreCache": { "allowNo": false, "char": "i", @@ -402,4 +413,127 @@ describe('get command tests', () => { `); expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`); }); + + // Active flag test cases + test('should get last successfully mesh config with --active flag', async () => { + const meshId = 'dummy_meshId'; + getMeshId.mockResolvedValueOnce(meshId); + getMesh.mockResolvedValueOnce({ + meshId: 'dummy_meshId', + mesh: mockGetMeshConfig, + }); + + parseSpy.mockResolvedValueOnce({ + args: {}, + flags: { + ignoreCache: mockIgnoreCacheFlag, + active: true, + }, + }); + + const runResult = await GetCommand.run(); + + expect(getMesh).toHaveBeenCalledWith( + selectedOrg.code, + selectedProject.id, + selectedWorkspace.id, + selectedWorkspace.title, + meshId, + true, + ); + + expect(runResult).toBeDefined(); + expect(runResult.meshId).toBe('dummy_meshId'); + }); + + test('should get last successfully mesh config with shorthand -a flag', async () => { + const meshId = 'dummy_meshId'; + getMeshId.mockResolvedValueOnce(meshId); + getMesh.mockResolvedValueOnce({ + meshId: 'dummy_meshId', + mesh: mockGetMeshConfig, + }); + + parseSpy.mockResolvedValueOnce({ + args: {}, + flags: { + ignoreCache: mockIgnoreCacheFlag, + active: true, // -a flag also sets active to true + }, + }); + + const runResult = await GetCommand.run(); + + expect(getMesh).toHaveBeenCalledWith( + selectedOrg.code, + selectedProject.id, + selectedWorkspace.id, + selectedWorkspace.title, + meshId, + true, + ); + + expect(runResult).toBeDefined(); + expect(runResult.meshId).toBe('dummy_meshId'); + }); + + test('should handle NoActiveDeploymentFound error when using --active flag', async () => { + const meshId = 'dummy_meshId'; + getMeshId.mockResolvedValueOnce(meshId); + getMesh.mockRejectedValueOnce(new Error('NoActiveDeploymentFound')); + + parseSpy.mockResolvedValueOnce({ + args: {}, + flags: { + ignoreCache: mockIgnoreCacheFlag, + active: true, + }, + }); + + const runResult = GetCommand.run(); + + return runResult.catch(err => { + expect(err.message).toMatchInlineSnapshot( + `"No active deployment found for mesh dummy_meshId. Check the mesh ID and try again or try without --active flag to get the mesh config. RequestId: dummy_request_id"`, + ); + expect(getMesh).toHaveBeenCalledWith( + selectedOrg.code, + selectedProject.id, + selectedWorkspace.id, + selectedWorkspace.title, + meshId, + true, + ); + }); + }); + + test('should handle mesh not found when using --active flag', async () => { + const meshId = 'dummy_meshId'; + getMeshId.mockResolvedValueOnce(meshId); + getMesh.mockResolvedValueOnce(null); // Mesh not found + + parseSpy.mockResolvedValueOnce({ + args: {}, + flags: { + ignoreCache: mockIgnoreCacheFlag, + active: true, + }, + }); + + const runResult = GetCommand.run(); + + return runResult.catch(err => { + expect(err.message).toMatchInlineSnapshot( + `"No active deployment found for mesh dummy_meshId. Check the mesh ID and try again or try without --active flag to get mesh config. RequestId: dummy_request_id"`, + ); + expect(getMesh).toHaveBeenCalledWith( + selectedOrg.code, + selectedProject.id, + selectedWorkspace.id, + selectedWorkspace.title, + meshId, + true, + ); + }); + }); }); diff --git a/src/commands/api-mesh/get.js b/src/commands/api-mesh/get.js index 03955505..94e05d66 100644 --- a/src/commands/api-mesh/get.js +++ b/src/commands/api-mesh/get.js @@ -14,7 +14,7 @@ const { writeFile } = require('fs/promises'); const logger = require('../../classes/logger'); const { initSdk } = require('../../helpers'); -const { ignoreCacheFlag, jsonFlag } = require('../../utils'); +const { ignoreCacheFlag, jsonFlag, activeFlag } = require('../../utils'); const { getMeshId, getMesh } = require('../../lib/smsClient'); const { buildMeshUrl } = require('../../urlBuilder'); @@ -24,6 +24,7 @@ class GetCommand extends Command { static flags = { ignoreCache: ignoreCacheFlag, json: jsonFlag, + active: activeFlag, }; static enableJsonFlag = true; @@ -35,6 +36,7 @@ class GetCommand extends Command { const ignoreCache = await flags.ignoreCache; const json = await flags.json; + const active = await flags.active; const { imsOrgId, imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({ ignoreCache, @@ -53,7 +55,14 @@ class GetCommand extends Command { if (meshId) { try { - const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, meshId); + const mesh = await getMesh( + imsOrgCode, + projectId, + workspaceId, + workspaceName, + meshId, + active, + ); if (mesh) { this.log('Successfully retrieved mesh %s', JSON.stringify(mesh, null, 2)); @@ -81,11 +90,16 @@ class GetCommand extends Command { ); } } catch (error) { - this.log(error.message); - - this.error( - `Unable to get mesh. Check the details and try again. If the error persists please contact support. RequestId: ${global.requestId}`, - ); + if (error.message === 'NoActiveDeploymentFound') { + this.error( + `No active deployment found for mesh ${meshId}. Check the mesh ID and try again or try without --active flag to get the mesh config. RequestId: ${global.requestId}`, + ); + } else { + this.log(error.message); + this.error( + `Unable to get mesh. Check the details and try again. If the error persists please contact support. RequestId: ${global.requestId}`, + ); + } } } else { this.error( @@ -96,6 +110,7 @@ class GetCommand extends Command { } } -GetCommand.description = 'Get the config of a given mesh'; +GetCommand.description = + 'Get the config of a given mesh. Use --active flag to retrieve the last successfully deployed mesh config'; module.exports = GetCommand; diff --git a/src/commands/api-mesh/source/install.js b/src/commands/api-mesh/source/install.js index b563faed..a99d42b8 100644 --- a/src/commands/api-mesh/source/install.js +++ b/src/commands/api-mesh/source/install.js @@ -140,7 +140,7 @@ class InstallCommand extends Command { } try { - const mesh = await getMesh(imsOrgCode, projectId, workspaceId, meshId, workspaceName); + const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, meshId); if (!mesh) { this.error( diff --git a/src/lib/smsClient.js b/src/lib/smsClient.js index 5d931ca9..6b1ecf99 100644 --- a/src/lib/smsClient.js +++ b/src/lib/smsClient.js @@ -142,11 +142,28 @@ const listLogs = async (organizationCode, projectId, workspaceId, meshId, fileNa } }; -const getMesh = async (organizationId, projectId, workspaceId, workspaceName, meshId) => { +/** + * Retrieves mesh configuration from the Schema Management Service. + * + * @param {string} organizationId - The organization ID + * @param {string} projectId - The project ID + * @param {string} workspaceId - The workspace ID + * @param {string} workspaceName - The workspace name + * @param {string} meshId - The mesh ID + * @param {boolean} active - Whether to retrieve the last successful deployed mesh configuration. + * @returns {Promise} The mesh configuration object, or null if mesh not found + * @throws {Error} Throws 'NoActiveDeploymentFound' when active=true but no successful deployment exists + * @throws {Error} Throws generic error for other API failures + */ +const getMesh = async (organizationId, projectId, workspaceId, workspaceName, meshId, active) => { const { accessToken } = await getDevConsoleConfig(); + + const baseUrl = `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`; + const url = active ? baseUrl + `?active=${active}` : baseUrl; + const config = { method: 'get', - url: `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`, + url: url, headers: { ...global?.metadataHeaders, 'Authorization': `Bearer ${accessToken}`, @@ -156,10 +173,7 @@ const getMesh = async (organizationId, projectId, workspaceId, workspaceName, me }, }; - logger.info( - 'Initiating GET %s', - `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`, - ); + logger.info('Initiating GET %s', url); try { const response = await axios(config); @@ -186,10 +200,19 @@ const getMesh = async (organizationId, projectId, workspaceId, workspaceName, me logger.info('Response from GET %s', error.response.status); if (error.response.status === 404) { - // The request was made and the server responded with a 404 status code - logger.error('Mesh not found'); - - return null; + // Check if no active deployment found + if ( + active && + error.response.data?.message && + error.response.data.message.includes('No active deployment found') + ) { + logger.error('No active deployment found for mesh'); + throw new Error('NoActiveDeploymentFound'); + } else { + // General mesh not found case + logger.error('Mesh not found'); + return null; + } } else if (error.response && error.response.data) { // The request was made and the server responded with an unsupported status code logger.error( diff --git a/src/utils.js b/src/utils.js index ce779305..e6a628ce 100644 --- a/src/utils.js +++ b/src/utils.js @@ -70,6 +70,12 @@ const inspectPortNoFlag = Flags.integer({ default: 9229, }); +const activeFlag = Flags.boolean({ + char: 'a', + description: 'Retrieve the last successfully deployed mesh config', + default: false, +}); + const debugFlag = Flags.boolean({ description: 'Enable debugging mode', default: false, @@ -815,6 +821,7 @@ module.exports = { getAppRootDir, portNoFlag, inspectPortNoFlag, + activeFlag, debugFlag, selectFlag, secretsFlag, From 080fb87a9535e4035cbeb8678e11d4a9a79cafe3 Mon Sep 17 00:00:00 2001 From: ajaz Date: Mon, 21 Jul 2025 13:37:36 +0530 Subject: [PATCH 02/18] fix: address review comment --- package.json | 2 +- src/commands/api-mesh/__tests__/get.test.js | 6 +++--- src/commands/api-mesh/get.js | 4 ++-- src/lib/smsClient.js | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index aaf5ba78..289de410 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/aio-cli-plugin-api-mesh", - "version": "5.4.1", + "version": "5.5.0-beta.1", "description": "Adobe I/O CLI plugin to develop and manage API mesh sources", "keywords": [ "oclif-plugin" diff --git a/src/commands/api-mesh/__tests__/get.test.js b/src/commands/api-mesh/__tests__/get.test.js index c608a737..38037bea 100644 --- a/src/commands/api-mesh/__tests__/get.test.js +++ b/src/commands/api-mesh/__tests__/get.test.js @@ -81,7 +81,7 @@ describe('get command tests', () => { test('snapshot get command', () => { expect(GetCommand.description).toMatchInlineSnapshot( - `"Get the config of a given mesh. Use --active flag to retrieve the last successfully deployed mesh config"`, + `"Get the config of a specified mesh. Use the --active flag to retrieve the last successfully deployed mesh config"`, ); expect(GetCommand.args).toMatchInlineSnapshot(` [ @@ -494,7 +494,7 @@ describe('get command tests', () => { return runResult.catch(err => { expect(err.message).toMatchInlineSnapshot( - `"No active deployment found for mesh dummy_meshId. Check the mesh ID and try again or try without --active flag to get the mesh config. RequestId: dummy_request_id"`, + `"No active deployment found for mesh dummy_meshId. Check the mesh ID and try again or try without the --active flag. RequestId: dummy_request_id"`, ); expect(getMesh).toHaveBeenCalledWith( selectedOrg.code, @@ -524,7 +524,7 @@ describe('get command tests', () => { return runResult.catch(err => { expect(err.message).toMatchInlineSnapshot( - `"No active deployment found for mesh dummy_meshId. Check the mesh ID and try again or try without --active flag to get mesh config. RequestId: dummy_request_id"`, + `"No active deployment found for mesh dummy_meshId. Check the mesh ID and try again or try without the --active flag. RequestId: dummy_request_id"`, ); expect(getMesh).toHaveBeenCalledWith( selectedOrg.code, diff --git a/src/commands/api-mesh/get.js b/src/commands/api-mesh/get.js index 94e05d66..3fb8c162 100644 --- a/src/commands/api-mesh/get.js +++ b/src/commands/api-mesh/get.js @@ -92,7 +92,7 @@ class GetCommand extends Command { } catch (error) { if (error.message === 'NoActiveDeploymentFound') { this.error( - `No active deployment found for mesh ${meshId}. Check the mesh ID and try again or try without --active flag to get the mesh config. RequestId: ${global.requestId}`, + `No active deployment found for mesh ${meshId}. Check the mesh ID and try again or try without the --active flag. RequestId: ${global.requestId}`, ); } else { this.log(error.message); @@ -111,6 +111,6 @@ class GetCommand extends Command { } GetCommand.description = - 'Get the config of a given mesh. Use --active flag to retrieve the last successfully deployed mesh config'; + 'Get the config of a specified mesh. Use the --active flag to retrieve the last successfully deployed mesh config'; module.exports = GetCommand; diff --git a/src/lib/smsClient.js b/src/lib/smsClient.js index 6b1ecf99..7feea4ab 100644 --- a/src/lib/smsClient.js +++ b/src/lib/smsClient.js @@ -683,6 +683,7 @@ const getMeshId = async (organizationCode, projectId, workspaceId, workspaceName ); } } catch (error) { + console.error(error.response.status); if (error.response.status === 400) { // The request was made and the server responded with a 400 status code logger.error('Mesh not found'); From ff4ff4c384e92879cb64fc9eb8f14dea85e28473 Mon Sep 17 00:00:00 2001 From: Revanth Kumar Annavarapu <35203638+revanth0212@users.noreply.github.com> Date: Tue, 22 Jul 2025 15:46:48 -0500 Subject: [PATCH 03/18] Added support for .graphql files --- src/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.js b/src/utils.js index ce779305..ea117067 100644 --- a/src/utils.js +++ b/src/utils.js @@ -357,7 +357,7 @@ function validateFileType(filesList) { filesList.forEach(file => { const extension = path.extname(file); - const isValidFileType = ['.js', '.json'].includes(extension); + const isValidFileType = ['.js', '.json', '.graphql'].includes(extension); if (!isValidFileType) { filesWithInvalidTypes.push(path.basename(file)); @@ -366,7 +366,7 @@ function validateFileType(filesList) { if (filesWithInvalidTypes.length) { throw new Error( - `Mesh files must be JavaScript or JSON. Other file types are not supported. The following file(s) are invalid: ${filesWithInvalidTypes}.`, + `Mesh files must be JavaScript, JSON or GraphQL. Other file types are not supported. The following file(s) are invalid: ${filesWithInvalidTypes}.`, ); } } From 241497180ce9d6fcf669303bd22b5c224fb7aac1 Mon Sep 17 00:00:00 2001 From: Revanth Date: Tue, 22 Jul 2025 17:30:23 -0500 Subject: [PATCH 04/18] Updated snapshots --- src/commands/api-mesh/__tests__/create.test.js | 2 +- src/commands/api-mesh/__tests__/run.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/api-mesh/__tests__/create.test.js b/src/commands/api-mesh/__tests__/create.test.js index f4260582..ceb11c8f 100644 --- a/src/commands/api-mesh/__tests__/create.test.js +++ b/src/commands/api-mesh/__tests__/create.test.js @@ -1015,7 +1015,7 @@ describe('create command tests', () => { expect(logSpy.mock.calls).toMatchInlineSnapshot(` [ [ - "Mesh files must be JavaScript or JSON. Other file types are not supported. The following file(s) are invalid: requestParams.txt.", + "Mesh files must be JavaScript, JSON or GraphQL. Other file types are not supported. The following file(s) are invalid: requestParams.txt.", ], ] `); diff --git a/src/commands/api-mesh/__tests__/run.test.js b/src/commands/api-mesh/__tests__/run.test.js index b0d4da92..43385ef5 100644 --- a/src/commands/api-mesh/__tests__/run.test.js +++ b/src/commands/api-mesh/__tests__/run.test.js @@ -541,7 +541,7 @@ describe('run command tests', () => { expect(logSpy.mock.calls).toMatchInlineSnapshot(` [ [ - "Mesh files must be JavaScript or JSON. Other file types are not supported. The following file(s) are invalid: requestParams.txt.", + "Mesh files must be JavaScript, JSON or GraphQL. Other file types are not supported. The following file(s) are invalid: requestParams.txt.", ], ] `); From 3defc2ad0c5a42bd6551b013f5cb23062e3e4833 Mon Sep 17 00:00:00 2001 From: Revanth Date: Tue, 22 Jul 2025 17:48:13 -0500 Subject: [PATCH 05/18] Minor --- src/commands/api-mesh/__tests__/create.test.js | 2 +- src/commands/api-mesh/__tests__/run.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/api-mesh/__tests__/create.test.js b/src/commands/api-mesh/__tests__/create.test.js index ceb11c8f..380f9e29 100644 --- a/src/commands/api-mesh/__tests__/create.test.js +++ b/src/commands/api-mesh/__tests__/create.test.js @@ -1000,7 +1000,7 @@ describe('create command tests', () => { `); }); - test('should fail if the file is of type other than js, json extension', async () => { + test('should fail if the file is of type other than js, json or graphql extension', async () => { parseSpy.mockResolvedValueOnce({ args: { file: 'src/commands/__fixtures__/sample_mesh_invalid_type.json' }, flags: { diff --git a/src/commands/api-mesh/__tests__/run.test.js b/src/commands/api-mesh/__tests__/run.test.js index 43385ef5..d8151ce5 100644 --- a/src/commands/api-mesh/__tests__/run.test.js +++ b/src/commands/api-mesh/__tests__/run.test.js @@ -526,7 +526,7 @@ describe('run command tests', () => { `); }); - test('should fail if the file is of type other than js, json extension', async () => { + test('should fail if the file is of type other than js, json or graphql extension', async () => { parseSpy.mockResolvedValueOnce({ args: { file: 'src/commands/__fixtures__/sample_mesh_invalid_type.json' }, flags: { From 515f32fbc1afcbe173d2c474b1fcf21e097f42e1 Mon Sep 17 00:00:00 2001 From: ajaz Date: Wed, 23 Jul 2025 13:06:01 +0530 Subject: [PATCH 06/18] fix: node version & address review comments --- .github/workflows/build.yml | 2 +- src/lib/smsClient.js | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f28a1ea..5aed3388 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 20 - run: yarn global add @adobe/aio-cli - run: yarn install --frozen-lockfile - run: yarn run lint diff --git a/src/lib/smsClient.js b/src/lib/smsClient.js index 7feea4ab..0846dbfa 100644 --- a/src/lib/smsClient.js +++ b/src/lib/smsClient.js @@ -158,8 +158,8 @@ const listLogs = async (organizationCode, projectId, workspaceId, meshId, fileNa const getMesh = async (organizationId, projectId, workspaceId, workspaceName, meshId, active) => { const { accessToken } = await getDevConsoleConfig(); - const baseUrl = `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`; - const url = active ? baseUrl + `?active=${active}` : baseUrl; + const url = `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`; + const params = active ? { active } : undefined; const config = { method: 'get', @@ -171,6 +171,7 @@ const getMesh = async (organizationId, projectId, workspaceId, workspaceName, me 'workspaceName': workspaceName, 'x-api-key': SMS_API_KEY, }, + params: params, }; logger.info('Initiating GET %s', url); @@ -203,8 +204,7 @@ const getMesh = async (organizationId, projectId, workspaceId, workspaceName, me // Check if no active deployment found if ( active && - error.response.data?.message && - error.response.data.message.includes('No active deployment found') + error.response.data?.message?.includes('No active deployment found') ) { logger.error('No active deployment found for mesh'); throw new Error('NoActiveDeploymentFound'); @@ -683,7 +683,6 @@ const getMeshId = async (organizationCode, projectId, workspaceId, workspaceName ); } } catch (error) { - console.error(error.response.status); if (error.response.status === 400) { // The request was made and the server responded with a 400 status code logger.error('Mesh not found'); From 86de09dbbac6b1157145d17b0249f5a5b8d215e5 Mon Sep 17 00:00:00 2001 From: ajaz Date: Wed, 23 Jul 2025 13:07:30 +0530 Subject: [PATCH 07/18] fix: linting --- src/lib/smsClient.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lib/smsClient.js b/src/lib/smsClient.js index 0846dbfa..70743442 100644 --- a/src/lib/smsClient.js +++ b/src/lib/smsClient.js @@ -202,10 +202,7 @@ const getMesh = async (organizationId, projectId, workspaceId, workspaceName, me if (error.response.status === 404) { // Check if no active deployment found - if ( - active && - error.response.data?.message?.includes('No active deployment found') - ) { + if (active && error.response.data?.message?.includes('No active deployment found')) { logger.error('No active deployment found for mesh'); throw new Error('NoActiveDeploymentFound'); } else { From 4bab3a22a51df5d5746b697d1ed1f275ff5f6f54 Mon Sep 17 00:00:00 2001 From: ajaz Date: Wed, 23 Jul 2025 16:51:36 +0530 Subject: [PATCH 08/18] refactor: update getMesh to use lookup API --- src/commands/api-mesh/__tests__/get.test.js | 43 +++------- src/commands/api-mesh/get.js | 90 ++++++++------------- src/lib/smsClient.js | 7 +- 3 files changed, 47 insertions(+), 93 deletions(-) diff --git a/src/commands/api-mesh/__tests__/get.test.js b/src/commands/api-mesh/__tests__/get.test.js index 38037bea..bd7bc346 100644 --- a/src/commands/api-mesh/__tests__/get.test.js +++ b/src/commands/api-mesh/__tests__/get.test.js @@ -34,7 +34,7 @@ const { writeFile } = require('fs/promises'); const { initSdk } = require('../../../helpers'); const GetCommand = require('../get'); const mockGetMeshConfig = require('../../__fixtures__/sample_mesh.json'); -const { getMeshId, getMesh } = require('../../../lib/smsClient'); +const { getMesh } = require('../../../lib/smsClient'); let logSpy = null; let errorLogSpy = null; @@ -60,7 +60,6 @@ describe('get command tests', () => { writeFile.mockResolvedValue(true); - getMeshId.mockResolvedValue('dummy_meshId'); getMesh.mockResolvedValue({ meshId: 'dummy_meshId', mesh: mockGetMeshConfig, @@ -120,8 +119,8 @@ describe('get command tests', () => { expect(GetCommand.aliases).toMatchInlineSnapshot(`[]`); }); - test('should fail if mesh id is missing', async () => { - getMeshId.mockResolvedValueOnce(null); + test('should fail if mesh is missing', async () => { + getMesh.mockResolvedValueOnce(null); const runResult = GetCommand.run(); return runResult.catch(err => { @@ -139,8 +138,8 @@ describe('get command tests', () => { }); }); - test('should fail if getMeshId failed', async () => { - getMeshId.mockRejectedValueOnce(new Error('getMeshId failed')); + test('should fail if getMesh failed with MeshIdNotFound', async () => { + getMesh.mockRejectedValueOnce(new Error('MeshIdNotFound')); const runResult = GetCommand.run(); return runResult.catch(err => { @@ -158,16 +157,6 @@ describe('get command tests', () => { }); }); - test('should fail if mesh id is not found', async () => { - getMesh.mockResolvedValueOnce(null); - - await GetCommand.run().catch(err => { - expect(err.message).toContain( - 'Unable to get mesh with the ID dummy_meshId. Please check the mesh ID and try again.', - ); - }); - }); - test('should fail if get mesh method failed', async () => { getMesh.mockRejectedValueOnce(new Error('get mesh failed')); @@ -195,8 +184,6 @@ describe('get command tests', () => { }); test('should pass if mesh id is valid', async () => { - const meshId = 'dummy_meshId'; - getMeshId.mockResolvedValueOnce(meshId); const runResult = await GetCommand.run(); expect(initSdk).toHaveBeenCalledWith({ @@ -415,9 +402,7 @@ describe('get command tests', () => { }); // Active flag test cases - test('should get last successfully mesh config with --active flag', async () => { - const meshId = 'dummy_meshId'; - getMeshId.mockResolvedValueOnce(meshId); + test('should get last successfully deployed mesh config with --active flag', async () => { getMesh.mockResolvedValueOnce({ meshId: 'dummy_meshId', mesh: mockGetMeshConfig, @@ -438,7 +423,6 @@ describe('get command tests', () => { selectedProject.id, selectedWorkspace.id, selectedWorkspace.title, - meshId, true, ); @@ -446,9 +430,7 @@ describe('get command tests', () => { expect(runResult.meshId).toBe('dummy_meshId'); }); - test('should get last successfully mesh config with shorthand -a flag', async () => { - const meshId = 'dummy_meshId'; - getMeshId.mockResolvedValueOnce(meshId); + test('should get last successfully deployed mesh config with shorthand -a flag', async () => { getMesh.mockResolvedValueOnce({ meshId: 'dummy_meshId', mesh: mockGetMeshConfig, @@ -469,7 +451,6 @@ describe('get command tests', () => { selectedProject.id, selectedWorkspace.id, selectedWorkspace.title, - meshId, true, ); @@ -478,8 +459,6 @@ describe('get command tests', () => { }); test('should handle NoActiveDeploymentFound error when using --active flag', async () => { - const meshId = 'dummy_meshId'; - getMeshId.mockResolvedValueOnce(meshId); getMesh.mockRejectedValueOnce(new Error('NoActiveDeploymentFound')); parseSpy.mockResolvedValueOnce({ @@ -494,22 +473,19 @@ describe('get command tests', () => { return runResult.catch(err => { expect(err.message).toMatchInlineSnapshot( - `"No active deployment found for mesh dummy_meshId. Check the mesh ID and try again or try without the --active flag. RequestId: dummy_request_id"`, + `"No active deployment found for mesh. Check the details and try again or try without the --active flag. RequestId: dummy_request_id"`, ); expect(getMesh).toHaveBeenCalledWith( selectedOrg.code, selectedProject.id, selectedWorkspace.id, selectedWorkspace.title, - meshId, true, ); }); }); test('should handle mesh not found when using --active flag', async () => { - const meshId = 'dummy_meshId'; - getMeshId.mockResolvedValueOnce(meshId); getMesh.mockResolvedValueOnce(null); // Mesh not found parseSpy.mockResolvedValueOnce({ @@ -524,14 +500,13 @@ describe('get command tests', () => { return runResult.catch(err => { expect(err.message).toMatchInlineSnapshot( - `"No active deployment found for mesh dummy_meshId. Check the mesh ID and try again or try without the --active flag. RequestId: dummy_request_id"`, + `"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again."`, ); expect(getMesh).toHaveBeenCalledWith( selectedOrg.code, selectedProject.id, selectedWorkspace.id, selectedWorkspace.title, - meshId, true, ); }); diff --git a/src/commands/api-mesh/get.js b/src/commands/api-mesh/get.js index 3fb8c162..2319d839 100644 --- a/src/commands/api-mesh/get.js +++ b/src/commands/api-mesh/get.js @@ -15,7 +15,7 @@ const { writeFile } = require('fs/promises'); const logger = require('../../classes/logger'); const { initSdk } = require('../../helpers'); const { ignoreCacheFlag, jsonFlag, activeFlag } = require('../../utils'); -const { getMeshId, getMesh } = require('../../lib/smsClient'); +const { getMesh } = require('../../lib/smsClient'); const { buildMeshUrl } = require('../../urlBuilder'); require('dotenv').config(); @@ -43,69 +43,49 @@ class GetCommand extends Command { verbose: !json, }); - let meshId = null; - try { - meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName); - } catch (err) { - this.error( - `Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`, - ); - } - - if (meshId) { - try { - const mesh = await getMesh( - imsOrgCode, - projectId, - workspaceId, - workspaceName, - meshId, - active, - ); + const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, active); - if (mesh) { - this.log('Successfully retrieved mesh %s', JSON.stringify(mesh, null, 2)); + if (mesh) { + this.log('Successfully retrieved mesh %s', JSON.stringify(mesh, null, 2)); - const meshUrl = buildMeshUrl(meshId, workspaceName); + const meshUrl = buildMeshUrl(mesh.meshId, workspaceName); - if (args.file) { - try { - const { meshConfig } = mesh; - await writeFile(args.file, JSON.stringify({ meshConfig }, null, 2)); + if (args.file) { + try { + const { meshConfig } = mesh; + await writeFile(args.file, JSON.stringify({ meshConfig }, null, 2)); - this.log('Successfully wrote mesh to file %s', args.file); - } catch (error) { - this.log('Unable to write mesh to file %s', args.file); + this.log('Successfully wrote mesh to file %s', args.file); + } catch (error) { + this.log('Unable to write mesh to file %s', args.file); - logger.error(error); - } + logger.error(error); } - - return { ...mesh, meshUrl, imsOrgId, projectId, workspaceId, workspaceName }; - } else { - logger.error( - `Unable to get mesh with the ID ${meshId}. Check the mesh ID and try again. RequestId: ${global.requestId}`, - { exit: false }, - ); - } - } catch (error) { - if (error.message === 'NoActiveDeploymentFound') { - this.error( - `No active deployment found for mesh ${meshId}. Check the mesh ID and try again or try without the --active flag. RequestId: ${global.requestId}`, - ); - } else { - this.log(error.message); - this.error( - `Unable to get mesh. Check the details and try again. If the error persists please contact support. RequestId: ${global.requestId}`, - ); } + + return { ...mesh, meshUrl, imsOrgId, projectId, workspaceId, workspaceName }; + } else { + this.error( + `Unable to get mesh config. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`, + { exit: false }, + ); + } + } catch (error) { + if (error.message === 'MeshIdNotFound') { + this.error( + `Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`, + ); + } else if (error.message === 'NoActiveDeploymentFound') { + this.error( + `No active deployment found for mesh. Check the details and try again or try without the --active flag. RequestId: ${global.requestId}`, + ); + } else { + this.log(error.message); + this.error( + `Unable to get mesh. Check the details and try again. If the error persists please contact support. RequestId: ${global.requestId}`, + ); } - } else { - this.error( - `Unable to get mesh config. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`, - { exit: false }, - ); } } } diff --git a/src/lib/smsClient.js b/src/lib/smsClient.js index 70743442..5f446730 100644 --- a/src/lib/smsClient.js +++ b/src/lib/smsClient.js @@ -149,16 +149,15 @@ const listLogs = async (organizationCode, projectId, workspaceId, meshId, fileNa * @param {string} projectId - The project ID * @param {string} workspaceId - The workspace ID * @param {string} workspaceName - The workspace name - * @param {string} meshId - The mesh ID * @param {boolean} active - Whether to retrieve the last successful deployed mesh configuration. * @returns {Promise} The mesh configuration object, or null if mesh not found * @throws {Error} Throws 'NoActiveDeploymentFound' when active=true but no successful deployment exists * @throws {Error} Throws generic error for other API failures */ -const getMesh = async (organizationId, projectId, workspaceId, workspaceName, meshId, active) => { +const getMesh = async (organizationId, projectId, workspaceId, workspaceName, active) => { const { accessToken } = await getDevConsoleConfig(); - const url = `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`; + const url = `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/mesh`; const params = active ? { active } : undefined; const config = { @@ -208,7 +207,7 @@ const getMesh = async (organizationId, projectId, workspaceId, workspaceName, me } else { // General mesh not found case logger.error('Mesh not found'); - return null; + throw new Error('MeshIdNotFound'); } } else if (error.response && error.response.data) { // The request was made and the server responded with an unsupported status code From 6de7ced980742c47685104afd80c866145cdc9c0 Mon Sep 17 00:00:00 2001 From: ajaz Date: Wed, 23 Jul 2025 17:05:09 +0530 Subject: [PATCH 09/18] chore: update getMesh references in the code --- src/commands/api-mesh/source/install.js | 2 +- src/commands/api-mesh/status.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/api-mesh/source/install.js b/src/commands/api-mesh/source/install.js index a99d42b8..9b7694c0 100644 --- a/src/commands/api-mesh/source/install.js +++ b/src/commands/api-mesh/source/install.js @@ -140,7 +140,7 @@ class InstallCommand extends Command { } try { - const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, meshId); + const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName); if (!mesh) { this.error( diff --git a/src/commands/api-mesh/status.js b/src/commands/api-mesh/status.js index dbc84d56..58b32ba9 100644 --- a/src/commands/api-mesh/status.js +++ b/src/commands/api-mesh/status.js @@ -41,7 +41,7 @@ class StatusCommand extends Command { } try { - const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, meshId); + const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName); this.log(''.padEnd(102, '*')); await this.displayMeshStatus(mesh, imsOrgCode, projectId, workspaceId); this.log(''.padEnd(102, '*')); From 6bc726c9bcd31006f01c277e4faedc21523f51c7 Mon Sep 17 00:00:00 2001 From: Revanth Kumar Annavarapu <35203638+revanth0212@users.noreply.github.com> Date: Wed, 23 Jul 2025 09:16:40 -0500 Subject: [PATCH 10/18] Update build.yml to use Node 24 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f28a1ea..47de00c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 24 - run: yarn global add @adobe/aio-cli - run: yarn install --frozen-lockfile - run: yarn run lint From d99a9eb1dfafc694bef220237a78f6be196d54ab Mon Sep 17 00:00:00 2001 From: Revanth Kumar Annavarapu <35203638+revanth0212@users.noreply.github.com> Date: Wed, 23 Jul 2025 09:17:08 -0500 Subject: [PATCH 11/18] Update publish-to-npm.yml to use Node 24 --- .github/workflows/publish-to-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-npm.yml b/.github/workflows/publish-to-npm.yml index b5e94b64..dbfdeafb 100644 --- a/.github/workflows/publish-to-npm.yml +++ b/.github/workflows/publish-to-npm.yml @@ -17,7 +17,7 @@ jobs: - name: Setup node uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 24 - name: Yarn install run: yarn install --frozen-lockfile From 7d42cc3ea4bfc7e18ee688c04d2d2e731ec483fa Mon Sep 17 00:00:00 2001 From: Revanth Kumar Annavarapu <35203638+revanth0212@users.noreply.github.com> Date: Wed, 23 Jul 2025 09:27:26 -0500 Subject: [PATCH 12/18] Update build.yml to use Node 22 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47de00c1..58f72aa9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: - node-version: 24 + node-version: 22 - run: yarn global add @adobe/aio-cli - run: yarn install --frozen-lockfile - run: yarn run lint From bc7059e3abe7593ff4f1e9163949d9aef6e96ce4 Mon Sep 17 00:00:00 2001 From: Revanth Kumar Annavarapu <35203638+revanth0212@users.noreply.github.com> Date: Wed, 23 Jul 2025 09:27:39 -0500 Subject: [PATCH 13/18] Update publish-to-npm.yml to use Node 22 --- .github/workflows/publish-to-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-npm.yml b/.github/workflows/publish-to-npm.yml index dbfdeafb..7b0441c2 100644 --- a/.github/workflows/publish-to-npm.yml +++ b/.github/workflows/publish-to-npm.yml @@ -17,7 +17,7 @@ jobs: - name: Setup node uses: actions/setup-node@v3 with: - node-version: 24 + node-version: 22 - name: Yarn install run: yarn install --frozen-lockfile From fb8811586ebdef2b135b9d3a5ff02f0ca2d09bbb Mon Sep 17 00:00:00 2001 From: ajaz Date: Wed, 23 Jul 2025 23:34:41 +0530 Subject: [PATCH 14/18] fix: error message and restore return statement --- src/commands/api-mesh/__tests__/get.test.js | 8 ++++---- src/commands/api-mesh/get.js | 5 +++-- src/lib/smsClient.js | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/commands/api-mesh/__tests__/get.test.js b/src/commands/api-mesh/__tests__/get.test.js index bd7bc346..b2f36cc4 100644 --- a/src/commands/api-mesh/__tests__/get.test.js +++ b/src/commands/api-mesh/__tests__/get.test.js @@ -138,19 +138,19 @@ describe('get command tests', () => { }); }); - test('should fail if getMesh failed with MeshIdNotFound', async () => { - getMesh.mockRejectedValueOnce(new Error('MeshIdNotFound')); + test('should fail if getMesh failed with MeshNotFound', async () => { + getMesh.mockRejectedValueOnce(new Error('MeshNotFound')); const runResult = GetCommand.run(); return runResult.catch(err => { expect(err.message).toMatchInlineSnapshot( - `"Unable to get mesh ID. Check the details and try again. RequestId: dummy_request_id"`, + `"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Check the details and try again."`, ); expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`); expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(` [ [ - "Unable to get mesh ID. Check the details and try again. RequestId: dummy_request_id", + "Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Check the details and try again.", ], ] `); diff --git a/src/commands/api-mesh/get.js b/src/commands/api-mesh/get.js index 2319d839..61775cd8 100644 --- a/src/commands/api-mesh/get.js +++ b/src/commands/api-mesh/get.js @@ -72,9 +72,10 @@ class GetCommand extends Command { ); } } catch (error) { - if (error.message === 'MeshIdNotFound') { + if (error.message === 'MeshNotFound') { this.error( - `Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`, + `Unable to get mesh config. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`, + { exit: false }, ); } else if (error.message === 'NoActiveDeploymentFound') { this.error( diff --git a/src/lib/smsClient.js b/src/lib/smsClient.js index 5f446730..038bd4d1 100644 --- a/src/lib/smsClient.js +++ b/src/lib/smsClient.js @@ -207,7 +207,7 @@ const getMesh = async (organizationId, projectId, workspaceId, workspaceName, ac } else { // General mesh not found case logger.error('Mesh not found'); - throw new Error('MeshIdNotFound'); + throw new Error('MeshNotFound'); } } else if (error.response && error.response.data) { // The request was made and the server responded with an unsupported status code From 95b26846c891927d3af350bdfed2a09a1f407c69 Mon Sep 17 00:00:00 2001 From: ajaz Date: Wed, 23 Jul 2025 23:45:34 +0530 Subject: [PATCH 15/18] fix: tests --- src/commands/api-mesh/__tests__/get.test.js | 45 +++++++++------------ 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/src/commands/api-mesh/__tests__/get.test.js b/src/commands/api-mesh/__tests__/get.test.js index b2f36cc4..0a6dfd8e 100644 --- a/src/commands/api-mesh/__tests__/get.test.js +++ b/src/commands/api-mesh/__tests__/get.test.js @@ -121,21 +121,13 @@ describe('get command tests', () => { test('should fail if mesh is missing', async () => { getMesh.mockResolvedValueOnce(null); - const runResult = GetCommand.run(); - return runResult.catch(err => { - expect(err.message).toMatchInlineSnapshot( - `"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Check the details and try again."`, - ); - expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`); - expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Check the details and try again.", - ], - ] - `); - }); + await GetCommand.run(); + + expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`); + expect(errorLogSpy.mock.calls[0][0]).toBe( + 'Unable to get mesh config. No mesh found for Org(CODE1234@AdobeOrg) -> Project(5678) -> Workspace(123456789). Please check the details and try again.', + ); }); test('should fail if getMesh failed with MeshNotFound', async () => { @@ -496,19 +488,18 @@ describe('get command tests', () => { }, }); - const runResult = GetCommand.run(); + await GetCommand.run(); - return runResult.catch(err => { - expect(err.message).toMatchInlineSnapshot( - `"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again."`, - ); - expect(getMesh).toHaveBeenCalledWith( - selectedOrg.code, - selectedProject.id, - selectedWorkspace.id, - selectedWorkspace.title, - true, - ); - }); + expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`); + expect(errorLogSpy.mock.calls[0][0]).toBe( + 'Unable to get mesh config. No mesh found for Org(CODE1234@AdobeOrg) -> Project(5678) -> Workspace(123456789). Please check the details and try again.', + ); + expect(getMesh).toHaveBeenCalledWith( + selectedOrg.code, + selectedProject.id, + selectedWorkspace.id, + selectedWorkspace.title, + true, + ); }); }); From dbd4a46963de616115dc9da40da210d824bc1b23 Mon Sep 17 00:00:00 2001 From: ajaz Date: Wed, 23 Jul 2025 23:50:02 +0530 Subject: [PATCH 16/18] fix: node version --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5aed3388..58f72aa9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: - node-version: 20 + node-version: 22 - run: yarn global add @adobe/aio-cli - run: yarn install --frozen-lockfile - run: yarn run lint From e0c9665273e6f3f571d461aea18bf8442dc7ce08 Mon Sep 17 00:00:00 2001 From: Andrew Molina Date: Wed, 23 Jul 2025 21:00:08 -0500 Subject: [PATCH 17/18] fix: update get test rejected values to match code --- src/commands/api-mesh/__tests__/get.test.js | 55 ++++++++------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/src/commands/api-mesh/__tests__/get.test.js b/src/commands/api-mesh/__tests__/get.test.js index 0a6dfd8e..c1d9fca1 100644 --- a/src/commands/api-mesh/__tests__/get.test.js +++ b/src/commands/api-mesh/__tests__/get.test.js @@ -120,8 +120,7 @@ describe('get command tests', () => { }); test('should fail if mesh is missing', async () => { - getMesh.mockResolvedValueOnce(null); - + getMesh.mockRejectedValueOnce(new Error('MeshNotFound')); await GetCommand.run(); expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`); @@ -130,25 +129,6 @@ describe('get command tests', () => { ); }); - test('should fail if getMesh failed with MeshNotFound', async () => { - getMesh.mockRejectedValueOnce(new Error('MeshNotFound')); - const runResult = GetCommand.run(); - - return runResult.catch(err => { - expect(err.message).toMatchInlineSnapshot( - `"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Check the details and try again."`, - ); - expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`); - expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(` - [ - [ - "Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Check the details and try again.", - ], - ] - `); - }); - }); - test('should fail if get mesh method failed', async () => { getMesh.mockRejectedValueOnce(new Error('get mesh failed')); @@ -175,7 +155,7 @@ describe('get command tests', () => { `); }); - test('should pass if mesh id is valid', async () => { + test('should pass if mesh is found', async () => { const runResult = await GetCommand.run(); expect(initSdk).toHaveBeenCalledWith({ @@ -463,22 +443,27 @@ describe('get command tests', () => { const runResult = GetCommand.run(); - return runResult.catch(err => { - expect(err.message).toMatchInlineSnapshot( - `"No active deployment found for mesh. Check the details and try again or try without the --active flag. RequestId: dummy_request_id"`, - ); - expect(getMesh).toHaveBeenCalledWith( - selectedOrg.code, - selectedProject.id, - selectedWorkspace.id, - selectedWorkspace.title, - true, - ); - }); + await expect(runResult).rejects.toEqual( + new Error( + 'No active deployment found for mesh. Check the details and try again or try without the --active flag. RequestId: dummy_request_id', + ), + ); + + expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`); + expect(errorLogSpy.mock.calls[0][0]).toBe( + 'No active deployment found for mesh. Check the details and try again or try without the --active flag. RequestId: dummy_request_id', + ); + expect(getMesh).toHaveBeenCalledWith( + selectedOrg.code, + selectedProject.id, + selectedWorkspace.id, + selectedWorkspace.title, + true, + ); }); test('should handle mesh not found when using --active flag', async () => { - getMesh.mockResolvedValueOnce(null); // Mesh not found + getMesh.mockRejectedValueOnce(new Error('MeshNotFound')); parseSpy.mockResolvedValueOnce({ args: {}, From 795643ed1f434eb8effcd0d9d581d5cde00fd906 Mon Sep 17 00:00:00 2001 From: Andrew Molina Date: Mon, 28 Jul 2025 16:22:58 -0500 Subject: [PATCH 18/18] chore: bump version for 5.5.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 289de410..d768f017 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/aio-cli-plugin-api-mesh", - "version": "5.5.0-beta.1", + "version": "5.5.0", "description": "Adobe I/O CLI plugin to develop and manage API mesh sources", "keywords": [ "oclif-plugin"