Skip to content

feature/init-cli into feature/graphql-sub 🧊 rebuild init cli#274

Open
debabin wants to merge 2 commits into
feature/grapql-subfrom
feature/init-cli
Open

feature/init-cli into feature/graphql-sub 🧊 rebuild init cli#274
debabin wants to merge 2 commits into
feature/grapql-subfrom
feature/init-cli

Conversation

@debabin

@debabin debabin commented Apr 5, 2026

Copy link
Copy Markdown
Member

No description provided.

@coderabbitai

coderabbitai Bot commented Apr 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8a2a8437-15d9-40d9-aed5-4a0aac3b211d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/init-cli

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.

@greptile-apps

greptile-apps Bot commented Apr 5, 2026

Copy link
Copy Markdown

Greptile Summary

This PR rebuilds the init CLI command, replacing the old multi-file mock-requests/ directory approach with self-contained single-file config templates using the new sugar-style API (mock, rest, graphql, ws). It adds three new template presets (REST playground, GraphQL playground, and WebSocket), updates the default port from 31299 to 7777, and aligns documentation accordingly.

Key changes:

  • New template presets: rest-playground, graphql-playground, ws (in addition to existing rest, graphql, full)
  • createTemplate no longer copies a mock-requests/ directory — all config is now self-contained in one file
  • Default port changed from 312997777 across code, templates, and docs
  • JS GraphQL templates contain a copy-paste bug using the wrong parameter accessor for variable extraction
  • The CLI docs are missing two of the six interactive flow options (REST playground and GraphQL playground)

Confidence Score: 3/5

Not safe to merge as-is — two JS GraphQL templates contain a runtime bug that breaks GetUser for all JS users choosing GraphQL or Full API presets.

The TS templates and CLI logic are well-implemented, but the JS graphql and JS full templates both use params.request.params.id inside a GraphQL handler (a copy-paste from REST logic), causing GetUser to always return 404. These are user-facing generated files, so the bug would be immediately apparent to every JS user who runs the generated code. The docs are also incomplete regarding the new playground options.

packages/server/bin/templates/js/graphql/mock-server.config.js and packages/server/bin/templates/js/full/mock-server.config.js require fixes before merging.

Important Files Changed

Filename Overview
packages/server/bin/templates/js/graphql/mock-server.config.js GetUser GraphQL query uses params.request.params.id (REST pattern) — will always 404; TS counterpart correctly uses params.request.body.variables.id
packages/server/bin/templates/js/full/mock-server.config.js GetUser GraphQL query has the same wrong params accessor; also diverges from the TS full template which omits GetUser entirely
packages/server/bin/init.ts Expands API type choices from 3 to 6 presets and updates default port to 7777
packages/server/bin/helpers/createTemplate.ts Removes mock-requests directory copy; now generates a single self-contained config file; apiType union expanded to 6 values
packages/docs/content/docs/cli.mdx Interactive flow example and option list are missing REST playground and GraphQL playground
packages/server/src/utils/constants/default.ts Default port updated from 31299 to 7777
packages/server/bin/templates/ts/full/mock-server.config.ts New self-contained Full API template combining REST, GraphQL, and WebSocket correctly
packages/server/bin/templates/ts/rest-playground/mock-server.config.ts New REST playground template with complete CRUD operations
packages/server/bin/templates/ts/graphql-playground/mock-server.config.ts New GraphQL playground template with CRUD mutations using correct body.variables accessor
packages/server/bin/templates/ts/ws/mock-server.config.ts New WebSocket template, clean and correct with dynamic ISO timestamp
packages/server/bin/templates/js/ws/mock-server.config.js WebSocket template uses static message string while TS counterpart uses a dynamic ISO timestamp

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([mcs init]) --> B{Would you like\nto use TypeScript?}
    B -->|Yes| C[TS templates]
    B -->|No| D[JS templates]
    C --> E{Choose API type}
    D --> E
    E --> F[rest]
    E --> G[rest-playground]
    E --> H[graphql]
    E --> I[graphql-playground]
    E --> J[ws]
    E --> K[full]
    F & G & H & I & J & K --> L[Prompt: baseUrl · port · staticPath]
    L --> M[createTemplate]
    M --> N[Read template mock-server.config file]
    N --> O[Replace port / baseUrl / staticPath tokens]
    O --> P([Write mock-server.config.ts/js])
    style H fill:#f88,stroke:#c00
    style I fill:#ffd,stroke:#aa0
    style D fill:#f88,stroke:#c00
Loading

Comments Outside Diff (1)

  1. packages/docs/content/docs/cli.mdx, line 58-71 (link)

    P1 Interactive flow example is missing two options

    The documented interactive flow shows only 4 API type choices, but packages/server/bin/init.ts actually presents 6. The REST playground and GraphQL playground options are entirely absent from both the code block and the explanatory bullet point.

    Current code block:

    ❯ REST
      GraphQL
      WebSocket
      Full API
    

    Actual choices in init.ts:

    ❯ REST
      REST playground
      GraphQL
      GraphQL playground
      WebSocket
      Full API
    

    The bullet on line 71 also needs updating from:

    Options: REST, GraphQL, WebSocket, or Full API (REST, GraphQL, and WebSocket).

    to include REST playground and GraphQL playground.

Reviews (1): Last reviewed commit: "feature/init-cli 🧊 rebuild init cli" | Re-trigger Greptile

Comment thread packages/server/bin/templates/js/graphql/mock-server.config.js
Comment thread packages/server/bin/templates/js/full/mock-server.config.js
Comment thread packages/server/bin/templates/js/ws/mock-server.config.js Outdated
@debabin debabin changed the title feature/init-cli 🧊 rebuild init cli feature/init-cli into feature/graphql-sub 🧊 rebuild init cli Apr 5, 2026
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