Skip to content

Commit 33eb1a2

Browse files
authored
Ensure Config Reload Before Deploy (#906)
* refactor: reload config just before deploy
1 parent 9a56b79 commit 33eb1a2

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/commands/app/deploy.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const LogForwarding = require('../../lib/log-forwarding')
3030
const { sendAppAssetsDeployedAuditLog, sendAppDeployAuditLog } = require('../../lib/audit-logger')
3131
const { setRuntimeApiHostAndAuthHandler, getAccessToken } = require('../../lib/auth-helper')
3232
const logActions = require('../../lib/log-actions')
33+
const aioConfigLoader = require('@adobe/aio-lib-core-config')
3334

3435
const PRE_DEPLOY_EVENT_REG = 'pre-deploy-event-reg'
3536
const POST_DEPLOY_EVENT_REG = 'post-deploy-event-reg'
@@ -230,6 +231,7 @@ class Deploy extends BuildCommand {
230231
// output should be "Error : <plugin-name> : <error-message>\n" for each failure
231232
this.error(hookResults.failures.map(f => `${f.plugin.name} : ${f.error.message}`).join('\nError: '), { exit: 1 })
232233
}
234+
aioConfigLoader.reload()
233235
deployedRuntimeEntities = await rtLib.deployActions(config, { filterEntities, useForce: flags['force-deploy'] }, onProgress)
234236
}
235237

test/commands/app/deploy.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ beforeEach(() => {
176176
helpers.buildExcShellViewExtensionMetadata.mockReset()
177177
helpers.createWebExportFilter.mockReset()
178178
helpers.rewriteActionUrlInEntities.mockReset()
179+
mockConfig.reload.mockReset()
179180
mockLogForwarding.isLocalConfigChanged.mockReset()
180181
mockLogForwarding.getLocalConfigWithSecrets.mockReset()
181182
mockLogForwarding.updateServerConfig.mockReset()
@@ -868,6 +869,24 @@ describe('run', () => {
868869
expect(command.error).toHaveBeenCalledTimes(0)
869870
})
870871

872+
test('deploy reloads config before deploying actions', async () => {
873+
command.getAppExtConfigs.mockResolvedValueOnce(createAppConfig(command.appConfig))
874+
const noScriptFound = undefined
875+
helpers.runInProcess
876+
.mockResolvedValueOnce(noScriptFound) // pre-app-deploy
877+
.mockResolvedValueOnce(noScriptFound) // deploy-actions
878+
.mockResolvedValueOnce(noScriptFound) // post-app-deploy
879+
880+
command.argv = ['--no-web-assets']
881+
await command.run()
882+
883+
expect(mockConfig.reload).toHaveBeenCalledTimes(1)
884+
expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1)
885+
expect(mockConfig.reload.mock.invocationCallOrder[0]).toBeLessThan(
886+
mockRuntimeLib.deployActions.mock.invocationCallOrder[0]
887+
)
888+
})
889+
871890
test('deploy (has deploy-actions and deploy-static hooks)', async () => {
872891
command.getAppExtConfigs.mockResolvedValueOnce(createAppConfig(command.appConfig))
873892
const noScriptFound = undefined

0 commit comments

Comments
 (0)