Skip to content

Commit 0710802

Browse files
authored
Merge pull request #12580 from quarto-dev/feature/deno-2
Feature/deno 2
2 parents 620a0bc + ef3317a commit 0710802

File tree

112 files changed

+819
-940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+819
-940
lines changed

configuration

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# in src/command/check/check.ts
1212

1313
# Binary dependencies
14-
export DENO=v1.46.3
14+
export DENO=v2.2.10
1515
# TODO figure out where 0.1.41 apple silicon libs are available
1616
export DENO_DOM=v0.1.41-alpha-artifacts
1717
export PANDOC=3.6.3

package/scripts/deno_std/download.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ fi
1010

1111

1212
export DENO_DIR="$QUARTO_SRC_PATH/resources/deno_std/cache"
13-
"$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"
13+
"$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"

package/src/common/archive-binary-dependencies.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ export async function archiveBinaryDependency(
159159
}
160160

161161
async function s3cmd(cmd: string, args: string[]) {
162-
const s3Command = ["aws", "s3", cmd, ...args];
162+
const s3Args = ["s3", cmd, ...args];
163163
const p = await execProcess({
164-
cmd: s3Command,
164+
cmd: "aws",
165+
args: s3Args,
165166
stdout: "piped",
166167
});
167168

package/src/common/prepare-dist.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export async function prepareDist(
9090
try {
9191
await configArchDependency(dependency, targetDir, config)
9292
} catch (e) {
93+
if (!(e instanceof Error)) { throw e; }
9394
if (
9495
e.message ===
9596
"The architecture aarch64 is missing the dependency deno_dom"
@@ -121,13 +122,11 @@ export async function prepareDist(
121122
info("");
122123

123124
// Create the deno bundle
124-
const input = join(config.directoryInfo.src, "quarto.ts");
125+
// const input = join(config.directoryInfo.src, "quarto.ts");
125126
const output = join(config.directoryInfo.pkgWorking.bin, "quarto.js");
126127
info("\nCreating Deno Bundle");
127128
info(output);
128129
await bundle(
129-
input,
130-
output,
131130
config,
132131
);
133132
info("");

package/src/common/validate-bundle.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export async function validateBundle(
3232
// NPM Install
3333
info("Installing Dependencies");
3434
const npm = await execProcess({
35-
cmd: ["npm", "install"],
35+
cmd: "npm",
36+
args: ["install"],
3637
stderr: "piped"
3738
});
3839
if (!npm.success) {
@@ -53,7 +54,8 @@ export async function validateBundle(
5354
// Test the bundled output
5455
info("Testing Bundled output");
5556
const npx = await execProcess({
56-
cmd: ["npx", "eslint", "bundle.js"],
57+
cmd: "npx",
58+
args: ["eslint", "bundle.js"],
5759
stderr: "piped"
5860

5961
});

package/src/util/cmd.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { debug, error, info } from "../../../src/deno_ral/log.ts";
99

1010
export interface CmdResult {
11-
status: Deno.ProcessStatus;
11+
status: Deno.CommandStatus;
1212
stdout: string;
1313
stderr: string;
1414
}
@@ -17,34 +17,32 @@ export async function runCmd(
1717
runCmd: string,
1818
args: string[],
1919
): Promise<CmdResult> {
20-
const cmd: string[] = [];
21-
cmd.push(runCmd);
22-
cmd.push(...args);
20+
// const cmd: string[] = [];
21+
// cmd.push(runCmd);
22+
// cmd.push(...args);
2323

24-
info(cmd);
24+
info([runCmd, ...args]);
2525
info(`Starting ${runCmd}`);
26-
const p = Deno.run({
27-
cmd,
26+
const cmd = new Deno.Command(runCmd, {
27+
args,
2828
stdout: "piped",
2929
stderr: "piped",
3030
});
31-
const stdout = new TextDecoder().decode(await p.output());
32-
const stderr = new TextDecoder().decode(await p.stderrOutput());
31+
const output = await cmd.output();
32+
const stdout = new TextDecoder().decode(output.stdout);
33+
const stderr = new TextDecoder().decode(output.stderr);
3334
info(`Finished ${runCmd}`);
3435
debug(stdout);
3536

36-
const status = await p.status();
37-
info(`Status ${status.code}`);
38-
if (status.code !== 0) {
37+
const code = output.code;
38+
info(`Status ${code}`);
39+
if (code !== 0) {
3940
error(stderr);
40-
throw Error(`Command ${cmd} failed.`);
41+
throw Error(`Command ${[runCmd, ...args]} failed.`);
4142
}
4243

43-
// Close the child process
44-
p.close();
45-
4644
return {
47-
status,
45+
status: output,
4846
stdout,
4947
stderr,
5048
};

package/src/util/deno.ts

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
* Copyright (C) 2020-2022 Posit Software, PBC
55
*
66
*/
7+
import { execProcess } from "../../../src/core/process.ts";
78
import { info } from "../../../src/deno_ral/log.ts";
89
import { isWindows } from "../../../src/deno_ral/platform.ts";
910
import { Configuration } from "../common/config.ts";
1011

12+
// TODO in we only use the bundler for quarto.ts
13+
// so we hardcode it in the new esbuild-based bundler
1114
export async function bundle(
12-
input: string,
13-
output: string,
1415
configuration: Configuration,
1516
) {
1617
// Bundle source code
@@ -19,28 +20,23 @@ export async function bundle(
1920
if (!denoExecPath) {
2021
throw Error("QUARTO_DENO is not defined");
2122
}
22-
denoBundleCmd.push(denoExecPath);
23-
denoBundleCmd.push("bundle");
24-
denoBundleCmd.push("--no-check");
25-
denoBundleCmd.push("--unstable-kv");
26-
denoBundleCmd.push("--unstable-ffi");
27-
denoBundleCmd.push(
28-
"--importmap=" + configuration.importmap,
29-
);
23+
denoBundleCmd.push("run");
24+
denoBundleCmd.push("--allow-all");
25+
denoBundleCmd.push("../tools/deno-esbuild-bundle.ts");
3026
/*
3127
denoBundleCmd.push("--log-level");
3228
denoBundleCmd.push("debug");
3329
*/
30+
// denoBundleCmd.push(input);
31+
// denoBundleCmd.push(output);
3432

35-
denoBundleCmd.push(input);
36-
denoBundleCmd.push(output);
37-
38-
const p = Deno.run({
39-
cmd: denoBundleCmd,
33+
const status = await execProcess({
34+
cmd: denoExecPath,
35+
args: denoBundleCmd,
36+
cwd: configuration.directoryInfo.src,
4037
});
41-
const status = await p.status();
4238
if (status.code !== 0) {
43-
throw Error(`Failure to bundle ${input}`);
39+
throw Error(`Failure to bundle src/quarto.ts`);
4440
}
4541
}
4642

@@ -55,7 +51,6 @@ export async function compile(
5551
if (!denoExecPath) {
5652
throw Error("QUARTO_DENO is not defined");
5753
}
58-
denoBundleCmd.push(denoExecPath);
5954
denoBundleCmd.push("compile");
6055
denoBundleCmd.push("--unstable-kv");
6156
denoBundleCmd.push("--unstable-ffi");
@@ -68,15 +63,14 @@ export async function compile(
6863

6964
denoBundleCmd.push(input);
7065

71-
const p = Deno.run({
72-
cmd: denoBundleCmd,
66+
const status = await execProcess({
67+
cmd: denoExecPath,
68+
args: denoBundleCmd,
7369
});
74-
const status = await p.status();
7570
if (status.code !== 0) {
7671
throw Error(`Failure to compile ${input}`);
7772
}
7873
}
79-
8074
export async function install(
8175
input: string,
8276
flags: string[],
@@ -87,7 +81,6 @@ export async function install(
8781
if (!denoExecPath) {
8882
throw Error("QUARTO_DENO is not defined");
8983
}
90-
denoBundleCmd.push(denoExecPath);
9184
denoBundleCmd.push("install");
9285
denoBundleCmd.push("--unstable-kv");
9386
denoBundleCmd.push("--unstable-ffi");
@@ -98,24 +91,19 @@ export async function install(
9891

9992
denoBundleCmd.push(input);
10093

101-
const p = Deno.run({
102-
cmd: denoBundleCmd,
94+
const status = await execProcess({
95+
cmd: denoExecPath,
96+
args: denoBundleCmd,
10397
stdout: "piped",
10498
});
105-
const status = await p.status();
10699
if (status.code !== 0) {
107100
throw Error(`Failure to install ${input}`);
108101
}
109-
const output = await p.output();
110-
111-
if (output) {
112-
// Try to read the installation path and return it
113-
const outputTxt = new TextDecoder().decode(output);
114-
102+
if (status.stdout) {
115103
// Forward the output
116-
info(outputTxt);
104+
info(status.stdout);
117105

118-
const match = outputTxt.match(/Successfully installed.*\n(.*)/);
106+
const match = status.stdout.match(/Successfully installed.*\n(.*)/);
119107
if (match) {
120108
return match[1];
121109
}

package/src/windows/installer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ export async function makeInstallerWindows(configuration: Configuration) {
157157

158158
export function zip(input: string, output: string) {
159159
const dir = dirname(input);
160-
const cmd = [
161-
"powershell",
160+
const cmd = "powershell";
161+
const args = [
162162
"Compress-Archive",
163163
"-Force",
164164
input,
@@ -169,6 +169,7 @@ export function zip(input: string, output: string) {
169169
return execProcess(
170170
{
171171
cmd,
172+
args,
172173
cwd: dir,
173174
stdout: "piped",
174175
},

src/command/check/check.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,17 @@ async function checkVersions(conf: CheckConfiguration) {
217217

218218
let pandocVersion = lines(
219219
(await execProcess({
220-
cmd: [pandocBinaryPath(), "--version"],
220+
cmd: pandocBinaryPath(),
221+
args: ["--version"],
221222
stdout: "piped",
222223
})).stdout!,
223224
)[0]?.split(" ")[1];
224225
const sassVersion = (await dartCommand(["--version"]))?.trim();
225226
const denoVersion = Deno.version.deno;
226227
const typstVersion = lines(
227228
(await execProcess({
228-
cmd: [typstBinaryPath(), "--version"],
229+
cmd: typstBinaryPath(),
230+
args: ["--version"],
229231
stdout: "piped",
230232
})).stdout!,
231233
)[0].split(" ")[1];
@@ -300,7 +302,8 @@ async function checkInstall(conf: CheckConfiguration) {
300302
const quartoRoot = Deno.env.get("QUARTO_ROOT");
301303
if (quartoRoot) {
302304
const gitHead = await execProcess({
303-
cmd: ["git", "-C", quartoRoot, "rev-parse", "HEAD"],
305+
cmd: "git",
306+
args: ["-C", quartoRoot, "rev-parse", "HEAD"],
304307
stdout: "piped",
305308
stderr: "piped", // to not show error if not in a git repo
306309
});

src/command/create/artifacts/artifact-shared.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export async function ejsData(
150150

151151
async function gitAuthor() {
152152
const result = await execProcess({
153-
cmd: ["git", "config", "--global", "user.name"],
153+
cmd: "git",
154+
args: ["config", "--global", "user.name"],
154155
stdout: "piped",
155156
stderr: "piped",
156157
});

0 commit comments

Comments
 (0)