@sinch/cli 0.4.12 → 0.4.13
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/package.json +1 -1
- package/scripts/postinstall.js +37 -0
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -88,6 +88,39 @@ Register-ArgumentCompleter -Native -CommandName sinch -ScriptBlock {
|
|
|
88
88
|
${SENTINEL_END}`;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// Twin of generateBashCompletionFile in src/index.ts — keep in sync.
|
|
92
|
+
function generateBashCompletionFile() {
|
|
93
|
+
const mainCmds = Object.keys(COMPLETION_COMMANDS).join(' ') + ' --version --help';
|
|
94
|
+
const cases = Object.entries(COMPLETION_COMMANDS)
|
|
95
|
+
.map(
|
|
96
|
+
([cmd, subs]) =>
|
|
97
|
+
` ${cmd}) COMPREPLY=( $(compgen -W "${subs.join(' ')}" -- "$cur") ) ;;`
|
|
98
|
+
)
|
|
99
|
+
.join('\n');
|
|
100
|
+
|
|
101
|
+
return `# Bash/Zsh completion for Sinch CLI (auto-generated — do not edit)
|
|
102
|
+
_sinch_completion() {
|
|
103
|
+
local cur prev
|
|
104
|
+
COMPREPLY=()
|
|
105
|
+
cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
106
|
+
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
107
|
+
|
|
108
|
+
case "\${COMP_CWORD}" in
|
|
109
|
+
1)
|
|
110
|
+
COMPREPLY=( $(compgen -W "${mainCmds}" -- "$cur") )
|
|
111
|
+
;;
|
|
112
|
+
2)
|
|
113
|
+
case "\${prev}" in
|
|
114
|
+
${cases}
|
|
115
|
+
esac
|
|
116
|
+
;;
|
|
117
|
+
esac
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
complete -F _sinch_completion sinch
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
|
|
91
124
|
function shellEscapePath(p) {
|
|
92
125
|
return "'" + p.replace(/'/g, "'\\''") + "'";
|
|
93
126
|
}
|
|
@@ -161,6 +194,8 @@ async function installPowerShellCompletion() {
|
|
|
161
194
|
|
|
162
195
|
function installBashZshCompletion() {
|
|
163
196
|
const completionFile = path.join(SINCH_DIR, 'sinch-completion.bash');
|
|
197
|
+
fs.writeFileSync(completionFile, generateBashCompletionFile());
|
|
198
|
+
|
|
164
199
|
const sourceLine = `source ${shellEscapePath(completionFile)}`;
|
|
165
200
|
const block = `${SENTINEL_START}\n${sourceLine}\n${SENTINEL_END}`;
|
|
166
201
|
|
|
@@ -278,4 +313,6 @@ if (require.main === module) {
|
|
|
278
313
|
module.exports = {
|
|
279
314
|
stripManagedBlocks,
|
|
280
315
|
upsertBlock,
|
|
316
|
+
installBashZshCompletion,
|
|
317
|
+
generateBashCompletionFile,
|
|
281
318
|
};
|