@shell-shock/plugin-completions 0.2.23 → 0.3.0

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 (133) hide show
  1. package/README.md +1 -1
  2. package/dist/components/bash-config-command.cjs +132 -0
  3. package/dist/components/bash-config-command.d.cts +10 -0
  4. package/dist/components/bash-config-command.d.cts.map +1 -0
  5. package/dist/components/bash-config-command.d.mts +10 -0
  6. package/dist/components/bash-config-command.d.mts.map +1 -0
  7. package/dist/components/bash-config-command.mjs +132 -0
  8. package/dist/components/bash-config-command.mjs.map +1 -0
  9. package/dist/components/bash-script-command.cjs +106 -0
  10. package/dist/components/bash-script-command.d.cts +10 -0
  11. package/dist/components/bash-script-command.d.cts.map +1 -0
  12. package/dist/components/bash-script-command.d.mts +10 -0
  13. package/dist/components/bash-script-command.d.mts.map +1 -0
  14. package/dist/components/bash-script-command.mjs +106 -0
  15. package/dist/components/bash-script-command.mjs.map +1 -0
  16. package/dist/components/bash-shared.cjs +172 -0
  17. package/dist/components/bash-shared.d.cts +10 -0
  18. package/dist/components/bash-shared.d.cts.map +1 -0
  19. package/dist/components/bash-shared.d.mts +10 -0
  20. package/dist/components/bash-shared.d.mts.map +1 -0
  21. package/dist/components/bash-shared.mjs +172 -0
  22. package/dist/components/bash-shared.mjs.map +1 -0
  23. package/dist/components/fish-config-command.cjs +132 -0
  24. package/dist/components/fish-config-command.d.cts +10 -0
  25. package/dist/components/fish-config-command.d.cts.map +1 -0
  26. package/dist/components/fish-config-command.d.mts +10 -0
  27. package/dist/components/fish-config-command.d.mts.map +1 -0
  28. package/dist/components/fish-config-command.mjs +132 -0
  29. package/dist/components/fish-config-command.mjs.map +1 -0
  30. package/dist/components/fish-script-command.cjs +106 -0
  31. package/dist/components/fish-script-command.d.cts +10 -0
  32. package/dist/components/fish-script-command.d.cts.map +1 -0
  33. package/dist/components/fish-script-command.d.mts +10 -0
  34. package/dist/components/fish-script-command.d.mts.map +1 -0
  35. package/dist/components/fish-script-command.mjs +106 -0
  36. package/dist/components/fish-script-command.mjs.map +1 -0
  37. package/dist/components/fish-shared.cjs +303 -0
  38. package/dist/components/fish-shared.d.cts +10 -0
  39. package/dist/components/fish-shared.d.cts.map +1 -0
  40. package/dist/components/fish-shared.d.mts +10 -0
  41. package/dist/components/fish-shared.d.mts.map +1 -0
  42. package/dist/components/fish-shared.mjs +303 -0
  43. package/dist/components/fish-shared.mjs.map +1 -0
  44. package/dist/components/index.cjs +24 -8
  45. package/dist/components/index.d.cts +13 -5
  46. package/dist/components/index.d.mts +13 -5
  47. package/dist/components/index.mjs +13 -5
  48. package/dist/components/powershell-config-command.cjs +128 -0
  49. package/dist/components/powershell-config-command.d.cts +7 -0
  50. package/dist/components/powershell-config-command.d.cts.map +1 -0
  51. package/dist/components/powershell-config-command.d.mts +7 -0
  52. package/dist/components/powershell-config-command.d.mts.map +1 -0
  53. package/dist/components/powershell-config-command.mjs +128 -0
  54. package/dist/components/powershell-config-command.mjs.map +1 -0
  55. package/dist/components/powershell-script-command.cjs +106 -0
  56. package/dist/components/powershell-script-command.d.cts +10 -0
  57. package/dist/components/powershell-script-command.d.cts.map +1 -0
  58. package/dist/components/powershell-script-command.d.mts +10 -0
  59. package/dist/components/powershell-script-command.d.mts.map +1 -0
  60. package/dist/components/powershell-script-command.mjs +106 -0
  61. package/dist/components/powershell-script-command.mjs.map +1 -0
  62. package/dist/components/powershell-shared.cjs +319 -0
  63. package/dist/components/powershell-shared.d.cts +10 -0
  64. package/dist/components/powershell-shared.d.cts.map +1 -0
  65. package/dist/components/powershell-shared.d.mts +10 -0
  66. package/dist/components/powershell-shared.d.mts.map +1 -0
  67. package/dist/components/{powershell-command.mjs → powershell-shared.mjs} +81 -181
  68. package/dist/components/powershell-shared.mjs.map +1 -0
  69. package/dist/components/zsh-config-command.cjs +132 -0
  70. package/dist/components/zsh-config-command.d.cts +10 -0
  71. package/dist/components/zsh-config-command.d.cts.map +1 -0
  72. package/dist/components/zsh-config-command.d.mts +10 -0
  73. package/dist/components/zsh-config-command.d.mts.map +1 -0
  74. package/dist/components/zsh-config-command.mjs +132 -0
  75. package/dist/components/zsh-config-command.mjs.map +1 -0
  76. package/dist/components/zsh-script-command.cjs +111 -0
  77. package/dist/components/zsh-script-command.d.cts +10 -0
  78. package/dist/components/zsh-script-command.d.cts.map +1 -0
  79. package/dist/components/zsh-script-command.d.mts +10 -0
  80. package/dist/components/zsh-script-command.d.mts.map +1 -0
  81. package/dist/components/zsh-script-command.mjs +111 -0
  82. package/dist/components/zsh-script-command.mjs.map +1 -0
  83. package/dist/components/zsh-shared.cjs +281 -0
  84. package/dist/components/zsh-shared.d.cts +10 -0
  85. package/dist/components/zsh-shared.d.cts.map +1 -0
  86. package/dist/components/zsh-shared.d.mts +10 -0
  87. package/dist/components/zsh-shared.d.mts.map +1 -0
  88. package/dist/components/zsh-shared.mjs +281 -0
  89. package/dist/components/zsh-shared.mjs.map +1 -0
  90. package/dist/helpers/complete-command.cjs +2 -7
  91. package/dist/helpers/complete-command.d.cts +2 -2
  92. package/dist/helpers/complete-command.d.cts.map +1 -1
  93. package/dist/helpers/complete-command.d.mts +2 -2
  94. package/dist/helpers/complete-command.d.mts.map +1 -1
  95. package/dist/helpers/complete-command.mjs +2 -7
  96. package/dist/helpers/complete-command.mjs.map +1 -1
  97. package/dist/helpers/index.cjs +1 -1
  98. package/dist/helpers/index.d.cts +2 -2
  99. package/dist/helpers/index.d.mts +2 -2
  100. package/dist/helpers/index.mjs +2 -2
  101. package/dist/index.cjs +245 -59
  102. package/dist/index.d.cts.map +1 -1
  103. package/dist/index.d.mts.map +1 -1
  104. package/dist/index.mjs +246 -60
  105. package/dist/index.mjs.map +1 -1
  106. package/package.json +148 -37
  107. package/dist/components/bash-command.cjs +0 -273
  108. package/dist/components/bash-command.d.cts +0 -10
  109. package/dist/components/bash-command.d.cts.map +0 -1
  110. package/dist/components/bash-command.d.mts +0 -10
  111. package/dist/components/bash-command.d.mts.map +0 -1
  112. package/dist/components/bash-command.mjs +0 -273
  113. package/dist/components/bash-command.mjs.map +0 -1
  114. package/dist/components/fish-command.cjs +0 -403
  115. package/dist/components/fish-command.d.cts +0 -10
  116. package/dist/components/fish-command.d.cts.map +0 -1
  117. package/dist/components/fish-command.d.mts +0 -10
  118. package/dist/components/fish-command.d.mts.map +0 -1
  119. package/dist/components/fish-command.mjs +0 -403
  120. package/dist/components/fish-command.mjs.map +0 -1
  121. package/dist/components/powershell-command.cjs +0 -419
  122. package/dist/components/powershell-command.d.cts +0 -10
  123. package/dist/components/powershell-command.d.cts.map +0 -1
  124. package/dist/components/powershell-command.d.mts +0 -10
  125. package/dist/components/powershell-command.d.mts.map +0 -1
  126. package/dist/components/powershell-command.mjs.map +0 -1
  127. package/dist/components/zsh-command.cjs +0 -384
  128. package/dist/components/zsh-command.d.cts +0 -10
  129. package/dist/components/zsh-command.d.cts.map +0 -1
  130. package/dist/components/zsh-command.d.mts +0 -10
  131. package/dist/components/zsh-command.d.mts.map +0 -1
  132. package/dist/components/zsh-command.mjs +0 -384
  133. package/dist/components/zsh-command.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fish-shared.mjs","names":[],"sources":["../../src/components/fish-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 } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions generation for the Shell Shock project.\n */\nexport function FishCompletionsShared() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n const name = computed(() => snakeCase(bin.value));\n\n return (\n <TypescriptFile\n path={joinPaths(context.entryPath, \"completions\", \"fish\", \"shared.ts\")}\n builtinImports={{\n console: [\"colors\"]\n }}>\n <Spacing />\n <VarDeclaration\n const\n export\n name=\"SHELL_COMPLETIONS\"\n initializer={code` \\`function __${name.value}_debug\n set -l file \"$BASH_COMP_DEBUG_FILE\"\n if test -n \"$file\"\n echo \"$argv\" >> $file\n end\nend\n\nfunction __${name.value}_perform_completion\n __${name.value}_debug \"Starting __${name.value}_perform_completion\"\n\n # Extract all args except the last one\n set -l args (commandline -opc)\n # Extract the last arg and escape it in case it is a space or wildcard\n set -l lastArg (string escape -- (commandline -ct))\n\n __${name.value}_debug \"args: $args\"\n __${name.value}_debug \"last arg: $lastArg\"\n\n # Build the completion request command\n set -l requestComp \"${EXEC_COMMAND} complete -- (string join ' ' -- (string escape -- $args[2..-1])) $lastArg\"\n\n __${name.value}_debug \"Calling $requestComp\"\n set -l results (eval $requestComp 2> /dev/null)\n\n # Some programs may output extra empty lines after the directive.\n # Let's ignore them or else it will break completion.\n # Ref: https://github.com/spf13/cobra/issues/1279\n for line in $results[-1..1]\n if test (string trim -- $line) = \"\"\n # Found an empty line, remove it\n set results $results[1..-2]\n else\n # Found non-empty line, we have our proper output\n break\n end\n end\n\n set -l comps $results[1..-2]\n set -l directiveLine $results[-1]\n\n # For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)\n # completions must be prefixed with the flag\n set -l flagPrefix (string match -r -- '-.*=' \"$lastArg\")\n\n __${name.value}_debug \"Comps: $comps\"\n __${name.value}_debug \"DirectiveLine: $directiveLine\"\n __${name.value}_debug \"flagPrefix: $flagPrefix\"\n\n for comp in $comps\n printf \"%s%s\\\\n\" \"$flagPrefix\" \"$comp\"\n end\n\n printf \"%s\\\\n\" \"$directiveLine\"\nend\n\n# This function limits calls to __${\n name.value\n }_perform_completion, by caching the result\nfunction __${name.value}_perform_completion_once\n __${name.value}_debug \"Starting __${name.value}_perform_completion_once\"\n\n if test -n \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"Seems like a valid result already exists, skipping __${name.value}_perform_completion\"\n return 0\n end\n\n set --global __${name.value}_perform_completion_once_result (__${\n name.value\n }_perform_completion)\n if test -z \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"No completions, probably due to a failure\"\n return 1\n end\n\n __${name.value}_debug \"Performed completions and set __${\n name.value\n }_perform_completion_once_result\"\n return 0\nend\n\n# This function is used to clear the cached result after completions are run\nfunction __${name.value}_clear_perform_completion_once_result\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= clearing previously set __${\n name.value\n }_perform_completion_once_result variable ==========\"\n set --erase __${name.value}_perform_completion_once_result\n __${name.value}_debug \"Successfully erased the variable __${\n name.value\n }_perform_completion_once_result\"\nend\n\nfunction __${name.value}_requires_order_preservation\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= checking if order preservation is required ==========\"\n\n __${name.value}_perform_completion_once\n if test -z \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"Error determining if order preservation is required\"\n return 1\n end\n\n set -l directive (string sub --start 2 $__${\n name.value\n }_perform_completion_once_result[-1])\n __${name.value}_debug \"Directive is: $directive\"\n\n set -l shellCompDirectiveKeepOrder ${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)\n __${name.value}_debug \"Keeporder is: $keeporder\"\n\n if test $keeporder -ne 0\n __${name.value}_debug \"This does require order preservation\"\n return 0\n end\n\n __${name.value}_debug \"This doesn't require order preservation\"\n return 1\nend\n\n# This function does two things:\n# - Obtain the completions and store them in the global __${\n name.value\n }_comp_results\n# - Return false if file completion should be performed\nfunction __${name.value}_prepare_completions\n __${name.value}_debug \"\"\n __${name.value}_debug \"========= starting completion logic ==========\"\n\n # Start fresh\n set --erase __${name.value}_comp_results\n\n __${name.value}_perform_completion_once\n __${name.value}_debug \"Completion results: $__${\n name.value\n }_perform_completion_once_result\"\n\n if test -z \"$__${name.value}_perform_completion_once_result\"\n __${name.value}_debug \"No completion, probably due to a failure\"\n # Might as well do file completion, in case it helps\n return 1\n end\n\n set -l directive (string sub --start 2 $__${\n name.value\n }_perform_completion_once_result[-1])\n set --global __${name.value}_comp_results $__${\n name.value\n }_perform_completion_once_result[1..-2]\n\n __${name.value}_debug \"Completions are: $__${name.value}_comp_results\"\n __${name.value}_debug \"Directive is: $directive\"\n\n set -l shellCompDirectiveError ${\n CompletionDirective.CompletionDirectiveError\n }\n set -l shellCompDirectiveNoSpace ${\n CompletionDirective.CompletionDirectiveNoSpace\n }\n set -l shellCompDirectiveNoFileComp ${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\n set -l shellCompDirectiveFilterFileExt ${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\n set -l shellCompDirectiveFilterDirs ${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\n if test -z \"$directive\"\n set directive 0\n end\n\n set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)\n if test $compErr -eq 1\n __${name.value}_debug \"Received error directive: aborting.\"\n # Might as well do file completion, in case it helps\n return 1\n end\n\n set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)\n set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)\n if test $filefilter -eq 1; or test $dirfilter -eq 1\n __${name.value}_debug \"File extension filtering or directory filtering not supported\"\n # Do full file completion instead\n return 1\n end\n\n set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)\n set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)\n\n __${name.value}_debug \"nospace: $nospace, nofiles: $nofiles\"\n\n # If we want to prevent a space, or if file completion is NOT disabled,\n # we need to count the number of valid completions.\n # To do so, we will filter on prefix as the completions we have received\n # may not already be filtered so as to allow fish to match on different\n # criteria than the prefix.\n if test $nospace -ne 0; or test $nofiles -eq 0\n set -l prefix (commandline -t | string escape --style=regex)\n __${name.value}_debug \"prefix: $prefix\"\n\n set -l completions (string match -r -- \"^$prefix.*\" $__${\n name.value\n }_comp_results)\n set --global __${name.value}_comp_results $completions\n __${name.value}_debug \"Filtered completions are: $__${\n name.value\n }_comp_results\"\n\n # Important not to quote the variable for count to work\n set -l numComps (count $__${name.value}_comp_results)\n __${name.value}_debug \"numComps: $numComps\"\n\n if test $numComps -eq 1; and test $nospace -ne 0\n # We must first split on \\\\t to get rid of the descriptions to be\n # able to check what the actual completion will be.\n # We don't need descriptions anyway since there is only a single\n # real completion which the shell will expand immediately.\n set -l split (string split --max 1 \"\\\\t\" $__${\n name.value\n }_comp_results[1])\n\n # Fish won't add a space if the completion ends with any\n # of the following characters: @=/:.,\n set -l lastChar (string sub -s -1 -- $split)\n if not string match -r -q \"[@=/:.,]\" -- \"$lastChar\"\n # In other cases, to support the \"nospace\" directive we trick the shell\n # by outputting an extra, longer completion.\n __${name.value}_debug \"Adding second completion to perform nospace directive\"\n set --global __${name.value}_comp_results $split[1] $split[1].\n __${name.value}_debug \"Completions are now: $__${\n name.value\n }_comp_results\"\n end\n end\n\n if test $numComps -eq 0; and test $nofiles -eq 0\n # To be consistent with bash and zsh, we only trigger file\n # completion when there are no other completions\n __${name.value}_debug \"Requesting file completion\"\n return 1\n end\n end\n\n return 0\nend\n\n# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves\n# so we can properly delete any completions provided by another script.\n# Only do this if the program can be found, or else fish may print some errors; besides,\n# the existing completions will only be loaded if the program can be found.\nif type -q \"${bin.value}\"\n # The space after the program name is essential to trigger completion for the program\n # and not completion of the program name itself.\n # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.\n complete --do-complete \"${bin.value} \" > /dev/null 2>&1\nend\n\n# Remove any pre-existing completions for the program since we will be handling all of them.\ncomplete -c ${bin.value} -e\n# This will get called after the two calls below and clear the cached result\ncomplete -c ${bin.value} -n '__${name.value}_clear_perform_completion_once_result'\n# The call to __${name.value}_prepare_completions will setup __${\n name.value\n }_comp_results\n# which provides the program's completion choices.\n# If this doesn't require order preservation, we don't use the -k flag\ncomplete -c ${getAppBin(\n context\n )} -n 'not __${name.value}_requires_order_preservation && __${\n name.value\n }_prepare_completions' -f -a '$__${name.value}_comp_results'\n# Otherwise we use the -k flag\ncomplete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && __${\n name.value\n }_prepare_completions' -f -a '$__${name.value}_comp_results'\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 \\`\\${colors.dim(line)}\\`;\n }\n\n return colors.white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, colors.green(\"$&\"))\n .replaceAll(/(\\\\\"|\\\\').*(\\\\\"|\\\\')/g, colors.cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|:)/g, colors.bold(colors.gray(\"$&\")))\n .replaceAll(/(function|complete)\\\\s+/g, colors.green(\"$&\"))\n .replaceAll(/(?<=(function|complete)\\\\s+)\\\\w/g, colors.bold(colors.greenBright(\"$&\")))\n .replaceAll(/set\\\\s+/g, colors.red(\"$&\"))\n .replaceAll(/(?<=set\\\\s+)\\\\w/g, colors.bold(colors.redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, colors.cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, colors.bold(colors.cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, colors.green(\"$&\"))\n .replaceAll(/\\\\s__\\\\w/g, colors.bold(colors.magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, colors.bold(colors.magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkCA,SAAgB,wBAAgB;;CAE9B,MAAM,MAAM,eAAe,UAAU,QAAQ,CAAC;CAC9C,MAAM,OAAO,eAAe,UAAU,IAAI,MAAM,CAAC;;EAEjD,IAAM,OAAC;AACJ,UAAA,UAAA,QAAA,WAAA,eAAA,QAAA,YAAA;;EAED,gBAAgB,EACd,SAAS,CAAC,SAAS,EACpB;EACD,IAAG,WAAS;AACV,UAAC;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACC,SAAA;KACA,UAAA;KACA,MAAM;KACN,IAAA,cAAkB;AAChB,aAAO,IAAC,iBAAoB,KAAA,MAAA;;;;;;;aAOzB,KAAK,MAAC;;;;;;;;QAQX,KAAK,MAAM;;;;;;QAMX,KAAG,MAAQ;;;;;;;;;;;;;;;;;;;;;;;QAuBX,KAAK,MAAM;QACX,KAAK,MAAM;;;;;;;;;;oCAUJ,KAAA,MAAA;aACN,KAAA,MAAA;QACD,KAAK,MAAK,qBAAM,KAAA,MAAA;;;YAGZ,KAAK,MAAI,+DAA0C,KAAA,MAAA;;;;;qBAK1C,KAAK,MAAM;YACrB,KAAA,MAAA;;;;QAIH,KAAA,MAAO,0CAAA,KAAA,MAAA;;;;;aAKV,KAAA,MAAA;QACD,KAAO,MAAA;;;QAGJ,KAAA,MAAY,6CAAsC,KAAY,MAAI;;;aAG5D,KAAK,MAAC;QACb,KAAK,MAAA;QACN,KAAA,MAAA;;QAEG,KAAK,MAAM;qBACR,KAAA,MAAA;YACN,KAAA,MAAA;;;;gDAIsB,KAAA,MAAA;QACnB,KAAK,MAAM;;yCAEA,oBAAA,6BAAA;;QAEX,KAAI,MAAK;;;;;;;QAOT,KAAK,MAAM;;;;;4DAKsC,KAAA,MAAA;;;QAGlD,KAAM,MAAA;QACL,KAAI,MAAK;;;;;QAKb,KAAO,MAAA;;;qBAGU,KAAI,MAAM;YACpB,KAAI,MAAA;;;;;gDAKY,KAAA,MAAA;qBACR,KAAO,MAAM,mBAAc,KAAU,MAAM;;QAExD,KAAM,MAAA,8BAAA,KAAA,MAAA;QACJ,KAAE,MAAS;;qCAEA,oBAAA,yBAAA;uCACmB,oBAAa,2BAAA;0CACxC,oBAAA,8BAAA;6CACyB,oBAAA,iCAAA;;;;;;;;YAQzB,KAAA,MAAW;;;;;;;;YAQV,KAAC,MAAM;;;;;;;;QAQX,KAAG,MAAA;;;;;;;;;YASC,KAAK,MAAA;;iEAEb,KAAA,MAAA;;YAEO,KAAA,MAAS,uCAAmC,KAAA,MAAA;;;oCAGvB,KAAA,MAAe;YACvC,KAAO,MAAA;;;;;;;0DAOmB,KAAA,MAAA;;;;;;;;;iCASJ,KAAO,MAAM;oBAC1B,KAAM,MAAI,kCAA2B,KAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;8BAuB1B,IAAA,MAAY;;;;cAI3B,IAAA,MAAA;;cAEC,IAAI,MAAM,SAAO,KAAM,MAAO;kBAC3B,KAAI,MAAA,oCAA2B,KAAA,MAAA;;;cAGlC,UAAO,QAAW,CAAC,aAAY,KAAK,MAAO,oCAAyB,KAAA,MAAA,kCAAA,KAAA,MAAA;;iBAElE,IAAI,MAAK,SAAM,KAAQ,MAAO,oCAAqC,KAAA,MAAS,kCAAA,KAAA,MAAA;;;KAGrF,CAAC;IAAE,gBAAa,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACf,UAAS;KACT,SAAI;KACJ,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBR,CAAA"}
@@ -1,10 +1,26 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_components_bash_command = require('./bash-command.cjs');
3
- const require_components_fish_command = require('./fish-command.cjs');
4
- const require_components_powershell_command = require('./powershell-command.cjs');
5
- const require_components_zsh_command = require('./zsh-command.cjs');
2
+ const require_components_bash_config_command = require('./bash-config-command.cjs');
3
+ const require_components_bash_script_command = require('./bash-script-command.cjs');
4
+ const require_components_bash_shared = require('./bash-shared.cjs');
5
+ const require_components_fish_config_command = require('./fish-config-command.cjs');
6
+ const require_components_fish_script_command = require('./fish-script-command.cjs');
7
+ const require_components_fish_shared = require('./fish-shared.cjs');
8
+ const require_components_powershell_config_command = require('./powershell-config-command.cjs');
9
+ const require_components_powershell_script_command = require('./powershell-script-command.cjs');
10
+ const require_components_powershell_shared = require('./powershell-shared.cjs');
11
+ const require_components_zsh_config_command = require('./zsh-config-command.cjs');
12
+ const require_components_zsh_script_command = require('./zsh-script-command.cjs');
13
+ const require_components_zsh_shared = require('./zsh-shared.cjs');
6
14
 
7
- exports.BashCompletionsCommand = require_components_bash_command.BashCompletionsCommand;
8
- exports.FishCompletionsCommand = require_components_fish_command.FishCompletionsCommand;
9
- exports.PowerShellCompletionsCommand = require_components_powershell_command.PowerShellCompletionsCommand;
10
- exports.ZshCompletionsCommand = require_components_zsh_command.ZshCompletionsCommand;
15
+ exports.BashCompletionsShared = require_components_bash_shared.BashCompletionsShared;
16
+ exports.BashConfigCompletionsCommand = require_components_bash_config_command.BashConfigCompletionsCommand;
17
+ exports.BashScriptCompletionsCommand = require_components_bash_script_command.BashScriptCompletionsCommand;
18
+ exports.FishCompletionsShared = require_components_fish_shared.FishCompletionsShared;
19
+ exports.FishConfigCompletionsCommand = require_components_fish_config_command.FishConfigCompletionsCommand;
20
+ exports.FishScriptCompletionsCommand = require_components_fish_script_command.FishScriptCompletionsCommand;
21
+ exports.PowerShellCompletionsShared = require_components_powershell_shared.PowerShellCompletionsShared;
22
+ exports.PowerShellConfigCompletionsCommand = require_components_powershell_config_command.PowerShellConfigCompletionsCommand;
23
+ exports.PowerShellScriptCompletionsCommand = require_components_powershell_script_command.PowerShellScriptCompletionsCommand;
24
+ exports.ZshCompletionsShared = require_components_zsh_shared.ZshCompletionsShared;
25
+ exports.ZshConfigCompletionsCommand = require_components_zsh_config_command.ZshConfigCompletionsCommand;
26
+ exports.ZshScriptCompletionsCommand = require_components_zsh_script_command.ZshScriptCompletionsCommand;
@@ -1,5 +1,13 @@
1
- import { BashCompletionsCommand } from "./bash-command.cjs";
2
- import { FishCompletionsCommand } from "./fish-command.cjs";
3
- import { PowerShellCompletionsCommand } from "./powershell-command.cjs";
4
- import { ZshCompletionsCommand } from "./zsh-command.cjs";
5
- export { BashCompletionsCommand, FishCompletionsCommand, PowerShellCompletionsCommand, ZshCompletionsCommand };
1
+ import { BashConfigCompletionsCommand } from "./bash-config-command.cjs";
2
+ import { BashScriptCompletionsCommand } from "./bash-script-command.cjs";
3
+ import { BashCompletionsShared } from "./bash-shared.cjs";
4
+ import { FishConfigCompletionsCommand } from "./fish-config-command.cjs";
5
+ import { FishScriptCompletionsCommand } from "./fish-script-command.cjs";
6
+ import { FishCompletionsShared } from "./fish-shared.cjs";
7
+ import { PowerShellConfigCompletionsCommand } from "./powershell-config-command.cjs";
8
+ import { PowerShellScriptCompletionsCommand } from "./powershell-script-command.cjs";
9
+ import { PowerShellCompletionsShared } from "./powershell-shared.cjs";
10
+ import { ZshConfigCompletionsCommand } from "./zsh-config-command.cjs";
11
+ import { ZshScriptCompletionsCommand } from "./zsh-script-command.cjs";
12
+ import { ZshCompletionsShared } from "./zsh-shared.cjs";
13
+ export { BashCompletionsShared, BashConfigCompletionsCommand, BashScriptCompletionsCommand, FishCompletionsShared, FishConfigCompletionsCommand, FishScriptCompletionsCommand, PowerShellCompletionsShared, PowerShellConfigCompletionsCommand, PowerShellScriptCompletionsCommand, ZshCompletionsShared, ZshConfigCompletionsCommand, ZshScriptCompletionsCommand };
@@ -1,5 +1,13 @@
1
- import { BashCompletionsCommand } from "./bash-command.mjs";
2
- import { FishCompletionsCommand } from "./fish-command.mjs";
3
- import { PowerShellCompletionsCommand } from "./powershell-command.mjs";
4
- import { ZshCompletionsCommand } from "./zsh-command.mjs";
5
- export { BashCompletionsCommand, FishCompletionsCommand, PowerShellCompletionsCommand, ZshCompletionsCommand };
1
+ import { BashConfigCompletionsCommand } from "./bash-config-command.mjs";
2
+ import { BashScriptCompletionsCommand } from "./bash-script-command.mjs";
3
+ import { BashCompletionsShared } from "./bash-shared.mjs";
4
+ import { FishConfigCompletionsCommand } from "./fish-config-command.mjs";
5
+ import { FishScriptCompletionsCommand } from "./fish-script-command.mjs";
6
+ import { FishCompletionsShared } from "./fish-shared.mjs";
7
+ import { PowerShellConfigCompletionsCommand } from "./powershell-config-command.mjs";
8
+ import { PowerShellScriptCompletionsCommand } from "./powershell-script-command.mjs";
9
+ import { PowerShellCompletionsShared } from "./powershell-shared.mjs";
10
+ import { ZshConfigCompletionsCommand } from "./zsh-config-command.mjs";
11
+ import { ZshScriptCompletionsCommand } from "./zsh-script-command.mjs";
12
+ import { ZshCompletionsShared } from "./zsh-shared.mjs";
13
+ export { BashCompletionsShared, BashConfigCompletionsCommand, BashScriptCompletionsCommand, FishCompletionsShared, FishConfigCompletionsCommand, FishScriptCompletionsCommand, PowerShellCompletionsShared, PowerShellConfigCompletionsCommand, PowerShellScriptCompletionsCommand, ZshCompletionsShared, ZshConfigCompletionsCommand, ZshScriptCompletionsCommand };
@@ -1,6 +1,14 @@
1
- import { BashCompletionsCommand } from "./bash-command.mjs";
2
- import { FishCompletionsCommand } from "./fish-command.mjs";
3
- import { PowerShellCompletionsCommand } from "./powershell-command.mjs";
4
- import { ZshCompletionsCommand } from "./zsh-command.mjs";
1
+ import { BashConfigCompletionsCommand } from "./bash-config-command.mjs";
2
+ import { BashScriptCompletionsCommand } from "./bash-script-command.mjs";
3
+ import { BashCompletionsShared } from "./bash-shared.mjs";
4
+ import { FishConfigCompletionsCommand } from "./fish-config-command.mjs";
5
+ import { FishScriptCompletionsCommand } from "./fish-script-command.mjs";
6
+ import { FishCompletionsShared } from "./fish-shared.mjs";
7
+ import { PowerShellConfigCompletionsCommand } from "./powershell-config-command.mjs";
8
+ import { PowerShellScriptCompletionsCommand } from "./powershell-script-command.mjs";
9
+ import { PowerShellCompletionsShared } from "./powershell-shared.mjs";
10
+ import { ZshConfigCompletionsCommand } from "./zsh-config-command.mjs";
11
+ import { ZshScriptCompletionsCommand } from "./zsh-script-command.mjs";
12
+ import { ZshCompletionsShared } from "./zsh-shared.mjs";
5
13
 
6
- export { BashCompletionsCommand, FishCompletionsCommand, PowerShellCompletionsCommand, ZshCompletionsCommand };
14
+ export { BashCompletionsShared, BashConfigCompletionsCommand, BashScriptCompletionsCommand, FishCompletionsShared, FishConfigCompletionsCommand, FishScriptCompletionsCommand, PowerShellCompletionsShared, PowerShellConfigCompletionsCommand, PowerShellScriptCompletionsCommand, ZshCompletionsShared, ZshConfigCompletionsCommand, ZshScriptCompletionsCommand };
@@ -0,0 +1,128 @@
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 _stryke_path = require("@stryke/path");
11
+
12
+ //#region src/components/powershell-config-command.tsx
13
+ function PowerShellConfigCompletionsCommand() {
14
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
15
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
16
+ get path() {
17
+ return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "powershell", "config", "command.ts");
18
+ },
19
+ imports: {
20
+ "node:os": "os",
21
+ "node:path": ["join"],
22
+ "node:fs/promises": ["readFile", "writeFile"],
23
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
24
+ },
25
+ builtinImports: { "shell-shock:console": [
26
+ "colors",
27
+ "writeLine",
28
+ "success",
29
+ "warn"
30
+ ] },
31
+ get children() {
32
+ return [
33
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, { heading: "Options for the PowerShell Completions - Configuration command." }),
34
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
35
+ "export": true,
36
+ name: "PowerShellConfigCompletionsOptions",
37
+ get children() {
38
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, {
39
+ 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.",
40
+ get children() {
41
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDocDefaultValue, {
42
+ get type() {
43
+ return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
44
+ },
45
+ defaultValue: false
46
+ });
47
+ }
48
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
49
+ name: "display",
50
+ optional: true,
51
+ type: "boolean"
52
+ })];
53
+ }
54
+ }),
55
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
56
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, { heading: "Handler logic for the \\`completions powershell config\\` command." }),
57
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
58
+ "export": true,
59
+ "default": true,
60
+ async: true,
61
+ name: "handler",
62
+ parameters: [{
63
+ name: "options",
64
+ type: "PowerShellConfigCompletionsOptions",
65
+ default: "{}"
66
+ }, {
67
+ name: "path",
68
+ type: "string",
69
+ default: `"~/.config/powershell/Microsoft.PowerShell_profile.ps1"`
70
+ }],
71
+ get children() {
72
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
73
+ condition: _alloy_js_core.code`options.display !== true`,
74
+ get children() {
75
+ return [
76
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
77
+ "let": true,
78
+ name: "configPath",
79
+ type: "string",
80
+ initializer: _alloy_js_core.code` path.includes(".") ? path : join(path, "Microsoft.PowerShell_profile.ps1");`
81
+ }),
82
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
83
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
84
+ condition: _alloy_js_core.code`configPath.startsWith("~")`,
85
+ children: _alloy_js_core.code`configPath = join(os.homedir(), configPath.replace("~", "")); `
86
+ }),
87
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
88
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
89
+ "let": true,
90
+ name: "content",
91
+ type: "string",
92
+ initializer: _alloy_js_core.code`"";`
93
+ }),
94
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
95
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
96
+ content = await readFile(configPath, "utf8");
97
+ } catch (error) {
98
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
99
+ // If the file doesn't exist, we can create it later when writing the completion script.
100
+ warn(\`Configuration file \${colors.bold(configPath)} does not exist. It will be created when the completion script is written.\`);
101
+ } else {
102
+ return { error };
103
+ }
104
+ }
105
+
106
+ await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell Completions ###\`);
107
+
108
+ success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} shell completions have been applied to PowerShell configuration file at \${colors.bold(configPath)}. Please restart your terminal or run \\\`source \${configPath}\\\` for the changes to take effect.\`); `)
109
+ ];
110
+ }
111
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
112
+ return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
113
+ writeLine(\`### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell Completions ###\`);
114
+ writeLine("");
115
+ SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
116
+ writeLine("");
117
+ writeLine(\`### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell Completions ###\`);
118
+ writeLine(" ------------------------------------------------- ");`;
119
+ } })];
120
+ }
121
+ })
122
+ ];
123
+ }
124
+ });
125
+ }
126
+
127
+ //#endregion
128
+ exports.PowerShellConfigCompletionsCommand = PowerShellConfigCompletionsCommand;
@@ -0,0 +1,7 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/powershell-config-command.d.ts
4
+ declare function PowerShellConfigCompletionsCommand(): _$_alloy_js_core0.Children;
5
+ //#endregion
6
+ export { PowerShellConfigCompletionsCommand };
7
+ //# sourceMappingURL=powershell-config-command.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-config-command.d.cts","names":[],"sources":["../../src/components/powershell-config-command.tsx"],"mappings":";;;iBAuCgB,kCAAA,CAAA,GAAkC,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,7 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/powershell-config-command.d.ts
4
+ declare function PowerShellConfigCompletionsCommand(): _$_alloy_js_core0.Children;
5
+ //#endregion
6
+ export { PowerShellConfigCompletionsCommand };
7
+ //# sourceMappingURL=powershell-config-command.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-config-command.d.mts","names":[],"sources":["../../src/components/powershell-config-command.tsx"],"mappings":";;;iBAuCgB,kCAAA,CAAA,GAAkC,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,128 @@
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, InterfaceMember, 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 { TSDoc, TSDocDefaultValue, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
9
+ import { joinPaths } from "@stryke/path";
10
+
11
+ //#region src/components/powershell-config-command.tsx
12
+ function PowerShellConfigCompletionsCommand() {
13
+ const context = usePowerlines();
14
+ return createComponent(TypescriptFile, {
15
+ get path() {
16
+ return joinPaths(context.entryPath, "completions", "powershell", "config", "command.ts");
17
+ },
18
+ imports: {
19
+ "node:os": "os",
20
+ "node:path": ["join"],
21
+ "node:fs/promises": ["readFile", "writeFile"],
22
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
23
+ },
24
+ builtinImports: { "shell-shock:console": [
25
+ "colors",
26
+ "writeLine",
27
+ "success",
28
+ "warn"
29
+ ] },
30
+ get children() {
31
+ return [
32
+ createComponent(TSDoc, { heading: "Options for the PowerShell Completions - Configuration command." }),
33
+ createComponent(InterfaceDeclaration, {
34
+ "export": true,
35
+ name: "PowerShellConfigCompletionsOptions",
36
+ get children() {
37
+ return [createComponent(TSDoc, {
38
+ 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.",
39
+ get children() {
40
+ return createComponent(TSDocDefaultValue, {
41
+ get type() {
42
+ return ReflectionKind.boolean;
43
+ },
44
+ defaultValue: false
45
+ });
46
+ }
47
+ }), createComponent(InterfaceMember, {
48
+ name: "display",
49
+ optional: true,
50
+ type: "boolean"
51
+ })];
52
+ }
53
+ }),
54
+ createComponent(Spacing, {}),
55
+ createComponent(TSDoc, { heading: "Handler logic for the \\`completions powershell config\\` command." }),
56
+ createComponent(FunctionDeclaration, {
57
+ "export": true,
58
+ "default": true,
59
+ async: true,
60
+ name: "handler",
61
+ parameters: [{
62
+ name: "options",
63
+ type: "PowerShellConfigCompletionsOptions",
64
+ default: "{}"
65
+ }, {
66
+ name: "path",
67
+ type: "string",
68
+ default: `"~/.config/powershell/Microsoft.PowerShell_profile.ps1"`
69
+ }],
70
+ get children() {
71
+ return [createComponent(IfStatement, {
72
+ condition: code`options.display !== true`,
73
+ get children() {
74
+ return [
75
+ createComponent(VarDeclaration, {
76
+ "let": true,
77
+ name: "configPath",
78
+ type: "string",
79
+ initializer: code` path.includes(".") ? path : join(path, "Microsoft.PowerShell_profile.ps1");`
80
+ }),
81
+ createComponent(Spacing, {}),
82
+ createComponent(IfStatement, {
83
+ condition: code`configPath.startsWith("~")`,
84
+ children: code`configPath = join(os.homedir(), configPath.replace("~", "")); `
85
+ }),
86
+ createComponent(Spacing, {}),
87
+ createComponent(VarDeclaration, {
88
+ "let": true,
89
+ name: "content",
90
+ type: "string",
91
+ initializer: code`"";`
92
+ }),
93
+ createComponent(Spacing, {}),
94
+ memo(() => code`try {
95
+ content = await readFile(configPath, "utf8");
96
+ } catch (error) {
97
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
98
+ // If the file doesn't exist, we can create it later when writing the completion script.
99
+ warn(\`Configuration file \${colors.bold(configPath)} does not exist. It will be created when the completion script is written.\`);
100
+ } else {
101
+ return { error };
102
+ }
103
+ }
104
+
105
+ await writeFile(configPath, \`\${content}\\n\\n### Begin - ${getAppTitle(context)} PowerShell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${getAppTitle(context)} PowerShell Completions ###\`);
106
+
107
+ success(\`${getAppTitle(context)} shell completions have been applied to PowerShell configuration file at \${colors.bold(configPath)}. Please restart your terminal or run \\\`source \${configPath}\\\` for the changes to take effect.\`); `)
108
+ ];
109
+ }
110
+ }), createComponent(ElseClause, { get children() {
111
+ return code`writeLine(" ------------------------------------------------- ");
112
+ writeLine(\`### Begin - ${getAppTitle(context)} PowerShell Completions ###\`);
113
+ writeLine("");
114
+ SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
115
+ writeLine("");
116
+ writeLine(\`### End - ${getAppTitle(context)} PowerShell Completions ###\`);
117
+ writeLine(" ------------------------------------------------- ");`;
118
+ } })];
119
+ }
120
+ })
121
+ ];
122
+ }
123
+ });
124
+ }
125
+
126
+ //#endregion
127
+ export { PowerShellConfigCompletionsCommand };
128
+ //# sourceMappingURL=powershell-config-command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-config-command.mjs","names":[],"sources":["../../src/components/powershell-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 InterfaceMember,\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 TSDoc,\n TSDocDefaultValue,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types\";\n\nexport function PowerShellConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"powershell\",\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 \"shell-shock:console\": [\"colors\", \"writeLine\", \"success\", \"warn\"]\n }}>\n <TSDoc heading=\"Options for the PowerShell Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"PowerShellConfigCompletionsOptions\">\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 powershell config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"PowerShellConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.config/powershell/Microsoft.PowerShell_profile.ps1\"`\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, \"Microsoft.PowerShell_profile.ps1\");`}\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 \\${colors.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)} PowerShell Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} PowerShell Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to PowerShell configuration file at \\${colors.bold(configPath)}. Please restart your terminal or run \\\\\\`source \\${configPath}\\\\\\` for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\\`### Begin - ${getAppTitle(context)} PowerShell Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} PowerShell Completions ###\\`);\n writeLine(\" ------------------------------------------------- \");`}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;AA4BA,SAAgB,qCAAkC;CAClD,MAAQ,UAAC,eAA+C;AACxD,QAAO,gBAAA,gBAAA;EACL,IAAK,OAAA;AACL,UAAA,UAAiB,QAAA,WAAA,eAAA,cAAA,UAAA,aAAA;;EAEjB,SAAO;GACH,WAAG;GACH,aAAa,CAAC,OAAO;GACrB,oBAAQ,CAAA,YAAyB,YAAW;;GAElD;EACE,gBAAgB;;;;;KAEhB;EACE,IAAC,WAAA;AACC,UAAM;IAAA,gBAAS,OAAA,EACb,SAAQ,mEACT,CAAC;IAAC,gBAAY,sBAAA;KACb,UAAC;KACD,MAAC;KACD,IAAC,WAAU;AACZ,aAAA,CAAA,gBAAA,OAAA;OACD,SAAS;OACN,IAAO,WAAO;AACT,eAAO,gBAAQ,mBAAA;SACb,IAAC,OAAU;AACT,iBAAK,eAAiB;;SAElC,cAAgB;SACP,CAAA;;OAER,CAAK,EAAC,gBAAiB,iBAAmB;OAC1C,MAAA;OACE,UAAa;OACX,MAAA;OACA,CAAC,CAAA;;KAEL,CAAC;IAAE,gBAAC,SAAA,EAAA,CAAA;IAAA,gBAAA,OAAA,EACH,SAAO,sEACR,CAAC;IAAC,gBAAgB,qBAAwB;KACzC,UAAA;KACD,WAAS;KACT,OAAM;KACN,MAAA;KACC,YAAA,CAAA;MACA,MAAA;MACA,MAAA;MACA,SAAM;MACN,EAAA;MACE,MAAA;MACA,MAAM;MACN,SAAS;MACV,CAAC;KACF,IAAG,WAAA;AACD,aAAA,CAAA,gBAAA,aAAA;OACE,WAAW,IAAC;OACZ,IAAI,WAAU;AACd,eAAS;SAAC,gBAAW,gBAAqB;UAC5C,OAAA;UACA,MAAA;UACD,MAAY;UACV,aAAA,IAAA;UACC,CAAA;SAAA,gBAAA,SAAA,EAAA,CAAA;SAAA,gBAAA,aAAA;UACI,WAAE,IAAU;UACZ,UAAQ,IAAA;UACZ,CAAA;SAAA,gBAAwB,SAAS,EAAE,CAAC;SAAE,gBAAkB,gBAAa;UACtE,OAAA;UACA,MAAS;UACT,MAAW;UACT,aAAgB,IAAE;UACnB,CAAA;SAAA,gBAAW,SAAA,EAAA,CAAA;SAAA,WAAA,IAAA;;;;;;;;;;;uEAWG,YAAA,QAAA,CAAA,yEAAA,YAAA,QAAA,CAAA;;sBAEN,YAAc,QAAQ,CAAC,8MAA0D;SAAA;;OAE1F,CAAC,EAAE,gBAAK,YAAA,EACP,IAAE,WAAS;AACX,cAAA,IAAA;sCACF,YAAA,QAAA,CAAA;;;;oCAI0B,YAAM,QAAA,CAAA;;SAG/B,CAAC,CAAA;;KAEL,CAAC;IAAC;;EAEN,CAAC"}
@@ -0,0 +1,106 @@
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/powershell-script-command.tsx
14
+ /**
15
+ * The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
16
+ */
17
+ function PowerShellScriptCompletionsCommand() {
18
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
19
+ const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
20
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
21
+ get path() {
22
+ return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "powershell", "script", "command.ts");
23
+ },
24
+ imports: {
25
+ "node:os": "os",
26
+ "node:path": ["join"],
27
+ "node:fs/promises": ["readFile", "writeFile"],
28
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
29
+ },
30
+ builtinImports: { "shell-shock:console": [
31
+ "colors",
32
+ "writeLine",
33
+ "success",
34
+ "warn"
35
+ ] },
36
+ get children() {
37
+ return [
38
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the PowerShell Completions - Script command." }),
39
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
40
+ "export": true,
41
+ name: "PowerShellScriptCompletionsOptions",
42
+ get children() {
43
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
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 (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
47
+ get type() {
48
+ return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
49
+ },
50
+ defaultValue: false
51
+ });
52
+ }
53
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
54
+ name: "display",
55
+ optional: true,
56
+ type: "boolean"
57
+ })];
58
+ }
59
+ }),
60
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
61
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions powershell script\\` command." }),
62
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
63
+ "export": true,
64
+ "default": true,
65
+ async: true,
66
+ name: "handler",
67
+ get parameters() {
68
+ return [{
69
+ name: "options",
70
+ type: "PowerShellScriptCompletionsOptions",
71
+ default: "{}"
72
+ }, {
73
+ name: "path",
74
+ type: "string",
75
+ default: `"${bin.value}-completions.ps1"`
76
+ }];
77
+ },
78
+ get children() {
79
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
80
+ condition: _alloy_js_core.code`options.display !== true`,
81
+ get children() {
82
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
83
+ "const": true,
84
+ name: "scriptPath",
85
+ type: "string",
86
+ initializer: _alloy_js_core.code` path.includes(".") ? \`\${path}.ps1\` : path;`
87
+ }), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`await writeFile(scriptPath, \`# PowerShell script to add completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
88
+
89
+ success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell completion script has been generated at \${colors.bold(scriptPath)}.\`);`)];
90
+ }
91
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
92
+ return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
93
+ writeLine(\`# PowerShell completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\`);
94
+ writeLine("");
95
+ SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
96
+ writeLine(" ------------------------------------------------- ");`;
97
+ } })];
98
+ }
99
+ })
100
+ ];
101
+ }
102
+ });
103
+ }
104
+
105
+ //#endregion
106
+ exports.PowerShellScriptCompletionsCommand = PowerShellScriptCompletionsCommand;
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/powershell-script-command.d.ts
4
+ /**
5
+ * The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function PowerShellScriptCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { PowerShellScriptCompletionsCommand };
10
+ //# sourceMappingURL=powershell-script-command.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-script-command.d.cts","names":[],"sources":["../../src/components/powershell-script-command.tsx"],"mappings":";;;;;;iBA4CgB,kCAAA,CAAA,GAAkC,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/powershell-script-command.d.ts
4
+ /**
5
+ * The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function PowerShellScriptCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { PowerShellScriptCompletionsCommand };
10
+ //# sourceMappingURL=powershell-script-command.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-script-command.d.mts","names":[],"sources":["../../src/components/powershell-script-command.tsx"],"mappings":";;;;;;iBA4CgB,kCAAA,CAAA,GAAkC,iBAAA,CAAA,QAAA"}