Skip to content

[refactor] Remove inquirer from core; expose create question metadata instead - #107

Merged
kmturley merged 1 commit into
mainfrom
refactor/create-remove-inquirer
Jul 31, 2026
Merged

[refactor] Remove inquirer from core; expose create question metadata instead#107
kmturley merged 1 commit into
mainfrom
refactor/create-remove-inquirer

Conversation

@kmturley

Copy link
Copy Markdown
Member

Summary

  • ManagerLocal.create() imported and drove inquirer directly (inquirer.prompt(...)) - an interactive-CLI/UX dependency baked into what's otherwise an isomorphic browser/server SDK (@open-audio-stack/core, exported for embedding per package.json). Any consumer embedding ManagerLocal for programmatic install/uninstall pulled in inquirer transitively even though they'd never call create(). This is Structural Warning #4 in review.md, and the // TODO Rewrite this code after prototype is proven. comment on create() acknowledged it was never meant to stay long-term.
  • Removes create() and inquirer entirely rather than keeping a thinner version - per discussion, interactive prompting belongs in the CLI that uses this package (studiorack-cli), not the package itself.
  • Adds src/helpers/createQuestions.ts: createPackageQuestions() (org/package/version - needed first, since the rest depend on them) and createPackageVersionQuestions(type, org, pkg) (name/author/description/license/type/tags/url/donate/audio/image/date/changes - type-appropriate choices, org+pkg-derived url/audio/image defaults). Returns a library-agnostic CreateQuestion shape (name/type/message/default/choices/validate/filter) - not inquirer's own Question type - 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.
  • ManagerLocal keeps thin delegating instance methods - createQuestions() and createVersionQuestions(org, pkg) - so a CLI can still call these off an existing manager instance, the same calling convention create() had.
  • Found and fixed a latent bug while extracting: the removed create() code defaulted a Preset/Project's plugins field to [] (an array), but PresetPlugins/ProjectPlugins are actually { [slug: string]: string } maps, not arrays - this would have produced a wrongly-shaped plugins field in every package scaffolded via create() for those two types. createSave() now defaults files to [] and, for Presets/Projects, plugins to {} (the correct shape) when the caller hasn't set them.
  • createQuestions.ts is exported from both index.ts and index-browser.ts - it's pure logic (no fs/node-only APIs), so a browser-based tool could use it too, unlike the rest of ManagerLocal.
  • Not included: any change to studiorack-cli, which currently calls manager.create() and will break until it's updated to call createQuestions()/createVersionQuestions() with its own prompt library and pass the answers to createSave(). 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, the inquirer-in-core part specifically).

Test plan

  • New tests/helpers/createQuestions.test.ts: org/package slug and version validation, tags filter, url/audio/image default derivation, and type-specific choices per registry type.
  • New tests in ManagerLocal.test.ts: createQuestions()/createVersionQuestions() delegate correctly, and createSave()'s new files/plugins defaulting (including the array→object fix) persists correctly to disk.
  • npm audit: 0 vulnerabilities after removing inquirer.
  • npm run check (format, lint, build, test): 218/218 tests, 18/18 files pass.

🤖 Generated with Claude Code

… 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.
@kmturley
kmturley merged commit 8c0c214 into main Jul 31, 2026
6 checks passed
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