From 61eba695687eedcb31d3b87cfd42c4a6110f3073 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Wed, 23 Apr 2025 16:10:35 -0400 Subject: [PATCH 1/3] dev-call - new command to generate JSON information --- src/command/command.ts | 2 ++ src/command/dev-call/cmd.ts | 58 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/command/dev-call/cmd.ts diff --git a/src/command/command.ts b/src/command/command.ts index ab4b69f0117..b9d6707205c 100644 --- a/src/command/command.ts +++ b/src/command/command.ts @@ -30,6 +30,7 @@ import { uninstallCommand } from "./uninstall/cmd.ts"; import { createCommand } from "./create/cmd.ts"; import { editorSupportCommand } from "./editor-support/cmd.ts"; import { callCommand } from "./call/cmd.ts"; +import { devCallCommand } from "./dev-call/cmd.ts"; // deno-lint-ignore no-explicit-any export function commands(): Command[] { @@ -59,5 +60,6 @@ export function commands(): Command[] { buildJsCommand, editorSupportCommand, callCommand, + devCallCommand, ]; } diff --git a/src/command/dev-call/cmd.ts b/src/command/dev-call/cmd.ts new file mode 100644 index 00000000000..4c52f60269e --- /dev/null +++ b/src/command/dev-call/cmd.ts @@ -0,0 +1,58 @@ +import { Command } from "cliffy/command/mod.ts"; +import { quartoConfig } from "../../core/quarto.ts"; +import { commands } from "../command.ts"; + +type CommandOptionInfo = { + name: string; + description: string; + args: []; + flags: string[]; + equalsSign: boolean; + typeDefinition: string; +}; + +type CommandInfo = { + name: string; + description: string; + options: CommandOptionInfo[]; + // arguments: string[]; + // subcommands: CommandInfo[]; + // aliases: string[]; + examples: { name: string; description: string }[]; + // flags: string[]; + usage: string; + commands: CommandInfo[]; +}; + +const generateCliInfoCommand = new Command() + .name("cli-info") + .description("Generate JSON information about the Quarto CLI.") + .action(async () => { + const output: Record = {}; + output["version"] = quartoConfig.version(); + const commandsInfo: CommandInfo[] = []; + output["commands"] = commandsInfo; + // deno-lint-ignore no-explicit-any + const cmdAsJson = (cmd: any): CommandInfo => { + return { + name: cmd.getName(), + description: cmd.getDescription(), + options: cmd.getOptions(), + usage: cmd.getUsage(), + examples: cmd.getExamples(), + commands: cmd.getCommands().map(cmdAsJson), + }; + }; + output["commands"] = commands().map(cmdAsJson); + console.log(JSON.stringify(output, null, 2)); + }); + +export const devCallCommand = new Command() + .name("dev-call") + .description( + "Access internals of Quarto - this command is not intended for general use.", + ) + .action(() => { + devCallCommand.showHelp(); + Deno.exit(1); + }).command("cli-info", generateCliInfoCommand); From 30b732018a7eebbe61f1779a464a1ee83930f0e7 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Thu, 24 Apr 2025 09:55:59 -0400 Subject: [PATCH 2/3] build-js - rename to 'dev-call build-artifacts' --- src/command/command.ts | 2 -- .../{build-js => dev-call/build-artifacts}/cmd.ts | 12 ++++++------ src/command/dev-call/cmd.ts | 5 ++++- 3 files changed, 10 insertions(+), 9 deletions(-) rename src/command/{build-js => dev-call/build-artifacts}/cmd.ts (92%) diff --git a/src/command/command.ts b/src/command/command.ts index b9d6707205c..061fee2421d 100644 --- a/src/command/command.ts +++ b/src/command/command.ts @@ -18,7 +18,6 @@ import { typstCommand } from "./typst/cmd.ts"; import { capabilitiesCommand } from "./capabilities/cmd.ts"; import { checkCommand } from "./check/cmd.ts"; import { inspectCommand } from "./inspect/cmd.ts"; -import { buildJsCommand } from "./build-js/cmd.ts"; import { installCommand } from "./install/cmd.ts"; import { updateCommand } from "./update/cmd.ts"; import { publishCommand } from "./publish/cmd.ts"; @@ -57,7 +56,6 @@ export function commands(): Command[] { capabilitiesCommand, inspectCommand, checkCommand, - buildJsCommand, editorSupportCommand, callCommand, devCallCommand, diff --git a/src/command/build-js/cmd.ts b/src/command/dev-call/build-artifacts/cmd.ts similarity index 92% rename from src/command/build-js/cmd.ts rename to src/command/dev-call/build-artifacts/cmd.ts index c70f374a285..36e2cf41b8c 100644 --- a/src/command/build-js/cmd.ts +++ b/src/command/dev-call/build-artifacts/cmd.ts @@ -10,17 +10,17 @@ import { ESBuildAnalysis, esbuildAnalyze, esbuildCompile, -} from "../../core/esbuild.ts"; -import { buildIntelligenceResources } from "../../core/schema/build-schema-file.ts"; -import { formatResourcePath, resourcePath } from "../../core/resources.ts"; +} from "../../../core/esbuild.ts"; +import { buildIntelligenceResources } from "../../../core/schema/build-schema-file.ts"; +import { formatResourcePath, resourcePath } from "../../../core/resources.ts"; import { simple } from "acorn/walk"; import { Parser } from "acorn/acorn"; import classFields from "acorn-class-fields"; -import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts"; +import { initYamlIntelligenceResourcesFromFilesystem } from "../../../core/schema/utils.ts"; // initialize language handlers -import "../../core/handlers/handlers.ts"; -import { join } from "../../deno_ral/path.ts"; +import "../../../core/handlers/handlers.ts"; +import { join } from "../../../deno_ral/path.ts"; function ensureAllowableIDESyntax(src: string, filename: string) { const ast = Parser.extend(classFields).parse(src, { diff --git a/src/command/dev-call/cmd.ts b/src/command/dev-call/cmd.ts index 4c52f60269e..8451ae18583 100644 --- a/src/command/dev-call/cmd.ts +++ b/src/command/dev-call/cmd.ts @@ -1,6 +1,7 @@ import { Command } from "cliffy/command/mod.ts"; import { quartoConfig } from "../../core/quarto.ts"; import { commands } from "../command.ts"; +import { buildJsCommand } from "./build-artifacts/cmd.ts"; type CommandOptionInfo = { name: string; @@ -55,4 +56,6 @@ export const devCallCommand = new Command() .action(() => { devCallCommand.showHelp(); Deno.exit(1); - }).command("cli-info", generateCliInfoCommand); + }) + .command("cli-info", generateCliInfoCommand) + .command("build-artifacts", buildJsCommand); From 4f897ac8bafe66d0d9b98e401681a0929f39a41c Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Thu, 24 Apr 2025 09:56:39 -0400 Subject: [PATCH 3/3] import from correct location --- package/src/common/prepare-dist.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/src/common/prepare-dist.ts b/package/src/common/prepare-dist.ts index a1ed57c93c6..70779887c99 100755 --- a/package/src/common/prepare-dist.ts +++ b/package/src/common/prepare-dist.ts @@ -12,7 +12,7 @@ import { Configuration } from "../common/config.ts"; import { buildFilter } from "./package-filters.ts"; import { bundle } from "../util/deno.ts"; import { info } from "../../../src/deno_ral/log.ts"; -import { buildAssets } from "../../../src/command/build-js/cmd.ts"; +import { buildAssets } from "../../../src/command/dev-call/build-artifacts/cmd.ts"; import { initTreeSitter } from "../../../src/core/schema/deno-init-tree-sitter.ts"; import { Dependency,