shopify-cli 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/docs/_config.yml +3 -0
  4. data/docs/_data/nav.yml +9 -0
  5. data/docs/getting-started/index.md +5 -40
  6. data/docs/getting-started/install/index.md +39 -0
  7. data/docs/getting-started/migrate/index.md +63 -0
  8. data/docs/getting-started/uninstall/index.md +37 -0
  9. data/docs/getting-started/upgrade/index.md +37 -0
  10. data/docs/index.md +5 -6
  11. data/lib/project_types/extension/cli.rb +2 -1
  12. data/lib/project_types/extension/commands/tunnel.rb +1 -1
  13. data/lib/project_types/extension/forms/register.rb +2 -3
  14. data/lib/project_types/extension/graphql/get_app_by_api_key.graphql +9 -0
  15. data/lib/project_types/extension/tasks/converters/app_converter.rb +27 -0
  16. data/lib/project_types/extension/tasks/get_app.rb +22 -0
  17. data/lib/project_types/extension/tasks/get_apps.rb +1 -6
  18. data/lib/project_types/script/cli.rb +3 -2
  19. data/lib/project_types/script/commands/create.rb +5 -4
  20. data/lib/project_types/script/errors.rb +1 -0
  21. data/lib/project_types/script/forms/create.rb +8 -4
  22. data/lib/project_types/script/layers/application/create_script.rb +11 -18
  23. data/lib/project_types/script/layers/application/project_dependencies.rb +0 -5
  24. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +106 -0
  25. data/lib/project_types/script/layers/infrastructure/errors.rb +1 -1
  26. data/lib/project_types/script/layers/infrastructure/project_creator.rb +23 -0
  27. data/lib/project_types/script/layers/infrastructure/script_repository.rb +0 -33
  28. data/lib/project_types/script/messages/messages.rb +5 -6
  29. data/lib/project_types/script/templates/ts/as-pect.d.ts +1 -0
  30. data/lib/project_types/script/ui/error_handler.rb +5 -0
  31. data/lib/shopify-cli/tunnel.rb +33 -1
  32. data/lib/shopify-cli/version.rb +1 -1
  33. data/vendor/deps/cli-ui/REVISION +1 -1
  34. data/vendor/deps/cli-ui/lib/cli/ui.rb +52 -11
  35. data/vendor/deps/cli-ui/lib/cli/ui/color.rb +11 -7
  36. data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +34 -21
  37. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +107 -149
  38. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +99 -0
  39. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +119 -0
  40. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +158 -0
  41. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +112 -0
  42. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +9 -15
  43. data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +47 -0
  44. data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +9 -7
  45. data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +39 -14
  46. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +62 -44
  47. data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +7 -2
  48. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +23 -3
  49. data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +34 -10
  50. data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +12 -7
  51. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +26 -16
  52. data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +3 -3
  53. data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +75 -0
  54. data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +27 -0
  55. data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +61 -0
  56. metadata +20 -7
  57. data/lib/project_types/extension/features/tunnel_url.rb +0 -20
  58. data/lib/project_types/script/layers/infrastructure/assemblyscript_dependency_manager.rb +0 -51
  59. data/lib/project_types/script/layers/infrastructure/dependency_manager.rb +0 -36
  60. data/lib/project_types/script/layers/infrastructure/test_suite_repository.rb +0 -62
  61. data/vendor/deps/cli-ui/lib/cli/ui/box.rb +0 -15
@@ -0,0 +1,99 @@
1
+ module CLI
2
+ module UI
3
+ module Frame
4
+ module FrameStack
5
+ COLOR_ENVVAR = 'CLI_FRAME_STACK'
6
+ STYLE_ENVVAR = 'CLI_STYLE_STACK'
7
+
8
+ StackItem = Struct.new(:color_name, :style_name) do
9
+ def color
10
+ @color ||= CLI::UI.resolve_color(color_name)
11
+ end
12
+
13
+ def frame_style
14
+ @frame_style ||= CLI::UI.resolve_style(style_name)
15
+ end
16
+ end
17
+
18
+ class << self
19
+ # Fetch all items off the frame stack
20
+ def items
21
+ colors = ENV.fetch(COLOR_ENVVAR, '').split(':').map(&:to_sym)
22
+ styles = ENV.fetch(STYLE_ENVVAR, '').split(':').map(&:to_sym)
23
+
24
+ colors.length.times.map do |i|
25
+ StackItem.new(colors[i], styles[i] || Frame.frame_style)
26
+ end
27
+ end
28
+
29
+ # Push a new item onto the frame stack.
30
+ #
31
+ # Either an item or a :color/:style pair should be pushed onto the stack.
32
+ #
33
+ # ==== Attributes
34
+ #
35
+ # * +item+ a +StackItem+ to push onto the stack. Defaults to nil
36
+ #
37
+ # ==== Options
38
+ #
39
+ # * +:color+ the color of the new stack item. Defaults to nil
40
+ # * +:style+ the style of the new stack item. Defaults to nil
41
+ #
42
+ # ==== Raises
43
+ #
44
+ # If both an item and a color/style pair are given, raises an +ArgumentError+
45
+ # If the given item is not a +StackItem+, raises an +ArgumentError+
46
+ #
47
+ def push(item = nil, color: nil, style: nil)
48
+ unless item.nil?
49
+ unless item.is_a?(StackItem)
50
+ raise ArgumentError, "item must be a StackItem"
51
+ end
52
+
53
+ unless color.nil? && style.nil?
54
+ raise ArgumentError, "Must give one of item or color: and style:"
55
+ end
56
+ end
57
+
58
+ item ||= StackItem.new(color.name, style.name)
59
+
60
+ curr = items
61
+ curr << item
62
+
63
+ serialize(curr)
64
+ end
65
+
66
+ # Removes and returns the last stack item off the stack
67
+ def pop
68
+ curr = items
69
+ ret = curr.pop
70
+
71
+ serialize(curr)
72
+
73
+ ret.nil? ? nil : ret
74
+ end
75
+
76
+ private
77
+
78
+ # Serializes the item stack into two ENV variables.
79
+ #
80
+ # This is done to preserve backward compatibility with earlier versions of cli/ui.
81
+ # This ensures that any code that relied upon previous stack behavior should continue
82
+ # to work.
83
+ def serialize(items)
84
+ colors = []
85
+ styles = []
86
+
87
+ items.each do |item|
88
+ colors << item.color_name
89
+ styles << item.style_name
90
+ end
91
+
92
+ ENV[COLOR_ENVVAR] = colors.join(':')
93
+ ENV[STYLE_ENVVAR] = styles.join(':')
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,119 @@
1
+ require 'cli/ui/frame'
2
+
3
+ module CLI
4
+ module UI
5
+ module Frame
6
+ module FrameStyle
7
+ class << self
8
+ # rubocop:disable Style/ClassVars
9
+ @@loaded_styles = []
10
+
11
+ def loaded_styles
12
+ @@loaded_styles.map(&:name)
13
+ end
14
+
15
+ # Lookup a frame style via its name
16
+ #
17
+ # ==== Attributes
18
+ #
19
+ # * +symbol+ - frame style name to lookup
20
+ def lookup(name)
21
+ @@loaded_styles
22
+ .find { |style| style.name.to_sym == name }
23
+ .tap { |style| raise InvalidFrameStyleName, name if style.nil? }
24
+ end
25
+
26
+ def extended(base)
27
+ @@loaded_styles << base
28
+ base.extend(Interface)
29
+ end
30
+ # rubocop:enable Style/ClassVars
31
+ end
32
+
33
+ class InvalidFrameStyleName < ArgumentError
34
+ def initialize(name)
35
+ @name = name
36
+ end
37
+
38
+ def message
39
+ keys = FrameStyle.loaded_styles.map(&:inspect).join(',')
40
+ "invalid frame style: #{@name.inspect}" \
41
+ "-- must be one of CLI::UI::Frame::FrameStyle.loaded_styles " \
42
+ "(#{keys})"
43
+ end
44
+ end
45
+
46
+ # Public interface for FrameStyles
47
+ # Applied by extending FrameStyle
48
+ module Interface
49
+ def name
50
+ raise NotImplementedError
51
+ end
52
+
53
+ # Returns the character(s) that should be printed at the beginning
54
+ # of lines inside this frame
55
+ def prefix
56
+ raise NotImplementedError
57
+ end
58
+
59
+ # Returns the printing width of the prefix
60
+ def prefix_width
61
+ CLI::UI::ANSI.printing_width(prefix)
62
+ end
63
+
64
+ # Draws the "Open" line for this frame style
65
+ #
66
+ # ==== Attributes
67
+ #
68
+ # * +text+ - (required) the text/title to output in the frame
69
+ #
70
+ # ==== Options
71
+ #
72
+ # * +:color+ - (required) The color of the frame.
73
+ #
74
+ def open(text, color:)
75
+ raise NotImplementedError
76
+ end
77
+
78
+ # Draws the "Close" line for this frame style
79
+ #
80
+ # ==== Attributes
81
+ #
82
+ # * +text+ - (required) the text/title to output in the frame
83
+ #
84
+ # ==== Options
85
+ #
86
+ # * +:color+ - (required) The color of the frame.
87
+ # * +:right_text+ - Text to print at the right of the line. Defaults to nil
88
+ #
89
+ def close(text, color:, right_text: nil)
90
+ raise NotImplementedError
91
+ end
92
+
93
+ # Draws a "divider" line for the current frame style
94
+ #
95
+ # ==== Attributes
96
+ #
97
+ # * +text+ - (required) the text/title to output in the frame
98
+ #
99
+ # ==== Options
100
+ #
101
+ # * +:color+ - (required) The color of the frame.
102
+ #
103
+ def divider(text, color: nil)
104
+ raise NotImplementedError
105
+ end
106
+
107
+ private
108
+
109
+ def print_at_x(x, str)
110
+ CLI::UI::ANSI.cursor_horizontal_absolute(1 + x) + str
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+
118
+ require 'cli/ui/frame/frame_style/box'
119
+ require 'cli/ui/frame/frame_style/bracket'
@@ -0,0 +1,158 @@
1
+ module CLI
2
+ module UI
3
+ module Frame
4
+ module FrameStyle
5
+ module Box
6
+ extend FrameStyle
7
+
8
+ VERTICAL = '┃'
9
+ HORIZONTAL = '━'
10
+ DIVIDER = '┣'
11
+ TOP_LEFT = '┏'
12
+ BOTTOM_LEFT = '┗'
13
+
14
+ class << self
15
+ def name
16
+ 'box'
17
+ end
18
+
19
+ def prefix
20
+ VERTICAL
21
+ end
22
+
23
+ def prefix_width
24
+ CLI::UI::ANSI.printing_width(prefix)
25
+ end
26
+
27
+ # Draws the "Open" line for this frame style
28
+ #
29
+ # ==== Attributes
30
+ #
31
+ # * +text+ - (required) the text/title to output in the frame
32
+ #
33
+ # ==== Options
34
+ #
35
+ # * +:color+ - (required) The color of the frame.
36
+ #
37
+ # ==== Output:
38
+ #
39
+ # ┏━━ Open ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
40
+ #
41
+ def open(text, color:)
42
+ edge(text, color: color, first: TOP_LEFT)
43
+ end
44
+
45
+ # Draws a "divider" line for the current frame style
46
+ #
47
+ # ==== Attributes
48
+ #
49
+ # * +text+ - (required) the text/title to output in the frame
50
+ #
51
+ # ==== Options
52
+ #
53
+ # * +:color+ - (required) The color of the frame.
54
+ #
55
+ # ==== Output:
56
+ #
57
+ # ┣━━ Divider ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
58
+ #
59
+ def divider(text, color:)
60
+ edge(text, color: color, first: DIVIDER)
61
+ end
62
+
63
+ # Draws the "Close" line for this frame style
64
+ #
65
+ # ==== Attributes
66
+ #
67
+ # * +text+ - (required) the text/title to output in the frame
68
+ #
69
+ # ==== Options
70
+ #
71
+ # * +:color+ - (required) The color of the frame.
72
+ # * +:right_text+ - Text to print at the right of the line. Defaults to nil
73
+ #
74
+ # ==== Output:
75
+ #
76
+ # ┗━━ Close ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
77
+ #
78
+ def close(text, color:, right_text: nil)
79
+ edge(text, color: color, right_text: right_text, first: BOTTOM_LEFT)
80
+ end
81
+
82
+ private
83
+
84
+ def edge(text, color:, first:, right_text: nil)
85
+ color = CLI::UI.resolve_color(color)
86
+
87
+ preamble = +''
88
+
89
+ preamble << color.code << first << (HORIZONTAL * 2)
90
+
91
+ text ||= ''
92
+ unless text.empty?
93
+ preamble << ' ' << CLI::UI.resolve_text("{{#{color.name}:#{text}}}") << ' '
94
+ end
95
+
96
+ termwidth = CLI::UI::Terminal.width
97
+
98
+ suffix = +''
99
+
100
+ if right_text
101
+ suffix << ' ' << right_text << ' '
102
+ end
103
+
104
+ preamble_width = CLI::UI::ANSI.printing_width(preamble)
105
+ preamble_start = Frame.prefix_width
106
+ preamble_end = preamble_start + preamble_width
107
+
108
+ suffix_width = CLI::UI::ANSI.printing_width(suffix)
109
+ suffix_end = termwidth - 2
110
+ suffix_start = suffix_end - suffix_width
111
+
112
+ if preamble_end > suffix_start
113
+ suffix = ''
114
+ # if preamble_end > termwidth
115
+ # we *could* truncate it, but let's just let it overflow to the
116
+ # next line and call it poor usage of this API.
117
+ end
118
+
119
+ o = +''
120
+
121
+ # Shopify's CI system supports terminal emulation, but not some of
122
+ # the fancier features that we normally use to draw frames
123
+ # extra-reliably, so we fall back to a less foolproof strategy. This
124
+ # is probably better in general for cases with impoverished terminal
125
+ # emulators and no active user.
126
+ unless [0, '', nil].include?(ENV['CI'])
127
+ linewidth = [0, termwidth - (preamble_end + suffix_width + 1)].max
128
+
129
+ o << color.code << preamble
130
+ o << color.code << (HORIZONTAL * linewidth)
131
+ o << color.code << suffix
132
+ o << CLI::UI::Color::RESET.code << "\n"
133
+ return o
134
+ end
135
+
136
+ # Jumping around the line can cause some unwanted flashes
137
+ o << CLI::UI::ANSI.hide_cursor
138
+
139
+ # reset to column 1 so that things like ^C don't ruin formatting
140
+ o << "\r"
141
+
142
+ o << color.code
143
+ o << print_at_x(preamble_start, HORIZONTAL * (termwidth - preamble_start)) # draw a full line
144
+ o << print_at_x(preamble_start, preamble)
145
+ o << color.code
146
+ o << print_at_x(suffix_start, suffix)
147
+ o << CLI::UI::Color::RESET.code
148
+ o << CLI::UI::ANSI.show_cursor
149
+ o << "\n"
150
+
151
+ o
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,112 @@
1
+ module CLI
2
+ module UI
3
+ module Frame
4
+ module FrameStyle
5
+ module Bracket
6
+ extend FrameStyle
7
+
8
+ VERTICAL = '┃'
9
+ HORIZONTAL = '━'
10
+ DIVIDER = '┣'
11
+ TOP_LEFT = '┏'
12
+ BOTTOM_LEFT = '┗'
13
+
14
+ class << self
15
+ def name
16
+ 'bracket'
17
+ end
18
+
19
+ def prefix
20
+ VERTICAL
21
+ end
22
+
23
+ # Draws the "Open" line for this frame style
24
+ #
25
+ # ==== Attributes
26
+ #
27
+ # * +text+ - (required) the text/title to output in the frame
28
+ #
29
+ # ==== Options
30
+ #
31
+ # * +:color+ - (required) The color of the frame.
32
+ #
33
+ # ==== Output
34
+ #
35
+ # ┏━━ Open
36
+ #
37
+ def open(text, color:)
38
+ edge(text, color: color, first: TOP_LEFT)
39
+ end
40
+
41
+ # Draws a "divider" line for the current frame style
42
+ #
43
+ # ==== Attributes
44
+ #
45
+ # * +text+ - (required) the text/title to output in the frame
46
+ #
47
+ # ==== Options
48
+ #
49
+ # * +:color+ - (required) The color of the frame.
50
+ #
51
+ # ==== Output:
52
+ #
53
+ # ┣━━ Divider
54
+ #
55
+ def divider(text, color:)
56
+ edge(text, color: color, first: DIVIDER)
57
+ end
58
+
59
+ # Draws the "Close" line for this frame style
60
+ #
61
+ # ==== Attributes
62
+ #
63
+ # * +text+ - (required) the text/title to output in the frame
64
+ #
65
+ # ==== Options
66
+ #
67
+ # * +:color+ - (required) The color of the frame.
68
+ # * +:right_text+ - Text to print at the right of the line. Defaults to nil
69
+ #
70
+ # ==== Output:
71
+ #
72
+ # ┗━━ Close
73
+ #
74
+ def close(text, color:, right_text: nil)
75
+ edge(text, color: color, right_text: right_text, first: BOTTOM_LEFT)
76
+ end
77
+
78
+ private
79
+
80
+ def edge(text, color:, first:, right_text: nil)
81
+ color = CLI::UI.resolve_color(color)
82
+
83
+ preamble = +''
84
+
85
+ preamble << color.code << first << (HORIZONTAL * 2)
86
+
87
+ text ||= ''
88
+ unless text.empty?
89
+ preamble << ' ' << CLI::UI.resolve_text("{{#{color.name}:#{text}}}") << ' '
90
+ end
91
+
92
+ suffix = +''
93
+
94
+ if right_text
95
+ suffix << ' ' << right_text << ' '
96
+ end
97
+
98
+ o = +''
99
+
100
+ o << color.code << preamble
101
+ o << color.code << suffix
102
+ o << CLI::UI::Color::RESET.code
103
+ o << "\n"
104
+
105
+ o
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end