Skip to content

Commit e5f0e64

Browse files
claude: Add optional entry-point argument to build-ts-extension
Adds support for specifying the entry point as a command-line argument: quarto dev-call build-ts-extension [entry-point] Entry point resolution priority (highest to lowest): 1. [entry-point] command-line argument 2. quartoExtension.entryPoint in deno.json 3. Single .ts file in src/ directory 4. src/mod.ts if multiple files exist This allows building extensions with multiple TypeScript files without requiring a deno.json just to specify the entry point. Updated error messages to suggest both CLI argument and deno.json options. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 83c9ee7 commit e5f0e64

File tree

1 file changed

+18
-11
lines changed
  • src/command/dev-call/build-ts-extension

1 file changed

+18
-11
lines changed

src/command/dev-call/build-ts-extension/cmd.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ async function autoDetectEntryPoint(
9292
error(" mkdir -p src");
9393
error(" touch src/my-engine.ts");
9494
error("");
95-
error("Or specify entry point in deno.json:");
95+
error("Or specify entry point as argument or in deno.json:");
96+
error(" quarto dev-call build-ts-extension src/my-engine.ts");
97+
error(" OR in deno.json:");
9698
error(" {");
9799
error(' "quartoExtension": {');
98100
error(' "entryPoint": "path/to/file.ts"');
@@ -140,7 +142,9 @@ async function autoDetectEntryPoint(
140142

141143
error(`Error: Multiple .ts files found in src/: ${tsFiles.join(", ")}`);
142144
error("");
143-
error("Specify entry point in deno.json:");
145+
error("Specify entry point as argument or in deno.json:");
146+
error(" quarto dev-call build-ts-extension src/my-engine.ts");
147+
error(" OR in deno.json:");
144148
error(" {");
145149
error(' "quartoExtension": {');
146150
error(' "entryPoint": "src/my-engine.ts"');
@@ -357,21 +361,23 @@ async function initializeConfig(): Promise<void> {
357361
export const buildTsExtensionCommand = new Command()
358362
.name("build-ts-extension")
359363
.hidden()
364+
.arguments("[entry-point:string]")
360365
.description(
361366
"Build TypeScript execution engine extensions.\n\n" +
362367
"This command type-checks and bundles TypeScript extensions " +
363-
"into single JavaScript files using Quarto's bundled esbuild.\n\n" +
368+
"into single JavaScript files using Quarto's bundled deno bundle.\n\n" +
364369
"The entry point is determined by:\n" +
365-
" 1. quartoExtension.entryPoint in deno.json (if specified)\n" +
366-
" 2. Single .ts file in src/ directory\n" +
367-
" 3. src/mod.ts (if multiple .ts files exist)",
370+
" 1. [entry-point] command-line argument (if specified)\n" +
371+
" 2. quartoExtension.entryPoint in deno.json (if specified)\n" +
372+
" 3. Single .ts file in src/ directory\n" +
373+
" 4. src/mod.ts (if multiple .ts files exist)",
368374
)
369375
.option("--check", "Type-check only (skip bundling)")
370376
.option(
371377
"--init-config",
372378
"Generate deno.json with absolute importMap path",
373379
)
374-
.action(async (options: BuildOptions) => {
380+
.action(async (options: BuildOptions, entryPointArg?: string) => {
375381
try {
376382
// Handle --init-config flag first (don't build)
377383
if (options.initConfig) {
@@ -382,10 +388,11 @@ export const buildTsExtensionCommand = new Command()
382388
// 1. Resolve configuration
383389
const { config, configPath } = await resolveConfig();
384390

385-
// 2. Resolve entry point
386-
const entryPoint = await autoDetectEntryPoint(
387-
config.quartoExtension?.entryPoint,
388-
);
391+
// 2. Resolve entry point (CLI arg takes precedence)
392+
const entryPoint = entryPointArg ||
393+
await autoDetectEntryPoint(
394+
config.quartoExtension?.entryPoint,
395+
);
389396
info(`Entry point: ${entryPoint}`);
390397

391398
// 3. Type-check or bundle

0 commit comments

Comments
 (0)