Skip to content

Commit 72c30a8

Browse files
committed
check for binary dependency versions in case of custom versions. Closes #3602
1 parent e6fe536 commit 72c30a8

3 files changed

Lines changed: 48 additions & 4 deletions

File tree

‎src/command/check/check.ts‎

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { info } from "log/mod.ts";
99

1010
import { render, renderServices } from "../render/render-shared.ts";
11+
1112
import { JupyterCapabilities } from "../../core/jupyter/types.ts";
1213
import { jupyterCapabilities } from "../../core/jupyter/capabilities.ts";
1314
import {
@@ -28,15 +29,23 @@ import { quartoConfig } from "../../core/quarto.ts";
2829
import { readCodePage } from "../../core/windows.ts";
2930
import { RenderServices } from "../render/types.ts";
3031
import { jupyterKernelspecForLanguage } from "../../core/jupyter/kernels.ts";
32+
import { execProcess } from "../../core/process.ts";
33+
import { pandocBinaryPath } from "../../core/resources.ts";
34+
import { lines } from "../../core/text.ts";
35+
import { satisfies } from "semver/mod.ts";
36+
import { dartCommand } from "../../core/dart-sass.ts";
3137

3238
const kIndent = " ";
3339

34-
export type Target = "install" | "jupyter" | "knitr" | "all";
40+
export type Target = "install" | "jupyter" | "knitr" | "versions" | "all";
3541

3642
export async function check(target: Target): Promise<void> {
3743
const services = renderServices();
3844
try {
3945
info("");
46+
if (target === "versions" || target === "all") {
47+
await checkVersions(services);
48+
}
4049
if (target === "install" || target === "all") {
4150
await checkInstall(services);
4251
}
@@ -51,6 +60,42 @@ export async function check(target: Target): Promise<void> {
5160
}
5261
}
5362

63+
async function checkVersions(_services: RenderServices) {
64+
const checkVersion = (
65+
version: string | undefined,
66+
constraint: string,
67+
name: string,
68+
) => {
69+
if (typeof version !== "string") {
70+
throw new Error(`Unable to determine ${name} version`);
71+
}
72+
if (!satisfies(version, constraint)) {
73+
info(
74+
` NOTE: ${name} version ${version} is too old. Please upgrade to ${
75+
constraint.slice(2)
76+
} or later.`,
77+
);
78+
} else {
79+
info(` ${name} version ${version}: OK`);
80+
}
81+
};
82+
83+
completeMessage("Checking versions of quarto binary dependencies...");
84+
85+
const pandocVersion = lines(
86+
(await execProcess({
87+
cmd: [pandocBinaryPath(), "--version"],
88+
stdout: "piped",
89+
})).stdout!,
90+
)[0]?.split(" ")[1];
91+
checkVersion(pandocVersion, ">=2.19.2", "Pandoc");
92+
93+
const sassVersion = (await dartCommand(["--version"]))?.trim();
94+
checkVersion(sassVersion, ">=1.32.8", "Dart Sass");
95+
96+
completeMessage("Checking versions of quarto dependencies......OK");
97+
}
98+
5499
async function checkInstall(services: RenderServices) {
55100
completeMessage("Checking Quarto installation......OK");
56101
info(` Version: ${quartoConfig.version()}`);

‎src/command/check/cmd.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { error } from "log/mod.ts";
1010
import { Command } from "cliffy/command/mod.ts";
1111
import { check, Target } from "./check.ts";
1212

13-
const kTargets = ["install", "jupyter", "knitr", "all"];
13+
const kTargets = ["install", "jupyter", "knitr", "versions", "all"];
1414

1515
export const checkCommand = new Command()
1616
.name("check")

‎src/core/dart-sass.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export async function dartCompile(
5252
return outputFilePath;
5353
}
5454

55-
async function dartCommand(args: string[]) {
55+
export async function dartCommand(args: string[]) {
5656
const resolvePath = () => {
5757
const dartOverrideCmd = Deno.env.get("QUARTO_DART_SASS");
5858
if (dartOverrideCmd) {
@@ -74,7 +74,6 @@ async function dartCommand(args: string[]) {
7474
sass,
7575
...args,
7676
];
77-
7877
// Run the sass compiler
7978
const result = await execProcess(
8079
{

0 commit comments

Comments
 (0)