@shell-shock/plugin-completions 0.4.14 → 0.4.16
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 +6 -120
- package/dist/components/bash-config-command.mjs +6 -119
- package/dist/components/bash-config-command.mjs.map +1 -1
- package/dist/components/bash-script-command.cjs +5 -105
- package/dist/components/bash-script-command.mjs +5 -104
- package/dist/components/bash-script-command.mjs.map +1 -1
- package/dist/components/bash-shared.cjs +13 -77
- package/dist/components/bash-shared.mjs +13 -76
- package/dist/components/bash-shared.mjs.map +1 -1
- package/dist/components/fish-config-command.cjs +6 -120
- package/dist/components/fish-config-command.mjs +6 -119
- package/dist/components/fish-config-command.mjs.map +1 -1
- package/dist/components/fish-script-command.cjs +4 -104
- package/dist/components/fish-script-command.mjs +4 -103
- package/dist/components/fish-script-command.mjs.map +1 -1
- package/dist/components/fish-shared.cjs +77 -141
- package/dist/components/fish-shared.mjs +77 -140
- package/dist/components/fish-shared.mjs.map +1 -1
- package/dist/components/index.cjs +1 -26
- package/dist/components/index.mjs +1 -14
- package/dist/components/powershell-config-command.cjs +6 -116
- package/dist/components/powershell-config-command.mjs +6 -115
- package/dist/components/powershell-config-command.mjs.map +1 -1
- package/dist/components/powershell-script-command.cjs +4 -104
- package/dist/components/powershell-script-command.mjs +4 -103
- package/dist/components/powershell-script-command.mjs.map +1 -1
- package/dist/components/powershell-shared.cjs +37 -101
- package/dist/components/powershell-shared.mjs +37 -100
- package/dist/components/powershell-shared.mjs.map +1 -1
- package/dist/components/zsh-config-command.cjs +6 -120
- package/dist/components/zsh-config-command.mjs +6 -119
- package/dist/components/zsh-config-command.mjs.map +1 -1
- package/dist/components/zsh-script-command.cjs +6 -108
- package/dist/components/zsh-script-command.mjs +6 -107
- package/dist/components/zsh-script-command.mjs.map +1 -1
- package/dist/components/zsh-shared.cjs +42 -106
- package/dist/components/zsh-shared.mjs +42 -105
- package/dist/components/zsh-shared.mjs.map +1 -1
- package/dist/helpers/complete-command.cjs +1 -10
- package/dist/helpers/complete-command.mjs +1 -8
- package/dist/helpers/complete-command.mjs.map +1 -1
- package/dist/helpers/completion-directive-constants.cjs +1 -16
- package/dist/helpers/completion-directive-constants.mjs +1 -14
- package/dist/helpers/completion-directive-constants.mjs.map +1 -1
- package/dist/helpers/index.cjs +1 -6
- package/dist/helpers/index.mjs +1 -4
- package/dist/index.cjs +1 -303
- package/dist/index.mjs +1 -301
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +1 -4
- package/dist/types/index.mjs +1 -3
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/shell-type.cjs +1 -12
- package/dist/types/shell-type.mjs +1 -10
- package/dist/types/shell-type.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -1,104 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
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/zsh-config-command.tsx
|
|
14
|
-
/**
|
|
15
|
-
* The Zsh Completions - Configuration command's handler wrapper for the Shell Shock project.
|
|
16
|
-
*/
|
|
17
|
-
function ZshConfigCompletionsCommand() {
|
|
18
|
-
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
19
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
|
|
20
|
-
get path() {
|
|
21
|
-
return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "zsh", "config", "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: { console: [
|
|
30
|
-
"bold",
|
|
31
|
-
"inlineCode",
|
|
32
|
-
"writeLine",
|
|
33
|
-
"success",
|
|
34
|
-
"warn",
|
|
35
|
-
"help"
|
|
36
|
-
] },
|
|
37
|
-
get children() {
|
|
38
|
-
return [
|
|
39
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Zsh Completions - Configuration command." }),
|
|
40
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
41
|
-
"export": true,
|
|
42
|
-
name: "ZshConfigCompletionsOptions",
|
|
43
|
-
get children() {
|
|
44
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
45
|
-
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.",
|
|
46
|
-
get children() {
|
|
47
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
48
|
-
get type() {
|
|
49
|
-
return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
|
|
50
|
-
},
|
|
51
|
-
defaultValue: false
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
|
|
55
|
-
name: "display",
|
|
56
|
-
optional: true,
|
|
57
|
-
type: "boolean"
|
|
58
|
-
})];
|
|
59
|
-
}
|
|
60
|
-
}),
|
|
61
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
62
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions zsh config\\` command." }),
|
|
63
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
64
|
-
"export": true,
|
|
65
|
-
"default": true,
|
|
66
|
-
async: true,
|
|
67
|
-
name: "handler",
|
|
68
|
-
parameters: [{
|
|
69
|
-
name: "options",
|
|
70
|
-
type: "ZshConfigCompletionsOptions",
|
|
71
|
-
default: "{}"
|
|
72
|
-
}, {
|
|
73
|
-
name: "path",
|
|
74
|
-
type: "string",
|
|
75
|
-
default: `"~/.zshrc"`
|
|
76
|
-
}],
|
|
77
|
-
get children() {
|
|
78
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
79
|
-
condition: _alloy_js_core.code`options.display !== true`,
|
|
80
|
-
get children() {
|
|
81
|
-
return [
|
|
82
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
83
|
-
"let": true,
|
|
84
|
-
name: "configPath",
|
|
85
|
-
type: "string",
|
|
86
|
-
initializer: _alloy_js_core.code` path.includes(".") ? path : join(path, ".zshrc");`
|
|
87
|
-
}),
|
|
88
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
89
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
90
|
-
condition: _alloy_js_core.code`configPath.startsWith("~")`,
|
|
91
|
-
children: _alloy_js_core.code`configPath = join(os.homedir(), configPath.replace("~", "")); `
|
|
92
|
-
}),
|
|
93
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
94
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
95
|
-
"let": true,
|
|
96
|
-
name: "content",
|
|
97
|
-
type: "string",
|
|
98
|
-
initializer: _alloy_js_core.code`"";`
|
|
99
|
-
}),
|
|
100
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
101
|
-
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@alloy-js/core/jsx-runtime`),t=require(`@shell-shock/core/plugin-utils`),n=require(`@alloy-js/core`),r=require(`@alloy-js/typescript`),i=require(`@powerlines/deepkit/vendor/type`),a=require(`@powerlines/plugin-alloy/core`),o=require(`@powerlines/plugin-alloy/core/contexts/context`),s=require(`@powerlines/plugin-alloy/typescript`),c=require(`@powerlines/plugin-alloy/typescript/components/tsdoc`),l=require(`@stryke/path`);function u(){let u=(0,o.usePowerlines)();return(0,e.createComponent)(s.TypescriptFile,{get path(){return(0,l.joinPaths)(u.entryPath,`completions`,`zsh`,`config`,`command.ts`)},imports:{"node:os":`os`,"node:path":[`join`],"node:fs/promises":[`readFile`,`writeFile`],"../shared":[`SHELL_COMPLETIONS`,`SHELL_COMPLETIONS_DISPLAY`]},builtinImports:{console:[`bold`,`inlineCode`,`writeLine`,`success`,`warn`,`help`]},get children(){return[(0,e.createComponent)(c.TSDoc,{heading:`Options for the Zsh Completions - Configuration command.`}),(0,e.createComponent)(r.InterfaceDeclaration,{export:!0,name:`ZshConfigCompletionsOptions`,get children(){return[(0,e.createComponent)(c.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.`,get children(){return(0,e.createComponent)(c.TSDocDefaultValue,{get type(){return i.ReflectionKind.boolean},defaultValue:!1})}}),(0,e.createComponent)(s.InterfaceMember,{name:`display`,optional:!0,type:`boolean`})]}}),(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(c.TSDoc,{heading:"Handler logic for the \\`completions zsh config\\` command."}),(0,e.createComponent)(r.FunctionDeclaration,{export:!0,default:!0,async:!0,name:`handler`,parameters:[{name:`options`,type:`ZshConfigCompletionsOptions`,default:`{}`},{name:`path`,type:`string`,default:`"~/.zshrc"`}],get children(){return[(0,e.createComponent)(r.IfStatement,{condition:n.code`options.display !== true`,get children(){return[(0,e.createComponent)(r.VarDeclaration,{let:!0,name:`configPath`,type:`string`,initializer:n.code` path.includes(".") ? path : join(path, ".zshrc");`}),(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(r.IfStatement,{condition:n.code`configPath.startsWith("~")`,children:n.code`configPath = join(os.homedir(), configPath.replace("~", "")); `}),(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(r.VarDeclaration,{let:!0,name:`content`,type:`string`,initializer:n.code`"";`}),(0,e.createComponent)(a.Spacing,{}),(0,e.memo)(()=>n.code`try {
|
|
102
2
|
content = await readFile(configPath, "utf8");
|
|
103
3
|
} catch (error) {
|
|
104
4
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
@@ -109,19 +9,15 @@ function ZshConfigCompletionsCommand() {
|
|
|
109
9
|
}
|
|
110
10
|
}
|
|
111
11
|
|
|
112
|
-
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0,
|
|
12
|
+
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${(0,t.getAppTitle)(u)} Shell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${(0,t.getAppTitle)(u)} Zsh Completions ###\`);
|
|
113
13
|
|
|
114
|
-
success(\`${(0,
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
118
|
-
return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
14
|
+
success(\`${(0,t.getAppTitle)(u)} shell completions have been applied to Zsh configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)]}}),(0,e.createComponent)(r.ElseClause,{get children(){return n.code`writeLine(" ------------------------------------------------- ");
|
|
119
15
|
writeLine("");
|
|
120
|
-
writeLine(\`### Begin - ${(0,
|
|
16
|
+
writeLine(\`### Begin - ${(0,t.getAppTitle)(u)} Zsh Completions ###\`);
|
|
121
17
|
writeLine("");
|
|
122
18
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
123
19
|
writeLine("");
|
|
124
|
-
writeLine(\`### End - ${(0,
|
|
20
|
+
writeLine(\`### End - ${(0,t.getAppTitle)(u)} Zsh Completions ###\`);
|
|
125
21
|
writeLine("");
|
|
126
22
|
writeLine(" ------------------------------------------------- ");
|
|
127
23
|
|
|
@@ -129,14 +25,4 @@ function ZshConfigCompletionsCommand() {
|
|
|
129
25
|
help(\`To enable these completions, perform one of the following actions:
|
|
130
26
|
|
|
131
27
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)
|
|
132
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
133
|
-
} })];
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
];
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
exports.ZshConfigCompletionsCommand = ZshConfigCompletionsCommand;
|
|
28
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `}})]}})]}})}exports.ZshConfigCompletionsCommand=u;
|
|
@@ -1,103 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
3
|
-
import { code } 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/zsh-config-command.tsx
|
|
13
|
-
/**
|
|
14
|
-
* The Zsh Completions - Configuration command's handler wrapper for the Shell Shock project.
|
|
15
|
-
*/
|
|
16
|
-
function ZshConfigCompletionsCommand() {
|
|
17
|
-
const context = usePowerlines();
|
|
18
|
-
return createComponent(TypescriptFile, {
|
|
19
|
-
get path() {
|
|
20
|
-
return joinPaths(context.entryPath, "completions", "zsh", "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: { console: [
|
|
29
|
-
"bold",
|
|
30
|
-
"inlineCode",
|
|
31
|
-
"writeLine",
|
|
32
|
-
"success",
|
|
33
|
-
"warn",
|
|
34
|
-
"help"
|
|
35
|
-
] },
|
|
36
|
-
get children() {
|
|
37
|
-
return [
|
|
38
|
-
createComponent(TSDoc$1, { heading: "Options for the Zsh Completions - Configuration command." }),
|
|
39
|
-
createComponent(InterfaceDeclaration, {
|
|
40
|
-
"export": true,
|
|
41
|
-
name: "ZshConfigCompletionsOptions",
|
|
42
|
-
get children() {
|
|
43
|
-
return [createComponent(TSDoc$1, {
|
|
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 createComponent(TSDocDefaultValue$1, {
|
|
47
|
-
get type() {
|
|
48
|
-
return ReflectionKind.boolean;
|
|
49
|
-
},
|
|
50
|
-
defaultValue: false
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}), createComponent(InterfaceMember$1, {
|
|
54
|
-
name: "display",
|
|
55
|
-
optional: true,
|
|
56
|
-
type: "boolean"
|
|
57
|
-
})];
|
|
58
|
-
}
|
|
59
|
-
}),
|
|
60
|
-
createComponent(Spacing, {}),
|
|
61
|
-
createComponent(TSDoc$1, { heading: "Handler logic for the \\`completions zsh config\\` command." }),
|
|
62
|
-
createComponent(FunctionDeclaration, {
|
|
63
|
-
"export": true,
|
|
64
|
-
"default": true,
|
|
65
|
-
async: true,
|
|
66
|
-
name: "handler",
|
|
67
|
-
parameters: [{
|
|
68
|
-
name: "options",
|
|
69
|
-
type: "ZshConfigCompletionsOptions",
|
|
70
|
-
default: "{}"
|
|
71
|
-
}, {
|
|
72
|
-
name: "path",
|
|
73
|
-
type: "string",
|
|
74
|
-
default: `"~/.zshrc"`
|
|
75
|
-
}],
|
|
76
|
-
get children() {
|
|
77
|
-
return [createComponent(IfStatement, {
|
|
78
|
-
condition: code`options.display !== true`,
|
|
79
|
-
get children() {
|
|
80
|
-
return [
|
|
81
|
-
createComponent(VarDeclaration, {
|
|
82
|
-
"let": true,
|
|
83
|
-
name: "configPath",
|
|
84
|
-
type: "string",
|
|
85
|
-
initializer: code` path.includes(".") ? path : join(path, ".zshrc");`
|
|
86
|
-
}),
|
|
87
|
-
createComponent(Spacing, {}),
|
|
88
|
-
createComponent(IfStatement, {
|
|
89
|
-
condition: code`configPath.startsWith("~")`,
|
|
90
|
-
children: code`configPath = join(os.homedir(), configPath.replace("~", "")); `
|
|
91
|
-
}),
|
|
92
|
-
createComponent(Spacing, {}),
|
|
93
|
-
createComponent(VarDeclaration, {
|
|
94
|
-
"let": true,
|
|
95
|
-
name: "content",
|
|
96
|
-
type: "string",
|
|
97
|
-
initializer: code`"";`
|
|
98
|
-
}),
|
|
99
|
-
createComponent(Spacing, {}),
|
|
100
|
-
memo(() => code`try {
|
|
1
|
+
import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{getAppTitle as n}from"@shell-shock/core/plugin-utils";import{code as r}from"@alloy-js/core";import{ElseClause as i,FunctionDeclaration as a,IfStatement as o,InterfaceDeclaration as s,VarDeclaration as c}from"@alloy-js/typescript";import{ReflectionKind as l}from"@powerlines/deepkit/vendor/type";import{Spacing as u}from"@powerlines/plugin-alloy/core";import{usePowerlines as d}from"@powerlines/plugin-alloy/core/contexts/context";import{InterfaceMember as f,TypescriptFile as p}from"@powerlines/plugin-alloy/typescript";import{TSDoc as m,TSDocDefaultValue as h}from"@powerlines/plugin-alloy/typescript/components/tsdoc";import{joinPaths as g}from"@stryke/path";function _(){let _=d();return e(p,{get path(){return g(_.entryPath,`completions`,`zsh`,`config`,`command.ts`)},imports:{"node:os":`os`,"node:path":[`join`],"node:fs/promises":[`readFile`,`writeFile`],"../shared":[`SHELL_COMPLETIONS`,`SHELL_COMPLETIONS_DISPLAY`]},builtinImports:{console:[`bold`,`inlineCode`,`writeLine`,`success`,`warn`,`help`]},get children(){return[e(m,{heading:`Options for the Zsh Completions - Configuration command.`}),e(s,{export:!0,name:`ZshConfigCompletionsOptions`,get children(){return[e(m,{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.`,get children(){return e(h,{get type(){return l.boolean},defaultValue:!1})}}),e(f,{name:`display`,optional:!0,type:`boolean`})]}}),e(u,{}),e(m,{heading:"Handler logic for the \\`completions zsh config\\` command."}),e(a,{export:!0,default:!0,async:!0,name:`handler`,parameters:[{name:`options`,type:`ZshConfigCompletionsOptions`,default:`{}`},{name:`path`,type:`string`,default:`"~/.zshrc"`}],get children(){return[e(o,{condition:r`options.display !== true`,get children(){return[e(c,{let:!0,name:`configPath`,type:`string`,initializer:r` path.includes(".") ? path : join(path, ".zshrc");`}),e(u,{}),e(o,{condition:r`configPath.startsWith("~")`,children:r`configPath = join(os.homedir(), configPath.replace("~", "")); `}),e(u,{}),e(c,{let:!0,name:`content`,type:`string`,initializer:r`"";`}),e(u,{}),t(()=>r`try {
|
|
101
2
|
content = await readFile(configPath, "utf8");
|
|
102
3
|
} catch (error) {
|
|
103
4
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
@@ -108,19 +9,15 @@ function ZshConfigCompletionsCommand() {
|
|
|
108
9
|
}
|
|
109
10
|
}
|
|
110
11
|
|
|
111
|
-
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${
|
|
12
|
+
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${n(_)} Shell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${n(_)} Zsh Completions ###\`);
|
|
112
13
|
|
|
113
|
-
success(\`${
|
|
114
|
-
];
|
|
115
|
-
}
|
|
116
|
-
}), createComponent(ElseClause, { get children() {
|
|
117
|
-
return code`writeLine(" ------------------------------------------------- ");
|
|
14
|
+
success(\`${n(_)} shell completions have been applied to Zsh configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)]}}),e(i,{get children(){return r`writeLine(" ------------------------------------------------- ");
|
|
118
15
|
writeLine("");
|
|
119
|
-
writeLine(\`### Begin - ${
|
|
16
|
+
writeLine(\`### Begin - ${n(_)} Zsh Completions ###\`);
|
|
120
17
|
writeLine("");
|
|
121
18
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
122
19
|
writeLine("");
|
|
123
|
-
writeLine(\`### End - ${
|
|
20
|
+
writeLine(\`### End - ${n(_)} Zsh Completions ###\`);
|
|
124
21
|
writeLine("");
|
|
125
22
|
writeLine(" ------------------------------------------------- ");
|
|
126
23
|
|
|
@@ -128,15 +25,5 @@ function ZshConfigCompletionsCommand() {
|
|
|
128
25
|
help(\`To enable these completions, perform one of the following actions:
|
|
129
26
|
|
|
130
27
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)
|
|
131
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
132
|
-
} })];
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
];
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
//#endregion
|
|
141
|
-
export { ZshConfigCompletionsCommand };
|
|
28
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `}})]}})]}})}export{_ as ZshConfigCompletionsCommand};
|
|
142
29
|
//# sourceMappingURL=zsh-config-command.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zsh-config-command.mjs","names":[],"sources":["../../src/components/zsh-config-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Zsh Completions - Configuration command's handler wrapper for the Shell Shock project.\n */\nexport function ZshConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"zsh\",\n \"config\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n console: [\"bold\", \"inlineCode\", \"writeLine\", \"success\", \"warn\", \"help\"]\n }}>\n <TSDoc heading=\"Options for the Zsh Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"ZshConfigCompletionsOptions\">\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 zsh config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"ZshConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.zshrc\"`\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, \".zshrc\");`}\n />\n <Spacing />\n <IfStatement condition={code`configPath.startsWith(\"~\")`}>\n {code`configPath = join(os.homedir(), configPath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"content\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n content = await readFile(configPath, \"utf8\");\n } catch (error) {\n if (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${bold(configPath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configPath, \\`\\${content}\\\\n\\\\n### Begin - ${getAppTitle(context)} Shell Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} Zsh Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to Zsh configuration file at \\${bold(configPath)}. Please restart your terminal or run \\${inlineCode(\\`source \\${configPath}\\`)} for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\\`### Begin - ${getAppTitle(context)} Zsh Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} Zsh Completions ###\\`);\n writeLine(\"\");\n writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)\n 2) Save the above script to a file and source it from your shell configuration file \\`); `}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"zsh-config-command.mjs","names":[],"sources":["../../src/components/zsh-config-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The Zsh Completions - Configuration command's handler wrapper for the Shell Shock project.\n */\nexport function ZshConfigCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"zsh\",\n \"config\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": \"os\",\n \"node:path\": [\"join\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"],\n \"../shared\": [\"SHELL_COMPLETIONS\", \"SHELL_COMPLETIONS_DISPLAY\"]\n }}\n builtinImports={{\n console: [\"bold\", \"inlineCode\", \"writeLine\", \"success\", \"warn\", \"help\"]\n }}>\n <TSDoc heading=\"Options for the Zsh Completions - Configuration command.\" />\n <InterfaceDeclaration export name=\"ZshConfigCompletionsOptions\">\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 zsh config\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n {\n name: \"options\",\n type: \"ZshConfigCompletionsOptions\",\n default: \"{}\"\n },\n {\n name: \"path\",\n type: \"string\",\n default: `\"~/.zshrc\"`\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, \".zshrc\");`}\n />\n <Spacing />\n <IfStatement condition={code`configPath.startsWith(\"~\")`}>\n {code`configPath = join(os.homedir(), configPath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"content\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n content = await readFile(configPath, \"utf8\");\n } catch (error) {\n if (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${bold(configPath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configPath, \\`\\${content}\\\\n\\\\n### Begin - ${getAppTitle(context)} Shell Completions ###\\\\n\\\\n\\${SHELL_COMPLETIONS} \\\\n\\\\n### End - ${getAppTitle(\n context\n )} Zsh Completions ###\\`);\n\n success(\\`${getAppTitle(\n context\n )} shell completions have been applied to Zsh configuration file at \\${bold(configPath)}. Please restart your terminal or run \\${inlineCode(\\`source \\${configPath}\\`)} for the changes to take effect.\\`); `}\n </IfStatement>\n <ElseClause>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(\"\");\n writeLine(\\`### Begin - ${getAppTitle(context)} Zsh Completions ###\\`);\n writeLine(\"\");\n SHELL_COMPLETIONS_DISPLAY.split(\"\\\\n\").map(line => writeLine(line));\n writeLine(\"\");\n writeLine(\\`### End - ${getAppTitle(context)} Zsh Completions ###\\`);\n writeLine(\"\");\n writeLine(\" ------------------------------------------------- \");\n\n writeLine(\"\");\n help(\\`To enable these completions, perform one of the following actions:\n\n 1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)\n 2) Save the above script to a file and source it from your shell configuration file \\`); `}\n </ElseClause>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":"muBA+BA,SAAE,GAAA,CACA,IAAM,EAAC,GAAwB,CACjC,OAAO,EAAA,EAAA,CACL,IAAK,MAAA,CACL,OAAA,EAAA,EAAA,UAAA,cAAA,MAAA,SAAA,aAAA,EAEF,QAAS,CACH,UAAG,KACH,YAAQ,CAAA,OAAA,6CAEZ,YAAA,CAAA,oBAAA,4BAAA,CACC,CACD,eAAA,CACI,QAAS,CAAC,OAAA,aAAA,YAA8B,UAAA,OAAA,OAAA,CAC5C,gBAEA,MAAO,CAAA,EAAA,EAAA,CACJ,QAAA,2DACC,CAAA,CAAI,EAAW,EAAA,CACb,OAAQ,GACR,KAAC,8BACD,IAAI,UAAC,CACJ,MAAO,CAAA,EAAA,EAAA,CACP,QAAU,6LACZ,IAAA,UAAA,CACO,OAAC,EAAA,EAAA,CACC,IAAI,MAAG,CACL,OAAK,EAAM,SAEjB,aAAW,GAChB,CAAA,EAEC,CAAA,CAAA,EAAmB,EAAc,CACjC,KAAA,UACI,SAAU,GACf,KAAA,UACE,CAAA,CAAA,EAEF,CAAC,CAAE,EAAQ,EAAe,EAAA,CAAO,CAAA,EAAA,EAAA,CAChC,QAAI,8DACL,CAAC,CAAE,EAAC,EAAA,CACH,OAAO,GACP,QAAC,GACD,MAAA,GACD,KAAO,UACP,WAAa,CAAC,CACd,KAAA,UACC,KAAA,8BACA,QAAA,KACA,CAAA,CACA,KAAM,OACN,KAAA,SACE,QAAA,aACD,CAAC,CACF,IAAI,UAAO,CACT,MAAE,CAAA,EAAY,EAAA,CACb,UAAA,CAAA,2BACD,IAAA,UAAA,CACE,MAAO,CAAA,EAAK,EAAA,CACR,IAAG,GACP,KAAU,aACZ,KAAA,SACA,YAAA,CAAA,qDACD,CAAA,CAAA,EAA2B,EAAS,EAAA,CAAA,CAAA,EAAkB,EAAA,CACpD,UAAA,CAAA,6BACC,SAAA,CAAA,iEACA,CAAI,CAAE,EAAU,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACZ,IAAE,GACN,KAAA,UACD,KAAA,SACA,YAAS,CAAA,MACT,CAAA,CAAA,EAAuB,EAAK,EAAA,CAAA,CAAW,MAAa,CAAI;;;;;;;;;;;uEAW/C,EAAA,EAAA,CAAA,oEAAA,EAAA,EAAA,CAAA;;sBAED,EAAO,EAAA,CAAA,4MAAA,CAAA,EAEf,CAAC,CAAE,EAAe,EAAe,CAChC,IAAE,UAAO,CACP,MAAK,EAAA;;sCAEP,EAAA,EAAA,CAAA;;;;oCAIA,EAAA,EAAA,CAAA;;;;;;;;wGAUD,CAAC,CAAA,EAEL,CAAC,CAAC,EAEN,CAAC"}
|
|
@@ -1,103 +1,11 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
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
|
-
let _stryke_string_format_snake_case = require("@stryke/string-format/snake-case");
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@alloy-js/core/jsx-runtime`),t=require(`@shell-shock/core/plugin-utils`),n=require(`@alloy-js/core`),r=require(`@alloy-js/typescript`),i=require(`@powerlines/deepkit/vendor/type`),a=require(`@powerlines/plugin-alloy/core`),o=require(`@powerlines/plugin-alloy/core/contexts/context`),s=require(`@powerlines/plugin-alloy/typescript`),c=require(`@powerlines/plugin-alloy/typescript/components/tsdoc`),l=require(`@stryke/path`),u=require(`@stryke/string-format/snake-case`);function d(){let d=(0,o.usePowerlines)(),f=(0,n.computed)(()=>(0,t.getAppBin)(d)),p=(0,n.computed)(()=>(0,u.snakeCase)(f.value));return(0,e.createComponent)(s.TypescriptFile,{get path(){return(0,l.joinPaths)(d.entryPath,`completions`,`zsh`,`script`,`command.ts`)},imports:{"node:os":`os`,"node:path":[`join`],"node:fs/promises":[`readFile`,`writeFile`],"../shared":[`SHELL_COMPLETIONS`,`SHELL_COMPLETIONS_DISPLAY`]},builtinImports:{console:[`bold`,`writeLine`,`success`,`warn`,`help`]},get children(){return[(0,e.createComponent)(c.TSDoc,{heading:`Options for the Zsh Completions - Script command.`}),(0,e.createComponent)(r.InterfaceDeclaration,{export:!0,name:`ZshScriptCompletionsOptions`,get children(){return[(0,e.createComponent)(c.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.`,get children(){return(0,e.createComponent)(c.TSDocDefaultValue,{get type(){return i.ReflectionKind.boolean},defaultValue:!1})}}),(0,e.createComponent)(s.InterfaceMember,{name:`display`,optional:!0,type:`boolean`})]}}),(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(c.TSDoc,{heading:"Handler logic for the \\`completions zsh script\\` command."}),(0,e.createComponent)(r.FunctionDeclaration,{export:!0,default:!0,async:!0,name:`handler`,get parameters(){return[{name:`options`,type:`ZshScriptCompletionsOptions`,default:`{}`},{name:`path`,type:`string`,default:`"${f.value}-completions.zsh"`}]},get children(){return[(0,e.createComponent)(r.IfStatement,{condition:n.code`options.display !== true`,get children(){return[(0,e.createComponent)(r.VarDeclaration,{const:!0,name:`scriptPath`,type:`string`,initializer:n.code` path.includes(".") ? \`\${path}.zsh\` : path;`}),(0,e.memo)(()=>n.code`await writeFile(scriptPath, \`# Zsh script to add completions for ${(0,t.getAppTitle)(d)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
13
2
|
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The Zsh Completions - Script command's handler wrapper for the Shell Shock project.
|
|
17
|
-
*/
|
|
18
|
-
function ZshScriptCompletionsCommand() {
|
|
19
|
-
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
20
|
-
const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
|
|
21
|
-
const name = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_snake_case.snakeCase)(bin.value));
|
|
22
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
|
|
23
|
-
get path() {
|
|
24
|
-
return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "zsh", "script", "command.ts");
|
|
25
|
-
},
|
|
26
|
-
imports: {
|
|
27
|
-
"node:os": "os",
|
|
28
|
-
"node:path": ["join"],
|
|
29
|
-
"node:fs/promises": ["readFile", "writeFile"],
|
|
30
|
-
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
31
|
-
},
|
|
32
|
-
builtinImports: { console: [
|
|
33
|
-
"bold",
|
|
34
|
-
"writeLine",
|
|
35
|
-
"success",
|
|
36
|
-
"warn",
|
|
37
|
-
"help"
|
|
38
|
-
] },
|
|
39
|
-
get children() {
|
|
40
|
-
return [
|
|
41
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Zsh Completions - Script command." }),
|
|
42
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
43
|
-
"export": true,
|
|
44
|
-
name: "ZshScriptCompletionsOptions",
|
|
45
|
-
get children() {
|
|
46
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
47
|
-
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.",
|
|
48
|
-
get children() {
|
|
49
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
50
|
-
get type() {
|
|
51
|
-
return _powerlines_deepkit_vendor_type.ReflectionKind.boolean;
|
|
52
|
-
},
|
|
53
|
-
defaultValue: false
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
|
|
57
|
-
name: "display",
|
|
58
|
-
optional: true,
|
|
59
|
-
type: "boolean"
|
|
60
|
-
})];
|
|
61
|
-
}
|
|
62
|
-
}),
|
|
63
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
64
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions zsh script\\` command." }),
|
|
65
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
66
|
-
"export": true,
|
|
67
|
-
"default": true,
|
|
68
|
-
async: true,
|
|
69
|
-
name: "handler",
|
|
70
|
-
get parameters() {
|
|
71
|
-
return [{
|
|
72
|
-
name: "options",
|
|
73
|
-
type: "ZshScriptCompletionsOptions",
|
|
74
|
-
default: "{}"
|
|
75
|
-
}, {
|
|
76
|
-
name: "path",
|
|
77
|
-
type: "string",
|
|
78
|
-
default: `"${bin.value}-completions.zsh"`
|
|
79
|
-
}];
|
|
80
|
-
},
|
|
81
|
-
get children() {
|
|
82
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
83
|
-
condition: _alloy_js_core.code`options.display !== true`,
|
|
84
|
-
get children() {
|
|
85
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
86
|
-
"const": true,
|
|
87
|
-
name: "scriptPath",
|
|
88
|
-
type: "string",
|
|
89
|
-
initializer: _alloy_js_core.code` path.includes(".") ? \`\${path}.zsh\` : path;`
|
|
90
|
-
}), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`await writeFile(scriptPath, \`# Zsh script to add completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
91
|
-
|
|
92
|
-
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh completion script has been generated at \${bold(scriptPath)}.\`);`)];
|
|
93
|
-
}
|
|
94
|
-
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
95
|
-
return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
3
|
+
success(\`${(0,t.getAppTitle)(d)} Zsh completion script has been generated at \${bold(scriptPath)}.\`);`)]}}),(0,e.createComponent)(r.ElseClause,{get children(){return n.code`writeLine(" ------------------------------------------------- ");
|
|
96
4
|
writeLine("");
|
|
97
|
-
writeLine("#compdef ${
|
|
98
|
-
writeLine("#compdef _${
|
|
5
|
+
writeLine("#compdef ${f.value} ");
|
|
6
|
+
writeLine("#compdef _${p.value} ${f.value}");
|
|
99
7
|
writeLine("");
|
|
100
|
-
writeLine("# Zsh completion for ${(0,
|
|
8
|
+
writeLine("# Zsh completion for ${(0,t.getAppTitle)(d)}");
|
|
101
9
|
writeLine("");
|
|
102
10
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
103
11
|
writeLine("");
|
|
@@ -107,14 +15,4 @@ function ZshScriptCompletionsCommand() {
|
|
|
107
15
|
help(\`To enable these completions, perform one of the following actions:
|
|
108
16
|
|
|
109
17
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)
|
|
110
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
111
|
-
} })];
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
//#endregion
|
|
120
|
-
exports.ZshScriptCompletionsCommand = ZshScriptCompletionsCommand;
|
|
18
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `}})]}})]}})}exports.ZshScriptCompletionsCommand=d;
|
|
@@ -1,102 +1,11 @@
|
|
|
1
|
-
import {
|
|
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
|
-
import { snakeCase } from "@stryke/string-format/snake-case";
|
|
1
|
+
import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{getAppBin as n,getAppTitle as r}from"@shell-shock/core/plugin-utils";import{code as i,computed as a}from"@alloy-js/core";import{ElseClause as o,FunctionDeclaration as s,IfStatement as c,InterfaceDeclaration as l,VarDeclaration as u}from"@alloy-js/typescript";import{ReflectionKind as d}from"@powerlines/deepkit/vendor/type";import{Spacing as f}from"@powerlines/plugin-alloy/core";import{usePowerlines as p}from"@powerlines/plugin-alloy/core/contexts/context";import{InterfaceMember as m,TypescriptFile as h}from"@powerlines/plugin-alloy/typescript";import{TSDoc as g,TSDocDefaultValue as _}from"@powerlines/plugin-alloy/typescript/components/tsdoc";import{joinPaths as v}from"@stryke/path";import{snakeCase as y}from"@stryke/string-format/snake-case";function b(){let b=p(),x=a(()=>n(b)),S=a(()=>y(x.value));return e(h,{get path(){return v(b.entryPath,`completions`,`zsh`,`script`,`command.ts`)},imports:{"node:os":`os`,"node:path":[`join`],"node:fs/promises":[`readFile`,`writeFile`],"../shared":[`SHELL_COMPLETIONS`,`SHELL_COMPLETIONS_DISPLAY`]},builtinImports:{console:[`bold`,`writeLine`,`success`,`warn`,`help`]},get children(){return[e(g,{heading:`Options for the Zsh Completions - Script command.`}),e(l,{export:!0,name:`ZshScriptCompletionsOptions`,get children(){return[e(g,{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.`,get children(){return e(_,{get type(){return d.boolean},defaultValue:!1})}}),e(m,{name:`display`,optional:!0,type:`boolean`})]}}),e(f,{}),e(g,{heading:"Handler logic for the \\`completions zsh script\\` command."}),e(s,{export:!0,default:!0,async:!0,name:`handler`,get parameters(){return[{name:`options`,type:`ZshScriptCompletionsOptions`,default:`{}`},{name:`path`,type:`string`,default:`"${x.value}-completions.zsh"`}]},get children(){return[e(c,{condition:i`options.display !== true`,get children(){return[e(u,{const:!0,name:`scriptPath`,type:`string`,initializer:i` path.includes(".") ? \`\${path}.zsh\` : path;`}),t(()=>i`await writeFile(scriptPath, \`# Zsh script to add completions for ${r(b)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
12
2
|
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The Zsh Completions - Script command's handler wrapper for the Shell Shock project.
|
|
16
|
-
*/
|
|
17
|
-
function ZshScriptCompletionsCommand() {
|
|
18
|
-
const context = usePowerlines();
|
|
19
|
-
const bin = computed(() => getAppBin(context));
|
|
20
|
-
const name = computed(() => snakeCase(bin.value));
|
|
21
|
-
return createComponent(TypescriptFile, {
|
|
22
|
-
get path() {
|
|
23
|
-
return joinPaths(context.entryPath, "completions", "zsh", "script", "command.ts");
|
|
24
|
-
},
|
|
25
|
-
imports: {
|
|
26
|
-
"node:os": "os",
|
|
27
|
-
"node:path": ["join"],
|
|
28
|
-
"node:fs/promises": ["readFile", "writeFile"],
|
|
29
|
-
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
30
|
-
},
|
|
31
|
-
builtinImports: { console: [
|
|
32
|
-
"bold",
|
|
33
|
-
"writeLine",
|
|
34
|
-
"success",
|
|
35
|
-
"warn",
|
|
36
|
-
"help"
|
|
37
|
-
] },
|
|
38
|
-
get children() {
|
|
39
|
-
return [
|
|
40
|
-
createComponent(TSDoc$1, { heading: "Options for the Zsh Completions - Script command." }),
|
|
41
|
-
createComponent(InterfaceDeclaration, {
|
|
42
|
-
"export": true,
|
|
43
|
-
name: "ZshScriptCompletionsOptions",
|
|
44
|
-
get children() {
|
|
45
|
-
return [createComponent(TSDoc$1, {
|
|
46
|
-
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.",
|
|
47
|
-
get children() {
|
|
48
|
-
return createComponent(TSDocDefaultValue$1, {
|
|
49
|
-
get type() {
|
|
50
|
-
return ReflectionKind.boolean;
|
|
51
|
-
},
|
|
52
|
-
defaultValue: false
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}), createComponent(InterfaceMember$1, {
|
|
56
|
-
name: "display",
|
|
57
|
-
optional: true,
|
|
58
|
-
type: "boolean"
|
|
59
|
-
})];
|
|
60
|
-
}
|
|
61
|
-
}),
|
|
62
|
-
createComponent(Spacing, {}),
|
|
63
|
-
createComponent(TSDoc$1, { heading: "Handler logic for the \\`completions zsh script\\` command." }),
|
|
64
|
-
createComponent(FunctionDeclaration, {
|
|
65
|
-
"export": true,
|
|
66
|
-
"default": true,
|
|
67
|
-
async: true,
|
|
68
|
-
name: "handler",
|
|
69
|
-
get parameters() {
|
|
70
|
-
return [{
|
|
71
|
-
name: "options",
|
|
72
|
-
type: "ZshScriptCompletionsOptions",
|
|
73
|
-
default: "{}"
|
|
74
|
-
}, {
|
|
75
|
-
name: "path",
|
|
76
|
-
type: "string",
|
|
77
|
-
default: `"${bin.value}-completions.zsh"`
|
|
78
|
-
}];
|
|
79
|
-
},
|
|
80
|
-
get children() {
|
|
81
|
-
return [createComponent(IfStatement, {
|
|
82
|
-
condition: code`options.display !== true`,
|
|
83
|
-
get children() {
|
|
84
|
-
return [createComponent(VarDeclaration, {
|
|
85
|
-
"const": true,
|
|
86
|
-
name: "scriptPath",
|
|
87
|
-
type: "string",
|
|
88
|
-
initializer: code` path.includes(".") ? \`\${path}.zsh\` : path;`
|
|
89
|
-
}), memo(() => code`await writeFile(scriptPath, \`# Zsh script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
90
|
-
|
|
91
|
-
success(\`${getAppTitle(context)} Zsh completion script has been generated at \${bold(scriptPath)}.\`);`)];
|
|
92
|
-
}
|
|
93
|
-
}), createComponent(ElseClause, { get children() {
|
|
94
|
-
return code`writeLine(" ------------------------------------------------- ");
|
|
3
|
+
success(\`${r(b)} Zsh completion script has been generated at \${bold(scriptPath)}.\`);`)]}}),e(o,{get children(){return i`writeLine(" ------------------------------------------------- ");
|
|
95
4
|
writeLine("");
|
|
96
|
-
writeLine("#compdef ${
|
|
97
|
-
writeLine("#compdef _${
|
|
5
|
+
writeLine("#compdef ${x.value} ");
|
|
6
|
+
writeLine("#compdef _${S.value} ${x.value}");
|
|
98
7
|
writeLine("");
|
|
99
|
-
writeLine("# Zsh completion for ${
|
|
8
|
+
writeLine("# Zsh completion for ${r(b)}");
|
|
100
9
|
writeLine("");
|
|
101
10
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
102
11
|
writeLine("");
|
|
@@ -106,15 +15,5 @@ function ZshScriptCompletionsCommand() {
|
|
|
106
15
|
help(\`To enable these completions, perform one of the following actions:
|
|
107
16
|
|
|
108
17
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/zsh/.zshrc)
|
|
109
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
110
|
-
} })];
|
|
111
|
-
}
|
|
112
|
-
})
|
|
113
|
-
];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
//#endregion
|
|
119
|
-
export { ZshScriptCompletionsCommand };
|
|
18
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `}})]}})]}})}export{b as ZshScriptCompletionsCommand};
|
|
120
19
|
//# sourceMappingURL=zsh-script-command.mjs.map
|