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.
- 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 -62
- metadata +14 -278
- 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 -62
- 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/navigate.rb +0 -57
- 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 -24
- 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 -308
- data/lib/fluid_cli/theme/development_theme.rb +0 -101
- data/lib/fluid_cli/theme/file.rb +0 -130
- 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/navigation/resource_fetcher.rb +0 -25
- data/lib/fluid_cli/theme/navigation/route_navigator.rb +0 -87
- 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/schema_validator.rb +0 -274
- 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 -500
- 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
data/lib/fluid_cli/api.rb
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
require "fluid_cli"
|
|
2
|
-
require "securerandom"
|
|
3
|
-
|
|
4
|
-
module FluidCLI
|
|
5
|
-
class API
|
|
6
|
-
|
|
7
|
-
class APIRequestError < StandardError
|
|
8
|
-
attr_reader :response
|
|
9
|
-
|
|
10
|
-
def initialize(message = nil, response: nil)
|
|
11
|
-
super(message)
|
|
12
|
-
@response = response
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
class APIRequestNotFoundError < APIRequestError; end
|
|
17
|
-
class APIRequestClientError < APIRequestError; end
|
|
18
|
-
class APIRequestUnauthorizedError < APIRequestClientError; end
|
|
19
|
-
class APIRequestForbiddenError < APIRequestClientError; end
|
|
20
|
-
class APIRequestUnexpectedError < APIRequestError; end
|
|
21
|
-
class APIRequestRetriableError < APIRequestError; end
|
|
22
|
-
class APIRequestTimeoutError < APIRequestRetriableError; end
|
|
23
|
-
class APIRequestServerError < APIRequestRetriableError; end
|
|
24
|
-
class APIRequestThrottledError < APIRequestRetriableError; end
|
|
25
|
-
|
|
26
|
-
def initialize(ctx)
|
|
27
|
-
@ctx = ctx
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def get(path:, **args, &block)
|
|
31
|
-
rest_request(method: "GET", path: path, **args, &block)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def put(path:, **args, &block)
|
|
35
|
-
rest_request(method: "PUT", path: path, **args, &block)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def post(path:, **args, &block)
|
|
39
|
-
rest_request(method: "POST", path: path, **args, &block)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def delete(path:, **args, &block)
|
|
43
|
-
rest_request(method: "DELETE", path: path, **args, &block)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def multipart_put(path:, **args, &block)
|
|
47
|
-
rest_request(method: "MULTIPART_PUT", path: path, **args, &block)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def multipart_post(path:, **args, &block)
|
|
51
|
-
rest_request(method: "MULTIPART_POST", path: path, **args, &block)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def rest_request(path:, query: nil, body: nil, method: "GET", token: nil, host: nil)
|
|
55
|
-
CLI::Kit::Util.begin do
|
|
56
|
-
url = URI::HTTPS.build(
|
|
57
|
-
host: host || FluidCLI::API_HOST,
|
|
58
|
-
path: "/api/#{path}",
|
|
59
|
-
query: query,
|
|
60
|
-
)
|
|
61
|
-
resp = request(url: url.to_s, body: body, headers: auth_headers, method: method)
|
|
62
|
-
resp
|
|
63
|
-
|
|
64
|
-
end.retry_after(API::APIRequestUnauthorizedError) do
|
|
65
|
-
FluidCLI::IdentityAuth.new(ctx: @ctx).reauthenticate unless path == "/me"
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def get_company_or_abort
|
|
70
|
-
env_store = FluidCLI::Environment.company
|
|
71
|
-
return env_store unless env_store.nil?
|
|
72
|
-
|
|
73
|
-
if FluidCLI::DB.exists?(:company)
|
|
74
|
-
FluidCLI::DB.get(:company)
|
|
75
|
-
else
|
|
76
|
-
resp = FluidCLI::IdentityAuth.new(ctx: @ctx).attempt_reauthenticate
|
|
77
|
-
@ctx.abort(
|
|
78
|
-
"No company found. Please login again"
|
|
79
|
-
) unless resp
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
private
|
|
84
|
-
|
|
85
|
-
def request(url:, body: nil, headers: {}, method: "POST")
|
|
86
|
-
CLI::Kit::Util.begin do
|
|
87
|
-
uri = URI.parse(url)
|
|
88
|
-
unless uri.is_a?(URI::HTTP)
|
|
89
|
-
@ctx.abort("Invalid URL: #{url}")
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
# we delay this require so as to avoid a performance hit on starting the CLI
|
|
94
|
-
require "fluid_cli/http_request"
|
|
95
|
-
@ctx.debug("#{method} #{uri} with X-Request-Id: #{headers["X-Request-Id"]}")
|
|
96
|
-
response = if method == "POST"
|
|
97
|
-
HttpRequest.post(uri, body, headers)
|
|
98
|
-
elsif method == "PUT"
|
|
99
|
-
HttpRequest.put(uri, body, headers)
|
|
100
|
-
elsif method == "GET"
|
|
101
|
-
HttpRequest.get(uri, body, headers)
|
|
102
|
-
elsif method == "DELETE"
|
|
103
|
-
HttpRequest.delete(uri, body, headers)
|
|
104
|
-
elsif method == "MULTIPART_PUT"
|
|
105
|
-
HttpRequest.multipart_put(uri, body, headers)
|
|
106
|
-
elsif method == "MULTIPART_POST"
|
|
107
|
-
HttpRequest.multipart_post(uri, body, headers)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
case response.code.to_i
|
|
112
|
-
when 200..399
|
|
113
|
-
[response.code.to_i, JSON.parse(response.body), response]
|
|
114
|
-
when 401
|
|
115
|
-
raise APIRequestUnauthorizedError.new("#{response.code}\n#{response.body}", response: response)
|
|
116
|
-
when 403
|
|
117
|
-
raise APIRequestForbiddenError.new("#{response.code}\n#{response.body}", response: response)
|
|
118
|
-
when 404
|
|
119
|
-
raise APIRequestNotFoundError.new("#{response.code}\n#{response.body}", response: response)
|
|
120
|
-
when 429
|
|
121
|
-
raise APIRequestThrottledError.new("#{response.code}\n#{response.body}", response: response)
|
|
122
|
-
when 400..499
|
|
123
|
-
raise APIRequestClientError.new("#{response.code}\n#{response.body}", response: response)
|
|
124
|
-
when 500..599
|
|
125
|
-
raise APIRequestServerError.new("#{response.code}\n#{response.body}", response: response)
|
|
126
|
-
else
|
|
127
|
-
raise APIRequestUnexpectedError.new("#{response.code}\n#{response.body}", response: response)
|
|
128
|
-
end
|
|
129
|
-
rescue Errno::ETIMEDOUT, Timeout::Error
|
|
130
|
-
@ctx.debug("timeout in #{method} #{uri} with X-Request-Id: #{headers["X-Request-Id"]}")
|
|
131
|
-
raise APIRequestTimeoutError, "Timeout"
|
|
132
|
-
end.retry_after(APIRequestRetriableError, retries: 3) do |e|
|
|
133
|
-
sleep(1) if e.is_a?(APIRequestThrottledError)
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def auth_headers
|
|
138
|
-
{ "Authorization" => "Bearer #{FluidCLI::Environment.auth_token || FluidCLI::DB.get(:jwt)}" }
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<title>Fluid CLI</title>
|
|
8
|
-
<style><%= locals[:css] %></style>
|
|
9
|
-
<link rel="icon" href="https://cdn.fluid.app/favicon-32x32.png" type="image/png">
|
|
10
|
-
</head>
|
|
11
|
-
|
|
12
|
-
<% if successful %>
|
|
13
|
-
<body class="body-success">
|
|
14
|
-
<div class="app-success">
|
|
15
|
-
<div class="container">
|
|
16
|
-
<h1><%= locals[:message] %></h1>
|
|
17
|
-
<p>You can close this tab and return to your terminal.</p>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
</body>
|
|
21
|
-
<% else %>
|
|
22
|
-
<body class="body-error">
|
|
23
|
-
<div class="app-error">
|
|
24
|
-
<div class="container">
|
|
25
|
-
<h1>Something went wrong!</h1>
|
|
26
|
-
<p><%= locals[:message] %></p>
|
|
27
|
-
<br>
|
|
28
|
-
<br>
|
|
29
|
-
<p>Return to your terminal and try running the previous command again.</p>
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
</body>
|
|
33
|
-
<% end %>
|
|
34
|
-
</html>
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
html {
|
|
2
|
-
font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
|
|
3
|
-
text-size-adjust: 100%;
|
|
4
|
-
text-rendering: optimizeLegibility;
|
|
5
|
-
-webkit-font-smoothing: antialiased;
|
|
6
|
-
-moz-osx-font-smoothing: grayscale;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
body {
|
|
10
|
-
font-size: 26px;
|
|
11
|
-
line-height: normal;
|
|
12
|
-
margin: 0;
|
|
13
|
-
padding: 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
button, input, optgroup, select, textarea {
|
|
17
|
-
font-family: inherit;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
h1 {
|
|
21
|
-
font-weight: 600;
|
|
22
|
-
font-size: 1em;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
p {
|
|
26
|
-
font-weight: 400;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.body-success {
|
|
30
|
-
color: #F6F6F7;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.body-error {
|
|
34
|
-
color: #202223;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.app-success {
|
|
38
|
-
width: 100vw;
|
|
39
|
-
height: 100vh;
|
|
40
|
-
background-color: #054A49;
|
|
41
|
-
display: flex;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.app-error {
|
|
45
|
-
width: 100vw;
|
|
46
|
-
height: 100vh;
|
|
47
|
-
background-color: #F6F6F7;
|
|
48
|
-
display: flex;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.container {
|
|
52
|
-
display: flex;
|
|
53
|
-
flex-direction: column;
|
|
54
|
-
justify-content: center;
|
|
55
|
-
width: 100%;
|
|
56
|
-
height: 100%;
|
|
57
|
-
padding-left: 7.5em;
|
|
58
|
-
}
|
data/lib/fluid_cli/command.rb
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require "fluid_cli"
|
|
3
|
-
|
|
4
|
-
module FluidCLI
|
|
5
|
-
class Command < CLI::Kit::BaseCommand
|
|
6
|
-
attr_writer :ctx
|
|
7
|
-
attr_accessor :options
|
|
8
|
-
|
|
9
|
-
class << self
|
|
10
|
-
attr_writer :ctx
|
|
11
|
-
|
|
12
|
-
def call(args, command_name, *)
|
|
13
|
-
subcommand, resolved_name = subcommand_registry.lookup_command(args.first)
|
|
14
|
-
if subcommand
|
|
15
|
-
subcommand.ctx = @ctx
|
|
16
|
-
subcommand.call(args.drop(1), resolved_name, command_name)
|
|
17
|
-
else
|
|
18
|
-
cmd = new(@ctx)
|
|
19
|
-
cmd.options.parse(@_options, args)
|
|
20
|
-
cmd.call(args, command_name)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def options(&block)
|
|
25
|
-
existing_options = @_options
|
|
26
|
-
# We prevent new options calls to override existing blocks by nesting them.
|
|
27
|
-
@_options = ->(parser, flags) {
|
|
28
|
-
existing_options&.call(parser, flags)
|
|
29
|
-
block.call(parser, flags)
|
|
30
|
-
}
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def subcommand(const, cmd, path = nil)
|
|
34
|
-
autoload(const, path) if path
|
|
35
|
-
subcommand_registry.add(->() { const_get(const) }, cmd.to_s)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def subcommand_registry
|
|
39
|
-
@subcommand_registry ||= CLI::Kit::CommandRegistry.new(
|
|
40
|
-
default: nil)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def call_help(*cmds)
|
|
44
|
-
help = Commands::Help.new(@ctx)
|
|
45
|
-
help.call(cmds, nil)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def initialize(ctx = nil)
|
|
50
|
-
super()
|
|
51
|
-
@ctx = ctx || FluidCLI::Context.new
|
|
52
|
-
self.options = Options.new
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'fluid_cli'
|
|
2
|
-
|
|
3
|
-
module FluidCLI
|
|
4
|
-
module Commands
|
|
5
|
-
class Help < FluidCLI::Command
|
|
6
|
-
def call(args, _name)
|
|
7
|
-
puts CLI::UI.fmt("{{bold:Available commands}}")
|
|
8
|
-
puts ""
|
|
9
|
-
|
|
10
|
-
FluidCLI::Commands::Registry.resolved_commands.each do |name, klass|
|
|
11
|
-
next if name == 'help'
|
|
12
|
-
puts CLI::UI.fmt("{{command:#{FluidCLI::TOOL_NAME} #{name}}}")
|
|
13
|
-
if help = klass.help
|
|
14
|
-
puts CLI::UI.fmt(help)
|
|
15
|
-
end
|
|
16
|
-
puts ""
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require "fluid_cli"
|
|
2
|
-
|
|
3
|
-
module FluidCLI
|
|
4
|
-
module Commands
|
|
5
|
-
class Login < FluidCLI::Command
|
|
6
|
-
PROTOCOL_REGEX = /^https?\:\/\//
|
|
7
|
-
PERMANENT_DOMAIN_SUFFIX = /\.myshopify\.(com|io)$/
|
|
8
|
-
|
|
9
|
-
options do |parser, flags|
|
|
10
|
-
parser.on("-c", "--company=COMPANY") { |url| flags[:company] = url }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def call(*)
|
|
14
|
-
company_identifier = (options.flags[:company] || @ctx.getenv("FLUID_COMPANY" || nil))
|
|
15
|
-
IdentityAuth.new(ctx: @ctx).authenticate(spinner: true)
|
|
16
|
-
company = FluidCLI::CompanySwitcher.new(
|
|
17
|
-
ctx: @ctx,
|
|
18
|
-
company: company_identifier,
|
|
19
|
-
switched_after_login: true
|
|
20
|
-
).switch
|
|
21
|
-
Whoami.call([], "whoami")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def self.help
|
|
25
|
-
"Log in to your Fluid account"
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require "fluid_cli"
|
|
2
|
-
require "fluid_cli/theme/development_theme"
|
|
3
|
-
|
|
4
|
-
module FluidCLI
|
|
5
|
-
module Commands
|
|
6
|
-
class Logout < FluidCLI::Command
|
|
7
|
-
def call(*)
|
|
8
|
-
try_delete_development_theme
|
|
9
|
-
|
|
10
|
-
FluidCLI::IdentityAuth.delete_tokens_and_keys
|
|
11
|
-
FluidCLI::DB.del(:company) if has_company?
|
|
12
|
-
@ctx.puts("Logged out successfully.")
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.help
|
|
16
|
-
"Logs out the current user."
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def has_company?
|
|
22
|
-
FluidCLI::DB.exists?(:company)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def try_delete_development_theme
|
|
26
|
-
return unless has_company?
|
|
27
|
-
|
|
28
|
-
FluidCLI::Theme::DevelopmentTheme.delete(@ctx)
|
|
29
|
-
rescue FluidCLI::API::APIRequestError, CLI::Kit::Abort, CLI::Kit::AbortSilent => e
|
|
30
|
-
@ctx.debug("[Logout Error]: #{e.message}")
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def has_company?
|
|
34
|
-
FluidCLI::DB.exists?(:company)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require "fluid_cli"
|
|
2
|
-
|
|
3
|
-
module FluidCLI
|
|
4
|
-
module Commands
|
|
5
|
-
class Switch < FluidCLI::Command
|
|
6
|
-
options do |parser, flags|
|
|
7
|
-
parser.on("-c", "--company=COMPANY") { |url| flags[:company] = url }
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def call(*)
|
|
11
|
-
company = FluidCLI::CompanySwitcher.new(
|
|
12
|
-
ctx: @ctx,
|
|
13
|
-
company: options.flags[:company]
|
|
14
|
-
).switch
|
|
15
|
-
@ctx.puts("Switched to company '#{company['name']}' successfully.")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.help
|
|
19
|
-
"Switches the current company context."
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
require 'fluid_cli'
|
|
2
|
-
|
|
3
|
-
module FluidCLI
|
|
4
|
-
module Commands
|
|
5
|
-
class Theme
|
|
6
|
-
module Common
|
|
7
|
-
module RootHelper
|
|
8
|
-
REQUIRED_FOLDERS = %w(config layouts sections product shop_page).freeze
|
|
9
|
-
|
|
10
|
-
def root_value(options, name)
|
|
11
|
-
argv = default_argv(options)
|
|
12
|
-
command_index = argv.index(name.to_s)
|
|
13
|
-
|
|
14
|
-
return "." if command_index.nil?
|
|
15
|
-
|
|
16
|
-
next_index = command_index + 1
|
|
17
|
-
option_by_key = options_map(options)
|
|
18
|
-
|
|
19
|
-
while next_index < argv.size
|
|
20
|
-
element = argv[next_index]
|
|
21
|
-
key, value = key_value_tuple(element)
|
|
22
|
-
option = option_by_key[key]
|
|
23
|
-
|
|
24
|
-
return element if option.nil?
|
|
25
|
-
|
|
26
|
-
# Skip the option argument
|
|
27
|
-
next_index += 1 if !option.arg.nil? && !value
|
|
28
|
-
|
|
29
|
-
# PATTERN arguments take precedence over the `root`
|
|
30
|
-
if option.arg =~ /PATTERN/ && !value
|
|
31
|
-
next_index += 1 while option_argument?(argv, next_index, option_by_key)
|
|
32
|
-
next
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
next_index += 1
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
"."
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def valid_theme_directory?(root)
|
|
42
|
-
REQUIRED_FOLDERS.all? { |required_folder| Dir.exist?(File.join(root, required_folder)) } ||
|
|
43
|
-
current_directory_confirmed?
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def exist_and_not_empty?(root)
|
|
47
|
-
Dir.exist?(root) && !Dir[File.join(root, "*")].empty?
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
def current_directory_confirmed?
|
|
53
|
-
return true if options.flags[:force]
|
|
54
|
-
|
|
55
|
-
@ctx.warn("Warning: The specified directory does not appear to be a valid theme directory.")
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return true if !FluidCLI::Environment.interactive?
|
|
59
|
-
|
|
60
|
-
CLI::UI::Prompt.confirm("Do you want to continue?", default: false)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def default_argv(options)
|
|
64
|
-
options.parser.default_argv.compact
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def options_map(options)
|
|
68
|
-
map = {}
|
|
69
|
-
options_list(options).each do |option|
|
|
70
|
-
map[option.short.first] = option
|
|
71
|
-
map[option.long.first] = option
|
|
72
|
-
end
|
|
73
|
-
map
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def options_list(options)
|
|
77
|
-
options.parser.top.list
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def option_argument?(argv, next_index, option_by_key)
|
|
81
|
-
return false unless next_index < argv.size
|
|
82
|
-
|
|
83
|
-
element = argv[next_index]
|
|
84
|
-
key, _value = key_value_tuple(element)
|
|
85
|
-
option_by_key[key].nil?
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def key_value_tuple(element)
|
|
89
|
-
element.split("=")
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require "fluid_cli/theme/dev_server"
|
|
3
|
-
require "fluid_cli/commands/theme/common/root_helper"
|
|
4
|
-
# require "fluid_cli/theme/conversions/include_glob"
|
|
5
|
-
# require "fluid_cli/theme/conversions/ignore_glob"
|
|
6
|
-
module FluidCLI
|
|
7
|
-
module Commands
|
|
8
|
-
class Theme
|
|
9
|
-
class Dev < FluidCLI::Command
|
|
10
|
-
include Common::RootHelper
|
|
11
|
-
|
|
12
|
-
# recommend_default_ruby_range
|
|
13
|
-
|
|
14
|
-
DEFAULT_HTTP_HOST = "127.0.0.1"
|
|
15
|
-
|
|
16
|
-
options do |parser, flags|
|
|
17
|
-
# Conversions::IncludeGlob.register(parser)
|
|
18
|
-
# Conversions::IgnoreGlob.register(parser)
|
|
19
|
-
|
|
20
|
-
parser.on("--host=HOST") { |host| flags[:host] = host.to_s }
|
|
21
|
-
parser.on("--port=PORT") { |port| flags[:port] = port.to_i }
|
|
22
|
-
parser.on("--poll") { flags[:poll] = true }
|
|
23
|
-
parser.on("--live-reload=MODE") { |mode| flags[:mode] = as_reload_mode(mode) }
|
|
24
|
-
parser.on("-t", "--theme=NAME_OR_ID") { |theme| flags[:theme] = theme }
|
|
25
|
-
parser.on("-f", "--force") { flags[:force] = true }
|
|
26
|
-
parser.on("--overwrite-json") { flags[:overwrite_json] = true }
|
|
27
|
-
parser.on("--navigate") { flags[:navigate] = true }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def call(_args, name)
|
|
31
|
-
valid_authentication_method!
|
|
32
|
-
|
|
33
|
-
root = root_value(options, name)
|
|
34
|
-
return unless valid_theme_directory?(root)
|
|
35
|
-
|
|
36
|
-
flags = options.flags.dup
|
|
37
|
-
host = flags[:host] || DEFAULT_HTTP_HOST
|
|
38
|
-
|
|
39
|
-
FluidCLI::Theme::DevServer.start(@ctx, root, host: host, **flags) do |syncer|
|
|
40
|
-
FluidCLI::Theme::UI::SyncProgressBar.new(syncer).progress(:upload_theme!, delay_low_priority_files: true)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def self.as_reload_mode(mode)
|
|
45
|
-
FluidCLI::Theme::DevServer::ReloadMode.get!(mode)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def self.help
|
|
49
|
-
FluidCLI::Context.message("theme.serve.help", FluidCLI::TOOL_NAME)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
private
|
|
53
|
-
|
|
54
|
-
def valid_authentication_method!
|
|
55
|
-
if FluidCLI::Environment.auth_token.nil? && FluidCLI::DB.get(:jwt).nil?
|
|
56
|
-
FluidCLI::Context.abort("Auth token is missing", "Please login using 'fluid_cli login' command.")
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'fluid_cli'
|
|
2
|
-
|
|
3
|
-
module FluidCLI
|
|
4
|
-
module Commands
|
|
5
|
-
class Theme
|
|
6
|
-
class Help
|
|
7
|
-
def call(_args, _name)
|
|
8
|
-
puts 'neato'
|
|
9
|
-
|
|
10
|
-
if rand < 0.05
|
|
11
|
-
raise(CLI::Kit::Abort, "you got unlucky!")
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.help
|
|
16
|
-
"A dummy command.\nUsage: {{command:#{FluidCLI::TOOL_NAME} example}}"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
require 'fluid_cli'
|
|
2
|
-
|
|
3
|
-
module FluidCLI
|
|
4
|
-
module Commands
|
|
5
|
-
class Theme
|
|
6
|
-
class Init < FluidCLI::Command
|
|
7
|
-
options do |parser, flags|
|
|
8
|
-
parser.on("-u", "--clone-url URL") { |url| flags[:clone_url] = url }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
DEFAULT_CLONE_URL = "git@github.com:fluid-commerce/base-theme.git"
|
|
12
|
-
|
|
13
|
-
def call(args, _name)
|
|
14
|
-
name = args.first || ask_name
|
|
15
|
-
clone_url = options.flags[:clone_url] || DEFAULT_CLONE_URL
|
|
16
|
-
puts "Cloning theme from #{clone_url} into #{name}..."
|
|
17
|
-
|
|
18
|
-
clone(clone_url, name)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def self.help
|
|
22
|
-
"Initialize a new theme by cloning the base theme."
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def ask_name
|
|
28
|
-
CLI::UI::Prompt.ask("Theme name")
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def clone(url, name)
|
|
32
|
-
FluidCLI::Git.clone(url, name)
|
|
33
|
-
|
|
34
|
-
@ctx.root = File.join(@ctx.root, name)
|
|
35
|
-
|
|
36
|
-
begin
|
|
37
|
-
@ctx.rm_r(".git")
|
|
38
|
-
@ctx.rm_r(".github")
|
|
39
|
-
rescue Errno::ENOENT => e
|
|
40
|
-
@ctx.debug(e)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|