Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b9a7c01
deno 2 - run -> Command
cscheid Apr 16, 2025
b94936f
deno 2 - Deno.run -> call() in our ral
cscheid Apr 16, 2025
177e821
deno 2 - serveHttp -> serve
cscheid Apr 16, 2025
cd531a7
deno 2 - catch is typed
cscheid Apr 16, 2025
a4c19dd
chore - deno 2
cscheid Apr 16, 2025
17f40be
Merge branch 'main' into feature/deno-2
cscheid Apr 16, 2025
3d25753
partial work
cscheid Apr 17, 2025
8195e18
Merge branch 'main' into feature/deno-2
cscheid Apr 17, 2025
90cb63a
partial work
cscheid Apr 17, 2025
402d574
chore - clean comments
cscheid Apr 17, 2025
b32cd3e
chore - deno 2
cscheid Apr 17, 2025
9305a88
chore - deno 2
cscheid Apr 17, 2025
f858fb7
chore - deno 2
cscheid Apr 17, 2025
5878d00
Merge branch 'main' into feature/deno-2
cscheid Apr 17, 2025
016c0bc
chore - deno 2
cscheid Apr 17, 2025
4c9a7b3
chore - deno 2
cscheid Apr 17, 2025
bf7f43d
chore - deno 2
cscheid Apr 17, 2025
910773a
chore - deno 2: release stdin lock
cscheid Apr 17, 2025
87a380d
chore - deno 2: release stdin lock
cscheid Apr 17, 2025
f5d1d53
chore - deno 2: use esbuild bundlers
cscheid Apr 17, 2025
5821e61
bring back compile
cscheid Apr 17, 2025
d028dd5
fix import
cscheid Apr 17, 2025
e8730de
chore - deno 2
cscheid Apr 17, 2025
20928c9
chore - deno 2
cscheid Apr 17, 2025
2bbfada
chore - deno 2
cscheid Apr 17, 2025
4262f4d
chore - deno 2
cscheid Apr 17, 2025
e07372b
Merge branch 'main' into feature/deno-2
cscheid Apr 18, 2025
13b9052
Merge branch 'main' into feature/deno-2
cscheid Apr 22, 2025
8818485
merge
cscheid May 5, 2025
ef3317a
Merge branch 'main' into feature/deno-2
cscheid May 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configuration
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# in src/command/check/check.ts

# Binary dependencies
export DENO=v1.46.3
export DENO=v2.2.10
# TODO figure out where 0.1.41 apple silicon libs are available
export DENO_DOM=v0.1.41-alpha-artifacts
export PANDOC=3.6.3
Expand Down
2 changes: 1 addition & 1 deletion package/scripts/deno_std/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ fi


export DENO_DIR="$QUARTO_SRC_PATH/resources/deno_std/cache"
"$QUARTO_DENO" cache --no-config --unstable-ffi --lock "$QUARTO_SRC_PATH/resources/deno_std/deno_std.lock" "$@" "$QUARTO_PACKAGE_PATH/scripts/deno_std/deno_std.ts"
"$QUARTO_DENO" cache --allow-import --no-config --unstable-ffi --lock "$QUARTO_SRC_PATH/resources/deno_std/deno_std.lock" "$@" "$QUARTO_PACKAGE_PATH/scripts/deno_std/deno_std.ts"
5 changes: 3 additions & 2 deletions package/src/common/archive-binary-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ export async function archiveBinaryDependency(
}

async function s3cmd(cmd: string, args: string[]) {
const s3Command = ["aws", "s3", cmd, ...args];
const s3Args = ["s3", cmd, ...args];
const p = await execProcess({
cmd: s3Command,
cmd: "aws",
args: s3Args,
stdout: "piped",
});

Expand Down
5 changes: 2 additions & 3 deletions package/src/common/prepare-dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export async function prepareDist(
try {
await configArchDependency(dependency, targetDir, config)
} catch (e) {
if (!(e instanceof Error)) { throw e; }
if (
e.message ===
"The architecture aarch64 is missing the dependency deno_dom"
Expand Down Expand Up @@ -121,13 +122,11 @@ export async function prepareDist(
info("");

// Create the deno bundle
const input = join(config.directoryInfo.src, "quarto.ts");
// const input = join(config.directoryInfo.src, "quarto.ts");
const output = join(config.directoryInfo.pkgWorking.bin, "quarto.js");
info("\nCreating Deno Bundle");
info(output);
await bundle(
input,
output,
config,
);
info("");
Expand Down
6 changes: 4 additions & 2 deletions package/src/common/validate-bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export async function validateBundle(
// NPM Install
info("Installing Dependencies");
const npm = await execProcess({
cmd: ["npm", "install"],
cmd: "npm",
args: ["install"],
stderr: "piped"
});
if (!npm.success) {
Expand All @@ -53,7 +54,8 @@ export async function validateBundle(
// Test the bundled output
info("Testing Bundled output");
const npx = await execProcess({
cmd: ["npx", "eslint", "bundle.js"],
cmd: "npx",
args: ["eslint", "bundle.js"],
stderr: "piped"

});
Expand Down
32 changes: 15 additions & 17 deletions package/src/util/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { debug, error, info } from "../../../src/deno_ral/log.ts";

export interface CmdResult {
status: Deno.ProcessStatus;
status: Deno.CommandStatus;
stdout: string;
stderr: string;
}
Expand All @@ -17,34 +17,32 @@ export async function runCmd(
runCmd: string,
args: string[],
): Promise<CmdResult> {
const cmd: string[] = [];
cmd.push(runCmd);
cmd.push(...args);
// const cmd: string[] = [];
// cmd.push(runCmd);
// cmd.push(...args);

info(cmd);
info([runCmd, ...args]);
info(`Starting ${runCmd}`);
const p = Deno.run({
cmd,
const cmd = new Deno.Command(runCmd, {
args,
stdout: "piped",
stderr: "piped",
});
const stdout = new TextDecoder().decode(await p.output());
const stderr = new TextDecoder().decode(await p.stderrOutput());
const output = await cmd.output();
const stdout = new TextDecoder().decode(output.stdout);
const stderr = new TextDecoder().decode(output.stderr);
info(`Finished ${runCmd}`);
debug(stdout);

const status = await p.status();
info(`Status ${status.code}`);
if (status.code !== 0) {
const code = output.code;
info(`Status ${code}`);
if (code !== 0) {
error(stderr);
throw Error(`Command ${cmd} failed.`);
throw Error(`Command ${[runCmd, ...args]} failed.`);
}

// Close the child process
p.close();

return {
status,
status: output,
stdout,
stderr,
};
Expand Down
56 changes: 22 additions & 34 deletions package/src/util/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
* Copyright (C) 2020-2022 Posit Software, PBC
*
*/
import { execProcess } from "../../../src/core/process.ts";
import { info } from "../../../src/deno_ral/log.ts";
import { isWindows } from "../../../src/deno_ral/platform.ts";
import { Configuration } from "../common/config.ts";

// TODO in we only use the bundler for quarto.ts
// so we hardcode it in the new esbuild-based bundler
export async function bundle(
input: string,
output: string,
configuration: Configuration,
) {
// Bundle source code
Expand All @@ -19,28 +20,23 @@ export async function bundle(
if (!denoExecPath) {
throw Error("QUARTO_DENO is not defined");
}
denoBundleCmd.push(denoExecPath);
denoBundleCmd.push("bundle");
denoBundleCmd.push("--no-check");
denoBundleCmd.push("--unstable-kv");
denoBundleCmd.push("--unstable-ffi");
denoBundleCmd.push(
"--importmap=" + configuration.importmap,
);
denoBundleCmd.push("run");
denoBundleCmd.push("--allow-all");
denoBundleCmd.push("../tools/deno-esbuild-bundle.ts");
/*
denoBundleCmd.push("--log-level");
denoBundleCmd.push("debug");
*/
// denoBundleCmd.push(input);
// denoBundleCmd.push(output);

denoBundleCmd.push(input);
denoBundleCmd.push(output);

const p = Deno.run({
cmd: denoBundleCmd,
const status = await execProcess({
cmd: denoExecPath,
args: denoBundleCmd,
cwd: configuration.directoryInfo.src,
});
const status = await p.status();
if (status.code !== 0) {
throw Error(`Failure to bundle ${input}`);
throw Error(`Failure to bundle src/quarto.ts`);
}
}

Expand All @@ -55,7 +51,6 @@ export async function compile(
if (!denoExecPath) {
throw Error("QUARTO_DENO is not defined");
}
denoBundleCmd.push(denoExecPath);
denoBundleCmd.push("compile");
denoBundleCmd.push("--unstable-kv");
denoBundleCmd.push("--unstable-ffi");
Expand All @@ -68,15 +63,14 @@ export async function compile(

denoBundleCmd.push(input);

const p = Deno.run({
cmd: denoBundleCmd,
const status = await execProcess({
cmd: denoExecPath,
args: denoBundleCmd,
});
const status = await p.status();
if (status.code !== 0) {
throw Error(`Failure to compile ${input}`);
}
}

export async function install(
input: string,
flags: string[],
Expand All @@ -87,7 +81,6 @@ export async function install(
if (!denoExecPath) {
throw Error("QUARTO_DENO is not defined");
}
denoBundleCmd.push(denoExecPath);
denoBundleCmd.push("install");
denoBundleCmd.push("--unstable-kv");
denoBundleCmd.push("--unstable-ffi");
Expand All @@ -98,24 +91,19 @@ export async function install(

denoBundleCmd.push(input);

const p = Deno.run({
cmd: denoBundleCmd,
const status = await execProcess({
cmd: denoExecPath,
args: denoBundleCmd,
stdout: "piped",
});
const status = await p.status();
if (status.code !== 0) {
throw Error(`Failure to install ${input}`);
}
const output = await p.output();

if (output) {
// Try to read the installation path and return it
const outputTxt = new TextDecoder().decode(output);

if (status.stdout) {
// Forward the output
info(outputTxt);
info(status.stdout);

const match = outputTxt.match(/Successfully installed.*\n(.*)/);
const match = status.stdout.match(/Successfully installed.*\n(.*)/);
if (match) {
return match[1];
}
Expand Down
5 changes: 3 additions & 2 deletions package/src/windows/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ export async function makeInstallerWindows(configuration: Configuration) {

export function zip(input: string, output: string) {
const dir = dirname(input);
const cmd = [
"powershell",
const cmd = "powershell";
const args = [
"Compress-Archive",
"-Force",
input,
Expand All @@ -169,6 +169,7 @@ export function zip(input: string, output: string) {
return execProcess(
{
cmd,
args,
cwd: dir,
stdout: "piped",
},
Expand Down
9 changes: 6 additions & 3 deletions src/command/check/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,17 @@ async function checkVersions(conf: CheckConfiguration) {

let pandocVersion = lines(
(await execProcess({
cmd: [pandocBinaryPath(), "--version"],
cmd: pandocBinaryPath(),
args: ["--version"],
stdout: "piped",
})).stdout!,
)[0]?.split(" ")[1];
const sassVersion = (await dartCommand(["--version"]))?.trim();
const denoVersion = Deno.version.deno;
const typstVersion = lines(
(await execProcess({
cmd: [typstBinaryPath(), "--version"],
cmd: typstBinaryPath(),
args: ["--version"],
stdout: "piped",
})).stdout!,
)[0].split(" ")[1];
Expand Down Expand Up @@ -300,7 +302,8 @@ async function checkInstall(conf: CheckConfiguration) {
const quartoRoot = Deno.env.get("QUARTO_ROOT");
if (quartoRoot) {
const gitHead = await execProcess({
cmd: ["git", "-C", quartoRoot, "rev-parse", "HEAD"],
cmd: "git",
args: ["-C", quartoRoot, "rev-parse", "HEAD"],
stdout: "piped",
stderr: "piped", // to not show error if not in a git repo
});
Expand Down
3 changes: 2 additions & 1 deletion src/command/create/artifacts/artifact-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ export async function ejsData(

async function gitAuthor() {
const result = await execProcess({
cmd: ["git", "config", "--global", "user.name"],
cmd: "git",
args: ["config", "--global", "user.name"],
stdout: "piped",
stderr: "piped",
});
Expand Down
23 changes: 7 additions & 16 deletions src/command/create/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
objectPredicate,
stringTypePredicate,
} from "../../typing/dynamic.ts";
import { call } from "../../deno_ral/process.ts";

export interface Editor {
// A short, command line friendly id
Expand Down Expand Up @@ -103,11 +104,7 @@ function vscodeEditorInfo(): EditorInfo {
: dirname(artifactPath);

return async () => {
const p = Deno.run({
cmd: [path, artifactPath],
cwd,
});
await p.status();
await call(path, { args: [artifactPath], cwd });
};
},
inEditor: isVSCodeTerminal(),
Expand Down Expand Up @@ -164,11 +161,7 @@ function positronEditorInfo(): EditorInfo {
: dirname(artifactPath);

return async () => {
const p = Deno.run({
cmd: [path, artifactPath],
cwd,
});
await p.status();
await call(path, { args: [artifactPath], cwd });
};
},
inEditor: isPositronTerminal(),
Expand Down Expand Up @@ -231,15 +224,13 @@ function rstudioEditorInfo(): EditorInfo {
const rProjPath = join(cwd, `${artifactName}.Rproj`);
Deno.writeTextFileSync(rProjPath, kRProjContents);

const cmd = path.endsWith(".app") && isMac
const callCmd = path.endsWith(".app") && isMac
? ["open", "-na", path, "--args", rProjPath]
: [path, rProjPath];

const p = Deno.run({
cmd,
cwd,
});
await p.status();
const callPath = callCmd[0];
const args = callCmd.slice(1);
await call(callPath, { args, cwd });
};
},
inEditor: isRStudioTerminal(),
Expand Down
6 changes: 4 additions & 2 deletions src/command/editor-support/crossref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ const makeCrossrefCommand = () => {
Deno.env.set("QUARTO_CROSSREF_INPUT_TYPE", "qmd");

// build command
const cmd = [pandocBinaryPath(), "+RTS", "-K512m", "-RTS"];
cmd.push(...[
const cmd = pandocBinaryPath();
const cmdArgs = ["+RTS", "-K512m", "-RTS"];
cmdArgs.push(...[
"--from",
resourcePath("filters/qmd-reader.lua"),
"--to",
Expand All @@ -118,6 +119,7 @@ const makeCrossrefCommand = () => {
const result = await execProcess(
{
cmd,
args: cmdArgs,
cwd: indexingDir,
env: {
"QUARTO_FILTER_PARAMS": filterParams,
Expand Down
Loading
Loading