From cd6f05bd36ca60b174515be5ccd892b503fe3880 Mon Sep 17 00:00:00 2001 From: waldekmastykarz Date: Wed, 20 Nov 2024 19:38:01 +0100 Subject: [PATCH] Fixes prompting for entra app. Closes #6498 --- src/m365/base/AppCommand.spec.ts | 5 ++++- src/m365/base/AppCommand.ts | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/m365/base/AppCommand.spec.ts b/src/m365/base/AppCommand.spec.ts index 4bb470931b6..ade0f671732 100644 --- a/src/m365/base/AppCommand.spec.ts +++ b/src/m365/base/AppCommand.spec.ts @@ -142,7 +142,10 @@ describe('AppCommand', () => { } ] })); - sinon.stub(cli, 'handleMultipleResultsFound').resolves({ appIdIndex: 1 }); + sinon.stub(cli, 'handleMultipleResultsFound').resolves({ + "appId": "9c79078b-815e-4a3e-bb80-2aaf2d9e9b3d", + "name": "CLI app1" + }); sinon.stub(Command.prototype, 'action').resolves(); try { diff --git a/src/m365/base/AppCommand.ts b/src/m365/base/AppCommand.ts index a8e1e1a194c..21a005fd593 100644 --- a/src/m365/base/AppCommand.ts +++ b/src/m365/base/AppCommand.ts @@ -90,9 +90,12 @@ export default abstract class AppCommand extends Command { } if (this.m365rcJson.apps.length > 1) { - const resultAsKeyValuePair = formatting.convertArrayToHashTable('appIdIndex', this.m365rcJson.apps); - const result = await cli.handleMultipleResultsFound<{ appIdIndex: number }>(`Multiple Entra apps found in ${m365rcJsonPath}.`, resultAsKeyValuePair); - this.appId = ((this.m365rcJson as M365RcJson).apps as M365RcJsonApp[])[result.appIdIndex].appId; + this.m365rcJson.apps.forEach((app, index) => { + (app as any).appIdIndex = index; + }); + const resultAsKeyValuePair = formatting.convertArrayToHashTable('appId', this.m365rcJson.apps); + const result = await cli.handleMultipleResultsFound(`Multiple Entra apps found in ${m365rcJsonPath}.`, resultAsKeyValuePair); + this.appId = result.appId; await super.action(logger, args); } }