@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.
- package/README.md +1 -1
- package/dist/components/bash-config-command.cjs +132 -0
- package/dist/components/bash-config-command.d.cts +10 -0
- package/dist/components/bash-config-command.d.cts.map +1 -0
- package/dist/components/bash-config-command.d.mts +10 -0
- package/dist/components/bash-config-command.d.mts.map +1 -0
- package/dist/components/bash-config-command.mjs +132 -0
- package/dist/components/bash-config-command.mjs.map +1 -0
- package/dist/components/bash-script-command.cjs +106 -0
- package/dist/components/bash-script-command.d.cts +10 -0
- package/dist/components/bash-script-command.d.cts.map +1 -0
- package/dist/components/bash-script-command.d.mts +10 -0
- package/dist/components/bash-script-command.d.mts.map +1 -0
- package/dist/components/bash-script-command.mjs +106 -0
- package/dist/components/bash-script-command.mjs.map +1 -0
- package/dist/components/bash-shared.cjs +172 -0
- package/dist/components/bash-shared.d.cts +10 -0
- package/dist/components/bash-shared.d.cts.map +1 -0
- package/dist/components/bash-shared.d.mts +10 -0
- package/dist/components/bash-shared.d.mts.map +1 -0
- package/dist/components/bash-shared.mjs +172 -0
- package/dist/components/bash-shared.mjs.map +1 -0
- package/dist/components/fish-config-command.cjs +132 -0
- package/dist/components/fish-config-command.d.cts +10 -0
- package/dist/components/fish-config-command.d.cts.map +1 -0
- package/dist/components/fish-config-command.d.mts +10 -0
- package/dist/components/fish-config-command.d.mts.map +1 -0
- package/dist/components/fish-config-command.mjs +132 -0
- package/dist/components/fish-config-command.mjs.map +1 -0
- package/dist/components/fish-script-command.cjs +106 -0
- package/dist/components/fish-script-command.d.cts +10 -0
- package/dist/components/fish-script-command.d.cts.map +1 -0
- package/dist/components/fish-script-command.d.mts +10 -0
- package/dist/components/fish-script-command.d.mts.map +1 -0
- package/dist/components/fish-script-command.mjs +106 -0
- package/dist/components/fish-script-command.mjs.map +1 -0
- package/dist/components/{fish-command.cjs → fish-shared.cjs} +40 -144
- package/dist/components/fish-shared.d.cts +10 -0
- package/dist/components/fish-shared.d.cts.map +1 -0
- package/dist/components/fish-shared.d.mts +10 -0
- package/dist/components/fish-shared.d.mts.map +1 -0
- package/dist/components/{fish-command.mjs → fish-shared.mjs} +45 -149
- package/dist/components/fish-shared.mjs.map +1 -0
- package/dist/components/index.cjs +24 -8
- package/dist/components/index.d.cts +13 -5
- package/dist/components/index.d.mts +13 -5
- package/dist/components/index.mjs +13 -5
- package/dist/components/powershell-config-command.cjs +128 -0
- package/dist/components/powershell-config-command.d.cts +7 -0
- package/dist/components/powershell-config-command.d.cts.map +1 -0
- package/dist/components/powershell-config-command.d.mts +7 -0
- package/dist/components/powershell-config-command.d.mts.map +1 -0
- package/dist/components/powershell-config-command.mjs +128 -0
- package/dist/components/powershell-config-command.mjs.map +1 -0
- package/dist/components/powershell-script-command.cjs +106 -0
- package/dist/components/powershell-script-command.d.cts +10 -0
- package/dist/components/powershell-script-command.d.cts.map +1 -0
- package/dist/components/powershell-script-command.d.mts +10 -0
- package/dist/components/powershell-script-command.d.mts.map +1 -0
- package/dist/components/powershell-script-command.mjs +106 -0
- package/dist/components/powershell-script-command.mjs.map +1 -0
- package/dist/components/{powershell-command.cjs → powershell-shared.cjs} +40 -146
- package/dist/components/powershell-shared.d.cts +10 -0
- package/dist/components/powershell-shared.d.cts.map +1 -0
- package/dist/components/powershell-shared.d.mts +10 -0
- package/dist/components/powershell-shared.d.mts.map +1 -0
- package/dist/components/{powershell-command.mjs → powershell-shared.mjs} +44 -150
- package/dist/components/powershell-shared.mjs.map +1 -0
- package/dist/components/zsh-config-command.cjs +132 -0
- package/dist/components/zsh-config-command.d.cts +10 -0
- package/dist/components/zsh-config-command.d.cts.map +1 -0
- package/dist/components/zsh-config-command.d.mts +10 -0
- package/dist/components/zsh-config-command.d.mts.map +1 -0
- package/dist/components/zsh-config-command.mjs +132 -0
- package/dist/components/zsh-config-command.mjs.map +1 -0
- package/dist/components/zsh-script-command.cjs +111 -0
- package/dist/components/zsh-script-command.d.cts +10 -0
- package/dist/components/zsh-script-command.d.cts.map +1 -0
- package/dist/components/zsh-script-command.d.mts +10 -0
- package/dist/components/zsh-script-command.d.mts.map +1 -0
- package/dist/components/zsh-script-command.mjs +111 -0
- package/dist/components/zsh-script-command.mjs.map +1 -0
- package/dist/components/{zsh-command.cjs → zsh-shared.cjs} +41 -147
- package/dist/components/zsh-shared.d.cts +10 -0
- package/dist/components/zsh-shared.d.cts.map +1 -0
- package/dist/components/zsh-shared.d.mts +10 -0
- package/dist/components/zsh-shared.d.mts.map +1 -0
- package/dist/components/{zsh-command.mjs → zsh-shared.mjs} +45 -151
- package/dist/components/zsh-shared.mjs.map +1 -0
- package/dist/index.cjs +232 -68
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +232 -68
- package/dist/index.mjs.map +1 -1
- package/package.json +148 -36
- package/dist/components/bash-command.cjs +0 -276
- package/dist/components/bash-command.d.cts +0 -10
- package/dist/components/bash-command.d.cts.map +0 -1
- package/dist/components/bash-command.d.mts +0 -10
- package/dist/components/bash-command.d.mts.map +0 -1
- package/dist/components/bash-command.mjs +0 -276
- package/dist/components/bash-command.mjs.map +0 -1
- package/dist/components/fish-command.d.cts +0 -10
- package/dist/components/fish-command.d.cts.map +0 -1
- package/dist/components/fish-command.d.mts +0 -10
- package/dist/components/fish-command.d.mts.map +0 -1
- package/dist/components/fish-command.mjs.map +0 -1
- package/dist/components/powershell-command.d.cts +0 -10
- package/dist/components/powershell-command.d.cts.map +0 -1
- package/dist/components/powershell-command.d.mts +0 -10
- package/dist/components/powershell-command.d.mts.map +0 -1
- package/dist/components/powershell-command.mjs.map +0 -1
- package/dist/components/zsh-command.d.cts +0 -10
- package/dist/components/zsh-command.d.cts.map +0 -1
- package/dist/components/zsh-command.d.mts +0 -10
- package/dist/components/zsh-command.d.mts.map +0 -1
- package/dist/components/zsh-command.mjs.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
3
|
+
import { code } from "@alloy-js/core";
|
|
4
|
+
import { ElseClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
|
|
5
|
+
import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
6
|
+
import { Spacing } from "@powerlines/plugin-alloy/core";
|
|
7
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
|
+
import { TSDoc, TSDocDefaultValue } from "@powerlines/plugin-alloy/typescript";
|
|
9
|
+
import { joinPaths } from "@stryke/path";
|
|
10
|
+
import { TypescriptFile as TypescriptFile$1 } from "@powerlines/plugin-alloy/typescript/components/typescript-file";
|
|
11
|
+
|
|
12
|
+
//#region src/components/fish-config-command.tsx
|
|
13
|
+
/**
|
|
14
|
+
* The Fish Completions - Configuration command's handler wrapper for the Shell Shock project.
|
|
15
|
+
*/
|
|
16
|
+
function FishConfigCompletionsCommand() {
|
|
17
|
+
const context = usePowerlines();
|
|
18
|
+
return createComponent(TypescriptFile$1, {
|
|
19
|
+
get path() {
|
|
20
|
+
return joinPaths(context.entryPath, "completions", "fish", "config", "command.ts");
|
|
21
|
+
},
|
|
22
|
+
imports: {
|
|
23
|
+
"node:os": "os",
|
|
24
|
+
"node:path": ["join"],
|
|
25
|
+
"node:fs/promises": ["readFile", "writeFile"],
|
|
26
|
+
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
27
|
+
},
|
|
28
|
+
builtinImports: { "shell-shock:console": [
|
|
29
|
+
"colors",
|
|
30
|
+
"writeLine",
|
|
31
|
+
"success",
|
|
32
|
+
"warn"
|
|
33
|
+
] },
|
|
34
|
+
get children() {
|
|
35
|
+
return [
|
|
36
|
+
createComponent(TSDoc, { heading: "Options for the Fish Completions - Configuration command." }),
|
|
37
|
+
createComponent(InterfaceDeclaration, {
|
|
38
|
+
"export": true,
|
|
39
|
+
name: "FishConfigCompletionsOptions",
|
|
40
|
+
get children() {
|
|
41
|
+
return [createComponent(TSDoc, {
|
|
42
|
+
heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
|
|
43
|
+
get children() {
|
|
44
|
+
return createComponent(TSDocDefaultValue, {
|
|
45
|
+
get type() {
|
|
46
|
+
return ReflectionKind.boolean;
|
|
47
|
+
},
|
|
48
|
+
defaultValue: false
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}), createComponent(InterfaceMember, {
|
|
52
|
+
name: "display",
|
|
53
|
+
optional: true,
|
|
54
|
+
type: "boolean"
|
|
55
|
+
})];
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
createComponent(Spacing, {}),
|
|
59
|
+
createComponent(TSDoc, { heading: "Handler logic for the \\`completions fish config\\` command." }),
|
|
60
|
+
createComponent(FunctionDeclaration, {
|
|
61
|
+
"export": true,
|
|
62
|
+
"default": true,
|
|
63
|
+
async: true,
|
|
64
|
+
name: "handler",
|
|
65
|
+
parameters: [{
|
|
66
|
+
name: "options",
|
|
67
|
+
type: "FishConfigCompletionsOptions",
|
|
68
|
+
default: "{}"
|
|
69
|
+
}, {
|
|
70
|
+
name: "path",
|
|
71
|
+
type: "string",
|
|
72
|
+
default: `"~/.config/fish/config.fish"`
|
|
73
|
+
}],
|
|
74
|
+
get children() {
|
|
75
|
+
return [createComponent(IfStatement, {
|
|
76
|
+
condition: code`options.display !== true`,
|
|
77
|
+
get children() {
|
|
78
|
+
return [
|
|
79
|
+
createComponent(VarDeclaration, {
|
|
80
|
+
"let": true,
|
|
81
|
+
name: "configPath",
|
|
82
|
+
type: "string",
|
|
83
|
+
initializer: code` path.includes(".") ? path : join(path, ".config", "fish", "config.fish");`
|
|
84
|
+
}),
|
|
85
|
+
createComponent(Spacing, {}),
|
|
86
|
+
createComponent(IfStatement, {
|
|
87
|
+
condition: code`configPath.startsWith("~")`,
|
|
88
|
+
children: code`configPath = join(os.homedir(), configPath.replace("~", "")); `
|
|
89
|
+
}),
|
|
90
|
+
createComponent(Spacing, {}),
|
|
91
|
+
createComponent(VarDeclaration, {
|
|
92
|
+
"let": true,
|
|
93
|
+
name: "content",
|
|
94
|
+
type: "string",
|
|
95
|
+
initializer: code`"";`
|
|
96
|
+
}),
|
|
97
|
+
createComponent(Spacing, {}),
|
|
98
|
+
memo(() => code`try {
|
|
99
|
+
content = await readFile(configPath, "utf8");
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
102
|
+
// If the file doesn't exist, we can create it later when writing the completion script.
|
|
103
|
+
warn(\`Configuration file \${colors.bold(configPath)} does not exist. It will be created when the completion script is written.\`);
|
|
104
|
+
} else {
|
|
105
|
+
return { error };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${getAppTitle(context)} Fish Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${getAppTitle(context)} Fish Completions ###\`);
|
|
110
|
+
|
|
111
|
+
success(\`${getAppTitle(context)} shell completions have been applied to Fish configuration file at \${colors.bold(configPath)}. Please restart your terminal or run \\\`source \${configPath}\\\` for the changes to take effect.\`); `)
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
}), createComponent(ElseClause, { get children() {
|
|
115
|
+
return code`writeLine(" ------------------------------------------------- ");
|
|
116
|
+
writeLine(\`### Begin - ${getAppTitle(context)} Fish Completions ###\`);
|
|
117
|
+
writeLine("");
|
|
118
|
+
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
119
|
+
writeLine("");
|
|
120
|
+
writeLine(\`### End - ${getAppTitle(context)} Fish Completions ###\`);
|
|
121
|
+
writeLine(" ------------------------------------------------- ");`;
|
|
122
|
+
} })];
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { FishConfigCompletionsCommand };
|
|
132
|
+
//# sourceMappingURL=fish-config-command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fish-config-command.mjs","names":[],"sources":["../../src/components/fish-config-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { TSDoc, TSDocDefaultValue } from \"@powerlines/plugin-alloy/typescript\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions - Configuration command's handler wrapper for the Shell Shock project.\n */\nexport function FishConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"fish\",\n \"config\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n \"shell-shock:console\": [\"colors\", \"writeLine\", \"success\", \"warn\"]\n }}>\n <TSDoc heading=\"Options for the Fish Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"FishConfigCompletionsOptions\">\n <TSDoc heading=\"Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.\">\n <TSDocDefaultValue\n type={ReflectionKind.boolean}\n defaultValue={false}\n />\n </TSDoc>\n <InterfaceMember name=\"display\" optional type=\"boolean\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions fish config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"FishConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.config/fish/config.fish\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n let\n name=\"configPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? path : join(path, \".config\", \"fish\", \"config.fish\");`}\n />\n <Spacing />\n <IfStatement condition={code`configPath.startsWith(\"~\")`}>\n {code`configPath = join(os.homedir(), configPath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"content\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n content = await readFile(configPath, \"utf8\");\n } catch (error) {\n if (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${colors.bold(configPath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configPath, \\`\\${content}\\\\n\\\\n### Begin - ${getAppTitle(context)} Fish Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} Fish Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to Fish configuration file at \\${colors.bold(configPath)}. Please restart your terminal or run \\\\\\`source \\${configPath}\\\\\\` for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\\`### Begin - ${getAppTitle(context)} Fish Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} Fish Completions ###\\`);\n writeLine(\" ------------------------------------------------- \");`}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAS,+BAA+B;CACxC,MAAO,UAAO,eAA0C;;EAEtD,IAAA,OAAA;AACI,UAAM,UAAW,QAAG,WAAc,eAAiB,QAAQ,UAAS,aAAY;;EAEtF,SAAO;GACL,WAAe;;GAEf,oBAAO,CAAA,YAAA,YAAA;GACJ,aAAA,CAAA,qBAAA,4BAAA;GACA;EACD,gBAAY,EACV,uBAAe;GAAA;GAAA;GAAA;GAAA;GAAA,EAChB;EACD,IAAI,WAAQ;AACV,UAAG;IAAA,gBAAU,OAAA,EACZ,SAAA,6DACD,CAAA;IAAA,gBAAS,sBAAA;KACP,UAAU;KACV,MAAM;KACN,IAAC,WAAQ;AACP,aAAE,CAAM,gBAAK,OAAoB;OACpC,SAAA;OACD,IAAA,WAAgB;AACR,eAAO,gBAAkB,mBAAiB;SAChD,IAAA,OAAA;AACK,iBAAS,eAAgB;;SAEvB,cAAe;SACnB,CAAA;;OAEA,CAAC,EAAA,gBAAmB,iBAAA;OACpB,MAAA;OACD,UAAK;OACN,MAAA;OACD,CAAA,CAAA;;KAED,CAAA;IAAA,gBAAe,SAAc,EAAG,CAAC;IAAA,gBAAkB,OAAK,EACxD,SAAA,gEACA,CAAC;IAAA,gBAAA,qBAAA;KACA,UAAA;KACA,WAAA;KACA,OAAM;KACN,MAAA;KACA,YAAE,CAAA;MACA,MAAM;MACN,MAAM;MACN,SAAS;MACV,EAAE;MACD,MAAA;MACA,MAAM;MACN,SAAS;MACV,CAAC;KACF,IAAE,WAAA;AACA,aAAA,CAAA,gBAAA,aAAA;OACD,WAAY,IAAA;OACV,IAAA,WAAA;AACC,eAAA;SAAA,gBAAA,gBAAA;UACI,OAAE;UACF,MAAE;UACN,MAAA;UACD,aAAA,IAAA;UACA,CAAA;SAAO,gBAAE,SAAA,EAAA,CAAA;SAAA,gBAAA,aAAA;UACT,WAAY,IAAA;UACV,UAAK,IAAY;UAClB,CAAA;SAAA,gBAAW,SAAA,EAAA,CAAA;SAAA,gBAAA,gBAAA;UACZ,OAAS;UACT,MAAA;UACC,MAAA;UACI,aAAS,IAAA;UACb,CAAI;SAAE,gBAAM,SAAA,EAAA,CAAA;SAAA,WAAA,IAAA;;;;;;;;;;;uEAWM,YAAA,QAAA,CAAA,mEAAA,YAAA,QAAA,CAAA;;sBAEpB,YAAA,QAAA,CAAA,wMAAA;SAAA;;OAEA,CAAA,EAAA,gBAAgB,YAAiB,EAC/B,IAAA,WAAA;AACC,cAAK,IAAA;;;;;oCAKG,YAAA,QAAA,CAAA;;SAGV,CAAC,CAAA;;KAEL,CAAC;IAAC;;EAEN,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
3
|
+
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
|
+
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
7
|
+
let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
|
|
8
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
9
|
+
let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
|
|
10
|
+
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
11
|
+
let _stryke_path = require("@stryke/path");
|
|
12
|
+
|
|
13
|
+
//#region src/components/fish-script-command.tsx
|
|
14
|
+
/**
|
|
15
|
+
* The Fish Completions - Script command's handler wrapper for the Shell Shock project.
|
|
16
|
+
*/
|
|
17
|
+
function FishScriptCompletionsCommand() {
|
|
18
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
19
|
+
const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
|
|
20
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
|
|
21
|
+
get path() {
|
|
22
|
+
return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "fish", "script", "command.ts");
|
|
23
|
+
},
|
|
24
|
+
imports: {
|
|
25
|
+
"node:os": "os",
|
|
26
|
+
"node:path": ["join"],
|
|
27
|
+
"node:fs/promises": ["readFile", "writeFile"],
|
|
28
|
+
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
29
|
+
},
|
|
30
|
+
builtinImports: { "shell-shock:console": [
|
|
31
|
+
"colors",
|
|
32
|
+
"writeLine",
|
|
33
|
+
"success",
|
|
34
|
+
"warn"
|
|
35
|
+
] },
|
|
36
|
+
get children() {
|
|
37
|
+
return [
|
|
38
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Fish Completions - Script command." }),
|
|
39
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
40
|
+
"export": true,
|
|
41
|
+
name: "FishScriptCompletionsOptions",
|
|
42
|
+
get children() {
|
|
43
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
44
|
+
heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
|
|
45
|
+
get children() {
|
|
46
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
47
|
+
get type() {
|
|
48
|
+
return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
|
|
49
|
+
},
|
|
50
|
+
defaultValue: false
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
|
|
54
|
+
name: "display",
|
|
55
|
+
optional: true,
|
|
56
|
+
type: "boolean"
|
|
57
|
+
})];
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
61
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions fish script\\` command." }),
|
|
62
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
63
|
+
"export": true,
|
|
64
|
+
"default": true,
|
|
65
|
+
async: true,
|
|
66
|
+
name: "handler",
|
|
67
|
+
get parameters() {
|
|
68
|
+
return [{
|
|
69
|
+
name: "options",
|
|
70
|
+
type: "FishScriptCompletionsOptions",
|
|
71
|
+
default: "{}"
|
|
72
|
+
}, {
|
|
73
|
+
name: "path",
|
|
74
|
+
type: "string",
|
|
75
|
+
default: `"${bin.value}-completions.fish"`
|
|
76
|
+
}];
|
|
77
|
+
},
|
|
78
|
+
get children() {
|
|
79
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
80
|
+
condition: _alloy_js_core.code`options.display !== true`,
|
|
81
|
+
get children() {
|
|
82
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
83
|
+
"const": true,
|
|
84
|
+
name: "scriptPath",
|
|
85
|
+
type: "string",
|
|
86
|
+
initializer: _alloy_js_core.code` path.includes(".") ? \`\${path}.fish\` : path;`
|
|
87
|
+
}), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`await writeFile(scriptPath, \`# Fish script to add completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
88
|
+
|
|
89
|
+
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Fish completion script has been generated at \${colors.bold(scriptPath)}.\`);`)];
|
|
90
|
+
}
|
|
91
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
92
|
+
return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
93
|
+
writeLine(\`# Fish completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\`);
|
|
94
|
+
writeLine("");
|
|
95
|
+
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
96
|
+
writeLine(" ------------------------------------------------- ");`;
|
|
97
|
+
} })];
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
exports.FishScriptCompletionsCommand = FishScriptCompletionsCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region src/components/fish-script-command.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The Fish Completions - Script command's handler wrapper for the Shell Shock project.
|
|
6
|
+
*/
|
|
7
|
+
declare function FishScriptCompletionsCommand(): _$_alloy_js_core0.Children;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { FishScriptCompletionsCommand };
|
|
10
|
+
//# sourceMappingURL=fish-script-command.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fish-script-command.d.cts","names":[],"sources":["../../src/components/fish-script-command.tsx"],"mappings":";;;;;;iBA4CgB,4BAAA,CAAA,GAA4B,iBAAA,CAAA,QAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region src/components/fish-script-command.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The Fish Completions - Script command's handler wrapper for the Shell Shock project.
|
|
6
|
+
*/
|
|
7
|
+
declare function FishScriptCompletionsCommand(): _$_alloy_js_core0.Children;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { FishScriptCompletionsCommand };
|
|
10
|
+
//# sourceMappingURL=fish-script-command.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fish-script-command.d.mts","names":[],"sources":["../../src/components/fish-script-command.tsx"],"mappings":";;;;;;iBA4CgB,4BAAA,CAAA,GAA4B,iBAAA,CAAA,QAAA"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
3
|
+
import { code, computed } from "@alloy-js/core";
|
|
4
|
+
import { ElseClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
5
|
+
import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
6
|
+
import { Spacing } from "@powerlines/plugin-alloy/core";
|
|
7
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
|
+
import { InterfaceMember as InterfaceMember$1, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
|
|
9
|
+
import { TSDoc as TSDoc$1, TSDocDefaultValue as TSDocDefaultValue$1 } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
10
|
+
import { joinPaths } from "@stryke/path";
|
|
11
|
+
|
|
12
|
+
//#region src/components/fish-script-command.tsx
|
|
13
|
+
/**
|
|
14
|
+
* The Fish Completions - Script command's handler wrapper for the Shell Shock project.
|
|
15
|
+
*/
|
|
16
|
+
function FishScriptCompletionsCommand() {
|
|
17
|
+
const context = usePowerlines();
|
|
18
|
+
const bin = computed(() => getAppBin(context));
|
|
19
|
+
return createComponent(TypescriptFile, {
|
|
20
|
+
get path() {
|
|
21
|
+
return joinPaths(context.entryPath, "completions", "fish", "script", "command.ts");
|
|
22
|
+
},
|
|
23
|
+
imports: {
|
|
24
|
+
"node:os": "os",
|
|
25
|
+
"node:path": ["join"],
|
|
26
|
+
"node:fs/promises": ["readFile", "writeFile"],
|
|
27
|
+
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
28
|
+
},
|
|
29
|
+
builtinImports: { "shell-shock:console": [
|
|
30
|
+
"colors",
|
|
31
|
+
"writeLine",
|
|
32
|
+
"success",
|
|
33
|
+
"warn"
|
|
34
|
+
] },
|
|
35
|
+
get children() {
|
|
36
|
+
return [
|
|
37
|
+
createComponent(TSDoc$1, { heading: "Options for the Fish Completions - Script command." }),
|
|
38
|
+
createComponent(InterfaceDeclaration, {
|
|
39
|
+
"export": true,
|
|
40
|
+
name: "FishScriptCompletionsOptions",
|
|
41
|
+
get children() {
|
|
42
|
+
return [createComponent(TSDoc$1, {
|
|
43
|
+
heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
|
|
44
|
+
get children() {
|
|
45
|
+
return createComponent(TSDocDefaultValue$1, {
|
|
46
|
+
get type() {
|
|
47
|
+
return ReflectionKind.boolean;
|
|
48
|
+
},
|
|
49
|
+
defaultValue: false
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}), createComponent(InterfaceMember$1, {
|
|
53
|
+
name: "display",
|
|
54
|
+
optional: true,
|
|
55
|
+
type: "boolean"
|
|
56
|
+
})];
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
createComponent(Spacing, {}),
|
|
60
|
+
createComponent(TSDoc$1, { heading: "Handler logic for the \\`completions fish script\\` command." }),
|
|
61
|
+
createComponent(FunctionDeclaration, {
|
|
62
|
+
"export": true,
|
|
63
|
+
"default": true,
|
|
64
|
+
async: true,
|
|
65
|
+
name: "handler",
|
|
66
|
+
get parameters() {
|
|
67
|
+
return [{
|
|
68
|
+
name: "options",
|
|
69
|
+
type: "FishScriptCompletionsOptions",
|
|
70
|
+
default: "{}"
|
|
71
|
+
}, {
|
|
72
|
+
name: "path",
|
|
73
|
+
type: "string",
|
|
74
|
+
default: `"${bin.value}-completions.fish"`
|
|
75
|
+
}];
|
|
76
|
+
},
|
|
77
|
+
get children() {
|
|
78
|
+
return [createComponent(IfStatement, {
|
|
79
|
+
condition: code`options.display !== true`,
|
|
80
|
+
get children() {
|
|
81
|
+
return [createComponent(VarDeclaration, {
|
|
82
|
+
"const": true,
|
|
83
|
+
name: "scriptPath",
|
|
84
|
+
type: "string",
|
|
85
|
+
initializer: code` path.includes(".") ? \`\${path}.fish\` : path;`
|
|
86
|
+
}), memo(() => code`await writeFile(scriptPath, \`# Fish script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
87
|
+
|
|
88
|
+
success(\`${getAppTitle(context)} Fish completion script has been generated at \${colors.bold(scriptPath)}.\`);`)];
|
|
89
|
+
}
|
|
90
|
+
}), createComponent(ElseClause, { get children() {
|
|
91
|
+
return code`writeLine(" ------------------------------------------------- ");
|
|
92
|
+
writeLine(\`# Fish completion for ${getAppTitle(context)}\`);
|
|
93
|
+
writeLine("");
|
|
94
|
+
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
95
|
+
writeLine(" ------------------------------------------------- ");`;
|
|
96
|
+
} })];
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
export { FishScriptCompletionsCommand };
|
|
106
|
+
//# sourceMappingURL=fish-script-command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fish-script-command.mjs","names":[],"sources":["../../src/components/fish-script-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Fish Completions - Script command's handler wrapper for the Shell Shock project.\n */\nexport function FishScriptCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n const bin = computed(() => getAppBin(context));\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"fish\",\n \"script\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n \"shell-shock:console\": [\"colors\", \"writeLine\", \"success\", \"warn\"]\n }}>\n <TSDoc heading=\"Options for the Fish Completions - Script command.\" />\n <InterfaceDeclaration export name=\"FishScriptCompletionsOptions\">\n <TSDoc heading=\"Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.\">\n <TSDocDefaultValue\n type={ReflectionKind.boolean}\n defaultValue={false}\n />\n </TSDoc>\n <InterfaceMember name=\"display\" optional type=\"boolean\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions fish script\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"FishScriptCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"${bin.value}-completions.fish\"`\n }\n ]}>\n <IfStatement condition={code`options.display !== true`}>\n <VarDeclaration\n const\n name=\"scriptPath\"\n type=\"string\"\n initializer={code` path.includes(\".\") ? \\`\\${path}.fish\\` : path;`}\n />\n {code`await writeFile(scriptPath, \\`# Fish script to add completions for ${getAppTitle(context)}\\\\n\\\\n\\${SHELL_COMPLETIONS}\\`);\n\n success(\\`${getAppTitle(\n context\n )} Fish completion script has been generated at \\${colors.bold(scriptPath)}.\\`);`}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\\`# Fish completion for ${getAppTitle(context)}\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\" ------------------------------------------------- \");`}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAO,+BAAA;CACL,MAAK,UAAA,eAAA;CACL,MAAA,MAAA,eAAA,UAAA,QAAA,CAAA;AACA,QAAO,gBAAkB,gBAAgB;EAC3C,IAAQ,OAAC;AACH,UAAG,UAAY,QAAO,WAAY,eAAA,QAAA,UAAA,aAAA;;;GAGtC,WAAA;GACI,aAAM,CAAA,OAAc;GACxB,oBAAA,CAAA,YAAA,YAAA;GACI,aAAU,CAAA,qBAAA,4BAA+B;GAC7C;oBAEA,uBAA2B;GAAA;GAAU;GAAS;GAAA;GAAA;EAE9C,IAAM,WAAC;AACJ,UAAA;IAAA,gBAAA,SAAA,EACC,SAAM,sDACL,CAAC;IAAA,gBAAiB,sBAAA;KACjB,UAAC;KACD,MAAM;KACN,IAAC,WAAO;AACP,aAAQ,CAAA,gBAAE,SAAA;OACZ,SAAA;OACD,IAAS,WAAA;AACD,eAAM,gBAAG,qBAAA;SACT,IAAM,OAAO;AACV,iBAAQ,eAAe;;SAEjC,cAAA;SACD,CAAA;;OAEE,CAAA,EAAA,gBAAA,mBAAA;OACI,MAAC;OACN,UAAA;OACE,MAAM;OACJ,CAAA,CAAA;;KAEJ,CAAC;IAAE,gBAAgB,SAAK,EAAA,CAAA;IAAA,gBAAA,SAAA,EACvB,SAAG,gEACJ,CAAC;IAAE,gBAAK,qBAAA;KACP,UAAC;KACD,WAAA;KACD,OAAQ;KACR,MAAM;KACN,IAAA,aAAA;AACC,aAAA,CAAA;OACA,MAAA;OACA,MAAA;OACI,SAAS;OACb,EAAA;OACE,MAAA;OACE,MAAM;OACN,SAAO,IAAA,IAAA,MAAA;OACR,CAAC;;KAEJ,IAAE,WAAA;AACA,aAAO,CAAC,gBAAM,aAAA;OACZ,WAAO,IAAO;OACd,IAAA,WAAa;AACf,eAAA,CAAA,gBAAA,gBAAA;SACA,SAAA;SACD,MAAY;SACV,MAAA;SACC,aAAA,IAAA;SACA,CAAI,EAAE,WAAU,IAAA,sEAAA,YAAA,QAAA,CAAA;;wBAEJ,YAAY,QAAQ,CAAC,gFAAiC,CAAA;;OAEnE,CAAA,EAAA,gBAAqB,YAAY;AAEhC,cAAS,IAAG;gDACV,YAAA,QAAA,CAAA;;;;SAKH,CAAC,CAAA;;KAEL,CAAC;IAAC;;EAEN,CAAC"}
|
|
@@ -1,109 +1,39 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_helpers_complete_command = require('../helpers/complete-command.cjs');
|
|
3
3
|
const require_helpers_completion_directive_constants = require('../helpers/completion-directive-constants.cjs');
|
|
4
|
+
require('../helpers/index.cjs');
|
|
4
5
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
6
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
6
7
|
let _alloy_js_core = require("@alloy-js/core");
|
|
7
8
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
8
|
-
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
9
9
|
let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
|
|
10
10
|
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
11
11
|
let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
|
|
12
|
-
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
13
12
|
let _stryke_path = require("@stryke/path");
|
|
14
13
|
let _stryke_string_format_snake_case = require("@stryke/string-format/snake-case");
|
|
15
14
|
|
|
16
|
-
//#region src/components/fish-
|
|
15
|
+
//#region src/components/fish-shared.tsx
|
|
17
16
|
/**
|
|
18
|
-
* The Fish Completions
|
|
17
|
+
* The Fish Completions generation for the Shell Shock project.
|
|
19
18
|
*/
|
|
20
|
-
function
|
|
19
|
+
function FishCompletionsShared() {
|
|
21
20
|
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
22
21
|
const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
|
|
23
22
|
const name = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_snake_case.snakeCase)(bin.value));
|
|
24
23
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
|
|
25
24
|
get path() {
|
|
26
|
-
return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "fish", "
|
|
25
|
+
return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "fish", "shared.ts");
|
|
27
26
|
},
|
|
28
|
-
|
|
29
|
-
"node:os": "os",
|
|
30
|
-
"node:path": ["join"],
|
|
31
|
-
"node:fs/promises": ["readFile", "writeFile"]
|
|
32
|
-
},
|
|
33
|
-
builtinImports: { "shell-shock:console": [
|
|
34
|
-
"colors",
|
|
35
|
-
"writeLine",
|
|
36
|
-
"success",
|
|
37
|
-
"warn",
|
|
38
|
-
"stripAnsi"
|
|
39
|
-
] },
|
|
27
|
+
builtinImports: { console: ["colors"] },
|
|
40
28
|
get children() {
|
|
41
29
|
return [
|
|
42
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Fish completions command." }),
|
|
43
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
44
|
-
"export": true,
|
|
45
|
-
name: "FishCompletionsOptions",
|
|
46
|
-
get children() {
|
|
47
|
-
return [
|
|
48
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
49
|
-
heading: "The path to write the completion script to.",
|
|
50
|
-
get children() {
|
|
51
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `If no extension is provided, the \`.fish\` extension will be used.` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
52
|
-
get type() {
|
|
53
|
-
return _powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
54
|
-
},
|
|
55
|
-
get defaultValue() {
|
|
56
|
-
return `${bin.value}-completions.fish`;
|
|
57
|
-
}
|
|
58
|
-
})];
|
|
59
|
-
}
|
|
60
|
-
}),
|
|
61
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
|
|
62
|
-
name: "script",
|
|
63
|
-
optional: true,
|
|
64
|
-
type: "string | true"
|
|
65
|
-
}),
|
|
66
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
67
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
68
|
-
heading: "The Fish configuration file to append the completion script to.",
|
|
69
|
-
get children() {
|
|
70
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The generated completion script will be appended to the specified configuration file. Possible values for the Fish configuration file include: \\n- \`~/.config/fish/config.fish\`` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
71
|
-
get type() {
|
|
72
|
-
return _powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
73
|
-
},
|
|
74
|
-
defaultValue: "~/.config/fish/config.fish"
|
|
75
|
-
})];
|
|
76
|
-
}
|
|
77
|
-
}),
|
|
78
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
|
|
79
|
-
name: "config",
|
|
80
|
-
optional: true,
|
|
81
|
-
type: "string | true"
|
|
82
|
-
})
|
|
83
|
-
];
|
|
84
|
-
}
|
|
85
|
-
}),
|
|
86
30
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
87
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(
|
|
88
|
-
|
|
31
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
32
|
+
"const": true,
|
|
89
33
|
"export": true,
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
parameters: [{
|
|
94
|
-
name: "options",
|
|
95
|
-
type: "FishCompletionsOptions"
|
|
96
|
-
}],
|
|
97
|
-
get children() {
|
|
98
|
-
return [
|
|
99
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
100
|
-
"const": true,
|
|
101
|
-
name: "completions",
|
|
102
|
-
type: "string",
|
|
103
|
-
get initializer() {
|
|
104
|
-
return _alloy_js_core.code` \`# fish completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} -*- shell-script -*-
|
|
105
|
-
|
|
106
|
-
function __${name.value}_debug
|
|
34
|
+
name: "SHELL_COMPLETIONS",
|
|
35
|
+
get initializer() {
|
|
36
|
+
return _alloy_js_core.code` \`function __${name.value}_debug
|
|
107
37
|
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
108
38
|
if test -n "$file"
|
|
109
39
|
echo "$argv" >> $file
|
|
@@ -195,8 +125,7 @@ function __${name.value}_requires_order_preservation
|
|
|
195
125
|
return 1
|
|
196
126
|
end
|
|
197
127
|
|
|
198
|
-
set -l directive (string sub --start 2 $__$
|
|
199
|
-
{name.value}_perform_completion_once_result[-1])
|
|
128
|
+
set -l directive (string sub --start 2 $__${name.value}_perform_completion_once_result[-1])
|
|
200
129
|
__${name.value}_debug "Directive is: $directive"
|
|
201
130
|
|
|
202
131
|
set -l shellCompDirectiveKeepOrder ${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveKeepOrder}
|
|
@@ -335,68 +264,35 @@ complete -c ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n 'not __
|
|
|
335
264
|
# Otherwise we use the -k flag
|
|
336
265
|
complete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && __${name.value}_prepare_completions' -f -a '$__${name.value}_comp_results'
|
|
337
266
|
\`; `;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
352
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
353
|
-
condition: _alloy_js_core.code`configFilePath.startsWith("~")`,
|
|
354
|
-
children: _alloy_js_core.code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
|
|
355
|
-
}),
|
|
356
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
357
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
358
|
-
"let": true,
|
|
359
|
-
name: "configFileContent",
|
|
360
|
-
type: "string",
|
|
361
|
-
initializer: _alloy_js_core.code`"";`
|
|
362
|
-
}),
|
|
363
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
364
|
-
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
|
|
365
|
-
configFileContent = await readFile(configFilePath, "utf8");
|
|
366
|
-
} catch (error) {
|
|
367
|
-
if (Error.isError(error) && error.code === "ENOENT") {
|
|
368
|
-
// If the file doesn't exist, we can create it later when writing the completion script.
|
|
369
|
-
warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
|
|
370
|
-
} else {
|
|
371
|
-
return { error };
|
|
372
|
-
}
|
|
267
|
+
}
|
|
268
|
+
}),
|
|
269
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
270
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
271
|
+
"export": true,
|
|
272
|
+
"const": true,
|
|
273
|
+
name: "SHELL_COMPLETIONS_DISPLAY",
|
|
274
|
+
initializer: _alloy_js_core.code` SHELL_COMPLETIONS.split("\\n").map(line => {
|
|
275
|
+
if (!line.trim()) {
|
|
276
|
+
return "";
|
|
277
|
+
}
|
|
278
|
+
if (line.trim().startsWith("#")) {
|
|
279
|
+
return \`\${colors.dim(line)}\`;
|
|
373
280
|
}
|
|
374
281
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
}),
|
|
391
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
392
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
393
|
-
condition: _alloy_js_core.code`!options.config && !options.script`,
|
|
394
|
-
children: _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
395
|
-
writeLine(completions);
|
|
396
|
-
writeLine(" ------------------------------------------------- ");`
|
|
397
|
-
})
|
|
398
|
-
];
|
|
399
|
-
}
|
|
282
|
+
return colors.white(line).replaceAll(/(?<=\\\$(\\{|\\()).*(?=(\\}\\)))/g, colors.green("$&"))
|
|
283
|
+
.replaceAll(/(\\"|\\').*(\\"|\\')/g, colors.cyan("$&"))
|
|
284
|
+
.replaceAll(/(\\[|\\]|\\(|\\)|\\||<|>|\\$\\(|\\$?\\{|\\}|\\+|=|;|:)/g, colors.bold(colors.gray("$&")))
|
|
285
|
+
.replaceAll(/(function|complete)\\s+/g, colors.green("$&"))
|
|
286
|
+
.replaceAll(/(?<=(function|complete)\\s+)\\w/g, colors.bold(colors.greenBright("$&")))
|
|
287
|
+
.replaceAll(/set\\s+/g, colors.red("$&"))
|
|
288
|
+
.replaceAll(/(?<=set\\s+)\\w/g, colors.bold(colors.redBright("$&")))
|
|
289
|
+
.replaceAll(/while\\s+/g, colors.cyan("$&"))
|
|
290
|
+
.replaceAll(/(?<=while\\s+)\\w/g, colors.bold(colors.cyanBright("$&")))
|
|
291
|
+
.replaceAll(/(if|fi|else|elif|then|done)\\s+/g, colors.green("$&"))
|
|
292
|
+
.replaceAll(/\\s__\\w/g, colors.bold(colors.magentaBright("$&")))
|
|
293
|
+
.replaceAll(/(?<=\\s)(-\\w|--\\w[\\w-]*)(?=\\s|$)/g, colors.bold(colors.magenta("$&")));
|
|
294
|
+
|
|
295
|
+
}).join("\\n"); `
|
|
400
296
|
})
|
|
401
297
|
];
|
|
402
298
|
}
|
|
@@ -404,4 +300,4 @@ complete -k -c ${bin.value} -n '__${name.value}_requires_order_preservation && _
|
|
|
404
300
|
}
|
|
405
301
|
|
|
406
302
|
//#endregion
|
|
407
|
-
exports.
|
|
303
|
+
exports.FishCompletionsShared = FishCompletionsShared;
|