@shell-shock/plugin-completions 0.2.24 → 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 (117) 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-command.cjs → fish-shared.cjs} +40 -144
  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-command.mjs → fish-shared.mjs} +45 -149
  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-command.cjs → powershell-shared.cjs} +40 -146
  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} +44 -150
  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-command.cjs → zsh-shared.cjs} +41 -147
  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-command.mjs → zsh-shared.mjs} +45 -151
  89. package/dist/components/zsh-shared.mjs.map +1 -0
  90. package/dist/index.cjs +232 -68
  91. package/dist/index.d.cts.map +1 -1
  92. package/dist/index.d.mts.map +1 -1
  93. package/dist/index.mjs +232 -68
  94. package/dist/index.mjs.map +1 -1
  95. package/package.json +148 -36
  96. package/dist/components/bash-command.cjs +0 -276
  97. package/dist/components/bash-command.d.cts +0 -10
  98. package/dist/components/bash-command.d.cts.map +0 -1
  99. package/dist/components/bash-command.d.mts +0 -10
  100. package/dist/components/bash-command.d.mts.map +0 -1
  101. package/dist/components/bash-command.mjs +0 -276
  102. package/dist/components/bash-command.mjs.map +0 -1
  103. package/dist/components/fish-command.d.cts +0 -10
  104. package/dist/components/fish-command.d.cts.map +0 -1
  105. package/dist/components/fish-command.d.mts +0 -10
  106. package/dist/components/fish-command.d.mts.map +0 -1
  107. package/dist/components/fish-command.mjs.map +0 -1
  108. package/dist/components/powershell-command.d.cts +0 -10
  109. package/dist/components/powershell-command.d.cts.map +0 -1
  110. package/dist/components/powershell-command.d.mts +0 -10
  111. package/dist/components/powershell-command.d.mts.map +0 -1
  112. package/dist/components/powershell-command.mjs.map +0 -1
  113. package/dist/components/zsh-command.d.cts +0 -10
  114. package/dist/components/zsh-command.d.cts.map +0 -1
  115. package/dist/components/zsh-command.d.mts +0 -10
  116. package/dist/components/zsh-command.d.mts.map +0 -1
  117. package/dist/components/zsh-command.mjs.map +0 -1
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/fish-shared.d.ts
4
+ /**
5
+ * The Fish Completions generation for the Shell Shock project.
6
+ */
7
+ declare function FishCompletionsShared(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { FishCompletionsShared };
10
+ //# sourceMappingURL=fish-shared.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fish-shared.d.cts","names":[],"sources":["../../src/components/fish-shared.tsx"],"mappings":";;;;;;iBAiCgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/fish-shared.d.ts
4
+ /**
5
+ * The Fish Completions generation for the Shell Shock project.
6
+ */
7
+ declare function FishCompletionsShared(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { FishCompletionsShared };
10
+ //# sourceMappingURL=fish-shared.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fish-shared.d.mts","names":[],"sources":["../../src/components/fish-shared.tsx"],"mappings":";;;;;;iBAiCgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA"}
@@ -1,108 +1,38 @@
1
1
  import { EXEC_COMMAND } from "../helpers/complete-command.mjs";
2
2
  import { CompletionDirective } from "../helpers/completion-directive-constants.mjs";
3
- import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
4
- import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
3
+ import "../helpers/index.mjs";
4
+ import { createComponent } from "@alloy-js/core/jsx-runtime";
5
+ import { getAppBin } from "@shell-shock/core/plugin-utils";
5
6
  import { code, computed } from "@alloy-js/core";
6
- import { FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
7
- import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
7
+ import { VarDeclaration } from "@alloy-js/typescript";
8
8
  import { Spacing } from "@powerlines/plugin-alloy/core";
9
9
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
10
- import { InterfaceMember, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
11
- import { TSDoc, TSDocDefaultValue, TSDocRemarks } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
10
+ import { TypescriptFile } from "@powerlines/plugin-alloy/typescript";
12
11
  import { joinPaths } from "@stryke/path";
13
12
  import { snakeCase } from "@stryke/string-format/snake-case";
14
13
 
15
- //#region src/components/fish-command.tsx
14
+ //#region src/components/fish-shared.tsx
16
15
  /**
17
- * The Fish Completions commands' handler wrapper for the Shell Shock project.
16
+ * The Fish Completions generation for the Shell Shock project.
18
17
  */
19
- function FishCompletionsCommand() {
18
+ function FishCompletionsShared() {
20
19
  const context = usePowerlines();
21
20
  const bin = computed(() => getAppBin(context));
22
21
  const name = computed(() => snakeCase(bin.value));
23
22
  return createComponent(TypescriptFile, {
24
23
  get path() {
25
- return joinPaths(context.entryPath, "completions", "fish", "command.ts");
24
+ return joinPaths(context.entryPath, "completions", "fish", "shared.ts");
26
25
  },
27
- imports: {
28
- "node:os": "os",
29
- "node:path": ["join"],
30
- "node:fs/promises": ["readFile", "writeFile"]
31
- },
32
- builtinImports: { "shell-shock:console": [
33
- "colors",
34
- "writeLine",
35
- "success",
36
- "warn",
37
- "stripAnsi"
38
- ] },
26
+ builtinImports: { console: ["colors"] },
39
27
  get children() {
40
28
  return [
41
- createComponent(TSDoc, { heading: "Options for the Fish completions command." }),
42
- createComponent(InterfaceDeclaration, {
43
- "export": true,
44
- name: "FishCompletionsOptions",
45
- get children() {
46
- return [
47
- createComponent(TSDoc, {
48
- heading: "The path to write the completion script to.",
49
- get children() {
50
- return [createComponent(TSDocRemarks, { children: `If no extension is provided, the \`.fish\` extension will be used.` }), createComponent(TSDocDefaultValue, {
51
- get type() {
52
- return ReflectionKind.string;
53
- },
54
- get defaultValue() {
55
- return `${bin.value}-completions.fish`;
56
- }
57
- })];
58
- }
59
- }),
60
- createComponent(InterfaceMember, {
61
- name: "script",
62
- optional: true,
63
- type: "string | true"
64
- }),
65
- createComponent(Spacing, {}),
66
- createComponent(TSDoc, {
67
- heading: "The Fish configuration file to append the completion script to.",
68
- get children() {
69
- return [createComponent(TSDocRemarks, { children: `The generated completion script will be appended to the specified configuration file. Possible values for the Fish configuration file include: \\n- \`~/.config/fish/config.fish\`` }), createComponent(TSDocDefaultValue, {
70
- get type() {
71
- return ReflectionKind.string;
72
- },
73
- defaultValue: "~/.config/fish/config.fish"
74
- })];
75
- }
76
- }),
77
- createComponent(InterfaceMember, {
78
- name: "config",
79
- optional: true,
80
- type: "string | true"
81
- })
82
- ];
83
- }
84
- }),
85
29
  createComponent(Spacing, {}),
86
- createComponent(TSDoc, { heading: "Handler logic for the \\`completions fish\\` command." }),
87
- createComponent(FunctionDeclaration, {
30
+ createComponent(VarDeclaration, {
31
+ "const": true,
88
32
  "export": true,
89
- "default": true,
90
- async: true,
91
- name: "handler",
92
- parameters: [{
93
- name: "options",
94
- type: "FishCompletionsOptions"
95
- }],
96
- get children() {
97
- return [
98
- createComponent(VarDeclaration, {
99
- "const": true,
100
- name: "completions",
101
- type: "string",
102
- get initializer() {
103
- return code` \`# fish completion for ${getAppTitle(context)} -*- shell-script -*-
104
-
105
- function __${name.value}_debug
33
+ name: "SHELL_COMPLETIONS",
34
+ get initializer() {
35
+ return code` \`function __${name.value}_debug
106
36
  set -l file "$BASH_COMP_DEBUG_FILE"
107
37
  if test -n "$file"
108
38
  echo "$argv" >> $file
@@ -194,8 +124,7 @@ function __${name.value}_requires_order_preservation
194
124
  return 1
195
125
  end
196
126
 
197
- set -l directive (string sub --start 2 $__$
198
- {name.value}_perform_completion_once_result[-1])
127
+ set -l directive (string sub --start 2 $__${name.value}_perform_completion_once_result[-1])
199
128
  __${name.value}_debug "Directive is: $directive"
200
129
 
201
130
  set -l shellCompDirectiveKeepOrder ${CompletionDirective.CompletionDirectiveKeepOrder}
@@ -334,68 +263,35 @@ complete -c ${getAppBin(context)} -n 'not __${name.value}_requires_order_preserv
334
263
  # Otherwise we use the -k flag
335
264
  complete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && __${name.value}_prepare_completions' -f -a '$__${name.value}_comp_results'
336
265
  \`; `;
337
- }
338
- }),
339
- createComponent(Spacing, {}),
340
- createComponent(IfStatement, {
341
- condition: code`options.config`,
342
- get children() {
343
- return [
344
- createComponent(VarDeclaration, {
345
- "let": true,
346
- name: "configFilePath",
347
- type: "string",
348
- initializer: code`options.config === true ? "~/.config/fish/config.fish" : options.config`
349
- }),
350
- createComponent(Spacing, {}),
351
- createComponent(IfStatement, {
352
- condition: code`configFilePath.startsWith("~")`,
353
- children: code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
354
- }),
355
- createComponent(Spacing, {}),
356
- createComponent(VarDeclaration, {
357
- "let": true,
358
- name: "configFileContent",
359
- type: "string",
360
- initializer: code`"";`
361
- }),
362
- createComponent(Spacing, {}),
363
- memo(() => code`try {
364
- configFileContent = await readFile(configFilePath, "utf8");
365
- } catch (error) {
366
- if (Error.isError(error) && error.code === "ENOENT") {
367
- // If the file doesn't exist, we can create it later when writing the completion script.
368
- warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
369
- } else {
370
- return { error };
371
- }
266
+ }
267
+ }),
268
+ createComponent(Spacing, {}),
269
+ createComponent(VarDeclaration, {
270
+ "export": true,
271
+ "const": true,
272
+ name: "SHELL_COMPLETIONS_DISPLAY",
273
+ initializer: code` SHELL_COMPLETIONS.split("\\n").map(line => {
274
+ if (!line.trim()) {
275
+ return "";
276
+ }
277
+ if (line.trim().startsWith("#")) {
278
+ return \`\${colors.dim(line)}\`;
372
279
  }
373
280
 
374
- await writeFile(configFilePath, \`\${configFileContent}\\n\\n\${stripAnsi(completions)}\`);
375
-
376
- success(\`${getAppTitle(context)} Fish completion script has been generated and appended to \${colors.bold(configFilePath)}. Please restart your terminal or run \`source \${configFilePath}\` to apply the changes.\`); `)
377
- ];
378
- }
379
- }),
380
- createComponent(Spacing, {}),
381
- createComponent(IfStatement, {
382
- condition: code`options.script`,
383
- get children() {
384
- return code`const outputPath = options.script === true ? "${bin.value}-completions.fish" : options.script;
385
- await writeFile(outputPath, stripAnsi(completions));
386
-
387
- success(\`${getAppTitle(context)} Fish completion script has been generated at \${colors.bold(outputPath)}.\`);`;
388
- }
389
- }),
390
- createComponent(Spacing, {}),
391
- createComponent(IfStatement, {
392
- condition: code`!options.config && !options.script`,
393
- children: code`writeLine(" ------------------------------------------------- ");
394
- writeLine(completions);
395
- writeLine(" ------------------------------------------------- ");`
396
- })
397
- ];
398
- }
281
+ return colors.white(line).replaceAll(/(?<=\\\$(\\{|\\()).*(?=(\\}\\)))/g, colors.green("$&"))
282
+ .replaceAll(/(\\"|\\').*(\\"|\\')/g, colors.cyan("$&"))
283
+ .replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|:)/g, colors.bold(colors.gray("$&")))
284
+ .replaceAll(/(function|complete)\\s+/g, colors.green("$&"))
285
+ .replaceAll(/(?<=(function|complete)\\s+)\\w/g, colors.bold(colors.greenBright("$&")))
286
+ .replaceAll(/set\\s+/g, colors.red("$&"))
287
+ .replaceAll(/(?<=set\\s+)\\w/g, colors.bold(colors.redBright("$&")))
288
+ .replaceAll(/while\\s+/g, colors.cyan("$&"))
289
+ .replaceAll(/(?<=while\\s+)\\w/g, colors.bold(colors.cyanBright("$&")))
290
+ .replaceAll(/(if|fi|else|elif|then|done)\\s+/g, colors.green("$&"))
291
+ .replaceAll(/\\s__\\w/g, colors.bold(colors.magentaBright("$&")))
292
+ .replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, colors.bold(colors.magenta("$&")));
293
+
294
+ }).join("\\n"); `
399
295
  })
400
296
  ];
401
297
  }
@@ -403,5 +299,5 @@ complete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && _
403
299
  }
404
300
 
405
301
  //#endregion
406
- export { FishCompletionsCommand };
407
- //# sourceMappingURL=fish-command.mjs.map
302
+ export { FishCompletionsShared };
303
+ //# sourceMappingURL=fish-shared.mjs.map
@@ -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"}