Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function makeConfigFromPath(
cwd: string = process.cwd(),
envVars?: { [key: string]: any },
): Promise {
const ymlPath = path.join(cwd, 'prisma.yml')
if (!fs.existsSync(ymlPath)) {
return null
}
const home = os.homedir()
const env = new Environment(home)
await env.load()
const definition = new PrismaDefinitionClass(env, ymlPath, envVars)
await definition.load({})
const serviceName = definition.service!
const stage = definition.stage!
const clusterName = definition.cluster
if (!clusterName) {
throw new Error(`No cluster set. Please set the "cluster" property in your prisma.yml`)
}
const cluster = await definition.getCluster()
if (!cluster) {
throw new Error(
`Cluster ${clusterName} provided in prisma.yml could not be found in global ~/.prisma/config.yml.
Please check in ~/.prisma/config.yml, if the cluster exists.
You can use \`docker-compose up -d\` to start a new cluster.`,
)
}
const url = cluster.getApiEndpoint(serviceName, stage, definition.getWorkspace() || undefined)
async function getEndpointsFromPath(
env: Environment,
ymlPath: string,
cwd?: string,
envVars?: { [key: string]: any },
graceful?: boolean,
): Promise {
const joinedYmlPath = cwd ? path.join(cwd, ymlPath) : ymlPath
const definition = new PrismaDefinitionClass(env, joinedYmlPath, envVars)
await definition.load({}, undefined, graceful)
const serviceName = definition.service!
const stage = definition.stage!
const clusterName = definition.cluster
if (!clusterName) {
throw new Error(`No cluster set. Please set the "cluster" property in your prisma.yml`)
}
const cluster = await definition.getCluster()
if (!cluster) {
throw new Error(
`Cluster ${clusterName} provided in prisma.yml could not be found in global ~/.prisma/config.yml.
Please check in ~/.prisma/config.yml, if the cluster exists.
You can use \`docker-compose up -d\` to start a new cluster.`,
)
}
const url = cluster.getApiEndpoint(serviceName, stage, definition.getWorkspace() || undefined)