Skip to content

fix: check when expression correctly#71

Merged
JounQin merged 1 commit into0.xfrom
fix/template_0.x
Jun 6, 2025
Merged

fix: check when expression correctly#71
JounQin merged 1 commit into0.xfrom
fix/template_0.x

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented Jun 6, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved evaluation of the when expression to handle null or undefined values correctly.
    • Updated OpenAI integration to use the latest stable API endpoint for chat completions parsing.
  • Chores

    • Updated and adjusted various dependency versions.
    • Modified release script to include a specific tagging option.

@JounQin JounQin self-assigned this Jun 6, 2025
Copilot AI review requested due to automatic review settings June 6, 2025 07:18
@JounQin JounQin added the bug Something isn't working label Jun 6, 2025
@changeset-bot
Copy link

changeset-bot bot commented Jun 6, 2025

🦋 Changeset detected

Latest commit: 8c092bc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@alauda/doom Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Jun 6, 2025

Walkthrough

This update modifies the evaluation logic for the when expression in the CLI, ensuring null or undefined are handled correctly. It also updates dependencies in package.json, adjusts the release script, and switches an OpenAI API call from a beta to a stable endpoint.

Changes

Files/Group Change Summary
.changeset/proud-masks-kiss.md Adds a patch note for fixing the when expression evaluation in @alauda/doom.
package.json Updates multiple dependencies, modifies release script to add a tag, and adjusts TypeScript handling.
src/cli/new.ts Refines when expression check to explicitly handle null and undefined.
src/cli/translate.ts Updates OpenAI API usage from beta to stable endpoint for chat completions parsing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant OpenAI API

    User->>CLI: Run translate command
    CLI->>OpenAI API: Call chat.completions.parse (stable)
    OpenAI API-->>CLI: Return parsed completion
    CLI-->>User: Output translation result
Loading

Possibly related PRs

  • fix: boolean value parsing #36: Adjusts boolean value parsing logic in CLI helpers to handle undefined inputs more accurately, similar to the fix for the when expression.
  • fix: check when expression correctly #69: Modifies the same condition in src/cli/new.ts to ensure when is not null or undefined before falsy value comparison, addressing the same issue.

Poem

Hop, hop, a patch is here,
To check for nulls and undefined, never fear!
With dependencies fresh and APIs in line,
The CLI’s logic is now just fine.
A bunny’s delight in every fix—
Clean code and carrots, that’s the mix! 🥕

✨ 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.

Copy link
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 corrects the evaluation of the when expression in the new CLI command, updates the OpenAI chat API call to the non-beta endpoint, and bumps related package versions (including adding a release tag).

  • Switch openai.beta.chat.completions.parse to openai.chat.completions.parse
  • Refine when check to skip only explicit string falsy values
  • Update the release script and bump dependency versions (notably openai, linting tools, and TypeScript placements)

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
src/cli/translate.ts Updated OpenAI API call from beta to stable chat.completions
src/cli/new.ts Added null check before testing string-falsy when values
package.json Added --tag to release, bumped dozens of package versions
.changeset/proud-masks-kiss.md Added changeset note for the when fix
Comments suppressed due to low confidence (1)

package.json:98

  • TypeScript is a build-time tool and should live under devDependencies instead of dependencies to avoid shipping it in production bundles.
+    "typescript": "^5.8.3",

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 6, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@alauda/doom@71

commit: 8c092bc

Copy link

@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: 0

🧹 Nitpick comments (1)
package.json (1)

98-98: Note: TypeScript moved to runtime dependencies.

TypeScript has been moved from devDependencies to dependencies, suggesting it's now required at runtime. Ensure this is intentional and necessary for your use case.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 698cfcb and 8c092bc.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • .changeset/proud-masks-kiss.md (1 hunks)
  • package.json (2 hunks)
  • src/cli/new.ts (1 hunks)
  • src/cli/translate.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/cli/new.ts (1)
src/shared/constants.ts (1)
  • JS_STR_FALSY_VALUES (17-25)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Build and Lint with Node.js 24 on ubuntu-latest
  • GitHub Check: Build and Lint with Node.js 22 on ubuntu-latest
  • GitHub Check: Build and Lint with Node.js 18 on ubuntu-latest
  • GitHub Check: Build and Lint with Node.js 20 on ubuntu-latest
  • GitHub Check: Build and Lint with Node.js 18 on ubuntu-latest
  • GitHub Check: Build and Lint with Node.js 22 on ubuntu-latest
🔇 Additional comments (5)
src/cli/new.ts (1)

224-226: LGTM! Correct handling of null/undefined values.

The explicit null check ensures that when expressions are evaluated correctly. When when is null or undefined, the layout should be processed (not skipped), which this fix properly implements.

.changeset/proud-masks-kiss.md (1)

1-6: LGTM! Proper changeset documentation.

The changeset correctly documents the patch fix and aligns with the code changes made in src/cli/new.ts.

package.json (2)

51-51: LGTM! Release script updated for proper tagging.

The addition of --tag release-0.x to the changeset publish command provides better release management.


79-79:

Details

✅ Verification successful

Verify OpenAI package version and security status.

The upgrade from ^5.0.0-beta.0 to ^5.1.1 aligns with the API change in src/cli/translate.ts. Please verify this version exists and check for any security advisories.


🏁 Script executed:

#!/bin/bash
# Description: Verify OpenAI package version exists and check for security advisories

# Check latest version on npm
npm view openai version

# Check for known vulnerabilities
npm audit --audit-level moderate --package-lock-only openai

Length of output: 442


🏁 Script executed:

#!/bin/bash
set -e

# Create a minimal lockfile for the OpenAI package
npm install openai@5.1.1 --package-lock-only

# Run an audit at moderate level and output JSON
npm audit --audit-level moderate --json

Length of output: 2973


OpenAI v5.1.1 confirmed – no advisories found

  • npm view openai version returned 5.1.1, matching the upgrade.
  • npm audit shows no vulnerabilities for the OpenAI package itself (all reported issues are in unrelated deps).
src/cli/translate.ts (1)

154-154: LGTM! Correct API endpoint update.

The change from openai.beta.chat.completions.parse to openai.chat.completions.parse properly aligns with the OpenAI package upgrade from beta (^5.0.0-beta.0) to stable (^5.1.1) version in package.json.

@JounQin JounQin merged commit b345b55 into 0.x Jun 6, 2025
16 checks passed
@JounQin JounQin deleted the fix/template_0.x branch June 6, 2025 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants