Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
fix(version): fix internal cli version
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Feb 6, 2018
1 parent b59d5de commit c84bc92
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
30 changes: 20 additions & 10 deletions cli/packages/prisma-cli-engine/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as yaml from 'js-yaml'
const debug = require('debug')('config')
import { getGraphQLConfig } from 'graphql-config'
import { values } from 'lodash'
import { getRoot } from './util'

const isDevConsole =
(process.env.CONSOLE_ENDPOINT || '').toLowerCase() === 'dev'
Expand All @@ -28,7 +29,7 @@ export class Config {
commandsDir: string = path.join(__dirname, '../dist/commands')
defaultCommand: string = 'help'
userPlugins: boolean = false
version: string = '1.3.11'
version: string = '1.1'
name: string = 'prisma'
pjson: any = {
name: 'cli-engine',
Expand Down Expand Up @@ -71,9 +72,7 @@ export class Config {
debug(`HOME`, this.home)
this.setDefinitionPaths()
this.setPaths()
if (options) {
this.readPackageJson(options)
}
this.readPackageJson(options!)
}
setOutput(out: Output) {
this.out = out
Expand Down Expand Up @@ -121,12 +120,23 @@ export class Config {

return null
}
private readPackageJson(options: RunOptions) {
this.mock = options.mock
this.argv = options.argv || this.argv
if (options.root) {
this.root = options.root
const pjsonPath = path.join(options.root, 'package.json')
private readPackageJson(options?: RunOptions) {
if (options) {
this.mock = options.mock
this.argv = options.argv || this.argv
if (options.root) {
this.root = options.root
const pjsonPath = path.join(options.root, 'package.json')
const pjson = fs.readJSONSync(pjsonPath)
if (pjson && pjson['cli-engine']) {
this.pjson = pjson
this.version = pjson.version
}
}
} else {
const root = getRoot()
this.root = root
const pjsonPath = path.join(root, 'package.json')
const pjson = fs.readJSONSync(pjsonPath)
if (pjson && pjson['cli-engine']) {
this.pjson = pjson
Expand Down
13 changes: 13 additions & 0 deletions cli/packages/prisma-cli-engine/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { stdtermwidth } from './Output/actions/screen'
import * as path from 'path'

const debug = require('debug')('util')

Expand Down Expand Up @@ -64,3 +65,15 @@ export function getCommandId(argv: string[]) {
}
}
}

export function getRoot() {
const parentFilename = module.parent!.parent!
? module.parent!.parent!.filename
: module.parent!.filename
const findUp = require('find-up')
return path.dirname(
findUp.sync('package.json', {
cwd: parentFilename,
}),
)
}

0 comments on commit c84bc92

Please sign in to comment.