Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: usage of load function from @adobe/aio-cli-lib-app-config was not async #59

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/templates/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DiscoverCommand extends BaseCommand {
const apiKey = env.getCliEnv() === 'prod' ? 'aio-cli-console-auth' : 'aio-cli-console-auth-stage'
const consoleCLI = await LibConsoleCLI.init({ accessToken: this.accessToken, env: env.getCliEnv(), apiKey })

const appConfig = loadConfig({})
const appConfig = await loadConfig({})
let orgId = appConfig?.aio?.project?.org?.id
if (!orgId) {
const organizations = await consoleCLI.getOrganizations()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/templates/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class InstallCommand extends BaseCommand {
const templateManager = await templateHandler.init(this.accessToken, installConfigFile)

// 3. Install the template
const appConfig = loadConfig({})
const appConfig = await loadConfig({})
const orgId = appConfig?.aio?.project?.org?.id
const projectId = appConfig?.aio?.project?.id
if (orgId && projectId) {
Expand Down
8 changes: 4 additions & 4 deletions test/commands/templates/discover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe('interactive install', () => {
test('normal choices', async () => {
getTemplates.mockReturnValue(templates)
libEnv.getCliEnv.mockReturnValue('prod')
loadConfig.mockImplementation(() => mockAIOConfigJSON)
loadConfig.mockResolvedValue(mockAIOConfigJSON)
mockConsoleCLIInstance.getEnabledServicesForOrg.mockResolvedValue(fakeSupportedOrgServices)
// default values for Order By
const orderByCriteria = {
Expand Down Expand Up @@ -234,7 +234,7 @@ describe('interactive install', () => {
test('org does not support all services', async () => {
getTemplates.mockReturnValue(templates)
libEnv.getCliEnv.mockReturnValue('prod')
loadConfig.mockImplementation(() => {})
loadConfig.mockResolvedValue(undefined)
const supportedOrgServices = [{ code: 'ViewSDK', properties: {} }, { code: 'UserMgmtSDK', properties: {} }, { code: 'McPlacesSDK', properties: {} }]
const fakeOrg = { id: 'fakeorgid', name: 'bestorg' }
mockConsoleCLIInstance.promptForSelectOrganization.mockResolvedValue(fakeOrg)
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('interactive install', () => {
test('all templates are already installed', async () => {
getTemplates.mockReturnValue(templates)
libEnv.getCliEnv.mockReturnValue('prod')
loadConfig.mockImplementation(() => mockAIOConfigJSON)
loadConfig.mockResolvedValue(mockAIOConfigJSON)
mockConsoleCLIInstance.getEnabledServicesForOrg.mockResolvedValue(fakeSupportedOrgServices)
// default values for Order By
const orderByCriteria = {
Expand All @@ -293,7 +293,7 @@ describe('interactive install', () => {
test('no choices', async () => {
getTemplates.mockReturnValue([])
libEnv.getCliEnv.mockReturnValue('stage')
loadConfig.mockImplementation(() => mockAIOConfigJSON)
loadConfig.mockResolvedValue(mockAIOConfigJSON)
mockConsoleCLIInstance.getEnabledServicesForOrg.mockResolvedValue(fakeSupportedOrgServices)
// default values for Order By
const orderByCriteria = {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/templates/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TemplateHandler.init.mockResolvedValue(mockTemplateHandlerInstance)
jest.mock('@adobe/aio-cli-lib-app-config')
const { load: loadConfig } = require('@adobe/aio-cli-lib-app-config')
const mockAIOConfigJSON = JSON.parse('{"aio": {"project": {"id": "project-id","org": {"id": "org-id"}}}}')
loadConfig.mockImplementation(() => mockAIOConfigJSON)
loadConfig.mockResolvedValue(mockAIOConfigJSON)

// mock ims calls
jest.mock('@adobe/aio-lib-ims', () => ({
Expand Down
Loading