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

feat: ACNA-1602 - add new flag to prevent action code deployment #537

Closed
Show file tree
Hide file tree
Changes from 5 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
10 changes: 9 additions & 1 deletion src/commands/app/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,15 @@ class Deploy extends BuildCommand {
if (filterActions) {
filterEntities = { actions: filterActions }
}

const options = { actionCode: flags['action-code'] }

const message = `Deploying actions for '${name}'`
spinner.start(message)
try {
const script = await runScript(config.hooks['deploy-actions'])
if (!script) {
deployedRuntimeEntities = await rtLib.deployActions(config, { filterEntities }, onProgress)
deployedRuntimeEntities = await rtLib.deployActions(config, { filterEntities }, onProgress, options)
}

if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
Expand Down Expand Up @@ -337,6 +340,11 @@ Deploy.flags = {
description: '[default: true] Update log forwarding configuration on server',
default: true,
allowNo: true
}),
'action-code': flags.boolean({
description: '[default: true] --no-action-code skips deployment of action code',
allowNo: true,
default: true
})
}

Expand Down
25 changes: 24 additions & 1 deletion test/commands/app/deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ test('flags', async () => {
expect(TheCommand.flags.actions.default).toEqual(true)
expect(TheCommand.flags.actions.allowNo).toEqual(true)
expect(TheCommand.flags.actions.exclusive).toEqual(['action'])

expect(typeof TheCommand.flags['action-code']).toBe('object')
expect(typeof TheCommand.flags['action-code'].description).toBe('string')
expect(TheCommand.flags['action-code'].default).toEqual(true)
expect(TheCommand.flags['action-code'].allowNo).toEqual(true)
})

describe('run', () => {
Expand Down Expand Up @@ -316,7 +321,8 @@ describe('run', () => {
expect(mockRuntimeLib.deployActions).toHaveBeenCalledWith(appConfig.application, {
filterEntities: { actions: ['a', 'b', 'c'] }
},
expect.any(Function))
expect.any(Function),
expect.objectContaining({ actionCode: true }))
})

test('build & deploy actions with no actions folder and no manifest', async () => {
Expand Down Expand Up @@ -480,6 +486,23 @@ describe('run', () => {
expect(command.buildOneExt).toHaveBeenCalledWith('application', appConfig.application, expect.objectContaining({ 'force-build': false }), expect.anything()) // force-build is true by default for build cmd
})

test('--no-action-code', async () => {
const appConfig = createAppConfig(command.appConfig)
command.getAppExtConfigs.mockReturnValueOnce(appConfig)

command.argv = ['--no-action-code', '--action', 'a']
await command.run()
expect(command.error).toHaveBeenCalledTimes(0)
expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1)
expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0)
expect(command.buildOneExt).toHaveBeenCalledTimes(1)
expect(mockRuntimeLib.deployActions).toHaveBeenCalledWith(appConfig.application, {
filterEntities: { actions: ['a'] }
},
expect.any(Function),
expect.objectContaining({ actionCode: false }))
})

test.each([
[['--no-log-forwarding-update']],
[['--no-actions']],
Expand Down