@shell-shock/plugin-completions 0.4.3 → 0.4.4
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.
- package/dist/components/bash-config-command.cjs +5 -4
- package/dist/components/bash-config-command.mjs +5 -4
- package/dist/components/bash-config-command.mjs.map +1 -1
- package/dist/components/bash-script-command.cjs +3 -3
- package/dist/components/bash-script-command.mjs +3 -3
- package/dist/components/bash-script-command.mjs.map +1 -1
- package/dist/components/bash-shared.cjs +27 -14
- package/dist/components/bash-shared.mjs +27 -14
- package/dist/components/bash-shared.mjs.map +1 -1
- package/dist/components/fish-config-command.cjs +5 -4
- package/dist/components/fish-config-command.mjs +5 -4
- package/dist/components/fish-config-command.mjs.map +1 -1
- package/dist/components/fish-script-command.cjs +3 -3
- package/dist/components/fish-script-command.mjs +3 -3
- package/dist/components/fish-script-command.mjs.map +1 -1
- package/dist/components/fish-shared.cjs +27 -14
- package/dist/components/fish-shared.mjs +27 -14
- package/dist/components/fish-shared.mjs.map +1 -1
- package/dist/components/powershell-config-command.cjs +4 -3
- package/dist/components/powershell-config-command.mjs +4 -3
- package/dist/components/powershell-config-command.mjs.map +1 -1
- package/dist/components/powershell-script-command.cjs +3 -3
- package/dist/components/powershell-script-command.mjs +3 -3
- package/dist/components/powershell-script-command.mjs.map +1 -1
- package/dist/components/powershell-shared.cjs +27 -14
- package/dist/components/powershell-shared.mjs +27 -14
- package/dist/components/powershell-shared.mjs.map +1 -1
- package/dist/components/zsh-config-command.cjs +5 -4
- package/dist/components/zsh-config-command.mjs +5 -4
- package/dist/components/zsh-config-command.mjs.map +1 -1
- package/dist/components/zsh-script-command.cjs +3 -3
- package/dist/components/zsh-script-command.mjs +3 -3
- package/dist/components/zsh-script-command.mjs.map +1 -1
- package/dist/components/zsh-shared.cjs +27 -14
- package/dist/components/zsh-shared.mjs +27 -14
- package/dist/components/zsh-shared.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -26,8 +26,9 @@ function BashConfigCompletionsCommand() {
|
|
|
26
26
|
"node:fs/promises": ["readFile", "writeFile"],
|
|
27
27
|
"../shared": ["SHELL_COMPLETIONS_DISPLAY", "SHELL_COMPLETIONS"]
|
|
28
28
|
},
|
|
29
|
-
builtinImports: {
|
|
30
|
-
"
|
|
29
|
+
builtinImports: { console: [
|
|
30
|
+
"bold",
|
|
31
|
+
"inlineCode",
|
|
31
32
|
"writeLine",
|
|
32
33
|
"success",
|
|
33
34
|
"warn",
|
|
@@ -102,7 +103,7 @@ function BashConfigCompletionsCommand() {
|
|
|
102
103
|
} catch (error) {
|
|
103
104
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
104
105
|
// If the file doesn't exist, we can create it later when writing the completion script.
|
|
105
|
-
warn(\`Configuration file \${
|
|
106
|
+
warn(\`Configuration file \${bold(configPath)} does not exist. It will be created when the completion script is written.\`);
|
|
106
107
|
} else {
|
|
107
108
|
return { error };
|
|
108
109
|
}
|
|
@@ -110,7 +111,7 @@ function BashConfigCompletionsCommand() {
|
|
|
110
111
|
|
|
111
112
|
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 ###\`);
|
|
112
113
|
|
|
113
|
-
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} shell completions have been applied to Bash configuration file at \${
|
|
114
|
+
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} shell completions have been applied to Bash configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)
|
|
114
115
|
];
|
|
115
116
|
}
|
|
116
117
|
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
@@ -25,8 +25,9 @@ function BashConfigCompletionsCommand() {
|
|
|
25
25
|
"node:fs/promises": ["readFile", "writeFile"],
|
|
26
26
|
"../shared": ["SHELL_COMPLETIONS_DISPLAY", "SHELL_COMPLETIONS"]
|
|
27
27
|
},
|
|
28
|
-
builtinImports: {
|
|
29
|
-
"
|
|
28
|
+
builtinImports: { console: [
|
|
29
|
+
"bold",
|
|
30
|
+
"inlineCode",
|
|
30
31
|
"writeLine",
|
|
31
32
|
"success",
|
|
32
33
|
"warn",
|
|
@@ -101,7 +102,7 @@ function BashConfigCompletionsCommand() {
|
|
|
101
102
|
} catch (error) {
|
|
102
103
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
103
104
|
// If the file doesn't exist, we can create it later when writing the completion script.
|
|
104
|
-
warn(\`Configuration file \${
|
|
105
|
+
warn(\`Configuration file \${bold(configPath)} does not exist. It will be created when the completion script is written.\`);
|
|
105
106
|
} else {
|
|
106
107
|
return { error };
|
|
107
108
|
}
|
|
@@ -109,7 +110,7 @@ function BashConfigCompletionsCommand() {
|
|
|
109
110
|
|
|
110
111
|
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${getAppTitle(context)} Shell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${getAppTitle(context)} Bash Completions ###\`);
|
|
111
112
|
|
|
112
|
-
success(\`${getAppTitle(context)} shell completions have been applied to Bash configuration file at \${
|
|
113
|
+
success(\`${getAppTitle(context)} shell completions have been applied to Bash configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)
|
|
113
114
|
];
|
|
114
115
|
}
|
|
115
116
|
}), createComponent(ElseClause, { get children() {
|
|
@@ -1 +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\", \"SHELL_COMPLETIONS\"]\n }}\n builtinImports={{\n
|
|
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\", \"SHELL_COMPLETIONS\"]\n }}\n builtinImports={{\n console: [\"bold\", \"inlineCode\", \"writeLine\", \"success\", \"warn\", \"help\"]\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 \\${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 \\${bold(configPath)}. Please restart your terminal or run \\${inlineCode(\\`source \\${configPath}\\`)} for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n 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 writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.bashrc)\n 2) Save the above script to a file and source it from your shell configuration file \\`); `}\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,6BAAA,oBAAA;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,CAAC;;OAET,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,6MAA0D;SAAA;;OAE1F,CAAC,EAAE,gBAAK,YAAA,EACP,IAAE,WAAS;AACX,cAAA,IAAA;;;;;;;;;;;;;;;SAgBF,CAAA,CAAA;;KAEH,CAAC;IAAC;;EAEN,CAAC"}
|
|
@@ -27,8 +27,8 @@ function BashScriptCompletionsCommand() {
|
|
|
27
27
|
"node:fs/promises": ["readFile", "writeFile"],
|
|
28
28
|
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
29
29
|
},
|
|
30
|
-
builtinImports: {
|
|
31
|
-
"
|
|
30
|
+
builtinImports: { console: [
|
|
31
|
+
"bold",
|
|
32
32
|
"writeLine",
|
|
33
33
|
"success",
|
|
34
34
|
"warn",
|
|
@@ -88,7 +88,7 @@ function BashScriptCompletionsCommand() {
|
|
|
88
88
|
}), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`
|
|
89
89
|
await writeFile(scriptPath, \`# Bash script to add completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
90
90
|
|
|
91
|
-
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Bash completion script has been generated at \${
|
|
91
|
+
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Bash completion script has been generated at \${bold(scriptPath)}.\`); `)];
|
|
92
92
|
}
|
|
93
93
|
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
94
94
|
return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
@@ -26,8 +26,8 @@ function BashScriptCompletionsCommand() {
|
|
|
26
26
|
"node:fs/promises": ["readFile", "writeFile"],
|
|
27
27
|
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
28
28
|
},
|
|
29
|
-
builtinImports: {
|
|
30
|
-
"
|
|
29
|
+
builtinImports: { console: [
|
|
30
|
+
"bold",
|
|
31
31
|
"writeLine",
|
|
32
32
|
"success",
|
|
33
33
|
"warn",
|
|
@@ -87,7 +87,7 @@ function BashScriptCompletionsCommand() {
|
|
|
87
87
|
}), memo(() => code`
|
|
88
88
|
await writeFile(scriptPath, \`# Bash script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
89
89
|
|
|
90
|
-
success(\`${getAppTitle(context)} Bash completion script has been generated at \${
|
|
90
|
+
success(\`${getAppTitle(context)} Bash completion script has been generated at \${bold(scriptPath)}.\`); `)];
|
|
91
91
|
}
|
|
92
92
|
}), createComponent(ElseClause, { get children() {
|
|
93
93
|
return code`writeLine(" ------------------------------------------------- ");
|
|
@@ -1 +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
|
|
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 console: [\"bold\", \"writeLine\", \"success\", \"warn\", \"help\"]\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`\n 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 \\${bold(scriptPath)}.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\\`# Bash completion for ${getAppTitle(context)}\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.bashrc)\n 2) Save the above script to a file and source it from your shell configuration file \\`); `}\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,SAAY;GAAA;GAAU;GAAK;GAAmB;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;+EACJ,YAAA,QAAA,CAAA;;sBAEb,YAAA,QAAA,CAAA,0EAAA,CAAA;;OAED,CAAA,EAAA,gBAAgB,YAAgB;AAEhC,cAAW,IAAC;;gDAEuB,YAAe,QAAM,CAAA;;;;;;;;;;;SAYvD,CAAC,CAAA;;KAEL,CAAC;IAAC;;EAEN,CAAC"}
|
|
@@ -24,7 +24,20 @@ function BashCompletionsShared() {
|
|
|
24
24
|
get path() {
|
|
25
25
|
return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "bash", "shared.ts");
|
|
26
26
|
},
|
|
27
|
-
builtinImports: { console: [
|
|
27
|
+
builtinImports: { console: [
|
|
28
|
+
"white",
|
|
29
|
+
"green",
|
|
30
|
+
"red",
|
|
31
|
+
"bold",
|
|
32
|
+
"cyan",
|
|
33
|
+
"gray",
|
|
34
|
+
"magenta",
|
|
35
|
+
"magentaBright",
|
|
36
|
+
"greenBright",
|
|
37
|
+
"redBright",
|
|
38
|
+
"cyanBright",
|
|
39
|
+
"dim"
|
|
40
|
+
] },
|
|
28
41
|
get children() {
|
|
29
42
|
return [
|
|
30
43
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
@@ -145,21 +158,21 @@ complete -F __${name.value}_complete ${bin.value}
|
|
|
145
158
|
return "";
|
|
146
159
|
}
|
|
147
160
|
if (line.trim().startsWith("#")) {
|
|
148
|
-
return \`\${
|
|
161
|
+
return \`\${dim(line)}\`;
|
|
149
162
|
}
|
|
150
163
|
|
|
151
|
-
return
|
|
152
|
-
.replaceAll(/\\".*\\"/g,
|
|
153
|
-
.replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|:)/g,
|
|
154
|
-
.replaceAll(/(readonly|complete)\\s+/g,
|
|
155
|
-
.replaceAll(/(?<=(readonly|complete)\\s+)\\w/g,
|
|
156
|
-
.replaceAll(/local\\s+/g,
|
|
157
|
-
.replaceAll(/(?<=local\\s+)\\w/g,
|
|
158
|
-
.replaceAll(/while\\s+/g,
|
|
159
|
-
.replaceAll(/(?<=while\\s+)\\w/g,
|
|
160
|
-
.replaceAll(/(if|fi|else|elif|then|done)\\s+/g,
|
|
161
|
-
.replaceAll(/__\\w/g,
|
|
162
|
-
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g,
|
|
164
|
+
return white(line).replaceAll(/(?<=\\\$(\\{|\\()).*(?=(\\}\\)))/g, green("$&"))
|
|
165
|
+
.replaceAll(/\\".*\\"/g, cyan("$&"))
|
|
166
|
+
.replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|:)/g, bold(gray("$&")))
|
|
167
|
+
.replaceAll(/(readonly|complete)\\s+/g, green("$&"))
|
|
168
|
+
.replaceAll(/(?<=(readonly|complete)\\s+)\\w/g, bold(greenBright("$&")))
|
|
169
|
+
.replaceAll(/local\\s+/g, red("$&"))
|
|
170
|
+
.replaceAll(/(?<=local\\s+)\\w/g, bold(redBright("$&")))
|
|
171
|
+
.replaceAll(/while\\s+/g, cyan("$&"))
|
|
172
|
+
.replaceAll(/(?<=while\\s+)\\w/g, bold(cyanBright("$&")))
|
|
173
|
+
.replaceAll(/(if|fi|else|elif|then|done)\\s+/g, green("$&"))
|
|
174
|
+
.replaceAll(/__\\w/g, bold(magentaBright("$&")))
|
|
175
|
+
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
163
176
|
|
|
164
177
|
}).join("\\n"); `
|
|
165
178
|
})
|
|
@@ -23,7 +23,20 @@ function BashCompletionsShared() {
|
|
|
23
23
|
get path() {
|
|
24
24
|
return joinPaths(context.entryPath, "completions", "bash", "shared.ts");
|
|
25
25
|
},
|
|
26
|
-
builtinImports: { console: [
|
|
26
|
+
builtinImports: { console: [
|
|
27
|
+
"white",
|
|
28
|
+
"green",
|
|
29
|
+
"red",
|
|
30
|
+
"bold",
|
|
31
|
+
"cyan",
|
|
32
|
+
"gray",
|
|
33
|
+
"magenta",
|
|
34
|
+
"magentaBright",
|
|
35
|
+
"greenBright",
|
|
36
|
+
"redBright",
|
|
37
|
+
"cyanBright",
|
|
38
|
+
"dim"
|
|
39
|
+
] },
|
|
27
40
|
get children() {
|
|
28
41
|
return [
|
|
29
42
|
createComponent(Spacing, {}),
|
|
@@ -144,21 +157,21 @@ complete -F __${name.value}_complete ${bin.value}
|
|
|
144
157
|
return "";
|
|
145
158
|
}
|
|
146
159
|
if (line.trim().startsWith("#")) {
|
|
147
|
-
return \`\${
|
|
160
|
+
return \`\${dim(line)}\`;
|
|
148
161
|
}
|
|
149
162
|
|
|
150
|
-
return
|
|
151
|
-
.replaceAll(/\\".*\\"/g,
|
|
152
|
-
.replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|:)/g,
|
|
153
|
-
.replaceAll(/(readonly|complete)\\s+/g,
|
|
154
|
-
.replaceAll(/(?<=(readonly|complete)\\s+)\\w/g,
|
|
155
|
-
.replaceAll(/local\\s+/g,
|
|
156
|
-
.replaceAll(/(?<=local\\s+)\\w/g,
|
|
157
|
-
.replaceAll(/while\\s+/g,
|
|
158
|
-
.replaceAll(/(?<=while\\s+)\\w/g,
|
|
159
|
-
.replaceAll(/(if|fi|else|elif|then|done)\\s+/g,
|
|
160
|
-
.replaceAll(/__\\w/g,
|
|
161
|
-
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g,
|
|
163
|
+
return white(line).replaceAll(/(?<=\\\$(\\{|\\()).*(?=(\\}\\)))/g, green("$&"))
|
|
164
|
+
.replaceAll(/\\".*\\"/g, cyan("$&"))
|
|
165
|
+
.replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|:)/g, bold(gray("$&")))
|
|
166
|
+
.replaceAll(/(readonly|complete)\\s+/g, green("$&"))
|
|
167
|
+
.replaceAll(/(?<=(readonly|complete)\\s+)\\w/g, bold(greenBright("$&")))
|
|
168
|
+
.replaceAll(/local\\s+/g, red("$&"))
|
|
169
|
+
.replaceAll(/(?<=local\\s+)\\w/g, bold(redBright("$&")))
|
|
170
|
+
.replaceAll(/while\\s+/g, cyan("$&"))
|
|
171
|
+
.replaceAll(/(?<=while\\s+)\\w/g, bold(cyanBright("$&")))
|
|
172
|
+
.replaceAll(/(if|fi|else|elif|then|done)\\s+/g, green("$&"))
|
|
173
|
+
.replaceAll(/__\\w/g, bold(magentaBright("$&")))
|
|
174
|
+
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, bold(magenta("$&")));
|
|
162
175
|
|
|
163
176
|
}).join("\\n"); `
|
|
164
177
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash-shared.mjs","names":[],"sources":["../../src/components/bash-shared.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Bash Completions generation for the Shell Shock project.\n */\nexport function BashCompletionsShared() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n const name = computed(() => snakeCase(bin.value));\n\n return (\n <TypescriptFile\n path={joinPaths(context.entryPath, \"completions\", \"bash\", \"shared.ts\")}\n builtinImports={{\n console: [\"
|
|
1
|
+
{"version":3,"file":"bash-shared.mjs","names":[],"sources":["../../src/components/bash-shared.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { CompletionDirective } from \"../helpers\";\nimport { EXEC_COMMAND } from \"../helpers/complete-command\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Bash Completions generation for the Shell Shock project.\n */\nexport function BashCompletionsShared() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n const name = computed(() => snakeCase(bin.value));\n\n return (\n <TypescriptFile\n path={joinPaths(context.entryPath, \"completions\", \"bash\", \"shared.ts\")}\n builtinImports={{\n console: [\n \"white\",\n \"green\",\n \"red\",\n \"bold\",\n \"cyan\",\n \"gray\",\n \"magenta\",\n \"magentaBright\",\n \"greenBright\",\n \"redBright\",\n \"cyanBright\",\n \"dim\"\n ]\n }}>\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS\"\n initializer={code` \\`# Define shell completion directives\nreadonly ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}\nreadonly ShellCompDirectiveNoSpace=${\n CompletionDirective.CompletionDirectiveNoSpace\n }\nreadonly ShellCompDirectiveNoFileComp=${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\nreadonly ShellCompDirectiveFilterFileExt=${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\nreadonly ShellCompDirectiveFilterDirs=${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\nreadonly ShellCompDirectiveKeepOrder=${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n\n# Function to debug completion\n__${name.value}_debug() {\n if [[ -n \\\\\\${BASH_COMP_DEBUG_FILE:-} ]]; then\n echo \"$*\" >> \"\\\\\\${BASH_COMP_DEBUG_FILE}\"\n fi\n}\n\n# Function to handle completions\n__${name.value}_complete() {\n local cur prev words cword\n _get_comp_words_by_ref -n \"=:\" cur prev words cword\n\n local requestComp out directive\n\n # Build the command to get completions\n requestComp=\"${EXEC_COMMAND} complete -- \\\\\\${words[@]:1}\"\n\n # Add an empty parameter if the last parameter is complete\n if [[ -z \"$cur\" ]]; then\n requestComp=\"$requestComp ''\"\n fi\n\n # Get completions from the program\n out=$(eval \"$requestComp\" 2>/dev/null)\n\n # Extract directive if present\n directive=0\n if [[ \"$out\" == *:* ]]; then\n directive=\\\\\\${out##*:}\n out=\\\\\\${out%:*}\n fi\n\n # Process completions based on directive\n if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then\n # Error, no completion\n return\n fi\n\n # Apply directives\n if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then\n compopt -o nospace\n fi\n if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then\n compopt -o nosort\n fi\n if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then\n compopt +o default\n fi\n\n # Handle file extension filtering\n if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then\n local filter=\"\"\n for ext in $out; do\n filter=\"$filter|$ext\"\n done\n filter=\"\\\\.($filter)\"\n compopt -o filenames\n COMPREPLY=( $(compgen -f -X \"!$filter\" -- \"$cur\") )\n return\n fi\n\n # Handle directory filtering\n if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then\n compopt -o dirnames\n COMPREPLY=( $(compgen -d -- \"$cur\") )\n return\n fi\n\n # Process completions\n local IFS=$'\\\\n'\n local tab=$(printf '\\\\t')\n\n # Parse completions with descriptions\n local completions=()\n while read -r comp; do\n if [[ \"$comp\" == *$tab* ]]; then\n # Split completion and description\n local value=\\\\\\${comp%%$tab*}\n local desc=\\\\\\${comp#*$tab}\n completions+=(\"$value\")\n else\n completions+=(\"$comp\")\n fi\n done <<< \"$out\"\n\n # Return completions\n COMPREPLY=( $(compgen -W \"\\\\\\${completions[*]}\" -- \"$cur\") )\n}\n\n# Register completion function\ncomplete -F __${name.value}_complete ${bin.value}\n\\`; `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"SHELL_COMPLETIONS_DISPLAY\"\n initializer={code` SHELL_COMPLETIONS.split(\"\\\\n\").map(line => {\n if (!line.trim()) {\n return \"\";\n }\n if (line.trim().startsWith(\"#\")) {\n return \\`\\${dim(line)}\\`;\n }\n\n return white(line).replaceAll(/(?<=\\\\\\$(\\\\{|\\\\()).*(?=(\\\\}\\\\)))/g, green(\"$&\"))\n .replaceAll(/\\\\\".*\\\\\"/g, cyan(\"$&\"))\n .replaceAll(/(\\\\[|\\\\]|\\\\(|\\\\)|\\\\||<|>|\\\\$\\\\(|\\\\$?\\\\{|\\\\}|\\\\+|=|;|:)/g, bold(gray(\"$&\")))\n .replaceAll(/(readonly|complete)\\\\s+/g, green(\"$&\"))\n .replaceAll(/(?<=(readonly|complete)\\\\s+)\\\\w/g, bold(greenBright(\"$&\")))\n .replaceAll(/local\\\\s+/g, red(\"$&\"))\n .replaceAll(/(?<=local\\\\s+)\\\\w/g, bold(redBright(\"$&\")))\n .replaceAll(/while\\\\s+/g, cyan(\"$&\"))\n .replaceAll(/(?<=while\\\\s+)\\\\w/g, bold(cyanBright(\"$&\")))\n .replaceAll(/(if|fi|else|elif|then|done)\\\\s+/g, green(\"$&\"))\n .replaceAll(/__\\\\w/g, bold(magentaBright(\"$&\")))\n .replaceAll(/(?<=\\\\s)(-\\\\w|--\\\\w[\\\\w-]*)(?=\\\\s|$)/g, bold(magenta(\"$&\")));\n\n }).join(\"\\\\n\"); `}\n />\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkCA,SAAgB,wBAAgB;;CAE9B,MAAM,MAAM,eAAe,UAAU,QAAQ,CAAC;CAC9C,MAAM,OAAO,eAAe,UAAU,IAAI,MAAM,CAAC;;EAEjD,IAAM,OAAC;AACJ,UAAA,UAAA,QAAA,WAAA,eAAA,QAAA,YAAA;;EAED,gBAAgB,EACd,SAAS;GAAC;GAAC;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA;GAAA,EACZ;EACD,IAAI,WAAS;AACX,UAAK;IAAG,gBAAC,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACP,UAAQ;KACR,SAAQ;KACR,MAAG;KACH,IAAG,cAAQ;AACT,aAAC,IAAA;mCACY,oBAAA,yBAAA;qCACF,oBAAA,2BAAA;wCACC,oBAAA,8BAAA;2CACR,oBAAA,iCAAA;wCACN,oBAAA,8BAAA;uCACA,oBAAA,6BAAA;;;IAGJ,KAAI,MAAA;;;;;;;IAOJ,KAAI,MAAA;;;;;;;mBAOC,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2EK,KAAA,MAAA,YAAA,IAAA,MAAA;;;;;;KAIR,UAAM;KACR,SAAM;KACN,MAAU;KACN,aAAa,IAAI;;;;;;;;;;;;;;;;;;;;;;KAsBlB,CAAC;IAAA;;EAEL,CAAC"}
|
|
@@ -26,8 +26,9 @@ function FishConfigCompletionsCommand() {
|
|
|
26
26
|
"node:fs/promises": ["readFile", "writeFile"],
|
|
27
27
|
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
28
28
|
},
|
|
29
|
-
builtinImports: {
|
|
30
|
-
"
|
|
29
|
+
builtinImports: { console: [
|
|
30
|
+
"bold",
|
|
31
|
+
"inlineCode",
|
|
31
32
|
"writeLine",
|
|
32
33
|
"success",
|
|
33
34
|
"warn",
|
|
@@ -102,7 +103,7 @@ function FishConfigCompletionsCommand() {
|
|
|
102
103
|
} catch (error) {
|
|
103
104
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
104
105
|
// If the file doesn't exist, we can create it later when writing the completion script.
|
|
105
|
-
warn(\`Configuration file \${
|
|
106
|
+
warn(\`Configuration file \${bold(configPath)} does not exist. It will be created when the completion script is written.\`);
|
|
106
107
|
} else {
|
|
107
108
|
return { error };
|
|
108
109
|
}
|
|
@@ -110,7 +111,7 @@ function FishConfigCompletionsCommand() {
|
|
|
110
111
|
|
|
111
112
|
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish Completions ###\`);
|
|
112
113
|
|
|
113
|
-
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} shell completions have been applied to Fish configuration file at \${
|
|
114
|
+
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} shell completions have been applied to Fish configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)
|
|
114
115
|
];
|
|
115
116
|
}
|
|
116
117
|
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
@@ -25,8 +25,9 @@ function FishConfigCompletionsCommand() {
|
|
|
25
25
|
"node:fs/promises": ["readFile", "writeFile"],
|
|
26
26
|
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
27
27
|
},
|
|
28
|
-
builtinImports: {
|
|
29
|
-
"
|
|
28
|
+
builtinImports: { console: [
|
|
29
|
+
"bold",
|
|
30
|
+
"inlineCode",
|
|
30
31
|
"writeLine",
|
|
31
32
|
"success",
|
|
32
33
|
"warn",
|
|
@@ -101,7 +102,7 @@ function FishConfigCompletionsCommand() {
|
|
|
101
102
|
} catch (error) {
|
|
102
103
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
103
104
|
// If the file doesn't exist, we can create it later when writing the completion script.
|
|
104
|
-
warn(\`Configuration file \${
|
|
105
|
+
warn(\`Configuration file \${bold(configPath)} does not exist. It will be created when the completion script is written.\`);
|
|
105
106
|
} else {
|
|
106
107
|
return { error };
|
|
107
108
|
}
|
|
@@ -109,7 +110,7 @@ function FishConfigCompletionsCommand() {
|
|
|
109
110
|
|
|
110
111
|
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${getAppTitle(context)} Fish Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${getAppTitle(context)} Fish Completions ###\`);
|
|
111
112
|
|
|
112
|
-
success(\`${getAppTitle(context)} shell completions have been applied to Fish configuration file at \${
|
|
113
|
+
success(\`${getAppTitle(context)} shell completions have been applied to Fish configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)
|
|
113
114
|
];
|
|
114
115
|
}
|
|
115
116
|
}), createComponent(ElseClause, { get children() {
|
|
@@ -1 +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
|
|
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 console: [\"bold\", \"inlineCode\", \"writeLine\", \"success\", \"warn\", \"help\"]\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 \\${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 \\${bold(configPath)}. Please restart your terminal or run \\${inlineCode(\\`source \\${configPath}\\`)} for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n 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 writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/fish/config.fish)\n 2) Save the above script to a file and source it from your shell configuration file \\`); `}\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,SAAG;GAAA;GAAY;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;AACd,eAAW,gBAAoB,mBAAe;SAC9C,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,6MAAA;SAAA;;OAEA,CAAA,EAAA,gBAAgB,YAAiB,EAC/B,IAAA,WAAA;AACC,cAAK,IAAA;;sCAEe,YAAA,QAAA,CAAA;;;;oCAId,YAAA,QAAA,CAAA;;;;;;;;;;;KAYZ,CAAC;IAAC;;EAEN,CAAC"}
|
|
@@ -27,8 +27,8 @@ function FishScriptCompletionsCommand() {
|
|
|
27
27
|
"node:fs/promises": ["readFile", "writeFile"],
|
|
28
28
|
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
29
29
|
},
|
|
30
|
-
builtinImports: {
|
|
31
|
-
"
|
|
30
|
+
builtinImports: { console: [
|
|
31
|
+
"bold",
|
|
32
32
|
"writeLine",
|
|
33
33
|
"success",
|
|
34
34
|
"warn",
|
|
@@ -87,7 +87,7 @@ function FishScriptCompletionsCommand() {
|
|
|
87
87
|
initializer: _alloy_js_core.code` path.includes(".") ? \`\${path}.fish\` : path;`
|
|
88
88
|
}), (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}\`);
|
|
89
89
|
|
|
90
|
-
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish completion script has been generated at \${
|
|
90
|
+
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish completion script has been generated at \${bold(scriptPath)}.\`);`)];
|
|
91
91
|
}
|
|
92
92
|
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
93
93
|
return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
@@ -26,8 +26,8 @@ function FishScriptCompletionsCommand() {
|
|
|
26
26
|
"node:fs/promises": ["readFile", "writeFile"],
|
|
27
27
|
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
28
28
|
},
|
|
29
|
-
builtinImports: {
|
|
30
|
-
"
|
|
29
|
+
builtinImports: { console: [
|
|
30
|
+
"bold",
|
|
31
31
|
"writeLine",
|
|
32
32
|
"success",
|
|
33
33
|
"warn",
|
|
@@ -86,7 +86,7 @@ function FishScriptCompletionsCommand() {
|
|
|
86
86
|
initializer: code` path.includes(".") ? \`\${path}.fish\` : path;`
|
|
87
87
|
}), memo(() => code`await writeFile(scriptPath, \`# Fish script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
88
88
|
|
|
89
|
-
success(\`${getAppTitle(context)} Fish completion script has been generated at \${
|
|
89
|
+
success(\`${getAppTitle(context)} Fish completion script has been generated at \${bold(scriptPath)}.\`);`)];
|
|
90
90
|
}
|
|
91
91
|
}), createComponent(ElseClause, { get children() {
|
|
92
92
|
return code`writeLine(" ------------------------------------------------- ");
|
|
@@ -1 +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
|
|
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 console: [\"bold\", \"writeLine\", \"success\", \"warn\", \"help\"]\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 \\${bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\\`# Fish completion for ${getAppTitle(context)}\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/fish/config.fish)\n 2) Save the above script to a file and source it from your shell configuration file \\`); `}\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,SAAY;GAAA;GAAU;GAAK;GAAmB;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,yEAAiC,CAAA;;OAEnE,CAAA,EAAA,gBAAqB,YAAY;AAEhC,cAAS,IAAG;;gDAEuB,YAAa,QAAQ,CAAA;;;;;;;;;;;SAYzD,CAAC,CAAA;;KAEL,CAAC;IAAC;;EAEN,CAAC"}
|