Skip to content

Commit

Permalink
feat: skip deprecated aliases (#3)
Browse files Browse the repository at this point in the history
* feat: skip deprecated aliases

Makes fzf-cmp skip deprecated command aliases.
This required a small refactor to get commands and aliases from config.plugins instead of config.commands (which includes cmds + aliases merged)

also bump deps
  • Loading branch information
cristiand391 authored Jan 6, 2024
1 parent 998d6c2 commit 531146b
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 236 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
"/oclif.manifest.json"
],
"dependencies": {
"@oclif/core": "^3.10.7",
"@salesforce/core": "^5.3.18",
"@salesforce/source-deploy-retrieve": "^9.8.4",
"@oclif/core": "^3.16.0",
"@salesforce/core": "^6.4.4",
"@salesforce/source-deploy-retrieve": "^10.2.6",
"chalk": "^4.1.2"
},
"devDependencies": {
"@types/cli-progress": "^3.11.5",
"@types/node": "^20.6.4",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"eslint": "^8.50.0",
"prettier": "^3.0.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
"@typescript-eslint/eslint-plugin": "^6.18.0",
"@typescript-eslint/parser": "^6.18.0",
"eslint": "^8.56.0",
"prettier": "^3.1.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"oclif": {
"commands": "./lib/commands"
Expand Down
51 changes: 37 additions & 14 deletions src/comp-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,46 @@ export async function genCompletion(
await mkdir(fzfCompDir, { recursive: true });
}

const commands = config.commands
.filter((cmd) => !cmd.hidden)
.map((cmd) => ({
id: cmd.id.replace(/:/g, ' '),
summary: cmd.summary,
}))
.sort((a, b) => {
if (a.id < b.id) {
return -1;
}
type CommandCompletion = {
id: string;
summary?: string;
};

if (a.id > b.id) {
return 1;
const commands: CommandCompletion[] = [];

config.plugins.forEach((p) => {
p.commands.forEach((c) => {
if (c.hidden) return;
const summary = c.summary;

commands.push({
id: c.id.replace(/:/g, ' '),
summary,
});

if (!c.deprecateAliases) {
c.aliases.forEach((a) => {
commands.push({
id: a.replace(/:/g, ' '),
summary,
});
});
}

return 0;
});
});

// sort alphabetically
commands.sort((a, b) => {
if (a.id < b.id) {
return -1;
}

if (a.id > b.id) {
return 1;
}

return 0;
});

const commandsFile = `${fzfCompDir}/commands.json`;

Expand Down
2 changes: 1 addition & 1 deletion src/shell-completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function getOrgs(
type: 'all' | 'scratch' | 'devhub' | 'sandbox',
): Promise<string> {
const { StateAggregator } = await import(
'@salesforce/core/lib/stateAggregator'
'@salesforce/core/lib/stateAggregator/stateAggregator'
);
const stateAgg = await StateAggregator.getInstance();

Expand Down
Loading

0 comments on commit 531146b

Please sign in to comment.