Skip to content

Comments

Improve Standalone Scripts#116

Merged
iamEvanYT merged 4 commits intomainfrom
evan/improve-standalone-scripts
Jun 11, 2025
Merged

Improve Standalone Scripts#116
iamEvanYT merged 4 commits intomainfrom
evan/improve-standalone-scripts

Conversation

@iamEvanYT
Copy link
Member

@iamEvanYT iamEvanYT commented Jun 10, 2025

Summary by CodeRabbit

  • New Features

    • Added scripts and type definitions to support automated upgrades to the latest Electron versions within the current and next major releases.
    • Introduced comprehensive TypeScript type definitions for both package.json and Bun's bun.lock files.
    • Added a dedicated TypeScript configuration for scripts to improve type checking and module resolution.
  • Refactor

    • Replaced and renamed Electron upgrade scripts for clearer version targeting and improved maintainability.
    • Enhanced scripts to preserve formatting when updating JSON files and improved error handling.
    • Consolidated version-fetching functions for Electron releases into a single generalized method.
    • Improved parsing and update logic for Electron versions in project files with better error handling and modularization.
  • Chores

    • Updated workflow automation and npm scripts to align with new Electron upgrade logic and naming conventions.
    • Added and updated TypeScript project references to include scripts.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 10, 2025

Walkthrough

The update restructures the Electron upgrade automation scripts and workflows. It renames and refactors scripts and workflow jobs to use "current" and "next" major version terminology instead of "stable" and "beta." Type definitions for package.json and bun.lock are added, and JSON handling is improved with the jju library. The Electron upgrade logic is modularized and expanded.

Changes

File(s) Change Summary
.github/workflows/electron-updater.yml, package.json Workflow jobs and npm scripts renamed from "stable/beta" to "current/next" major; command and pattern updates.
scripts/electron-upgrader/beta.ts, scripts/electron-upgrader/stable.ts Deleted old scripts for upgrading to "beta" and "stable" Electron versions.
scripts/electron-upgrader/current.ts, scripts/electron-upgrader/next.ts Added new scripts for upgrading to "current" and "next" major Electron versions.
scripts/electron-upgrader/_modules/github.ts Refactored to generalize version-finding logic; renamed and replaced functions for new versioning scheme.
scripts/electron-upgrader/_modules/updater.ts Added type annotations; introduced function to increment updater version configuration.
scripts/_types/package-json.ts, scripts/_types/bun-lock.ts Added comprehensive TypeScript type definitions for package.json and bun.lock.
scripts/use-stock-electron.ts Refactored with modular functions, robust error handling, and jju for JSON parsing/updating.
scripts/temp-change-name/module.ts Switched to jju for JSON parsing/updating to preserve formatting.
tsconfig.json, tsconfig.scripts.json Added new TypeScript project reference and configuration for scripts.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Workflow
    participant Script
    participant GitHubAPI
    participant FS as FileSystem

    User->>Workflow: Trigger Electron upgrade job (current/next)
    Workflow->>Script: Run upgrade script (current.ts/next.ts)
    Script->>GitHubAPI: Fetch latest Electron version (current/next major)
    GitHubAPI-->>Script: Return version tag
    Script->>GitHubAPI: Fetch commit hash for version
    GitHubAPI-->>Script: Return commit hash
    Script->>FS: Update package.json with new version
    Script->>FS: Update bun.lock with new version and commit hash
    alt Next major upgrade
        Script->>FS: Increment updater version configuration
    end
    Script-->>Workflow: Log success and exit
Loading

Possibly related PRs

  • Automatical Electron Upgrader #110: Refactors and renames Electron upgrade workflow and scripts to use "current" and "next" major versions instead of "stable" and "beta," consolidates version-fetching functions, and adds a version increment function; this PR is a direct evolution of the original Electron upgrade automation.

Suggested labels

enhancement

Poem

🐰
A hop, a skip, a version jump,
Scripts renamed and workflows pump.
"Current" and "Next" now lead the way,
With types to keep the bugs at bay.
JSON's neat, thanks to jju's might—
The toolkit's future's looking bright!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e2baea5 and ac52930.

📒 Files selected for processing (2)
  • .github/workflows/electron-updater.yml (5 hunks)
  • scripts/temp-change-name/module.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • scripts/temp-change-name/module.ts
  • .github/workflows/electron-updater.yml
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (macos-13)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-24.04-arm)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 10, 2025

Build artifacts for all platforms are ready! 🚀

Download the artifacts from:

(execution 15585963298 / attempt 1)

Copy link
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: 7

♻️ Duplicate comments (1)
scripts/electron-upgrader/next.ts (1)

1-16: Same tag-SHA issue as in current.ts

The script inherits the tag-vs-commit SHA confusion. See earlier comment.

🧹 Nitpick comments (5)
scripts/temp-change-name/module.ts (1)

20-22: Hard-coded backup path is inconsistent with backupPath constant

writeFileSync("package.json.old", …) bypasses the backupPath you already declared, risking divergent behaviour on Windows vs *nix paths or when rootDir changes.
Use the constant for both read & write.

-writeFileSync("package.json.old", packageJSONString);
+writeFileSync(backupPath, packageJSONString);
scripts/electron-upgrader/_modules/updater.ts (1)

63-71: Silent parse failure obscures root cause

The catch block logs and re-throws the original error, but without augmenting the stack trace with file path/context.
Add the path to the thrown error or wrap in Error with cause so callers can act on it.

.github/workflows/electron-updater.yml (1)

37-46: Grepping console output is brittle

Parsing the version via grep … | sed … breaks if log colouring or wording changes.
Prefer emitting a dedicated machine-readable line, e.g. ::set-output name=version::${latestVersion}, or echoing a JSON blob to stdout and using jq.

scripts/use-stock-electron.ts (2)

58-77: Use optional chaining for cleaner code

Consider using optional chaining as suggested by static analysis.

-  if (packageJson.devDependencies && packageJson.devDependencies.electron) {
+  if (packageJson.devDependencies?.electron) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 66-66: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


100-102: Simplify null checks with optional chaining

Use optional chaining for cleaner code.

-  if (bunLock.workspaces && bunLock.workspaces[""] && bunLock.workspaces[""].devDependencies) {
+  if (bunLock.workspaces?.[""]?.devDependencies) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 100-100: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc7e692 and e2baea5.

📒 Files selected for processing (14)
  • .github/workflows/electron-updater.yml (5 hunks)
  • package.json (1 hunks)
  • scripts/_types/bun-lock.ts (1 hunks)
  • scripts/_types/package-json.ts (1 hunks)
  • scripts/electron-upgrader/_modules/github.ts (2 hunks)
  • scripts/electron-upgrader/_modules/updater.ts (4 hunks)
  • scripts/electron-upgrader/beta.ts (0 hunks)
  • scripts/electron-upgrader/current.ts (1 hunks)
  • scripts/electron-upgrader/next.ts (1 hunks)
  • scripts/electron-upgrader/stable.ts (0 hunks)
  • scripts/temp-change-name/module.ts (2 hunks)
  • scripts/use-stock-electron.ts (1 hunks)
  • tsconfig.json (1 hunks)
  • tsconfig.scripts.json (1 hunks)
💤 Files with no reviewable changes (2)
  • scripts/electron-upgrader/beta.ts
  • scripts/electron-upgrader/stable.ts
🧰 Additional context used
🧬 Code Graph Analysis (4)
scripts/electron-upgrader/_modules/updater.ts (2)
scripts/_types/package-json.ts (1)
  • PackageJson (439-580)
scripts/_types/bun-lock.ts (1)
  • BunLock (73-86)
scripts/electron-upgrader/current.ts (2)
scripts/electron-upgrader/_modules/github.ts (2)
  • findLatestCurrentMajorVersion (134-136)
  • getCommitHashForTag (152-174)
scripts/electron-upgrader/_modules/updater.ts (2)
  • updatePackageJson (20-39)
  • updateBunLock (56-94)
scripts/electron-upgrader/next.ts (2)
scripts/electron-upgrader/_modules/github.ts (2)
  • findLatestNextMajorVersion (138-140)
  • getCommitHashForTag (152-174)
scripts/electron-upgrader/_modules/updater.ts (3)
  • updatePackageJson (20-39)
  • updateBunLock (56-94)
  • incrementElectronUpdaterVersionConfiguration (99-133)
scripts/use-stock-electron.ts (2)
scripts/electron-upgrader/_modules/updater.ts (2)
  • updatePackageJson (20-39)
  • updateBunLock (56-94)
scripts/_types/bun-lock.ts (1)
  • BunLock (73-86)
🪛 Biome (1.9.4)
scripts/use-stock-electron.ts

[error] 66-66: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 100-100: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 105-105: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: build (macos-13)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (ubuntu-24.04-arm)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (30)
tsconfig.scripts.json (1)

1-13: tsconfig.scripts.json setup looks correct.

The configuration properly extends the Electron node base, includes script files, enables composite builds, uses bundler resolution, and defines the @/* path alias for the scripts directory.

scripts/_types/bun-lock.ts (7)

1-5: File header and documentation link are clear.
The top‐level comments accurately reference the Bun lockfile schema.


10-25: BunLockFileBasePackageInfo is comprehensive.
Optional dependency maps and binary fields cover expected lockfile metadata.


30-35: Workspace package interface extends base correctly.
The optional name and version fields align with Bun workspace entries.


40-47: Detailed package info interface is well defined.
OS, CPU, and bundling flags are correctly modelled as optional properties.


52-57: Root package bin interface covers expected fields.
Binary mappings and directory definitions are accurate for root packages.


63-69: Union type BunLockFilePackageArray correctly represents all entry variants.
Each tuple variant is documented and matches Bun’s lockfile formats.


73-86: Top‐level BunLock interface is complete.
Lockfile version, workspace packages, overrides, and trusted dependencies are all represented.

scripts/_types/package-json.ts (11)

1-8: File header and ESLint disable are appropriate.
Disabling no-explicit-any is reasonable for this exhaustive schema.


12-28: Person and dependency type definitions cover all schema cases.
String and object forms for contributors and the dependency Records are correctly typed.


55-78: SPDX License union is exhaustive.
Common license identifiers are included; custom strings are allowed via the fallback.


83-116: PackageExportsEntry and PackageImportsEntry types align with Node’s conditional exports/imports.
The nested fallback arrays and object shapes follow the official spec.


159-180: Funding and DevEngineDependency are well-typed.
URL/string union for funding and structured engine dependency controls are covered.


185-248: Scripts interface covers the full npm lifecycle.
All standard pre/post hooks and custom script entries are defined.


253-312: Directories, Repository, Funding, and Workspaces types are accurate.
These align with the package.json schema and support both shorthand and object forms.


316-346: PublishConfig, Dist, and ESNext types are correct.
They match npm’s publish and distribution metadata conventions.


362-420: PnpmConfig interface is comprehensive.
Overrides, peer rules, patch configs, and execution environment options are all modelled.


426-434: StackBlitzConfig covers key playground settings.
Install and compile trigger options are clearly typed.


439-580: Main PackageJson interface is exhaustive and matches the JSON schema.
All standard fields, deprecated aliases, and custom _-prefixed properties are supported.

tsconfig.json (1)

3-3: Reference to tsconfig.scripts.json added.
This integrates the new scripts config into the composite project.

package.json (1)

29-30: Upgrade scripts renamed to current/next.
Ensure the new current.ts and next.ts files exist and update any documentation or README accordingly.

scripts/electron-upgrader/_modules/github.ts (3)

1-5: LGTM! Clear and consistent renaming

The renaming from "stable/beta" to "current/next" major version terminology provides clearer semantics about what these constants represent.


95-132: Excellent refactoring to reduce code duplication

The generalized function with configurable major version and prerelease handling eliminates code duplication while maintaining flexibility. The sorting logic correctly prioritizes non-prereleases over prereleases.


134-140: Clean wrapper functions maintain API compatibility

These wrapper functions provide a clean interface while leveraging the generalized implementation underneath.

scripts/use-stock-electron.ts (6)

2-5: LGTM! Clean imports with proper typing

Good use of namespace imports and type imports for better organization.


17-31: Well-designed version extraction with multiple format support

The function handles both castlabs fork format and standard npm version formats effectively.


36-53: Good error handling with clear error messages

The function provides clear error messages for missing dependencies and parsing failures.


105-110: Clarify the array manipulation logic

The code modifies the electron entry array structure but the purpose is unclear.

Why is splice(1, 0, "") needed at line 108? This inserts an empty string at index 1, changing the array structure. Please verify this is the intended behavior for the standard npm electron package format in bun.lock.

🧰 Tools
🪛 Biome (1.9.4)

[error] 105-105: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


124-137: Clean argument parsing implementation

Simple and effective command-line argument parsing.


140-176: Excellent user experience with clear feedback

The main function provides comprehensive feedback throughout the process and helpful usage instructions.

@iamEvanYT iamEvanYT merged commit 1685a03 into main Jun 11, 2025
10 checks passed
@iamEvanYT iamEvanYT deleted the evan/improve-standalone-scripts branch June 11, 2025 13:48
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