@shipstatic/ship 0.1.8 → 0.1.10

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.
@@ -13,17 +13,94 @@ _ship_completions() {
13
13
  return
14
14
  fi
15
15
 
16
+ # Context-aware completions based on command structure
17
+ case "${COMP_WORDS[1]}" in
18
+ "deployments")
19
+ case "${COMP_WORDS[2]}" in
20
+ "create")
21
+ # File/directory completion for deploy path
22
+ COMPREPLY=( $(compgen -f -- "${current_word}") )
23
+ return
24
+ ;;
25
+ "get"|"remove")
26
+ if [[ ${COMP_CWORD} -eq 3 ]]; then
27
+ # Would ideally complete deployment IDs from API, but keep simple for now
28
+ COMPREPLY=()
29
+ return
30
+ fi
31
+ ;;
32
+ *)
33
+ if [[ ${COMP_CWORD} -eq 2 ]]; then
34
+ completions="list create get remove"
35
+ COMPREPLY=( $(compgen -W "${completions}" -- "${current_word}") )
36
+ return
37
+ fi
38
+ ;;
39
+ esac
40
+ ;;
41
+ "aliases")
42
+ case "${COMP_WORDS[2]}" in
43
+ "set")
44
+ if [[ ${COMP_CWORD} -eq 4 ]]; then
45
+ # Would ideally complete deployment IDs, but keep simple
46
+ COMPREPLY=()
47
+ return
48
+ fi
49
+ ;;
50
+ "get"|"remove")
51
+ if [[ ${COMP_CWORD} -eq 3 ]]; then
52
+ # Would ideally complete alias names, but keep simple
53
+ COMPREPLY=()
54
+ return
55
+ fi
56
+ ;;
57
+ *)
58
+ if [[ ${COMP_CWORD} -eq 2 ]]; then
59
+ completions="list get set remove"
60
+ COMPREPLY=( $(compgen -W "${completions}" -- "${current_word}") )
61
+ return
62
+ fi
63
+ ;;
64
+ esac
65
+ ;;
66
+ "account")
67
+ if [[ ${COMP_CWORD} -eq 2 ]]; then
68
+ completions="get"
69
+ COMPREPLY=( $(compgen -W "${completions}" -- "${current_word}") )
70
+ return
71
+ fi
72
+ ;;
73
+ "completion")
74
+ if [[ ${COMP_CWORD} -eq 2 ]]; then
75
+ completions="install uninstall"
76
+ COMPREPLY=( $(compgen -W "${completions}" -- "${current_word}") )
77
+ return
78
+ fi
79
+ ;;
80
+ esac
81
+
16
82
  # Delegate for commands that expect files, like 'create'
17
- if [[ "$prev_word" == "create" || "$prev_word" == "--config" || "$prev_word" == "-c" ]]; then
83
+ if [[ "$prev_word" == "create" || "$prev_word" == "--config" ]]; then
18
84
  COMPREPLY=( $(compgen -f -- "${current_word}") )
19
85
  return
20
86
  fi
21
87
 
22
- # Get static completions from CLI
23
- completions=$(ship --compbash 2>/dev/null)
24
-
25
- # Filter completions based on the current word and reply
26
- COMPREPLY=( $(compgen -W "${completions}" -- "${current_word}") )
88
+ # Flag completion
89
+ if [[ "$current_word" == --* ]]; then
90
+ completions="--api-key --config --api-url --preserve-dirs --json --no-color --version --help"
91
+ COMPREPLY=( $(compgen -W "${completions}" -- "${current_word}") )
92
+ return
93
+ fi
94
+
95
+ # Top-level commands
96
+ if [[ ${COMP_CWORD} -eq 1 ]]; then
97
+ completions="ping whoami deployments aliases account completion"
98
+ COMPREPLY=( $(compgen -W "${completions}" -- "${current_word}") )
99
+ return
100
+ fi
101
+
102
+ # Default: no completions
103
+ COMPREPLY=()
27
104
  }
28
105
 
29
106
  # Register the completion function for the 'ship' command
@@ -1,10 +1,9 @@
1
- # ship.fish
1
+ # ship.fish - Tab completion for Ship CLI
2
2
 
3
- # Don't complete if it looks like a path
3
+ # Helper function to check if we're completing a path
4
4
  function __ship_is_path
5
5
  set -l cmd (commandline -opc)
6
6
  if test (count $cmd) -gt 1
7
- # The last token will be what we are completing
8
7
  set -l last_token $cmd[-1]
9
8
  if string match -q -- "*/*" "$last_token"
10
9
  return 0
@@ -19,6 +18,56 @@ function __ship_is_path
19
18
  return 1
20
19
  end
21
20
 
22
- # Command completion by calling the CLI
23
- complete -c ship -n '__fish_use_subcommand' -a '(ship --compfish --compgen (commandline -b) 2>/dev/null)'
24
- complete -c ship -n 'not __ship_is_path' -a '(ship --compfish --compgen (commandline -b) 2>/dev/null)'
21
+ # Helper function to check if we should complete files for certain commands
22
+ function __ship_needs_file
23
+ set -l cmd (commandline -opc)
24
+ if test (count $cmd) -ge 2
25
+ set -l prev $cmd[-1]
26
+ if test "$prev" = "create" -o "$prev" = "--config"
27
+ return 0
28
+ end
29
+ end
30
+ return 1
31
+ end
32
+
33
+ # Top-level commands
34
+ complete -c ship -f -n '__fish_use_subcommand' -a 'ping' -d 'Check API connectivity'
35
+ complete -c ship -f -n '__fish_use_subcommand' -a 'whoami' -d 'Get current account information'
36
+ complete -c ship -f -n '__fish_use_subcommand' -a 'deployments' -d 'Manage deployments'
37
+ complete -c ship -f -n '__fish_use_subcommand' -a 'aliases' -d 'Manage aliases'
38
+ complete -c ship -f -n '__fish_use_subcommand' -a 'account' -d 'Manage account'
39
+ complete -c ship -f -n '__fish_use_subcommand' -a 'completion' -d 'Setup shell completion'
40
+
41
+ # Global options
42
+ complete -c ship -l api-key -d 'API key for authentication' -x
43
+ complete -c ship -l config -d 'Custom config file path' -r
44
+ complete -c ship -l api-url -d 'API URL (for development)' -x
45
+ complete -c ship -l json -d 'Output results in JSON format'
46
+ complete -c ship -l no-color -d 'Disable colored output'
47
+ complete -c ship -l version -d 'Show version information'
48
+ complete -c ship -l help -d 'Display help for command'
49
+
50
+ # Deployments subcommands
51
+ complete -c ship -f -n '__fish_seen_subcommand_from deployments' -a 'list' -d 'List all deployments'
52
+ complete -c ship -f -n '__fish_seen_subcommand_from deployments' -a 'create' -d 'Create deployment from file or directory'
53
+ complete -c ship -f -n '__fish_seen_subcommand_from deployments' -a 'get' -d 'Show deployment information'
54
+ complete -c ship -f -n '__fish_seen_subcommand_from deployments' -a 'remove' -d 'Delete deployment permanently'
55
+
56
+ # Deployments create options
57
+ complete -c ship -l preserve-dirs -n '__fish_seen_subcommand_from deployments; and __fish_seen_subcommand_from create' -d 'Preserve directory structure in deployment'
58
+
59
+ # Aliases subcommands
60
+ complete -c ship -f -n '__fish_seen_subcommand_from aliases' -a 'list' -d 'List all aliases'
61
+ complete -c ship -f -n '__fish_seen_subcommand_from aliases' -a 'get' -d 'Show alias information'
62
+ complete -c ship -f -n '__fish_seen_subcommand_from aliases' -a 'set' -d 'Create or update alias pointing to deployment'
63
+ complete -c ship -f -n '__fish_seen_subcommand_from aliases' -a 'remove' -d 'Delete alias permanently'
64
+
65
+ # Account subcommands
66
+ complete -c ship -f -n '__fish_seen_subcommand_from account' -a 'get' -d 'Show account information'
67
+
68
+ # Completion subcommands
69
+ complete -c ship -f -n '__fish_seen_subcommand_from completion' -a 'install' -d 'Install shell completion script'
70
+ complete -c ship -f -n '__fish_seen_subcommand_from completion' -a 'uninstall' -d 'Uninstall shell completion script'
71
+
72
+ # File completion for appropriate commands (only when not a path is being typed)
73
+ complete -c ship -F -n '__ship_needs_file and not __ship_is_path'
@@ -23,20 +23,91 @@ if [[ -n ${ZSH_VERSION-} ]]; then
23
23
  return
24
24
  fi
25
25
 
26
+ # Context-aware completions based on command structure
27
+ case "${words[2]}" in
28
+ "deployments")
29
+ case "${words[3]}" in
30
+ "create")
31
+ # File/directory completion for deploy path
32
+ _files
33
+ return
34
+ ;;
35
+ "get"|"remove")
36
+ if [[ $CURRENT -eq 4 ]]; then
37
+ # Would ideally complete deployment IDs from API, but keep simple for now
38
+ return
39
+ fi
40
+ ;;
41
+ *)
42
+ if [[ $CURRENT -eq 3 ]]; then
43
+ completions=("list:List all deployments" "create:Create deployment from file or directory" "get:Show deployment information" "remove:Delete deployment permanently")
44
+ _describe 'deployments commands' completions
45
+ return
46
+ fi
47
+ ;;
48
+ esac
49
+ ;;
50
+ "aliases")
51
+ case "${words[3]}" in
52
+ "set")
53
+ if [[ $CURRENT -eq 5 ]]; then
54
+ # Would ideally complete deployment IDs, but keep simple
55
+ return
56
+ fi
57
+ ;;
58
+ "get"|"remove")
59
+ if [[ $CURRENT -eq 4 ]]; then
60
+ # Would ideally complete alias names, but keep simple
61
+ return
62
+ fi
63
+ ;;
64
+ *)
65
+ if [[ $CURRENT -eq 3 ]]; then
66
+ completions=("list:List all aliases" "get:Show alias information" "set:Create or update alias pointing to deployment" "remove:Delete alias permanently")
67
+ _describe 'aliases commands' completions
68
+ return
69
+ fi
70
+ ;;
71
+ esac
72
+ ;;
73
+ "account")
74
+ if [[ $CURRENT -eq 3 ]]; then
75
+ completions=("get:Show account information")
76
+ _describe 'account commands' completions
77
+ return
78
+ fi
79
+ ;;
80
+ "completion")
81
+ if [[ $CURRENT -eq 3 ]]; then
82
+ completions=("install:Install shell completion script" "uninstall:Uninstall shell completion script")
83
+ _describe 'completion commands' completions
84
+ return
85
+ fi
86
+ ;;
87
+ esac
88
+
26
89
  # If the previous command expects a file path, also use file completion.
27
- if [[ "$prev_word" == "create" || "$prev_word" == "--config" || "$prev_word" == "-c" ]]; then
90
+ if [[ "$prev_word" == "create" || "$prev_word" == "--config" ]]; then
28
91
  _files
29
92
  return
30
93
  fi
31
94
 
32
- # --- Command Completion Logic ---
33
- # If we're not completing a path, call our Node.js script for command suggestions.
34
- # We pass the full command line and cursor position to our script for context.
35
- completions=($(ship --compzsh --compgen="${BUFFER}" --compword="${CURRENT}" 2>/dev/null))
95
+ # Flag completion
96
+ if [[ "$current_word" == --* ]]; then
97
+ completions=("--api-key:API key for authentication" "--config:Custom config file path" "--api-url:API URL (for development)" "--preserve-dirs:Preserve directory structure in deployment" "--json:Output results in JSON format" "--no-color:Disable colored output" "--version:Show version information" "--help:Display help for command")
98
+ _describe 'options' completions
99
+ return
100
+ fi
36
101
 
37
- if [[ ${#completions[@]} -gt 0 ]]; then
102
+ # Top-level commands
103
+ if [[ $CURRENT -eq 2 ]]; then
104
+ completions=("ping:Check API connectivity" "whoami:Get current account information" "deployments:Manage deployments" "aliases:Manage aliases" "account:Manage account" "completion:Setup shell completion")
38
105
  _describe 'commands' completions
106
+ return
39
107
  fi
108
+
109
+ # Default: no completions
110
+ return 1
40
111
  }
41
112
 
42
113
  # Only register the completion if compdef is available
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/ship",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "SDK & CLI for Shipstatic platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -49,7 +49,7 @@
49
49
  "author": "ShipStatic",
50
50
  "license": "MIT",
51
51
  "dependencies": {
52
- "@shipstatic/types": "^0.1.9",
52
+ "@shipstatic/types": "^0.1.10",
53
53
  "columnify": "^1.6.0",
54
54
  "commander": "^12.1.0",
55
55
  "cosmiconfig": "^9.0.0",