@prisma/engine-core
Advanced tools
Comparing version 0.0.38 to 0.0.40
@@ -5,8 +5,5 @@ /// <reference types="node" /> | ||
interface EngineConfig { | ||
prismaYmlPath?: string; | ||
prismaConfig?: string; | ||
cwd?: string; | ||
datamodel: string; | ||
datamodelJson?: string; | ||
debug?: boolean; | ||
schemaInferrerPath?: string; | ||
prismaPath?: string; | ||
@@ -22,4 +19,2 @@ fetcher?: (query: string) => Promise<{ | ||
export declare class NodeEngine extends Engine { | ||
prismaYmlPath?: string; | ||
prismaConfig?: string; | ||
port?: number; | ||
@@ -42,12 +37,8 @@ debug: boolean; | ||
static defaultPrismaPath: string; | ||
constructor({ prismaConfig, datamodelJson, prismaYmlPath, datamodel, schemaInferrerPath, prismaPath, ...args }: EngineConfig); | ||
constructor({ cwd, datamodel, prismaPath, ...args }: EngineConfig); | ||
/** | ||
* Resolve the prisma.yml | ||
*/ | ||
getPrismaYml(ymlPath: string): Promise<string>; | ||
/** | ||
* Starts the engine, returns the url that it runs on | ||
*/ | ||
start(): Promise<void>; | ||
fail: (e: any, why: any) => void; | ||
fail: (e: any, why: any) => Promise<void>; | ||
/** | ||
@@ -62,6 +53,2 @@ * If Prisma runs, stop it | ||
/** | ||
* Replace the port in the Prisma Config | ||
*/ | ||
protected generatePrismaConfig(): string; | ||
/** | ||
* Make sure that our internal port is not conflicting with the prisma.yml's port | ||
@@ -68,0 +55,0 @@ * @param str config |
@@ -24,5 +24,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const util_1 = require("util"); | ||
const child_process_1 = require("child_process"); | ||
const fs = __importStar(require("fs")); | ||
const path = __importStar(require("path")); | ||
@@ -34,4 +32,2 @@ const net = __importStar(require("net")); | ||
const debug = debug_1.default('engine'); | ||
const readFile = util_1.promisify(fs.readFile); | ||
const exists = util_1.promisify(fs.exists); | ||
/** | ||
@@ -42,3 +38,3 @@ * Node.js based wrapper to run the Prisma binary | ||
constructor(_a) { | ||
var { prismaConfig, datamodelJson, prismaYmlPath, datamodel, schemaInferrerPath, prismaPath } = _a, args = __rest(_a, ["prismaConfig", "datamodelJson", "prismaYmlPath", "datamodel", "schemaInferrerPath", "prismaPath"]); | ||
var { cwd, datamodel, prismaPath } = _a, args = __rest(_a, ["cwd", "datamodel", "prismaPath"]); | ||
super(); | ||
@@ -52,5 +48,5 @@ /** | ||
this.errorLogs = ''; | ||
this.fail = (e, why) => { | ||
this.fail = async (e, why) => { | ||
debug(e, why); | ||
this.stop(); | ||
await this.stop(); | ||
}; | ||
@@ -69,7 +65,4 @@ /** | ||
}; | ||
this.prismaYmlPath = prismaYmlPath; | ||
this.prismaConfig = prismaConfig; | ||
this.cwd = prismaYmlPath ? path.dirname(this.prismaYmlPath) : process.cwd(); | ||
this.cwd = cwd || process.cwd(); | ||
this.debug = args.debug || false; | ||
this.datamodelJson = datamodelJson; | ||
this.datamodel = datamodel; | ||
@@ -83,11 +76,2 @@ this.prismaPath = prismaPath || NodeEngine.defaultPrismaPath; | ||
/** | ||
* Resolve the prisma.yml | ||
*/ | ||
async getPrismaYml(ymlPath) { | ||
if (!exists(ymlPath)) { | ||
return undefined; | ||
} | ||
return await readFile(ymlPath, 'utf-8'); | ||
} | ||
/** | ||
* Starts the engine, returns the url that it runs on | ||
@@ -101,7 +85,4 @@ */ | ||
this.port = await this.getFreePort(); | ||
this.prismaConfig = this.prismaConfig || (await this.getPrismaYml(this.prismaYmlPath)); | ||
const PRISMA_CONFIG = this.generatePrismaConfig(); | ||
const schemaEnv = {}; | ||
debug(`Starting binary at ${this.prismaPath}`); | ||
const env = Object.assign({}, process.env, { PRISMA_CONFIG, PRISMA_DML: this.datamodel, RUST_BACKTRACE: '1' }); | ||
const env = Object.assign({}, process.env, { PRISMA_DML: this.datamodel, PORT: String(this.port), RUST_BACKTRACE: '1' }); | ||
debug(env); | ||
@@ -133,4 +114,4 @@ this.child = child_process_1.spawn(this.prismaPath, [], { | ||
// Make sure we kill Rust when this process is being killed | ||
process.once('SIGTERM', e => this.fail(e, 'SIGTERM')); | ||
process.once('SIGINT', e => this.fail(e, 'SIGINT')); | ||
process.on('SIGTERM', e => this.fail(e, 'SIGTERM')); | ||
process.on('SIGINT', e => this.fail(e, 'SIGINT')); | ||
// process.once('uncaughtException', e => this.fail(e, 'uncaughtException')) | ||
@@ -165,8 +146,2 @@ // process.once('unhandledRejection', e => this.fail(e, 'unhandledRejection')) | ||
/** | ||
* Replace the port in the Prisma Config | ||
*/ | ||
generatePrismaConfig() { | ||
return `port: ${this.port}\n${this.trimPort(this.prismaConfig)}`; | ||
} | ||
/** | ||
* Make sure that our internal port is not conflicting with the prisma.yml's port | ||
@@ -173,0 +148,0 @@ * @param str config |
{ | ||
"name": "@prisma/engine-core", | ||
"version": "0.0.38", | ||
"version": "0.0.40", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2
36750
609