@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
package/README.md CHANGED
@@ -27,7 +27,7 @@ This package is part of the ⚡<b>Shell Shock</b> monorepo. The Shell Shock pack
27
27
 
28
28
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
29
29
 
30
- [![Version](https://img.shields.io/badge/version-0.2.22-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/shell-shock/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/shell-shock/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
30
+ [![Version](https://img.shields.io/badge/version-0.2.23-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/shell-shock/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/shell-shock/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
31
31
 
32
32
  <!-- prettier-ignore-start -->
33
33
  <!-- markdownlint-disable -->
@@ -0,0 +1,132 @@
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/bash-config-command.tsx
14
+ /**
15
+ * The Bash Completions - Configuration command's handler wrapper for the Shell Shock project.
16
+ */
17
+ function BashConfigCompletionsCommand() {
18
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
19
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
20
+ get path() {
21
+ return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "bash", "config", "command.ts");
22
+ },
23
+ imports: {
24
+ "node:os": "os",
25
+ "node:path": ["join"],
26
+ "node:fs/promises": ["readFile", "writeFile"],
27
+ "../shared": ["SHELL_COMPLETIONS_DISPLAY"]
28
+ },
29
+ builtinImports: { "shell-shock:console": [
30
+ "colors",
31
+ "writeLine",
32
+ "success",
33
+ "warn"
34
+ ] },
35
+ get children() {
36
+ return [
37
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Bash Completions - Configuration command." }),
38
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
39
+ "export": true,
40
+ name: "BashConfigCompletionsOptions",
41
+ get children() {
42
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
43
+ 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.",
44
+ get children() {
45
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
46
+ get type() {
47
+ return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
48
+ },
49
+ defaultValue: false
50
+ });
51
+ }
52
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
53
+ name: "display",
54
+ optional: true,
55
+ type: "boolean"
56
+ })];
57
+ }
58
+ }),
59
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
60
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions bash config\\` command." }),
61
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
62
+ "export": true,
63
+ "default": true,
64
+ async: true,
65
+ name: "handler",
66
+ parameters: [{
67
+ name: "options",
68
+ type: "BashConfigCompletionsOptions",
69
+ default: "{}"
70
+ }, {
71
+ name: "path",
72
+ type: "string",
73
+ default: `"~/.bashrc"`
74
+ }],
75
+ get children() {
76
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
77
+ condition: _alloy_js_core.code`options.display !== true`,
78
+ get children() {
79
+ return [
80
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
81
+ "let": true,
82
+ name: "configPath",
83
+ type: "string",
84
+ initializer: _alloy_js_core.code` path.includes(".") ? path : join(path, ".bashrc");`
85
+ }),
86
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
87
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
88
+ condition: _alloy_js_core.code`configPath.startsWith("~")`,
89
+ children: _alloy_js_core.code`configPath = join(os.homedir(), configPath.replace("~", "")); `
90
+ }),
91
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
92
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
93
+ "let": true,
94
+ name: "content",
95
+ type: "string",
96
+ initializer: _alloy_js_core.code`"";`
97
+ }),
98
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
99
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
100
+ content = await readFile(configPath, "utf8");
101
+ } catch (error) {
102
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
103
+ // If the file doesn't exist, we can create it later when writing the completion script.
104
+ warn(\`Configuration file \${colors.bold(configPath)} does not exist. It will be created when the completion script is written.\`);
105
+ } else {
106
+ return { error };
107
+ }
108
+ }
109
+
110
+ await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Shell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Bash Completions ###\`);
111
+
112
+ success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} shell completions have been applied to Bash configuration file at \${colors.bold(configPath)}. Please restart your terminal or run \\\`source \${configPath}\\\` for the changes to take effect.\`); `)
113
+ ];
114
+ }
115
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
116
+ return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
117
+ writeLine(\`### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Bash Completions ###\`);
118
+ writeLine("");
119
+ SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
120
+ writeLine("");
121
+ writeLine(\`### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Bash Completions ###\`);
122
+ writeLine(" ------------------------------------------------- ");`;
123
+ } })];
124
+ }
125
+ })
126
+ ];
127
+ }
128
+ });
129
+ }
130
+
131
+ //#endregion
132
+ exports.BashConfigCompletionsCommand = BashConfigCompletionsCommand;
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/bash-config-command.d.ts
4
+ /**
5
+ * The Bash Completions - Configuration command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function BashConfigCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { BashConfigCompletionsCommand };
10
+ //# sourceMappingURL=bash-config-command.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash-config-command.d.cts","names":[],"sources":["../../src/components/bash-config-command.tsx"],"mappings":";;;;;;iBA4CgB,4BAAA,CAAA,GAA4B,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/bash-config-command.d.ts
4
+ /**
5
+ * The Bash Completions - Configuration command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function BashConfigCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { BashConfigCompletionsCommand };
10
+ //# sourceMappingURL=bash-config-command.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash-config-command.d.mts","names":[],"sources":["../../src/components/bash-config-command.tsx"],"mappings":";;;;;;iBA4CgB,4BAAA,CAAA,GAA4B,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,132 @@
1
+ import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
2
+ import { getAppTitle } from "@shell-shock/core/plugin-utils";
3
+ import { code } from "@alloy-js/core";
4
+ import { ElseClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
5
+ import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
6
+ import { Spacing } from "@powerlines/plugin-alloy/core";
7
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
8
+ import { InterfaceMember as InterfaceMember$1, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
9
+ import { TSDoc as TSDoc$1, TSDocDefaultValue as TSDocDefaultValue$1 } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
10
+ import { joinPaths } from "@stryke/path";
11
+
12
+ //#region src/components/bash-config-command.tsx
13
+ /**
14
+ * The Bash Completions - Configuration command's handler wrapper for the Shell Shock project.
15
+ */
16
+ function BashConfigCompletionsCommand() {
17
+ const context = usePowerlines();
18
+ return createComponent(TypescriptFile, {
19
+ get path() {
20
+ return joinPaths(context.entryPath, "completions", "bash", "config", "command.ts");
21
+ },
22
+ imports: {
23
+ "node:os": "os",
24
+ "node:path": ["join"],
25
+ "node:fs/promises": ["readFile", "writeFile"],
26
+ "../shared": ["SHELL_COMPLETIONS_DISPLAY"]
27
+ },
28
+ builtinImports: { "shell-shock:console": [
29
+ "colors",
30
+ "writeLine",
31
+ "success",
32
+ "warn"
33
+ ] },
34
+ get children() {
35
+ return [
36
+ createComponent(TSDoc$1, { heading: "Options for the Bash Completions - Configuration command." }),
37
+ createComponent(InterfaceDeclaration, {
38
+ "export": true,
39
+ name: "BashConfigCompletionsOptions",
40
+ get children() {
41
+ return [createComponent(TSDoc$1, {
42
+ 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.",
43
+ get children() {
44
+ return createComponent(TSDocDefaultValue$1, {
45
+ get type() {
46
+ return ReflectionKind.boolean;
47
+ },
48
+ defaultValue: false
49
+ });
50
+ }
51
+ }), createComponent(InterfaceMember$1, {
52
+ name: "display",
53
+ optional: true,
54
+ type: "boolean"
55
+ })];
56
+ }
57
+ }),
58
+ createComponent(Spacing, {}),
59
+ createComponent(TSDoc$1, { heading: "Handler logic for the \\`completions bash config\\` command." }),
60
+ createComponent(FunctionDeclaration, {
61
+ "export": true,
62
+ "default": true,
63
+ async: true,
64
+ name: "handler",
65
+ parameters: [{
66
+ name: "options",
67
+ type: "BashConfigCompletionsOptions",
68
+ default: "{}"
69
+ }, {
70
+ name: "path",
71
+ type: "string",
72
+ default: `"~/.bashrc"`
73
+ }],
74
+ get children() {
75
+ return [createComponent(IfStatement, {
76
+ condition: code`options.display !== true`,
77
+ get children() {
78
+ return [
79
+ createComponent(VarDeclaration, {
80
+ "let": true,
81
+ name: "configPath",
82
+ type: "string",
83
+ initializer: code` path.includes(".") ? path : join(path, ".bashrc");`
84
+ }),
85
+ createComponent(Spacing, {}),
86
+ createComponent(IfStatement, {
87
+ condition: code`configPath.startsWith("~")`,
88
+ children: code`configPath = join(os.homedir(), configPath.replace("~", "")); `
89
+ }),
90
+ createComponent(Spacing, {}),
91
+ createComponent(VarDeclaration, {
92
+ "let": true,
93
+ name: "content",
94
+ type: "string",
95
+ initializer: code`"";`
96
+ }),
97
+ createComponent(Spacing, {}),
98
+ memo(() => code`try {
99
+ content = await readFile(configPath, "utf8");
100
+ } catch (error) {
101
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
102
+ // If the file doesn't exist, we can create it later when writing the completion script.
103
+ warn(\`Configuration file \${colors.bold(configPath)} does not exist. It will be created when the completion script is written.\`);
104
+ } else {
105
+ return { error };
106
+ }
107
+ }
108
+
109
+ await writeFile(configPath, \`\${content}\\n\\n### Begin - ${getAppTitle(context)} Shell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${getAppTitle(context)} Bash Completions ###\`);
110
+
111
+ success(\`${getAppTitle(context)} shell completions have been applied to Bash configuration file at \${colors.bold(configPath)}. Please restart your terminal or run \\\`source \${configPath}\\\` for the changes to take effect.\`); `)
112
+ ];
113
+ }
114
+ }), createComponent(ElseClause, { get children() {
115
+ return code`writeLine(" ------------------------------------------------- ");
116
+ writeLine(\`### Begin - ${getAppTitle(context)} Bash Completions ###\`);
117
+ writeLine("");
118
+ SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
119
+ writeLine("");
120
+ writeLine(\`### End - ${getAppTitle(context)} Bash Completions ###\`);
121
+ writeLine(" ------------------------------------------------- ");`;
122
+ } })];
123
+ }
124
+ })
125
+ ];
126
+ }
127
+ });
128
+ }
129
+
130
+ //#endregion
131
+ export { BashConfigCompletionsCommand };
132
+ //# sourceMappingURL=bash-config-command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash-config-command.mjs","names":[],"sources":["../../src/components/bash-config-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Bash Completions - Configuration command's handler wrapper for the Shell Shock project.\n */\nexport function BashConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"bash\",\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_DISPLAY\"]\n }}\n builtinImports={{\n \"shell-shock:console\": [\"colors\", \"writeLine\", \"success\", \"warn\"]\n }}>\n <TSDoc heading=\"Options for the Bash Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"BashConfigCompletionsOptions\">\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 bash config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"BashConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.bashrc\"`\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, \".bashrc\");`}\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)} Shell Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} Bash Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to Bash 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)} Bash Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} Bash Completions ###\\`);\n writeLine(\" ------------------------------------------------- \");`}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAO,+BAAA;CACL,MAAK,UAAA,eAAA;AACL,QAAA,gBAAA,gBAAA;EACA,IAAM,OAAC;AACH,UAAG,UAAc,QAAO,WAAY,eAAY,QAAM,UAAA,aAAA;;EAE5D,SAAa;;GAEX,aAAA,CAAA,OAAA;GACI,oBAAoB,CAAA,YAAa,YAAW;GAChD,aAAA,CAAA,4BAAA;GACF;EACE,gBAAgB;;;;;KAEhB;EACE,IAAC,WAAA;AACC,UAAM;IAAA,gBAAS,SAAA,EACb,SAAQ,6DACT,CAAC;IAAC,gBAAY,sBAAA;KACb,UAAM;KACN,MAAC;KACD,IAAC,WAAU;AACZ,aAAA,CAAA,gBAAA,SAAA;OACD,SAAS;OACN,IAAO,WAAO;AACT,eAAO,gBAAQ,qBAAA;SACb,IAAC,OAAU;AACT,iBAAK,eAAA;;SAEjB,cAAgB;SACP,CAAA;;OAER,CAAK,EAAC,gBAAiB,mBAAa;OACpC,MAAA;OACE,UAAa;OACX,MAAA;OACA,CAAC,CAAA;;KAEL,CAAC;IAAE,gBAAC,SAAA,EAAA,CAAA;IAAA,gBAAA,SAAA,EACH,SAAO,gEACR,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,gBAAA;UACvB,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,gBAAc;UACvE,OAAA;UACA,MAAS;UACT,MAAW;UACT,aAAgB,IAAE;UACnB,CAAA;SAAA,gBAAW,SAAA,EAAA,CAAA;SAAA,WAAA,IAAA;;;;;;;;;;;uEAWG,YAAA,QAAA,CAAA,oEAAA,YAAA,QAAA,CAAA;;sBAEN,YAAc,QAAQ,CAAC,wMAA0D;SAAA;;OAE1F,CAAC,EAAE,gBAAK,YAAA,EACP,IAAE,WAAS;AACX,cAAA,IAAA;sCACF,YAAA,QAAA,CAAA;;;;oCAI0B,YAAA,QAAA,CAAA;;SAGzB,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/bash-script-command.tsx
14
+ /**
15
+ * The Bash Completions - Script command's handler wrapper for the Shell Shock project.
16
+ */
17
+ function BashScriptCompletionsCommand() {
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", "bash", "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 Bash Completions - Script command." }),
39
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
40
+ "export": true,
41
+ name: "BashScriptCompletionsOptions",
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 bash 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: "BashScriptCompletionsOptions",
71
+ default: "{}"
72
+ }, {
73
+ name: "path",
74
+ type: "string",
75
+ default: `"${bin.value}-completions.bash"`
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}.bash\` : path;`
87
+ }), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`await writeFile(scriptPath, \`# Bash 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)} Bash 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(\`# Bash completion 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.BashScriptCompletionsCommand = BashScriptCompletionsCommand;
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/bash-script-command.d.ts
4
+ /**
5
+ * The Bash Completions - Script command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function BashScriptCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { BashScriptCompletionsCommand };
10
+ //# sourceMappingURL=bash-script-command.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash-script-command.d.cts","names":[],"sources":["../../src/components/bash-script-command.tsx"],"mappings":";;;;;;iBA4CgB,4BAAA,CAAA,GAA4B,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/bash-script-command.d.ts
4
+ /**
5
+ * The Bash Completions - Script command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function BashScriptCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { BashScriptCompletionsCommand };
10
+ //# sourceMappingURL=bash-script-command.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash-script-command.d.mts","names":[],"sources":["../../src/components/bash-script-command.tsx"],"mappings":";;;;;;iBA4CgB,4BAAA,CAAA,GAA4B,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,106 @@
1
+ import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
2
+ import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
3
+ import { code, computed } from "@alloy-js/core";
4
+ import { ElseClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
5
+ import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
6
+ import { Spacing } from "@powerlines/plugin-alloy/core";
7
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
8
+ import { InterfaceMember as InterfaceMember$1, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
9
+ import { TSDoc as TSDoc$1, TSDocDefaultValue as TSDocDefaultValue$1 } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
10
+ import { joinPaths } from "@stryke/path";
11
+
12
+ //#region src/components/bash-script-command.tsx
13
+ /**
14
+ * The Bash Completions - Script command's handler wrapper for the Shell Shock project.
15
+ */
16
+ function BashScriptCompletionsCommand() {
17
+ const context = usePowerlines();
18
+ const bin = computed(() => getAppBin(context));
19
+ return createComponent(TypescriptFile, {
20
+ get path() {
21
+ return joinPaths(context.entryPath, "completions", "bash", "script", "command.ts");
22
+ },
23
+ imports: {
24
+ "node:os": "os",
25
+ "node:path": ["join"],
26
+ "node:fs/promises": ["readFile", "writeFile"],
27
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
28
+ },
29
+ builtinImports: { "shell-shock:console": [
30
+ "colors",
31
+ "writeLine",
32
+ "success",
33
+ "warn"
34
+ ] },
35
+ get children() {
36
+ return [
37
+ createComponent(TSDoc$1, { heading: "Options for the Bash Completions - Script command." }),
38
+ createComponent(InterfaceDeclaration, {
39
+ "export": true,
40
+ name: "BashScriptCompletionsOptions",
41
+ get children() {
42
+ return [createComponent(TSDoc$1, {
43
+ 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.",
44
+ get children() {
45
+ return createComponent(TSDocDefaultValue$1, {
46
+ get type() {
47
+ return ReflectionKind.boolean;
48
+ },
49
+ defaultValue: false
50
+ });
51
+ }
52
+ }), createComponent(InterfaceMember$1, {
53
+ name: "display",
54
+ optional: true,
55
+ type: "boolean"
56
+ })];
57
+ }
58
+ }),
59
+ createComponent(Spacing, {}),
60
+ createComponent(TSDoc$1, { heading: "Handler logic for the \\`completions bash script\\` command." }),
61
+ createComponent(FunctionDeclaration, {
62
+ "export": true,
63
+ "default": true,
64
+ async: true,
65
+ name: "handler",
66
+ get parameters() {
67
+ return [{
68
+ name: "options",
69
+ type: "BashScriptCompletionsOptions",
70
+ default: "{}"
71
+ }, {
72
+ name: "path",
73
+ type: "string",
74
+ default: `"${bin.value}-completions.bash"`
75
+ }];
76
+ },
77
+ get children() {
78
+ return [createComponent(IfStatement, {
79
+ condition: code`options.display !== true`,
80
+ get children() {
81
+ return [createComponent(VarDeclaration, {
82
+ "const": true,
83
+ name: "scriptPath",
84
+ type: "string",
85
+ initializer: code` path.includes(".") ? \`\${path}.bash\` : path;`
86
+ }), memo(() => code`await writeFile(scriptPath, \`# Bash script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
87
+
88
+ success(\`${getAppTitle(context)} Bash completion script has been generated at \${colors.bold(scriptPath)}.\`);`)];
89
+ }
90
+ }), createComponent(ElseClause, { get children() {
91
+ return code`writeLine(" ------------------------------------------------- ");
92
+ writeLine(\`# Bash completion for ${getAppTitle(context)}\`);
93
+ writeLine("");
94
+ SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
95
+ writeLine(" ------------------------------------------------- ");`;
96
+ } })];
97
+ }
98
+ })
99
+ ];
100
+ }
101
+ });
102
+ }
103
+
104
+ //#endregion
105
+ export { BashScriptCompletionsCommand };
106
+ //# sourceMappingURL=bash-script-command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash-script-command.mjs","names":[],"sources":["../../src/components/bash-script-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, computed } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Bash Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function BashScriptCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"bash\",\n \"script\",\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 Bash Completions - Script command.\" />\n <InterfaceDeclaration export name=\"BashScriptCompletionsOptions\">\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 bash script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"BashScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"${bin.value}-completions.bash\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n const\n name=\"scriptPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? \\`\\${path}.bash\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# Bash script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} Bash completion script has been generated at \\${colors.bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\\`# Bash completion for ${getAppTitle(context)}\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\" ------------------------------------------------- \");`}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAO,+BAAA;CACL,MAAK,UAAA,eAAA;CACL,MAAA,MAAA,eAAA,UAAA,QAAA,CAAA;AACA,QAAO,gBAAkB,gBAAgB;EAC3C,IAAQ,OAAC;AACH,UAAG,UAAY,QAAO,WAAY,eAAA,QAAA,UAAA,aAAA;;;GAGtC,WAAA;GACI,aAAM,CAAA,OAAc;GACxB,oBAAA,CAAA,YAAA,YAAA;GACI,aAAU,CAAA,qBAAA,4BAA+B;GAC7C;oBAEA,uBAA2B;GAAA;GAAU;GAAS;GAAA;GAAA;EAE9C,IAAM,WAAC;AACJ,UAAA;IAAA,gBAAA,SAAA,EACC,SAAM,sDACL,CAAC;IAAA,gBAAiB,sBAAA;KACjB,UAAC;KACD,MAAM;KACN,IAAC,WAAO;AACP,aAAQ,CAAA,gBAAE,SAAA;OACZ,SAAA;OACD,IAAS,WAAA;AACD,eAAM,gBAAG,qBAAA;SACT,IAAM,OAAO;AACV,iBAAQ,eAAe;;SAEjC,cAAA;SACD,CAAA;;OAEE,CAAA,EAAA,gBAAA,mBAAA;OACI,MAAC;OACN,UAAA;OACE,MAAM;OACJ,CAAA,CAAA;;KAEJ,CAAC;IAAE,gBAAgB,SAAK,EAAA,CAAA;IAAA,gBAAA,SAAA,EACvB,SAAG,gEACJ,CAAC;IAAE,gBAAK,qBAAA;KACP,UAAC;KACD,WAAA;KACD,OAAQ;KACR,MAAM;KACN,IAAA,aAAA;AACC,aAAA,CAAA;OACA,MAAA;OACA,MAAA;OACI,SAAS;OACb,EAAA;OACE,MAAA;OACE,MAAM;OACN,SAAO,IAAA,IAAA,MAAA;OACR,CAAC;;KAEJ,IAAE,WAAA;AACA,aAAO,CAAC,gBAAM,aAAA;OACZ,WAAO,IAAO;OACd,IAAA,WAAa;AACf,eAAA,CAAA,gBAAA,gBAAA;SACA,SAAA;SACD,MAAY;SACV,MAAA;SACC,aAAA,IAAA;SACA,CAAI,EAAE,WAAU,IAAA,sEAAA,YAAA,QAAA,CAAA;;wBAEJ,YAAY,QAAQ,CAAC,gFAAiC,CAAA;;OAEnE,CAAA,EAAA,gBAAqB,YAAY;AAEhC,cAAS,IAAG;gDACV,YAAA,QAAA,CAAA;;;;SAKH,CAAC,CAAA;;KAEL,CAAC;IAAC;;EAEN,CAAC"}