@shell-shock/plugin-completions 0.4.16 → 0.4.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/bash-config-command.cjs +116 -6
- package/dist/components/bash-config-command.d.cts +1 -3
- package/dist/components/bash-config-command.d.cts.map +1 -1
- package/dist/components/bash-config-command.d.mts +1 -3
- package/dist/components/bash-config-command.d.mts.map +1 -1
- package/dist/components/bash-config-command.mjs +115 -6
- package/dist/components/bash-config-command.mjs.map +1 -1
- package/dist/components/bash-script-command.cjs +101 -5
- package/dist/components/bash-script-command.d.cts +1 -3
- package/dist/components/bash-script-command.d.cts.map +1 -1
- package/dist/components/bash-script-command.d.mts +1 -3
- package/dist/components/bash-script-command.d.mts.map +1 -1
- package/dist/components/bash-script-command.mjs +100 -5
- package/dist/components/bash-script-command.mjs.map +1 -1
- package/dist/components/bash-shared.cjs +77 -13
- package/dist/components/bash-shared.d.cts +1 -3
- package/dist/components/bash-shared.d.cts.map +1 -1
- package/dist/components/bash-shared.d.mts +1 -3
- package/dist/components/bash-shared.d.mts.map +1 -1
- package/dist/components/bash-shared.mjs +76 -13
- package/dist/components/bash-shared.mjs.map +1 -1
- package/dist/components/fish-config-command.cjs +116 -6
- package/dist/components/fish-config-command.d.cts +1 -3
- package/dist/components/fish-config-command.d.cts.map +1 -1
- package/dist/components/fish-config-command.d.mts +1 -3
- package/dist/components/fish-config-command.d.mts.map +1 -1
- package/dist/components/fish-config-command.mjs +115 -6
- package/dist/components/fish-config-command.mjs.map +1 -1
- package/dist/components/fish-script-command.cjs +100 -4
- package/dist/components/fish-script-command.d.cts +1 -3
- package/dist/components/fish-script-command.d.cts.map +1 -1
- package/dist/components/fish-script-command.d.mts +1 -3
- package/dist/components/fish-script-command.d.mts.map +1 -1
- package/dist/components/fish-script-command.mjs +99 -4
- package/dist/components/fish-script-command.mjs.map +1 -1
- package/dist/components/fish-shared.cjs +141 -77
- package/dist/components/fish-shared.d.cts +1 -3
- package/dist/components/fish-shared.d.cts.map +1 -1
- package/dist/components/fish-shared.d.mts +1 -3
- package/dist/components/fish-shared.d.mts.map +1 -1
- package/dist/components/fish-shared.mjs +140 -77
- package/dist/components/fish-shared.mjs.map +1 -1
- package/dist/components/index.cjs +26 -1
- package/dist/components/index.mjs +14 -1
- package/dist/components/powershell-config-command.cjs +112 -6
- package/dist/components/powershell-config-command.d.cts +1 -3
- package/dist/components/powershell-config-command.d.cts.map +1 -1
- package/dist/components/powershell-config-command.d.mts +1 -3
- package/dist/components/powershell-config-command.d.mts.map +1 -1
- package/dist/components/powershell-config-command.mjs +111 -6
- package/dist/components/powershell-config-command.mjs.map +1 -1
- package/dist/components/powershell-script-command.cjs +100 -4
- package/dist/components/powershell-script-command.d.cts +1 -3
- package/dist/components/powershell-script-command.d.cts.map +1 -1
- package/dist/components/powershell-script-command.d.mts +1 -3
- package/dist/components/powershell-script-command.d.mts.map +1 -1
- package/dist/components/powershell-script-command.mjs +99 -4
- package/dist/components/powershell-script-command.mjs.map +1 -1
- package/dist/components/powershell-shared.cjs +101 -37
- package/dist/components/powershell-shared.d.cts +1 -3
- package/dist/components/powershell-shared.d.cts.map +1 -1
- package/dist/components/powershell-shared.d.mts +1 -3
- package/dist/components/powershell-shared.d.mts.map +1 -1
- package/dist/components/powershell-shared.mjs +100 -37
- package/dist/components/powershell-shared.mjs.map +1 -1
- package/dist/components/zsh-config-command.cjs +116 -6
- package/dist/components/zsh-config-command.d.cts +1 -3
- package/dist/components/zsh-config-command.d.cts.map +1 -1
- package/dist/components/zsh-config-command.d.mts +1 -3
- package/dist/components/zsh-config-command.d.mts.map +1 -1
- package/dist/components/zsh-config-command.mjs +115 -6
- package/dist/components/zsh-config-command.mjs.map +1 -1
- package/dist/components/zsh-script-command.cjs +104 -6
- package/dist/components/zsh-script-command.d.cts +1 -3
- package/dist/components/zsh-script-command.d.cts.map +1 -1
- package/dist/components/zsh-script-command.d.mts +1 -3
- package/dist/components/zsh-script-command.d.mts.map +1 -1
- package/dist/components/zsh-script-command.mjs +103 -6
- package/dist/components/zsh-script-command.mjs.map +1 -1
- package/dist/components/zsh-shared.cjs +106 -42
- package/dist/components/zsh-shared.d.cts +1 -3
- package/dist/components/zsh-shared.d.cts.map +1 -1
- package/dist/components/zsh-shared.d.mts +1 -3
- package/dist/components/zsh-shared.d.mts.map +1 -1
- package/dist/components/zsh-shared.mjs +105 -42
- package/dist/components/zsh-shared.mjs.map +1 -1
- package/dist/helpers/complete-command.cjs +10 -1
- package/dist/helpers/complete-command.d.mts.map +1 -1
- package/dist/helpers/complete-command.mjs +8 -1
- package/dist/helpers/complete-command.mjs.map +1 -1
- package/dist/helpers/completion-directive-constants.cjs +16 -1
- package/dist/helpers/completion-directive-constants.d.mts.map +1 -1
- package/dist/helpers/completion-directive-constants.mjs +14 -1
- package/dist/helpers/completion-directive-constants.mjs.map +1 -1
- package/dist/helpers/index.cjs +6 -1
- package/dist/helpers/index.mjs +4 -1
- package/dist/index.cjs +290 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +288 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +4 -1
- package/dist/types/index.mjs +3 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/shell-type.cjs +12 -1
- package/dist/types/shell-type.d.cts.map +1 -1
- package/dist/types/shell-type.d.mts.map +1 -1
- package/dist/types/shell-type.mjs +10 -1
- package/dist/types/shell-type.mjs.map +1 -1
- package/package.json +13 -13
|
@@ -1,4 +1,95 @@
|
|
|
1
|
-
import{createComponent
|
|
1
|
+
import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
3
|
+
import { code } from "@alloy-js/core";
|
|
4
|
+
import { ElseClause, FunctionDeclaration, IfStatement, InterfaceDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
5
|
+
import { Spacing } from "@powerlines/plugin-alloy/core";
|
|
6
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
7
|
+
import { InterfaceMember, TSDoc, TSDocDefaultValue, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
|
|
8
|
+
import { joinPaths } from "@stryke/path";
|
|
9
|
+
|
|
10
|
+
//#region src/components/powershell-config-command.tsx
|
|
11
|
+
function PowerShellConfigCompletionsCommand() {
|
|
12
|
+
const context = usePowerlines();
|
|
13
|
+
return createComponent(TypescriptFile, {
|
|
14
|
+
get path() {
|
|
15
|
+
return joinPaths(context.entryPath, "completions", "powershell", "config", "command.ts");
|
|
16
|
+
},
|
|
17
|
+
imports: {
|
|
18
|
+
"node:os": "os",
|
|
19
|
+
"node:path": ["join"],
|
|
20
|
+
"node:fs/promises": ["readFile", "writeFile"],
|
|
21
|
+
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
22
|
+
},
|
|
23
|
+
builtinImports: { "shell-shock:console": [
|
|
24
|
+
"bold",
|
|
25
|
+
"inlineCode",
|
|
26
|
+
"writeLine",
|
|
27
|
+
"success",
|
|
28
|
+
"warn",
|
|
29
|
+
"help"
|
|
30
|
+
] },
|
|
31
|
+
get children() {
|
|
32
|
+
return [
|
|
33
|
+
createComponent(TSDoc, { heading: "Options for the PowerShell Completions - Configuration command." }),
|
|
34
|
+
createComponent(InterfaceDeclaration, {
|
|
35
|
+
"export": true,
|
|
36
|
+
name: "PowerShellConfigCompletionsOptions",
|
|
37
|
+
get children() {
|
|
38
|
+
return [createComponent(TSDoc, {
|
|
39
|
+
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.",
|
|
40
|
+
get children() {
|
|
41
|
+
return createComponent(TSDocDefaultValue, {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
defaultValue: false
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}), createComponent(InterfaceMember, {
|
|
47
|
+
name: "display",
|
|
48
|
+
type: "boolean"
|
|
49
|
+
})];
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
createComponent(Spacing, {}),
|
|
53
|
+
createComponent(TSDoc, { heading: "Handler logic for the \\`completions powershell config\\` command." }),
|
|
54
|
+
createComponent(FunctionDeclaration, {
|
|
55
|
+
"export": true,
|
|
56
|
+
"default": true,
|
|
57
|
+
async: true,
|
|
58
|
+
name: "handler",
|
|
59
|
+
parameters: [{
|
|
60
|
+
name: "options",
|
|
61
|
+
type: "PowerShellConfigCompletionsOptions",
|
|
62
|
+
default: "{}"
|
|
63
|
+
}, {
|
|
64
|
+
name: "path",
|
|
65
|
+
type: "string",
|
|
66
|
+
default: `"~/.config/powershell/Microsoft.PowerShell_profile.ps1"`
|
|
67
|
+
}],
|
|
68
|
+
get children() {
|
|
69
|
+
return [createComponent(IfStatement, {
|
|
70
|
+
condition: code`options.display !== true`,
|
|
71
|
+
get children() {
|
|
72
|
+
return [
|
|
73
|
+
createComponent(VarDeclaration, {
|
|
74
|
+
"let": true,
|
|
75
|
+
name: "configPath",
|
|
76
|
+
type: "string",
|
|
77
|
+
initializer: code` path.includes(".") ? path : join(path, "Microsoft.PowerShell_profile.ps1");`
|
|
78
|
+
}),
|
|
79
|
+
createComponent(Spacing, {}),
|
|
80
|
+
createComponent(IfStatement, {
|
|
81
|
+
condition: code`configPath.startsWith("~")`,
|
|
82
|
+
children: code`configPath = join(os.homedir(), configPath.replace("~", "")); `
|
|
83
|
+
}),
|
|
84
|
+
createComponent(Spacing, {}),
|
|
85
|
+
createComponent(VarDeclaration, {
|
|
86
|
+
"let": true,
|
|
87
|
+
name: "content",
|
|
88
|
+
type: "string",
|
|
89
|
+
initializer: code`"";`
|
|
90
|
+
}),
|
|
91
|
+
createComponent(Spacing, {}),
|
|
92
|
+
memo(() => code`try {
|
|
2
93
|
content = await readFile(configPath, "utf8");
|
|
3
94
|
} catch (error) {
|
|
4
95
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
@@ -9,15 +100,19 @@ import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{ge
|
|
|
9
100
|
}
|
|
10
101
|
}
|
|
11
102
|
|
|
12
|
-
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${
|
|
103
|
+
await writeFile(configPath, \`\${content}\\n\\n### Begin - ${getAppTitle(context)} PowerShell Completions ###\\n\\n\${SHELL_COMPLETIONS} \\n\\n### End - ${getAppTitle(context)} PowerShell Completions ###\`);
|
|
13
104
|
|
|
14
|
-
success(\`${
|
|
105
|
+
success(\`${getAppTitle(context)} shell completions have been applied to PowerShell configuration file at \${bold(configPath)}. Please restart your terminal or run \${inlineCode(\`source \${configPath}\`)} for the changes to take effect.\`); `)
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
}), createComponent(ElseClause, { get children() {
|
|
109
|
+
return code`writeLine(" ------------------------------------------------- ");
|
|
15
110
|
writeLine("");
|
|
16
|
-
writeLine(\`### Begin - ${
|
|
111
|
+
writeLine(\`### Begin - ${getAppTitle(context)} PowerShell Completions ###\`);
|
|
17
112
|
writeLine("");
|
|
18
113
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
19
114
|
writeLine("");
|
|
20
|
-
writeLine(\`### End - ${
|
|
115
|
+
writeLine(\`### End - ${getAppTitle(context)} PowerShell Completions ###\`);
|
|
21
116
|
writeLine("");
|
|
22
117
|
writeLine(" ------------------------------------------------- ");
|
|
23
118
|
|
|
@@ -25,5 +120,15 @@ import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{ge
|
|
|
25
120
|
help(\`To enable these completions, perform one of the following actions:
|
|
26
121
|
|
|
27
122
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/powershell/Microsoft.PowerShell_profile.ps1)
|
|
28
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
123
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `;
|
|
124
|
+
} })];
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
export { PowerShellConfigCompletionsCommand };
|
|
29
134
|
//# sourceMappingURL=powershell-config-command.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powershell-config-command.mjs","names":[],"sources":[
|
|
1
|
+
{"version":3,"file":"powershell-config-command.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1,8 +1,94 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
3
|
+
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
|
+
let _powerlines_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_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
10
|
+
let _stryke_path = require("@stryke/path");
|
|
2
11
|
|
|
3
|
-
|
|
12
|
+
//#region src/components/powershell-script-command.tsx
|
|
13
|
+
/**
|
|
14
|
+
* The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
|
|
15
|
+
*/
|
|
16
|
+
function PowerShellScriptCompletionsCommand() {
|
|
17
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
18
|
+
const bin = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppBin)(context));
|
|
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", "powershell", "script", "command.ts");
|
|
22
|
+
},
|
|
23
|
+
imports: {
|
|
24
|
+
"node:os": "os",
|
|
25
|
+
"node:path": ["join"],
|
|
26
|
+
"node:fs/promises": ["readFile", "writeFile"],
|
|
27
|
+
"../shared": ["SHELL_COMPLETIONS", "SHELL_COMPLETIONS_DISPLAY"]
|
|
28
|
+
},
|
|
29
|
+
builtinImports: { console: [
|
|
30
|
+
"bold",
|
|
31
|
+
"writeLine",
|
|
32
|
+
"success",
|
|
33
|
+
"warn",
|
|
34
|
+
"help"
|
|
35
|
+
] },
|
|
36
|
+
get children() {
|
|
37
|
+
return [
|
|
38
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the PowerShell Completions - Script command." }),
|
|
39
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceDeclaration, {
|
|
40
|
+
"export": true,
|
|
41
|
+
name: "PowerShellScriptCompletionsOptions",
|
|
42
|
+
get children() {
|
|
43
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
44
|
+
heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
|
|
45
|
+
get children() {
|
|
46
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
47
|
+
type: "boolean",
|
|
48
|
+
defaultValue: false
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
|
|
52
|
+
name: "display",
|
|
53
|
+
type: "boolean"
|
|
54
|
+
})];
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
|
|
58
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions powershell script\\` command." }),
|
|
59
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
60
|
+
"export": true,
|
|
61
|
+
"default": true,
|
|
62
|
+
async: true,
|
|
63
|
+
name: "handler",
|
|
64
|
+
get parameters() {
|
|
65
|
+
return [{
|
|
66
|
+
name: "options",
|
|
67
|
+
type: "PowerShellScriptCompletionsOptions",
|
|
68
|
+
default: "{}"
|
|
69
|
+
}, {
|
|
70
|
+
name: "path",
|
|
71
|
+
type: "string",
|
|
72
|
+
default: `"./${bin.value}-completions.ps1"`
|
|
73
|
+
}];
|
|
74
|
+
},
|
|
75
|
+
get children() {
|
|
76
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
77
|
+
condition: _alloy_js_core.code`options.display !== true`,
|
|
78
|
+
get children() {
|
|
79
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
80
|
+
"const": true,
|
|
81
|
+
name: "scriptPath",
|
|
82
|
+
type: "string",
|
|
83
|
+
initializer: _alloy_js_core.code` path.includes(".") ? \`\${path}.ps1\` : path;`
|
|
84
|
+
}), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`await writeFile(scriptPath, \`# PowerShell script to add completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
85
|
+
|
|
86
|
+
success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} PowerShell completion script has been generated at \${bold(scriptPath)}.\`);`)];
|
|
87
|
+
}
|
|
88
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { get children() {
|
|
89
|
+
return _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
|
|
4
90
|
writeLine("");
|
|
5
|
-
writeLine(\`# PowerShell completions for ${(0,
|
|
91
|
+
writeLine(\`# PowerShell completions for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)}\`);
|
|
6
92
|
writeLine("");
|
|
7
93
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
8
94
|
writeLine("");
|
|
@@ -12,4 +98,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
|
|
|
12
98
|
help(\`To enable these completions, perform one of the following actions:
|
|
13
99
|
|
|
14
100
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/powershell/Microsoft.PowerShell_profile.ps1)
|
|
15
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
101
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `;
|
|
102
|
+
} })];
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
exports.PowerShellScriptCompletionsCommand = PowerShellScriptCompletionsCommand;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
|
-
|
|
3
1
|
//#region src/components/powershell-script-command.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
|
|
6
4
|
*/
|
|
7
|
-
declare function PowerShellScriptCompletionsCommand():
|
|
5
|
+
declare function PowerShellScriptCompletionsCommand(): import("@alloy-js/core").Children;
|
|
8
6
|
//#endregion
|
|
9
7
|
export { PowerShellScriptCompletionsCommand };
|
|
10
8
|
//# sourceMappingURL=powershell-script-command.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powershell-script-command.d.cts","names":[],"sources":["../../src/components/powershell-script-command.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"powershell-script-command.d.cts","names":[],"sources":["../../src/components/powershell-script-command.tsx"],"mappings":";;AA2CA;;iBAAgB,kCAAA,6BAAkC,QAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
2
|
-
|
|
3
1
|
//#region src/components/powershell-script-command.d.ts
|
|
4
2
|
/**
|
|
5
3
|
* The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
|
|
6
4
|
*/
|
|
7
|
-
declare function PowerShellScriptCompletionsCommand():
|
|
5
|
+
declare function PowerShellScriptCompletionsCommand(): import("@alloy-js/core").Children;
|
|
8
6
|
//#endregion
|
|
9
7
|
export { PowerShellScriptCompletionsCommand };
|
|
10
8
|
//# sourceMappingURL=powershell-script-command.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powershell-script-command.d.mts","names":[],"sources":["../../src/components/powershell-script-command.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"powershell-script-command.d.mts","names":[],"sources":["../../src/components/powershell-script-command.tsx"],"mappings":""}
|
|
@@ -1,8 +1,93 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
3
|
+
import { code, computed } from "@alloy-js/core";
|
|
4
|
+
import { ElseClause, FunctionDeclaration, IfStatement, VarDeclaration } from "@alloy-js/typescript";
|
|
5
|
+
import { Spacing } from "@powerlines/plugin-alloy/core";
|
|
6
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
7
|
+
import { InterfaceDeclaration as InterfaceDeclaration$1, InterfaceMember, TypescriptFile } from "@powerlines/plugin-alloy/typescript";
|
|
8
|
+
import { TSDoc as TSDoc$1, TSDocDefaultValue as TSDocDefaultValue$1 } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
9
|
+
import { joinPaths } from "@stryke/path";
|
|
2
10
|
|
|
3
|
-
|
|
11
|
+
//#region src/components/powershell-script-command.tsx
|
|
12
|
+
/**
|
|
13
|
+
* The PowerShell Completions - Script command's handler wrapper for the Shell Shock project.
|
|
14
|
+
*/
|
|
15
|
+
function PowerShellScriptCompletionsCommand() {
|
|
16
|
+
const context = usePowerlines();
|
|
17
|
+
const bin = computed(() => getAppBin(context));
|
|
18
|
+
return createComponent(TypescriptFile, {
|
|
19
|
+
get path() {
|
|
20
|
+
return joinPaths(context.entryPath, "completions", "powershell", "script", "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
|
+
"writeLine",
|
|
31
|
+
"success",
|
|
32
|
+
"warn",
|
|
33
|
+
"help"
|
|
34
|
+
] },
|
|
35
|
+
get children() {
|
|
36
|
+
return [
|
|
37
|
+
createComponent(TSDoc$1, { heading: "Options for the PowerShell Completions - Script command." }),
|
|
38
|
+
createComponent(InterfaceDeclaration$1, {
|
|
39
|
+
"export": true,
|
|
40
|
+
name: "PowerShellScriptCompletionsOptions",
|
|
41
|
+
get children() {
|
|
42
|
+
return [createComponent(TSDoc$1, {
|
|
43
|
+
heading: "Should the generated completion script be written to console output instead of an actual file on disk? This is useful for debugging purposes or if you want to manually handle the output.",
|
|
44
|
+
get children() {
|
|
45
|
+
return createComponent(TSDocDefaultValue$1, {
|
|
46
|
+
type: "boolean",
|
|
47
|
+
defaultValue: false
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}), createComponent(InterfaceMember, {
|
|
51
|
+
name: "display",
|
|
52
|
+
type: "boolean"
|
|
53
|
+
})];
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
createComponent(Spacing, {}),
|
|
57
|
+
createComponent(TSDoc$1, { heading: "Handler logic for the \\`completions powershell script\\` command." }),
|
|
58
|
+
createComponent(FunctionDeclaration, {
|
|
59
|
+
"export": true,
|
|
60
|
+
"default": true,
|
|
61
|
+
async: true,
|
|
62
|
+
name: "handler",
|
|
63
|
+
get parameters() {
|
|
64
|
+
return [{
|
|
65
|
+
name: "options",
|
|
66
|
+
type: "PowerShellScriptCompletionsOptions",
|
|
67
|
+
default: "{}"
|
|
68
|
+
}, {
|
|
69
|
+
name: "path",
|
|
70
|
+
type: "string",
|
|
71
|
+
default: `"./${bin.value}-completions.ps1"`
|
|
72
|
+
}];
|
|
73
|
+
},
|
|
74
|
+
get children() {
|
|
75
|
+
return [createComponent(IfStatement, {
|
|
76
|
+
condition: code`options.display !== true`,
|
|
77
|
+
get children() {
|
|
78
|
+
return [createComponent(VarDeclaration, {
|
|
79
|
+
"const": true,
|
|
80
|
+
name: "scriptPath",
|
|
81
|
+
type: "string",
|
|
82
|
+
initializer: code` path.includes(".") ? \`\${path}.ps1\` : path;`
|
|
83
|
+
}), memo(() => code`await writeFile(scriptPath, \`# PowerShell script to add completions for ${getAppTitle(context)}\\n\\n\${SHELL_COMPLETIONS}\`);
|
|
84
|
+
|
|
85
|
+
success(\`${getAppTitle(context)} PowerShell completion script has been generated at \${bold(scriptPath)}.\`);`)];
|
|
86
|
+
}
|
|
87
|
+
}), createComponent(ElseClause, { get children() {
|
|
88
|
+
return code`writeLine(" ------------------------------------------------- ");
|
|
4
89
|
writeLine("");
|
|
5
|
-
writeLine(\`# PowerShell completions for ${
|
|
90
|
+
writeLine(\`# PowerShell completions for ${getAppTitle(context)}\`);
|
|
6
91
|
writeLine("");
|
|
7
92
|
SHELL_COMPLETIONS_DISPLAY.split("\\n").map(line => writeLine(line));
|
|
8
93
|
writeLine("");
|
|
@@ -12,5 +97,15 @@ import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{ge
|
|
|
12
97
|
help(\`To enable these completions, perform one of the following actions:
|
|
13
98
|
|
|
14
99
|
1) Copy and paste the above script into your shell configuration file (e.g., ~/.config/powershell/Microsoft.PowerShell_profile.ps1)
|
|
15
|
-
2) Save the above script to a file and source it from your shell configuration file \`);
|
|
100
|
+
2) Save the above script to a file and source it from your shell configuration file \`); `;
|
|
101
|
+
} })];
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
export { PowerShellScriptCompletionsCommand };
|
|
16
111
|
//# sourceMappingURL=powershell-script-command.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powershell-script-command.mjs","names":[],"sources":[
|
|
1
|
+
{"version":3,"file":"powershell-script-command.mjs","names":[],"sources":[],"mappings":""}
|