@seamapi/cli 0.12.0 → 0.13.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 CHANGED
@@ -202,17 +202,28 @@ seam completion zsh > "${fpath[1]}/_seam"
202
202
  ```
203
203
 
204
204
  System packages install completion loaders instead: small scripts packaged
205
- under `completions/` in the published package and attached to each
206
- [GitHub release]. A loader runs `seam completion` the first time the shell
207
- completes a seam command, so installed completions always match the CLI's
208
- current Seam API definitions and never go stale between package updates. The
209
- `seam-bin` AUR package installs the loaders for all three shells.
205
+ under `completions/` in the published package, and released as
206
+ `seam-completions-v<version>.tar.gz` on each [GitHub release]. A loader runs
207
+ `seam completion` the first time the shell completes a seam command, so
208
+ installed completions always match the CLI's current Seam API definitions and
209
+ never go stale between package updates. The `seam-bin` AUR package installs
210
+ the loaders for all three shells.
210
211
 
211
212
  Completions are generated from the cached Seam API definitions, so they may
212
213
  briefly lag a newly released API. Pass `--update` to refresh the cache first,
213
214
  e.g., `seam completion bash --update`. They do not reflect definitions served
214
215
  by another Seam API server when `seam config use-remote-api-defs` is enabled.
215
216
 
217
+ If completions do not appear after installing them system wide:
218
+
219
+ - Bash reads them via the [bash-completion] package,
220
+ so it must be installed and sourced by the shell.
221
+ - Zsh caches the completion functions it found at startup: after installing,
222
+ rebuild the cache with `rm -f ~/.zcompdump*` and start a new shell.
223
+ This applies to frameworks that call `compinit -C`, e.g., oh-my-zsh.
224
+ - Fish needs nothing extra: completions load on demand in new sessions.
225
+
226
+ [bash-completion]: https://github.com/scop/bash-completion
216
227
  [GitHub release]: https://github.com/seamapi/cli/releases/latest
217
228
 
218
229
  ## Development and Testing
@@ -7,5 +7,10 @@
7
7
  # Install to /usr/share/bash-completion/completions/seam
8
8
 
9
9
  if command -v seam > /dev/null 2>&1; then
10
- eval "$(seam completion bash 2> /dev/null)"
10
+ __seam_completion_script="$(seam completion bash 2> /dev/null)"
11
+ # Evaluate only a completion script, never anything else the CLI printed.
12
+ case "$__seam_completion_script" in
13
+ '# bash completion for the seam command.'*) eval "$__seam_completion_script" ;;
14
+ esac
15
+ unset __seam_completion_script
11
16
  fi
@@ -7,5 +7,9 @@
7
7
  # Install to /usr/share/fish/vendor_completions.d/seam.fish
8
8
 
9
9
  if command --query seam
10
- seam completion fish 2> /dev/null | source
10
+ set -l __seam_completion_script (seam completion fish 2> /dev/null | string collect)
11
+ # Source only a completion script, never anything else the CLI printed.
12
+ if string match --quiet '# fish completion for the seam command.*' -- $__seam_completion_script
13
+ printf '%s\n' $__seam_completion_script | source
14
+ end
11
15
  end
@@ -7,7 +7,13 @@
7
7
  #
8
8
  # Install to a directory in fpath as _seam
9
9
 
10
- # The generated script ends by dispatching on funcstack, so evaluating it
11
- # while this autoloaded _seam runs both redefines _seam and completes the
12
- # in-flight request.
13
- eval "$(seam completion zsh 2> /dev/null)"
10
+ local __seam_completion_script
11
+ __seam_completion_script="$(seam completion zsh 2> /dev/null)"
12
+
13
+ # Evaluate only a completion script, never anything else the CLI printed.
14
+ # The script ends by dispatching on funcstack, so evaluating it while this
15
+ # autoloaded _seam runs both redefines _seam and completes the in-flight
16
+ # request.
17
+ if [[ "$__seam_completion_script" == '#compdef seam'* ]]; then
18
+ eval "$__seam_completion_script"
19
+ fi
@@ -15,6 +15,14 @@ export declare const renderCompletion: (shell: CompletionShell, blueprint: Bluep
15
15
  * at first completion, never at shell startup.
16
16
  *
17
17
  * The loader degrades to no completions when the seam command is missing or
18
- * cannot produce a script, e.g., offline before the definitions are cached.
18
+ * does not produce a completion script: a script is only evaluated when it
19
+ * starts with the exact first line 'seam completion' generates, so nothing
20
+ * else the CLI may print, e.g., 'Not logged in' from a version without the
21
+ * completion command, is ever evaluated as shell code.
19
22
  */
20
23
  export declare const renderCompletionStub: (shell: CompletionShell) => string;
24
+ /**
25
+ * First line of each generated completion script, which the loaders require
26
+ * before evaluating one. Must match the output of {@link renderCompletion}.
27
+ */
28
+ export declare const completionScriptSentinels: Record<CompletionShell, string>;
@@ -26,9 +26,21 @@ export const renderCompletion = (shell, blueprint) => renderers[shell](getComman
26
26
  * at first completion, never at shell startup.
27
27
  *
28
28
  * The loader degrades to no completions when the seam command is missing or
29
- * cannot produce a script, e.g., offline before the definitions are cached.
29
+ * does not produce a completion script: a script is only evaluated when it
30
+ * starts with the exact first line 'seam completion' generates, so nothing
31
+ * else the CLI may print, e.g., 'Not logged in' from a version without the
32
+ * completion command, is ever evaluated as shell code.
30
33
  */
31
34
  export const renderCompletionStub = (shell) => stubs[shell];
35
+ /**
36
+ * First line of each generated completion script, which the loaders require
37
+ * before evaluating one. Must match the output of {@link renderCompletion}.
38
+ */
39
+ export const completionScriptSentinels = {
40
+ bash: '# bash completion for the seam command.',
41
+ fish: '# fish completion for the seam command.',
42
+ zsh: '#compdef seam',
43
+ };
32
44
  const stubHeader = (shell) => `# ${shell} completion loader for the seam command.
33
45
  #
34
46
  # Generated by @seamapi/cli. Loads completions from the CLI on first use, so
@@ -40,7 +52,12 @@ const stubs = {
40
52
  # Install to /usr/share/bash-completion/completions/seam
41
53
 
42
54
  if command -v seam > /dev/null 2>&1; then
43
- eval "$(seam completion bash 2> /dev/null)"
55
+ __seam_completion_script="$(seam completion bash 2> /dev/null)"
56
+ # Evaluate only a completion script, never anything else the CLI printed.
57
+ case "$__seam_completion_script" in
58
+ '${completionScriptSentinels.bash}'*) eval "$__seam_completion_script" ;;
59
+ esac
60
+ unset __seam_completion_script
44
61
  fi
45
62
  `,
46
63
  fish: `${stubHeader('fish')}
@@ -48,7 +65,11 @@ fi
48
65
  # Install to /usr/share/fish/vendor_completions.d/seam.fish
49
66
 
50
67
  if command --query seam
51
- seam completion fish 2> /dev/null | source
68
+ set -l __seam_completion_script (seam completion fish 2> /dev/null | string collect)
69
+ # Source only a completion script, never anything else the CLI printed.
70
+ if string match --quiet '${completionScriptSentinels.fish}*' -- $__seam_completion_script
71
+ printf '%s\\n' $__seam_completion_script | source
72
+ end
52
73
  end
53
74
  `,
54
75
  zsh: `#compdef seam
@@ -56,10 +77,16 @@ ${stubHeader('zsh')}
56
77
  #
57
78
  # Install to a directory in fpath as _seam
58
79
 
59
- # The generated script ends by dispatching on funcstack, so evaluating it
60
- # while this autoloaded _seam runs both redefines _seam and completes the
61
- # in-flight request.
62
- eval "$(seam completion zsh 2> /dev/null)"
80
+ local __seam_completion_script
81
+ __seam_completion_script="$(seam completion zsh 2> /dev/null)"
82
+
83
+ # Evaluate only a completion script, never anything else the CLI printed.
84
+ # The script ends by dispatching on funcstack, so evaluating it while this
85
+ # autoloaded _seam runs both redefines _seam and completes the in-flight
86
+ # request.
87
+ if [[ "$__seam_completion_script" == '${completionScriptSentinels.zsh}'* ]]; then
88
+ eval "$__seam_completion_script"
89
+ fi
63
90
  `,
64
91
  };
65
92
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/completion/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAU,CAAA;AAIhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAA4B,EAAE,CAC5E,gBAAgB,CAAC,QAAQ,CAAC,KAAwB,CAAC,CAAA;AAErD,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAoC;IAClE,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,UAAU;CAChB,CAAA;AAED,MAAM,SAAS,GAA2D;IACxE,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,GAA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AAU;CAChB,CAAA;AAED,MAAM,SAAS,GAA2D;IACxE,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,GAAG,EAAE,mBAAmB;CACzB,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAAsB,EACtB,SAAoB,EACZ,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAA;AAExD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAsB,EAAU,EAAE,CACrE,KAAK,CAAC,KAAK,CAAC,CAAA;AAEd;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAoC;IACxE,IAAI,EAAE,yCAAyC;IAC/C,IAAI,EAAE,yCAAyC;IAC/C,GAAG,EAAE,eAAe;CACrB,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAU,EAAE,CACpD,KAAK,KAAK;;;;uEAI2D,KAAK,IAAI,CAAA;AAEhF,MAAM,KAAK,GAAoC;IAC7C,IAAI,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC;;;;;;;;OAQtB,yBAAyB,CAAC,IAAI;;;;CAIpC;IACC,IAAI,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC;;;;;;;+BAOE,yBAAyB,CAAC,IAAI;;;;CAI5D;IACC,GAAG,EAAE;EACL,UAAU,CAAC,KAAK,CAAC;;;;;;;;;;;wCAWqB,yBAAyB,CAAC,GAAG;;;CAGpE;CACA,CAAA"}
package/lib/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const seamapiCliVersion = "0.12.0";
1
+ declare const seamapiCliVersion = "0.13.0";
2
2
  declare const seamapiBlueprintVersion = "1.2.0";
3
3
  export { seamapiBlueprintVersion };
4
4
  export default seamapiCliVersion;
package/lib/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Versions are replaced with generated values when the package is packed.
2
- const seamapiCliVersion = '0.12.0';
2
+ const seamapiCliVersion = '0.13.0';
3
3
  const seamapiBlueprintVersion = '1.2.0';
4
4
  export { seamapiBlueprintVersion };
5
5
  export default seamapiCliVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamapi/cli",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "A command line interface (CLI) for interacting with the Seam API.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -40,11 +40,24 @@ export const renderCompletion = (
40
40
  * at first completion, never at shell startup.
41
41
  *
42
42
  * The loader degrades to no completions when the seam command is missing or
43
- * cannot produce a script, e.g., offline before the definitions are cached.
43
+ * does not produce a completion script: a script is only evaluated when it
44
+ * starts with the exact first line 'seam completion' generates, so nothing
45
+ * else the CLI may print, e.g., 'Not logged in' from a version without the
46
+ * completion command, is ever evaluated as shell code.
44
47
  */
45
48
  export const renderCompletionStub = (shell: CompletionShell): string =>
46
49
  stubs[shell]
47
50
 
51
+ /**
52
+ * First line of each generated completion script, which the loaders require
53
+ * before evaluating one. Must match the output of {@link renderCompletion}.
54
+ */
55
+ export const completionScriptSentinels: Record<CompletionShell, string> = {
56
+ bash: '# bash completion for the seam command.',
57
+ fish: '# fish completion for the seam command.',
58
+ zsh: '#compdef seam',
59
+ }
60
+
48
61
  const stubHeader = (shell: CompletionShell): string =>
49
62
  `# ${shell} completion loader for the seam command.
50
63
  #
@@ -58,7 +71,12 @@ const stubs: Record<CompletionShell, string> = {
58
71
  # Install to /usr/share/bash-completion/completions/seam
59
72
 
60
73
  if command -v seam > /dev/null 2>&1; then
61
- eval "$(seam completion bash 2> /dev/null)"
74
+ __seam_completion_script="$(seam completion bash 2> /dev/null)"
75
+ # Evaluate only a completion script, never anything else the CLI printed.
76
+ case "$__seam_completion_script" in
77
+ '${completionScriptSentinels.bash}'*) eval "$__seam_completion_script" ;;
78
+ esac
79
+ unset __seam_completion_script
62
80
  fi
63
81
  `,
64
82
  fish: `${stubHeader('fish')}
@@ -66,7 +84,11 @@ fi
66
84
  # Install to /usr/share/fish/vendor_completions.d/seam.fish
67
85
 
68
86
  if command --query seam
69
- seam completion fish 2> /dev/null | source
87
+ set -l __seam_completion_script (seam completion fish 2> /dev/null | string collect)
88
+ # Source only a completion script, never anything else the CLI printed.
89
+ if string match --quiet '${completionScriptSentinels.fish}*' -- $__seam_completion_script
90
+ printf '%s\\n' $__seam_completion_script | source
91
+ end
70
92
  end
71
93
  `,
72
94
  zsh: `#compdef seam
@@ -74,9 +96,15 @@ ${stubHeader('zsh')}
74
96
  #
75
97
  # Install to a directory in fpath as _seam
76
98
 
77
- # The generated script ends by dispatching on funcstack, so evaluating it
78
- # while this autoloaded _seam runs both redefines _seam and completes the
79
- # in-flight request.
80
- eval "$(seam completion zsh 2> /dev/null)"
99
+ local __seam_completion_script
100
+ __seam_completion_script="$(seam completion zsh 2> /dev/null)"
101
+
102
+ # Evaluate only a completion script, never anything else the CLI printed.
103
+ # The script ends by dispatching on funcstack, so evaluating it while this
104
+ # autoloaded _seam runs both redefines _seam and completes the in-flight
105
+ # request.
106
+ if [[ "$__seam_completion_script" == '${completionScriptSentinels.zsh}'* ]]; then
107
+ eval "$__seam_completion_script"
108
+ fi
81
109
  `,
82
110
  }
@@ -1,5 +1,5 @@
1
1
  // Versions are replaced with generated values when the package is packed.
2
- const seamapiCliVersion = '0.12.0'
2
+ const seamapiCliVersion = '0.13.0'
3
3
  const seamapiBlueprintVersion = '1.2.0'
4
4
 
5
5
  export { seamapiBlueprintVersion }