From 82b6e2f79760f043f0c1b15e57088bf41db22927 Mon Sep 17 00:00:00 2001 From: nvyas Date: Fri, 2 Aug 2024 17:45:00 +0530 Subject: [PATCH 01/10] feat: enable edge mesh for all --- src/commands/api-mesh/create.js | 15 +++++---------- src/commands/api-mesh/describe.js | 13 ++++--------- src/commands/api-mesh/status.js | 8 ++------ 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/commands/api-mesh/create.js b/src/commands/api-mesh/create.js index 0e78652..3d0607a 100644 --- a/src/commands/api-mesh/create.js +++ b/src/commands/api-mesh/create.js @@ -27,7 +27,7 @@ const { validateSecretsFile, encryptSecrets, } = require('../../utils'); -const { createMesh, getTenantFeatures, getPublicEncryptionKey } = require('../../lib/devConsole'); +const { createMesh, getPublicEncryptionKey } = require('../../lib/devConsole'); const { buildEdgeMeshUrl, buildMeshUrl } = require('../../urlBuilder'); class CreateCommand extends Command { @@ -170,15 +170,10 @@ class CreateCommand extends Command { apiKey, ); - const { showCloudflareURL: showEdgeMeshUrl } = await getTenantFeatures(imsOrgCode); - - if (showEdgeMeshUrl) { - const edgeMeshUrl = buildEdgeMeshUrl(mesh.meshId, workspaceName); - this.log('Legacy Mesh Endpoint: %s', meshUrl); - this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); - } else { - this.log('Mesh Endpoint: %s\n', meshUrl); - } + const edgeMeshUrl = buildEdgeMeshUrl(mesh.meshId, workspaceName); + this.log('Legacy Mesh Endpoint: %s', meshUrl); + this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); + } else { this.log('Unable to subscribe API Key %s to API Mesh service', apiKey); } diff --git a/src/commands/api-mesh/describe.js b/src/commands/api-mesh/describe.js index 795b338..4f20459 100644 --- a/src/commands/api-mesh/describe.js +++ b/src/commands/api-mesh/describe.js @@ -15,7 +15,7 @@ const chalk = require('chalk'); const logger = require('../../classes/logger'); const { initSdk, initRequestId } = require('../../helpers'); const { ignoreCacheFlag } = require('../../utils'); -const { describeMesh, getTenantFeatures } = require('../../lib/devConsole'); +const { describeMesh } = require('../../lib/devConsole'); const { buildMeshUrl, buildEdgeMeshUrl } = require('../../urlBuilder'); require('dotenv').config(); @@ -41,7 +41,6 @@ class DescribeCommand extends Command { if (meshDetails) { const { meshId, apiKey } = meshDetails; - const { showCloudflareURL: showEdgeMeshUrl } = await getTenantFeatures(imsOrgCode); if (meshId) { const meshUrl = await buildMeshUrl( @@ -59,13 +58,9 @@ class DescribeCommand extends Command { this.log('Workspace ID: %s', workspaceId); this.log('Mesh ID: %s', meshId); - if (showEdgeMeshUrl) { - const edgeMeshUrl = buildEdgeMeshUrl(meshId, workspaceName); - this.log('Legacy Mesh Endpoint: %s', meshUrl); - this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); - } else { - this.log('Mesh Endpoint: %s\n', meshUrl); - } + const edgeMeshUrl = buildEdgeMeshUrl(meshId, workspaceName); + this.log('Legacy Mesh Endpoint: %s', meshUrl); + this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); return meshDetails; } else { diff --git a/src/commands/api-mesh/status.js b/src/commands/api-mesh/status.js index 27f0989..d0c897d 100644 --- a/src/commands/api-mesh/status.js +++ b/src/commands/api-mesh/status.js @@ -6,7 +6,6 @@ const { initRequestId, initSdk } = require('../../helpers'); const { getMeshId, getMesh, - getTenantFeatures, getMeshDeployments, } = require('../../lib/devConsole'); const { ignoreCacheFlag } = require('../../utils'); @@ -41,15 +40,12 @@ class StatusCommand extends Command { if (meshId) { try { - const { showCloudflareURL: showEdgeMeshUrl } = await getTenantFeatures(imsOrgCode); const mesh = await getMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId); - const meshLabel = showEdgeMeshUrl ? chalk.bold(`Legacy Mesh:`) : 'Your mesh'; + const meshLabel = chalk.bold(`Legacy Mesh:`); this.log(''.padEnd(102, '*')); this.displayMeshStatus(mesh, meshLabel); - if (showEdgeMeshUrl) { - await this.displayEdgeMeshStatus(mesh, imsOrgCode, projectId, workspaceId); - } + await this.displayEdgeMeshStatus(mesh, imsOrgCode, projectId, workspaceId); this.log(''.padEnd(102, '*')); } catch (err) { this.log(err.message); From 86d8e59fe129017a3b29363c24e2fa5d76dec305 Mon Sep 17 00:00:00 2001 From: nvyas Date: Fri, 2 Aug 2024 19:17:24 +0530 Subject: [PATCH 02/10] feat: lint fixes --- src/commands/api-mesh/create.js | 1 - src/commands/api-mesh/describe.js | 2 +- src/commands/api-mesh/status.js | 6 +----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/commands/api-mesh/create.js b/src/commands/api-mesh/create.js index 3d0607a..3df8b0d 100644 --- a/src/commands/api-mesh/create.js +++ b/src/commands/api-mesh/create.js @@ -173,7 +173,6 @@ class CreateCommand extends Command { const edgeMeshUrl = buildEdgeMeshUrl(mesh.meshId, workspaceName); this.log('Legacy Mesh Endpoint: %s', meshUrl); this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); - } else { this.log('Unable to subscribe API Key %s to API Mesh service', apiKey); } diff --git a/src/commands/api-mesh/describe.js b/src/commands/api-mesh/describe.js index 4f20459..c45d6e3 100644 --- a/src/commands/api-mesh/describe.js +++ b/src/commands/api-mesh/describe.js @@ -32,7 +32,7 @@ class DescribeCommand extends Command { const { flags } = await this.parse(DescribeCommand); const ignoreCache = await flags.ignoreCache; - const { imsOrgId, imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({ + const { imsOrgId, projectId, workspaceId, workspaceName } = await initSdk({ ignoreCache, }); diff --git a/src/commands/api-mesh/status.js b/src/commands/api-mesh/status.js index d0c897d..36906f6 100644 --- a/src/commands/api-mesh/status.js +++ b/src/commands/api-mesh/status.js @@ -3,11 +3,7 @@ const chalk = require('chalk'); const logger = require('../../classes/logger'); const { initRequestId, initSdk } = require('../../helpers'); -const { - getMeshId, - getMesh, - getMeshDeployments, -} = require('../../lib/devConsole'); +const { getMeshId, getMesh, getMeshDeployments } = require('../../lib/devConsole'); const { ignoreCacheFlag } = require('../../utils'); require('dotenv').config(); From c6d5d3e08526bf7584e27cb4edf16fc221a4721f Mon Sep 17 00:00:00 2001 From: nvyas Date: Wed, 7 Aug 2024 15:42:52 +0530 Subject: [PATCH 03/10] Showing deprication notice in describe command --- src/commands/api-mesh/describe.js | 16 +++++++++++++++- src/helpers.js | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/commands/api-mesh/describe.js b/src/commands/api-mesh/describe.js index c45d6e3..132f7e2 100644 --- a/src/commands/api-mesh/describe.js +++ b/src/commands/api-mesh/describe.js @@ -13,7 +13,7 @@ const { Command } = require('@oclif/command'); const chalk = require('chalk'); const logger = require('../../classes/logger'); -const { initSdk, initRequestId } = require('../../helpers'); +const { initSdk, initRequestId, createNotice } = require('../../helpers'); const { ignoreCacheFlag } = require('../../utils'); const { describeMesh } = require('../../lib/devConsole'); const { buildMeshUrl, buildEdgeMeshUrl } = require('../../urlBuilder'); @@ -59,9 +59,23 @@ class DescribeCommand extends Command { this.log('Mesh ID: %s', meshId); const edgeMeshUrl = buildEdgeMeshUrl(meshId, workspaceName); + this.log( + await createNotice( + `API Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:\n${chalk.underline.blue( + 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration', + )}`, + ), + ); this.log('Legacy Mesh Endpoint: %s', meshUrl); this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); + // this.log(chalk.bgYellow('Make sure that you update your mesh before using the edge mesh endpoint. You can validate your edge mesh status using the status command.')); + this.log( + await createNotice( + `Make sure that you update your mesh before using the edge mesh endpoint.\nYou can validate your edge mesh status using the status command.`, + ), + ); + return meshDetails; } else { logger.error( diff --git a/src/helpers.js b/src/helpers.js index 052219b..c0c951c 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -17,6 +17,7 @@ const { getToken, context } = require('@adobe/aio-lib-ims'); const { CLI } = require('@adobe/aio-lib-ims/src/context'); const libConsoleCLI = require('@adobe/aio-cli-lib-console'); const { getCliEnv } = require('@adobe/aio-lib-env'); +const chalk = require('chalk'); const logger = require('../src/classes/logger'); const { UUID } = require('./classes/UUID'); @@ -880,6 +881,21 @@ async function writeSecretsFile(secretsData, meshId) { } } +// Function to generate the notice message with multiline support +async function createNotice(message) { + const lines = message.split('\n'); + const maxLength = Math.max(...lines.map(line => line.length)); + const border = chalk.yellow('='.repeat(maxLength + 12)); + + const formattedLines = lines.map(line => { + const padding = ' '.repeat(maxLength - line.length); + return `${chalk.whiteBright(line)}${padding}`; + }); + + const noticeMessage = formattedLines.join('\n'); + return `${border}\n${chalk.blueBright.bold('ⓘ')} ${noticeMessage} \n${border}`; +} + module.exports = { objToString, promptInput, @@ -897,4 +913,5 @@ module.exports = { startGraphqlServer, setUpTenantFiles, writeSecretsFile, + createNotice, }; From 04f4187c69b15e70c8e09814e4d1a2d27afe8f36 Mon Sep 17 00:00:00 2001 From: nvyas Date: Wed, 7 Aug 2024 16:38:42 +0530 Subject: [PATCH 04/10] feat: EOD push, pushed all variants --- src/commands/api-mesh/create.js | 21 ++++++++++++++++++++- src/commands/api-mesh/describe.js | 31 ++++++++++++++++++++++++------- src/commands/api-mesh/status.js | 21 ++++++++++++++++++++- 3 files changed, 64 insertions(+), 9 deletions(-) diff --git a/src/commands/api-mesh/create.js b/src/commands/api-mesh/create.js index 3df8b0d..f039239 100644 --- a/src/commands/api-mesh/create.js +++ b/src/commands/api-mesh/create.js @@ -11,7 +11,7 @@ governing permissions and limitations under the License. const { Command } = require('@oclif/core'); const chalk = require('chalk'); -const { initSdk, initRequestId, promptConfirm, importFiles } = require('../../helpers'); +const { initSdk, initRequestId, promptConfirm, importFiles, createNotice } = require('../../helpers'); const logger = require('../../classes/logger'); const { ignoreCacheFlag, @@ -171,6 +171,25 @@ class CreateCommand extends Command { ); const edgeMeshUrl = buildEdgeMeshUrl(mesh.meshId, workspaceName); + // this.log( + // await createNotice( + // `API Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:\n${chalk.underline.blue( + // 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration', + // )}`, + // ), + // ); + + this.log( + chalk.yellow( + `\nAPI Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:`, + ), + ); + this.log( + chalk.underline.blue( + 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration\n', + ), + ); + this.log('Legacy Mesh Endpoint: %s', meshUrl); this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); } else { diff --git a/src/commands/api-mesh/describe.js b/src/commands/api-mesh/describe.js index 132f7e2..573c21a 100644 --- a/src/commands/api-mesh/describe.js +++ b/src/commands/api-mesh/describe.js @@ -59,23 +59,40 @@ class DescribeCommand extends Command { this.log('Mesh ID: %s', meshId); const edgeMeshUrl = buildEdgeMeshUrl(meshId, workspaceName); + // this.log( + // await createNotice( + // `API Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:\n${chalk.underline.blue( + // 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration', + // )}`, + // ), + // ); + + this.log( + chalk.bgYellow( + `\nAPI Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:`, + ), + ); this.log( - await createNotice( - `API Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:\n${chalk.underline.blue( - 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration', - )}`, + chalk.underline.blue( + 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration\n', ), ); + this.log('Legacy Mesh Endpoint: %s', meshUrl); this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); - // this.log(chalk.bgYellow('Make sure that you update your mesh before using the edge mesh endpoint. You can validate your edge mesh status using the status command.')); this.log( - await createNotice( - `Make sure that you update your mesh before using the edge mesh endpoint.\nYou can validate your edge mesh status using the status command.`, + chalk.bgYellow( + 'Make sure that you update your mesh before using the edge mesh endpoint.\nYou can validate your edge mesh status using the status command.', ), ); + // this.log( + // await createNotice( + // `Make sure that you update your mesh before using the edge mesh endpoint.\nYou can validate your edge mesh status using the status command.`, + // ), + // ); + return meshDetails; } else { logger.error( diff --git a/src/commands/api-mesh/status.js b/src/commands/api-mesh/status.js index 36906f6..f656340 100644 --- a/src/commands/api-mesh/status.js +++ b/src/commands/api-mesh/status.js @@ -2,7 +2,7 @@ const { Command } = require('@oclif/core'); const chalk = require('chalk'); const logger = require('../../classes/logger'); -const { initRequestId, initSdk } = require('../../helpers'); +const { initRequestId, initSdk, createNotice } = require('../../helpers'); const { getMeshId, getMesh, getMeshDeployments } = require('../../lib/devConsole'); const { ignoreCacheFlag } = require('../../utils'); @@ -37,6 +37,25 @@ class StatusCommand extends Command { if (meshId) { try { const mesh = await getMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId); + + // this.log( + // await createNotice( + // `API Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:\n${chalk.underline.blue( + // 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration', + // )}`, + // ), + // ); + + this.log( + chalk.bgYellow( + `\nAPI Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:`, + ), + ); + this.log( + chalk.underline.blue( + 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration\n', + ), + ); const meshLabel = chalk.bold(`Legacy Mesh:`); this.log(''.padEnd(102, '*')); From 5ab25924d932d7fa9e7cc5f1336d4db351c8557c Mon Sep 17 00:00:00 2001 From: nvyas Date: Fri, 9 Aug 2024 13:35:07 +0530 Subject: [PATCH 05/10] feat: changes as per approved design --- src/commands/api-mesh/create.js | 11 +---------- src/commands/api-mesh/describe.js | 19 +------------------ src/commands/api-mesh/status.js | 11 +---------- src/helpers.js | 17 ----------------- 4 files changed, 3 insertions(+), 55 deletions(-) diff --git a/src/commands/api-mesh/create.js b/src/commands/api-mesh/create.js index f039239..3f9339b 100644 --- a/src/commands/api-mesh/create.js +++ b/src/commands/api-mesh/create.js @@ -11,7 +11,7 @@ governing permissions and limitations under the License. const { Command } = require('@oclif/core'); const chalk = require('chalk'); -const { initSdk, initRequestId, promptConfirm, importFiles, createNotice } = require('../../helpers'); +const { initSdk, initRequestId, promptConfirm, importFiles } = require('../../helpers'); const logger = require('../../classes/logger'); const { ignoreCacheFlag, @@ -171,14 +171,6 @@ class CreateCommand extends Command { ); const edgeMeshUrl = buildEdgeMeshUrl(mesh.meshId, workspaceName); - // this.log( - // await createNotice( - // `API Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:\n${chalk.underline.blue( - // 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration', - // )}`, - // ), - // ); - this.log( chalk.yellow( `\nAPI Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:`, @@ -189,7 +181,6 @@ class CreateCommand extends Command { 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration\n', ), ); - this.log('Legacy Mesh Endpoint: %s', meshUrl); this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); } else { diff --git a/src/commands/api-mesh/describe.js b/src/commands/api-mesh/describe.js index 573c21a..e46ff07 100644 --- a/src/commands/api-mesh/describe.js +++ b/src/commands/api-mesh/describe.js @@ -13,7 +13,7 @@ const { Command } = require('@oclif/command'); const chalk = require('chalk'); const logger = require('../../classes/logger'); -const { initSdk, initRequestId, createNotice } = require('../../helpers'); +const { initSdk, initRequestId } = require('../../helpers'); const { ignoreCacheFlag } = require('../../utils'); const { describeMesh } = require('../../lib/devConsole'); const { buildMeshUrl, buildEdgeMeshUrl } = require('../../urlBuilder'); @@ -59,14 +59,6 @@ class DescribeCommand extends Command { this.log('Mesh ID: %s', meshId); const edgeMeshUrl = buildEdgeMeshUrl(meshId, workspaceName); - // this.log( - // await createNotice( - // `API Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:\n${chalk.underline.blue( - // 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration', - // )}`, - // ), - // ); - this.log( chalk.bgYellow( `\nAPI Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:`, @@ -77,22 +69,13 @@ class DescribeCommand extends Command { 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration\n', ), ); - this.log('Legacy Mesh Endpoint: %s', meshUrl); this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); - this.log( chalk.bgYellow( 'Make sure that you update your mesh before using the edge mesh endpoint.\nYou can validate your edge mesh status using the status command.', ), ); - - // this.log( - // await createNotice( - // `Make sure that you update your mesh before using the edge mesh endpoint.\nYou can validate your edge mesh status using the status command.`, - // ), - // ); - return meshDetails; } else { logger.error( diff --git a/src/commands/api-mesh/status.js b/src/commands/api-mesh/status.js index f656340..8d102d3 100644 --- a/src/commands/api-mesh/status.js +++ b/src/commands/api-mesh/status.js @@ -2,7 +2,7 @@ const { Command } = require('@oclif/core'); const chalk = require('chalk'); const logger = require('../../classes/logger'); -const { initRequestId, initSdk, createNotice } = require('../../helpers'); +const { initRequestId, initSdk } = require('../../helpers'); const { getMeshId, getMesh, getMeshDeployments } = require('../../lib/devConsole'); const { ignoreCacheFlag } = require('../../utils'); @@ -37,15 +37,6 @@ class StatusCommand extends Command { if (meshId) { try { const mesh = await getMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId); - - // this.log( - // await createNotice( - // `API Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:\n${chalk.underline.blue( - // 'https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration', - // )}`, - // ), - // ); - this.log( chalk.bgYellow( `\nAPI Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:`, diff --git a/src/helpers.js b/src/helpers.js index c0c951c..052219b 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -17,7 +17,6 @@ const { getToken, context } = require('@adobe/aio-lib-ims'); const { CLI } = require('@adobe/aio-lib-ims/src/context'); const libConsoleCLI = require('@adobe/aio-cli-lib-console'); const { getCliEnv } = require('@adobe/aio-lib-env'); -const chalk = require('chalk'); const logger = require('../src/classes/logger'); const { UUID } = require('./classes/UUID'); @@ -881,21 +880,6 @@ async function writeSecretsFile(secretsData, meshId) { } } -// Function to generate the notice message with multiline support -async function createNotice(message) { - const lines = message.split('\n'); - const maxLength = Math.max(...lines.map(line => line.length)); - const border = chalk.yellow('='.repeat(maxLength + 12)); - - const formattedLines = lines.map(line => { - const padding = ' '.repeat(maxLength - line.length); - return `${chalk.whiteBright(line)}${padding}`; - }); - - const noticeMessage = formattedLines.join('\n'); - return `${border}\n${chalk.blueBright.bold('ⓘ')} ${noticeMessage} \n${border}`; -} - module.exports = { objToString, promptInput, @@ -913,5 +897,4 @@ module.exports = { startGraphqlServer, setUpTenantFiles, writeSecretsFile, - createNotice, }; From 2da219bfad88018714a0c944e773925a210e7a73 Mon Sep 17 00:00:00 2001 From: nvyas Date: Fri, 9 Aug 2024 17:27:14 +0530 Subject: [PATCH 06/10] feat: jest test fixed --- .../api-mesh/__tests__/create.test.js | 69 ++++++++++----- .../api-mesh/__tests__/describe.test.js | 83 +++++++++++++------ 2 files changed, 103 insertions(+), 49 deletions(-) diff --git a/src/commands/api-mesh/__tests__/create.test.js b/src/commands/api-mesh/__tests__/create.test.js index 21f9bdf..ad78ced 100644 --- a/src/commands/api-mesh/__tests__/create.test.js +++ b/src/commands/api-mesh/__tests__/create.test.js @@ -75,6 +75,10 @@ jest.mock('../../../lib/devConsole'); jest.mock('chalk', () => ({ red: jest.fn(text => text), // Return the input text without any color formatting bold: jest.fn(text => text), + underline: { + blue: jest.fn(text => text), + }, + yellow: jest.fn(text => text), })); jest.mock('crypto'); @@ -409,10 +413,23 @@ describe('create command tests', () => { "dummy_api_key", ], [ - "Mesh Endpoint: %s + " + API Mesh now runs at the edge and legacy mesh URLs will be deprecated. + Use the following link to find more information on how to migrate your mesh:", + ], + [ + "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration ", + ], + [ + "Legacy Mesh Endpoint: %s", "https://graph.adobe.io/api/dummy_mesh_id/graphql?api_key=dummy_api_key", ], + [ + "Edge Mesh Endpoint: %s + ", + "https://edge-sandbox-graph.adobe.io/api/dummy_mesh_id/graphql", + ], ] `); expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`); @@ -502,10 +519,23 @@ describe('create command tests', () => { "dummy_api_key", ], [ - "Mesh Endpoint: %s + " + API Mesh now runs at the edge and legacy mesh URLs will be deprecated. + Use the following link to find more information on how to migrate your mesh:", + ], + [ + "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration ", + ], + [ + "Legacy Mesh Endpoint: %s", "https://tigraph.adobe.io/dummy_mesh_id/graphql", ], + [ + "Edge Mesh Endpoint: %s + ", + "https://edge-sandbox-graph.adobe.io/api/dummy_mesh_id/graphql", + ], ] `); expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`); @@ -693,10 +723,23 @@ describe('create command tests', () => { "dummy_api_key", ], [ - "Mesh Endpoint: %s + " + API Mesh now runs at the edge and legacy mesh URLs will be deprecated. + Use the following link to find more information on how to migrate your mesh:", + ], + [ + "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration ", + ], + [ + "Legacy Mesh Endpoint: %s", "https://graph.adobe.io/api/dummy_mesh_id/graphql?api_key=dummy_api_key", ], + [ + "Edge Mesh Endpoint: %s + ", + "https://edge-sandbox-graph.adobe.io/api/dummy_mesh_id/graphql", + ], ] `); expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`); @@ -1883,26 +1926,6 @@ describe('create command tests', () => { ); }); - test('should not show edge mesh url if feature is disabled', async () => { - // mock the edge mesh url feature to be disabled - getTenantFeatures.mockResolvedValueOnce({ - imsOrgId: selectedOrg.code, - showCloudflareURL: false, - }); - - await CreateCommand.run(); - - expect(logSpy).not.toHaveBeenCalledWith( - expect.stringContaining('Edge Mesh Endpoint:'), - expect.any(String), - ); - - expect(logSpy).toHaveBeenCalledWith( - expect.stringContaining('Mesh Endpoint:'), - 'https://graph.adobe.io/api/dummy_mesh_id/graphql?api_key=dummy_api_key', - ); - }); - test('should return error if mesh has placeholders and the provided secrets file is invalid', async () => { parseSpy.mockResolvedValueOnce({ args: { file: 'src/commands/__fixtures__/sample_secrets_mesh.json' }, diff --git a/src/commands/api-mesh/__tests__/describe.test.js b/src/commands/api-mesh/__tests__/describe.test.js index b1b2f46..010669d 100644 --- a/src/commands/api-mesh/__tests__/describe.test.js +++ b/src/commands/api-mesh/__tests__/describe.test.js @@ -179,10 +179,27 @@ describe('describe command tests', () => { "dummy_meshId", ], [ - "Mesh Endpoint: %s - ", + " + API Mesh now runs at the edge and legacy mesh URLs will be deprecated. + Use the following link to find more information on how to migrate your mesh:", + ], + [ + "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration + ", + ], + [ + "Legacy Mesh Endpoint: %s", "https://graph.adobe.io/api/dummy_meshId/graphql", ], + [ + "Edge Mesh Endpoint: %s + ", + "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql", + ], + [ + "Make sure that you update your mesh before using the edge mesh endpoint. + You can validate your edge mesh status using the status command.", + ], ] `); expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`); @@ -227,10 +244,27 @@ describe('describe command tests', () => { "dummy_meshId", ], [ - "Mesh Endpoint: %s - ", + " + API Mesh now runs at the edge and legacy mesh URLs will be deprecated. + Use the following link to find more information on how to migrate your mesh:", + ], + [ + "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration + ", + ], + [ + "Legacy Mesh Endpoint: %s", "https://graph.adobe.io/api/dummy_meshId/graphql?api_key=dummy_apiKey", ], + [ + "Edge Mesh Endpoint: %s + ", + "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql", + ], + [ + "Make sure that you update your mesh before using the edge mesh endpoint. + You can validate your edge mesh status using the status command.", + ], ] `); }); @@ -279,10 +313,27 @@ describe('describe command tests', () => { "dummy_meshId", ], [ - "Mesh Endpoint: %s - ", + " + API Mesh now runs at the edge and legacy mesh URLs will be deprecated. + Use the following link to find more information on how to migrate your mesh:", + ], + [ + "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration + ", + ], + [ + "Legacy Mesh Endpoint: %s", "https://tigraph.adobe.io/dummy_meshId/graphql", ], + [ + "Edge Mesh Endpoint: %s + ", + "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql", + ], + [ + "Make sure that you update your mesh before using the edge mesh endpoint. + You can validate your edge mesh status using the status command.", + ], ] `); expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`); @@ -337,24 +388,4 @@ describe('describe command tests', () => { 'https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql', ); }); - - test('should not show edge mesh url if feature is disabled', async () => { - // mock the edge mesh url feature to be disabled - getTenantFeatures.mockResolvedValueOnce({ - imsOrgId: selectedOrg.code, - showCloudflareURL: false, - }); - - await DescribeCommand.run(); - - expect(logSpy).not.toHaveBeenCalledWith( - expect.stringContaining('Edge Mesh Endpoint:'), - expect.any(String), - ); - - expect(logSpy).toHaveBeenCalledWith( - expect.stringContaining('Mesh Endpoint:'), - 'https://graph.adobe.io/api/dummy_meshId/graphql?api_key=dummy_apiKey', - ); - }); }); From 092b960b592fd7abe7d683179d9076fbcdd162af Mon Sep 17 00:00:00 2001 From: nvyas Date: Fri, 9 Aug 2024 17:44:07 +0530 Subject: [PATCH 07/10] minor change --- src/commands/api-mesh/create.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/api-mesh/create.js b/src/commands/api-mesh/create.js index 3f9339b..7629579 100644 --- a/src/commands/api-mesh/create.js +++ b/src/commands/api-mesh/create.js @@ -172,7 +172,7 @@ class CreateCommand extends Command { const edgeMeshUrl = buildEdgeMeshUrl(mesh.meshId, workspaceName); this.log( - chalk.yellow( + chalk.bgYellow( `\nAPI Mesh now runs at the edge and legacy mesh URLs will be deprecated.\nUse the following link to find more information on how to migrate your mesh:`, ), ); From 5bb84f75ca47ab6f81352a6fd08a525370bdc61c Mon Sep 17 00:00:00 2001 From: nvyas Date: Fri, 9 Aug 2024 17:54:42 +0530 Subject: [PATCH 08/10] feat: fixed tests including tests that has chalk --- .../api-mesh/__tests__/create.test.js | 2 +- .../api-mesh/__tests__/describe.test.js | 62 +++++++++++-------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/commands/api-mesh/__tests__/create.test.js b/src/commands/api-mesh/__tests__/create.test.js index ad78ced..0365301 100644 --- a/src/commands/api-mesh/__tests__/create.test.js +++ b/src/commands/api-mesh/__tests__/create.test.js @@ -78,7 +78,7 @@ jest.mock('chalk', () => ({ underline: { blue: jest.fn(text => text), }, - yellow: jest.fn(text => text), + bgYellow: jest.fn(text => text), })); jest.mock('crypto'); diff --git a/src/commands/api-mesh/__tests__/describe.test.js b/src/commands/api-mesh/__tests__/describe.test.js index 010669d..fb8db7c 100644 --- a/src/commands/api-mesh/__tests__/describe.test.js +++ b/src/commands/api-mesh/__tests__/describe.test.js @@ -24,6 +24,13 @@ jest.mock('@adobe/aio-cli-lib-console', () => ({ cleanStdOut: jest.fn(), })); jest.mock('../../../lib/devConsole'); +jest.mock('chalk', () => ({ + bold: jest.fn(text => text), // Return the input text without any color formatting + underline: { + blue: jest.fn(text => text), + }, + bgYellow: jest.fn(text => text), +})); const DescribeCommand = require('../describe'); const { initSdk, initRequestId } = require('../../../helpers'); @@ -179,26 +186,26 @@ describe('describe command tests', () => { "dummy_meshId", ], [ - " - API Mesh now runs at the edge and legacy mesh URLs will be deprecated. - Use the following link to find more information on how to migrate your mesh:", + " + API Mesh now runs at the edge and legacy mesh URLs will be deprecated. + Use the following link to find more information on how to migrate your mesh:", ], [ - "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration - ", + "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration + ", ], [ "Legacy Mesh Endpoint: %s", "https://graph.adobe.io/api/dummy_meshId/graphql", ], [ - "Edge Mesh Endpoint: %s - ", + "Edge Mesh Endpoint: %s + ", "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql", ], [ - "Make sure that you update your mesh before using the edge mesh endpoint. - You can validate your edge mesh status using the status command.", + "Make sure that you update your mesh before using the edge mesh endpoint. + You can validate your edge mesh status using the status command.", ], ] `); @@ -244,26 +251,26 @@ describe('describe command tests', () => { "dummy_meshId", ], [ - " - API Mesh now runs at the edge and legacy mesh URLs will be deprecated. - Use the following link to find more information on how to migrate your mesh:", + " + API Mesh now runs at the edge and legacy mesh URLs will be deprecated. + Use the following link to find more information on how to migrate your mesh:", ], [ - "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration - ", + "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration + ", ], [ "Legacy Mesh Endpoint: %s", "https://graph.adobe.io/api/dummy_meshId/graphql?api_key=dummy_apiKey", ], [ - "Edge Mesh Endpoint: %s - ", + "Edge Mesh Endpoint: %s + ", "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql", ], [ - "Make sure that you update your mesh before using the edge mesh endpoint. - You can validate your edge mesh status using the status command.", + "Make sure that you update your mesh before using the edge mesh endpoint. + You can validate your edge mesh status using the status command.", ], ] `); @@ -313,26 +320,26 @@ describe('describe command tests', () => { "dummy_meshId", ], [ - " - API Mesh now runs at the edge and legacy mesh URLs will be deprecated. - Use the following link to find more information on how to migrate your mesh:", + " + API Mesh now runs at the edge and legacy mesh URLs will be deprecated. + Use the following link to find more information on how to migrate your mesh:", ], [ - "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration - ", + "https://developer.adobe.com/graphql-mesh-gateway/mesh/release/migration + ", ], [ "Legacy Mesh Endpoint: %s", "https://tigraph.adobe.io/dummy_meshId/graphql", ], [ - "Edge Mesh Endpoint: %s - ", + "Edge Mesh Endpoint: %s + ", "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql", ], [ - "Make sure that you update your mesh before using the edge mesh endpoint. - You can validate your edge mesh status using the status command.", + "Make sure that you update your mesh before using the edge mesh endpoint. + You can validate your edge mesh status using the status command.", ], ] `); @@ -388,4 +395,5 @@ describe('describe command tests', () => { 'https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql', ); }); + }); From 0f8ff53942be246af7c26d3bf534cbc6b343b0b0 Mon Sep 17 00:00:00 2001 From: nvyas Date: Fri, 9 Aug 2024 17:56:46 +0530 Subject: [PATCH 09/10] lint fix --- src/commands/api-mesh/__tests__/describe.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/api-mesh/__tests__/describe.test.js b/src/commands/api-mesh/__tests__/describe.test.js index fb8db7c..05dac99 100644 --- a/src/commands/api-mesh/__tests__/describe.test.js +++ b/src/commands/api-mesh/__tests__/describe.test.js @@ -395,5 +395,4 @@ describe('describe command tests', () => { 'https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql', ); }); - }); From 68f628902c3bc1f77afc00665803095abbffbb82 Mon Sep 17 00:00:00 2001 From: Andrew Molina <44038475+amolina-adobe@users.noreply.github.com> Date: Fri, 9 Aug 2024 11:29:00 -0500 Subject: [PATCH 10/10] style: apply verbiage suggestions from code review Co-authored-by: Jared Hoover <98363870+jhadobe@users.noreply.github.com> --- src/commands/api-mesh/__tests__/describe.test.js | 12 ++++++------ src/commands/api-mesh/describe.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/commands/api-mesh/__tests__/describe.test.js b/src/commands/api-mesh/__tests__/describe.test.js index 05dac99..0e65631 100644 --- a/src/commands/api-mesh/__tests__/describe.test.js +++ b/src/commands/api-mesh/__tests__/describe.test.js @@ -204,8 +204,8 @@ describe('describe command tests', () => { "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql", ], [ - "Make sure that you update your mesh before using the edge mesh endpoint. - You can validate your edge mesh status using the status command.", + "Update your mesh before using the edge mesh endpoint. + You can validate your edge mesh status using the aio api-mesh status command.", ], ] `); @@ -269,8 +269,8 @@ describe('describe command tests', () => { "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql", ], [ - "Make sure that you update your mesh before using the edge mesh endpoint. - You can validate your edge mesh status using the status command.", + "Update your mesh before using the edge mesh endpoint. + You can validate your edge mesh status using the aio api-mesh status command.", ], ] `); @@ -338,8 +338,8 @@ describe('describe command tests', () => { "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql", ], [ - "Make sure that you update your mesh before using the edge mesh endpoint. - You can validate your edge mesh status using the status command.", + "Update your mesh before using the edge mesh endpoint. + You can validate your edge mesh status using the aio api-mesh status command.", ], ] `); diff --git a/src/commands/api-mesh/describe.js b/src/commands/api-mesh/describe.js index e46ff07..fe63b85 100644 --- a/src/commands/api-mesh/describe.js +++ b/src/commands/api-mesh/describe.js @@ -73,7 +73,7 @@ class DescribeCommand extends Command { this.log(chalk.bold('Edge Mesh Endpoint: %s\n'), edgeMeshUrl); this.log( chalk.bgYellow( - 'Make sure that you update your mesh before using the edge mesh endpoint.\nYou can validate your edge mesh status using the status command.', + 'Update your mesh before using the edge mesh endpoint.\nYou can validate your edge mesh status using the aio api-mesh status command.', ), ); return meshDetails;