From e3e09316e5d12fa09bd6a6a1e316dd3c6150e5a0 Mon Sep 17 00:00:00 2001 From: timsuchanek Date: Tue, 8 May 2018 17:59:02 +0200 Subject: [PATCH] cli: fix demo endpoint generation --- .../src/utils/EndpointDialog.ts | 2 ++ .../prisma-yml/src/PrismaDefinition.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/cli/packages/prisma-cli-core/src/utils/EndpointDialog.ts b/cli/packages/prisma-cli-core/src/utils/EndpointDialog.ts index 8bfb5ecfae..34e1d1df41 100644 --- a/cli/packages/prisma-cli-core/src/utils/EndpointDialog.ts +++ b/cli/packages/prisma-cli-core/src/utils/EndpointDialog.ts @@ -342,6 +342,8 @@ export class EndpointDialog { stage = await this.askForStage('dev') } + workspace = workspace || cluster.workspaceSlug + return { endpoint: cluster.getApiEndpoint(service, stage, workspace), cluster, diff --git a/cli/packages/prisma-yml/src/PrismaDefinition.ts b/cli/packages/prisma-yml/src/PrismaDefinition.ts index f9e419308e..7edde2f535 100644 --- a/cli/packages/prisma-yml/src/PrismaDefinition.ts +++ b/cli/packages/prisma-yml/src/PrismaDefinition.ts @@ -160,6 +160,8 @@ export class PrismaDefinitionClass { const clusterName = this.getClusterName() const cluster = this.env.clusterByName(clusterName!)! if ( + this.definition && + this.definition.cluster && clusterName && cluster && cluster.shared && @@ -177,6 +179,22 @@ and execute ${chalk.bold.green( )} again, to get that value auto-filled.`, ) } + if ( + this.definition && + this.definition.endpoint && + clusterName && + cluster && + cluster.shared && + !cluster.isPrivate && + !this.getWorkspace() && + clusterName !== 'shared-public-demo' + ) { + throw new Error( + `The provided endpoint ${ + this.definition.endpoint + } points to a demo cluster, but is missing the workspace slug. A valid demo endpoint looks like this: https://eu1.prisma.sh/myworkspace/service-name/stage-name`, + ) + } this.env.sharedClusters }