Skip to content

feat: add non-interactive mode #831

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

Merged
merged 1 commit into from
May 3, 2025
Merged

feat: add non-interactive mode #831

merged 1 commit into from
May 3, 2025

Conversation

satya164
Copy link
Member

@satya164 satya164 commented May 3, 2025

this adds --interactive and --non-interactive arguments.
it is automatically disabled on non-interactive terminals and CI

@satya164 satya164 requested a review from Copilot May 3, 2025 16:38
Copy link

@Copilot 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 adds support for non‑interactive mode by introducing the --interactive/--non‑interactive arguments and adjusting the CLI flow accordingly. Key changes include updating the prompt function to handle non‑interactive behavior, modifying input argument definitions to expose the interactive flag, and unifying the post‑generation commit/next‑steps logic.

Reviewed Changes

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

Show a summary per file
File Description
packages/create-react-native-library/src/utils/prompt.ts Enhanced prompt function to include an interactive flag and improved dynamic question handling
packages/create-react-native-library/src/utils/local.ts Removed the promptLocalLibrary function as local handling is now integrated
packages/create-react-native-library/src/utils/assert.ts Removed redundant input assertion logic
packages/create-react-native-library/src/template.ts Minor formatting adjustments
packages/create-react-native-library/src/input.ts Added the interactive flag to accepted arguments and integrated it within question creation
packages/create-react-native-library/src/inform.ts Updated error help messaging with modified color usage
packages/create-react-native-library/src/index.ts Revised the create flow to use the new interactive flag and a unified commit/next‑steps process
Comments suppressed due to low confidence (5)

packages/create-react-native-library/src/utils/prompt.ts:38

  • [nitpick] Consider adding a comment here to explain the logic used for determining interactive mode for future maintainers.
const interactive = options?.interactive ?? Boolean(process.stdout.isTTY && process.env.TERM !== 'dumb' && !process.env.CI);

packages/create-react-native-library/src/utils/prompt.ts:90

  • [nitpick] Consider explicitly typing the parameters of the dynamic 'type' function to improve type safety and enhance clarity.
promptQuestion = { ...question, type: (prev, values) => { ... } };

packages/create-react-native-library/src/input.ts:138

  • [nitpick] Ensure the default 'interactive' value is fully aligned with the interactive mode detection logic in the prompt function to avoid any behavioral inconsistencies.
interactive: { description: 'Whether to run in interactive mode', type: 'boolean', default: true, },

packages/create-react-native-library/src/inform.ts:92

  • [nitpick] Consider restoring color formatting (or documenting the change) for error messages to maintain consistency with other CLI outputs.
console.log(message);

packages/create-react-native-library/src/index.ts:143

  • Review the updated commit and next‑steps flow to ensure that unifying post‑generation steps for both local and non‑local libraries is intentional, as this represents a change from the previous separate handling.
if (answers.local) { ... }

@satya164 satya164 force-pushed the @satya164/non-interactive branch 5 times, most recently from 50cb60c to 85ac3d3 Compare May 3, 2025 17:21
@satya164 satya164 requested a review from Copilot May 3, 2025 17:21
Copy link

@Copilot 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 introduces a non-interactive mode and improves prompt handling for both interactive and CI environments. Key changes include updating the prompt utility for enhanced type-safety and default value handling, refactoring CLI input question logic, and removing the legacy prompt for local libraries.

Reviewed Changes

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

Show a summary per file
File Description
packages/create-react-native-library/src/utils/prompt.ts Enhanced type definitions and non-interactive mode handling in prompt logic
packages/create-react-native-library/src/utils/local.ts Removed legacy prompt logic for local libraries
packages/create-react-native-library/src/utils/assert.ts Removed unused assertUserInput helper
packages/create-react-native-library/src/template.ts Minor update to accommodate local library flag
packages/create-react-native-library/src/input.ts Adjusted question definitions and added the interactive flag
packages/create-react-native-library/src/inform.ts Modified error message formatting in printErrorHelp
packages/create-react-native-library/src/index.ts Updated CLI flow to use the new prompt API and revised local library handling
Comments suppressed due to low confidence (2)

packages/create-react-native-library/src/index.ts:144

  • [nitpick] Non-local libraries no longer trigger an initial git commit, as the previous branch calling createInitialGitCommit has been removed. Please confirm that this behavioral change is intended; if not, consider restoring the initial commit for non-local library creation.
if (answers.local) {

packages/create-react-native-library/src/input.ts:267

  • [nitpick] This change now passes the authorEmail to githubUsername instead of the previous value. Please verify that githubUsername is designed to handle email addresses, or update its implementation and/or naming accordingly.
const username = await githubUsername(answers.authorEmail);

@satya164 satya164 force-pushed the @satya164/non-interactive branch from 85ac3d3 to 6c7ce34 Compare May 3, 2025 17:29
this adds `--interactive` and `--non-interactive` arguments.
it is automatically disabled on non-interactive terminals and CI
@satya164 satya164 force-pushed the @satya164/non-interactive branch from 6c7ce34 to 62b7e39 Compare May 3, 2025 17:51
@satya164 satya164 merged commit 5b07097 into main May 3, 2025
7 of 8 checks passed
@satya164 satya164 deleted the @satya164/non-interactive branch May 3, 2025 17:53
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