Skip to content

Commit a60f683

Browse files
authored
Merge pull request #12654 from quarto-dev/chore/1.8-dependencies-refresh
Chore/1.8 dependencies refresh
2 parents 79a1b18 + b54d671 commit a60f683

File tree

7 files changed

+710
-18
lines changed

7 files changed

+710
-18
lines changed

configuration

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export DENO=v1.46.3
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
18-
export DARTSASS=1.85.1
19-
export ESBUILD=0.19.12
18+
export DARTSASS=1.87.0
19+
export ESBUILD=0.25.3
2020
export TYPST=0.13.0
2121

2222

package/src/cmd/pkg-cmd.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
import { Command } from "cliffy/command/mod.ts";
88
import { join } from "../../../src/deno_ral/path.ts";
99

10-
import { printConfiguration } from "../common/config.ts";
10+
import { configurationAST, printConfiguration } from "../common/config.ts";
1111

1212
import {
1313
Configuration,
1414
kValidArch,
1515
kValidOS,
1616
readConfiguration,
1717
} from "../common/config.ts";
18+
import { logPandocJson } from "../../../src/core/log.ts";
1819

1920
export const kLogLevel = "logLevel";
2021
export const kVersion = "setVersion";
@@ -49,7 +50,11 @@ export function packageCommand(run: (config: Configuration) => Promise<void>) {
4950
Deno.env.set("QUARTO_DEBUG", "true");
5051

5152
// Print the configuration
52-
printConfiguration(config);
53+
try {
54+
await logPandocJson(configurationAST(config));
55+
} catch (e) {
56+
printConfiguration(config);
57+
}
5358

5459
// Run the command
5560
await run(config);

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
import { join } from "../../../src/deno_ral/path.ts";
77
import { info } from "../../../src/deno_ral/log.ts";
8+
import { logPandoc } from "../../../src/core/log.ts";
89

910
import { execProcess } from "../../../src/core/process.ts";
1011
import { Configuration, withWorkingDir } from "./config.ts";
@@ -34,7 +35,7 @@ export function archiveUrl(
3435
// Archives dependencies (if they are not present in the archive already)
3536
export async function archiveBinaryDependencies(_config: Configuration) {
3637
await withWorkingDir(async (workingDir) => {
37-
info(`Updating binary dependencies...\n`);
38+
await logPandoc(`## Updating binary dependencies`);
3839

3940
for (const dependency of kDependencies) {
4041
await archiveBinaryDependency(dependency, workingDir);
@@ -45,7 +46,7 @@ export async function archiveBinaryDependencies(_config: Configuration) {
4546
// Archives dependencies (if they are not present in the archive already)
4647
export async function checkBinaryDependencies(_config: Configuration) {
4748
await withWorkingDir(async (workingDir) => {
48-
info(`Updating binary dependencies...\n`);
49+
await logPandoc(`## Checking binary dependencies`);
4950

5051
for (const dependency of kDependencies) {
5152
await checkBinaryDependency(dependency, workingDir);
@@ -99,10 +100,9 @@ export async function archiveBinaryDependency(
99100
dependency: Dependency,
100101
workingDir: string,
101102
) {
102-
info(`** ${dependency.name} ${dependency.version} **`);
103+
await logPandoc(`## ${dependency.name} ${dependency.version}\n\nChecking archive status...`, "markdown");
103104

104105
const dependencyBucketPath = `${dependency.bucket}/${dependency.version}`;
105-
info("Checking archive status...\n");
106106

107107
const archive = async (
108108
architectureDependency: ArchitectureDependency,
@@ -117,7 +117,7 @@ export async function archiveBinaryDependency(
117117

118118
const dependencyAwsPath =
119119
`${kBucket}/${dependencyBucketPath}/${platformDep.filename}`;
120-
info(`Checking ${dependencyAwsPath}`);
120+
await logPandoc(`Checking \`${dependencyAwsPath}\``, "markdown");
121121
const response = await s3cmd("ls", [dependencyAwsPath]);
122122
if (response?.includes('Unable to locate credentials')) {
123123
throw new Error("Unable to locate S3 credentials, please try again.");
@@ -126,8 +126,8 @@ export async function archiveBinaryDependency(
126126

127127
if (!response) {
128128
// This dependency doesn't exist, archive it
129-
info(
130-
`Archiving ${dependencyBucketPath} - ${platformDep.filename}`,
129+
await logPandoc(
130+
`Archiving \`${dependencyBucketPath}\` - ${platformDep.filename}`,
131131
);
132132

133133
// Download the file
@@ -144,23 +144,18 @@ export async function archiveBinaryDependency(
144144
"--acl",
145145
"public-read",
146146
]);
147-
148-
info(`(Reponse): ${result}`);
149-
147+
info(` (Response): ${result}`);
150148
} else {
151-
info(`${dependencyAwsPath} already archived.`);
149+
info(` ${dependencyAwsPath.split("/").slice(-1)[0]} already archived.\n`);
152150
}
153151
}
154152
}
155153
};
156154

157155
for (const arch of Object.keys(dependency.architectureDependencies)) {
158-
info(`Archiving ${dependency.name}`);
159156
const archDep = dependency.architectureDependencies[arch];
160157
await archive(archDep);
161158
}
162-
163-
info("");
164159
}
165160

166161
async function s3cmd(cmd: string, args: string[]) {

package/src/common/config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { info } from "../../../src/deno_ral/log.ts";
1111
import { getEnv } from "../util/utils.ts";
1212

1313
import { os as platformOs } from "../../../src/deno_ral/platform.ts"
14+
import * as Pandoc from "../../../src/core/pandoc/json.ts";
15+
import { fromObjects } from "../../../src/core/pandoc/table.ts";
1416

1517
// The core configuration for the packaging process
1618
export interface Configuration extends PlatformConfiguration {
@@ -116,6 +118,36 @@ export function readConfiguration(
116118
};
117119
}
118120

121+
export function configurationAST(config: Configuration): Pandoc.Block[] {
122+
const makeObject = (
123+
obj: {
124+
key: string,
125+
value: string
126+
},
127+
) => ({
128+
"key": [Pandoc.plain([Pandoc.str(obj.key)])],
129+
"value": [Pandoc.plain([Pandoc.code(obj.value)])]
130+
});
131+
const configTable = fromObjects([
132+
{key: "OS", value: config.os},
133+
{key: "Arch", value: config.arch},
134+
{key: "Version", value: config.version},
135+
{key: "Cwd", value: Deno.cwd()},
136+
{key: "Package folder (build source)", value: config.directoryInfo.pkg},
137+
{key: "Dist folder (output folder)", value: config.directoryInfo.dist},
138+
{key: "Bin folder", value: config.directoryInfo.bin},
139+
{key: "Share folder", value: config.directoryInfo.share},
140+
{key: "Package working folder", value: config.directoryInfo.pkgWorking.root},
141+
].map(makeObject), undefined, [
142+
Pandoc.colspec("AlignLeft", {t: "ColWidth", c: 0.3}),
143+
Pandoc.colspec("AlignLeft", {t: "ColWidth", c: 0.6}),
144+
]);
145+
return [
146+
Pandoc.header(2, [Pandoc.str("Configuration:")]),
147+
configTable,
148+
];
149+
}
150+
119151
export function printConfiguration(config: Configuration) {
120152
info("");
121153
info("******************************************");

src/core/log.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import { lines } from "./text.ts";
1919
import { debug, error, getLogger, setup, warning } from "../deno_ral/log.ts";
2020
import { asErrorEx, InternalError } from "./lib/error.ts";
2121
import { onCleanup } from "./cleanup.ts";
22+
import { execProcess } from "./process.ts";
23+
import { pandocBinaryPath } from "./resources.ts";
24+
import { Block, pandoc } from "./pandoc/json.ts";
2225

2326
export type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR";
2427

@@ -459,3 +462,42 @@ const levelMap: Record<
459462
warning: "WARN",
460463
error: "ERROR",
461464
};
465+
466+
export async function logPandocJson(
467+
blocks: Block[],
468+
) {
469+
const src = JSON.stringify(pandoc({}, blocks), null, 2);
470+
return logPandoc(src, "json");
471+
}
472+
473+
const getColumns = () => {
474+
try {
475+
// Catch error in none tty mode: Inappropriate ioctl for device (os error 25)
476+
return Deno.consoleSize().columns ?? 130;
477+
} catch (_error) {
478+
return 130;
479+
}
480+
};
481+
482+
export async function logPandoc(
483+
src: string,
484+
format: string = "markdown",
485+
) {
486+
const cols = getColumns();
487+
const result = await execProcess({
488+
cmd: [
489+
pandocBinaryPath(),
490+
"-f",
491+
format,
492+
"-t",
493+
"ansi",
494+
`--columns=${cols}`,
495+
],
496+
stdout: "piped",
497+
}, src);
498+
if (result.code !== 0) {
499+
error(result.stderr);
500+
} else {
501+
log.info(result.stdout);
502+
}
503+
}

0 commit comments

Comments
 (0)