Skip to content

refactor: unify duplicate selectAppInteractively implementations - #10844

Merged
joehan merged 3 commits into
mainfrom
refactor-select-app-interactively
Jul 27, 2026
Merged

refactor: unify duplicate selectAppInteractively implementations#10844
joehan merged 3 commits into
mainfrom
refactor-select-app-interactively

Conversation

@joehan

@joehan joehan commented Jul 24, 2026

Copy link
Copy Markdown
Member

Description

Consolidates the three duplicate implementations of selectAppInteractively found in src/commands/apps-sdkconfig.ts, src/init/features/ailogic/index.ts, and src/management/apps.ts into a single, public, type-safe implementation exported from src/management/apps.ts.

Key Changes:

  • Replaced the private implementations in src/commands/apps-sdkconfig.ts and src/init/features/ailogic/index.ts with the exported function from src/management/apps.ts.
  • Removed unused imports and duplicate helper functions like checkForApps.
  • Added unit tests for selectAppInteractively covering empty checks, choice formatting, and custom message options.
  • Adjusted unit tests in src/init/features/ailogic/index.spec.ts to expect the new general project app check error message.

Scenarios Tested

  • Ran mocha tests on app management (src/management/apps.spec.ts) and AI logic (src/init/features/ailogic/index.spec.ts).
  • Ran complete CLI fast test suite with 4685 unit tests.
  • Linted modified files to ensure strict TypeScript checks and formatting guidelines.

Sample Commands

npx mocha src/management/apps.spec.ts
npx mocha src/init/features/ailogic/index.spec.ts

### Description
Consolidates the three duplicate implementations of `selectAppInteractively` found in `src/commands/apps-sdkconfig.ts`, `src/init/features/ailogic/index.ts`, and `src/management/apps.ts` into a single, public, type-safe implementation exported from `src/management/apps.ts`.

Key Changes:
- Replaced the private implementations in `src/commands/apps-sdkconfig.ts` and `src/init/features/ailogic/index.ts` with the exported function from `src/management/apps.ts`.
- Removed unused imports and duplicate helper functions like `checkForApps`.
- Added unit tests for `selectAppInteractively` covering empty checks, choice formatting, and custom message options.
- Adjusted unit tests in `src/init/features/ailogic/index.spec.ts` to expect the new general project app check error message.

### Scenarios Tested
- Ran mocha tests on app management (`src/management/apps.spec.ts`) and AI logic (`src/init/features/ailogic/index.spec.ts`).
- Ran complete CLI fast test suite with 4685 unit tests.
- Linted modified files to ensure strict TypeScript checks and formatting guidelines.

### Sample Commands
`npx mocha src/management/apps.spec.ts`
`npx mocha src/init/features/ailogic/index.spec.ts`

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request consolidates the interactive app selection logic by moving selectAppInteractively and checkForApps to a shared utility in src/management/apps.ts, reducing duplication across commands and initialization features. It also adds corresponding unit tests. The feedback highlights several empty JSDoc blocks added to exported functions in src/management/apps.ts that should either be removed or populated with meaningful descriptions.

Comment thread src/management/apps.ts Outdated
Comment on lines +46 to +48
/**
*
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Several empty JSDoc blocks have been added to exported functions in this file. These empty comments do not provide any useful documentation and add unnecessary noise to the codebase.

Please either remove them or populate them with meaningful descriptions of the functions.

Other occurrences in this file:

  • Lines 170-172 (sdkInit)
  • Lines 190-192 (getSdkOutputPath)
  • Lines 210-212 (checkForApps)
  • Lines 262-264 (getSdkConfig)
  • Lines 631-633 (writeConfigToFile)
  • Lines 778-780 (findIntelligentPathForIOS)
  • Lines 811-813 (findIntelligentPathForAndroid)
Suggested change
/**
*
*/
/**
* Detects the app platform based on the directory contents, prompting the user if needed.
*/

Comment thread src/management/apps.ts Outdated
displayName: string;
}

/**

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these empty comment blocks. Applies throughout the file

@joehan
joehan enabled auto-merge (squash) July 27, 2026 17:06
@joehan
joehan merged commit f673106 into main Jul 27, 2026
79 of 80 checks passed
@joehan
joehan deleted the refactor-select-app-interactively branch July 27, 2026 18:33
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.

3 participants