From bcf6fd15a110fc26cef7748711f18fe93753d8f7 Mon Sep 17 00:00:00 2001 From: sandeep-paliwal Date: Mon, 18 May 2020 17:33:59 +0530 Subject: [PATCH] Continue App init when Login timeouts (#233) --- src/commands/app/init.js | 3 +-- test/commands/app/init.test.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/commands/app/init.js b/src/commands/app/init.js index dfe28fab..9962c3e0 100644 --- a/src/commands/app/init.js +++ b/src/commands/app/init.js @@ -38,9 +38,8 @@ class InitCommand extends BaseCommand { let services = 'AdobeTargetSDK,AdobeAnalyticsSDK,CampaignSDK,McDataServicesSdk,AudienceManagerCustomerSDK' // todo fetch those from console when no --import if (!(flags.import || flags.yes)) { - const { accessToken, env: imsEnv } = await getCliInfo() - try { + const { accessToken, env: imsEnv } = await getCliInfo() const generatedFile = 'console.json' env.register(require.resolve('@adobe/generator-aio-console'), 'gen-console') res = await env.run('gen-console', { diff --git a/test/commands/app/init.test.js b/test/commands/app/init.test.js index 33b50cf7..14f777bf 100644 --- a/test/commands/app/init.test.js +++ b/test/commands/app/init.test.js @@ -257,6 +257,26 @@ describe('run', () => { expect(spyChdir).not.toHaveBeenCalled() }) + test('getCliInfo error', async () => { + mockGetCli.mockReset() + mockGetCli.mockImplementationOnce(() => { throw new Error('Error') }) + + const project = mockValidConfig() + await TheCommand.run(['--skip-install']) + + expect(yeoman.createEnv).toHaveBeenCalled() + expect(mockRegister).toHaveBeenCalledTimes(1) + const genApp = mockRegister.mock.calls[0][1] + expect(mockRun).toHaveBeenNthCalledWith(1, genApp, { + 'skip-prompt': false, + 'skip-install': true, + 'project-name': project.name, + 'adobe-services': getFullServicesList() + }) + expect(fs.ensureDirSync).not.toHaveBeenCalled() + expect(spyChdir).not.toHaveBeenCalled() + }) + test('no-path', async () => { const project = mockValidConfig() await TheCommand.run([])