Replace any-casts in command-registry with a typed command lookup - #8439
Draft
alfonso-noriega wants to merge 1 commit into
Draft
Replace any-casts in command-registry with a typed command lookup#8439alfonso-noriega wants to merge 1 commit into
alfonso-noriega wants to merge 1 commit into
Conversation
Type the lazy command loader against @oclif/core's Command class and bridge the external plugin package tables through a single helper, removing the per-branch eslint-disable/any casts. Add unit tests for manifest misses and the full-package fallback path. Assisted-By: devx/c4b514ef-dee6-425a-99d0-2f300e272eb6
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.
WHY are these changes introduced?
packages/cli/src/command-registry.tscarried 7eslint-disable @typescript-eslint/no-explicit-anysuppressions: the lazy command loader returnedPromise<any | undefined>and each external plugin branch indexed its command table throughas any. The module also had no unit tests. Surfaced by the daily maintenance radar (suppression cleanup).WHAT is this pull request doing?
@oclif/core'sCommandclass (CommandClass = typeof Command), matching theLazyCommandLoadercontract in cli-kit ((id: string) => Promise<typeof Command | undefined>).@shopify/cli-hydrogen,@oclif/plugin-commands,@oclif/plugin-plugins,@shopify/plugin-did-you-mean) through a singlecommandFromTablehelper — one documented cast at the package boundary instead of four inlineas any, since each package compiles against its own@oclif/core.command-registry.test.tscovering manifest misses and the full-package fallback path (real imports, no mocks).@shopify/plugin-did-you-mean→srcalias to the shared vitest config so the module under test resolves in vitest, same pattern as the existing@shopify/theme/@shopify/organizationsaliases.No runtime behavior change: the lookups and fallbacks are identical, only the types changed.
How to test your changes?
pnpm vitest run packages/cli/src/command-registry.test.ts(3 tests)pnpm --filter @shopify/cli type-check && pnpm --filter @shopify/cli lintpnpm shopify commandsandpnpm shopify pluginsstill resolve through the full-package fallback; anyapp/themecommand still loads per-file.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset addNo changeset: internal refactor + tests, no user-visible change.