@shell-shock/plugin-completions 0.2.23 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +1 -1
  2. package/dist/components/bash-config-command.cjs +132 -0
  3. package/dist/components/bash-config-command.d.cts +10 -0
  4. package/dist/components/bash-config-command.d.cts.map +1 -0
  5. package/dist/components/bash-config-command.d.mts +10 -0
  6. package/dist/components/bash-config-command.d.mts.map +1 -0
  7. package/dist/components/bash-config-command.mjs +132 -0
  8. package/dist/components/bash-config-command.mjs.map +1 -0
  9. package/dist/components/bash-script-command.cjs +106 -0
  10. package/dist/components/bash-script-command.d.cts +10 -0
  11. package/dist/components/bash-script-command.d.cts.map +1 -0
  12. package/dist/components/bash-script-command.d.mts +10 -0
  13. package/dist/components/bash-script-command.d.mts.map +1 -0
  14. package/dist/components/bash-script-command.mjs +106 -0
  15. package/dist/components/bash-script-command.mjs.map +1 -0
  16. package/dist/components/bash-shared.cjs +172 -0
  17. package/dist/components/bash-shared.d.cts +10 -0
  18. package/dist/components/bash-shared.d.cts.map +1 -0
  19. package/dist/components/bash-shared.d.mts +10 -0
  20. package/dist/components/bash-shared.d.mts.map +1 -0
  21. package/dist/components/bash-shared.mjs +172 -0
  22. package/dist/components/bash-shared.mjs.map +1 -0
  23. package/dist/components/fish-config-command.cjs +132 -0
  24. package/dist/components/fish-config-command.d.cts +10 -0
  25. package/dist/components/fish-config-command.d.cts.map +1 -0
  26. package/dist/components/fish-config-command.d.mts +10 -0
  27. package/dist/components/fish-config-command.d.mts.map +1 -0
  28. package/dist/components/fish-config-command.mjs +132 -0
  29. package/dist/components/fish-config-command.mjs.map +1 -0
  30. package/dist/components/fish-script-command.cjs +106 -0
  31. package/dist/components/fish-script-command.d.cts +10 -0
  32. package/dist/components/fish-script-command.d.cts.map +1 -0
  33. package/dist/components/fish-script-command.d.mts +10 -0
  34. package/dist/components/fish-script-command.d.mts.map +1 -0
  35. package/dist/components/fish-script-command.mjs +106 -0
  36. package/dist/components/fish-script-command.mjs.map +1 -0
  37. package/dist/components/fish-shared.cjs +303 -0
  38. package/dist/components/fish-shared.d.cts +10 -0
  39. package/dist/components/fish-shared.d.cts.map +1 -0
  40. package/dist/components/fish-shared.d.mts +10 -0
  41. package/dist/components/fish-shared.d.mts.map +1 -0
  42. package/dist/components/fish-shared.mjs +303 -0
  43. package/dist/components/fish-shared.mjs.map +1 -0
  44. package/dist/components/index.cjs +24 -8
  45. package/dist/components/index.d.cts +13 -5
  46. package/dist/components/index.d.mts +13 -5
  47. package/dist/components/index.mjs +13 -5
  48. package/dist/components/powershell-config-command.cjs +128 -0
  49. package/dist/components/powershell-config-command.d.cts +7 -0
  50. package/dist/components/powershell-config-command.d.cts.map +1 -0
  51. package/dist/components/powershell-config-command.d.mts +7 -0
  52. package/dist/components/powershell-config-command.d.mts.map +1 -0
  53. package/dist/components/powershell-config-command.mjs +128 -0
  54. package/dist/components/powershell-config-command.mjs.map +1 -0
  55. package/dist/components/powershell-script-command.cjs +106 -0
  56. package/dist/components/powershell-script-command.d.cts +10 -0
  57. package/dist/components/powershell-script-command.d.cts.map +1 -0
  58. package/dist/components/powershell-script-command.d.mts +10 -0
  59. package/dist/components/powershell-script-command.d.mts.map +1 -0
  60. package/dist/components/powershell-script-command.mjs +106 -0
  61. package/dist/components/powershell-script-command.mjs.map +1 -0
  62. package/dist/components/powershell-shared.cjs +319 -0
  63. package/dist/components/powershell-shared.d.cts +10 -0
  64. package/dist/components/powershell-shared.d.cts.map +1 -0
  65. package/dist/components/powershell-shared.d.mts +10 -0
  66. package/dist/components/powershell-shared.d.mts.map +1 -0
  67. package/dist/components/{powershell-command.mjs → powershell-shared.mjs} +81 -181
  68. package/dist/components/powershell-shared.mjs.map +1 -0
  69. package/dist/components/zsh-config-command.cjs +132 -0
  70. package/dist/components/zsh-config-command.d.cts +10 -0
  71. package/dist/components/zsh-config-command.d.cts.map +1 -0
  72. package/dist/components/zsh-config-command.d.mts +10 -0
  73. package/dist/components/zsh-config-command.d.mts.map +1 -0
  74. package/dist/components/zsh-config-command.mjs +132 -0
  75. package/dist/components/zsh-config-command.mjs.map +1 -0
  76. package/dist/components/zsh-script-command.cjs +111 -0
  77. package/dist/components/zsh-script-command.d.cts +10 -0
  78. package/dist/components/zsh-script-command.d.cts.map +1 -0
  79. package/dist/components/zsh-script-command.d.mts +10 -0
  80. package/dist/components/zsh-script-command.d.mts.map +1 -0
  81. package/dist/components/zsh-script-command.mjs +111 -0
  82. package/dist/components/zsh-script-command.mjs.map +1 -0
  83. package/dist/components/zsh-shared.cjs +281 -0
  84. package/dist/components/zsh-shared.d.cts +10 -0
  85. package/dist/components/zsh-shared.d.cts.map +1 -0
  86. package/dist/components/zsh-shared.d.mts +10 -0
  87. package/dist/components/zsh-shared.d.mts.map +1 -0
  88. package/dist/components/zsh-shared.mjs +281 -0
  89. package/dist/components/zsh-shared.mjs.map +1 -0
  90. package/dist/helpers/complete-command.cjs +2 -7
  91. package/dist/helpers/complete-command.d.cts +2 -2
  92. package/dist/helpers/complete-command.d.cts.map +1 -1
  93. package/dist/helpers/complete-command.d.mts +2 -2
  94. package/dist/helpers/complete-command.d.mts.map +1 -1
  95. package/dist/helpers/complete-command.mjs +2 -7
  96. package/dist/helpers/complete-command.mjs.map +1 -1
  97. package/dist/helpers/index.cjs +1 -1
  98. package/dist/helpers/index.d.cts +2 -2
  99. package/dist/helpers/index.d.mts +2 -2
  100. package/dist/helpers/index.mjs +2 -2
  101. package/dist/index.cjs +245 -59
  102. package/dist/index.d.cts.map +1 -1
  103. package/dist/index.d.mts.map +1 -1
  104. package/dist/index.mjs +246 -60
  105. package/dist/index.mjs.map +1 -1
  106. package/package.json +148 -37
  107. package/dist/components/bash-command.cjs +0 -273
  108. package/dist/components/bash-command.d.cts +0 -10
  109. package/dist/components/bash-command.d.cts.map +0 -1
  110. package/dist/components/bash-command.d.mts +0 -10
  111. package/dist/components/bash-command.d.mts.map +0 -1
  112. package/dist/components/bash-command.mjs +0 -273
  113. package/dist/components/bash-command.mjs.map +0 -1
  114. package/dist/components/fish-command.cjs +0 -403
  115. package/dist/components/fish-command.d.cts +0 -10
  116. package/dist/components/fish-command.d.cts.map +0 -1
  117. package/dist/components/fish-command.d.mts +0 -10
  118. package/dist/components/fish-command.d.mts.map +0 -1
  119. package/dist/components/fish-command.mjs +0 -403
  120. package/dist/components/fish-command.mjs.map +0 -1
  121. package/dist/components/powershell-command.cjs +0 -419
  122. package/dist/components/powershell-command.d.cts +0 -10
  123. package/dist/components/powershell-command.d.cts.map +0 -1
  124. package/dist/components/powershell-command.d.mts +0 -10
  125. package/dist/components/powershell-command.d.mts.map +0 -1
  126. package/dist/components/powershell-command.mjs.map +0 -1
  127. package/dist/components/zsh-command.cjs +0 -384
  128. package/dist/components/zsh-command.d.cts +0 -10
  129. package/dist/components/zsh-command.d.cts.map +0 -1
  130. package/dist/components/zsh-command.d.mts +0 -10
  131. package/dist/components/zsh-command.d.mts.map +0 -1
  132. package/dist/components/zsh-command.mjs +0 -384
  133. package/dist/components/zsh-command.mjs.map +0 -1
@@ -0,0 +1,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, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
5
+ import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
6
+ import { Spacing } from "@powerlines/plugin-alloy/core";
7
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
8
+ import { TSDoc, TSDocDefaultValue } from "@powerlines/plugin-alloy/typescript";
9
+ import { joinPaths } from "@stryke/path";
10
+ import { TypescriptFile as TypescriptFile$1 } from "@powerlines/plugin-alloy/typescript/components/typescript-file";
11
+
12
+ //#region src/components/fish-config-command.tsx
13
+ /**
14
+ * The Fish Completions - Configuration command's handler wrapper for the Shell Shock project.
15
+ */
16
+ function FishConfigCompletionsCommand() {
17
+ const context = usePowerlines();
18
+ return createComponent(TypescriptFile$1, {
19
+ get path() {
20
+ return joinPaths(context.entryPath, "completions", "fish", "config", "command.ts");
21
+ },
22
+ imports: {
23
+ "node:os": "os",
24
+ "node:path": ["join"],
25
+ "node:fs/promises": ["readFile", "writeFile"],
26
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
27
+ },
28
+ builtinImports: { "shell-shock:console": [
29
+ "colors",
30
+ "writeLine",
31
+ "success",
32
+ "warn"
33
+ ] },
34
+ get children() {
35
+ return [
36
+ createComponent(TSDoc, { heading: "Options for the Fish Completions - Configuration command." }),
37
+ createComponent(InterfaceDeclaration, {
38
+ "export": true,
39
+ name: "FishConfigCompletionsOptions",
40
+ get children() {
41
+ return [createComponent(TSDoc, {
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, {
45
+ get type() {
46
+ return ReflectionKind.boolean;
47
+ },
48
+ defaultValue: false
49
+ });
50
+ }
51
+ }), createComponent(InterfaceMember, {
52
+ name: "display",
53
+ optional: true,
54
+ type: "boolean"
55
+ })];
56
+ }
57
+ }),
58
+ createComponent(Spacing, {}),
59
+ createComponent(TSDoc, { heading: "Handler logic for the \\`completions fish config\\` command." }),
60
+ createComponent(FunctionDeclaration, {
61
+ "export": true,
62
+ "default": true,
63
+ async: true,
64
+ name: "handler",
65
+ parameters: [{
66
+ name: "options",
67
+ type: "FishConfigCompletionsOptions",
68
+ default: "{}"
69
+ }, {
70
+ name: "path",
71
+ type: "string",
72
+ default: `"~/.config/fish/config.fish"`
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, ".config", "fish", "config.fish");`
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)} Fish Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${getAppTitle(context)} Fish Completions ###\`);
110
+
111
+ success(\`${getAppTitle(context)} shell completions have been applied to Fish 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)} Fish Completions ###\`);
117
+ writeLine("");
118
+ SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
119
+ writeLine("");
120
+ writeLine(\`### End - ${getAppTitle(context)} Fish Completions ###\`);
121
+ writeLine(" ------------------------------------------------- ");`;
122
+ } })];
123
+ }
124
+ })
125
+ ];
126
+ }
127
+ });
128
+ }
129
+
130
+ //#endregion
131
+ export { FishConfigCompletionsCommand };
132
+ //# sourceMappingURL=fish-config-command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fish-config-command.mjs","names":[],"sources":["../../src/components/fish-config-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TSDoc, TSDocDefaultValue } from \"@powerlines/plugin-alloy/typescript\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions - Configuration command's handler wrapper for the Shell Shock project.\n */\nexport function FishConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"fish\",\n \"config\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n \"shell-shock:console\": [\"colors\", \"writeLine\", \"success\", \"warn\"]\n }}>\n <TSDoc heading=\"Options for the Fish Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"FishConfigCompletionsOptions\">\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 fish config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"FishConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.config/fish/config.fish\"`\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, \".config\", \"fish\", \"config.fish\");`}\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)} Fish Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} Fish Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to Fish 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)} Fish Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} Fish Completions ###\\`);\n writeLine(\" ------------------------------------------------- \");`}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAS,+BAA+B;CACxC,MAAO,UAAO,eAA0C;;EAEtD,IAAA,OAAA;AACI,UAAM,UAAW,QAAG,WAAc,eAAiB,QAAQ,UAAS,aAAY;;EAEtF,SAAO;GACL,WAAe;;GAEf,oBAAO,CAAA,YAAA,YAAA;GACJ,aAAA,CAAA,qBAAA,4BAAA;GACA;EACD,gBAAY,EACV,uBAAe;GAAA;GAAA;GAAA;GAAA;GAAA,EAChB;EACD,IAAI,WAAQ;AACV,UAAG;IAAA,gBAAU,OAAA,EACZ,SAAA,6DACD,CAAA;IAAA,gBAAS,sBAAA;KACP,UAAU;KACV,MAAM;KACN,IAAC,WAAQ;AACP,aAAE,CAAM,gBAAK,OAAoB;OACpC,SAAA;OACD,IAAA,WAAgB;AACR,eAAO,gBAAkB,mBAAiB;SAChD,IAAA,OAAA;AACK,iBAAS,eAAgB;;SAEvB,cAAe;SACnB,CAAA;;OAEA,CAAC,EAAA,gBAAmB,iBAAA;OACpB,MAAA;OACD,UAAK;OACN,MAAA;OACD,CAAA,CAAA;;KAED,CAAA;IAAA,gBAAe,SAAc,EAAG,CAAC;IAAA,gBAAkB,OAAK,EACxD,SAAA,gEACA,CAAC;IAAA,gBAAA,qBAAA;KACA,UAAA;KACA,WAAA;KACA,OAAM;KACN,MAAA;KACA,YAAE,CAAA;MACA,MAAM;MACN,MAAM;MACN,SAAS;MACV,EAAE;MACD,MAAA;MACA,MAAM;MACN,SAAS;MACV,CAAC;KACF,IAAE,WAAA;AACA,aAAA,CAAA,gBAAA,aAAA;OACD,WAAY,IAAA;OACV,IAAA,WAAA;AACC,eAAA;SAAA,gBAAA,gBAAA;UACI,OAAE;UACF,MAAE;UACN,MAAA;UACD,aAAA,IAAA;UACA,CAAA;SAAO,gBAAE,SAAA,EAAA,CAAA;SAAA,gBAAA,aAAA;UACT,WAAY,IAAA;UACV,UAAK,IAAY;UAClB,CAAA;SAAA,gBAAW,SAAA,EAAA,CAAA;SAAA,gBAAA,gBAAA;UACZ,OAAS;UACT,MAAA;UACC,MAAA;UACI,aAAS,IAAA;UACb,CAAI;SAAE,gBAAM,SAAA,EAAA,CAAA;SAAA,WAAA,IAAA;;;;;;;;;;;uEAWM,YAAA,QAAA,CAAA,mEAAA,YAAA,QAAA,CAAA;;sBAEpB,YAAA,QAAA,CAAA,wMAAA;SAAA;;OAEA,CAAA,EAAA,gBAAgB,YAAiB,EAC/B,IAAA,WAAA;AACC,cAAK,IAAA;;;;;oCAKG,YAAA,QAAA,CAAA;;SAGV,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/fish-script-command.tsx
14
+ /**
15
+ * The Fish Completions - Script command's handler wrapper for the Shell Shock project.
16
+ */
17
+ function FishScriptCompletionsCommand() {
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", "fish", "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 Fish Completions - Script command." }),
39
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
40
+ "export": true,
41
+ name: "FishScriptCompletionsOptions",
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 fish 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: "FishScriptCompletionsOptions",
71
+ default: "{}"
72
+ }, {
73
+ name: "path",
74
+ type: "string",
75
+ default: `"${bin.value}-completions.fish"`
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}.fish\` : path;`
87
+ }), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`await writeFile(scriptPath, \`# Fish 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)} Fish 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(\`# Fish 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.FishScriptCompletionsCommand = FishScriptCompletionsCommand;
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/fish-script-command.d.ts
4
+ /**
5
+ * The Fish Completions - Script command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function FishScriptCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { FishScriptCompletionsCommand };
10
+ //# sourceMappingURL=fish-script-command.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fish-script-command.d.cts","names":[],"sources":["../../src/components/fish-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/fish-script-command.d.ts
4
+ /**
5
+ * The Fish Completions - Script command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function FishScriptCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { FishScriptCompletionsCommand };
10
+ //# sourceMappingURL=fish-script-command.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fish-script-command.d.mts","names":[],"sources":["../../src/components/fish-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/fish-script-command.tsx
13
+ /**
14
+ * The Fish Completions - Script command's handler wrapper for the Shell Shock project.
15
+ */
16
+ function FishScriptCompletionsCommand() {
17
+ const context = usePowerlines();
18
+ const bin = computed(() => getAppBin(context));
19
+ return createComponent(TypescriptFile, {
20
+ get path() {
21
+ return joinPaths(context.entryPath, "completions", "fish", "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 Fish Completions - Script command." }),
38
+ createComponent(InterfaceDeclaration, {
39
+ "export": true,
40
+ name: "FishScriptCompletionsOptions",
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 fish 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: "FishScriptCompletionsOptions",
70
+ default: "{}"
71
+ }, {
72
+ name: "path",
73
+ type: "string",
74
+ default: `"${bin.value}-completions.fish"`
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}.fish\` : path;`
86
+ }), memo(() => code`await writeFile(scriptPath, \`# Fish script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
87
+
88
+ success(\`${getAppTitle(context)} Fish completion script has been generated at \${colors.bold(scriptPath)}.\`);`)];
89
+ }
90
+ }), createComponent(ElseClause, { get children() {
91
+ return code`writeLine(" ------------------------------------------------- ");
92
+ writeLine(\`# Fish 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 { FishScriptCompletionsCommand };
106
+ //# sourceMappingURL=fish-script-command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fish-script-command.mjs","names":[],"sources":["../../src/components/fish-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 Fish Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function FishScriptCompletionsCommand() {\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 \"fish\",\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 Fish Completions - Script command.\" />\n <InterfaceDeclaration export name=\"FishScriptCompletionsOptions\">\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 fish script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"FishScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"${bin.value}-completions.fish\"`\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}.fish\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# Fish script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} Fish completion script has been generated at \\${colors.bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\\`# Fish 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"}