From 76be22e47443d7acadd6c35b21d9969a0be2dee0 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 29 May 2025 12:48:01 +0800 Subject: [PATCH 1/3] add failing test --- test/DeployServiceCommand.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/DeployServiceCommand.test.js b/test/DeployServiceCommand.test.js index 0189204b..c0f8dd66 100644 --- a/test/DeployServiceCommand.test.js +++ b/test/DeployServiceCommand.test.js @@ -62,8 +62,8 @@ describe('DeployServiceCommand', () => { getCliEnv.mockReturnValue(mockEnv) }) - test('should use CLI context by default', async () => { - context.getCurrent.mockResolvedValue(CLI) + test('should use CLI context (default) if current context undefined', async () => { + context.getCurrent.mockResolvedValue(undefined) getToken.mockResolvedValue(mockToken) const result = await command.getAccessToken() From 345d82602a69d866dc71c7aaf85efd73efd8b386 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 29 May 2025 12:48:59 +0800 Subject: [PATCH 2/3] fix: error when current ims context is undefined --- src/DeployServiceCommand.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DeployServiceCommand.js b/src/DeployServiceCommand.js index cdba96e4..b1ab98f7 100644 --- a/src/DeployServiceCommand.js +++ b/src/DeployServiceCommand.js @@ -38,7 +38,7 @@ class DeployServiceCommand extends RuntimeBaseCommand { let contextName = CLI // default const currentContext = await context.getCurrent() // potential override - if (currentContext !== CLI) { + if (currentContext && currentContext !== CLI) { contextName = currentContext } else { await context.setCli({ 'cli.bare-output': true }, false) // set this globally From 8678b259f0790a4b526d7f53ecd63117bbd34672 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 29 May 2025 13:06:05 +0800 Subject: [PATCH 3/3] CLI reference was undefined --- src/DeployServiceCommand.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DeployServiceCommand.js b/src/DeployServiceCommand.js index b1ab98f7..042f277e 100644 --- a/src/DeployServiceCommand.js +++ b/src/DeployServiceCommand.js @@ -14,7 +14,8 @@ const { Flags } = require('@oclif/core') const { PropertyDefault } = require('./properties') const runtimeLib = require('@adobe/aio-lib-runtime') -const { getToken, context, CLI } = require('@adobe/aio-lib-ims') +const { getToken, context } = require('@adobe/aio-lib-ims') +const { CLI } = require('@adobe/aio-lib-ims/src/context') const { getCliEnv } = require('@adobe/aio-lib-env') const RuntimeBaseCommand = require('./RuntimeBaseCommand')