Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix aliases in config.commandIDs missing the default topic separator (#1229) #1230

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {OCLIF_MARKER_OWNER, Performance} from '../performance'
import {settings} from '../settings'
import {determinePriority} from '../util/determine-priority'
import {safeReadJson} from '../util/fs'
import {toStandardizedId} from '../util/ids'
import {getHomeDir, getPlatform} from '../util/os'
import {compact, isProd} from '../util/util'
import {ux} from '../ux'
Expand Down Expand Up @@ -780,23 +781,27 @@ export class Config implements IConfig {
}

const handleAlias = (alias: string, hidden = false) => {
if (this._commands.has(alias)) {
const aliasWithDefaultTopicSeparator = toStandardizedId(alias, this)
if (this._commands.has(aliasWithDefaultTopicSeparator)) {
const prioritizedCommand = determinePriority(this.pjson.oclif.plugins ?? [], [
this._commands.get(alias)!,
this._commands.get(aliasWithDefaultTopicSeparator)!,
command,
])
this._commands.set(alias, {...prioritizedCommand, id: alias})
this._commands.set(aliasWithDefaultTopicSeparator, {
...prioritizedCommand,
id: aliasWithDefaultTopicSeparator,
})
} else {
this._commands.set(alias, {...command, hidden, id: alias})
this._commands.set(aliasWithDefaultTopicSeparator, {...command, hidden, id: aliasWithDefaultTopicSeparator})
}

// set every permutation of the aliases
// v3 moved command alias permutations to the manifest, but some plugins may not have
// the new manifest yet. For those, we need to calculate the permutations here.
const aliasPermutations =
this.flexibleTaxonomy && command.aliasPermutations === undefined
? getCommandIdPermutations(alias)
: (command.permutations ?? [alias])
? getCommandIdPermutations(aliasWithDefaultTopicSeparator)
: (command.permutations ?? [aliasWithDefaultTopicSeparator])
// set every permutation
for (const permutation of aliasPermutations) {
this.commandPermutations.add(permutation, command.id)
Expand Down
Loading