-
Notifications
You must be signed in to change notification settings - Fork 48
feat: npm scripts for beta builds #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces a beta build configuration system for the Electron application. It adds two new environment variables (IS_BETA_BUILD and PREVIEW_URL) to the webpack production config, implements new npm scripts (build:beta, build:main:beta, package:beta) to orchestrate beta builds with proper environment variables, and refactors the main build script to use a separate cleanup step. The main.ts file is updated with a DESKTOP_APP_URL constant that conditionally selects the application URL based on the IS_BETA_BUILD flag, supporting development, beta, and production environments. The release app version is bumped from 26.1.6 to 26.1.10. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @package.json:
- Line 13: The npm script "build:main:beta" uses Unix-style "$PREVIEW_URL"
expansion which fails on Windows; update that script so PREVIEW_URL is set via
cross-env (e.g., include PREVIEW_URL=%PREVIEW_URL% via cross-env or use
cross-env-shell to allow shell expansion) or remove inline expansion and rely on
the environment/webpack EnvironmentPlugin to read PREVIEW_URL at runtime; modify
the "build:main:beta" entry so both IS_BETA_BUILD and PREVIEW_URL are provided
through cross-env (or switch to cross-env-shell) to ensure consistent behavior
across platforms.
🧹 Nitpick comments (1)
src/main/main.ts (1)
71-75: Consider refactoring nested ternary for improved readability.The logic is correct, but the nested ternary can be difficult to parse at a glance. A helper function or early-return pattern would make the URL resolution clearer.
♻️ Suggested refactor
-const DESKTOP_APP_URL = isDevelopment ? 'http://localhost:3000' : - process.env.IS_BETA_BUILD == "true" ? - process.env.PREVIEW_URL ? process.env.PREVIEW_URL : "https://beta.requestly.io" : - "https://app.requestly.io" +const getDesktopAppUrl = (): string => { + if (isDevelopment) { + return 'http://localhost:3000'; + } + if (process.env.IS_BETA_BUILD === 'true') { + return process.env.PREVIEW_URL || 'https://beta.requestly.io'; + } + return 'https://app.requestly.io'; +}; + +const DESKTOP_APP_URL = getDesktopAppUrl();Also, prefer
===over==for string comparison consistency.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
release/app/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
.erb/configs/webpack.config.main.prod.tspackage.jsonrelease/app/package.jsonsrc/main/main.ts
🔇 Additional comments (4)
release/app/package.json (1)
4-4: LGTM!Version bump to 26.1.10 aligns with the beta build feature additions.
.erb/configs/webpack.config.main.prod.ts (1)
66-73: LGTM!The
EnvironmentPlugindefaults are correctly configured. Thefalsedefault forIS_BETA_BUILDensures production builds targetapp.requestly.io, while the empty string forPREVIEW_URLcorrectly falls back tobeta.requestly.iowhen beta builds don't specify a custom URL.package.json (2)
9-11: LGTM!Good refactoring to extract
cleanupinto a dedicated script. This improves maintainability and ensures consistent cleanup behavior across both standard and beta builds.
18-18: LGTM!The
package:betascript correctly chains the beta build with electron-builder using--publish never.
| "build": "npm run cleanup && concurrently \"npm run build:main\" \"npm run build:renderer\"", | ||
| "build:beta": "npm run cleanup && concurrently \"npm run build:main:beta\" \"npm run build:renderer\"", | ||
| "build:main": "cross-env NODE_ENV=production TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.main.prod.ts", | ||
| "build:main:beta": "cross-env IS_BETA_BUILD=true PREVIEW_URL=$PREVIEW_URL npm run build:main", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$PREVIEW_URL expansion may fail on Windows.
The $PREVIEW_URL shell variable expansion relies on a Unix-like shell. On Windows (cmd.exe), this won't expand correctly—the literal string $PREVIEW_URL will be passed instead.
Consider using cross-env consistently for both variables, or document that this script requires a Unix-like shell (Git Bash, WSL, etc.) on Windows.
🔧 Suggested fix using cross-env-shell
- "build:main:beta": "cross-env IS_BETA_BUILD=true PREVIEW_URL=$PREVIEW_URL npm run build:main",
+ "build:main:beta": "cross-env-shell IS_BETA_BUILD=true PREVIEW_URL=$PREVIEW_URL npm run build:main",Alternatively, if PREVIEW_URL is always optional and typically unset:
- "build:main:beta": "cross-env IS_BETA_BUILD=true PREVIEW_URL=$PREVIEW_URL npm run build:main",
+ "build:main:beta": "cross-env IS_BETA_BUILD=true npm run build:main",This relies on webpack's EnvironmentPlugin to pick up PREVIEW_URL directly from the environment if set.
📝 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.
| "build:main:beta": "cross-env IS_BETA_BUILD=true PREVIEW_URL=$PREVIEW_URL npm run build:main", | |
| "build:main:beta": "cross-env-shell IS_BETA_BUILD=true PREVIEW_URL=$PREVIEW_URL npm run build:main", |
🤖 Prompt for AI Agents
In @package.json at line 13, The npm script "build:main:beta" uses Unix-style
"$PREVIEW_URL" expansion which fails on Windows; update that script so
PREVIEW_URL is set via cross-env (e.g., include PREVIEW_URL=%PREVIEW_URL% via
cross-env or use cross-env-shell to allow shell expansion) or remove inline
expansion and rely on the environment/webpack EnvironmentPlugin to read
PREVIEW_URL at runtime; modify the "build:main:beta" entry so both IS_BETA_BUILD
and PREVIEW_URL are provided through cross-env (or switch to cross-env-shell) to
ensure consistent behavior across platforms.
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.