Skip to content
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
65 changes: 33 additions & 32 deletions bin/completion-handlers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// TODO: i do not see any completion functionality in this file. nothing is being provided for the defined commands of these package managers. this is a blocker for release. every each of them should be handled.
import { Completion } from '../src/index.js';

const noopCompletion = async () => [];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not an efficiency and performance win, it's more like a syntactic optimization.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aslemammad, I mean, if we think technically (though it’s a very small difference), the inlined way creates more memory allocations, and more allocations technically mean slightly less efficient memory usage.
but yeah we won’t see a real performance or memory impact either way in this case!


export function setupCompletionForPackageManager(
packageManager: string,
completion: Completion
Expand All @@ -20,50 +22,49 @@ export function setupCompletionForPackageManager(
}

export function setupPnpmCompletions(completion: Completion) {
completion.addCommand('add', 'Install a package', [], async () => []);
completion.addCommand('remove', 'Remove a package', [], async () => []);
completion.addCommand('add', 'Install a package', [], noopCompletion);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought descriptions were being retrieved from the package managers themselves as we talked. we should not do that manually.

completion.addCommand('remove', 'Remove a package', [], noopCompletion);
completion.addCommand(
'install',
'Install all dependencies',
[],
async () => []
noopCompletion
);
// TODO: empty functions should be replaced with noop functions rather than creating that many empty functions
completion.addCommand('update', 'Update packages', [], async () => []);
completion.addCommand('exec', 'Execute a command', [], async () => []);
completion.addCommand('run', 'Run a script', [], async () => []);
completion.addCommand('publish', 'Publish package', [], async () => []);
completion.addCommand('test', 'Run tests', [], async () => []);
completion.addCommand('build', 'Build project', [], async () => []);
completion.addCommand('update', 'Update packages', [], noopCompletion);
completion.addCommand('exec', 'Execute a command', [], noopCompletion);
completion.addCommand('run', 'Run a script', [], noopCompletion);
completion.addCommand('publish', 'Publish package', [], noopCompletion);
completion.addCommand('test', 'Run tests', [], noopCompletion);
completion.addCommand('build', 'Build project', [], noopCompletion);
}

export function setupNpmCompletions(completion: Completion) {
completion.addCommand('install', 'Install a package', [], async () => []);
completion.addCommand('uninstall', 'Uninstall a package', [], async () => []);
completion.addCommand('run', 'Run a script', [], async () => []);
completion.addCommand('test', 'Run tests', [], async () => []);
completion.addCommand('publish', 'Publish package', [], async () => []);
completion.addCommand('update', 'Update packages', [], async () => []);
completion.addCommand('start', 'Start the application', [], async () => []);
completion.addCommand('build', 'Build project', [], async () => []);
completion.addCommand('install', 'Install a package', [], noopCompletion);
completion.addCommand('uninstall', 'Uninstall a package', [], noopCompletion);
completion.addCommand('run', 'Run a script', [], noopCompletion);
completion.addCommand('test', 'Run tests', [], noopCompletion);
completion.addCommand('publish', 'Publish package', [], noopCompletion);
completion.addCommand('update', 'Update packages', [], noopCompletion);
completion.addCommand('start', 'Start the application', [], noopCompletion);
completion.addCommand('build', 'Build project', [], noopCompletion);
}

export function setupYarnCompletions(completion: Completion) {
completion.addCommand('add', 'Add a package', [], async () => []);
completion.addCommand('remove', 'Remove a package', [], async () => []);
completion.addCommand('run', 'Run a script', [], async () => []);
completion.addCommand('test', 'Run tests', [], async () => []);
completion.addCommand('publish', 'Publish package', [], async () => []);
completion.addCommand('install', 'Install dependencies', [], async () => []);
completion.addCommand('build', 'Build project', [], async () => []);
completion.addCommand('add', 'Add a package', [], noopCompletion);
completion.addCommand('remove', 'Remove a package', [], noopCompletion);
completion.addCommand('run', 'Run a script', [], noopCompletion);
completion.addCommand('test', 'Run tests', [], noopCompletion);
completion.addCommand('publish', 'Publish package', [], noopCompletion);
completion.addCommand('install', 'Install dependencies', [], noopCompletion);
completion.addCommand('build', 'Build project', [], noopCompletion);
}

export function setupBunCompletions(completion: Completion) {
completion.addCommand('add', 'Add a package', [], async () => []);
completion.addCommand('remove', 'Remove a package', [], async () => []);
completion.addCommand('run', 'Run a script', [], async () => []);
completion.addCommand('test', 'Run tests', [], async () => []);
completion.addCommand('install', 'Install dependencies', [], async () => []);
completion.addCommand('update', 'Update packages', [], async () => []);
completion.addCommand('build', 'Build project', [], async () => []);
completion.addCommand('add', 'Add a package', [], noopCompletion);
completion.addCommand('remove', 'Remove a package', [], noopCompletion);
completion.addCommand('run', 'Run a script', [], noopCompletion);
completion.addCommand('test', 'Run tests', [], noopCompletion);
completion.addCommand('install', 'Install dependencies', [], noopCompletion);
completion.addCommand('update', 'Update packages', [], noopCompletion);
completion.addCommand('build', 'Build project', [], noopCompletion);
}
Loading