Skip to content

fix(PackageManagerTabs): correctly handle deno run args and add -A flag#3188

Merged
SoonIter merged 1 commit intomainfrom
fix/deno-run-args
Mar 3, 2026
Merged

fix(PackageManagerTabs): correctly handle deno run args and add -A flag#3188
SoonIter merged 1 commit intomainfrom
fix/deno-run-args

Conversation

@Timeless0911
Copy link
Copy Markdown
Contributor

Summary

Correctly handle positional arguments for deno run in PackageManagerTabs component. Previously, all positional arguments were prefixed with npm:, which caused issues when running tools that take subcommands (e.g., skills add ...).

This PR:

  1. Updates transformDenoPositional to only prefix the first positional argument with npm: when the subcommand is run.
  2. Adds the -A (allow-all) flag to deno run by default to match the behavior of other package managers' execution commands (like npx, bunx).
  3. Adds E2E test cases for dlx with multiple arguments.

Related Issue

None.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings March 3, 2026 07:30
@Timeless0911 Timeless0911 changed the title fix(theme): correctly handle deno run args and add -A flag fix(PackageManagerTabs): correctly handle deno run args and add -A flag Mar 3, 2026
@Timeless0911 Timeless0911 requested a review from SoonIter March 3, 2026 07:31
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying rspress-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: a4e5565
Status: ✅  Deploy successful!
Preview URL: https://ed356772.rspress-v2.pages.dev
Branch Preview URL: https://fix-deno-run-args.rspress-v2.pages.dev

View logs

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2026

Rsdoctor Bundle Diff Analysis

Found 3 projects in monorepo, 3 projects with changes.

📊 Quick Summary
Project Total Size Change
node 12.0 MB -10.0 B (-0.0%)
web 16.0 MB +57.0 B (0.0%)
node_md 1.5 MB -20.0 B (-0.0%)
📋 Detailed Reports (Click to expand)

📁 node

Path: website/doc_build/diff-rsdoctor/node/rsdoctor-data.json

📌 Baseline Commit: d33071610a | PR: #3181

Metric Current Baseline Change
📊 Total Size 12.0 MB 12.0 MB -10.0 B (-0.0%)
📄 JavaScript 0 B 0 B 0
🎨 CSS 0 B 0 B 0
🌐 HTML 12.0 MB 12.0 MB -10.0 B (-0.0%)
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: node Bundle Diff

📁 web

Path: website/doc_build/diff-rsdoctor/web/rsdoctor-data.json

📌 Baseline Commit: d33071610a | PR: #3181

Metric Current Baseline Change
📊 Total Size 16.0 MB 16.0 MB +57.0 B (0.0%)
📄 JavaScript 15.7 MB 15.7 MB +57.0 B (0.0%)
🎨 CSS 120.3 KB 120.3 KB 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 163.6 KB 163.6 KB 0

📦 Download Diff Report: web Bundle Diff

📁 node_md

Path: website/doc_build/diff-rsdoctor/node_md/rsdoctor-data.json

📌 Baseline Commit: d33071610a | PR: #3181

Metric Current Baseline Change
📊 Total Size 1.5 MB 1.5 MB -20.0 B (-0.0%)
📄 JavaScript 0 B 0 B 0
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 1.5 MB 1.5 MB -20.0 B (-0.0%)

📦 Download Diff Report: node_md Bundle Diff

Generated by Rsdoctor GitHub Action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes how Deno run commands are generated in PackageManagerTabs, ensuring only the first positional argument is prefixed with npm: when using deno run, and adds default -A permissions. It also extends E2E coverage for dlx commands that include multiple arguments.

Changes:

  • Update Deno positional-arg transformation to only prefix the first positional argument for deno run.
  • Change Deno execution commands to use deno run -A by default.
  • Add E2E fixture + assertions for dlx commands with multiple arguments.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/core/src/theme/components/PackageManagerTabs/index.tsx Adjusts Deno command rendering (-A) and positional arg prefixing logic.
e2e/fixtures/package-manager-tabs/index.test.ts Adds assertions for multi-arg dlx commands and updates expected Deno output.
e2e/fixtures/package-manager-tabs/doc/index.mdx Adds fixture content for a dlx command with multiple args.
Comments suppressed due to low confidence (2)

packages/core/src/theme/components/PackageManagerTabs/index.tsx:66

  • transformDenoPositional only treats --... tokens as flags. With the new default deno run -A, -A is a short flag that does not start with -- and will be treated as a positional argument and incorrectly rewritten to npm:-A (and then the actual script/tool may stop being transformed). Update the positional detection to also exclude short flags (tokens starting with -), and (if applicable) exclude their flag-values similar to the existing --... logic.
  const subcommand = parts[1];
  const isRun = subcommand === 'run';
  let transformedFirst = false;

  const transformed = parts.map((tok, idx) => {
    // only transform positional args (after "deno" and the subcommand)
    if (
      idx >= 2 &&
      !tok.startsWith('-') &&
      !tok.includes(':') &&
      !/^https?:/.test(tok)
    ) {
      if (isRun && transformedFirst) {
        return tok;
      }
      transformedFirst = true;
      return `npm:${tok}`;
    }
    return tok;
  });

e2e/fixtures/package-manager-tabs/index.test.ts:1

  • The fixture doc now renders an additional <PackageManagerTabs ... /> (multi-arg dlx) while still keeping the original dlx and exec examples, so the page likely has 3 tab groups (15 tabs), not 2 (10 tabs). Either update this expectation to match the new number of rendered tab groups, or change the test query to scope to the specific PackageManagerTabs instance(s) it intends to assert.
import { expect, test } from '@playwright/test';

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SoonIter SoonIter enabled auto-merge (squash) March 3, 2026 07:41
@SoonIter SoonIter merged commit 40f8895 into main Mar 3, 2026
11 checks passed
@SoonIter SoonIter deleted the fix/deno-run-args branch March 3, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants