Skip to content

Commit

Permalink
fix: deploy error (Production workspace): Error: Cannot read properti…
Browse files Browse the repository at this point in the history
…es of undefined (reading 'getProject') (#599)

* add failing test for deploying a legacy app in the Production workspace
  • Loading branch information
shazron authored Oct 10, 2022
1 parent 29a6089 commit 3986d36
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/commands/app/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class Deploy extends BuildCommand {
const deployConfigs = this.getAppExtConfigs(flags)
const keys = Object.keys(deployConfigs)
const values = Object.values(deployConfigs)
const isStandaloneApp = (keys.length === 1 && keys[0] === 'application')

// if there are no extensions, then set publish to false
flags.publish = flags.publish && !(keys.length === 1 && keys[0] === 'application')
flags.publish = flags.publish && !isStandaloneApp
let libConsoleCLI
if (flags.publish) {
// force login at beginning (if required)
Expand Down Expand Up @@ -82,7 +83,7 @@ class Deploy extends BuildCommand {
}

// 2. Bail if workspace is production and application status is PUBLISHED, honor force-deploy
if (aioConfig?.project?.workspace?.name === 'Production' && !flags['force-deploy']) {
if (!isStandaloneApp && aioConfig?.project?.workspace?.name === 'Production' && !flags['force-deploy']) {
const extension = await this.getApplicationExtension(libConsoleCLI, aioConfig)
spinner.info(chalk.dim(JSON.stringify(extension)))
if (extension && extension.status === 'PUBLISHED') {
Expand Down
25 changes: 25 additions & 0 deletions test/commands/app/deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,31 @@ describe('run', () => {
expect(mockLibConsoleCLI.updateExtensionPointsWithoutOverwrites).toHaveBeenCalledTimes(1)
})

test('deploy for Production legacy app', async () => {
command.getAppExtConfigs.mockReturnValueOnce(createAppConfig(command.appConfig))
command.getFullConfig.mockReturnValue({
aio: {
project: {
workspace: {
name: 'Production'
},
org: {
id: '1111'
}
}
}
})
command.argv = []
await command.run()

expect(mockLibConsoleCLI.getProject).toHaveBeenCalledTimes(0)
expect(mockLibConsoleCLI.getApplicationExtensions).toHaveBeenCalledTimes(0)
expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1)
expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1)
expect(mockLibConsoleCLI.updateExtensionPoints).toHaveBeenCalledTimes(0)
expect(mockLibConsoleCLI.updateExtensionPointsWithoutOverwrites).toHaveBeenCalledTimes(0)
})

test('deploy for RETRACTED Production extension - publish', async () => {
mockLibConsoleCLI.getApplicationExtensions.mockReset()

Expand Down

0 comments on commit 3986d36

Please sign in to comment.