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

Commit

Permalink
feat(cli): Add support for PRISMA_CLOUD_SESSION_KEY env var
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Jan 25, 2018
1 parent d614d43 commit e8b9b82
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 90 deletions.
5 changes: 2 additions & 3 deletions cli/packages/prisma-cli-core/src/commands/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,10 @@ ${chalk.gray(
if (
workspace &&
!workspace.startsWith('public-') &&
(!this.env.globalRC.cloudSessionKey ||
this.env.globalRC.cloudSessionKey === '')
(!this.env.cloudSessionKey || this.env.cloudSessionKey === '')
) {
await this.client.login()
cluster.clusterSecret = this.env.globalRC.cloudSessionKey
cluster.clusterSecret = this.env.cloudSessionKey
}
}

Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-cli-core/src/commands/list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class List extends Command {
let gotCloud = false

try {
if (this.env.globalRC.cloudSessionKey) {
if (this.env.cloudSessionKey) {
const services = await this.client.getCloudServices()
const mappedServices = services.filter(s => s.cluster).map(s => ({
name: s.name,
Expand Down
4 changes: 2 additions & 2 deletions cli/packages/prisma-cli-engine/src/CLI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ export class CLI {
}

setRavenUserContext() {
if (this.cmd && this.cmd.env && this.cmd.env.globalRC.cloudSessionKey) {
const data = jwt.decode(this.cmd.env.globalRC.cloudSessionKey)
if (this.cmd && this.cmd.env && this.cmd.env.cloudSessionKey) {
const data = jwt.decode(this.cmd.env.cloudSessionKey)
Raven.mergeContext({
user: {
fid: getFid(),
Expand Down
4 changes: 2 additions & 2 deletions cli/packages/prisma-cli-engine/src/Client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ To reset the key pair, please run ${chalk.bold.green('prisma local start')}
const options = {
headers: {},
}
if (this.env.globalRC.cloudSessionKey) {
if (this.env.cloudSessionKey) {
options.headers = {
Authorization: `Bearer ${this.env.globalRC.cloudSessionKey}`,
Authorization: `Bearer ${this.env.cloudSessionKey}`,
}
}
const client = new GraphQLClient(this.config.cloudApiEndpoint, options)
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-cli-engine/src/StatusChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class StatusChecker {
argv,
error: serializedError,
})
const auth = this.env ? this.env.globalRC.cloudSessionKey : undefined
const auth = this.env ? this.env.cloudSessionKey : undefined
const hashDate = new Date().toISOString()
const mac = getMac()

Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"dependencies": {
"fs-extra": "^5.0.0",
"prisma-cli-core": "1.0.5-2",
"prisma-cli-engine": "1.0.3-6",
"prisma-cli-engine": "1.0.3-7",
"semver": "^5.4.1",
"source-map-support": "^0.4.18"
},
Expand Down
4 changes: 4 additions & 0 deletions cli/packages/prisma-yml/src/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export class Environment {
await Promise.all([this.loadGlobalRC(), this.setSharedClusters()])
}

get cloudSessionKey(): string | undefined {
return process.env.PRISMA_CLOUD_SESSION_KEY || this.globalRC.cloudSessionKey
}

async setSharedClusters() {
try {
const res = await fetch('https://stats.graph.cool/', {
Expand Down
80 changes: 0 additions & 80 deletions cli/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4003,66 +4003,6 @@ pretty-format@^21.2.1:
ansi-regex "^3.0.0"
ansi-styles "^3.2.0"

prisma-cli-engine@1.0.3-6:
version "1.0.3-6"
resolved "https://registry.yarnpkg.com/prisma-cli-engine/-/prisma-cli-engine-1.0.3-6.tgz#2d798966edeb6145f109d373d5b5ae541d16d6fa"
dependencies:
"@heroku/linewrap" "^1.0.0"
ajv "5"
ansi-escapes "^3.0.0"
ansi-styles "^3.2.0"
bluebird "^3.5.0"
cache-require-paths "^0.3.0"
callsites "^2.0.0"
cardinal "^1.0.0"
chalk "^2.3.0"
charm "^1.0.2"
debug "^3.1.0"
directory-tree "^2.0.0"
dotenv "^4.0.0"
figures "^2.0.0"
find-up "^2.1.0"
fs-extra "^5.0.0"
graphcool-inquirer "^1.0.3"
graphql-request "^1.3.4"
isomorphic-fetch "^2.2.1"
jsonwebtoken "^8.1.0"
klaw-sync "^3.0.0"
lodash "^4.17.4"
lodash.ary "^4.1.1"
lodash.defaults "^4.2.0"
lodash.flatten "^4.4.0"
lodash.get "^4.4.2"
lodash.groupby "^4.6.0"
lodash.identity "^3.0.0"
lodash.keys "^4.2.0"
lodash.maxby "4.x"
lodash.merge "4.x"
lodash.partial "^4.2.1"
lodash.property "^4.4.2"
lodash.result "^4.5.2"
lodash.uniqby "^4.7.0"
marked "^0.3.6"
marked-terminal "^2.0.0"
memfs "^2.5.3"
opn "^5.1.0"
prisma-json-schema "^0.0.1"
prisma-yml "1.0.14-4"
raven "2.3.0"
replaceall "^0.1.6"
rwlockfile "^1.4.8"
scuid "^1.0.2"
serialize-error "^2.1.0"
source-map-support "^0.4.18"
string "3.x"
string-similarity "^1.2.0"
strip-ansi "^4.0.0"
supports-color "^4.4.0"
treeify "^1.0.1"
update-notifier "^2.3.0"
validator "^8.2.0"
yaml-ast-parser "^0.0.34"

prisma-json-schema@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/prisma-json-schema/-/prisma-json-schema-0.0.1.tgz#0802e156a293faefdf21e5e41beb8d3681f45cb1"
Expand All @@ -4087,26 +4027,6 @@ prisma-yml@0.0.4:
scuid "^1.0.2"
yaml-ast-parser "^0.0.40"

prisma-yml@1.0.14-4:
version "1.0.14-4"
resolved "https://registry.yarnpkg.com/prisma-yml/-/prisma-yml-1.0.14-4.tgz#18b1cda82f65ac36f38a6aa8fbea0b57068948cd"
dependencies:
ajv "5"
bluebird "^3.5.1"
chalk "^2.3.0"
debug "^3.1.0"
dotenv "^4.0.0"
fs-extra "^5.0.0"
isomorphic-fetch "^2.2.1"
js-yaml "^3.10.0"
json-stable-stringify "^1.0.1"
jsonwebtoken "^8.1.0"
lodash "^4.17.4"
prisma-json-schema "^0.0.1"
replaceall "^0.1.6"
scuid "^1.0.2"
yaml-ast-parser "^0.0.40"

private@^0.1.7:
version "0.1.8"
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
Expand Down

0 comments on commit e8b9b82

Please sign in to comment.