Skip to content

Fix(apps)/not update app config #206

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions docs/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ updates an existing private app in the Zendesk products specified in the apps ma
```
USAGE
$ zcli apps:update APPDIRECTORIES

OPTIONS
--not-update-setting Does not update current app config on instance

EXAMPLES
$ zcli apps:update
$ zcli apps:update --not-update-setting
```

## `zcli apps:validate APPDIRECTORY`
Expand Down
15 changes: 10 additions & 5 deletions packages/zcli-apps/src/commands/apps/update.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Command, CliUx } from '@oclif/core'
import { Command, CliUx, Flags } from '@oclif/core'
import { getAllConfigs } from '../../utils/appConfig'
import { CLIError } from '@oclif/core/lib/errors'
import * as chalk from 'chalk'
Expand All @@ -16,6 +16,10 @@ export default class Update extends Command {
{ name: 'appDirectories', required: true, default: '.' }
]

static flags = {
'not-update-setting': Flags.boolean({ default: false, description: 'Does not update current app config on instance' })
}

static strict = false

getAppID (appPath: string) {
Expand All @@ -25,14 +29,14 @@ export default class Update extends Command {
return app_id
}

async installApp (appConfig: ZcliConfigFileContent, uploadId: number, appPath: string, manifest: Manifest) {
async installApp (appConfig: ZcliConfigFileContent, uploadId: number, appPath: string, manifest: Manifest, updateSetting: boolean) {
CliUx.ux.action.start('Deploying app')
const { job_id } = await deployApp('PUT', `api/v2/apps/${appConfig.app_id}`, uploadId)

try {
const { app_id }: any = await getUploadJobStatus(job_id, appPath)
CliUx.ux.action.stop('Deployed')
if (!manifest.requirementsOnly && manifest.location) {
if (!manifest.requirementsOnly && manifest.location && !updateSetting) {
Object.keys(manifest.location).forEach(async product => {
if (!updateProductInstallation(appConfig, manifest, app_id, product)) {
this.error(chalk.red(`Failed to update ${manifest.name} with app_id: ${app_id}`))
Expand All @@ -47,7 +51,8 @@ export default class Update extends Command {
}

async run () {
const { argv: appDirectories } = await this.parse(Update)
const { argv: appDirectories, flags } = await this.parse(Update)
const updateSetting = flags['not-update-setting']

for (const appPath of appDirectories) {
validateAppPath(appPath)
Expand All @@ -65,7 +70,7 @@ export default class Update extends Command {

CliUx.ux.action.stop('Uploaded')
try {
await this.installApp(appConfig, upload_id, appPath, manifest)
await this.installApp(appConfig, upload_id, appPath, manifest, updateSetting)
} catch (error) {
this.error(chalk.red(error))
}
Expand Down