Skip to content
Merged
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
12 changes: 10 additions & 2 deletions src/commands/features/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ describe('features create', () => {
])
.it('returns a new feature with quick create',
(ctx) => {
expect(JSON.parse(ctx.stdout)).to.eql(mockFeature)
const jsonStartIndex = ctx.stdout.indexOf('{')
const jsonEndIndex = ctx.stdout.lastIndexOf('}')
const jsonString = ctx.stdout.slice(jsonStartIndex, jsonEndIndex + 1)
const parsedJson = JSON.parse(jsonString)
expect(parsedJson).to.eql(mockFeature)
})

dvcTest()
Expand Down Expand Up @@ -309,7 +313,11 @@ describe('features create', () => {
])
.it('returns a new feature with quick create not in headless mode',
(ctx) => {
expect(JSON.parse(ctx.stdout)).to.eql(mockFeature)
const jsonStartIndex = ctx.stdout.indexOf('{')
const jsonEndIndex = ctx.stdout.lastIndexOf('}')
const jsonString = ctx.stdout.slice(jsonStartIndex, jsonEndIndex + 1)
const parsedJson = JSON.parse(jsonString)
expect(parsedJson).to.eql(mockFeature)
})

// dvcTest()
Expand Down
17 changes: 13 additions & 4 deletions src/commands/features/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { descriptionPrompt, getSdkVisibilityPrompt, keyPrompt, namePrompt } from
import CreateCommand from '../createCommand'
import { VariableListOptions } from '../../ui/prompts/listPrompts/variablesListPrompt'
import { Flags } from '@oclif/core'
import { CreateFeatureDto } from '../../api/schemas'
import { CreateFeatureDto, Feature } from '../../api/schemas'
import { VariationListOptions } from '../../ui/prompts/listPrompts/variationsListPrompt'
import {
mergeQuickFeatureParamsWithAnswers,
setupTargetingForEnvironments
import {
mergeQuickFeatureParamsWithAnswers,
setupTargetingForEnvironments
} from '../../utils/features/quickCreateFeatureUtils'
import { fetchProject } from '../../api/projects'

Expand Down Expand Up @@ -53,6 +53,7 @@ export default class CreateFeature extends CreateCommand {
const feature = await createFeature(this.authToken, this.projectKey, featureParams)
await setupTargetingForEnvironments(this.authToken, this.projectKey, feature.key)
this.writer.showResults(feature)
this.showSuggestedCommand(feature)
return
}

Expand All @@ -78,4 +79,12 @@ export default class CreateFeature extends CreateCommand {
const result = await createFeature(this.authToken, this.projectKey, params)
this.writer.showResults(result)
}

private showSuggestedCommand(feature: Feature) {
const message = `\nFeature "${feature.name}" successfully created!\n` +
'\nTo update the targeting rules, use: \n\n' +
` dvc targeting update ${feature.key}\n`

this.writer.showRawResults(message)
}
}