|
1 | 1 | /* |
2 | 2 | * package.ts |
3 | 3 | * |
4 | | - * Copyright (C) 2020-2022 Posit Software, PBC |
| 4 | + * Copyright (C) 2020-2024 Posit Software, PBC |
5 | 5 | */ |
6 | | -import { Command } from "cliffy/command/mod.ts"; |
7 | | -import { packageCommand } from "./cmd/pkg-cmd.ts"; |
8 | | -import { configure } from "./common/configure.ts"; |
| 6 | +import { Builtins, Cli } from "npm:clipanion"; |
| 7 | +import { ConfigureCommand } from "./common/configure.ts"; |
9 | 8 | import { mainRunner } from "../../src/core/main.ts"; |
| 9 | +import { PackageCommand } from "./cmd/pkg-cmd.ts"; |
10 | 10 |
|
11 | | -import { prepareDist } from "./common/prepare-dist.ts"; |
12 | | -import { updateHtmlDependencies } from "./common/update-html-dependencies.ts"; |
13 | | -import { makeInstallerDeb } from "./linux/installer.ts"; |
14 | | -import { makeInstallerMac } from "./macos/installer.ts"; |
| 11 | +import { PrepareDistCommand } from "./common/prepare-dist.ts"; |
| 12 | +import { UpdateHTMLDependenciesCommand } from "./common/update-html-dependencies.ts"; |
| 13 | +import { MakeInstallerDebCommand } from "./linux/installer.ts"; |
| 14 | +import { MakeInstallerMacCommand } from "./macos/installer.ts"; |
15 | 15 | import { |
16 | | - compileQuartoLatexmkCommand, |
| 16 | + CompileQuartoLatexmkCommand, |
17 | 17 | } from "./common/compile-quarto-latexmk.ts"; |
18 | | -import { makeInstallerWindows } from "./windows/installer.ts"; |
| 18 | +import { MakeInstallerWindowsCommand } from "./windows/installer.ts"; |
19 | 19 |
|
20 | | -import { appendLogOptions } from "../../src/core/log.ts"; |
| 20 | +import { addLoggingOptions } from "../../src/core/log.ts"; |
21 | 21 | import { |
22 | | - cycleDependenciesCommand, |
23 | | - parseSwcLogCommand, |
| 22 | + CycleDependenciesCommand, |
| 23 | + ParseSwcLogCommand, |
24 | 24 | } from "./common/cyclic-dependencies.ts"; |
25 | 25 | import { |
26 | | - archiveBinaryDependencies, |
27 | | - checkBinaryDependencies, |
| 26 | + ArchiveBinaryDependenciesCommand, |
| 27 | + CheckBinaryDependenciesCommand, |
28 | 28 | } from "./common/archive-binary-dependencies.ts"; |
29 | | -import { updatePandoc } from "./common/update-pandoc.ts"; |
30 | | -import { validateBundle } from "./common/validate-bundle.ts"; |
31 | | -import { makeInstallerExternal } from "./ext/installer.ts"; |
| 29 | +import { UpdatePandocCommand } from "./common/update-pandoc.ts"; |
| 30 | +import { ValidateBundleCommand } from "./common/validate-bundle.ts"; |
| 31 | +import { MakeInstallerExternalCommand } from "./ext/installer.ts"; |
32 | 32 |
|
33 | | -// Core command dispatch |
34 | | -export async function quartoBld(args: string[]) { |
35 | | - const rootCommand = new Command() |
36 | | - .name("quarto-bld [command]") |
37 | | - .version("0.1") |
38 | | - .description( |
39 | | - "Utility that implements packaging and distribution of quarto cli", |
40 | | - ) |
41 | | - .option( |
42 | | - "-s, --signing-identity [id:string]", |
43 | | - "Signing identity to use when signing any files.", |
44 | | - { global: true }, |
45 | | - ) |
46 | | - .throwErrors(); |
| 33 | +const commands: (typeof PackageCommand)[] = [ |
| 34 | + ArchiveBinaryDependenciesCommand, |
| 35 | + CheckBinaryDependenciesCommand, |
| 36 | + CompileQuartoLatexmkCommand, |
| 37 | + ConfigureCommand, |
| 38 | + CycleDependenciesCommand, |
| 39 | + MakeInstallerDebCommand, |
| 40 | + MakeInstallerExternalCommand, |
| 41 | + MakeInstallerMacCommand, |
| 42 | + MakeInstallerWindowsCommand, |
| 43 | + ParseSwcLogCommand, |
| 44 | + PrepareDistCommand, |
| 45 | + UpdateHTMLDependenciesCommand, |
| 46 | + UpdatePandocCommand, |
| 47 | + ValidateBundleCommand, |
| 48 | +] |
47 | 49 |
|
48 | | - getCommands().forEach((command) => { |
49 | | - rootCommand.command(command.getName(), appendLogOptions(command)); |
50 | | - }); |
51 | 50 |
|
52 | | - await rootCommand.parse(args); |
53 | | -} |
| 51 | +class QuartoBld extends Cli { |
| 52 | + constructor() { |
| 53 | + super({ |
| 54 | + binaryLabel: "Utility that implements packaging and distribution of quarto cli", |
| 55 | + binaryName: 'quarto-bld', |
| 56 | + binaryVersion: "0.1", |
| 57 | + }); |
54 | 58 |
|
55 | | -if (import.meta.main) { |
56 | | - await mainRunner(() => quartoBld(Deno.args)); |
| 59 | + [ |
| 60 | + ...commands, |
| 61 | + Builtins.HelpCommand |
| 62 | + ].forEach((command) => { |
| 63 | + addLoggingOptions(command); |
| 64 | + this.register(command); |
| 65 | + }); |
| 66 | + } |
57 | 67 | } |
58 | 68 |
|
59 | | -// Supported package commands |
60 | | -function getCommands() { |
61 | | - // deno-lint-ignore no-explicit-any |
62 | | - const commands: Command<any>[] = []; |
63 | | - commands.push( |
64 | | - packageCommand(configure) |
65 | | - .name("configure") |
66 | | - .description( |
67 | | - "Configures this machine for running developer version of Quarto", |
68 | | - ), |
69 | | - ); |
70 | | - commands.push( |
71 | | - packageCommand(updateHtmlDependencies) |
72 | | - .name("update-html-dependencies") |
73 | | - .description( |
74 | | - "Updates Bootstrap, themes, and JS/CSS dependencies based upon the version in configuration", |
75 | | - ), |
76 | | - ); |
77 | | - commands.push( |
78 | | - packageCommand(archiveBinaryDependencies) |
79 | | - .name("archive-bin-deps") |
80 | | - .description("Downloads and archives our binary dependencies."), |
81 | | - ); |
82 | | - commands.push( |
83 | | - packageCommand(checkBinaryDependencies) |
84 | | - .name("check-bin-deps") |
85 | | - .description("Checks the paths and URLs of our binary dependencies."), |
86 | | - ); |
87 | | - commands.push( |
88 | | - packageCommand(prepareDist) |
89 | | - .name("prepare-dist") |
90 | | - .description("Prepares the distribution directory for packaging."), |
91 | | - ); |
92 | | - commands.push( |
93 | | - packageCommand(validateBundle) |
94 | | - .name("validate-bundle") |
95 | | - .description("Validate a JS bundle built using prepare-dist") |
96 | | - ); |
97 | | - commands.push( |
98 | | - packageCommand(makeInstallerMac) |
99 | | - .name("make-installer-mac") |
100 | | - .description("Builds Mac OS installer"), |
101 | | - ); |
102 | | - commands.push( |
103 | | - packageCommand(makeInstallerDeb) |
104 | | - .name("make-installer-deb") |
105 | | - .description("Builds Linux deb installer"), |
106 | | - ); |
107 | | - commands.push( |
108 | | - packageCommand(makeInstallerWindows) |
109 | | - .name("make-installer-win") |
110 | | - .description("Builds Windows installer"), |
111 | | - ); |
112 | | - commands.push( |
113 | | - packageCommand(makeInstallerExternal) |
114 | | - .name("make-installer-dir") |
115 | | - .description("Copies Quarto-only files, omitting dependencies, to specified location (for use in third party packaging)"), |
116 | | - ); |
117 | | - commands.push( |
118 | | - compileQuartoLatexmkCommand(), |
119 | | - ); |
120 | | - commands.push( |
121 | | - cycleDependenciesCommand(), |
122 | | - ); |
123 | | - commands.push( |
124 | | - parseSwcLogCommand(), |
125 | | - ); |
126 | | - commands.push( |
127 | | - updatePandoc(), |
128 | | - ); |
129 | | - |
130 | | - return commands; |
| 69 | +if (import.meta.main) { |
| 70 | + await mainRunner(async () => { |
| 71 | + const quartoBld = new QuartoBld(); |
| 72 | + await quartoBld.runExit(Deno.args); |
| 73 | + }); |
131 | 74 | } |
0 commit comments