[READ-ONLY] Mirror of https://github.com/bombshell-dev/tab. shell autocompletions for javascript CLIs
4

Configure Feed

Select the types of activity you want to include in your feed.

feat: add more completions for package managers (#34)

authored by

AmirHossein Sakhravi and committed by
GitHub
(Aug 11, 2025, 9:50 AM +0330) d3d8c5da cec5d29a

+429 -45
+429 -45
bin/completion-handlers.ts
··· 1 - // 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. 2 1 import { PackageManagerCompletion } from './package-manager-completion.js'; 2 + import { readFileSync } from 'fs'; 3 + 4 + // Helper functions for dynamic completions 5 + function getPackageJsonScripts(): string[] { 6 + try { 7 + const packageJson = JSON.parse(readFileSync('package.json', 'utf8')); 8 + return Object.keys(packageJson.scripts || {}); 9 + } catch { 10 + return []; 11 + } 12 + } 13 + 14 + function getPackageJsonDependencies(): string[] { 15 + try { 16 + const packageJson = JSON.parse(readFileSync('package.json', 'utf8')); 17 + const deps = { 18 + ...packageJson.dependencies, 19 + ...packageJson.devDependencies, 20 + ...packageJson.peerDependencies, 21 + ...packageJson.optionalDependencies, 22 + }; 23 + return Object.keys(deps); 24 + } catch { 25 + return []; 26 + } 27 + } 28 + 29 + // Common completion handlers 30 + const scriptCompletion = async (complete: any) => { 31 + const scripts = getPackageJsonScripts(); 32 + scripts.forEach((script) => complete(script, `Run ${script} script`)); 33 + }; 34 + 35 + const dependencyCompletion = async (complete: any) => { 36 + const deps = getPackageJsonDependencies(); 37 + deps.forEach((dep) => complete(dep, '')); 38 + }; 3 39 4 40 export function setupCompletionForPackageManager( 5 41 packageManager: string, ··· 14 50 } else if (packageManager === 'bun') { 15 51 setupBunCompletions(completion); 16 52 } 17 - 18 - // Note: Package manager logic is now handled by PackageManagerCompletion wrapper 19 53 } 20 54 21 55 export function setupPnpmCompletions(completion: PackageManagerCompletion) { 22 - completion.command('add', 'Install a package'); 23 - completion.command('remove', 'Remove a package'); 24 - completion.command('install', 'Install dependencies'); 25 - completion.command('update', 'Update dependencies'); 26 - completion.command('run', 'Run a script'); 27 - completion.command('exec', 'Execute a command'); 28 - completion.command('dlx', 'Run a package without installing'); 29 - completion.command('create', 'Create a new project'); 30 - completion.command('init', 'Initialize a new project'); 31 - completion.command('publish', 'Publish the package'); 32 - completion.command('pack', 'Create a tarball'); 33 - completion.command('link', 'Link a package'); 34 - completion.command('unlink', 'Unlink a package'); 35 - completion.command('outdated', 'Check for outdated packages'); 36 - completion.command('audit', 'Run security audit'); 37 - completion.command('list', 'List installed packages'); 56 + // Package management 57 + const addCmd = completion.command('add', 'Install packages'); 58 + addCmd.option('save-dev', 'Save to devDependencies', 'D'); 59 + addCmd.option('save-optional', 'Save to optionalDependencies', 'O'); 60 + addCmd.option('save-exact', 'Save exact version', 'E'); 61 + addCmd.option('global', 'Install globally', 'g'); 62 + addCmd.option('workspace', 'Install to workspace'); 63 + addCmd.option('filter', 'Filter packages'); 64 + 65 + const removeCmd = completion.command('remove', 'Remove packages'); 66 + removeCmd.argument('package', dependencyCompletion); 67 + removeCmd.option('global', 'Remove globally', 'g'); 68 + 69 + const installCmd = completion.command('install', 'Install dependencies'); 70 + installCmd.option('frozen-lockfile', 'Install with frozen lockfile'); 71 + installCmd.option('prefer-frozen-lockfile', 'Prefer frozen lockfile'); 72 + installCmd.option('production', 'Install production dependencies only'); 73 + installCmd.option('dev', 'Install dev dependencies only'); 74 + installCmd.option('optional', 'Include optional dependencies'); 75 + installCmd.option('filter', 'Filter packages'); 76 + 77 + const updateCmd = completion.command('update', 'Update dependencies'); 78 + updateCmd.argument('package', dependencyCompletion); 79 + updateCmd.option('latest', 'Update to latest versions'); 80 + updateCmd.option('global', 'Update global packages', 'g'); 81 + updateCmd.option('interactive', 'Interactive update', 'i'); 82 + 83 + // Script execution 84 + const runCmd = completion.command('run', 'Run scripts'); 85 + runCmd.argument('script', scriptCompletion, true); 86 + runCmd.option('parallel', 'Run scripts in parallel'); 87 + runCmd.option('stream', 'Stream output'); 88 + runCmd.option('filter', 'Filter packages'); 89 + 90 + const execCmd = completion.command('exec', 'Execute commands'); 91 + execCmd.option('filter', 'Filter packages'); 92 + execCmd.option('parallel', 'Run in parallel'); 93 + execCmd.option('stream', 'Stream output'); 94 + 95 + completion.command('dlx', 'Run package without installing'); 96 + 97 + // Project management 98 + completion.command('create', 'Create new project'); 99 + completion.command('init', 'Initialize project'); 100 + 101 + // Publishing 102 + const publishCmd = completion.command('publish', 'Publish package'); 103 + publishCmd.option('tag', 'Publish with tag'); 104 + publishCmd.option('access', 'Set access level'); 105 + publishCmd.option('otp', 'One-time password'); 106 + publishCmd.option('dry-run', 'Dry run'); 107 + 108 + const packCmd = completion.command('pack', 'Create tarball'); 109 + packCmd.option('pack-destination', 'Destination directory'); 110 + 111 + // Linking 112 + const linkCmd = completion.command('link', 'Link packages'); 113 + linkCmd.option('global', 'Link globally', 'g'); 114 + 115 + const unlinkCmd = completion.command('unlink', 'Unlink packages'); 116 + unlinkCmd.option('global', 'Unlink globally', 'g'); 117 + 118 + // Information 119 + const listCmd = completion.command('list', 'List packages'); 120 + listCmd.option('depth', 'Max depth'); 121 + listCmd.option('global', 'List global packages', 'g'); 122 + listCmd.option('long', 'Show extended information'); 123 + listCmd.option('parseable', 'Parseable output'); 124 + listCmd.option('json', 'JSON output'); 125 + 126 + const outdatedCmd = completion.command('outdated', 'Check outdated packages'); 127 + outdatedCmd.option('global', 'Check global packages', 'g'); 128 + outdatedCmd.option('long', 'Show extended information'); 129 + 130 + const auditCmd = completion.command('audit', 'Security audit'); 131 + auditCmd.option('fix', 'Automatically fix vulnerabilities'); 132 + auditCmd.option('json', 'JSON output'); 133 + 134 + // Workspace commands 135 + completion.command('workspace', 'Workspace commands'); 136 + 137 + // Store management 138 + completion.command('store', 'Store management'); 139 + completion.command('store status', 'Store status'); 140 + completion.command('store prune', 'Prune store'); 141 + completion.command('store path', 'Store path'); 142 + 143 + // Configuration 144 + completion.command('config', 'Configuration'); 145 + completion.command('config get', 'Get config value'); 146 + completion.command('config set', 'Set config value'); 147 + completion.command('config delete', 'Delete config value'); 148 + completion.command('config list', 'List config'); 149 + 150 + // Other useful commands 151 + completion.command('why', 'Explain why package is installed'); 152 + completion.command('rebuild', 'Rebuild packages'); 153 + completion.command('root', 'Print root directory'); 154 + completion.command('bin', 'Print bin directory'); 155 + completion.command('start', 'Run start script'); 156 + completion.command('test', 'Run test script'); 157 + completion.command('restart', 'Run restart script'); 158 + completion.command('stop', 'Run stop script'); 38 159 } 39 160 40 161 export function setupNpmCompletions(completion: PackageManagerCompletion) { 41 - completion.command('install', 'Install a package'); 42 - completion.command('uninstall', 'Remove a package'); 43 - completion.command('update', 'Update dependencies'); 44 - completion.command('run', 'Run a script'); 45 - completion.command('exec', 'Execute a command'); 46 - completion.command('init', 'Initialize a new project'); 47 - completion.command('publish', 'Publish the package'); 48 - completion.command('pack', 'Create a tarball'); 49 - completion.command('link', 'Link a package'); 50 - completion.command('unlink', 'Unlink a package'); 162 + // Package management 163 + const installCmd = completion.command('install', 'Install packages'); 164 + installCmd.option('save', 'Save to dependencies', 'S'); 165 + installCmd.option('save-dev', 'Save to devDependencies', 'D'); 166 + installCmd.option('save-optional', 'Save to optionalDependencies', 'O'); 167 + installCmd.option('save-exact', 'Save exact version', 'E'); 168 + installCmd.option('global', 'Install globally', 'g'); 169 + installCmd.option('production', 'Production install'); 170 + installCmd.option('only', 'Install only specific dependencies'); 171 + 172 + const uninstallCmd = completion.command('uninstall', 'Remove packages'); 173 + uninstallCmd.argument('package', dependencyCompletion); 174 + uninstallCmd.option('save', 'Remove from dependencies', 'S'); 175 + uninstallCmd.option('save-dev', 'Remove from devDependencies', 'D'); 176 + uninstallCmd.option('global', 'Remove globally', 'g'); 177 + 178 + const updateCmd = completion.command('update', 'Update packages'); 179 + updateCmd.argument('package', dependencyCompletion); 180 + updateCmd.option('global', 'Update global packages', 'g'); 181 + 182 + // Script execution 183 + const runCmd = completion.command('run', 'Run scripts'); 184 + runCmd.argument('script', scriptCompletion, true); 185 + 186 + const runScriptCmd = completion.command('run-script', 'Run scripts'); 187 + runScriptCmd.argument('script', scriptCompletion, true); 188 + 189 + completion.command('exec', 'Execute command'); 190 + 191 + // Project management 192 + const initCmd = completion.command('init', 'Initialize project'); 193 + initCmd.option('yes', 'Use defaults', 'y'); 194 + initCmd.option('scope', 'Set scope'); 195 + 196 + // Publishing 197 + const publishCmd = completion.command('publish', 'Publish package'); 198 + publishCmd.option('tag', 'Publish with tag'); 199 + publishCmd.option('access', 'Set access level'); 200 + publishCmd.option('otp', 'One-time password'); 201 + publishCmd.option('dry-run', 'Dry run'); 202 + 203 + completion.command('pack', 'Create tarball'); 204 + 205 + // Linking 206 + completion.command('link', 'Link packages'); 207 + completion.command('unlink', 'Unlink packages'); 208 + 209 + // Information 210 + const listCmd = completion.command('list', 'List packages'); 211 + listCmd.option('depth', 'Max depth'); 212 + listCmd.option('global', 'List global packages', 'g'); 213 + listCmd.option('long', 'Show extended information'); 214 + listCmd.option('parseable', 'Parseable output'); 215 + listCmd.option('json', 'JSON output'); 216 + 217 + const lsCmd = completion.command('ls', 'List packages (alias)'); 218 + lsCmd.option('depth', 'Max depth'); 219 + lsCmd.option('global', 'List global packages', 'g'); 220 + 221 + const outdatedCmd = completion.command('outdated', 'Check outdated packages'); 222 + outdatedCmd.option('global', 'Check global packages', 'g'); 223 + 224 + const auditCmd = completion.command('audit', 'Security audit'); 225 + auditCmd.option('fix', 'Fix vulnerabilities'); 226 + auditCmd.option('json', 'JSON output'); 227 + 228 + // Configuration 229 + completion.command('config', 'Configuration'); 230 + completion.command('config get', 'Get config value'); 231 + completion.command('config set', 'Set config value'); 232 + completion.command('config delete', 'Delete config value'); 233 + completion.command('config list', 'List config'); 234 + 235 + // Other commands 236 + completion.command('version', 'Bump version'); 237 + completion.command('view', 'View package info'); 238 + completion.command('search', 'Search packages'); 239 + completion.command('whoami', 'Display username'); 240 + completion.command('login', 'Login to registry'); 241 + completion.command('logout', 'Logout from registry'); 242 + completion.command('adduser', 'Add user'); 243 + completion.command('owner', 'Manage package owners'); 244 + completion.command('deprecate', 'Deprecate package'); 245 + completion.command('dist-tag', 'Manage distribution tags'); 246 + completion.command('cache', 'Manage cache'); 247 + completion.command('completion', 'Tab completion'); 248 + completion.command('explore', 'Browse package'); 249 + completion.command('docs', 'Open documentation'); 250 + completion.command('repo', 'Open repository'); 251 + completion.command('bugs', 'Open bug tracker'); 252 + completion.command('help', 'Get help'); 253 + completion.command('root', 'Print root directory'); 254 + completion.command('prefix', 'Print prefix'); 255 + completion.command('bin', 'Print bin directory'); 256 + completion.command('fund', 'Fund packages'); 257 + completion.command('find-dupes', 'Find duplicate packages'); 258 + completion.command('dedupe', 'Deduplicate packages'); 259 + completion.command('prune', 'Remove extraneous packages'); 260 + completion.command('rebuild', 'Rebuild packages'); 261 + completion.command('start', 'Run start script'); 262 + completion.command('stop', 'Run stop script'); 263 + completion.command('test', 'Run test script'); 264 + completion.command('restart', 'Run restart script'); 51 265 } 52 266 53 267 export function setupYarnCompletions(completion: PackageManagerCompletion) { 54 - completion.command('add', 'Install a package'); 55 - completion.command('remove', 'Remove a package'); 56 - completion.command('install', 'Install dependencies'); 57 - completion.command('upgrade', 'Update dependencies'); 58 - completion.command('run', 'Run a script'); 59 - completion.command('exec', 'Execute a command'); 60 - completion.command('create', 'Create a new project'); 61 - completion.command('init', 'Initialize a new project'); 268 + // Package management 269 + const addCmd = completion.command('add', 'Add packages'); 270 + addCmd.option('dev', 'Add to devDependencies', 'D'); 271 + addCmd.option('peer', 'Add to peerDependencies', 'P'); 272 + addCmd.option('optional', 'Add to optionalDependencies', 'O'); 273 + addCmd.option('exact', 'Add exact version', 'E'); 274 + addCmd.option('tilde', 'Add with tilde range', 'T'); 275 + 276 + const removeCmd = completion.command('remove', 'Remove packages'); 277 + removeCmd.argument('package', dependencyCompletion); 278 + 279 + const installCmd = completion.command('install', 'Install dependencies'); 280 + installCmd.option('frozen-lockfile', 'Install with frozen lockfile'); 281 + installCmd.option('prefer-offline', 'Prefer offline'); 282 + installCmd.option('production', 'Production install'); 283 + installCmd.option('pure-lockfile', 'Pure lockfile'); 284 + installCmd.option('focus', 'Focus install'); 285 + installCmd.option('har', 'Save HAR file'); 286 + 287 + const upgradeCmd = completion.command('upgrade', 'Upgrade packages'); 288 + upgradeCmd.argument('package', dependencyCompletion); 289 + upgradeCmd.option('latest', 'Upgrade to latest'); 290 + upgradeCmd.option('pattern', 'Upgrade pattern'); 291 + upgradeCmd.option('scope', 'Upgrade scope'); 292 + 293 + const upgradeInteractiveCmd = completion.command( 294 + 'upgrade-interactive', 295 + 'Interactive upgrade' 296 + ); 297 + upgradeInteractiveCmd.option('latest', 'Show latest versions'); 298 + 299 + // Script execution 300 + const runCmd = completion.command('run', 'Run scripts'); 301 + runCmd.argument('script', scriptCompletion, true); 302 + 303 + completion.command('exec', 'Execute command'); 304 + 305 + // Project management 306 + completion.command('create', 'Create new project'); 307 + const initCmd = completion.command('init', 'Initialize project'); 308 + initCmd.option('yes', 'Use defaults', 'y'); 309 + initCmd.option('private', 'Create private package', 'p'); 310 + 311 + // Publishing 312 + const publishCmd = completion.command('publish', 'Publish package'); 313 + publishCmd.option('tag', 'Publish with tag'); 314 + publishCmd.option('access', 'Set access level'); 315 + publishCmd.option('new-version', 'Set new version'); 316 + 317 + const packCmd = completion.command('pack', 'Create tarball'); 318 + packCmd.option('filename', 'Output filename'); 319 + 320 + // Linking 321 + completion.command('link', 'Link packages'); 322 + completion.command('unlink', 'Unlink packages'); 323 + 324 + // Information 325 + const listCmd = completion.command('list', 'List packages'); 326 + listCmd.option('depth', 'Max depth'); 327 + listCmd.option('pattern', 'Filter pattern'); 328 + 329 + completion.command('info', 'Show package info'); 330 + completion.command('outdated', 'Check outdated packages'); 331 + const auditCmd = completion.command('audit', 'Security audit'); 332 + auditCmd.option('level', 'Minimum severity level'); 333 + 334 + // Workspace commands 335 + completion.command('workspace', 'Workspace commands'); 336 + completion.command('workspaces', 'Workspaces commands'); 337 + completion.command('workspaces info', 'Workspace info'); 338 + completion.command('workspaces run', 'Run in workspaces'); 339 + 340 + // Configuration 341 + completion.command('config', 'Configuration'); 342 + completion.command('config get', 'Get config value'); 343 + completion.command('config set', 'Set config value'); 344 + completion.command('config delete', 'Delete config value'); 345 + completion.command('config list', 'List config'); 346 + 347 + // Cache management 348 + completion.command('cache', 'Cache management'); 349 + completion.command('cache list', 'List cache'); 350 + completion.command('cache dir', 'Cache directory'); 351 + completion.command('cache clean', 'Clean cache'); 352 + 353 + // Other commands 354 + completion.command('version', 'Show version'); 355 + completion.command('versions', 'Show all versions'); 356 + completion.command('why', 'Explain installation'); 357 + completion.command('owner', 'Manage owners'); 358 + completion.command('team', 'Manage teams'); 359 + completion.command('login', 'Login to registry'); 360 + completion.command('logout', 'Logout from registry'); 361 + completion.command('tag', 'Manage tags'); 362 + completion.command('global', 'Global packages'); 363 + completion.command('bin', 'Print bin directory'); 364 + completion.command('dir', 'Print modules directory'); 365 + completion.command('licenses', 'List licenses'); 366 + completion.command('generate-lock-entry', 'Generate lock entry'); 367 + completion.command('check', 'Verify package tree'); 368 + completion.command('import', 'Import from npm'); 369 + completion.command('install-peerdeps', 'Install peer dependencies'); 370 + completion.command('autoclean', 'Clean unnecessary files'); 371 + completion.command('policies', 'Policies'); 372 + completion.command('start', 'Run start script'); 373 + completion.command('test', 'Run test script'); 374 + completion.command('node', 'Run node'); 62 375 } 63 376 64 377 export function setupBunCompletions(completion: PackageManagerCompletion) { 65 - completion.command('add', 'Install a package'); 66 - completion.command('remove', 'Remove a package'); 67 - completion.command('install', 'Install dependencies'); 68 - completion.command('update', 'Update dependencies'); 69 - completion.command('run', 'Run a script'); 70 - completion.command('x', 'Execute a command'); 71 - completion.command('create', 'Create a new project'); 72 - completion.command('init', 'Initialize a new project'); 378 + // Package management 379 + const addCmd = completion.command('add', 'Add packages'); 380 + addCmd.option('development', 'Add to devDependencies', 'd'); 381 + addCmd.option('optional', 'Add to optionalDependencies'); 382 + addCmd.option('exact', 'Add exact version', 'E'); 383 + addCmd.option('global', 'Install globally', 'g'); 384 + 385 + const removeCmd = completion.command('remove', 'Remove packages'); 386 + removeCmd.argument('package', dependencyCompletion); 387 + removeCmd.option('global', 'Remove globally', 'g'); 388 + 389 + const installCmd = completion.command('install', 'Install dependencies'); 390 + installCmd.option('production', 'Production install'); 391 + installCmd.option('frozen-lockfile', 'Use frozen lockfile'); 392 + installCmd.option('dry-run', 'Dry run'); 393 + installCmd.option('force', 'Force install'); 394 + installCmd.option('silent', 'Silent install'); 395 + 396 + const updateCmd = completion.command('update', 'Update packages'); 397 + updateCmd.argument('package', dependencyCompletion); 398 + updateCmd.option('global', 'Update global packages', 'g'); 399 + 400 + // Script execution and running 401 + const runCmd = completion.command('run', 'Run scripts'); 402 + runCmd.argument('script', scriptCompletion, true); 403 + runCmd.option('silent', 'Silent output'); 404 + runCmd.option('bun', 'Use bun runtime'); 405 + 406 + const xCmd = completion.command('x', 'Execute packages'); 407 + xCmd.option('bun', 'Use bun runtime'); 408 + 409 + // Bun-specific commands 410 + completion.command('dev', 'Development server'); 411 + completion.command('build', 'Build project'); 412 + completion.command('test', 'Run tests'); 413 + 414 + // Project management 415 + completion.command('create', 'Create new project'); 416 + const initCmd = completion.command('init', 'Initialize project'); 417 + initCmd.option('yes', 'Use defaults', 'y'); 418 + 419 + // Publishing 420 + const publishCmd = completion.command('publish', 'Publish package'); 421 + publishCmd.option('tag', 'Publish with tag'); 422 + publishCmd.option('access', 'Set access level'); 423 + publishCmd.option('otp', 'One-time password'); 424 + 425 + completion.command('pack', 'Create tarball'); 426 + 427 + // Linking 428 + completion.command('link', 'Link packages'); 429 + completion.command('unlink', 'Unlink packages'); 430 + 431 + // Information 432 + const listCmd = completion.command('list', 'List packages'); 433 + listCmd.option('global', 'List global packages', 'g'); 434 + 435 + completion.command('outdated', 'Check outdated packages'); 436 + completion.command('audit', 'Security audit'); 437 + 438 + // Configuration 439 + completion.command('config', 'Configuration'); 440 + 441 + // Bun runtime commands 442 + completion.command('bun', 'Run with Bun runtime'); 443 + completion.command('node', 'Node.js compatibility'); 444 + completion.command('upgrade', 'Upgrade Bun'); 445 + completion.command('completions', 'Generate completions'); 446 + completion.command('discord', 'Open Discord'); 447 + completion.command('help', 'Show help'); 448 + 449 + // File operations 450 + completion.command('install.cache', 'Cache operations'); 451 + completion.command('pm', 'Package manager operations'); 452 + 453 + // Other commands 454 + completion.command('start', 'Run start script'); 455 + completion.command('stop', 'Run stop script'); 456 + completion.command('restart', 'Run restart script'); 73 457 }