fluid_cli 0.1.9 → 0.2.1

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.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +200 -1
  3. data/exe/fluid +12 -17
  4. data/lib/fluid_cli/version.rb +1 -1
  5. data/lib/fluid_cli.rb +4 -62
  6. metadata +14 -278
  7. data/Rakefile +0 -26
  8. data/dev.yml +0 -5
  9. data/lib/fluid_cli/api.rb +0 -141
  10. data/lib/fluid_cli/assets/post_auth_page/index.html.erb +0 -34
  11. data/lib/fluid_cli/assets/post_auth_page/style.css +0 -58
  12. data/lib/fluid_cli/command.rb +0 -55
  13. data/lib/fluid_cli/commands/help.rb +0 -21
  14. data/lib/fluid_cli/commands/login.rb +0 -30
  15. data/lib/fluid_cli/commands/logout.rb +0 -38
  16. data/lib/fluid_cli/commands/switch.rb +0 -23
  17. data/lib/fluid_cli/commands/theme/common/company_helper.rb +0 -15
  18. data/lib/fluid_cli/commands/theme/common/root_helper.rb +0 -95
  19. data/lib/fluid_cli/commands/theme/dev.rb +0 -62
  20. data/lib/fluid_cli/commands/theme/help.rb +0 -21
  21. data/lib/fluid_cli/commands/theme/init.rb +0 -46
  22. data/lib/fluid_cli/commands/theme/navigate.rb +0 -57
  23. data/lib/fluid_cli/commands/theme/pull.rb +0 -68
  24. data/lib/fluid_cli/commands/theme/push.rb +0 -132
  25. data/lib/fluid_cli/commands/theme.rb +0 -24
  26. data/lib/fluid_cli/commands/whoami.rb +0 -23
  27. data/lib/fluid_cli/commands.rb +0 -19
  28. data/lib/fluid_cli/company_switcher.rb +0 -69
  29. data/lib/fluid_cli/context.rb +0 -691
  30. data/lib/fluid_cli/db.rb +0 -114
  31. data/lib/fluid_cli/entry_point.rb +0 -10
  32. data/lib/fluid_cli/environment.rb +0 -32
  33. data/lib/fluid_cli/file_system_listener.rb +0 -29
  34. data/lib/fluid_cli/form.rb +0 -42
  35. data/lib/fluid_cli/git.rb +0 -319
  36. data/lib/fluid_cli/http_request.rb +0 -60
  37. data/lib/fluid_cli/identity_auth/servlet.rb +0 -39
  38. data/lib/fluid_cli/identity_auth.rb +0 -126
  39. data/lib/fluid_cli/options.rb +0 -38
  40. data/lib/fluid_cli/packager.rb +0 -36
  41. data/lib/fluid_cli/theme/dev_server/certificate_manager.rb +0 -79
  42. data/lib/fluid_cli/theme/dev_server/errors.rb +0 -9
  43. data/lib/fluid_cli/theme/dev_server/header_hash.rb +0 -98
  44. data/lib/fluid_cli/theme/dev_server/hooks/file_change_hook.rb +0 -39
  45. data/lib/fluid_cli/theme/dev_server/hot_reload/resources/hot-reload-no-script.html +0 -27
  46. data/lib/fluid_cli/theme/dev_server/hot_reload/resources/hot_reload.js +0 -28
  47. data/lib/fluid_cli/theme/dev_server/hot_reload/resources/sse_client.js +0 -43
  48. data/lib/fluid_cli/theme/dev_server/hot_reload/resources/theme.js +0 -16
  49. data/lib/fluid_cli/theme/dev_server/hot_reload/script_injector.rb +0 -54
  50. data/lib/fluid_cli/theme/dev_server/hot_reload.rb +0 -75
  51. data/lib/fluid_cli/theme/dev_server/local_assets.rb +0 -92
  52. data/lib/fluid_cli/theme/dev_server/proxy.rb +0 -235
  53. data/lib/fluid_cli/theme/dev_server/proxy_param_builder.rb +0 -82
  54. data/lib/fluid_cli/theme/dev_server/reload_mode.rb +0 -34
  55. data/lib/fluid_cli/theme/dev_server/sse.rb +0 -75
  56. data/lib/fluid_cli/theme/dev_server/watcher.rb +0 -57
  57. data/lib/fluid_cli/theme/dev_server/web_server.rb +0 -140
  58. data/lib/fluid_cli/theme/dev_server.rb +0 -308
  59. data/lib/fluid_cli/theme/development_theme.rb +0 -101
  60. data/lib/fluid_cli/theme/file.rb +0 -130
  61. data/lib/fluid_cli/theme/forms/select.rb +0 -33
  62. data/lib/fluid_cli/theme/mime_type.rb +0 -34
  63. data/lib/fluid_cli/theme/navigation/resource_fetcher.rb +0 -25
  64. data/lib/fluid_cli/theme/navigation/route_navigator.rb +0 -87
  65. data/lib/fluid_cli/theme/presenters/theme_presenter.rb +0 -49
  66. data/lib/fluid_cli/theme/presenters/themes_presenter.rb +0 -31
  67. data/lib/fluid_cli/theme/root.rb +0 -62
  68. data/lib/fluid_cli/theme/schema_validator.rb +0 -274
  69. data/lib/fluid_cli/theme/syncer/checksums.rb +0 -66
  70. data/lib/fluid_cli/theme/syncer/downloader.rb +0 -54
  71. data/lib/fluid_cli/theme/syncer/error_reporter.rb +0 -45
  72. data/lib/fluid_cli/theme/syncer/merger.rb +0 -53
  73. data/lib/fluid_cli/theme/syncer/operation.rb +0 -58
  74. data/lib/fluid_cli/theme/syncer/standard_reporter.rb +0 -32
  75. data/lib/fluid_cli/theme/syncer/unsupported_script_warning.rb +0 -90
  76. data/lib/fluid_cli/theme/syncer/uploader/forms/apply_to_all.rb +0 -41
  77. data/lib/fluid_cli/theme/syncer/uploader/forms/apply_to_all_form.rb +0 -37
  78. data/lib/fluid_cli/theme/syncer/uploader/forms/base_strategy_form.rb +0 -64
  79. data/lib/fluid_cli/theme/syncer/uploader/forms/select_delete_strategy.rb +0 -29
  80. data/lib/fluid_cli/theme/syncer/uploader/forms/select_update_strategy.rb +0 -30
  81. data/lib/fluid_cli/theme/syncer/uploader/json_delete_handler.rb +0 -49
  82. data/lib/fluid_cli/theme/syncer/uploader/json_update_handler.rb +0 -71
  83. data/lib/fluid_cli/theme/syncer/uploader.rb +0 -105
  84. data/lib/fluid_cli/theme/syncer.rb +0 -500
  85. data/lib/fluid_cli/theme/theme.rb +0 -186
  86. data/lib/fluid_cli/theme/ui/sync_progress_bar.rb +0 -22
  87. data/lib/fluid_cli/thread_pool/job.rb +0 -35
  88. data/lib/fluid_cli/thread_pool.rb +0 -49
  89. data/packaging/homebrew/fluid_cli.base.rb +0 -103
  90. data/vendor/deps/base64/.document +0 -5
  91. data/vendor/deps/base64/.gitignore +0 -9
  92. data/vendor/deps/base64/BSDL +0 -22
  93. data/vendor/deps/base64/COPYING +0 -56
  94. data/vendor/deps/base64/Gemfile +0 -9
  95. data/vendor/deps/base64/LEGAL +0 -60
  96. data/vendor/deps/base64/README.md +0 -48
  97. data/vendor/deps/base64/Rakefile +0 -31
  98. data/vendor/deps/base64/base64.gemspec +0 -28
  99. data/vendor/deps/base64/bin/console +0 -14
  100. data/vendor/deps/base64/bin/setup +0 -8
  101. data/vendor/deps/base64/lib/base64.rb +0 -382
  102. data/vendor/deps/base64/sig/base64.rbs +0 -358
  103. data/vendor/deps/base64/test/base64/test_base64.rb +0 -115
  104. data/vendor/deps/base64/test_sig/test_base64.rb +0 -44
  105. data/vendor/deps/cli-kit/REVISION +0 -1
  106. data/vendor/deps/cli-kit/lib/cli/kit/args/definition.rb +0 -286
  107. data/vendor/deps/cli-kit/lib/cli/kit/args/evaluation.rb +0 -215
  108. data/vendor/deps/cli-kit/lib/cli/kit/args/parser/node.rb +0 -128
  109. data/vendor/deps/cli-kit/lib/cli/kit/args/parser.rb +0 -125
  110. data/vendor/deps/cli-kit/lib/cli/kit/args/tokenizer.rb +0 -130
  111. data/vendor/deps/cli-kit/lib/cli/kit/args.rb +0 -16
  112. data/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +0 -30
  113. data/vendor/deps/cli-kit/lib/cli/kit/command_help.rb +0 -268
  114. data/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +0 -150
  115. data/vendor/deps/cli-kit/lib/cli/kit/config.rb +0 -137
  116. data/vendor/deps/cli-kit/lib/cli/kit/core_ext.rb +0 -28
  117. data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +0 -166
  118. data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +0 -92
  119. data/vendor/deps/cli-kit/lib/cli/kit/ini.rb +0 -91
  120. data/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +0 -92
  121. data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +0 -94
  122. data/vendor/deps/cli-kit/lib/cli/kit/opts.rb +0 -248
  123. data/vendor/deps/cli-kit/lib/cli/kit/parse_args.rb +0 -55
  124. data/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +0 -66
  125. data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +0 -260
  126. data/vendor/deps/cli-kit/lib/cli/kit/support.rb +0 -11
  127. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +0 -290
  128. data/vendor/deps/cli-kit/lib/cli/kit/util.rb +0 -118
  129. data/vendor/deps/cli-kit/lib/cli/kit/version.rb +0 -7
  130. data/vendor/deps/cli-kit/lib/cli/kit.rb +0 -139
  131. data/vendor/deps/cli-ui/REVISION +0 -1
  132. data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +0 -218
  133. data/vendor/deps/cli-ui/lib/cli/ui/color.rb +0 -101
  134. data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +0 -219
  135. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +0 -67
  136. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +0 -179
  137. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +0 -152
  138. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +0 -127
  139. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +0 -286
  140. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +0 -92
  141. data/vendor/deps/cli-ui/lib/cli/ui/os.rb +0 -63
  142. data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +0 -64
  143. data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +0 -132
  144. data/vendor/deps/cli-ui/lib/cli/ui/progress_reporter.rb +0 -209
  145. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +0 -583
  146. data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +0 -36
  147. data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +0 -381
  148. data/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +0 -48
  149. data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +0 -602
  150. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +0 -79
  151. data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +0 -399
  152. data/vendor/deps/cli-ui/lib/cli/ui/table.rb +0 -83
  153. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +0 -55
  154. data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +0 -106
  155. data/vendor/deps/cli-ui/lib/cli/ui/version.rb +0 -8
  156. data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +0 -46
  157. data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +0 -79
  158. data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +0 -89
  159. data/vendor/deps/cli-ui/lib/cli/ui/work_queue.rb +0 -142
  160. data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +0 -61
  161. data/vendor/deps/cli-ui/lib/cli/ui.rb +0 -359
  162. data/vendor/deps/cli-ui/vendor/reentrant_mutex.rb +0 -78
  163. data/vendor/deps/webrick/.gitignore +0 -9
  164. data/vendor/deps/webrick/Gemfile +0 -3
  165. data/vendor/deps/webrick/LICENSE.txt +0 -22
  166. data/vendor/deps/webrick/README.md +0 -61
  167. data/vendor/deps/webrick/Rakefile +0 -10
  168. data/vendor/deps/webrick/lib/webrick/accesslog.rb +0 -157
  169. data/vendor/deps/webrick/lib/webrick/cgi.rb +0 -313
  170. data/vendor/deps/webrick/lib/webrick/compat.rb +0 -36
  171. data/vendor/deps/webrick/lib/webrick/config.rb +0 -158
  172. data/vendor/deps/webrick/lib/webrick/cookie.rb +0 -172
  173. data/vendor/deps/webrick/lib/webrick/htmlutils.rb +0 -30
  174. data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +0 -117
  175. data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +0 -116
  176. data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +0 -395
  177. data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +0 -132
  178. data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +0 -97
  179. data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +0 -158
  180. data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +0 -53
  181. data/vendor/deps/webrick/lib/webrick/httpauth.rb +0 -96
  182. data/vendor/deps/webrick/lib/webrick/httpproxy.rb +0 -354
  183. data/vendor/deps/webrick/lib/webrick/httprequest.rb +0 -636
  184. data/vendor/deps/webrick/lib/webrick/httpresponse.rb +0 -564
  185. data/vendor/deps/webrick/lib/webrick/https.rb +0 -152
  186. data/vendor/deps/webrick/lib/webrick/httpserver.rb +0 -294
  187. data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +0 -152
  188. data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +0 -47
  189. data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +0 -126
  190. data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +0 -88
  191. data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +0 -552
  192. data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +0 -47
  193. data/vendor/deps/webrick/lib/webrick/httpservlet.rb +0 -23
  194. data/vendor/deps/webrick/lib/webrick/httpstatus.rb +0 -194
  195. data/vendor/deps/webrick/lib/webrick/httputils.rb +0 -512
  196. data/vendor/deps/webrick/lib/webrick/httpversion.rb +0 -76
  197. data/vendor/deps/webrick/lib/webrick/log.rb +0 -156
  198. data/vendor/deps/webrick/lib/webrick/server.rb +0 -381
  199. data/vendor/deps/webrick/lib/webrick/ssl.rb +0 -215
  200. data/vendor/deps/webrick/lib/webrick/utils.rb +0 -265
  201. data/vendor/deps/webrick/lib/webrick/version.rb +0 -18
  202. data/vendor/deps/webrick/lib/webrick.rb +0 -232
  203. data/vendor/deps/webrick/webrick.gemspec +0 -74
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "fluid_cli"
4
-
5
- module FluidCLI
6
- module Commands
7
- class Theme
8
- class Navigate < FluidCLI::Command
9
- DEFAULT_HTTP_HOST = "127.0.0.1"
10
- DEFAULT_PORT = 9292
11
-
12
- options do |parser, flags|
13
- parser.on("--host=HOST") { |host| flags[:host] = host.to_s }
14
- parser.on("--port=PORT") { |port| flags[:port] = port.to_i }
15
- parser.on("-t", "--theme=NAME_OR_ID") { |theme| flags[:theme] = theme }
16
- end
17
-
18
- def call(_args, _name)
19
- valid_authentication_method!
20
-
21
- flags = options.flags.dup
22
- host = flags[:host] || DEFAULT_HTTP_HOST
23
- port = flags[:port] || DEFAULT_PORT
24
- address = "http://#{host}:#{port}"
25
-
26
- theme_id = resolve_theme_id(flags[:theme])
27
-
28
- FluidCLI::Theme::Navigation::RouteNavigator.new(@ctx, address, theme_id).navigate
29
- end
30
-
31
- def self.help
32
- "Interactively select a route and resource to navigate to in the theme dev server."
33
- end
34
-
35
- private
36
-
37
- def valid_authentication_method!
38
- if FluidCLI::Environment.auth_token.nil? && FluidCLI::DB.get(:jwt).nil?
39
- FluidCLI::Context.abort("Auth token is missing", "Please login using 'fluid login' command.")
40
- end
41
- end
42
-
43
- def resolve_theme_id(theme_identifier)
44
- if theme_identifier
45
- theme = FluidCLI::Theme::Theme.find_by_identifier(@ctx, root: ".", identifier: theme_identifier)
46
- @ctx.abort("Theme not found: #{theme_identifier}") unless theme
47
- theme.id
48
- else
49
- id = FluidCLI::DB.get(:development_theme_id)
50
- @ctx.abort("No active development theme found. Run 'fluid theme dev' first, or specify a theme with --theme.") unless id
51
- id
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,68 +0,0 @@
1
- require 'fluid_cli'
2
- require "fluid_cli/theme/syncer"
3
- require 'fluid_cli/theme/theme'
4
- require "fluid_cli/commands/theme/common/root_helper"
5
-
6
-
7
- module FluidCLI
8
- module Commands
9
- class Theme
10
- class Pull < FluidCLI::Command
11
- include Common::RootHelper
12
-
13
- options do |parser, flags|
14
- parser.on("-t", "--theme=NAME_OR_ID") { |theme| flags[:theme] = theme }
15
- end
16
-
17
- def call(_args, name)
18
- root = root_value(options, name)
19
- return if exist_and_not_empty?(root) && !valid_theme_directory?(root)
20
-
21
- delete = !options.flags[:nodelete]
22
- theme = find_theme(root, **options.flags)
23
- return if theme.nil?
24
-
25
- syncer = FluidCLI::Theme::Syncer.new(@ctx, theme: theme)
26
- begin
27
- syncer.start_threads
28
- CLI::UI::Frame.open("pulling theme #{theme.name} (##{theme.id})") do
29
- FluidCLI::Theme::UI::SyncProgressBar.new(syncer).progress(:download_theme!, delete: delete)
30
- end
31
- if syncer.has_any_error?
32
- @ctx.warn("Some files could not be downloaded. Please check the log file for more details: #{FluidCLI::LOG_FILE}")
33
- else
34
- @ctx.done("Theme #{theme.name} (##{theme.id}) pulled successfully.")
35
- end
36
- rescue FluidCLI::API::APIRequestNotFoundError
37
- @ctx.abort("No theme found with ID: ##{theme.id}")
38
- ensure
39
- syncer.shutdown
40
- end
41
- end
42
-
43
-
44
- private
45
-
46
- def find_theme(root, theme: nil, **_args)
47
- if theme
48
- selected_theme = FluidCLI::Theme::Theme.find_by_identifier(@ctx, root: root, identifier: theme)
49
- return selected_theme || @ctx.abort("No theme found with identifier: #{theme}")
50
- end
51
-
52
- select_theme(root)
53
- end
54
-
55
-
56
- def select_theme(root)
57
- form = FluidCLI::Theme::Forms::Select.ask(
58
- @ctx,
59
- [],
60
- title: "Select a theme to pull",
61
- root: root,
62
- )
63
- form&.theme
64
- end
65
- end
66
- end
67
- end
68
- end
@@ -1,132 +0,0 @@
1
- # frozen_string_literal: true
2
- require "fluid_cli/theme/theme"
3
- require "fluid_cli/theme/development_theme"
4
- require "fluid_cli/theme/syncer"
5
- require "fluid_cli/commands/theme/common/root_helper"
6
- require "fluid_cli/commands/theme/common/company_helper"
7
- module FluidCLI
8
- module Commands
9
- class Theme
10
- class Push < FluidCLI::Command
11
- include Common::RootHelper
12
- include Common::CompanyHelper
13
-
14
- # recommend_default_ruby_range
15
-
16
- options do |parser, flags|
17
- parser.on("-n", "--nodelete") { flags[:nodelete] = true }
18
- parser.on("-t", "--theme=NAME_OR_ID") { |theme| flags[:theme] = theme }
19
- # parser.on("-l", "--live") { flags[:live] = true }
20
- # parser.on("-d", "--development") { flags[:development] = true }
21
- parser.on("-u", "--unpublished") { flags[:unpublished] = true }
22
- parser.on("-j", "--json") { flags[:json] = true }
23
- parser.on("-a", "--allow-live") { flags[:allow_live] = true }
24
- parser.on("-p", "--publish") { flags[:publish] = true }
25
- parser.on("-f", "--force") { flags[:force] = true }
26
- # parser.on("--development-theme-id=DEVELOPMENT_THEME_ID") do |development_theme_id|
27
- # flags[:development_theme_id] = development_theme_id.to_i
28
- # end
29
- end
30
-
31
- def call(_args, name)
32
- root = root_value(options, name)
33
- return unless valid_theme_directory?(root)
34
-
35
- development_theme_id = options.flags[:development_theme_id]
36
- FluidCLI::DB.set(development_theme_id: development_theme_id) unless development_theme_id.nil?
37
-
38
- delete = !options.flags[:nodelete]
39
- theme = find_theme(root, **options.flags)
40
- return if theme.nil?
41
-
42
- # if theme.live? && !options.flags[:allow_live]
43
- # question = @ctx.message("theme.push.live")
44
- # question += @ctx.message("theme.push.theme", theme.name, theme.id) if options.flags[:live]
45
- # return unless CLI::UI::Prompt.confirm(question)
46
- # end
47
-
48
- syncer = FluidCLI::Theme::Syncer.new(@ctx, theme: theme, force: options.flags[:force])
49
- begin
50
- syncer.start_threads
51
- if options.flags[:json]
52
- syncer.standard_reporter.disable!
53
- syncer.upload_theme!(delete: delete)
54
- else
55
- CLI::UI::Frame.open("Pushing #{theme.name} (##{theme.id}) to #{theme.company}") do
56
- FluidCLI::Theme::UI::SyncProgressBar.new(syncer).progress(:upload_theme!, delete: delete)
57
- end
58
- end
59
- push_completion_handler(theme, syncer.has_any_error?)
60
- ensure
61
- syncer.shutdown
62
- end
63
- rescue FluidCLI::API::APIRequestNotFoundError
64
- @ctx.abort("No theme found with ID: ##{theme.id}")
65
- end
66
-
67
- def self.help
68
- "Pushes local theme files to a company's theme."
69
- end
70
-
71
- private
72
-
73
- def push_completion_handler(theme, has_errors)
74
- if options.flags[:json]
75
- output = { theme: theme.to_h }
76
- output[:warning] = "Theme pushed with some errors" if has_errors
77
-
78
- puts(JSON.generate(output))
79
- elsif options.flags[:publish]
80
- theme.publish
81
- return @ctx.done("Theme published successfully") unless has_errors
82
- @ctx.warn("Theme published with errors")
83
- else
84
- return @ctx.done("Theme pushed successfully") unless has_errors
85
- @ctx.warn("Theme pushed with errors")
86
- end
87
- raise CLI::Kit::AbortSilent if has_errors
88
- end
89
-
90
- def find_theme(root, theme_id: nil, theme: nil, live: nil, development: nil, unpublished: nil, **_args)
91
- if live
92
- return FluidCLI::Theme::Theme.live(@ctx, root: root)
93
- end
94
-
95
- if development
96
- return FluidCLI::Theme::DevelopmentTheme.find_or_create!(@ctx, root: root)
97
- end
98
-
99
- if unpublished
100
- name = theme || ask_theme_name
101
- return FluidCLI::Theme::Theme.create_unpublished(@ctx, root: root, name: name)
102
- end
103
-
104
- if theme
105
- selected_theme = FluidCLI::Theme::Theme.find_by_identifier(@ctx, root: root, identifier: theme)
106
- return selected_theme || @ctx.abort("No theme found with identifier: #{theme}")
107
- end
108
-
109
- select_theme(root)
110
- end
111
-
112
- def ask_theme_name
113
- CLI::UI::Prompt.ask("Enter theme name:", allow_empty: false)
114
- end
115
-
116
- def select_theme(root)
117
- form = FluidCLI::Theme::Forms::Select.ask(
118
- @ctx,
119
- [],
120
- title: "Select a theme to push to #{company}",
121
- root: root,
122
- )
123
- form&.theme
124
- end
125
-
126
- def themes(root)
127
- FluidCLI::Theme::Theme.all(@ctx, root: root)
128
- end
129
- end
130
- end
131
- end
132
- end
@@ -1,24 +0,0 @@
1
- require "fluid_cli"
2
-
3
- module FluidCLI
4
- module Commands
5
- class Theme < FluidCLI::Command
6
- subcommand :Dev, 'dev', 'fluid_cli/commands/theme/dev'
7
- subcommand :Init, 'init', 'fluid_cli/commands/theme/init'
8
- subcommand :Navigate, 'navigate', 'fluid_cli/commands/theme/navigate'
9
- subcommand :Pull, 'pull', 'fluid_cli/commands/theme/pull'
10
- subcommand :Push, 'push', 'fluid_cli/commands/theme/push'
11
-
12
- def call(*args)
13
- self.class.help(*args)
14
- end
15
-
16
- class << self
17
- def help(*args)
18
- subcommands = subcommand_registry.command_names.join(" | ")
19
- puts "Manage themes.\n\n{{bold:Subcommands:}} {{command:#{subcommands}}}"
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,23 +0,0 @@
1
- require "fluid_cli"
2
-
3
- module FluidCLI
4
- module Commands
5
- class Whoami < FluidCLI::Command
6
- def call(_args, _name)
7
- company = FluidCLI::DB.get(:company)
8
- company_name = FluidCLI::DB.get(:company_name)
9
-
10
- output = if company.nil?
11
- "Not logged in to any company."
12
- else
13
- "Logged in to company: #{company_name || company}"
14
- end
15
- @ctx.puts(output)
16
- end
17
-
18
- def self.help
19
- "Displays the currently logged in company."
20
- end
21
- end
22
- end
23
- end
@@ -1,19 +0,0 @@
1
- require 'fluid_cli'
2
-
3
- module FluidCLI
4
- module Commands
5
- Registry = CLI::Kit::CommandRegistry.new(default: 'help')
6
-
7
- def self.register(const, cmd, path)
8
- autoload(const, path)
9
- Registry.add(->() { const_get(const) }, cmd)
10
- end
11
-
12
- register :Login, 'login', 'fluid_cli/commands/login'
13
- register :Logout, 'logout', 'fluid_cli/commands/logout'
14
- register :Theme, 'theme', 'fluid_cli/commands/theme'
15
- register :Help, 'help', 'fluid_cli/commands/help'
16
- register :Switch, 'switch', 'fluid_cli/commands/switch'
17
- register :Whoami, 'whoami', 'fluid_cli/commands/whoami'
18
- end
19
- end
@@ -1,69 +0,0 @@
1
- require "fluid_cli"
2
-
3
- module FluidCLI
4
- class CompanySwitcher
5
- class Error < StandardError; end
6
- class Timeout < StandardError; end
7
-
8
- attr_accessor :ctx, :identifier, :switched_after_login
9
-
10
- def initialize(ctx:, company: nil, switched_after_login: false)
11
- @ctx = ctx
12
- @identifier = company
13
- @switched_after_login = switched_after_login
14
- end
15
-
16
- def switch
17
- company = find_company
18
- switch_company(company)
19
- end
20
-
21
- def find_company
22
- if switched_after_login
23
- if identifier
24
- company = companies.find { |c| c["subdomain"] == identifier }
25
- company ||= select_company
26
- else
27
- if companies.size == 1
28
- company = companies.first
29
- else
30
- company = select_company
31
- end
32
- end
33
- else
34
- if identifier
35
- company = companies.find { |c| c["subdomain"] == identifier }
36
- unless company
37
- @ctx.abort("Company with subdomain '#{identifier}' not found.")
38
- end
39
- else
40
- company = select_company
41
- end
42
- end
43
- company
44
- end
45
-
46
- def select_company
47
- company_id = CLI::UI::Prompt.ask("Select a company") do |handler|
48
- companies.each do |c|
49
- handler.option("#{c["name"]} <#{c["subdomain"]}>") { c["id"] }
50
- end
51
- end
52
- companies.find { |c| c["id"] == company_id }
53
- end
54
-
55
- def companies
56
- @companies ||= begin
57
- _status, body = FluidCLI::API.new(@ctx).get(path: "/me")
58
- body["companies"]
59
- end
60
- end
61
-
62
- def switch_company(company)
63
- _status, body = FluidCLI::API.new(@ctx).put(path: "/authentication/company/#{company['id']}/switch")
64
- FluidCLI::DB.set(jwt: body.dig("company", "jwt"))
65
- IdentityAuth.new(ctx: @ctx).reauthenticate
66
- company
67
- end
68
- end
69
- end