fluid_cli 0.1.8 → 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.
- checksums.yaml +4 -4
- data/README.md +200 -1
- data/exe/fluid +12 -17
- data/lib/fluid_cli/version.rb +1 -1
- data/lib/fluid_cli.rb +4 -57
- metadata +14 -274
- data/Rakefile +0 -26
- data/dev.yml +0 -5
- data/lib/fluid_cli/api.rb +0 -141
- data/lib/fluid_cli/assets/post_auth_page/index.html.erb +0 -34
- data/lib/fluid_cli/assets/post_auth_page/style.css +0 -58
- data/lib/fluid_cli/command.rb +0 -55
- data/lib/fluid_cli/commands/help.rb +0 -21
- data/lib/fluid_cli/commands/login.rb +0 -30
- data/lib/fluid_cli/commands/logout.rb +0 -38
- data/lib/fluid_cli/commands/switch.rb +0 -23
- data/lib/fluid_cli/commands/theme/common/company_helper.rb +0 -15
- data/lib/fluid_cli/commands/theme/common/root_helper.rb +0 -95
- data/lib/fluid_cli/commands/theme/dev.rb +0 -61
- data/lib/fluid_cli/commands/theme/help.rb +0 -21
- data/lib/fluid_cli/commands/theme/init.rb +0 -46
- data/lib/fluid_cli/commands/theme/pull.rb +0 -68
- data/lib/fluid_cli/commands/theme/push.rb +0 -132
- data/lib/fluid_cli/commands/theme.rb +0 -23
- data/lib/fluid_cli/commands/whoami.rb +0 -23
- data/lib/fluid_cli/commands.rb +0 -19
- data/lib/fluid_cli/company_switcher.rb +0 -69
- data/lib/fluid_cli/context.rb +0 -691
- data/lib/fluid_cli/db.rb +0 -114
- data/lib/fluid_cli/entry_point.rb +0 -10
- data/lib/fluid_cli/environment.rb +0 -32
- data/lib/fluid_cli/file_system_listener.rb +0 -29
- data/lib/fluid_cli/form.rb +0 -42
- data/lib/fluid_cli/git.rb +0 -319
- data/lib/fluid_cli/http_request.rb +0 -60
- data/lib/fluid_cli/identity_auth/servlet.rb +0 -39
- data/lib/fluid_cli/identity_auth.rb +0 -126
- data/lib/fluid_cli/options.rb +0 -38
- data/lib/fluid_cli/packager.rb +0 -36
- data/lib/fluid_cli/theme/dev_server/certificate_manager.rb +0 -79
- data/lib/fluid_cli/theme/dev_server/errors.rb +0 -9
- data/lib/fluid_cli/theme/dev_server/header_hash.rb +0 -98
- data/lib/fluid_cli/theme/dev_server/hooks/file_change_hook.rb +0 -39
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/hot-reload-no-script.html +0 -27
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/hot_reload.js +0 -28
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/sse_client.js +0 -43
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/theme.js +0 -16
- data/lib/fluid_cli/theme/dev_server/hot_reload/script_injector.rb +0 -54
- data/lib/fluid_cli/theme/dev_server/hot_reload.rb +0 -75
- data/lib/fluid_cli/theme/dev_server/local_assets.rb +0 -92
- data/lib/fluid_cli/theme/dev_server/proxy.rb +0 -235
- data/lib/fluid_cli/theme/dev_server/proxy_param_builder.rb +0 -82
- data/lib/fluid_cli/theme/dev_server/reload_mode.rb +0 -34
- data/lib/fluid_cli/theme/dev_server/sse.rb +0 -75
- data/lib/fluid_cli/theme/dev_server/watcher.rb +0 -57
- data/lib/fluid_cli/theme/dev_server/web_server.rb +0 -140
- data/lib/fluid_cli/theme/dev_server.rb +0 -293
- data/lib/fluid_cli/theme/development_theme.rb +0 -101
- data/lib/fluid_cli/theme/file.rb +0 -105
- data/lib/fluid_cli/theme/forms/select.rb +0 -33
- data/lib/fluid_cli/theme/mime_type.rb +0 -34
- data/lib/fluid_cli/theme/presenters/theme_presenter.rb +0 -49
- data/lib/fluid_cli/theme/presenters/themes_presenter.rb +0 -31
- data/lib/fluid_cli/theme/root.rb +0 -62
- data/lib/fluid_cli/theme/syncer/checksums.rb +0 -66
- data/lib/fluid_cli/theme/syncer/downloader.rb +0 -54
- data/lib/fluid_cli/theme/syncer/error_reporter.rb +0 -45
- data/lib/fluid_cli/theme/syncer/merger.rb +0 -53
- data/lib/fluid_cli/theme/syncer/operation.rb +0 -58
- data/lib/fluid_cli/theme/syncer/standard_reporter.rb +0 -32
- data/lib/fluid_cli/theme/syncer/unsupported_script_warning.rb +0 -90
- data/lib/fluid_cli/theme/syncer/uploader/forms/apply_to_all.rb +0 -41
- data/lib/fluid_cli/theme/syncer/uploader/forms/apply_to_all_form.rb +0 -37
- data/lib/fluid_cli/theme/syncer/uploader/forms/base_strategy_form.rb +0 -64
- data/lib/fluid_cli/theme/syncer/uploader/forms/select_delete_strategy.rb +0 -29
- data/lib/fluid_cli/theme/syncer/uploader/forms/select_update_strategy.rb +0 -30
- data/lib/fluid_cli/theme/syncer/uploader/json_delete_handler.rb +0 -49
- data/lib/fluid_cli/theme/syncer/uploader/json_update_handler.rb +0 -71
- data/lib/fluid_cli/theme/syncer/uploader.rb +0 -105
- data/lib/fluid_cli/theme/syncer.rb +0 -492
- data/lib/fluid_cli/theme/theme.rb +0 -186
- data/lib/fluid_cli/theme/ui/sync_progress_bar.rb +0 -22
- data/lib/fluid_cli/thread_pool/job.rb +0 -35
- data/lib/fluid_cli/thread_pool.rb +0 -49
- data/packaging/homebrew/fluid_cli.base.rb +0 -103
- data/vendor/deps/base64/.document +0 -5
- data/vendor/deps/base64/.gitignore +0 -9
- data/vendor/deps/base64/BSDL +0 -22
- data/vendor/deps/base64/COPYING +0 -56
- data/vendor/deps/base64/Gemfile +0 -9
- data/vendor/deps/base64/LEGAL +0 -60
- data/vendor/deps/base64/README.md +0 -48
- data/vendor/deps/base64/Rakefile +0 -31
- data/vendor/deps/base64/base64.gemspec +0 -28
- data/vendor/deps/base64/bin/console +0 -14
- data/vendor/deps/base64/bin/setup +0 -8
- data/vendor/deps/base64/lib/base64.rb +0 -382
- data/vendor/deps/base64/sig/base64.rbs +0 -358
- data/vendor/deps/base64/test/base64/test_base64.rb +0 -115
- data/vendor/deps/base64/test_sig/test_base64.rb +0 -44
- data/vendor/deps/cli-kit/REVISION +0 -1
- data/vendor/deps/cli-kit/lib/cli/kit/args/definition.rb +0 -286
- data/vendor/deps/cli-kit/lib/cli/kit/args/evaluation.rb +0 -215
- data/vendor/deps/cli-kit/lib/cli/kit/args/parser/node.rb +0 -128
- data/vendor/deps/cli-kit/lib/cli/kit/args/parser.rb +0 -125
- data/vendor/deps/cli-kit/lib/cli/kit/args/tokenizer.rb +0 -130
- data/vendor/deps/cli-kit/lib/cli/kit/args.rb +0 -16
- data/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +0 -30
- data/vendor/deps/cli-kit/lib/cli/kit/command_help.rb +0 -268
- data/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +0 -150
- data/vendor/deps/cli-kit/lib/cli/kit/config.rb +0 -137
- data/vendor/deps/cli-kit/lib/cli/kit/core_ext.rb +0 -28
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +0 -166
- data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +0 -92
- data/vendor/deps/cli-kit/lib/cli/kit/ini.rb +0 -91
- data/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +0 -92
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +0 -94
- data/vendor/deps/cli-kit/lib/cli/kit/opts.rb +0 -248
- data/vendor/deps/cli-kit/lib/cli/kit/parse_args.rb +0 -55
- data/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +0 -66
- data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +0 -260
- data/vendor/deps/cli-kit/lib/cli/kit/support.rb +0 -11
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +0 -290
- data/vendor/deps/cli-kit/lib/cli/kit/util.rb +0 -118
- data/vendor/deps/cli-kit/lib/cli/kit/version.rb +0 -7
- data/vendor/deps/cli-kit/lib/cli/kit.rb +0 -139
- data/vendor/deps/cli-ui/REVISION +0 -1
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +0 -218
- data/vendor/deps/cli-ui/lib/cli/ui/color.rb +0 -101
- data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +0 -219
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +0 -67
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +0 -179
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +0 -152
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +0 -127
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +0 -286
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +0 -92
- data/vendor/deps/cli-ui/lib/cli/ui/os.rb +0 -63
- data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +0 -64
- data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +0 -132
- data/vendor/deps/cli-ui/lib/cli/ui/progress_reporter.rb +0 -209
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +0 -583
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +0 -36
- data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +0 -381
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +0 -48
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +0 -602
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +0 -79
- data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +0 -399
- data/vendor/deps/cli-ui/lib/cli/ui/table.rb +0 -83
- data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +0 -55
- data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +0 -106
- data/vendor/deps/cli-ui/lib/cli/ui/version.rb +0 -8
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +0 -46
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +0 -79
- data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +0 -89
- data/vendor/deps/cli-ui/lib/cli/ui/work_queue.rb +0 -142
- data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +0 -61
- data/vendor/deps/cli-ui/lib/cli/ui.rb +0 -359
- data/vendor/deps/cli-ui/vendor/reentrant_mutex.rb +0 -78
- data/vendor/deps/webrick/.gitignore +0 -9
- data/vendor/deps/webrick/Gemfile +0 -3
- data/vendor/deps/webrick/LICENSE.txt +0 -22
- data/vendor/deps/webrick/README.md +0 -61
- data/vendor/deps/webrick/Rakefile +0 -10
- data/vendor/deps/webrick/lib/webrick/accesslog.rb +0 -157
- data/vendor/deps/webrick/lib/webrick/cgi.rb +0 -313
- data/vendor/deps/webrick/lib/webrick/compat.rb +0 -36
- data/vendor/deps/webrick/lib/webrick/config.rb +0 -158
- data/vendor/deps/webrick/lib/webrick/cookie.rb +0 -172
- data/vendor/deps/webrick/lib/webrick/htmlutils.rb +0 -30
- data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +0 -117
- data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +0 -116
- data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +0 -395
- data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +0 -132
- data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +0 -97
- data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +0 -158
- data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +0 -53
- data/vendor/deps/webrick/lib/webrick/httpauth.rb +0 -96
- data/vendor/deps/webrick/lib/webrick/httpproxy.rb +0 -354
- data/vendor/deps/webrick/lib/webrick/httprequest.rb +0 -636
- data/vendor/deps/webrick/lib/webrick/httpresponse.rb +0 -564
- data/vendor/deps/webrick/lib/webrick/https.rb +0 -152
- data/vendor/deps/webrick/lib/webrick/httpserver.rb +0 -294
- data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +0 -152
- data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +0 -47
- data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +0 -126
- data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +0 -88
- data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +0 -552
- data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +0 -47
- data/vendor/deps/webrick/lib/webrick/httpservlet.rb +0 -23
- data/vendor/deps/webrick/lib/webrick/httpstatus.rb +0 -194
- data/vendor/deps/webrick/lib/webrick/httputils.rb +0 -512
- data/vendor/deps/webrick/lib/webrick/httpversion.rb +0 -76
- data/vendor/deps/webrick/lib/webrick/log.rb +0 -156
- data/vendor/deps/webrick/lib/webrick/server.rb +0 -381
- data/vendor/deps/webrick/lib/webrick/ssl.rb +0 -215
- data/vendor/deps/webrick/lib/webrick/utils.rb +0 -265
- data/vendor/deps/webrick/lib/webrick/version.rb +0 -18
- data/vendor/deps/webrick/lib/webrick.rb +0 -232
- data/vendor/deps/webrick/webrick.gemspec +0 -74
|
@@ -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)
|
|
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,23 +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 :Pull, 'pull', 'fluid_cli/commands/theme/pull'
|
|
9
|
-
subcommand :Push, 'push', 'fluid_cli/commands/theme/push'
|
|
10
|
-
|
|
11
|
-
def call(*args)
|
|
12
|
-
self.class.help(*args)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
class << self
|
|
16
|
-
def help(*args)
|
|
17
|
-
subcommands = subcommand_registry.command_names.join(" | ")
|
|
18
|
-
puts "Manage themes.\n\n{{bold:Subcommands:}} {{command:#{subcommands}}}"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
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
|
data/lib/fluid_cli/commands.rb
DELETED
|
@@ -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
|