@shell-shock/plugin-completions 0.0.18 → 0.1.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.cjs +197 -0
- package/dist/components/bash.d.cts +10 -0
- package/dist/components/bash.d.cts.map +1 -0
- package/dist/components/bash.d.mts +10 -0
- package/dist/components/bash.d.mts.map +1 -0
- package/dist/components/bash.mjs +198 -0
- package/dist/components/bash.mjs.map +1 -0
- package/dist/components/index.cjs +5 -1
- package/dist/components/index.d.cts +3 -1
- package/dist/components/index.d.mts +3 -1
- package/dist/components/index.mjs +3 -2
- package/dist/components/zsh.cjs +197 -0
- package/dist/components/zsh.d.cts +10 -0
- package/dist/components/zsh.d.cts.map +1 -0
- package/dist/components/zsh.d.mts +10 -0
- package/dist/components/zsh.d.mts.map +1 -0
- package/dist/components/zsh.mjs +198 -0
- package/dist/components/zsh.mjs.map +1 -0
- package/dist/index.cjs +13 -3
- package/dist/index.d.cts +5 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +11 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +3 -0
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.mts +2 -1
- package/dist/types/index.mjs +3 -1
- package/dist/types/shell-type.cjs +6 -0
- package/dist/types/shell-type.d.cts +6 -0
- package/dist/types/shell-type.d.cts.map +1 -0
- package/dist/types/shell-type.d.mts +6 -0
- package/dist/types/shell-type.d.mts.map +1 -0
- package/dist/types/shell-type.mjs +6 -0
- package/dist/types/shell-type.mjs.map +1 -0
- package/package.json +68 -7
- package/dist/components/command.cjs +0 -59
- package/dist/components/command.d.cts +0 -10
- package/dist/components/command.d.cts.map +0 -1
- package/dist/components/command.d.mts +0 -10
- package/dist/components/command.d.mts.map +0 -1
- package/dist/components/command.mjs +0 -60
- package/dist/components/command.mjs.map +0 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
2
|
+
let __shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
3
|
+
let __alloy_js_core = require("@alloy-js/core");
|
|
4
|
+
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
5
|
+
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
6
|
+
let __powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
|
|
7
|
+
let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
8
|
+
let __powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
|
|
9
|
+
let __powerlines_plugin_alloy_typescript_components_entry_file = require("@powerlines/plugin-alloy/typescript/components/entry-file");
|
|
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/zsh.tsx
|
|
14
|
+
/**
|
|
15
|
+
* The Zsh Completions commands' handler wrapper for the Shell Shock project.
|
|
16
|
+
*/
|
|
17
|
+
function ZshCompletionsCommandEntryFile() {
|
|
18
|
+
const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
19
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_entry_file.EntryFile, {
|
|
20
|
+
get path() {
|
|
21
|
+
return (0, __stryke_path.joinPaths)(context.entryPath, "completions", "zsh", "command.ts");
|
|
22
|
+
},
|
|
23
|
+
imports: {
|
|
24
|
+
"node:os": ["os"],
|
|
25
|
+
"node:fs/promises": ["readFile", "writeFile"]
|
|
26
|
+
},
|
|
27
|
+
builtinImports: { "shell-shock:console": [
|
|
28
|
+
"colors",
|
|
29
|
+
"writeLine",
|
|
30
|
+
"success",
|
|
31
|
+
"warn",
|
|
32
|
+
"stripAnsi"
|
|
33
|
+
] },
|
|
34
|
+
get children() {
|
|
35
|
+
return [
|
|
36
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Zsh completions command." }),
|
|
37
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
38
|
+
"export": true,
|
|
39
|
+
name: "ZshCompletionsOptions",
|
|
40
|
+
get children() {
|
|
41
|
+
return [
|
|
42
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
43
|
+
heading: "The path to write the completion script to.",
|
|
44
|
+
get children() {
|
|
45
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `If no extension is provided, the \`.zsh\` extension will be used.` }), (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
46
|
+
get type() {
|
|
47
|
+
return __powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
48
|
+
},
|
|
49
|
+
get defaultValue() {
|
|
50
|
+
return `${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}-completions.zsh`;
|
|
51
|
+
}
|
|
52
|
+
})];
|
|
53
|
+
}
|
|
54
|
+
}),
|
|
55
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
|
|
56
|
+
name: "script",
|
|
57
|
+
optional: true,
|
|
58
|
+
type: "string | true"
|
|
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, {
|
|
62
|
+
heading: "The Zsh configuration file to append the completion script to.",
|
|
63
|
+
get children() {
|
|
64
|
+
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 Zsh configuration file include: \\n- \`~/.zshrc\` \\n- \`~/.zprofile\`` }), (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
65
|
+
get type() {
|
|
66
|
+
return __powerlines_deepkit_vendor_type.ReflectionKind.string;
|
|
67
|
+
},
|
|
68
|
+
defaultValue: "~/.zshrc"
|
|
69
|
+
})];
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
|
|
73
|
+
name: "config",
|
|
74
|
+
optional: true,
|
|
75
|
+
type: "string | true"
|
|
76
|
+
})
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
|
|
81
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Entry point for the Zsh completions command." }),
|
|
82
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
83
|
+
"export": true,
|
|
84
|
+
"default": true,
|
|
85
|
+
async: true,
|
|
86
|
+
name: "handler",
|
|
87
|
+
parameters: [{
|
|
88
|
+
name: "options",
|
|
89
|
+
type: "ZshCompletionsOptions"
|
|
90
|
+
}],
|
|
91
|
+
get children() {
|
|
92
|
+
return [
|
|
93
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
94
|
+
"const": true,
|
|
95
|
+
name: "completions",
|
|
96
|
+
type: "string",
|
|
97
|
+
get initializer() {
|
|
98
|
+
return __alloy_js_core.code`colors.white(\`\${colors.gray(\`#compdef \${colors.bold("${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}")}\`)}
|
|
99
|
+
\${colors.gray("###-begin-${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}-completions-###")}
|
|
100
|
+
|
|
101
|
+
\${colors.gray(\`
|
|
102
|
+
# \${colors.bold("${(0, __shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh CLI command completion script")}
|
|
103
|
+
#
|
|
104
|
+
# \${colors.bold("Installation:")} ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} completions zsh --config ~/.zshrc or ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} completions zsh --script or ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} completions zsh >> ~/.zshrc or ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} completions zsh >> ~/.zprofile on OSX. \`
|
|
105
|
+
)}
|
|
106
|
+
\${colors.cyan("_${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}_completions()")}
|
|
107
|
+
{
|
|
108
|
+
local reply
|
|
109
|
+
local si=$IFS
|
|
110
|
+
IFS=$'\\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} --get-completions "\\\${words[@]}"))
|
|
111
|
+
IFS=$si
|
|
112
|
+
if [[ \\\${#reply} -gt 0 ]]; then
|
|
113
|
+
_describe 'values' reply
|
|
114
|
+
else
|
|
115
|
+
_default
|
|
116
|
+
fi
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if [[ "\\\${zsh_eval_context[-1]}" == "loadautofunc" ]]; then
|
|
120
|
+
_${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}_completions "$@"
|
|
121
|
+
else
|
|
122
|
+
compdef _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}_completions ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}
|
|
123
|
+
fi
|
|
124
|
+
complete -o bashdefault -o default -F _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}_completions ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}
|
|
125
|
+
|
|
126
|
+
\${colors.gray("###-end-${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}-completions-###")}
|
|
127
|
+
\`);`;
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
|
|
131
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
132
|
+
condition: __alloy_js_core.code`options.config`,
|
|
133
|
+
get children() {
|
|
134
|
+
return [
|
|
135
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
136
|
+
"let": true,
|
|
137
|
+
name: "configFilePath",
|
|
138
|
+
type: "string",
|
|
139
|
+
initializer: __alloy_js_core.code`options.config === true ? "~/.zshrc" : options.config`
|
|
140
|
+
}),
|
|
141
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
|
|
142
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
143
|
+
condition: __alloy_js_core.code`configFilePath.startsWith("~")`,
|
|
144
|
+
children: __alloy_js_core.code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
|
|
145
|
+
}),
|
|
146
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
|
|
147
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
148
|
+
"let": true,
|
|
149
|
+
name: "configFileContent",
|
|
150
|
+
type: "string",
|
|
151
|
+
initializer: __alloy_js_core.code`"";`
|
|
152
|
+
}),
|
|
153
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
|
|
154
|
+
(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`try {
|
|
155
|
+
configFileContent = await readFile(configFilePath, "utf8");
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (error.code === "ENOENT") {
|
|
158
|
+
// If the file doesn't exist, we can create it later when writing the completion script.
|
|
159
|
+
warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
|
|
160
|
+
} else {
|
|
161
|
+
return { error };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
await writeFile(configFilePath, \`\${configFileContent}\\n\\n\${stripAnsi(completions)}\`);
|
|
166
|
+
|
|
167
|
+
success(\`${(0, __shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh completion script has been generated and appended to \${colors.bold(configFilePath)}. Please restart your terminal or run \`source \${configFilePath}\` to apply the changes.\`); `)
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
}),
|
|
171
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
|
|
172
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
173
|
+
condition: __alloy_js_core.code`options.script`,
|
|
174
|
+
get children() {
|
|
175
|
+
return __alloy_js_core.code`const outputPath = options.script === true ? "${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}-completions.zsh" : options.script;
|
|
176
|
+
await writeFile(outputPath, stripAnsi(completions));
|
|
177
|
+
|
|
178
|
+
success(\`${(0, __shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh completion script has been generated at \${colors.bold(outputPath)}.\`);`;
|
|
179
|
+
}
|
|
180
|
+
}),
|
|
181
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
|
|
182
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
183
|
+
condition: __alloy_js_core.code`!options.config && !options.script`,
|
|
184
|
+
children: __alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
185
|
+
writeLine(completions);
|
|
186
|
+
writeLine(" ------------------------------------------------- ");`
|
|
187
|
+
})
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
exports.ZshCompletionsCommandEntryFile = ZshCompletionsCommandEntryFile;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region src/components/zsh.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The Zsh Completions commands' handler wrapper for the Shell Shock project.
|
|
6
|
+
*/
|
|
7
|
+
declare function ZshCompletionsCommandEntryFile(): _alloy_js_core0.Children;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ZshCompletionsCommandEntryFile };
|
|
10
|
+
//# sourceMappingURL=zsh.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zsh.d.cts","names":[],"sources":["../../src/components/zsh.tsx"],"sourcesContent":[],"mappings":";;;;;;AA0CgB,iBAAA,8BAAA,CAAA,CAA8B,EAAA,eAAA,CAAA,QAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region src/components/zsh.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The Zsh Completions commands' handler wrapper for the Shell Shock project.
|
|
6
|
+
*/
|
|
7
|
+
declare function ZshCompletionsCommandEntryFile(): _alloy_js_core0.Children;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ZshCompletionsCommandEntryFile };
|
|
10
|
+
//# sourceMappingURL=zsh.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zsh.d.mts","names":[],"sources":["../../src/components/zsh.tsx"],"sourcesContent":[],"mappings":";;;;;;AA0CgB,iBAAA,8BAAA,CAAA,CAA8B,EAAA,eAAA,CAAA,QAAA"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
3
|
+
import { code } from "@alloy-js/core";
|
|
4
|
+
import { 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 } from "@powerlines/plugin-alloy/typescript";
|
|
9
|
+
import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
10
|
+
import { TSDoc, TSDocDefaultValue, TSDocRemarks } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
11
|
+
import { joinPaths } from "@stryke/path";
|
|
12
|
+
|
|
13
|
+
//#region src/components/zsh.tsx
|
|
14
|
+
/**
|
|
15
|
+
* The Zsh Completions commands' handler wrapper for the Shell Shock project.
|
|
16
|
+
*/
|
|
17
|
+
function ZshCompletionsCommandEntryFile() {
|
|
18
|
+
const context = usePowerlines();
|
|
19
|
+
return createComponent(EntryFile, {
|
|
20
|
+
get path() {
|
|
21
|
+
return joinPaths(context.entryPath, "completions", "zsh", "command.ts");
|
|
22
|
+
},
|
|
23
|
+
imports: {
|
|
24
|
+
"node:os": ["os"],
|
|
25
|
+
"node:fs/promises": ["readFile", "writeFile"]
|
|
26
|
+
},
|
|
27
|
+
builtinImports: { "shell-shock:console": [
|
|
28
|
+
"colors",
|
|
29
|
+
"writeLine",
|
|
30
|
+
"success",
|
|
31
|
+
"warn",
|
|
32
|
+
"stripAnsi"
|
|
33
|
+
] },
|
|
34
|
+
get children() {
|
|
35
|
+
return [
|
|
36
|
+
createComponent(TSDoc, { heading: "Options for the Zsh completions command." }),
|
|
37
|
+
createComponent(InterfaceDeclaration, {
|
|
38
|
+
"export": true,
|
|
39
|
+
name: "ZshCompletionsOptions",
|
|
40
|
+
get children() {
|
|
41
|
+
return [
|
|
42
|
+
createComponent(TSDoc, {
|
|
43
|
+
heading: "The path to write the completion script to.",
|
|
44
|
+
get children() {
|
|
45
|
+
return [createComponent(TSDocRemarks, { children: `If no extension is provided, the \`.zsh\` extension will be used.` }), createComponent(TSDocDefaultValue, {
|
|
46
|
+
get type() {
|
|
47
|
+
return ReflectionKind.string;
|
|
48
|
+
},
|
|
49
|
+
get defaultValue() {
|
|
50
|
+
return `${getAppBin(context)}-completions.zsh`;
|
|
51
|
+
}
|
|
52
|
+
})];
|
|
53
|
+
}
|
|
54
|
+
}),
|
|
55
|
+
createComponent(InterfaceMember, {
|
|
56
|
+
name: "script",
|
|
57
|
+
optional: true,
|
|
58
|
+
type: "string | true"
|
|
59
|
+
}),
|
|
60
|
+
createComponent(Spacing, {}),
|
|
61
|
+
createComponent(TSDoc, {
|
|
62
|
+
heading: "The Zsh configuration file to append the completion script to.",
|
|
63
|
+
get children() {
|
|
64
|
+
return [createComponent(TSDocRemarks, { children: `The generated completion script will be appended to the specified configuration file. Possible values for the Zsh configuration file include: \\n- \`~/.zshrc\` \\n- \`~/.zprofile\`` }), createComponent(TSDocDefaultValue, {
|
|
65
|
+
get type() {
|
|
66
|
+
return ReflectionKind.string;
|
|
67
|
+
},
|
|
68
|
+
defaultValue: "~/.zshrc"
|
|
69
|
+
})];
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
createComponent(InterfaceMember, {
|
|
73
|
+
name: "config",
|
|
74
|
+
optional: true,
|
|
75
|
+
type: "string | true"
|
|
76
|
+
})
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
createComponent(Spacing, {}),
|
|
81
|
+
createComponent(TSDoc, { heading: "Entry point for the Zsh completions command." }),
|
|
82
|
+
createComponent(FunctionDeclaration, {
|
|
83
|
+
"export": true,
|
|
84
|
+
"default": true,
|
|
85
|
+
async: true,
|
|
86
|
+
name: "handler",
|
|
87
|
+
parameters: [{
|
|
88
|
+
name: "options",
|
|
89
|
+
type: "ZshCompletionsOptions"
|
|
90
|
+
}],
|
|
91
|
+
get children() {
|
|
92
|
+
return [
|
|
93
|
+
createComponent(VarDeclaration, {
|
|
94
|
+
"const": true,
|
|
95
|
+
name: "completions",
|
|
96
|
+
type: "string",
|
|
97
|
+
get initializer() {
|
|
98
|
+
return code`colors.white(\`\${colors.gray(\`#compdef \${colors.bold("${getAppBin(context)}")}\`)}
|
|
99
|
+
\${colors.gray("###-begin-${getAppBin(context)}-completions-###")}
|
|
100
|
+
|
|
101
|
+
\${colors.gray(\`
|
|
102
|
+
# \${colors.bold("${getAppTitle(context)} Zsh CLI command completion script")}
|
|
103
|
+
#
|
|
104
|
+
# \${colors.bold("Installation:")} ${getAppBin(context)} completions zsh --config ~/.zshrc or ${getAppBin(context)} completions zsh --script or ${getAppBin(context)} completions zsh >> ~/.zshrc or ${getAppBin(context)} completions zsh >> ~/.zprofile on OSX. \`
|
|
105
|
+
)}
|
|
106
|
+
\${colors.cyan("_${getAppBin(context)}_completions()")}
|
|
107
|
+
{
|
|
108
|
+
local reply
|
|
109
|
+
local si=$IFS
|
|
110
|
+
IFS=$'\\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" ${getAppBin(context)} --get-completions "\\\${words[@]}"))
|
|
111
|
+
IFS=$si
|
|
112
|
+
if [[ \\\${#reply} -gt 0 ]]; then
|
|
113
|
+
_describe 'values' reply
|
|
114
|
+
else
|
|
115
|
+
_default
|
|
116
|
+
fi
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if [[ "\\\${zsh_eval_context[-1]}" == "loadautofunc" ]]; then
|
|
120
|
+
_${getAppBin(context)}_completions "$@"
|
|
121
|
+
else
|
|
122
|
+
compdef _${getAppBin(context)}_completions ${getAppBin(context)}
|
|
123
|
+
fi
|
|
124
|
+
complete -o bashdefault -o default -F _${getAppBin(context)}_completions ${getAppBin(context)}
|
|
125
|
+
|
|
126
|
+
\${colors.gray("###-end-${getAppBin(context)}-completions-###")}
|
|
127
|
+
\`);`;
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
createComponent(Spacing, {}),
|
|
131
|
+
createComponent(IfStatement, {
|
|
132
|
+
condition: code`options.config`,
|
|
133
|
+
get children() {
|
|
134
|
+
return [
|
|
135
|
+
createComponent(VarDeclaration, {
|
|
136
|
+
"let": true,
|
|
137
|
+
name: "configFilePath",
|
|
138
|
+
type: "string",
|
|
139
|
+
initializer: code`options.config === true ? "~/.zshrc" : options.config`
|
|
140
|
+
}),
|
|
141
|
+
createComponent(Spacing, {}),
|
|
142
|
+
createComponent(IfStatement, {
|
|
143
|
+
condition: code`configFilePath.startsWith("~")`,
|
|
144
|
+
children: code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
|
|
145
|
+
}),
|
|
146
|
+
createComponent(Spacing, {}),
|
|
147
|
+
createComponent(VarDeclaration, {
|
|
148
|
+
"let": true,
|
|
149
|
+
name: "configFileContent",
|
|
150
|
+
type: "string",
|
|
151
|
+
initializer: code`"";`
|
|
152
|
+
}),
|
|
153
|
+
createComponent(Spacing, {}),
|
|
154
|
+
memo(() => code`try {
|
|
155
|
+
configFileContent = await readFile(configFilePath, "utf8");
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (error.code === "ENOENT") {
|
|
158
|
+
// If the file doesn't exist, we can create it later when writing the completion script.
|
|
159
|
+
warn(\`Configuration file \${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\`);
|
|
160
|
+
} else {
|
|
161
|
+
return { error };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
await writeFile(configFilePath, \`\${configFileContent}\\n\\n\${stripAnsi(completions)}\`);
|
|
166
|
+
|
|
167
|
+
success(\`${getAppTitle(context)} Zsh completion script has been generated and appended to \${colors.bold(configFilePath)}. Please restart your terminal or run \`source \${configFilePath}\` to apply the changes.\`); `)
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
}),
|
|
171
|
+
createComponent(Spacing, {}),
|
|
172
|
+
createComponent(IfStatement, {
|
|
173
|
+
condition: code`options.script`,
|
|
174
|
+
get children() {
|
|
175
|
+
return code`const outputPath = options.script === true ? "${getAppBin(context)}-completions.zsh" : options.script;
|
|
176
|
+
await writeFile(outputPath, stripAnsi(completions));
|
|
177
|
+
|
|
178
|
+
success(\`${getAppTitle(context)} Zsh completion script has been generated at \${colors.bold(outputPath)}.\`);`;
|
|
179
|
+
}
|
|
180
|
+
}),
|
|
181
|
+
createComponent(Spacing, {}),
|
|
182
|
+
createComponent(IfStatement, {
|
|
183
|
+
condition: code`!options.config && !options.script`,
|
|
184
|
+
children: code`writeLine(" ------------------------------------------------- ");
|
|
185
|
+
writeLine(completions);
|
|
186
|
+
writeLine(" ------------------------------------------------- ");`
|
|
187
|
+
})
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
export { ZshCompletionsCommandEntryFile };
|
|
198
|
+
//# sourceMappingURL=zsh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zsh.mjs","names":["code","FunctionDeclaration","IfStatement","InterfaceDeclaration","VarDeclaration","ReflectionKind","Spacing","usePowerlines","InterfaceMember","EntryFile","TSDoc","TSDocDefaultValue","TSDocRemarks","getAppBin","getAppTitle","joinPaths","ZshCompletionsCommandEntryFile","context","_$createComponent","path","entryPath","imports","builtinImports","children","heading","name","type","string","defaultValue","optional","async","parameters","initializer","condition","_$memo"],"sources":["../../src/components/zsh.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 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 { InterfaceMember } from \"@powerlines/plugin-alloy/typescript\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocDefaultValue,\n TSDocRemarks\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 Zsh Completions commands' handler wrapper for the Shell Shock project.\n */\nexport function ZshCompletionsCommandEntryFile() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <EntryFile\n path={joinPaths(context.entryPath, \"completions\", \"zsh\", \"command.ts\")}\n imports={{\n \"node:os\": [\"os\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"]\n }}\n builtinImports={{\n \"shell-shock:console\": [\n \"colors\",\n \"writeLine\",\n \"success\",\n \"warn\",\n \"stripAnsi\"\n ]\n }}>\n <TSDoc heading=\"Options for the Zsh completions command.\" />\n <InterfaceDeclaration export name=\"ZshCompletionsOptions\">\n <TSDoc heading=\"The path to write the completion script to.\">\n <TSDocRemarks>{`If no extension is provided, the \\`.zsh\\` extension will be used.`}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue={`${getAppBin(context)}-completions.zsh`}\n />\n </TSDoc>\n <InterfaceMember name=\"script\" optional type=\"string | true\" />\n <Spacing />\n <TSDoc heading=\"The Zsh configuration file to append the completion script to.\">\n <TSDocRemarks>{`The generated completion script will be appended to the specified configuration file. Possible values for the Zsh configuration file include: \\\\n- \\`~/.zshrc\\` \\\\n- \\`~/.zprofile\\``}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue=\"~/.zshrc\"\n />\n </TSDoc>\n <InterfaceMember name=\"config\" optional type=\"string | true\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Entry point for the Zsh completions command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[{ name: \"options\", type: \"ZshCompletionsOptions\" }]}>\n <VarDeclaration\n const\n name=\"completions\"\n type=\"string\"\n initializer={code`colors.white(\\`\\${colors.gray(\\`#compdef \\${colors.bold(\"${getAppBin(context)}\")}\\`)}\n\\${colors.gray(\"###-begin-${getAppBin(context)}-completions-###\")}\n\n\\${colors.gray(\\`\n# \\${colors.bold(\"${getAppTitle(context)} Zsh CLI command completion script\")}\n#\n# \\${colors.bold(\"Installation:\")} ${getAppBin(context)} completions zsh --config ~/.zshrc or ${getAppBin(context)} completions zsh --script or ${getAppBin(context)} completions zsh >> ~/.zshrc or ${getAppBin(context)} completions zsh >> ~/.zprofile on OSX. \\`\n)}\n\\${colors.cyan(\"_${getAppBin(context)}_completions()\")}\n{\n local reply\n local si=$IFS\n IFS=$'\\\\n' reply=($(COMP_CWORD=\"$((CURRENT-1))\" COMP_LINE=\"$BUFFER\" COMP_POINT=\"$CURSOR\" ${getAppBin(context)} --get-completions \"\\\\\\${words[@]}\"))\n IFS=$si\n if [[ \\\\\\${#reply} -gt 0 ]]; then\n _describe 'values' reply\n else\n _default\n fi\n}\n\nif [[ \"\\\\\\${zsh_eval_context[-1]}\" == \"loadautofunc\" ]]; then\n _${getAppBin(context)}_completions \"$@\"\nelse\n compdef _${getAppBin(context)}_completions ${getAppBin(context)}\nfi\ncomplete -o bashdefault -o default -F _${getAppBin(context)}_completions ${getAppBin(context)}\n\n\\${colors.gray(\"###-end-${getAppBin(context)}-completions-###\")}\n\\`);`}\n />\n <Spacing />\n <IfStatement condition={code`options.config`}>\n <VarDeclaration\n let\n name=\"configFilePath\"\n type=\"string\"\n initializer={code`options.config === true ? \"~/.zshrc\" : options.config`}\n />\n <Spacing />\n <IfStatement condition={code`configFilePath.startsWith(\"~\")`}>\n {code`configFilePath = join(os.homedir(), configFilePath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"configFileContent\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n configFileContent = await readFile(configFilePath, \"utf8\");\n } catch (error) {\n if (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(configFilePath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configFilePath, \\`\\${configFileContent}\\\\n\\\\n\\${stripAnsi(completions)}\\`);\n\n success(\\`${getAppTitle(context)} Zsh completion script has been generated and appended to \\${colors.bold(configFilePath)}. Please restart your terminal or run \\`source \\${configFilePath}\\` to apply the changes.\\`); `}\n </IfStatement>\n <Spacing />\n <IfStatement condition={code`options.script`}>\n {code`const outputPath = options.script === true ? \"${getAppBin(context)}-completions.zsh\" : options.script;\n await writeFile(outputPath, stripAnsi(completions));\n\n success(\\`${getAppTitle(context)} Zsh completion script has been generated at \\${colors.bold(outputPath)}.\\`);`}\n </IfStatement>\n <Spacing />\n <IfStatement condition={code`!options.config && !options.script`}>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(completions);\n writeLine(\" ------------------------------------------------- \");`}\n </IfStatement>\n </FunctionDeclaration>\n </EntryFile>\n );\n}\n"],"mappings":"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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const
|
|
2
|
+
const require_components_bash = require('./components/bash.cjs');
|
|
3
|
+
const require_components_zsh = require('./components/zsh.cjs');
|
|
3
4
|
require('./components/index.cjs');
|
|
5
|
+
const require_types_shell_type = require('./types/shell-type.cjs');
|
|
6
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
7
|
+
let __powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
4
8
|
let __shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
5
9
|
let __stryke_path_join = require("@stryke/path/join");
|
|
6
10
|
|
|
7
|
-
//#region src/index.
|
|
11
|
+
//#region src/index.tsx
|
|
8
12
|
/**
|
|
9
13
|
* The Completions - Shell Shock plugin to add completion commands to a Shell Shock application.
|
|
10
14
|
*/
|
|
@@ -52,12 +56,18 @@ const plugin = (options = {}) => {
|
|
|
52
56
|
entry: { file: (0, __stryke_path_join.joinPaths)(this.entryPath, "completions", "zsh", "command.ts") },
|
|
53
57
|
isVirtual: false
|
|
54
58
|
});
|
|
59
|
+
},
|
|
60
|
+
async prepare() {
|
|
61
|
+
this.debug("Rendering entry point modules for the Shell Shock `completions` plugin.");
|
|
62
|
+
return (0, __powerlines_plugin_alloy_render.render)(this, [(0, __alloy_js_core_jsx_runtime.createComponent)(require_components_bash.BashCompletionsCommandEntryFile, {}), (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_zsh.ZshCompletionsCommandEntryFile, {})]);
|
|
55
63
|
}
|
|
56
64
|
}];
|
|
57
65
|
};
|
|
58
66
|
var src_default = plugin;
|
|
59
67
|
|
|
60
68
|
//#endregion
|
|
61
|
-
exports.
|
|
69
|
+
exports.BashCompletionsCommandEntryFile = require_components_bash.BashCompletionsCommandEntryFile;
|
|
70
|
+
exports.SHELL_TYPES = require_types_shell_type.SHELL_TYPES;
|
|
71
|
+
exports.ZshCompletionsCommandEntryFile = require_components_zsh.ZshCompletionsCommandEntryFile;
|
|
62
72
|
exports.default = src_default;
|
|
63
73
|
exports.plugin = plugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BashCompletionsCommandEntryFile } from "./components/bash.cjs";
|
|
2
|
+
import { ZshCompletionsCommandEntryFile } from "./components/zsh.cjs";
|
|
3
3
|
import "./components/index.cjs";
|
|
4
|
+
import { CompletionsPluginContext, CompletionsPluginOptions, CompletionsPluginResolvedConfig, CompletionsPluginUserConfig } from "./types/plugin.cjs";
|
|
5
|
+
import { SHELL_TYPES, ShellType } from "./types/shell-type.cjs";
|
|
4
6
|
import { Plugin } from "powerlines";
|
|
5
7
|
|
|
6
8
|
//#region src/index.d.ts
|
|
7
|
-
|
|
8
9
|
/**
|
|
9
10
|
* The Completions - Shell Shock plugin to add completion commands to a Shell Shock application.
|
|
10
11
|
*/
|
|
11
12
|
declare const plugin: <TContext extends CompletionsPluginContext = CompletionsPluginContext>(options?: CompletionsPluginOptions) => Plugin<TContext>[];
|
|
12
13
|
//#endregion
|
|
13
|
-
export {
|
|
14
|
+
export { BashCompletionsCommandEntryFile, CompletionsPluginContext, CompletionsPluginOptions, CompletionsPluginResolvedConfig, CompletionsPluginUserConfig, SHELL_TYPES, ShellType, ZshCompletionsCommandEntryFile, plugin as default, plugin };
|
|
14
15
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;cAqCa,0BACM,2BAA2B,oCAEnC,6BACR,OAAO"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BashCompletionsCommandEntryFile } from "./components/bash.mjs";
|
|
2
|
+
import { ZshCompletionsCommandEntryFile } from "./components/zsh.mjs";
|
|
3
3
|
import "./components/index.mjs";
|
|
4
|
+
import { CompletionsPluginContext, CompletionsPluginOptions, CompletionsPluginResolvedConfig, CompletionsPluginUserConfig } from "./types/plugin.mjs";
|
|
5
|
+
import { SHELL_TYPES, ShellType } from "./types/shell-type.mjs";
|
|
4
6
|
import { Plugin } from "powerlines";
|
|
5
7
|
|
|
6
8
|
//#region src/index.d.ts
|
|
7
|
-
|
|
8
9
|
/**
|
|
9
10
|
* The Completions - Shell Shock plugin to add completion commands to a Shell Shock application.
|
|
10
11
|
*/
|
|
11
12
|
declare const plugin: <TContext extends CompletionsPluginContext = CompletionsPluginContext>(options?: CompletionsPluginOptions) => Plugin<TContext>[];
|
|
12
13
|
//#endregion
|
|
13
|
-
export {
|
|
14
|
+
export { BashCompletionsCommandEntryFile, CompletionsPluginContext, CompletionsPluginOptions, CompletionsPluginResolvedConfig, CompletionsPluginUserConfig, SHELL_TYPES, ShellType, ZshCompletionsCommandEntryFile, plugin as default, plugin };
|
|
14
15
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;cAqCa,0BACM,2BAA2B,oCAEnC,6BACR,OAAO"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BashCompletionsCommandEntryFile } from "./components/bash.mjs";
|
|
2
|
+
import { ZshCompletionsCommandEntryFile } from "./components/zsh.mjs";
|
|
2
3
|
import "./components/index.mjs";
|
|
4
|
+
import { SHELL_TYPES } from "./types/shell-type.mjs";
|
|
5
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
6
|
+
import { render } from "@powerlines/plugin-alloy/render";
|
|
3
7
|
import { getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
4
8
|
import { joinPaths } from "@stryke/path/join";
|
|
5
9
|
|
|
6
|
-
//#region src/index.
|
|
10
|
+
//#region src/index.tsx
|
|
7
11
|
/**
|
|
8
12
|
* The Completions - Shell Shock plugin to add completion commands to a Shell Shock application.
|
|
9
13
|
*/
|
|
@@ -51,11 +55,15 @@ const plugin = (options = {}) => {
|
|
|
51
55
|
entry: { file: joinPaths(this.entryPath, "completions", "zsh", "command.ts") },
|
|
52
56
|
isVirtual: false
|
|
53
57
|
});
|
|
58
|
+
},
|
|
59
|
+
async prepare() {
|
|
60
|
+
this.debug("Rendering entry point modules for the Shell Shock `completions` plugin.");
|
|
61
|
+
return render(this, [createComponent(BashCompletionsCommandEntryFile, {}), createComponent(ZshCompletionsCommandEntryFile, {})]);
|
|
54
62
|
}
|
|
55
63
|
}];
|
|
56
64
|
};
|
|
57
65
|
var src_default = plugin;
|
|
58
66
|
|
|
59
67
|
//#endregion
|
|
60
|
-
export {
|
|
68
|
+
export { BashCompletionsCommandEntryFile, SHELL_TYPES, ZshCompletionsCommandEntryFile, src_default as default, plugin };
|
|
61
69
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["getAppTitle","joinPaths","plugin","options","name","config","debug","completions","configResolved","inputs","some","input","id","info","push","alias","path","segments","title","description","entry","file","entryPath","isVirtual"],"sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["render","getAppTitle","joinPaths","BashCompletionsCommandEntryFile","ZshCompletionsCommandEntryFile","plugin","options","name","config","debug","completions","configResolved","inputs","some","input","id","info","push","alias","path","segments","title","description","entry","file","entryPath","isVirtual","prepare","_$createComponent"],"sources":["../src/index.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 { render } from \"@powerlines/plugin-alloy/render\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport type { Plugin } from \"powerlines\";\nimport {\n BashCompletionsCommandEntryFile,\n ZshCompletionsCommandEntryFile\n} from \"./components\";\nimport type {\n CompletionsPluginContext,\n CompletionsPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./components\";\nexport * from \"./types\";\n\n/**\n * The Completions - Shell Shock plugin to add completion commands to a Shell Shock application.\n */\nexport const plugin = <\n TContext extends CompletionsPluginContext = CompletionsPluginContext\n>(\n options: CompletionsPluginOptions = {}\n): Plugin<TContext>[] => {\n return [\n {\n name: \"shell-shock:completions\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `completions` plugin.\"\n );\n\n return {\n completions: options\n };\n },\n configResolved() {\n this.debug(\"Adding the CLI completion commands to the entry points.\");\n\n this.inputs ??= [];\n if (this.inputs.some(input => input.id === \"completions\")) {\n this.info(\n \"The `completions` command already exists in the commands list. If you would like the completions command to be managed by the `@shell-shock/plugin-completions` package, please remove or rename the command.\"\n );\n } else {\n this.inputs.push({\n id: \"completions\",\n name: \"completions\",\n alias: [\"completion\"],\n path: \"completions\",\n segments: [\"completions\"],\n title: \"CLI Completions\",\n description: `Commands for generating shell completion scripts for the ${getAppTitle(\n this\n )}.`,\n entry: {\n file: joinPaths(this.entryPath, \"completions\", \"command.ts\")\n },\n isVirtual: true\n });\n }\n\n if (this.inputs.some(input => input.id === \"completions-bash\")) {\n this.info(\n \"The `completions-bash` command already exists in the commands list. If you would like the completions-bash command to be managed by the `@shell-shock/plugin-completions` package, please remove or rename the command.\"\n );\n } else {\n this.inputs.push({\n id: \"completions-bash\",\n name: \"bash\",\n alias: [],\n path: \"completions/bash\",\n segments: [\"completions\", \"bash\"],\n title: \"CLI Completions - Bash Shell\",\n entry: {\n file: joinPaths(\n this.entryPath,\n \"completions\",\n \"bash\",\n \"command.ts\"\n )\n },\n isVirtual: false\n });\n }\n\n if (this.inputs.some(input => input.id === \"completions-zsh\")) {\n this.info(\n \"The `completions-zsh` command already exists in the commands list. If you would like the completions-zsh command to be managed by the `@shell-shock/plugin-completions` package, please remove or rename the command.\"\n );\n } else {\n this.inputs.push({\n id: \"completions-zsh\",\n name: \"zsh\",\n alias: [],\n path: \"completions/zsh\",\n segments: [\"completions\", \"zsh\"],\n title: \"CLI Completions - Zsh Shell\",\n entry: {\n file: joinPaths(\n this.entryPath,\n \"completions\",\n \"zsh\",\n \"command.ts\"\n )\n },\n isVirtual: false\n });\n }\n },\n async prepare() {\n this.debug(\n \"Rendering entry point modules for the Shell Shock `completions` plugin.\"\n );\n\n return render(\n this,\n <>\n <BashCompletionsCommandEntryFile />\n <ZshCompletionsCommandEntryFile />\n </>\n );\n }\n }\n ];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;AAqCA,MAAaK,UAGXC,UAAoC,EAAE,KACf;AACvB,QAAO,CACL;EACEC,MAAM;EACNC,SAAS;AACP,QAAKC,MACH,4EACD;AAED,UAAO,EACLC,aAAaJ,SACd;;EAEHK,iBAAiB;AACf,QAAKF,MAAM,0DAA0D;AAErE,QAAKG,WAAW,EAAE;AAClB,OAAI,KAAKA,OAAOC,MAAKC,UAASA,MAAMC,OAAO,cAAc,CACvD,MAAKC,KACH,gNACD;OAED,MAAKJ,OAAOK,KAAK;IACfF,IAAI;IACJR,MAAM;IACNW,OAAO,CAAC,aAAa;IACrBC,MAAM;IACNC,UAAU,CAAC,cAAc;IACzBC,OAAO;IACPC,aAAa,4DAA4DrB,YACvE,KACD,CAAA;IACDsB,OAAO,EACLC,MAAMtB,UAAU,KAAKuB,WAAW,eAAe,aAAY,EAC5D;IACDC,WAAW;IACZ,CAAC;AAGJ,OAAI,KAAKd,OAAOC,MAAKC,UAASA,MAAMC,OAAO,mBAAmB,CAC5D,MAAKC,KACH,0NACD;OAED,MAAKJ,OAAOK,KAAK;IACfF,IAAI;IACJR,MAAM;IACNW,OAAO,EAAE;IACTC,MAAM;IACNC,UAAU,CAAC,eAAe,OAAO;IACjCC,OAAO;IACPE,OAAO,EACLC,MAAMtB,UACJ,KAAKuB,WACL,eACA,QACA,aACF,EACD;IACDC,WAAW;IACZ,CAAC;AAGJ,OAAI,KAAKd,OAAOC,MAAKC,UAASA,MAAMC,OAAO,kBAAkB,CAC3D,MAAKC,KACH,wNACD;OAED,MAAKJ,OAAOK,KAAK;IACfF,IAAI;IACJR,MAAM;IACNW,OAAO,EAAE;IACTC,MAAM;IACNC,UAAU,CAAC,eAAe,MAAM;IAChCC,OAAO;IACPE,OAAO,EACLC,MAAMtB,UACJ,KAAKuB,WACL,eACA,OACA,aACF,EACD;IACDC,WAAW;IACZ,CAAC;;EAGN,MAAMC,UAAU;AACd,QAAKlB,MACH,0EACD;AAED,UAAOT,OACL,MAAI,CAAA4B,gBAEDzB,iCAA+B,EAAA,CAAA,EAAAyB,gBAC/BxB,gCAA8B,EAAA,CAAA,CAEnC,CAAC;;EAEJ,CACF;;AAGH,kBAAeC"}
|
package/dist/types/index.cjs
CHANGED
package/dist/types/index.d.cts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { CompletionsPluginContext, CompletionsPluginOptions, CompletionsPluginResolvedConfig, CompletionsPluginUserConfig } from "./plugin.cjs";
|
|
2
|
-
|
|
2
|
+
import { SHELL_TYPES, ShellType } from "./shell-type.cjs";
|
|
3
|
+
export { CompletionsPluginContext, CompletionsPluginOptions, CompletionsPluginResolvedConfig, CompletionsPluginUserConfig, SHELL_TYPES, ShellType };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { CompletionsPluginContext, CompletionsPluginOptions, CompletionsPluginResolvedConfig, CompletionsPluginUserConfig } from "./plugin.mjs";
|
|
2
|
-
|
|
2
|
+
import { SHELL_TYPES, ShellType } from "./shell-type.mjs";
|
|
3
|
+
export { CompletionsPluginContext, CompletionsPluginOptions, CompletionsPluginResolvedConfig, CompletionsPluginUserConfig, SHELL_TYPES, ShellType };
|
package/dist/types/index.mjs
CHANGED