refactor: extract duplicated prompt, JSON, file-write, and exec patterns into shared utils - #2
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description of Changes
Four patterns were copy-pasted across commands/plugins/utils; each is now a single utility. Net -105 lines, no behavior change other than error output now going through the logger (
✖ Error: ...) instead of rawconsole.error.utils/inquirer/prompts.ts— three duplicated inquirer shapes:selectOption({ message, options, name, invalidMessage })replaces the identical list-prompt +options.find(o => o.name === answers[name])+ invalid-selection error indeploy.ts,auth.ts,database.ts.confirmPrompt(message, { default, prefix })replaces four hand-rolledtype: 'confirm'prompts (ask-open-page.ts,check-git.ts, and two inkinde.ts).promptRequiredInput({ message, emptyMessage, password })replaces the two non-empty-validator prompts inmongoose.ts.deploy.tsandinit.tsalso drop their.then().catch()promise chains forasync/await+ a single try/catch, matchingauth.ts/database.ts.utils/fs/json-file.ts—readJsonFile<T>/writeJsonFilereplace read+parse+JSON.stringify(x, null, 2)+write blocks ininstall-plugins.ts,prettier.ts,read-config-file.ts,init.ts.utils/fs/write-project-file.ts—writeProjectFile(relativePath, content, { projectPath, mode })replacesfs.writeFileSync(path.join(process.cwd() | projectPath, ...), content, { encoding: 'utf8' })ineslint.ts,prettier.ts,jest.ts,husky.ts,init.ts,selectGitHubTemplate.ts. Itmkdir -ps the parent, which subsumes husky's manual.huskydir creation.utils/exec.ts—runCommand(cmd, options)(defaultsstdio: 'inherit') replaces the privaterunCmdinpackage-manager.tsand the scatteredexecSync(cmd, { stdio: 'inherit' })calls ininit.ts,husky.ts,setup-git-repo.ts.logFailure(text, error)inutils/logger.tsreplaces ~8console.error('Failed to X:', error)sites so CLI errors are formatted consistently._template/andCOMMAND_TEMPLATE/are intentionally untouched — they are standalone scaffolding examples.Verified with
npx tsc --noEmit,npm run lint src,npm run build.Related Issues
None
Link to Devin session: https://app.devin.ai/sessions/00fcd088d0e545abb8332fc70ef5bb93
Requested by: @lox-bot