Skip to content

Commit ab90baf

Browse files
authored
test-cli: produce dmmf directly (#3774)
i.e. without using an external query engine binary. We import the dmmf crate instead. A long time ago, when this was made, it wasn't possible, but now it is.
1 parent 246e59f commit ab90baf

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/test-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ anyhow = "1.0.26"
88
colored = "2"
99
structopt = "0.3.8"
1010
enumflags2 = "0.7"
11+
dmmf = { path = "../../query-engine/dmmf" }
1112
migration-core = { path = "../../migration-engine/core" }
1213
migration-connector = { path = "../../migration-engine/connectors/migration-connector" }
1314
introspection-core = { path = "../../introspection-engine/core" }

libs/test-cli/src/main.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ enum Command {
4747

4848
#[derive(Debug, StructOpt)]
4949
struct DmmfCommand {
50-
/// The path to the `query-engine` binary. Defaults to the value of the `PRISMA_BINARY_PATH`
51-
/// env var, or just `query-engine`.
52-
#[structopt(env = "PRISMA_BINARY_PATH", default_value = "query-engine")]
53-
query_engine_binary_path: String,
5450
/// A database URL to introspect and generate DMMF for.
5551
#[structopt(long = "url")]
5652
url: Option<String>,
@@ -340,19 +336,9 @@ async fn generate_dmmf(cmd: &DmmfCommand) -> anyhow::Result<()> {
340336
}
341337
};
342338

343-
eprintln!(
344-
"{} {}",
345-
"Using the query engine binary at".yellow(),
346-
cmd.query_engine_binary_path.bold()
347-
);
348-
349-
let cmd = std::process::Command::new(&cmd.query_engine_binary_path)
350-
.arg("cli")
351-
.arg("dmmf")
352-
.env("PRISMA_DML_PATH", schema_path)
353-
.spawn()?;
354-
355-
cmd.wait_with_output()?;
339+
let prisma_schema = std::fs::read_to_string(schema_path).unwrap();
340+
let result = dmmf::dmmf_json_from_schema(&prisma_schema);
341+
println!("{result}");
356342

357343
Ok(())
358344
}

0 commit comments

Comments
 (0)