@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,128 @@
1
+ import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
2
+ import { getAppTitle } from "@shell-shock/core/plugin-utils";
3
+ import { code } from "@alloy-js/core";
4
+ import { ElseClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
5
+ import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
6
+ import { Spacing } from "@powerlines/plugin-alloy/core";
7
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
8
+ import { TSDoc, TSDocDefaultValue, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
9
+ import { joinPaths } from "@stryke/path";
10
+
11
+ //#region src/components/powershell-config-command.tsx
12
+ function PowerShellConfigCompletionsCommand() {
13
+ const context = usePowerlines();
14
+ return createComponent(TypescriptFile, {
15
+ get path() {
16
+ return joinPaths(context.entryPath, "completions", "powershell", "config", "command.ts");
17
+ },
18
+ imports: {
19
+ "node:os": "os",
20
+ "node:path": ["join"],
21
+ "node:fs/promises": ["readFile", "writeFile"],
22
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
23
+ },
24
+ builtinImports: { "shell-shock:console": [
25
+ "colors",
26
+ "writeLine",
27
+ "success",
28
+ "warn"
29
+ ] },
30
+ get children() {
31
+ return [
32
+ createComponent(TSDoc, { heading: "Options for the PowerShell Completions - Configuration command." }),
33
+ createComponent(InterfaceDeclaration, {
34
+ "export": true,
35
+ name: "PowerShellConfigCompletionsOptions",
36
+ get children() {
37
+ return [createComponent(TSDoc, {
38
+ heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
39
+ get children() {
40
+ return createComponent(TSDocDefaultValue, {
41
+ get type() {
42
+ return ReflectionKind.boolean;
43
+ },
44
+ defaultValue: false
45
+ });
46
+ }
47
+ }), createComponent(InterfaceMember, {
48
+ name: "display",
49
+ optional: true,
50
+ type: "boolean"
51
+ })];
52
+ }
53
+ }),
54
+ createComponent(Spacing, {}),
55
+ createComponent(TSDoc, { heading: "Handler logic for the \\`completions powershell config\\` command." }),
56
+ createComponent(FunctionDeclaration, {
57
+ "export": true,
58
+ "default": true,
59
+ async: true,
60
+ name: "handler",
61
+ parameters: [{
62
+ name: "options",
63
+ type: "PowerShellConfigCompletionsOptions",
64
+ default: "{}"
65
+ }, {
66
+ name: "path",
67
+ type: "string",
68
+ default: `"~/.config/powershell/Microsoft.PowerShell_profile.ps1"`
69
+ }],
70
+ get children() {
71
+ return [createComponent(IfStatement, {
72
+ condition: code`options.display !== true`,
73
+ get children() {
74
+ return [
75
+ createComponent(VarDeclaration, {
76
+ "let": true,
77
+ name: "configPath",
78
+ type: "string",
79
+ initializer: code` path.includes(".") ? path : join(path, "Microsoft.PowerShell_profile.ps1");`
80
+ }),
81
+ createComponent(Spacing, {}),
82
+ createComponent(IfStatement, {
83
+ condition: code`configPath.startsWith("~")`,
84
+ children: code`configPath = join(os.homedir(), configPath.replace("~", "")); `
85
+ }),
86
+ createComponent(Spacing, {}),
87
+ createComponent(VarDeclaration, {
88
+ "let": true,
89
+ name: "content",
90
+ type: "string",
91
+ initializer: code`"";`
92
+ }),
93
+ createComponent(Spacing, {}),
94
+ memo(() => code`try {
95
+ content = await readFile(configPath, "utf8");
96
+ } catch (error) {
97
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
98
+ // If the file doesn't exist, we can create it later when writing the completion script.
99
+ warn(\`Configuration file \${colors.bold(configPath)} does not exist. It will be created when the completion script is written.\`);
100
+ } else {
101
+ return { error };
102
+ }
103
+ }
104
+
105
+ await writeFile(configPath, \`\${content}\\n\\n### Begin - ${getAppTitle(context)} PowerShell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${getAppTitle(context)} PowerShell Completions ###\`);
106
+
107
+ success(\`${getAppTitle(context)} shell completions have been applied to PowerShell configuration file at \${colors.bold(configPath)}. Please restart your terminal or run \\\`source \${configPath}\\\` for the changes to take effect.\`); `)
108
+ ];
109
+ }
110
+ }), createComponent(ElseClause, { get children() {
111
+ return code`writeLine(" ------------------------------------------------- ");
112
+ writeLine(\`### Begin - ${getAppTitle(context)} PowerShell Completions ###\`);
113
+ writeLine("");
114
+ SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
115
+ writeLine("");
116
+ writeLine(\`### End - ${getAppTitle(context)} PowerShell Completions ###\`);
117
+ writeLine(" ------------------------------------------------- ");`;
118
+ } })];
119
+ }
120
+ })
121
+ ];
122
+ }
123
+ });
124
+ }
125
+
126
+ //#endregion
127
+ export { PowerShellConfigCompletionsCommand };
128
+ //# sourceMappingURL=powershell-config-command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-config-command.mjs","names":[],"sources":["../../src/components/powershell-config-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n TSDoc,\n TSDocDefaultValue,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types\";\n\nexport function PowerShellConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"powershell\",\n \"config\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n \"shell-shock:console\": [\"colors\", \"writeLine\", \"success\", \"warn\"]\n }}>\n <TSDoc heading=\"Options for the PowerShell Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"PowerShellConfigCompletionsOptions\">\n <TSDoc heading=\"Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.\">\n <TSDocDefaultValue\n type={ReflectionKind.boolean}\n defaultValue={false}\n />\n </TSDoc>\n <InterfaceMember name=\"display\" optional type=\"boolean\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions powershell config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"PowerShellConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.config/powershell/Microsoft.PowerShell_profile.ps1\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n let\n name=\"configPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? path : join(path, \"Microsoft.PowerShell_profile.ps1\");`}\n />\n <Spacing />\n <IfStatement condition={code`configPath.startsWith(\"~\")`}>\n {code`configPath = join(os.homedir(), configPath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"content\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n content = await readFile(configPath, \"utf8\");\n } catch (error) {\n if (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${colors.bold(configPath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configPath, \\`\\${content}\\\\n\\\\n### Begin - ${getAppTitle(context)} PowerShell Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} PowerShell Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to PowerShell configuration file at \\${colors.bold(configPath)}. Please restart your terminal or run \\\\\\`source \\${configPath}\\\\\\` for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\\`### Begin - ${getAppTitle(context)} PowerShell Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} PowerShell Completions ###\\`);\n writeLine(\" ------------------------------------------------- \");`}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;AA4BA,SAAgB,qCAAkC;CAClD,MAAQ,UAAC,eAA+C;AACxD,QAAO,gBAAA,gBAAA;EACL,IAAK,OAAA;AACL,UAAA,UAAiB,QAAA,WAAA,eAAA,cAAA,UAAA,aAAA;;EAEjB,SAAO;GACH,WAAG;GACH,aAAa,CAAC,OAAO;GACrB,oBAAQ,CAAA,YAAyB,YAAW;;GAElD;EACE,gBAAgB;;;;;KAEhB;EACE,IAAC,WAAA;AACC,UAAM;IAAA,gBAAS,OAAA,EACb,SAAQ,mEACT,CAAC;IAAC,gBAAY,sBAAA;KACb,UAAC;KACD,MAAC;KACD,IAAC,WAAU;AACZ,aAAA,CAAA,gBAAA,OAAA;OACD,SAAS;OACN,IAAO,WAAO;AACT,eAAO,gBAAQ,mBAAA;SACb,IAAC,OAAU;AACT,iBAAK,eAAiB;;SAElC,cAAgB;SACP,CAAA;;OAER,CAAK,EAAC,gBAAiB,iBAAmB;OAC1C,MAAA;OACE,UAAa;OACX,MAAA;OACA,CAAC,CAAA;;KAEL,CAAC;IAAE,gBAAC,SAAA,EAAA,CAAA;IAAA,gBAAA,OAAA,EACH,SAAO,sEACR,CAAC;IAAC,gBAAgB,qBAAwB;KACzC,UAAA;KACD,WAAS;KACT,OAAM;KACN,MAAA;KACC,YAAA,CAAA;MACA,MAAA;MACA,MAAA;MACA,SAAM;MACN,EAAA;MACE,MAAA;MACA,MAAM;MACN,SAAS;MACV,CAAC;KACF,IAAG,WAAA;AACD,aAAA,CAAA,gBAAA,aAAA;OACE,WAAW,IAAC;OACZ,IAAI,WAAU;AACd,eAAS;SAAC,gBAAW,gBAAqB;UAC5C,OAAA;UACA,MAAA;UACD,MAAY;UACV,aAAA,IAAA;UACC,CAAA;SAAA,gBAAA,SAAA,EAAA,CAAA;SAAA,gBAAA,aAAA;UACI,WAAE,IAAU;UACZ,UAAQ,IAAA;UACZ,CAAA;SAAA,gBAAwB,SAAS,EAAE,CAAC;SAAE,gBAAkB,gBAAa;UACtE,OAAA;UACA,MAAS;UACT,MAAW;UACT,aAAgB,IAAE;UACnB,CAAA;SAAA,gBAAW,SAAA,EAAA,CAAA;SAAA,WAAA,IAAA;;;;;;;;;;;uEAWG,YAAA,QAAA,CAAA,yEAAA,YAAA,QAAA,CAAA;;sBAEN,YAAc,QAAQ,CAAC,8MAA0D;SAAA;;OAE1F,CAAC,EAAE,gBAAK,YAAA,EACP,IAAE,WAAS;AACX,cAAA,IAAA;sCACF,YAAA,QAAA,CAAA;;;;oCAI0B,YAAM,QAAA,CAAA;;SAG/B,CAAC,CAAA;;KAEL,CAAC;IAAC;;EAEN,CAAC"}
@@ -0,0 +1,106 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
3
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
4
+ let _alloy_js_core = require("@alloy-js/core");
5
+ let _alloy_js_typescript = require("@alloy-js/typescript");
6
+ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
7
+ let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
8
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
9
+ let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
10
+ let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
11
+ let _stryke_path = require("@stryke/path");
12
+
13
+ //#region src/components/powershell-script-command.tsx
14
+ /**
15
+ * The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
16
+ */
17
+ function PowerShellScriptCompletionsCommand() {
18
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
19
+ const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
20
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
21
+ get path() {
22
+ return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "powershell", "script", "command.ts");
23
+ },
24
+ imports: {
25
+ "node:os": "os",
26
+ "node:path": ["join"],
27
+ "node:fs/promises": ["readFile", "writeFile"],
28
+ "../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
29
+ },
30
+ builtinImports: { "shell-shock:console": [
31
+ "colors",
32
+ "writeLine",
33
+ "success",
34
+ "warn"
35
+ ] },
36
+ get children() {
37
+ return [
38
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the PowerShell Completions - Script command." }),
39
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
40
+ "export": true,
41
+ name: "PowerShellScriptCompletionsOptions",
42
+ get children() {
43
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
44
+ heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
45
+ get children() {
46
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
47
+ get type() {
48
+ return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
49
+ },
50
+ defaultValue: false
51
+ });
52
+ }
53
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
54
+ name: "display",
55
+ optional: true,
56
+ type: "boolean"
57
+ })];
58
+ }
59
+ }),
60
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
61
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions powershell script\\` command." }),
62
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
63
+ "export": true,
64
+ "default": true,
65
+ async: true,
66
+ name: "handler",
67
+ get parameters() {
68
+ return [{
69
+ name: "options",
70
+ type: "PowerShellScriptCompletionsOptions",
71
+ default: "{}"
72
+ }, {
73
+ name: "path",
74
+ type: "string",
75
+ default: `"${bin.value}-completions.ps1"`
76
+ }];
77
+ },
78
+ get children() {
79
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
80
+ condition: _alloy_js_core.code`options.display !== true`,
81
+ get children() {
82
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
83
+ "const": true,
84
+ name: "scriptPath",
85
+ type: "string",
86
+ initializer: _alloy_js_core.code` path.includes(".") ? \`\${path}.ps1\` : path;`
87
+ }), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`await writeFile(scriptPath, \`# PowerShell script to add completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
88
+
89
+ success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell completion script has been generated at \${colors.bold(scriptPath)}.\`);`)];
90
+ }
91
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
92
+ return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
93
+ writeLine(\`# PowerShell completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\`);
94
+ writeLine("");
95
+ SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
96
+ writeLine(" ------------------------------------------------- ");`;
97
+ } })];
98
+ }
99
+ })
100
+ ];
101
+ }
102
+ });
103
+ }
104
+
105
+ //#endregion
106
+ exports.PowerShellScriptCompletionsCommand = PowerShellScriptCompletionsCommand;
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/powershell-script-command.d.ts
4
+ /**
5
+ * The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function PowerShellScriptCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { PowerShellScriptCompletionsCommand };
10
+ //# sourceMappingURL=powershell-script-command.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-script-command.d.cts","names":[],"sources":["../../src/components/powershell-script-command.tsx"],"mappings":";;;;;;iBA4CgB,kCAAA,CAAA,GAAkC,iBAAA,CAAA,QAAA"}
@@ -0,0 +1,10 @@
1
+ import * as _$_alloy_js_core0 from "@alloy-js/core";
2
+
3
+ //#region src/components/powershell-script-command.d.ts
4
+ /**
5
+ * The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
6
+ */
7
+ declare function PowerShellScriptCompletionsCommand(): _$_alloy_js_core0.Children;
8
+ //#endregion
9
+ export { PowerShellScriptCompletionsCommand };
10
+ //# sourceMappingURL=powershell-script-command.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-script-command.d.mts","names":[],"sources":["../../src/components/powershell-script-command.tsx"],"mappings":";;;;;;iBA4CgB,kCAAA,CAAA,GAAkC,iBAAA,CAAA,QAAA"}
@@ -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/powershell-script-command.tsx
13
+ /**
14
+ * The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
15
+ */
16
+ function PowerShellScriptCompletionsCommand() {
17
+ const context = usePowerlines();
18
+ const bin = computed(() => getAppBin(context));
19
+ return createComponent(TypescriptFile, {
20
+ get path() {
21
+ return joinPaths(context.entryPath, "completions", "powershell", "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 PowerShell Completions - Script command." }),
38
+ createComponent(InterfaceDeclaration, {
39
+ "export": true,
40
+ name: "PowerShellScriptCompletionsOptions",
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 powershell 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: "PowerShellScriptCompletionsOptions",
70
+ default: "{}"
71
+ }, {
72
+ name: "path",
73
+ type: "string",
74
+ default: `"${bin.value}-completions.ps1"`
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}.ps1\` : path;`
86
+ }), memo(() => code`await writeFile(scriptPath, \`# PowerShell script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
87
+
88
+ success(\`${getAppTitle(context)} PowerShell completion script has been generated at \${colors.bold(scriptPath)}.\`);`)];
89
+ }
90
+ }), createComponent(ElseClause, { get children() {
91
+ return code`writeLine(" ------------------------------------------------- ");
92
+ writeLine(\`# PowerShell completions 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 { PowerShellScriptCompletionsCommand };
106
+ //# sourceMappingURL=powershell-script-command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powershell-script-command.mjs","names":[],"sources":["../../src/components/powershell-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 PowerShell Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function PowerShellScriptCompletionsCommand() {\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 \"powershell\",\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 PowerShell Completions - Script command.\" />\n <InterfaceDeclaration export name=\"PowerShellScriptCompletionsOptions\">\n <TSDoc heading=\"Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.\">\n <TSDocDefaultValue\n type={ReflectionKind.boolean}\n defaultValue={false}\n />\n </TSDoc>\n <InterfaceMember name=\"display\" optional type=\"boolean\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions powershell script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"PowerShellScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"${bin.value}-completions.ps1\"`\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}.ps1\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# PowerShell script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} PowerShell completion script has been generated at \\${colors.bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\\`# PowerShell completions 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,qCAAA;CACL,MAAK,UAAA,eAAA;CACL,MAAA,MAAA,eAAA,UAAA,QAAA,CAAA;AACA,QAAO,gBAAkB,gBAAgB;EAC3C,IAAQ,OAAC;AACH,UAAG,UAAY,QAAO,WAAY,eAAA,cAAA,UAAA,aAAA;;;GAGtC,WAAA;GACI,aAAY,CAAA,OAAA;GAChB,oBAAA,CAAA,YAAA,YAAA;GACI,aAAU,CAAA,qBAAA,4BAAqC;GACnD;oBAEA,uBAA2B;GAAA;GAAU;GAAS;GAAA;GAAA;EAE9C,IAAM,WAAC;AACJ,UAAA;IAAA,gBAAA,SAAA,EACC,SAAM,4DACL,CAAC;IAAA,gBAAiB,sBAAA;KACjB,UAAC;KACD,MAAC;KACD,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,sEACJ,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,4EAAA,YAAA,QAAA,CAAA;;wBAEJ,YAAY,QAAQ,CAAC,sFAAgC,CAAA;;OAElE,CAAA,EAAA,gBAAqB,YAAY;AAEhC,cAAS,IAAG;uDACV,YAAA,QAAA,CAAA;;;;SAKH,CAAC,CAAA;;KAEL,CAAC;IAAC;;EAEN,CAAC"}