Skip to content

Commit

Permalink
fix(cli): add feature flags to version command
Browse files Browse the repository at this point in the history
Closes #3054
  • Loading branch information
timsuchanek committed Jul 17, 2020
1 parent 4c7af29 commit 4463a28
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/packages/cli/src/Version.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { Command, getVersion, resolveBinary, arg } from '@prisma/sdk'
import {
Command,
getVersion,
resolveBinary,
arg,
getSchemaPath,
getSchema,
getConfig,
} from '@prisma/sdk'
import { getPlatform } from '@prisma/get-platform'
import fs from 'fs'
import path from 'path'
Expand Down Expand Up @@ -54,9 +62,32 @@ export class Version implements Command {
['Format Binary', this.printBinaryInfo(fmtBinary)],
]

const featureFlags = await this.getFeatureFlags()
if (featureFlags && featureFlags.length > 0) {
rows.push(['Preview Features', featureFlags.join(', ')])
}

return this.printTable(rows, args['--json'])
}

private async getFeatureFlags(): Promise<string[]> {
try {
const datamodel = await getSchema()
const config = await getConfig({
datamodel,
})
const generator = config.generators.find(
(g) => g.experimentalFeatures.length > 0,
)
if (generator) {
return generator.experimentalFeatures
}
} catch (e) {
// console.error(e)
}
return []
}

private printBinaryInfo({
path: absolutePath,
version,
Expand Down

0 comments on commit 4463a28

Please sign in to comment.