Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config: GraphQLConfigData,
cwd?: string,
envVars?: { [key: string]: any },
graceful?: boolean,
): Promise {
// return early if no prisma extension found
const allExtensions = [config.extensions, ...values(config.projects).map(p => p.extensions)]
if (!allExtensions.some(e => e && e.prisma)) {
return config
}
const newConfig = { ...config }
const home = os.homedir()
const env = new Environment(home)
await env.load()
if (newConfig.extensions && newConfig.extensions.prisma) {
set(
newConfig,
['extensions', 'endpoints'],
await getEndpointsFromPath(env, newConfig.extensions.prisma, cwd, envVars, graceful),
)
}
if (newConfig.projects) {
await Promise.all(
Object.keys(newConfig.projects).map(async projectName => {
const project = newConfig.projects![projectName]
if (project.extensions && project.extensions.prisma) {
set(
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)
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.`,