[refactor] Remove inquirer from core; expose create question metadata instead - #107
Merged
Conversation
… instead
ManagerLocal.create() imported and drove `inquirer` directly, pulling
an interactive-CLI/UX dependency into an isomorphic browser/server
library - any consumer embedding ManagerLocal for programmatic
install/uninstall pulled in inquirer transitively even though they'd
never call create(). Interactive prompting belongs in the CLI that
uses this package, not the package itself.
Replace create() with:
- helpers/createQuestions.ts: createPackageQuestions() (org/package/
version) and createPackageVersionQuestions(type, org, pkg) (the rest
- name/author/license/type/tags/url/etc, with type-appropriate
choices and org+pkg-derived url/audio/image defaults), returning a
library-agnostic question shape (name/type/message/default/choices/
validate/filter) rather than importing inquirer's own types.
- ManagerLocal.createQuestions()/createVersionQuestions(org, pkg): thin
delegating instance methods, so a CLI can still call them off an
existing manager instance the way it called create() before.
- createSave() now defaults `files` to [] and, for Presets/Projects,
`plugins` to {} when the caller hasn't set them, rather than requiring
every caller to remember to - this also fixes a latent bug in the
removed code, which defaulted `plugins` to [] (an array) where the
type is actually a slug->version map (PresetPlugins/ProjectPlugins).
Removes `inquirer` from dependencies entirely. studiorack-cli (the
current consumer of ManagerLocal.create()) will need a follow-up change
to call createQuestions()/createVersionQuestions() with its own prompt
library and pass the answers to createSave() - not included here, since
this package needs to be merged and published first.
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.
Summary
ManagerLocal.create()imported and droveinquirerdirectly (inquirer.prompt(...)) - an interactive-CLI/UX dependency baked into what's otherwise an isomorphic browser/server SDK (@open-audio-stack/core, exported for embedding perpackage.json). Any consumer embeddingManagerLocalfor programmatic install/uninstall pulled ininquirertransitively even though they'd never callcreate(). This is Structural Warning #4 inreview.md, and the// TODO Rewrite this code after prototype is proven.comment oncreate()acknowledged it was never meant to stay long-term.create()andinquirerentirely rather than keeping a thinner version - per discussion, interactive prompting belongs in the CLI that uses this package (studiorack-cli), not the package itself.src/helpers/createQuestions.ts:createPackageQuestions()(org/package/version - needed first, since the rest depend on them) andcreatePackageVersionQuestions(type, org, pkg)(name/author/description/license/type/tags/url/donate/audio/image/date/changes - type-appropriatechoices, org+pkg-derivedurl/audio/imagedefaults). Returns a library-agnosticCreateQuestionshape (name/type/message/default/choices/validate/filter) - notinquirer's ownQuestiontype - so core has no prompt-library dependency of any kind, though the shape happens to be close enough that most prompt libraries (inquirer included) can consume it directly.ManagerLocalkeeps thin delegating instance methods -createQuestions()andcreateVersionQuestions(org, pkg)- so a CLI can still call these off an existing manager instance, the same calling conventioncreate()had.create()code defaulted a Preset/Project'spluginsfield to[](an array), butPresetPlugins/ProjectPluginsare actually{ [slug: string]: string }maps, not arrays - this would have produced a wrongly-shapedpluginsfield in every package scaffolded viacreate()for those two types.createSave()now defaultsfilesto[]and, for Presets/Projects,pluginsto{}(the correct shape) when the caller hasn't set them.createQuestions.tsis exported from bothindex.tsandindex-browser.ts- it's pure logic (no fs/node-only APIs), so a browser-based tool could use it too, unlike the rest ofManagerLocal.studiorack-cli, which currently callsmanager.create()and will break until it's updated to callcreateQuestions()/createVersionQuestions()with its own prompt library and pass the answers tocreateSave(). Per discussion, that follow-up needs this package published first, so it's out of scope here.This is item 5 of the architectural review in
review.md(Structural Warning #4, theinquirer-in-core part specifically).Test plan
tests/helpers/createQuestions.test.ts: org/package slug and version validation, tags filter, url/audio/image default derivation, and type-specificchoicesper registry type.ManagerLocal.test.ts:createQuestions()/createVersionQuestions()delegate correctly, andcreateSave()'s newfiles/pluginsdefaulting (including the array→object fix) persists correctly to disk.npm audit: 0 vulnerabilities after removinginquirer.npm run check(format, lint, build, test): 218/218 tests, 18/18 files pass.🤖 Generated with Claude Code