Added 3 more CLI commands #345
Conversation
|
Warning Review limit reached
Next review available in: 6 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThree new ChangesWorkspace Commands
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sdks/urbackend-cli/src/commands/generate/index.ts`:
- Around line 38-46: The generated TypeScript in parseFields and the top-level
model emission is writing CollectionField.key as a bare property name, which
breaks for keys containing spaces or hyphens. Update the field serialization in
parseFields and the surrounding model loop in generate/index.ts to quote or
otherwise safely emit any non-identifier keys, so urbackend.d.ts stays valid for
names like user-name or display name.
In `@sdks/urbackend-cli/src/commands/init/index.ts`:
- Around line 69-80: The .gitignore update logic in the init command is matching
by substring, so it can miss cases where .ub is not actually ignored. In the
init flow around the .gitignore handling, change the check in the existing file
branch to detect a real ignore entry by line, using the .ub rule itself and not
a broad includes(".ub") substring search. Keep the logic in the same init
command path and preserve the append/write behavior in the .gitignore update
block.
In `@sdks/urbackend-cli/src/commands/pull/index.ts`:
- Around line 36-44: The pull flow in the command handler still leaves deleted
or renamed collection schema files behind, so the local cache can become stale.
Add a cleanup step in the pull path (around the loop in the command’s main
handler, alongside saveSchemaFile) that removes existing .json files from the
schemas directory before writing the current project.collections, using a helper
like clearSchemaFiles to keep only the latest remote schemas.
In `@sdks/urbackend-cli/src/core/workspace.ts`:
- Around line 45-52: The saveSchemaFile() helper is using collectionName
directly as a filename, which allows path traversal outside the schemas
directory. Update saveSchemaFile() (and any caller that passes collectionName)
to validate or sanitize names so only safe basename-style identifiers are
accepted, and reject absolute paths or any value containing path separators/..
segments before constructing the path. Ensure the final resolved file path stays
under getSchemasDir() before calling fs.writeFileSync.
In `@sdks/urbackend-cli/src/index.ts`:
- Around line 101-104: The init command is not declaring its optional positional
argument, so Commander passes trailing command data into initCommand and
projectIdOrName can become an object. Update the program.command("init")
declaration to accept [projectIdOrName] (or explicitly forward that positional)
so initCommand receives the expected string and can safely call toLowerCase().
🪄 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: fd78bc21-ba1c-4327-a50b-1de0b5444581
📒 Files selected for processing (7)
sdks/urbackend-cli/package.jsonsdks/urbackend-cli/src/commands/generate/index.tssdks/urbackend-cli/src/commands/init/index.tssdks/urbackend-cli/src/commands/pull/index.tssdks/urbackend-cli/src/core/workspace.tssdks/urbackend-cli/src/index.tssdks/urbackend-cli/src/types/config.ts
|
@yash-pouranik |
|
looks good |
yes!!! all 3works |
|
@yash-pouranik |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sdks/urbackend-cli/src/core/workspace.ts`:
- Around line 46-48: The new collection name validation in workspace helpers is
happening too late in the pull flow, after `.ub/schemas` has already been
cleared. Update `pullCommand()` to validate all remote collection names up front
before calling `clearSchemaFiles()`, or otherwise stage schema writes and only
replace the local schemas after all `saveSchemaFile()` calls succeed, so a bad
name does not leave the workspace partially emptied.
🪄 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: 12db994a-10fc-4547-b7d3-dbe67f968987
📒 Files selected for processing (6)
sdks/urbackend-cli/package.jsonsdks/urbackend-cli/src/commands/generate/index.tssdks/urbackend-cli/src/commands/init/index.tssdks/urbackend-cli/src/commands/pull/index.tssdks/urbackend-cli/src/core/workspace.tssdks/urbackend-cli/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- sdks/urbackend-cli/src/index.ts
- sdks/urbackend-cli/package.json
- sdks/urbackend-cli/src/commands/pull/index.ts
- sdks/urbackend-cli/src/commands/generate/index.ts
- sdks/urbackend-cli/src/commands/init/index.ts
|
@yash-pouranik |
🚀 Pull Request Description
Added 3 more CLI commands
ub init.ub/) and link it to a specific urBackend projectub pullub generateurbackend.d.tsTypeScript definitions file from local schemasChanged the lint script in
sdks/urbackend-cli/package.jsonfrom"eslint src"to"tsc --noEmit". Change this because the CLI package wasn't configured with@typescript-eslint, which caused ESLint to throw fake syntax errors anytime it saw standard TypeScript keywords likeinterfaceortype.Switching the script to
tsc --noEmitnatively and perfectly validates the type-safety of the entire CLI workspace in our CI/CD pipeline ....🛠️ Type of Change
🧪 Testing & Validation
Backend Verification:
npm testin thebackend/directory and all tests passed.Frontend Verification:
npm run lintin thefrontend/directory.✅ Checklist
Summary by CodeRabbit
New Features
ub init [projectIdOrName],ub pull, andub generateworkspace commands to set up a local workspace, download schemas, and generateurbackend.d.ts..ubdirectory (config + per-collection schema JSON files).Bug Fixes
Chores
0.2.0and switched linting totsc --noEmittype-checking.