Skip to content

Commit

Permalink
do not call console if we are not publishing, was forcing login (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
purplecabbage authored Nov 9, 2024
1 parent 31ebbbd commit b1b95f6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/commands/app/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Deploy extends BuildCommand {

// flags
flags['web-assets'] = flags['web-assets'] && !flags.action
// Deploy only a specific action, the flags can be specified multiple times, this will set --no-publish
flags.publish = flags.publish && !flags.action

const deployConfigs = await this.getAppExtConfigs(flags)
Expand Down Expand Up @@ -80,7 +81,8 @@ class Deploy extends BuildCommand {
}

// 2. If workspace is prod and has extensions, check if the app is published
if (!isStandaloneApp && aioConfig?.project?.workspace?.name === 'Production') {
// if --no-publish, we skip this check
if (flags.publish && aioConfig?.project?.workspace?.name === 'Production') {
const extension = await this.getApplicationExtension(aioConfig)
if (extension && extension.status === 'PUBLISHED') {
flags.publish = false // if the app is production and published, then skip publish later on
Expand Down
28 changes: 27 additions & 1 deletion test/commands/app/deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,33 @@ describe('run', () => {
expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1)
expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0)
expect(command.buildOneExt).toHaveBeenCalledTimes(1)
expect(mockLibConsoleCLI.getApplicationExtensions).toHaveBeenCalledTimes(1)
// action flag sets --no-publish, which means no getApplicationExtensions
expect(mockLibConsoleCLI.getApplicationExtensions).not.toHaveBeenCalled()
})

test('deploy does not require logged in user with --no-publish (workspace: Production)', async () => {
command.getAppExtConfigs.mockResolvedValueOnce(createAppConfig(command.appConfig, 'exc'))
mockGetExtensionPointsRetractedApp() // not published
command.getFullConfig.mockResolvedValue({
aio: {
project: {
workspace: {
name: 'Production'
},
org: {
id: '1111'
}
}
}
})

command.argv = ['--no-publish']
await command.run()
expect(command.error).toHaveBeenCalledTimes(0)
expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1)
expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1)
expect(command.buildOneExt).toHaveBeenCalledTimes(1)
expect(mockLibConsoleCLI.getApplicationExtensions).not.toHaveBeenCalled()
})

test('build & deploy only some actions using --action', async () => {
Expand Down

0 comments on commit b1b95f6

Please sign in to comment.