88import { info } from "log/mod.ts" ;
99
1010import { render , renderServices } from "../render/render-shared.ts" ;
11+
1112import { JupyterCapabilities } from "../../core/jupyter/types.ts" ;
1213import { jupyterCapabilities } from "../../core/jupyter/capabilities.ts" ;
1314import {
@@ -28,15 +29,23 @@ import { quartoConfig } from "../../core/quarto.ts";
2829import { readCodePage } from "../../core/windows.ts" ;
2930import { RenderServices } from "../render/types.ts" ;
3031import { 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
3238const kIndent = " " ;
3339
34- export type Target = "install" | "jupyter" | "knitr" | "all" ;
40+ export type Target = "install" | "jupyter" | "knitr" | "versions" | " all";
3541
3642export 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+
5499async function checkInstall ( services : RenderServices ) {
55100 completeMessage ( "Checking Quarto installation......OK" ) ;
56101 info ( ` Version: ${ quartoConfig . version ( ) } ` ) ;
0 commit comments