@shell-shock/plugin-completions 0.4.16 → 0.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/components/bash-config-command.cjs +120 -6
  2. package/dist/components/bash-config-command.mjs +119 -6
  3. package/dist/components/bash-config-command.mjs.map +1 -1
  4. package/dist/components/bash-script-command.cjs +105 -5
  5. package/dist/components/bash-script-command.mjs +104 -5
  6. package/dist/components/bash-script-command.mjs.map +1 -1
  7. package/dist/components/bash-shared.cjs +77 -13
  8. package/dist/components/bash-shared.mjs +76 -13
  9. package/dist/components/bash-shared.mjs.map +1 -1
  10. package/dist/components/fish-config-command.cjs +120 -6
  11. package/dist/components/fish-config-command.mjs +119 -6
  12. package/dist/components/fish-config-command.mjs.map +1 -1
  13. package/dist/components/fish-script-command.cjs +104 -4
  14. package/dist/components/fish-script-command.mjs +103 -4
  15. package/dist/components/fish-script-command.mjs.map +1 -1
  16. package/dist/components/fish-shared.cjs +141 -77
  17. package/dist/components/fish-shared.mjs +140 -77
  18. package/dist/components/fish-shared.mjs.map +1 -1
  19. package/dist/components/index.cjs +26 -1
  20. package/dist/components/index.mjs +14 -1
  21. package/dist/components/powershell-config-command.cjs +116 -6
  22. package/dist/components/powershell-config-command.mjs +115 -6
  23. package/dist/components/powershell-config-command.mjs.map +1 -1
  24. package/dist/components/powershell-script-command.cjs +104 -4
  25. package/dist/components/powershell-script-command.mjs +103 -4
  26. package/dist/components/powershell-script-command.mjs.map +1 -1
  27. package/dist/components/powershell-shared.cjs +101 -37
  28. package/dist/components/powershell-shared.mjs +100 -37
  29. package/dist/components/powershell-shared.mjs.map +1 -1
  30. package/dist/components/zsh-config-command.cjs +120 -6
  31. package/dist/components/zsh-config-command.mjs +119 -6
  32. package/dist/components/zsh-config-command.mjs.map +1 -1
  33. package/dist/components/zsh-script-command.cjs +108 -6
  34. package/dist/components/zsh-script-command.mjs +107 -6
  35. package/dist/components/zsh-script-command.mjs.map +1 -1
  36. package/dist/components/zsh-shared.cjs +106 -42
  37. package/dist/components/zsh-shared.mjs +105 -42
  38. package/dist/components/zsh-shared.mjs.map +1 -1
  39. package/dist/helpers/complete-command.cjs +10 -1
  40. package/dist/helpers/complete-command.mjs +8 -1
  41. package/dist/helpers/complete-command.mjs.map +1 -1
  42. package/dist/helpers/completion-directive-constants.cjs +16 -1
  43. package/dist/helpers/completion-directive-constants.mjs +14 -1
  44. package/dist/helpers/completion-directive-constants.mjs.map +1 -1
  45. package/dist/helpers/index.cjs +6 -1
  46. package/dist/helpers/index.mjs +4 -1
  47. package/dist/index.cjs +303 -1
  48. package/dist/index.mjs +301 -1
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/types/index.cjs +4 -1
  51. package/dist/types/index.mjs +3 -1
  52. package/dist/types/plugin.mjs +1 -1
  53. package/dist/types/shell-type.cjs +12 -1
  54. package/dist/types/shell-type.mjs +10 -1
  55. package/dist/types/shell-type.mjs.map +1 -1
  56. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"powershell-shared.mjs","names":[],"sources":["../../src/components/powershell-shared.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The PowerShell Completions generation for the Shell Shock project.\n */\nexport function PowerShellCompletionsShared() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n const name = computed(() => camelCase(bin.value));\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"powershell\",\n \"shared.ts\"\n )}\n builtinImports={{\n console: [\n \"white\",\n \"green\",\n \"red\",\n \"bold\",\n \"cyan\",\n \"gray\",\n \"magenta\",\n \"magentaBright\",\n \"greenBright\",\n \"redBright\",\n \"cyanBright\",\n \"dim\"\n ]\n }}>\n <Spacing />\n <VarDeclaration\n const\n export\n name=\"SHELL_COMPLETIONS\"\n initializer={code` \\`# powershell completion for ${getAppTitle(context)}\n\n [Console]::OutputEncoding = [System.Text.Encoding]::UTF8\n function __${name.value}_debug {\n if ($env:BASH_COMP_DEBUG_FILE) {\n \"$args\" | Out-File -Append -FilePath \"$env:BASH_COMP_DEBUG_FILE\"\n }\n }\n\n filter __${name.value}_escapeStringWithSpecialChars {\n $_ -replace '\\\\s|#|@|\\\\$|;|,|''|\\\\{|\\\\}|\\\\(|\\\\)|\"|\\\\||<|>|&','\\\\\\`$&'\n }\n\n[scriptblock]$__${name.value}CompleterBlock = {\n param(\n $WordToComplete,\n $CommandAst,\n $CursorPosition\n )\n\n # Get the current command-line and convert into a string\n $Command = $CommandAst.CommandElements\n $Command = \"$Command\"\n\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= starting completion logic ==========\"\n __${name.value}_debug \"WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition\"\n\n # The user could have moved the cursor backwards on the command-line.\n # We need to trigger completion from the $CursorPosition location, so we need\n # to truncate the command-line ($Command) up to the $CursorPosition location.\n # Make sure the $Command is longer then the $CursorPosition before we truncate.\n # This happens because the $Command does not include the last space.\n if ($Command.Length -gt $CursorPosition) {\n $Command = $Command.Substring(0, $CursorPosition)\n }\n __${name.value}_debug \"Truncated command: $Command\"\n\n $ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}\n $ShellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}\n $ShellCompDirectiveNoFileComp=${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\n $ShellCompDirectiveFilterFileExt=${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\n $ShellCompDirectiveFilterDirs=${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\n $ShellCompDirectiveKeepOrder=${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n\n # Prepare the command to request completions for the program.\n # Split the command at the first space to separate the program and arguments.\n $Program, $Arguments = $Command.Split(\" \", 2)\n\n $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { \"'\" + ($_ -replace \"'\", \"''\") + \"'\" }) -join ' '\n __${name.value}_debug \"QuotedArgs: $QuotedArgs\"\n\n $RequestComp = \"& ${EXEC_COMMAND} complete '--' $QuotedArgs\"\n __${name.value}_debug \"RequestComp: $RequestComp\"\n\n # we cannot use $WordToComplete because it\n # has the wrong values if the cursor was moved\n # so use the last argument\n if ($WordToComplete -ne \"\" ) {\n $WordToComplete = $Arguments.Split(\" \")[-1]\n }\n __${name.value}_debug \"New WordToComplete: $WordToComplete\"\n\n\n # Check for flag with equal sign\n $IsEqualFlag = ($WordToComplete -Like \"--*=*\" )\n if ( $IsEqualFlag ) {\n __${name.value}_debug \"Completing equal sign flag\"\n # Remove the flag part\n $Flag, $WordToComplete = $WordToComplete.Split(\"=\", 2)\n }\n\n if ( $WordToComplete -eq \"\" -And ( -Not $IsEqualFlag )) {\n # If the last parameter is complete (there is a space following it)\n # We add an extra empty parameter so we can indicate this to the go method.\n __${name.value}_debug \"Adding extra empty parameter\"\n # PowerShell 7.2+ changed the way how the arguments are passed to executables,\n # so for pre-7.2 or when Legacy argument passing is enabled we need to use\n if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or\n ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled(\"PSNativeCommandArgumentPassing\")) -or\n (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled(\"PSNativeCommandArgumentPassing\")) -and\n $PSNativeCommandArgumentPassing -eq 'Legacy')) {\n $RequestComp=\"$RequestComp\" + ' \\\\\\`\"\\\\\\`\"'\n } else {\n $RequestComp = \"$RequestComp\" + ' \"\"'\n }\n }\n\n __${name.value}_debug \"Calling $RequestComp\"\n # First disable ActiveHelp which is not supported for Powershell\n $env:ActiveHelp = 0\n\n # call the command store the output in $out and redirect stderr and stdout to null\n # $Out is an array contains each line per element\n Invoke-Expression -OutVariable out \"$RequestComp\" 2>&1 | Out-Null\n\n # get directive from last line\n [int]$Directive = $Out[-1].TrimStart(':')\n if ($Directive -eq \"\") {\n # There is no directive specified\n $Directive = 0\n }\n __${name.value}_debug \"The completion directive is: $Directive\"\n\n # remove directive (last element) from out\n $Out = $Out | Where-Object { $_ -ne $Out[-1] }\n __${name.value}_debug \"The completions are: $Out\"\n if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {\n # Error code. No completion.\n __${name.value}_debug \"Received error from custom completion go code\"\n return\n }\n\n $Longest = 0\n [Array]$Values = $Out | ForEach-Object {\n # Split the output in name and description\n $Name, $Description = $_.Split(\"\\\\\\`t\", 2)\n __${name.value}_debug \"Name: $Name Description: $Description\"\n\n # Look for the longest completion so that we can format things nicely\n if ($Longest -lt $Name.Length) {\n $Longest = $Name.Length\n }\n\n # Set the description to a one space string if there is none set.\n # This is needed because the CompletionResult does not accept an empty string as argument\n if (-Not $Description) {\n $Description = \" \"\n }\n @{ Name = \"$Name\"; Description = \"$Description\" }\n }\n\n\n $Space = \" \"\n if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {\n # remove the space here\n __${name.value}_debug \"ShellCompDirectiveNoSpace is called\"\n $Space = \"\"\n }\n\n if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or\n (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {\n __${\n name.value\n }_debug \"ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported\"\n\n # return here to prevent the completion of the extensions\n return\n }\n\n $Values = $Values | Where-Object {\n # filter the result\n $_.Name -like \"$WordToComplete*\"\n\n # Join the flag back if we have an equal sign flag\n if ( $IsEqualFlag ) {\n __${\n name.value\n }_debug \"Join the equal sign flag back to the completion value\"\n $_.Name = $Flag + \"=\" + $_.Name\n }\n }\n\n # we sort the values in ascending order by name if keep order isn't passed\n if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {\n $Values = $Values | Sort-Object -Property Name\n }\n\n if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {\n __${name.value}_debug \"ShellCompDirectiveNoFileComp is called\"\n\n if ($Values.Length -eq 0) {\n # Just print an empty string here so the\n # shell does not start to complete paths.\n # We cannot use CompletionResult here because\n # it does not accept an empty string as argument.\n \"\"\n return\n }\n }\n\n # Get the current mode\n $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq \"Tab\" }).Function\n __${name.value}_debug \"Mode: $Mode\"\n\n $Values | ForEach-Object {\n\n # store temporary because switch will overwrite $_\n $comp = $_\n\n # PowerShell supports three different completion modes\n # - TabCompleteNext (default windows style - on each key press the next option is displayed)\n # - Complete (works like bash)\n # - MenuComplete (works like zsh)\n # You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>\n\n # CompletionResult Arguments:\n # 1) CompletionText text to be used as the auto completion result\n # 2) ListItemText text to be displayed in the suggestion list\n # 3) ResultType type of completion result\n # 4) ToolTip text for the tooltip with details about the object\n\n switch ($Mode) {\n\n # bash like\n \"Complete\" {\n\n if ($Values.Length -eq 1) {\n __${name.value}_debug \"Only one completion left\"\n\n # insert space after value\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${\n name.value\n }_escapeStringWithSpecialChars) + $Space, \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n\n } else {\n # Add the proper number of spaces to align the descriptions\n while($comp.Name.Length -lt $Longest) {\n $comp.Name = $comp.Name + \" \"\n }\n\n # Check for empty description and only add parentheses if needed\n if ($($comp.Description) -eq \" \" ) {\n $Description = \"\"\n } else {\n $Description = \" ($($comp.Description))\"\n }\n\n [System.Management.Automation.CompletionResult]::new(\"$($comp.Name)$Description\", \"$($comp.Name)$Description\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n\n # zsh like\n \"MenuComplete\" {\n # insert space after value\n # MenuComplete will automatically show the ToolTip of\n # the highlighted value at the bottom of the suggestions.\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${\n name.value\n }_escapeStringWithSpecialChars) + $Space, \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n\n # TabCompleteNext and in case we get something unknown\n Default {\n # Like MenuComplete but we don't want to add a space here because\n # the user need to press space anyway to get the completion.\n # Description will not be shown because that's not possible with TabCompleteNext\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${\n name.value\n }_escapeStringWithSpecialChars), \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n }\n}\n\nRegister-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${\n name.value\n }CompleterBlock\n\\`; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS_DISPLAY\"\n initializer={code` SHELL_COMPLETIONS.split(\"\\\\n\").map(line => {\n if (!line.trim()) {\n return \"\";\n }\n if (line.trim().startsWith(\"#\")) {\n return \\`\\${dim(line)}\\`;\n }\n\n return white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, green(\"$&\"))\n .replaceAll(/\\\\\".*\\\\\"/g, cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|::new|::OutputEncoding|::UTF8)/g, bold(gray(\"$&\")))\n .replaceAll(/(switch|complete)\\\\s+/g, green(\"$&\"))\n .replaceAll(/(?<=(switch|complete)\\\\s+)\\\\w/g, bold(greenBright(\"$&\")))\n .replaceAll(/(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\\\w+)\\\\s+/g, red(\"$&\"))\n .replaceAll(/(?<=(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\\\w+)\\\\s+)\\\\w/g, bold(redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, bold(cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, green(\"$&\"))\n .replaceAll(/\\\\$?__\\\\w/g, bold(magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, bold(magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":"qtBAgCA,SAAE,GAAA,CACF,IAAO,EAAS,GAAA,CACR,EAAA,MAAU,EAAc,EAAA,CAAA,qBAE9B,OAAM,EAAmB,EAAY,CACrC,IAAM,MAAO,+DAGX,eAAC,CACC,QAAM,CAAA,QAAS,QAAA,MAAA,OAAA,OAAA,OAAA,UAAA,gBAAA,cAAA,YAAA,aAAA,MAAA,CAChB,CACD,IAAI,UAAC,CACH,MAAG,CAAA,EAAW,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACZ,MAAQ,GACT,OAAA,GACD,KAAA,oBACE,IAAA,aAAS,CACP,MAAO,EAAA,kCAAA,EAAA,EAAA,CAAA;;;iBAGD,EAAA,MAAA;;;;;;eAML,EAAS,MAAC;;;;kBAIb,EAAA,MAAA;;;;;;;;;;;QAWA,EAAK,MAAM;QACX,EAAA,MAAA;QACJ,EAAA,MAAA;;;;;;;;;;QAUI,EAAK,MAAA;;;iCAGiB,EAAuB,2BAAC;oCAC3B,EAAA,8BAAA;uCACH,EAAA,iCAAA;;mCAEG,EAAA,6BAAA;;;;;;;QAOrB,EAAK,MAAQ;;wBAEK,EAAK;QACrB,EAAC,MAAU;;;;;;;;QAQf,EAAA,MAAA;;;;;;YAMA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;QAqBI,EAAK,MAAM;;;;;;;;;;;;;;QAcX,EAAI,MAAK;;;;QAIT,EAAK,MAAC;;;YAGF,EAAE,MAAA;;;;;;;;YAQL,EAAA,MAAa;;;;;;;;;;;;;;;;;;;YAmBV,EAAK,MAAM;;;;;;YAMb,EAAM,MAAI;;;;;;;;;;;;gBAYP,EAAA,MAAc;;;;;;;;;;;YAWvB,EAAA,MAAA;;;;;;;;;;;;;;QAcI,EAAG,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;wBAyBL,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;wFA2BO,EAAA,MAAA;;;;;;;;wFAQQ,EAAA,MAAA;;;;;;2CAMgB,EAAI,MAAK,oBAAA,EAAA,MAAA;OAG7C,CAAC,CAAE,EAAkB,EAAS,EAAC,CAAA,CAAA,EAAqB,EAAgB,CACnE,OAAU,GACV,MAAS,GACT,KAAM,4BACN,YAAa,CAAI;;;;;;;;;;;;;;;;;;;;;0BAsBlB,CAAC,CAAC,EAEN,CAAC"}
1
+ {"version":3,"file":"powershell-shared.mjs","names":[],"sources":["../../src/components/powershell-shared.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The PowerShell Completions generation for the Shell Shock project.\n */\nexport function PowerShellCompletionsShared() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n const name = computed(() => camelCase(bin.value));\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"powershell\",\n \"shared.ts\"\n )}\n builtinImports={{\n console: [\n \"white\",\n \"green\",\n \"red\",\n \"bold\",\n \"cyan\",\n \"gray\",\n \"magenta\",\n \"magentaBright\",\n \"greenBright\",\n \"redBright\",\n \"cyanBright\",\n \"dim\"\n ]\n }}>\n <Spacing />\n <VarDeclaration\n const\n export\n name=\"SHELL_COMPLETIONS\"\n initializer={code` \\`# powershell completion for ${getAppTitle(context)}\n\n [Console]::OutputEncoding = [System.Text.Encoding]::UTF8\n function __${name.value}_debug {\n if ($env:BASH_COMP_DEBUG_FILE) {\n \"$args\" | Out-File -Append -FilePath \"$env:BASH_COMP_DEBUG_FILE\"\n }\n }\n\n filter __${name.value}_escapeStringWithSpecialChars {\n $_ -replace '\\\\s|#|@|\\\\$|;|,|''|\\\\{|\\\\}|\\\\(|\\\\)|\"|\\\\||<|>|&','\\\\\\`$&'\n }\n\n[scriptblock]$__${name.value}CompleterBlock = {\n param(\n $WordToComplete,\n $CommandAst,\n $CursorPosition\n )\n\n # Get the current command-line and convert into a string\n $Command = $CommandAst.CommandElements\n $Command = \"$Command\"\n\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= starting completion logic ==========\"\n __${name.value}_debug \"WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition\"\n\n # The user could have moved the cursor backwards on the command-line.\n # We need to trigger completion from the $CursorPosition location, so we need\n # to truncate the command-line ($Command) up to the $CursorPosition location.\n # Make sure the $Command is longer then the $CursorPosition before we truncate.\n # This happens because the $Command does not include the last space.\n if ($Command.Length -gt $CursorPosition) {\n $Command = $Command.Substring(0, $CursorPosition)\n }\n __${name.value}_debug \"Truncated command: $Command\"\n\n $ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}\n $ShellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}\n $ShellCompDirectiveNoFileComp=${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\n $ShellCompDirectiveFilterFileExt=${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\n $ShellCompDirectiveFilterDirs=${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\n $ShellCompDirectiveKeepOrder=${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n\n # Prepare the command to request completions for the program.\n # Split the command at the first space to separate the program and arguments.\n $Program, $Arguments = $Command.Split(\" \", 2)\n\n $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { \"'\" + ($_ -replace \"'\", \"''\") + \"'\" }) -join ' '\n __${name.value}_debug \"QuotedArgs: $QuotedArgs\"\n\n $RequestComp = \"& ${EXEC_COMMAND} complete '--' $QuotedArgs\"\n __${name.value}_debug \"RequestComp: $RequestComp\"\n\n # we cannot use $WordToComplete because it\n # has the wrong values if the cursor was moved\n # so use the last argument\n if ($WordToComplete -ne \"\" ) {\n $WordToComplete = $Arguments.Split(\" \")[-1]\n }\n __${name.value}_debug \"New WordToComplete: $WordToComplete\"\n\n\n # Check for flag with equal sign\n $IsEqualFlag = ($WordToComplete -Like \"--*=*\" )\n if ( $IsEqualFlag ) {\n __${name.value}_debug \"Completing equal sign flag\"\n # Remove the flag part\n $Flag, $WordToComplete = $WordToComplete.Split(\"=\", 2)\n }\n\n if ( $WordToComplete -eq \"\" -And ( -Not $IsEqualFlag )) {\n # If the last parameter is complete (there is a space following it)\n # We add an extra empty parameter so we can indicate this to the go method.\n __${name.value}_debug \"Adding extra empty parameter\"\n # PowerShell 7.2+ changed the way how the arguments are passed to executables,\n # so for pre-7.2 or when Legacy argument passing is enabled we need to use\n if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or\n ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled(\"PSNativeCommandArgumentPassing\")) -or\n (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled(\"PSNativeCommandArgumentPassing\")) -and\n $PSNativeCommandArgumentPassing -eq 'Legacy')) {\n $RequestComp=\"$RequestComp\" + ' \\\\\\`\"\\\\\\`\"'\n } else {\n $RequestComp = \"$RequestComp\" + ' \"\"'\n }\n }\n\n __${name.value}_debug \"Calling $RequestComp\"\n # First disable ActiveHelp which is not supported for Powershell\n $env:ActiveHelp = 0\n\n # call the command store the output in $out and redirect stderr and stdout to null\n # $Out is an array contains each line per element\n Invoke-Expression -OutVariable out \"$RequestComp\" 2>&1 | Out-Null\n\n # get directive from last line\n [int]$Directive = $Out[-1].TrimStart(':')\n if ($Directive -eq \"\") {\n # There is no directive specified\n $Directive = 0\n }\n __${name.value}_debug \"The completion directive is: $Directive\"\n\n # remove directive (last element) from out\n $Out = $Out | Where-Object { $_ -ne $Out[-1] }\n __${name.value}_debug \"The completions are: $Out\"\n if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {\n # Error code. No completion.\n __${name.value}_debug \"Received error from custom completion go code\"\n return\n }\n\n $Longest = 0\n [Array]$Values = $Out | ForEach-Object {\n # Split the output in name and description\n $Name, $Description = $_.Split(\"\\\\\\`t\", 2)\n __${name.value}_debug \"Name: $Name Description: $Description\"\n\n # Look for the longest completion so that we can format things nicely\n if ($Longest -lt $Name.Length) {\n $Longest = $Name.Length\n }\n\n # Set the description to a one space string if there is none set.\n # This is needed because the CompletionResult does not accept an empty string as argument\n if (-Not $Description) {\n $Description = \" \"\n }\n @{ Name = \"$Name\"; Description = \"$Description\" }\n }\n\n\n $Space = \" \"\n if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {\n # remove the space here\n __${name.value}_debug \"ShellCompDirectiveNoSpace is called\"\n $Space = \"\"\n }\n\n if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or\n (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {\n __${\n name.value\n }_debug \"ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported\"\n\n # return here to prevent the completion of the extensions\n return\n }\n\n $Values = $Values | Where-Object {\n # filter the result\n $_.Name -like \"$WordToComplete*\"\n\n # Join the flag back if we have an equal sign flag\n if ( $IsEqualFlag ) {\n __${\n name.value\n }_debug \"Join the equal sign flag back to the completion value\"\n $_.Name = $Flag + \"=\" + $_.Name\n }\n }\n\n # we sort the values in ascending order by name if keep order isn't passed\n if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {\n $Values = $Values | Sort-Object -Property Name\n }\n\n if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {\n __${name.value}_debug \"ShellCompDirectiveNoFileComp is called\"\n\n if ($Values.Length -eq 0) {\n # Just print an empty string here so the\n # shell does not start to complete paths.\n # We cannot use CompletionResult here because\n # it does not accept an empty string as argument.\n \"\"\n return\n }\n }\n\n # Get the current mode\n $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq \"Tab\" }).Function\n __${name.value}_debug \"Mode: $Mode\"\n\n $Values | ForEach-Object {\n\n # store temporary because switch will overwrite $_\n $comp = $_\n\n # PowerShell supports three different completion modes\n # - TabCompleteNext (default windows style - on each key press the next option is displayed)\n # - Complete (works like bash)\n # - MenuComplete (works like zsh)\n # You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>\n\n # CompletionResult Arguments:\n # 1) CompletionText text to be used as the auto completion result\n # 2) ListItemText text to be displayed in the suggestion list\n # 3) ResultType type of completion result\n # 4) ToolTip text for the tooltip with details about the object\n\n switch ($Mode) {\n\n # bash like\n \"Complete\" {\n\n if ($Values.Length -eq 1) {\n __${name.value}_debug \"Only one completion left\"\n\n # insert space after value\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${\n name.value\n }_escapeStringWithSpecialChars) + $Space, \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n\n } else {\n # Add the proper number of spaces to align the descriptions\n while($comp.Name.Length -lt $Longest) {\n $comp.Name = $comp.Name + \" \"\n }\n\n # Check for empty description and only add parentheses if needed\n if ($($comp.Description) -eq \" \" ) {\n $Description = \"\"\n } else {\n $Description = \" ($($comp.Description))\"\n }\n\n [System.Management.Automation.CompletionResult]::new(\"$($comp.Name)$Description\", \"$($comp.Name)$Description\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n\n # zsh like\n \"MenuComplete\" {\n # insert space after value\n # MenuComplete will automatically show the ToolTip of\n # the highlighted value at the bottom of the suggestions.\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${\n name.value\n }_escapeStringWithSpecialChars) + $Space, \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n\n # TabCompleteNext and in case we get something unknown\n Default {\n # Like MenuComplete but we don't want to add a space here because\n # the user need to press space anyway to get the completion.\n # Description will not be shown because that's not possible with TabCompleteNext\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${\n name.value\n }_escapeStringWithSpecialChars), \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n }\n}\n\nRegister-ArgumentCompleter -CommandName '${bin.value}' -ScriptBlock $__${\n name.value\n }CompleterBlock\n\\`; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS_DISPLAY\"\n initializer={code` SHELL_COMPLETIONS.split(\"\\\\n\").map(line => {\n if (!line.trim()) {\n return \"\";\n }\n if (line.trim().startsWith(\"#\")) {\n return \\`\\${dim(line)}\\`;\n }\n\n return white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, green(\"$&\"))\n .replaceAll(/\\\\\".*\\\\\"/g, cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|::new|::OutputEncoding|::UTF8)/g, bold(gray(\"$&\")))\n .replaceAll(/(switch|complete)\\\\s+/g, green(\"$&\"))\n .replaceAll(/(?<=(switch|complete)\\\\s+)\\\\w/g, bold(greenBright(\"$&\")))\n .replaceAll(/(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\\\w+)\\\\s+/g, red(\"$&\"))\n .replaceAll(/(?<=(Get-PSReadLineKeyHandler|Where-Object|ExperimentalFeature|Console|ScriptBlock|Array|ForEach-Object|Register-ArgumentCompleter|System.Management.Automation.CompletionResult|$\\\\w+)\\\\s+)\\\\w/g, bold(redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, bold(cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, green(\"$&\"))\n .replaceAll(/\\\\$?__\\\\w/g, bold(magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, bold(magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,SAAE,8BAAA;CACF,MAAO,UAAS,eAAA;CACd,MAAM,MAAA,eAAU,UAAc,QAAA,CAAA;;AAE9B,QAAM,gBAAmB,gBAAY;EACrC,IAAM,OAAO;;;EAGX,gBAAC,EACC,SAAM;GAAA;GAAS;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA,EAChB;EACD,IAAI,WAAC;AACH,UAAG;IAAA,gBAAW,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACZ,SAAQ;KACT,UAAA;KACD,MAAA;KACE,IAAA,cAAS;AACP,aAAO,IAAA,kCAAA,YAAA,QAAA,CAAA;;;iBAGD,KAAA,MAAA;;;;;;eAML,KAAS,MAAC;;;;kBAIb,KAAA,MAAA;;;;;;;;;;;QAWA,KAAK,MAAM;QACX,KAAA,MAAA;QACJ,KAAA,MAAA;;;;;;;;;;QAUI,KAAK,MAAA;;;iCAGiB,oBAAuB,2BAAC;oCAC3B,oBAAA,8BAAA;uCACH,oBAAA,iCAAA;;mCAEG,oBAAA,6BAAA;;;;;;;QAOrB,KAAK,MAAQ;;wBAEK,aAAK;QACrB,KAAC,MAAU;;;;;;;;QAQf,KAAA,MAAA;;;;;;YAMA,KAAA,MAAA;;;;;;;;;;;;;;;;;;;;;QAqBI,KAAK,MAAM;;;;;;;;;;;;;;QAcX,KAAI,MAAK;;;;QAIT,KAAK,MAAC;;;YAGF,KAAE,MAAA;;;;;;;;YAQL,KAAA,MAAa;;;;;;;;;;;;;;;;;;;YAmBV,KAAK,MAAM;;;;;;YAMb,KAAM,MAAI;;;;;;;;;;;;gBAYP,KAAA,MAAc;;;;;;;;;;;YAWvB,KAAA,MAAA;;;;;;;;;;;;;;QAcI,KAAG,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;wBAyBL,KAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;wFA2BO,KAAA,MAAA;;;;;;;;wFAQQ,KAAA,MAAA;;;;;;2CAMgB,IAAI,MAAK,oBAAA,KAAA,MAAA;;;KAG7C,CAAC;IAAE,gBAAkB,SAAS,EAAC,CAAA;IAAA,gBAAqB,gBAAgB;KACnE,UAAU;KACV,SAAS;KACT,MAAM;KACN,aAAa,IAAI;;;;;;;;;;;;;;;;;;;;;;KAsBlB,CAAC;IAAC;;EAEN,CAAC"}
@@ -1,4 +1,104 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@alloy-js/core/jsx-runtime`),t=require(`@shell-shock/core/plugin-utils`),n=require(`@alloy-js/core`),r=require(`@alloy-js/typescript`),i=require(`@powerlines/deepkit/vendor/type`),a=require(`@powerlines/plugin-alloy/core`),o=require(`@powerlines/plugin-alloy/core/contexts/context`),s=require(`@powerlines/plugin-alloy/typescript`),c=require(`@powerlines/plugin-alloy/typescript/components/tsdoc`),l=require(`@stryke/path`);function u(){let u=(0,o.usePowerlines)();return(0,e.createComponent)(s.TypescriptFile,{get path(){return(0,l.joinPaths)(u.entryPath,`completions`,`zsh`,`config`,`command.ts`)},imports:{"node:os":`os`,"node:path":[`join`],"node:fs/promises":[`readFile`,`writeFile`],"../shared":[`SHELL_COMPLETIONS`,`SHELL_COMPLETIONS_DISPLAY`]},builtinImports:{console:[`bold`,`inlineCode`,`writeLine`,`success`,`warn`,`help`]},get children(){return[(0,e.createComponent)(c.TSDoc,{heading:`Options for the Zsh Completions - Configuration command.`}),(0,e.createComponent)(r.InterfaceDeclaration,{export:!0,name:`ZshConfigCompletionsOptions`,get children(){return[(0,e.createComponent)(c.TSDoc,{heading:`Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.`,get children(){return(0,e.createComponent)(c.TSDocDefaultValue,{get type(){return i.ReflectionKind.boolean},defaultValue:!1})}}),(0,e.createComponent)(s.InterfaceMember,{name:`display`,optional:!0,type:`boolean`})]}}),(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(c.TSDoc,{heading:"Handler logic for the \\`completions zsh config\\` command."}),(0,e.createComponent)(r.FunctionDeclaration,{export:!0,default:!0,async:!0,name:`handler`,parameters:[{name:`options`,type:`ZshConfigCompletionsOptions`,default:`{}`},{name:`path`,type:`string`,default:`"~/.zshrc"`}],get children(){return[(0,e.createComponent)(r.IfStatement,{condition:n.code`options.display !== true`,get children(){return[(0,e.createComponent)(r.VarDeclaration,{let:!0,name:`configPath`,type:`string`,initializer:n.code` path.includes(".") ? path : join(path, ".zshrc");`}),(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(r.IfStatement,{condition:n.code`configPath.startsWith("~")`,children:n.code`configPath = join(os.homedir(), configPath.replace("~", "")); `}),(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(r.VarDeclaration,{let:!0,name:`content`,type:`string`,initializer:n.code`"";`}),(0,e.createComponent)(a.Spacing,{}),(0,e.memo)(()=>n.code`try {
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
3
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
4
+ let _alloy_js_core = require("@alloy-js/core");
5
+ let _alloy_js_typescript = require("@alloy-js/typescript");
6
+ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
7
+ let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
8
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
9
+ let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
10
+ let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
11
+ let _stryke_path = require("@stryke/path");
12
+
13
+ //#region src/components/zsh-config-command.tsx
14
+ /**
15
+ * The Zsh Completions - Configuration command's handler wrapper for the Shell Shock project.
16
+ */
17
+ function ZshConfigCompletionsCommand() {
18
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
19
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
20
+ get path() {
21
+ return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "zsh", "config", "command.ts");
22
+ },
23
+ imports: {
24
+ "node:os": "os",
25
+ "node:path": ["join"],
26
+ "node:fs/promises": ["readFile", "writeFile"],
27
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
28
+ },
29
+ builtinImports: { console: [
30
+ "bold",
31
+ "inlineCode",
32
+ "writeLine",
33
+ "success",
34
+ "warn",
35
+ "help"
36
+ ] },
37
+ get children() {
38
+ return [
39
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Zsh Completions - Configuration command." }),
40
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
41
+ "export": true,
42
+ name: "ZshConfigCompletionsOptions",
43
+ get children() {
44
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
45
+ heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
46
+ get children() {
47
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
48
+ get type() {
49
+ return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
50
+ },
51
+ defaultValue: false
52
+ });
53
+ }
54
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
55
+ name: "display",
56
+ optional: true,
57
+ type: "boolean"
58
+ })];
59
+ }
60
+ }),
61
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
62
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions zsh config\\` command." }),
63
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
64
+ "export": true,
65
+ "default": true,
66
+ async: true,
67
+ name: "handler",
68
+ parameters: [{
69
+ name: "options",
70
+ type: "ZshConfigCompletionsOptions",
71
+ default: "{}"
72
+ }, {
73
+ name: "path",
74
+ type: "string",
75
+ default: `"~/.zshrc"`
76
+ }],
77
+ get children() {
78
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
79
+ condition: _alloy_js_core.code`options.display !== true`,
80
+ get children() {
81
+ return [
82
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
83
+ "let": true,
84
+ name: "configPath",
85
+ type: "string",
86
+ initializer: _alloy_js_core.code` path.includes(".") ? path : join(path, ".zshrc");`
87
+ }),
88
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
89
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
90
+ condition: _alloy_js_core.code`configPath.startsWith("~")`,
91
+ children: _alloy_js_core.code`configPath = join(os.homedir(), configPath.replace("~", "")); `
92
+ }),
93
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
94
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
95
+ "let": true,
96
+ name: "content",
97
+ type: "string",
98
+ initializer: _alloy_js_core.code`"";`
99
+ }),
100
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
101
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
2
102
  content = await readFile(configPath, "utf8");
3
103
  } catch (error) {
4
104
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
@@ -9,15 +109,19 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
9
109
  }
10
110
  }
11
111
 
12
- await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0,t.getAppTitle)(u)} Shell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${(0,t.getAppTitle)(u)} Zsh Completions ###\`);
112
+ await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Shell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh Completions ###\`);
13
113
 
14
- success(\`${(0,t.getAppTitle)(u)} shell completions have been applied to Zsh configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)]}}),(0,e.createComponent)(r.ElseClause,{get children(){return n.code`writeLine(" ------------------------------------------------- ");
114
+ success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} shell completions have been applied to Zsh configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)
115
+ ];
116
+ }
117
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
118
+ return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
15
119
  writeLine("");
16
- writeLine(\`### Begin - ${(0,t.getAppTitle)(u)} Zsh Completions ###\`);
120
+ writeLine(\`### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh Completions ###\`);
17
121
  writeLine("");
18
122
  SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
19
123
  writeLine("");
20
- writeLine(\`### End - ${(0,t.getAppTitle)(u)} Zsh Completions ###\`);
124
+ writeLine(\`### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh Completions ###\`);
21
125
  writeLine("");
22
126
  writeLine(" ------------------------------------------------- ");
23
127
 
@@ -25,4 +129,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
25
129
  help(\`To enable these completions, perform one of the following actions:
26
130
 
27
131
  1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)
28
- 2) Save the above script to a file and source it from your shell configuration file \`); `}})]}})]}})}exports.ZshConfigCompletionsCommand=u;
132
+ 2) Save the above script to a file and source it from your shell configuration file \`); `;
133
+ } })];
134
+ }
135
+ })
136
+ ];
137
+ }
138
+ });
139
+ }
140
+
141
+ //#endregion
142
+ exports.ZshConfigCompletionsCommand = ZshConfigCompletionsCommand;
@@ -1,4 +1,103 @@
1
- import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{getAppTitle as n}from"@shell-shock/core/plugin-utils";import{code as r}from"@alloy-js/core";import{ElseClause as i,FunctionDeclaration as a,IfStatement as o,InterfaceDeclaration as s,VarDeclaration as c}from"@alloy-js/typescript";import{ReflectionKind as l}from"@powerlines/deepkit/vendor/type";import{Spacing as u}from"@powerlines/plugin-alloy/core";import{usePowerlines as d}from"@powerlines/plugin-alloy/core/contexts/context";import{InterfaceMember as f,TypescriptFile as p}from"@powerlines/plugin-alloy/typescript";import{TSDoc as m,TSDocDefaultValue as h}from"@powerlines/plugin-alloy/typescript/components/tsdoc";import{joinPaths as g}from"@stryke/path";function _(){let _=d();return e(p,{get path(){return g(_.entryPath,`completions`,`zsh`,`config`,`command.ts`)},imports:{"node:os":`os`,"node:path":[`join`],"node:fs/promises":[`readFile`,`writeFile`],"../shared":[`SHELL_COMPLETIONS`,`SHELL_COMPLETIONS_DISPLAY`]},builtinImports:{console:[`bold`,`inlineCode`,`writeLine`,`success`,`warn`,`help`]},get children(){return[e(m,{heading:`Options for the Zsh Completions - Configuration command.`}),e(s,{export:!0,name:`ZshConfigCompletionsOptions`,get children(){return[e(m,{heading:`Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.`,get children(){return e(h,{get type(){return l.boolean},defaultValue:!1})}}),e(f,{name:`display`,optional:!0,type:`boolean`})]}}),e(u,{}),e(m,{heading:"Handler logic for the \\`completions zsh config\\` command."}),e(a,{export:!0,default:!0,async:!0,name:`handler`,parameters:[{name:`options`,type:`ZshConfigCompletionsOptions`,default:`{}`},{name:`path`,type:`string`,default:`"~/.zshrc"`}],get children(){return[e(o,{condition:r`options.display !== true`,get children(){return[e(c,{let:!0,name:`configPath`,type:`string`,initializer:r` path.includes(".") ? path : join(path, ".zshrc");`}),e(u,{}),e(o,{condition:r`configPath.startsWith("~")`,children:r`configPath = join(os.homedir(), configPath.replace("~", "")); `}),e(u,{}),e(c,{let:!0,name:`content`,type:`string`,initializer:r`"";`}),e(u,{}),t(()=>r`try {
1
+ import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
2
+ import { getAppTitle } from "@shell-shock/core/plugin-utils";
3
+ import { code } from "@alloy-js/core";
4
+ import { ElseClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
5
+ import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
6
+ import { Spacing } from "@powerlines/plugin-alloy/core";
7
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
8
+ import { InterfaceMember as InterfaceMember$1, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
9
+ import { TSDoc as TSDoc$1, TSDocDefaultValue as TSDocDefaultValue$1 } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
10
+ import { joinPaths } from "@stryke/path";
11
+
12
+ //#region src/components/zsh-config-command.tsx
13
+ /**
14
+ * The Zsh Completions - Configuration command's handler wrapper for the Shell Shock project.
15
+ */
16
+ function ZshConfigCompletionsCommand() {
17
+ const context = usePowerlines();
18
+ return createComponent(TypescriptFile, {
19
+ get path() {
20
+ return joinPaths(context.entryPath, "completions", "zsh", "config", "command.ts");
21
+ },
22
+ imports: {
23
+ "node:os": "os",
24
+ "node:path": ["join"],
25
+ "node:fs/promises": ["readFile", "writeFile"],
26
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
27
+ },
28
+ builtinImports: { console: [
29
+ "bold",
30
+ "inlineCode",
31
+ "writeLine",
32
+ "success",
33
+ "warn",
34
+ "help"
35
+ ] },
36
+ get children() {
37
+ return [
38
+ createComponent(TSDoc$1, { heading: "Options for the Zsh Completions - Configuration command." }),
39
+ createComponent(InterfaceDeclaration, {
40
+ "export": true,
41
+ name: "ZshConfigCompletionsOptions",
42
+ get children() {
43
+ return [createComponent(TSDoc$1, {
44
+ heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
45
+ get children() {
46
+ return createComponent(TSDocDefaultValue$1, {
47
+ get type() {
48
+ return ReflectionKind.boolean;
49
+ },
50
+ defaultValue: false
51
+ });
52
+ }
53
+ }), createComponent(InterfaceMember$1, {
54
+ name: "display",
55
+ optional: true,
56
+ type: "boolean"
57
+ })];
58
+ }
59
+ }),
60
+ createComponent(Spacing, {}),
61
+ createComponent(TSDoc$1, { heading: "Handler logic for the \\`completions zsh config\\` command." }),
62
+ createComponent(FunctionDeclaration, {
63
+ "export": true,
64
+ "default": true,
65
+ async: true,
66
+ name: "handler",
67
+ parameters: [{
68
+ name: "options",
69
+ type: "ZshConfigCompletionsOptions",
70
+ default: "{}"
71
+ }, {
72
+ name: "path",
73
+ type: "string",
74
+ default: `"~/.zshrc"`
75
+ }],
76
+ get children() {
77
+ return [createComponent(IfStatement, {
78
+ condition: code`options.display !== true`,
79
+ get children() {
80
+ return [
81
+ createComponent(VarDeclaration, {
82
+ "let": true,
83
+ name: "configPath",
84
+ type: "string",
85
+ initializer: code` path.includes(".") ? path : join(path, ".zshrc");`
86
+ }),
87
+ createComponent(Spacing, {}),
88
+ createComponent(IfStatement, {
89
+ condition: code`configPath.startsWith("~")`,
90
+ children: code`configPath = join(os.homedir(), configPath.replace("~", "")); `
91
+ }),
92
+ createComponent(Spacing, {}),
93
+ createComponent(VarDeclaration, {
94
+ "let": true,
95
+ name: "content",
96
+ type: "string",
97
+ initializer: code`"";`
98
+ }),
99
+ createComponent(Spacing, {}),
100
+ memo(() => code`try {
2
101
  content = await readFile(configPath, "utf8");
3
102
  } catch (error) {
4
103
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
@@ -9,15 +108,19 @@ import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{ge
9
108
  }
10
109
  }
11
110
 
12
- await writeFile(configPath, \`\${content}\\n\\n### Begin - ${n(_)} Shell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${n(_)} Zsh Completions ###\`);
111
+ await writeFile(configPath, \`\${content}\\n\\n### Begin - ${getAppTitle(context)} Shell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${getAppTitle(context)} Zsh Completions ###\`);
13
112
 
14
- success(\`${n(_)} shell completions have been applied to Zsh configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)]}}),e(i,{get children(){return r`writeLine(" ------------------------------------------------- ");
113
+ success(\`${getAppTitle(context)} shell completions have been applied to Zsh configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)
114
+ ];
115
+ }
116
+ }), createComponent(ElseClause, { get children() {
117
+ return code`writeLine(" ------------------------------------------------- ");
15
118
  writeLine("");
16
- writeLine(\`### Begin - ${n(_)} Zsh Completions ###\`);
119
+ writeLine(\`### Begin - ${getAppTitle(context)} Zsh Completions ###\`);
17
120
  writeLine("");
18
121
  SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
19
122
  writeLine("");
20
- writeLine(\`### End - ${n(_)} Zsh Completions ###\`);
123
+ writeLine(\`### End - ${getAppTitle(context)} Zsh Completions ###\`);
21
124
  writeLine("");
22
125
  writeLine(" ------------------------------------------------- ");
23
126
 
@@ -25,5 +128,15 @@ import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{ge
25
128
  help(\`To enable these completions, perform one of the following actions:
26
129
 
27
130
  1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)
28
- 2) Save the above script to a file and source it from your shell configuration file \`); `}})]}})]}})}export{_ as ZshConfigCompletionsCommand};
131
+ 2) Save the above script to a file and source it from your shell configuration file \`); `;
132
+ } })];
133
+ }
134
+ })
135
+ ];
136
+ }
137
+ });
138
+ }
139
+
140
+ //#endregion
141
+ export { ZshConfigCompletionsCommand };
29
142
  //# sourceMappingURL=zsh-config-command.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"zsh-config-command.mjs","names":[],"sources":["../../src/components/zsh-config-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Zsh Completions - Configuration command's handler wrapper for the Shell Shock project.\n */\nexport function ZshConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"zsh\",\n \"config\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n console: [\"bold\", \"inlineCode\", \"writeLine\", \"success\", \"warn\", \"help\"]\n }}>\n <TSDoc heading=\"Options for the Zsh Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"ZshConfigCompletionsOptions\">\n <TSDoc heading=\"Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.\">\n <TSDocDefaultValue\n type={ReflectionKind.boolean}\n defaultValue={false}\n />\n </TSDoc>\n <InterfaceMember name=\"display\" optional type=\"boolean\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions zsh config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"ZshConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.zshrc\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n let\n name=\"configPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? path : join(path, \".zshrc\");`}\n />\n <Spacing />\n <IfStatement condition={code`configPath.startsWith(\"~\")`}>\n {code`configPath = join(os.homedir(), configPath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"content\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n content = await readFile(configPath, \"utf8\");\n } catch (error) {\n if (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${bold(configPath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configPath, \\`\\${content}\\\\n\\\\n### Begin - ${getAppTitle(context)} Shell Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} Zsh Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to Zsh configuration file at \\${bold(configPath)}. Please restart your terminal or run \\${inlineCode(\\`source \\${configPath}\\`)} for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\\`### Begin - ${getAppTitle(context)} Zsh Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} Zsh Completions ###\\`);\n writeLine(\"\");\n writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)\n 2) Save the above script to a file and source it from your shell configuration file \\`); `}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":"muBA+BA,SAAE,GAAA,CACA,IAAM,EAAC,GAAwB,CACjC,OAAO,EAAA,EAAA,CACL,IAAK,MAAA,CACL,OAAA,EAAA,EAAA,UAAA,cAAA,MAAA,SAAA,aAAA,EAEF,QAAS,CACH,UAAG,KACH,YAAQ,CAAA,OAAA,6CAEZ,YAAA,CAAA,oBAAA,4BAAA,CACC,CACD,eAAA,CACI,QAAS,CAAC,OAAA,aAAA,YAA8B,UAAA,OAAA,OAAA,CAC5C,gBAEA,MAAO,CAAA,EAAA,EAAA,CACJ,QAAA,2DACC,CAAA,CAAI,EAAW,EAAA,CACb,OAAQ,GACR,KAAC,8BACD,IAAI,UAAC,CACJ,MAAO,CAAA,EAAA,EAAA,CACP,QAAU,6LACZ,IAAA,UAAA,CACO,OAAC,EAAA,EAAA,CACC,IAAI,MAAG,CACL,OAAK,EAAM,SAEjB,aAAW,GAChB,CAAA,EAEC,CAAA,CAAA,EAAmB,EAAc,CACjC,KAAA,UACI,SAAU,GACf,KAAA,UACE,CAAA,CAAA,EAEF,CAAC,CAAE,EAAQ,EAAe,EAAA,CAAO,CAAA,EAAA,EAAA,CAChC,QAAI,8DACL,CAAC,CAAE,EAAC,EAAA,CACH,OAAO,GACP,QAAC,GACD,MAAA,GACD,KAAO,UACP,WAAa,CAAC,CACd,KAAA,UACC,KAAA,8BACA,QAAA,KACA,CAAA,CACA,KAAM,OACN,KAAA,SACE,QAAA,aACD,CAAC,CACF,IAAI,UAAO,CACT,MAAE,CAAA,EAAY,EAAA,CACb,UAAA,CAAA,2BACD,IAAA,UAAA,CACE,MAAO,CAAA,EAAK,EAAA,CACR,IAAG,GACP,KAAU,aACZ,KAAA,SACA,YAAA,CAAA,qDACD,CAAA,CAAA,EAA2B,EAAS,EAAA,CAAA,CAAA,EAAkB,EAAA,CACpD,UAAA,CAAA,6BACC,SAAA,CAAA,iEACA,CAAI,CAAE,EAAU,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACZ,IAAE,GACN,KAAA,UACD,KAAA,SACA,YAAS,CAAA,MACT,CAAA,CAAA,EAAuB,EAAK,EAAA,CAAA,CAAW,MAAa,CAAI;;;;;;;;;;;uEAW/C,EAAA,EAAA,CAAA,oEAAA,EAAA,EAAA,CAAA;;sBAED,EAAO,EAAA,CAAA,4MAAA,CAAA,EAEf,CAAC,CAAE,EAAe,EAAe,CAChC,IAAE,UAAO,CACP,MAAK,EAAA;;sCAEP,EAAA,EAAA,CAAA;;;;oCAIA,EAAA,EAAA,CAAA;;;;;;;;wGAUD,CAAC,CAAA,EAEL,CAAC,CAAC,EAEN,CAAC"}
1
+ {"version":3,"file":"zsh-config-command.mjs","names":[],"sources":["../../src/components/zsh-config-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Zsh Completions - Configuration command's handler wrapper for the Shell Shock project.\n */\nexport function ZshConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"zsh\",\n \"config\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n console: [\"bold\", \"inlineCode\", \"writeLine\", \"success\", \"warn\", \"help\"]\n }}>\n <TSDoc heading=\"Options for the Zsh Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"ZshConfigCompletionsOptions\">\n <TSDoc heading=\"Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.\">\n <TSDocDefaultValue\n type={ReflectionKind.boolean}\n defaultValue={false}\n />\n </TSDoc>\n <InterfaceMember name=\"display\" optional type=\"boolean\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions zsh config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"ZshConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.zshrc\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n let\n name=\"configPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? path : join(path, \".zshrc\");`}\n />\n <Spacing />\n <IfStatement condition={code`configPath.startsWith(\"~\")`}>\n {code`configPath = join(os.homedir(), configPath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"content\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n content = await readFile(configPath, \"utf8\");\n } catch (error) {\n if (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${bold(configPath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configPath, \\`\\${content}\\\\n\\\\n### Begin - ${getAppTitle(context)} Shell Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} Zsh Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to Zsh configuration file at \\${bold(configPath)}. Please restart your terminal or run \\${inlineCode(\\`source \\${configPath}\\`)} for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\\`### Begin - ${getAppTitle(context)} Zsh Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} Zsh Completions ###\\`);\n writeLine(\"\");\n writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)\n 2) Save the above script to a file and source it from your shell configuration file \\`); `}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,SAAE,8BAAA;CACA,MAAM,UAAC,eAAwB;AACjC,QAAO,gBAAA,gBAAA;EACL,IAAK,OAAA;AACL,UAAA,UAAA,QAAA,WAAA,eAAA,OAAA,UAAA,aAAA;;EAEF,SAAS;GACH,WAAG;GACH,aAAQ,CAAA,OAAA;;GAEZ,aAAA,CAAA,qBAAA,4BAAA;GACC;EACD,gBAAA,EACI,SAAS;GAAC;GAAA;GAAA;GAA8B;GAAA;GAAA;GAAA,EAC5C;;AAEA,UAAO;IAAA,gBAAA,SAAA,EACJ,SAAA,4DACC,CAAA;IAAI,gBAAW,sBAAA;KACb,UAAQ;KACR,MAAC;KACD,IAAI,WAAC;AACJ,aAAO,CAAA,gBAAA,SAAA;OACP,SAAU;OACZ,IAAA,WAAA;AACO,eAAC,gBAAA,qBAAA;SACC,IAAI,OAAG;AACL,iBAAK,eAAM;;SAEjB,cAAW;SAChB,CAAA;;OAEC,CAAA,EAAA,gBAAmB,mBAAc;OACjC,MAAA;OACI,UAAU;OACf,MAAA;OACE,CAAA,CAAA;;KAEF,CAAC;IAAE,gBAAQ,SAAe,EAAA,CAAO;IAAA,gBAAA,SAAA,EAChC,SAAI,+DACL,CAAC;IAAE,gBAAC,qBAAA;KACH,UAAO;KACP,WAAC;KACD,OAAA;KACD,MAAO;KACP,YAAa,CAAC;MACd,MAAA;MACC,MAAA;MACA,SAAA;MACA,EAAA;MACA,MAAM;MACN,MAAA;MACE,SAAA;MACD,CAAC;KACF,IAAI,WAAO;AACT,aAAE,CAAA,gBAAY,aAAA;OACb,WAAA,IAAA;OACD,IAAA,WAAA;AACE,eAAO;SAAA,gBAAK,gBAAA;UACR,OAAG;UACP,MAAU;UACZ,MAAA;UACA,aAAA,IAAA;UACD,CAAA;SAAA,gBAA2B,SAAS,EAAA,CAAA;SAAA,gBAAkB,aAAA;UACpD,WAAA,IAAA;UACC,UAAA,IAAA;UACA,CAAI;SAAE,gBAAU,SAAA,EAAA,CAAA;SAAA,gBAAA,gBAAA;UACZ,OAAE;UACN,MAAA;UACD,MAAA;UACA,aAAS,IAAA;UACT,CAAA;SAAA,gBAAuB,SAAK,EAAA,CAAA;SAAW,WAAa,IAAI;;;;;;;;;;;uEAW/C,YAAA,QAAA,CAAA,oEAAA,YAAA,QAAA,CAAA;;sBAED,YAAO,QAAA,CAAA,4MAAA;SAAA;;OAEf,CAAC,EAAE,gBAAe,YAAe,EAChC,IAAE,WAAO;AACP,cAAK,IAAA;;sCAEP,YAAA,QAAA,CAAA;;;;oCAIA,YAAA,QAAA,CAAA;;;;;;;;;SAUD,CAAC,CAAA;;KAEL,CAAC;IAAC;;EAEN,CAAC"}
@@ -1,11 +1,103 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@alloy-js/core/jsx-runtime`),t=require(`@shell-shock/core/plugin-utils`),n=require(`@alloy-js/core`),r=require(`@alloy-js/typescript`),i=require(`@powerlines/deepkit/vendor/type`),a=require(`@powerlines/plugin-alloy/core`),o=require(`@powerlines/plugin-alloy/core/contexts/context`),s=require(`@powerlines/plugin-alloy/typescript`),c=require(`@powerlines/plugin-alloy/typescript/components/tsdoc`),l=require(`@stryke/path`),u=require(`@stryke/string-format/snake-case`);function d(){let d=(0,o.usePowerlines)(),f=(0,n.computed)(()=>(0,t.getAppBin)(d)),p=(0,n.computed)(()=>(0,u.snakeCase)(f.value));return(0,e.createComponent)(s.TypescriptFile,{get path(){return(0,l.joinPaths)(d.entryPath,`completions`,`zsh`,`script`,`command.ts`)},imports:{"node:os":`os`,"node:path":[`join`],"node:fs/promises":[`readFile`,`writeFile`],"../shared":[`SHELL_COMPLETIONS`,`SHELL_COMPLETIONS_DISPLAY`]},builtinImports:{console:[`bold`,`writeLine`,`success`,`warn`,`help`]},get children(){return[(0,e.createComponent)(c.TSDoc,{heading:`Options for the Zsh Completions - Script command.`}),(0,e.createComponent)(r.InterfaceDeclaration,{export:!0,name:`ZshScriptCompletionsOptions`,get children(){return[(0,e.createComponent)(c.TSDoc,{heading:`Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.`,get children(){return(0,e.createComponent)(c.TSDocDefaultValue,{get type(){return i.ReflectionKind.boolean},defaultValue:!1})}}),(0,e.createComponent)(s.InterfaceMember,{name:`display`,optional:!0,type:`boolean`})]}}),(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(c.TSDoc,{heading:"Handler logic for the \\`completions zsh script\\` command."}),(0,e.createComponent)(r.FunctionDeclaration,{export:!0,default:!0,async:!0,name:`handler`,get parameters(){return[{name:`options`,type:`ZshScriptCompletionsOptions`,default:`{}`},{name:`path`,type:`string`,default:`"${f.value}-completions.zsh"`}]},get children(){return[(0,e.createComponent)(r.IfStatement,{condition:n.code`options.display !== true`,get children(){return[(0,e.createComponent)(r.VarDeclaration,{const:!0,name:`scriptPath`,type:`string`,initializer:n.code` path.includes(".") ? \`\${path}.zsh\` : path;`}),(0,e.memo)(()=>n.code`await writeFile(scriptPath, \`# Zsh script to add completions for ${(0,t.getAppTitle)(d)}\\n\\n\${SHELL_COMPLETIONS}\`);
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
3
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
4
+ let _alloy_js_core = require("@alloy-js/core");
5
+ let _alloy_js_typescript = require("@alloy-js/typescript");
6
+ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
7
+ let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
8
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
9
+ let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
10
+ let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
11
+ let _stryke_path = require("@stryke/path");
12
+ let _stryke_string_format_snake_case = require("@stryke/string-format/snake-case");
2
13
 
3
- success(\`${(0,t.getAppTitle)(d)} Zsh completion script has been generated at \${bold(scriptPath)}.\`);`)]}}),(0,e.createComponent)(r.ElseClause,{get children(){return n.code`writeLine(" ------------------------------------------------- ");
14
+ //#region src/components/zsh-script-command.tsx
15
+ /**
16
+ * The Zsh Completions - Script command's handler wrapper for the Shell Shock project.
17
+ */
18
+ function ZshScriptCompletionsCommand() {
19
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
20
+ const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
21
+ const name = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_snake_case.snakeCase)(bin.value));
22
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
23
+ get path() {
24
+ return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "zsh", "script", "command.ts");
25
+ },
26
+ imports: {
27
+ "node:os": "os",
28
+ "node:path": ["join"],
29
+ "node:fs/promises": ["readFile", "writeFile"],
30
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
31
+ },
32
+ builtinImports: { console: [
33
+ "bold",
34
+ "writeLine",
35
+ "success",
36
+ "warn",
37
+ "help"
38
+ ] },
39
+ get children() {
40
+ return [
41
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Zsh Completions - Script command." }),
42
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
43
+ "export": true,
44
+ name: "ZshScriptCompletionsOptions",
45
+ get children() {
46
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
47
+ heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
48
+ get children() {
49
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
50
+ get type() {
51
+ return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
52
+ },
53
+ defaultValue: false
54
+ });
55
+ }
56
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
57
+ name: "display",
58
+ optional: true,
59
+ type: "boolean"
60
+ })];
61
+ }
62
+ }),
63
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
64
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions zsh script\\` command." }),
65
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
66
+ "export": true,
67
+ "default": true,
68
+ async: true,
69
+ name: "handler",
70
+ get parameters() {
71
+ return [{
72
+ name: "options",
73
+ type: "ZshScriptCompletionsOptions",
74
+ default: "{}"
75
+ }, {
76
+ name: "path",
77
+ type: "string",
78
+ default: `"${bin.value}-completions.zsh"`
79
+ }];
80
+ },
81
+ get children() {
82
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
83
+ condition: _alloy_js_core.code`options.display !== true`,
84
+ get children() {
85
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
86
+ "const": true,
87
+ name: "scriptPath",
88
+ type: "string",
89
+ initializer: _alloy_js_core.code` path.includes(".") ? \`\${path}.zsh\` : path;`
90
+ }), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`await writeFile(scriptPath, \`# Zsh script to add completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
91
+
92
+ success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh completion script has been generated at \${bold(scriptPath)}.\`);`)];
93
+ }
94
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
95
+ return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
4
96
  writeLine("");
5
- writeLine("#compdef ${f.value} ");
6
- writeLine("#compdef _${p.value} ${f.value}");
97
+ writeLine("#compdef ${bin.value} ");
98
+ writeLine("#compdef _${name.value} ${bin.value}");
7
99
  writeLine("");
8
- writeLine("# Zsh completion for ${(0,t.getAppTitle)(d)}");
100
+ writeLine("# Zsh completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}");
9
101
  writeLine("");
10
102
  SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
11
103
  writeLine("");
@@ -15,4 +107,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
15
107
  help(\`To enable these completions, perform one of the following actions:
16
108
 
17
109
  1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)
18
- 2) Save the above script to a file and source it from your shell configuration file \`); `}})]}})]}})}exports.ZshScriptCompletionsCommand=d;
110
+ 2) Save the above script to a file and source it from your shell configuration file \`); `;
111
+ } })];
112
+ }
113
+ })
114
+ ];
115
+ }
116
+ });
117
+ }
118
+
119
+ //#endregion
120
+ exports.ZshScriptCompletionsCommand = ZshScriptCompletionsCommand;