Skip to content

Update bootstrap.ps1#408

Merged
gnh1201 merged 3 commits intomasterfrom
dev
Apr 18, 2026
Merged

Update bootstrap.ps1#408
gnh1201 merged 3 commits intomasterfrom
dev

Conversation

@gnh1201
Copy link
Copy Markdown
Owner

@gnh1201 gnh1201 commented Apr 18, 2026

Update bootstrap.ps1

Summary by Sourcery

Update the PowerShell bootstrap script to support both default interactive installation and argument-driven execution of WelsonJS, including new file execution mode and clearer usage guidance.

New Features:

  • Add support for a -file argument to run a specified script via cscript with an interactive console, automatically appending .js when no extension is provided.

Enhancements:

  • Clarify bootstrap.ps1 usage comments with separate quick-start and argument-based invocation examples.
  • Adjust bootstrap flow to conditionally launch either app.js via cscript when a file is provided or bootstrap.bat in a non-blocking way when no file is specified.
  • Improve status output messages to reflect execution start rather than completion and to distinguish between interactive and non-blocking modes.

Summary by CodeRabbit

  • New Features

    • The bootstrap script now supports a -file <path> argument to execute custom JavaScript files. Files without a .js extension are automatically appended.
  • Improvements

    • Updated console output messages to better reflect execution status and provide clearer feedback.

gnh1201 added 2 commits April 18, 2026 21:21
Add -file argument handling and automatic .js extension, allowing the script to locate and run app.js via cscript (interactive) when provided. Improve argument parsing to support -dev and -file together, surface file/branch choices in logs, and reorganize steps/messages for clearer temporary workspace, download, extraction, and execution flow. Default bootstrap behavior remains (launch bootstrap.bat non-blocking), with updated success/failure reporting.
Clarify and expand the usage comments in bootstrap.ps1: add a "Quick start (no arguments)" note and a recommended "With arguments" workflow that shows saving the script locally and invoking it with -dev and -file parameters. Reformat example commands for clarity; no functional code changes.
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 18, 2026

Reviewer's Guide

Refactors bootstrap.ps1 to support a new -file argument for running app.js via cscript with an explicit JS file, updates usage docs, and changes the default bootstrap behavior to launch either app.js or bootstrap.bat in a non-blocking way while simplifying the temporary workspace steps.

Sequence diagram for the updated bootstrap.ps1 execution flow

sequenceDiagram
    actor User
    participant PowerShell as PowerShell_bootstrap.ps1
    participant GitHub as GitHub_repo
    participant Cmd as cmd_exe
    participant CScript as cscript

    User->>PowerShell: Invoke bootstrap.ps1 (optional -dev, -file)
    PowerShell->>PowerShell: Set branch from -dev or positional
    PowerShell->>PowerShell: Set fileArg from -file
    PowerShell->>PowerShell: Auto-append .js if fileArg has no extension
    PowerShell->>GitHub: Download branch zip
    GitHub-->>PowerShell: ZIP archive
    PowerShell->>PowerShell: Extract archive to temp workspace

    alt fileArg specified
        PowerShell->>PowerShell: Locate app.js in extracted repo
        PowerShell->>Cmd: Start-Process cmd.exe /k cscript app.js fileArg
        Cmd->>CScript: Run app.js with fileArg (interactive)
        CScript-->>Cmd: Script output
        Cmd-->>User: Interactive console stays open
    else no fileArg
        PowerShell->>PowerShell: Locate bootstrap.bat in extracted repo
        PowerShell->>Cmd: Start-Process cmd.exe /c bootstrap.bat
        Cmd-->>User: Non-blocking bootstrap execution
    end

    PowerShell-->>User: Print WelsonJS execution started
Loading

Flow diagram for argument parsing and execution paths in bootstrap.ps1

flowchart TD
    A[Start bootstrap.ps1] --> B[Initialize branch = defaultBranch, fileArg = null]
    B --> C{More args?}
    C -->|Yes| D[Read current arg]
    C -->|No| G

    D --> E{arg == -dev and has next?}
    E -->|Yes| E1[Set branch = next arg, increment i] --> F
    E -->|No| F[Check -file]

    F --> F1{arg == -file and has next?}
    F1 -->|Yes| F2[Set fileArg = next arg, increment i] --> H
    F1 -->|No| F3{arg does not start with -}

    F3 -->|Yes| F4[Set branch = arg] --> H
    F3 -->|No| H[Increment i]

    H --> C

    G[Finish arg parsing] --> I{fileArg set?}
    I -->|Yes| J{fileArg has extension?}
    I -->|No| N

    J -->|No| K[Append .js to fileArg]
    J -->|Yes| L[Keep fileArg as is]
    K --> M
    L --> M

    M[Log branch and fileArg] --> O[Create temp workspace]
    N[Log branch only] --> O

    O --> P[Download branch ZIP from GitHub]
    P --> Q[Extract ZIP]
    Q --> R{fileArg set?}

    R -->|Yes| S[Locate app.js]
    S --> T{app.js found?}
    T -->|No| U[Throw error app.js not found]
    T -->|Yes| V[Start cmd.exe /k cscript app.js fileArg]
    V --> W[Print WelsonJS execution started]

    R -->|No| X[Locate bootstrap.bat]
    X --> Y{bootstrap.bat found?}
    Y -->|No| Z[Throw error bootstrap.bat not found]
    Y -->|Yes| AA[Start cmd.exe /c bootstrap.bat]
    AA --> W

    W --> AB[End]
Loading

File-Level Changes

Change Details Files
Extend argument parsing to support an optional -file parameter and adjust branch handling.
  • Initialize a new $fileArg variable alongside $branch with default null.
  • Update the argument parsing loop to handle -dev by consuming the following token without breaking the loop.
  • Add support for a -file argument that records the subsequent value into $fileArg.
  • Retain support for passing a bare branch name without a leading dash.
  • Automatically append .js to the file argument when no extension is provided.
  • Log the resolved branch and optional file argument using Write-Step.
bootstrap.ps1
Change bootstrap execution flow to optionally run app.js via cscript when -file is provided, otherwise run bootstrap.bat as before but in a non-blocking way.
  • Rename and simplify comments for the workspace creation and download/extract steps.
  • Add a new conditional branch: when $fileArg is set, locate app.js in the extracted tree and start cmd.exe with /k cscript app.js passing the file argument, leaving the console open.
  • Throw a descriptive error if app.js is not found.
  • For the default path (no -file), keep locating bootstrap.bat but start cmd.exe with /c bootstrap.bat using Start-Process without waiting for completion and without checking exit code.
  • Update success messaging from 'WelsonJS installation completed!' to 'WelsonJS execution started!' to reflect the new non-blocking behavior.
bootstrap.ps1
Update usage comments and minor formatting at the top of the script.
  • Normalize spacing in comment headers.
  • Document a quick-start usage with no arguments via Invoke-RestMethod piped to Invoke-Expression.
  • Add a recommended usage section that downloads bootstrap.ps1 to disk and then runs it with -dev and -file examples.
  • Move the $defaultBranch initialization directly under the usage comments for clarity.
bootstrap.ps1

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add file argument support and improve bootstrap.ps1 documentation

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add -file argument support to run custom JavaScript files via cscript
• Implement automatic .js extension appending for file arguments
• Refactor argument parsing to support -dev and -file together
• Improve usage documentation with quick start and recommended workflow examples
• Reorganize execution flow with conditional branching for file vs. bootstrap modes
• Change bootstrap execution to non-blocking with updated success messaging
Diagram
flowchart LR
  A["Parse Arguments<br/>-dev, -file"] --> B["Create Temp<br/>Workspace"]
  B --> C["Download<br/>Package"]
  C --> D["Extract<br/>Archive"]
  D --> E{File Arg<br/>Provided?}
  E -->|Yes| F["Run app.js<br/>via cscript"]
  E -->|No| G["Run bootstrap.bat<br/>non-blocking"]
  F --> H["Execution<br/>Started"]
  G --> H
Loading

Grey Divider

File Changes

1. bootstrap.ps1 ✨ Enhancement +58/-39

Add file argument support and improve documentation

• Added -file argument parsing to support running custom JavaScript files with automatic .js
 extension appending
• Implemented conditional execution flow: cscript for file mode (interactive) vs. bootstrap.bat for
 default mode (non-blocking)
• Refactored argument parsing loop to support multiple arguments (-dev and -file together) with
 proper index increment
• Updated usage documentation with "Quick start" and "With arguments" sections showing recommended
 workflow
• Reorganized step comments and messaging for clearer temporary workspace, download, extraction, and
 execution phases
• Changed bootstrap execution to non-blocking and updated final success message from "installation
 completed" to "execution started"

bootstrap.ps1


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented Apr 18, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (3) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Unvalidated $fileArg in cmd.exe 📘 Rule violation ⛨ Security
Description
$fileArg (user-controlled via -file) is interpolated into a cmd.exe command line without
validation/escaping, so quotes/metacharacters can break argument parsing or enable command
injection. This violates the requirement to validate inputs/constraints before operating on them.
Code

bootstrap.ps1[R103-105]

+        Start-Process "cmd.exe" `
+            -ArgumentList "/k cscript `"$($app.FullName)`" `"$fileArg`""

-    if ($proc.ExitCode -ne 0) {
-        throw "bootstrap failed with exit code $($proc.ExitCode)"
Evidence
PR Compliance ID 1 requires validating inputs/constraints before operating on values. The code
passes the raw $fileArg into cmd.exe via -ArgumentList with only quoting, which does not
prevent embedded quotes/metacharacters from altering the command line.

bootstrap.ps1[103-105]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`$fileArg` is user-controlled and is embedded into a `cmd.exe` command line without strict validation/escaping, which can lead to command-line injection or unexpected parsing.

## Issue Context
`-file` is parsed from `$args` and later used to build `Start-Process "cmd.exe" -ArgumentList ...`.

## Fix Focus Areas
- bootstrap.ps1[89-106]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Fire-and-forget Start-Process call 📘 Rule violation ☼ Reliability
Description
The script launches bootstrap.bat with Start-Process without -Wait/-PassThru, so failures
and non-zero exit codes are not observed or reported. This matches the checklist’s prohibition on
unobserved fire-and-forget operations where faults can be lost.
Code

bootstrap.ps1[R120-125]

+        Write-Step "Executing bootstrap (non-blocking)..."
+
+        Start-Process "cmd.exe" `
+            -ArgumentList "/c `"$($bootstrap.FullName)`""
+
+        Write-Ok "Bootstrap launched"
Evidence
PR Compliance ID 2 requires avoiding unobserved fire-and-forget operations and ensuring faults are
handled/observable. The Start-Process invocation does not wait or capture the process/exit status,
and the script prints success immediately afterward.

bootstrap.ps1[120-126]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`Start-Process` is used in a fire-and-forget way, which prevents observing failures (exit code) and reporting them.

## Issue Context
The default bootstrap flow used to be blocking and could validate success; now it launches and immediately reports "Bootstrap launched".

## Fix Focus Areas
- bootstrap.ps1[120-126]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Wrong cscript bitness 🐞 Bug ≡ Correctness
Description
In -file mode, bootstrap.ps1 launches cscript via cmd.exe without forcing the 32-bit
SysWOW64\cscript.exe that bootstrap.bat uses, which can break scripts that depend on the 32-bit
WelsonJS.Toolkit COM registration. This can cause runtime failures (e.g.,
CreateObject('WelsonJS.Toolkit')) in the launched session even though bootstrap.ps1 reports it
started successfully.
Code

bootstrap.ps1[R103-105]

+        Start-Process "cmd.exe" `
+            -ArgumentList "/k cscript `"$($app.FullName)`" `"$fileArg`""

-    if ($proc.ExitCode -ne 0) {
-        throw "bootstrap failed with exit code $($proc.ExitCode)"
Evidence
bootstrap.ps1’s -file branch launches cscript from PATH (bitness depends on the host OS/command
resolution), while bootstrap.bat explicitly uses the 32-bit cscript and registers an x86 toolkit DLL
via RegAsm—indicating bitness is important for correct execution. The codebase also directly
instantiates WelsonJS.Toolkit from scripts, which will fail if the wrong-bitness COM registration
is used.

bootstrap.ps1[89-107]
bootstrap.bat[8-13]
bootstrap.bat[44-50]
lib/std.js[299-314]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`-file` mode launches `cscript` via `cmd.exe` without pinning bitness. On 64-bit Windows this commonly resolves to 64-bit `cscript.exe`, which is incompatible with the x86 WelsonJS.Toolkit COM registration performed by `bootstrap.bat`.

### Issue Context
- `bootstrap.bat` registers an x86 toolkit DLL and then runs `%SystemRoot%\SysWOW64\cscript.exe`.
- User scripts and libraries may call `CreateObject("WelsonJS.Toolkit")`.

### Fix Focus Areas
- bootstrap.ps1[89-107]
- bootstrap.bat[8-13]
- bootstrap.bat[44-50]

### Suggested change
- In `-file` mode, launch `"$env:SystemRoot\SysWOW64\cscript.exe"` explicitly (or otherwise ensure 32-bit host) instead of relying on `cscript` from PATH.
- Consider also setting `-WorkingDirectory` to the extracted repo root (where `app.js` resides) for consistency with bootstrap.bat’s `pushd %~dp0` behavior.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

4. No cmd.exe/cscript detection 📘 Rule violation ☼ Reliability
Description
The new -file path assumes Windows-only executables (cmd.exe, cscript) without feature
detection or a clear fallback/error message, which will fail on non-Windows PowerShell environments.
This violates the cross-environment compatibility requirement.
Code

bootstrap.ps1[R101-105]

+        Write-Step "Executing via cscript (interactive)..."

-    $proc = Start-Process -FilePath "cmd.exe" `
-        -ArgumentList "/c `"$($bootstrap.FullName)`"" `
-        -Wait -PassThru
+        Start-Process "cmd.exe" `
+            -ArgumentList "/k cscript `"$($app.FullName)`" `"$fileArg`""

-    if ($proc.ExitCode -ne 0) {
-        throw "bootstrap failed with exit code $($proc.ExitCode)"
Evidence
PR Compliance ID 5 requires cross-environment compatible patterns and feature detection fallbacks.
The code invokes cmd.exe and cscript directly without checking platform/availability or
providing a fallback path.

bootstrap.ps1[101-105]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `-file` execution path hard-depends on Windows executables (`cmd.exe`, `cscript`) without validating that the environment supports them.

## Issue Context
This script may be executed under PowerShell 7+ in non-Windows environments, or on Windows where `cscript` is unavailable/disabled.

## Fix Focus Areas
- bootstrap.ps1[89-107]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2026

📝 Walkthrough

Walkthrough

The bootstrap.ps1 script is extended to support a new -file <path> argument that enables direct execution of specified JavaScript files via cscript, alongside existing -dev and branch-selection arguments. The script conditionally either executes the provided file or defaults to launching bootstrap.bat based on whether the file argument is present.

Changes

Cohort / File(s) Summary
Argument Parsing & Execution Flow
bootstrap.ps1
Extended argument parsing to capture -file <path> parameter; added .js extension auto-appending logic; refactored conditional execution to launch cscript with app.js when file argument provided, otherwise default to bootstrap.bat; updated user-facing log messages to reflect file selection state.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Add the one-click bootstrap #407: Modifies bootstrap.ps1's argument parsing with iex-compatible logic, providing foundational changes that this PR extends with the new -file option and conditional execution paths.

Poem

🐰 A script once simple, now takes flight,
With -file paths it sees new light!
Branch or bundle, bat or bee—
More choices bloom, wild and free! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Update bootstrap.ps1' is vague and generic, using non-descriptive language that does not convey the specific changes or main purpose of the pull request. Consider a more descriptive title such as 'Add -file argument support to bootstrap.ps1' or 'Extend bootstrap.ps1 to support file argument and cscript execution' to clearly communicate the primary change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • When deciding whether to auto-append ".js" to -file, consider using [System.IO.Path]::GetExtension($fileArg) instead of a regex match on "." to avoid misclassifying paths that contain dots in folder names but no file extension.
  • The new -file execution path invokes cmd.exe /k cscript ... without waiting on or checking the exit code; if error reporting or scripting usage is important, you may want to use -Wait -PassThru and surface failures similarly to how the old bootstrap path handled them.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When deciding whether to auto-append ".js" to `-file`, consider using `[System.IO.Path]::GetExtension($fileArg)` instead of a regex match on `"."` to avoid misclassifying paths that contain dots in folder names but no file extension.
- The new `-file` execution path invokes `cmd.exe /k cscript ...` without waiting on or checking the exit code; if error reporting or scripting usage is important, you may want to use `-Wait -PassThru` and surface failures similarly to how the old bootstrap path handled them.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

All updates of master branch until 2026-04-18
@sonarqubecloud
Copy link
Copy Markdown

Comment thread bootstrap.ps1
Comment on lines +103 to 105
Start-Process "cmd.exe" `
-ArgumentList "/k cscript `"$($app.FullName)`" `"$fileArg`""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. Unvalidated $filearg in cmd.exe 📘 Rule violation ⛨ Security

$fileArg (user-controlled via -file) is interpolated into a cmd.exe command line without
validation/escaping, so quotes/metacharacters can break argument parsing or enable command
injection. This violates the requirement to validate inputs/constraints before operating on them.
Agent Prompt
## Issue description
`$fileArg` is user-controlled and is embedded into a `cmd.exe` command line without strict validation/escaping, which can lead to command-line injection or unexpected parsing.

## Issue Context
`-file` is parsed from `$args` and later used to build `Start-Process "cmd.exe" -ArgumentList ...`.

## Fix Focus Areas
- bootstrap.ps1[89-106]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread bootstrap.ps1
Comment on lines +120 to +125
Write-Step "Executing bootstrap (non-blocking)..."

Start-Process "cmd.exe" `
-ArgumentList "/c `"$($bootstrap.FullName)`""

Write-Ok "Bootstrap launched"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

2. Fire-and-forget start-process call 📘 Rule violation ☼ Reliability

The script launches bootstrap.bat with Start-Process without -Wait/-PassThru, so failures
and non-zero exit codes are not observed or reported. This matches the checklist’s prohibition on
unobserved fire-and-forget operations where faults can be lost.
Agent Prompt
## Issue description
`Start-Process` is used in a fire-and-forget way, which prevents observing failures (exit code) and reporting them.

## Issue Context
The default bootstrap flow used to be blocking and could validate success; now it launches and immediately reports "Bootstrap launched".

## Fix Focus Areas
- bootstrap.ps1[120-126]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread bootstrap.ps1
Comment on lines +103 to 105
Start-Process "cmd.exe" `
-ArgumentList "/k cscript `"$($app.FullName)`" `"$fileArg`""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

3. Wrong cscript bitness 🐞 Bug ≡ Correctness

In -file mode, bootstrap.ps1 launches cscript via cmd.exe without forcing the 32-bit
SysWOW64\cscript.exe that bootstrap.bat uses, which can break scripts that depend on the 32-bit
WelsonJS.Toolkit COM registration. This can cause runtime failures (e.g.,
CreateObject('WelsonJS.Toolkit')) in the launched session even though bootstrap.ps1 reports it
started successfully.
Agent Prompt
### Issue description
`-file` mode launches `cscript` via `cmd.exe` without pinning bitness. On 64-bit Windows this commonly resolves to 64-bit `cscript.exe`, which is incompatible with the x86 WelsonJS.Toolkit COM registration performed by `bootstrap.bat`.

### Issue Context
- `bootstrap.bat` registers an x86 toolkit DLL and then runs `%SystemRoot%\SysWOW64\cscript.exe`.
- User scripts and libraries may call `CreateObject("WelsonJS.Toolkit")`.

### Fix Focus Areas
- bootstrap.ps1[89-107]
- bootstrap.bat[8-13]
- bootstrap.bat[44-50]

### Suggested change
- In `-file` mode, launch `"$env:SystemRoot\SysWOW64\cscript.exe"` explicitly (or otherwise ensure 32-bit host) instead of relying on `cscript` from PATH.
- Consider also setting `-WorkingDirectory` to the extracted repo root (where `app.js` resides) for consistency with bootstrap.bat’s `pushd %~dp0` behavior.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
bootstrap.ps1 (1)

36-50: Silent failure when -file/-dev is the last token.

If a user invokes the script as ... -file (no value following), the ($i + 1) -lt $args.Count guard fails, the flag is silently ignored, and execution falls back to the default bootstrap.bat path with no indication that the requested file was dropped. Same applies to a trailing -dev. Consider emitting an explicit error (or warning) when a flag is provided without its required value, e.g.:

         if ($arg -eq "-dev" -and ($i + 1) -lt $args.Count) {
             $branch = $args[$i + 1]
             $i++
         }
+        elseif ($arg -eq "-dev") {
+            throw "-dev requires a branch name"
+        }
         elseif ($arg -eq "-file" -and ($i + 1) -lt $args.Count) {
             $fileArg = $args[$i + 1]
             $i++
         }
+        elseif ($arg -eq "-file") {
+            throw "-file requires a file path"
+        }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bootstrap.ps1` around lines 36 - 50, The loop that parses $args in
bootstrap.ps1 silently ignores a trailing "-file" or "-dev" because the ($i + 1)
-lt $args.Count guard prevents capturing a missing value; update the parsing in
the for loop that examines $arg to detect when "-file" or "-dev" is the last
token and emit an explicit error and exit (e.g. use Write-Error/Write-Host and
exit 1) instead of falling back to defaults; ensure you set $fileArg and $branch
only when a value exists and add a branch that logs the missing-value error
referencing the same variables/flags ($arg, $fileArg, $branch) so callers are
informed when a flag is provided without a value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bootstrap.ps1`:
- Around line 52-55: The current extension check uses -match "\." on $fileArg
which triggers for any dot anywhere in the path (e.g., "sub.dir/file"), so
change the condition to test for a real filename extension instead; update the
if that currently reads `if ($fileArg -and -not ($fileArg -match "\."))` to use
a proper extension check such as verifying
[System.IO.Path]::GetExtension($fileArg) is empty (or use a regex that matches
an extension at the end like '\.[^\\/]+$') before appending ".js" so $fileArg
only gets ".js" when it truly lacks an extension.
- Around line 103-104: The current Start-Process call invoking cmd.exe with
-ArgumentList "/k cscript `"$($app.FullName)`" `"$fileArg`"" fails for paths
with spaces because cmd.exe /k strips inner quotes; update the invocation so the
entire command after /k is wrapped in a single quoted string (e.g. "/k \"cscript
\"<path>\" \"<arg>\"\"") or, better, avoid cmd.exe entirely by calling
Start-Process directly with FilePath "cscript.exe" and Arguments built from
$app.FullName and $fileArg, or change to Set-Location to the app directory and
pass only the file name; target the Start-Process line that references cmd.exe,
$app.FullName and $fileArg.

---

Nitpick comments:
In `@bootstrap.ps1`:
- Around line 36-50: The loop that parses $args in bootstrap.ps1 silently
ignores a trailing "-file" or "-dev" because the ($i + 1) -lt $args.Count guard
prevents capturing a missing value; update the parsing in the for loop that
examines $arg to detect when "-file" or "-dev" is the last token and emit an
explicit error and exit (e.g. use Write-Error/Write-Host and exit 1) instead of
falling back to defaults; ensure you set $fileArg and $branch only when a value
exists and add a branch that logs the missing-value error referencing the same
variables/flags ($arg, $fileArg, $branch) so callers are informed when a flag is
provided without a value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5fee5102-aa18-4622-af6c-cc6102999a94

📥 Commits

Reviewing files that changed from the base of the PR and between 672ceb3 and 47ba0cf.

📒 Files selected for processing (1)
  • bootstrap.ps1

Comment thread bootstrap.ps1
Comment on lines +52 to +55
# Auto-append .js if no extension
if ($fileArg -and -not ($fileArg -match "\.")) {
$fileArg = "$fileArg.js"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Extension check matches any dot in the path, not just an extension.

$fileArg -match "\." returns true for inputs like my.app, sub.dir/test, or any path containing a dot, so .js will not be appended even when there is no real extension. Use a proper extension check instead.

Proposed fix
-    # Auto-append .js if no extension
-    if ($fileArg -and -not ($fileArg -match "\.")) {
-        $fileArg = "$fileArg.js"
-    }
+    # Auto-append .js if no extension on the file name
+    if ($fileArg -and -not [System.IO.Path]::GetExtension($fileArg)) {
+        $fileArg = "$fileArg.js"
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Auto-append .js if no extension
if ($fileArg -and -not ($fileArg -match "\.")) {
$fileArg = "$fileArg.js"
}
# Auto-append .js if no extension on the file name
if ($fileArg -and -not [System.IO.Path]::GetExtension($fileArg)) {
$fileArg = "$fileArg.js"
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bootstrap.ps1` around lines 52 - 55, The current extension check uses -match
"\." on $fileArg which triggers for any dot anywhere in the path (e.g.,
"sub.dir/file"), so change the condition to test for a real filename extension
instead; update the if that currently reads `if ($fileArg -and -not ($fileArg
-match "\."))` to use a proper extension check such as verifying
[System.IO.Path]::GetExtension($fileArg) is empty (or use a regex that matches
an extension at the end like '\.[^\\/]+$') before appending ".js" so $fileArg
only gets ".js" when it truly lacks an extension.

Comment thread bootstrap.ps1
Comment on lines +103 to +104
Start-Process "cmd.exe" `
-ArgumentList "/k cscript `"$($app.FullName)`" `"$fileArg`""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "bootstrap.ps1" 2>/dev/null

Repository: gnh1201/welsonjs

Length of output: 75


🏁 Script executed:

cat -n bootstrap.ps1 | head -120 | tail -40

Repository: gnh1201/welsonjs

Length of output: 1557


🏁 Script executed:

cat > /tmp/test_quoting.md << 'EOF'
# PowerShell Start-Process argument passing behavior

When using Start-Process with -ArgumentList, PowerShell passes arguments as a single command line string to the process. For cmd.exe /k:

1. Start-Process receives: "/k cscript `"C:\path with spaces\app.js`" `"arg with spaces`""
2. This becomes the full command line argument to cmd.exe
3. cmd.exe /k then processes this string with its own parsing rules

cmd.exe /k quoting rules (from cmd /?):
- cmd /k interprets the first unquoted string as the command to execute
- Everything after /k becomes the command line to execute
- If the command contains spaces and is NOT quoted, cmd will split at the first space

The issue: If $app.FullName contains spaces, the backtick-escaped quotes may not protect it properly
because cmd.exe receives the entire ArgumentList as a single parameter and applies its own quote parsing.

Proposed fix syntax check:
/k `"cscript `"`"$($app.FullName)`"`" `"`"$fileArg`"`"`"

This would result in nested quotes being passed to cmd.exe which could be problematic.
EOF
cat /tmp/test_quoting.md

Repository: gnh1201/welsonjs

Length of output: 1106


🏁 Script executed:

# Let me check what actual behavior occurs with Start-Process and cmd.exe argument passing
python3 << 'EOF'
# Analyze the proposed fix syntax
original = '/k cscript `"$($app.FullName)`" `"$fileArg`"'
proposed = '/k `"cscript `"`"$($app.FullName)`"`" `"`"$fileArg`"`"`"'

print("Original quoting:")
print(f"  {original}")
print()
print("Proposed quoting:")
print(f"  {proposed}")
print()
print("Issue analysis:")
print("- Start-Process passes -ArgumentList as a single string to cmd.exe")
print("- cmd.exe /k applies its own quote-stripping rules")
print("- Backtick escaping in PowerShell handles PowerShell parsing, not cmd.exe parsing")
print()
print("The real issue:")
print("- If $app.FullName contains spaces and cmd.exe strips/misinterprets quotes,")
print("  the command may be split incorrectly")
print("- Example: /k cscript \"C:\\Program Files\\app.js\" \"arg\"")
print("  If cmd strips outer quotes, it becomes: cscript C:\\Program Files\\app.js ...")
print("  And cmd treats 'C:\\Program' as one argument and 'Files\\app.js' as another")
EOF

Repository: gnh1201/welsonjs

Length of output: 759


🌐 Web query:

PowerShell Start-Process cmd.exe ArgumentList cmd /k quoting spaces paths

💡 Result:

To start cmd.exe using PowerShell's Start-Process cmdlet with the /k switch (to execute a command and keep the window open) while properly handling paths containing spaces in ArgumentList, use embedded double-quoting with escaped quotes in PowerShell strings. Official Microsoft documentation recommends using a single string for ArgumentList when dealing with complex quoting: Start-Process -FilePath cmd.exe -ArgumentList "/k dir "%SystemDrive%\Program Files"" This passes cmd.exe /k dir "C:\Program Files" (assuming C: drive), correctly quoting the path with spaces. The "" is PowerShell's escaped double quote. For an array: Start-Process -FilePath cmd.exe -ArgumentList "/k", "dir", ""%SystemDrive%\Program Files"" Both work per docs (results 7,9,10,17 from first search; similar in second). For a custom path with spaces, e.g., $path = "C:\My Folder\script.bat": - Single string (recommended for cmd /k): Start-Process cmd.exe -ArgumentList "/k "$path"" The resulting command line is: cmd.exe /k "C:\My Folder\script.bat" - Array: Start-Process cmd.exe -ArgumentList "/k", ""$path"" Due to a longstanding Start-Process bug (GitHub #5576, mentioned in results 1,2,11), arguments with spaces must have embedded "..." in PowerShell strings using "" . For cmd /k followed by multiple commands or complex args, enclose the entire command after /k in additional quotes to avoid cmd.exe parsing bugs (result 1): "/k "dir "C:\My Folder" & pause"" Here-strings simplify multi-line: $args = @" /k dir "$env:SystemDrive\Program Files" "@ Start-Process cmd.exe -ArgumentList $args Examples tested in recent PowerShell 7.x docs (up to 7.6 as of 2026).

Citations:


🏁 Script executed:

python3 << 'EOF'
# Verify the proposed fix syntax against PowerShell quoting rules

original = r'/k cscript `"$($app.FullName)`" `"$fileArg`"'
proposed = r'/k `"cscript `"`"$($app.FullName)`"`" `"`"$fileArg`"`"`"'
recommended = r'/k `"cscript `"$($app.FullName)`" `"$fileArg`"`"'

print("Current code (as in bootstrap.ps1):")
print(f"  -ArgumentList \"{original}\"")
print("  → cmd.exe receives: /k cscript \"...path...\" \"...arg...\"")
print()

print("Proposed fix (from review):")
print(f"  -ArgumentList \"{proposed}\"")
print("  Analysis: Multiple nested backtick escapes appear to double-escape")
print()

print("Recommended fix (per cmd /k best practices):")
print(f"  -ArgumentList \"{recommended}\"")
print("  → cmd.exe receives: /k \"cscript \"...path...\" \"...arg...\"\"")
print()

print("Key difference:")
print("  - Current: /k cscript ... (if path has spaces, cmd splits incorrectly)")
print("  - Recommended: /k \"cscript ...\" (entire command wrapped, cmd /k respects quotes)")
print()

print("Proposed fix assessment:")
print("  - Syntax is convoluted and may not escape correctly in PowerShell")
print("  - The extra backtick escapes don't follow standard PowerShell quoting patterns")
print("  - A simpler, cleaner fix would be the 'recommended' form above")
EOF

Repository: gnh1201/welsonjs

Length of output: 975


🏁 Script executed:

# Verify the proposed syntax would even be valid PowerShell
python3 << 'EOF'
import re

# Count backtick escapes in proposed fix
proposed = r'/k `"cscript `"`"$($app.FullName)`"`" `"`"$fileArg`"`"`"'

# Each `" should become a literal " in the string
# Let's trace through what PowerShell would produce:
backtick_escaped = re.findall(r'`"', proposed)
print(f"Number of `\" sequences in proposed fix: {len(backtick_escaped)}")
print(f"Positions: {[m.start() for m in re.finditer(r'`\"', proposed)]}")
print()
print("This creates a very complex quoting pattern that may be error-prone")
print("and doesn't match standard PowerShell/cmd quoting conventions")
EOF

Repository: gnh1201/welsonjs

Length of output: 306


Correct the cmd.exe /k argument quoting to handle paths with spaces.

The concern about cmd.exe /k quote-stripping is valid when $app.FullName or $fileArg contains spaces. The proper fix wraps the entire command after /k in quotes:

Proposed fix
-        Start-Process "cmd.exe" `
-            -ArgumentList "/k cscript `"$($app.FullName)`" `"$fileArg`""
+        Start-Process "cmd.exe" `
+            -ArgumentList "/k `"cscript `"$($app.FullName)`" `"$fileArg`"`""

Alternatively, Set-Location to the app directory and pass just the file name, or invoke cscript.exe directly via Start-Process without going through cmd.exe.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Start-Process "cmd.exe" `
-ArgumentList "/k cscript `"$($app.FullName)`" `"$fileArg`""
Start-Process "cmd.exe" `
-ArgumentList "/k `"cscript `"$($app.FullName)`" `"$fileArg`"`"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bootstrap.ps1` around lines 103 - 104, The current Start-Process call
invoking cmd.exe with -ArgumentList "/k cscript `"$($app.FullName)`"
`"$fileArg`"" fails for paths with spaces because cmd.exe /k strips inner
quotes; update the invocation so the entire command after /k is wrapped in a
single quoted string (e.g. "/k \"cscript \"<path>\" \"<arg>\"\"") or, better,
avoid cmd.exe entirely by calling Start-Process directly with FilePath
"cscript.exe" and Arguments built from $app.FullName and $fileArg, or change to
Set-Location to the app directory and pass only the file name; target the
Start-Process line that references cmd.exe, $app.FullName and $fileArg.

@gnh1201 gnh1201 merged commit c0f0ddc into master Apr 18, 2026
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant