Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Razon committed Oct 18, 2023
1 parent 7ace423 commit b30421f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
8 changes: 6 additions & 2 deletions packages/cli/src/commands/profile/config/update.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { profileStore } from '@preevy/core'
import { Flags, ux } from '@oclif/core'
import { mapValues, omit, pickBy } from 'lodash'
import chalk from 'chalk'
import {
removeDriverFlagPrefix,
extractDriverFlags,
Expand Down Expand Up @@ -34,7 +35,10 @@ const validateUnset = (driver: DriverName, unset: string[]) => {

const unknownUnset = unset.filter(k => !driverFlagsAvailableToUnset.has(k))
if (unknownUnset.length) {
ux.error(`Unknown unset values for driver ${driver}: ${unknownUnset.join(', ')}. Available options to unset: ${[...driverFlagsAvailableToUnset.keys()].join(', ')}`, { exit: 1 })
ux.error(
`Unknown unset values for driver ${chalk.bold(driver)}: ${unknownUnset.map(x => chalk.bold(x)).join(', ')}. Available options to unset: ${[...driverFlagsAvailableToUnset.keys()].map(x => chalk.bold(x)).join(', ')}`,
{ exit: 1 },
)
}
}

Expand Down Expand Up @@ -80,7 +84,7 @@ export default class UpdateProfileConfig extends ProfileCommand<typeof UpdatePro

await pStore.setDefaultFlags(driver, updated)

ux.info(`Updated configuration for driver ${driver}:`)
ux.info(`Updated configuration for driver ${chalk.bold(driver)}:`)
if (Object.keys(updated).length) {
ux.styledObject(updated)
} else {
Expand Down
31 changes: 19 additions & 12 deletions packages/cli/src/commands/profile/config/view.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
import { profileStore } from '@preevy/core'
import { ux } from '@oclif/core'
import {
DriverName,
} from '../../../drivers'
import { EOL } from 'os'
import chalk from 'chalk'
import { DriverName } from '../../../drivers'
import ProfileCommand from '../../../profile-command'

// eslint-disable-next-line no-use-before-define
export default class ViewProfileConfig extends ProfileCommand<typeof ViewProfileConfig> {
static description = 'View profile configuration'

static strict = false

static enableJsonFlag = true

async run(): Promise<void> {
async run(): Promise<unknown> {
const pStore = profileStore(this.store)
const driver = this.profile.driver as DriverName
const origin = await pStore.defaultFlags(driver)
const config = await pStore.defaultFlags(driver)
if (!driver) {
ux.info('Missing driver configuration in profile, use preevy profile config update --driver flag to set the desired machine driver')
return
ux.error([
'Missing driver configuration in profile.',
`Run ${chalk.bold(`${this.config.bin} profile config update --driver <driver>`)} to set the desired machine driver`,
].join(EOL))
}
if (this.flags.json) {
return { driver, defaultFlags: config }
}
ux.info(`Current configuration for driver ${chalk.bold(driver)}:`)
if (Object.keys(config).length) {
ux.styledObject(config)
} else {
ux.info('(empty)')
}
ux.info(`Current configuration for ${driver}:`)
ux.styledObject(origin)
return undefined
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/proxy/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class Urls extends ProfileCommand<typeof Urls> {
const composeInspector = commands.proxy.inspectRunningComposeApp(args['compose-project'])
const envId = await composeInspector.getEnvId()
if (!envId) {
throw new Error('Proxy not running, use preevy proxy connect <compose-project>')
throw new Error(`Proxy not running, use ${this.config.bin} proxy connect <compose-project>`)
}
const commandArgs = [`--id=${envId}`, ...formatFlagsToArgs(flags, PreevyUrlsCmd.flags), ...Object.values(pick(this.args, Object.keys(PreevyUrlsCmd.args))).map(x => `${x}`)]
await this.config.runCommand('urls', commandArgs)
Expand Down

0 comments on commit b30421f

Please sign in to comment.