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
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require "webrick"
|
|
3
|
-
|
|
4
|
-
module FluidCLI
|
|
5
|
-
module Theme
|
|
6
|
-
class MimeType < Struct.new(:name)
|
|
7
|
-
MIME_TYPES = WEBrick::HTTPUtils::DefaultMimeTypes.merge(
|
|
8
|
-
"liquid" => "text/x-liquid",
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
class << self
|
|
12
|
-
def by_filename(filename)
|
|
13
|
-
new(WEBrick::HTTPUtils.mime_type(filename.to_s, MIME_TYPES))
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def text?
|
|
18
|
-
/text/.match?(name) || json? || javascript?
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def json?
|
|
22
|
-
name == "application/json"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def javascript?
|
|
26
|
-
name == "application/javascript"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def to_s
|
|
30
|
-
name
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module FluidCLI
|
|
4
|
-
module Theme
|
|
5
|
-
module Navigation
|
|
6
|
-
class ResourceFetcher
|
|
7
|
-
def initialize(ctx, theme_id)
|
|
8
|
-
@ctx = ctx
|
|
9
|
-
@theme_id = theme_id
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def fetch(themeable_type)
|
|
13
|
-
_status, body = FluidCLI::API.new(@ctx).get(
|
|
14
|
-
path: "application_themes/#{@theme_id}/available_themeables",
|
|
15
|
-
query: URI.encode_www_form(themeable: themeable_type, per_page: 50),
|
|
16
|
-
)
|
|
17
|
-
body["available_themeables"] || []
|
|
18
|
-
rescue FluidCLI::API::APIRequestError => e
|
|
19
|
-
@ctx.debug("Failed to fetch #{themeable_type} themeables: #{e.message}")
|
|
20
|
-
[]
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module FluidCLI
|
|
4
|
-
module Theme
|
|
5
|
-
module Navigation
|
|
6
|
-
class RouteNavigator
|
|
7
|
-
STATIC_ROUTES = [
|
|
8
|
-
{ label: "Home", path: "/home" },
|
|
9
|
-
{ label: "Shop", path: "/home/shop" },
|
|
10
|
-
{ label: "Join / Sign Up", path: "/home/join" },
|
|
11
|
-
{ label: "Cart", path: "/cart" },
|
|
12
|
-
{ label: "Blog", path: "/home/blog" },
|
|
13
|
-
{ label: "Categories (all)", path: "/home/categories" },
|
|
14
|
-
{ label: "Collections (all)", path: "/home/collections" },
|
|
15
|
-
].freeze
|
|
16
|
-
|
|
17
|
-
RESOURCE_ROUTES = [
|
|
18
|
-
{ label: "Category", themeable_type: "category", path_template: "/home/categories/%<id>s", fallback_path: "/home/categories" },
|
|
19
|
-
{ label: "Collection", themeable_type: "collection", path_template: "/home/collections/%<id>s", fallback_path: "/home/collections" },
|
|
20
|
-
{ label: "Product", themeable_type: "product", path_template: "/home/products/%<id>s", fallback_path: "/home/shop" },
|
|
21
|
-
{ label: "Library", themeable_type: "library", path_template: "/home/libraries/%<id>s", fallback_path: "/home/libraries" },
|
|
22
|
-
{ label: "Post", themeable_type: "post", path_template: "/home/posts/%<id>s", fallback_path: "/home/blog" },
|
|
23
|
-
{ label: "Media", themeable_type: "medium", path_template: "/home/media/%<id>s", fallback_path: "/home/media" },
|
|
24
|
-
{ label: "Enrollment Pack", themeable_type: "enrollment_pack", path_template: "/home/enrollments/%<id>s", fallback_path: "/home/join" },
|
|
25
|
-
].freeze
|
|
26
|
-
|
|
27
|
-
def initialize(ctx, address, theme_id)
|
|
28
|
-
@ctx = ctx
|
|
29
|
-
@address = address
|
|
30
|
-
@theme_id = theme_id
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def navigate
|
|
34
|
-
path = select_destination
|
|
35
|
-
return unless path
|
|
36
|
-
|
|
37
|
-
url = "#{@address}#{path}"
|
|
38
|
-
@ctx.puts("\n{{bold:Navigate to: {{green:#{url}}}}}\n")
|
|
39
|
-
open_browser(url)
|
|
40
|
-
rescue => e
|
|
41
|
-
@ctx.debug("Navigation error: #{e.message}")
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
private
|
|
45
|
-
|
|
46
|
-
def select_destination
|
|
47
|
-
all_options = STATIC_ROUTES.map { |r| [:static, r] } + RESOURCE_ROUTES.map { |r| [:resource, r] }
|
|
48
|
-
type, data = CLI::UI::Prompt.ask("Select a route to navigate to") do |handler|
|
|
49
|
-
all_options.each { |t, r| handler.option(option_label(t, r)) { [t, r] } }
|
|
50
|
-
end
|
|
51
|
-
type == :static ? data[:path] : resolve_resource_path(data)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def option_label(type, data)
|
|
55
|
-
type == :static ? data[:label] : "#{data[:label]} (select specific)"
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def resolve_resource_path(route)
|
|
59
|
-
resources = ResourceFetcher.new(@ctx, @theme_id).fetch(route[:themeable_type])
|
|
60
|
-
|
|
61
|
-
if resources.empty?
|
|
62
|
-
@ctx.puts("{{yellow:No #{route[:label].downcase} resources found, navigating to listing page.}}")
|
|
63
|
-
return route[:fallback_path]
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
resource = CLI::UI::Prompt.ask("Select a #{route[:label].downcase}") do |handler|
|
|
67
|
-
resources.each { |r| handler.option(display_name(r)) { r } }
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
format(route[:path_template], id: resource["slug"])
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def display_name(resource)
|
|
74
|
-
resource["title"] || resource["id"].to_s
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def open_browser(url)
|
|
78
|
-
case RbConfig::CONFIG["host_os"]
|
|
79
|
-
when /darwin/ then system("open", url)
|
|
80
|
-
when /linux/ then system("xdg-open", url)
|
|
81
|
-
when /mswin|mingw|cygwin/ then system("start", "", url)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require "forwardable"
|
|
3
|
-
|
|
4
|
-
module FluidCLI
|
|
5
|
-
module Theme
|
|
6
|
-
module Presenters
|
|
7
|
-
class ThemePresenter
|
|
8
|
-
extend Forwardable
|
|
9
|
-
|
|
10
|
-
COLOR_BY_STATUS = {
|
|
11
|
-
"active" => "green",
|
|
12
|
-
"draft" => "yellow",
|
|
13
|
-
"development" => "blue",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
attr_reader :theme
|
|
17
|
-
|
|
18
|
-
def_delegators :theme, :id, :name, :status
|
|
19
|
-
|
|
20
|
-
def initialize(theme)
|
|
21
|
-
@theme = theme
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def to_s(mode = :long)
|
|
25
|
-
case mode
|
|
26
|
-
when :short
|
|
27
|
-
"{{bold:#{name}}}"
|
|
28
|
-
when :long
|
|
29
|
-
"{{green:##{id}}} {{bold:#{name}}}"
|
|
30
|
-
else
|
|
31
|
-
inspect
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def theme_tags
|
|
38
|
-
tags = ["{{#{tag_color}:[#{status}]}}"]
|
|
39
|
-
tags << "{{cyan:[yours]}}}}" if theme.current_development?
|
|
40
|
-
tags.join(" ")
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def tag_color
|
|
44
|
-
COLOR_BY_STATUS[status] || "italic"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "theme_presenter"
|
|
4
|
-
|
|
5
|
-
module FluidCLI
|
|
6
|
-
module Theme
|
|
7
|
-
module Presenters
|
|
8
|
-
class ThemesPresenter
|
|
9
|
-
SUPPORTED_STATUSES = %w(active draft development)
|
|
10
|
-
|
|
11
|
-
def initialize(ctx, root)
|
|
12
|
-
@ctx = ctx
|
|
13
|
-
@root = root
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def all
|
|
17
|
-
all_themes
|
|
18
|
-
.select { |theme| SUPPORTED_STATUSES.include?(theme.status) }
|
|
19
|
-
.sort_by { |theme| SUPPORTED_STATUSES.index(theme.status) }
|
|
20
|
-
.map { |theme| ThemePresenter.new(theme) }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
def all_themes
|
|
26
|
-
FluidCLI::Theme::Theme.all(@ctx, root: @root)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
data/lib/fluid_cli/theme/root.rb
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require_relative "file"
|
|
3
|
-
require "pathname"
|
|
4
|
-
|
|
5
|
-
module FluidCLI
|
|
6
|
-
module Theme
|
|
7
|
-
class Root
|
|
8
|
-
attr_reader :root, :ctx
|
|
9
|
-
|
|
10
|
-
def initialize(ctx, root:)
|
|
11
|
-
@ctx = ctx
|
|
12
|
-
@root = Pathname.new(root) if root
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def static_asset_files
|
|
16
|
-
glob("assets/*", raise_on_dir: true)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def liquid_files
|
|
20
|
-
glob("**/*.liquid")
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def json_files
|
|
24
|
-
glob("**/*.json")
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def glob(pattern, raise_on_dir: false)
|
|
28
|
-
root
|
|
29
|
-
.glob(pattern)
|
|
30
|
-
.select { |path| file?(path, raise_on_dir) }
|
|
31
|
-
.map { |path| File.new(path, root) }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def static_asset_file?(file)
|
|
35
|
-
static_asset_files.include?(self[file])
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def static_asset_paths
|
|
39
|
-
static_asset_files.map(&:relative_path)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def [](file)
|
|
43
|
-
case file
|
|
44
|
-
when File
|
|
45
|
-
file
|
|
46
|
-
when Pathname
|
|
47
|
-
File.new(file, root)
|
|
48
|
-
when String
|
|
49
|
-
File.new(root.join(file), root)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def file?(path, raise_on_dir = false)
|
|
54
|
-
if raise_on_dir && ::File.directory?(path)
|
|
55
|
-
@ctx.abort(@ctx.message("theme.serve.error.invalid_subdirectory", path.to_s))
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
::File.file?(path)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "json"
|
|
4
|
-
|
|
5
|
-
module FluidCLI
|
|
6
|
-
module Theme
|
|
7
|
-
|
|
8
|
-
class SchemaValidator
|
|
9
|
-
Diagnostic = Struct.new(:severity, :message, keyword_init: true)
|
|
10
|
-
|
|
11
|
-
VALID_SETTING_TYPES = %w[
|
|
12
|
-
text rich_text richtext textarea range select checkbox color text_alignment
|
|
13
|
-
color_background radio url image image_picker video_picker font_picker html
|
|
14
|
-
html_textarea link_list header blog posts posts_list products products_list
|
|
15
|
-
product product_list forms collections collections_list collection
|
|
16
|
-
collection_list categories categories_list category category_list enrollments
|
|
17
|
-
enrollments_list enrollment_pack enrollment enrollment_list
|
|
18
|
-
].freeze
|
|
19
|
-
|
|
20
|
-
def initialize(file, blocks_schema_type: "unknown")
|
|
21
|
-
@file = file
|
|
22
|
-
@blocks_schema_type = blocks_schema_type
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def validate
|
|
26
|
-
text = @file.read.to_s
|
|
27
|
-
diagnostics = []
|
|
28
|
-
|
|
29
|
-
match = text.match(/{% schema %}([\s\S]*?){% endschema %}/)
|
|
30
|
-
|
|
31
|
-
return diagnostics.map(&:to_h) unless match
|
|
32
|
-
|
|
33
|
-
json_text = match[1] || ""
|
|
34
|
-
|
|
35
|
-
schema = nil
|
|
36
|
-
begin
|
|
37
|
-
schema = JSON.parse(json_text)
|
|
38
|
-
rescue JSON::ParserError => e
|
|
39
|
-
diagnostics << Diagnostic.new(severity: "error", message: "Invalid JSON:\n #{e.message}")
|
|
40
|
-
return diagnostics.map(&:to_h)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
scan = JsonTokenScan.scan(json_text)
|
|
44
|
-
|
|
45
|
-
scan.duplicate_blocks_key_tokens.each do
|
|
46
|
-
diagnostics << Diagnostic.new(
|
|
47
|
-
severity: "error",
|
|
48
|
-
message: "Error in blocks: duplicate 'blocks' key in the same object"
|
|
49
|
-
)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
if schema.is_a?(Hash) && schema["settings"].is_a?(Array)
|
|
53
|
-
diagnostics.concat(validate_settings(schema["settings"]))
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
if @blocks_schema_type == "object" && !schema["blocks"].is_a?(Hash)
|
|
57
|
-
scan.blocks_array_value_tokens.each do
|
|
58
|
-
diagnostics << Diagnostic.new(
|
|
59
|
-
severity: "error",
|
|
60
|
-
message: "Error in blocks: expected an object ({})"
|
|
61
|
-
)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
if schema.is_a?(Hash) && schema.key?("blocks")
|
|
66
|
-
blocks = schema["blocks"]
|
|
67
|
-
|
|
68
|
-
case @blocks_schema_type
|
|
69
|
-
when "array"
|
|
70
|
-
if !blocks.is_a?(Array)
|
|
71
|
-
diagnostics << Diagnostic.new(
|
|
72
|
-
severity: "error",
|
|
73
|
-
message: "Error in blocks: expected an array ([])"
|
|
74
|
-
)
|
|
75
|
-
else
|
|
76
|
-
diagnostics.concat(validate_blocks(blocks))
|
|
77
|
-
end
|
|
78
|
-
when "object"
|
|
79
|
-
unless blocks.is_a?(Hash)
|
|
80
|
-
diagnostics << Diagnostic.new(
|
|
81
|
-
severity: "error",
|
|
82
|
-
message: "Error in blocks: expected an object ({})"
|
|
83
|
-
)
|
|
84
|
-
end
|
|
85
|
-
else # "unknown"
|
|
86
|
-
diagnostics.concat(validate_blocks(blocks)) if blocks.is_a?(Array)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
diagnostics.map(&:to_h)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
private
|
|
94
|
-
|
|
95
|
-
def validate_settings(settings)
|
|
96
|
-
diagnostics = []
|
|
97
|
-
ids = {}
|
|
98
|
-
|
|
99
|
-
settings.each_with_index do |setting, index|
|
|
100
|
-
setting ||= {}
|
|
101
|
-
setting = {} unless setting.is_a?(Hash)
|
|
102
|
-
|
|
103
|
-
id = setting["id"]
|
|
104
|
-
type = setting["type"]
|
|
105
|
-
|
|
106
|
-
if id.is_a?(String) && id.strip.empty?
|
|
107
|
-
diagnostics << Diagnostic.new(
|
|
108
|
-
severity: "error",
|
|
109
|
-
message: "Error in settings: id cannot be empty"
|
|
110
|
-
)
|
|
111
|
-
elsif id && ids.key?(id)
|
|
112
|
-
diagnostics << Diagnostic.new(
|
|
113
|
-
severity: "error",
|
|
114
|
-
message: "Error in settings: duplicate id '#{id}' found"
|
|
115
|
-
)
|
|
116
|
-
elsif id
|
|
117
|
-
ids[id] = true
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
if !type
|
|
121
|
-
diagnostics << Diagnostic.new(
|
|
122
|
-
severity: "error",
|
|
123
|
-
message: "Error in setting '#{id || index}': missing required field 'type'"
|
|
124
|
-
)
|
|
125
|
-
elsif !VALID_SETTING_TYPES.include?(type)
|
|
126
|
-
diagnostics << Diagnostic.new(
|
|
127
|
-
severity: "error",
|
|
128
|
-
message: "Invalid settings type: '#{type}'"
|
|
129
|
-
)
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
diagnostics
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def validate_blocks(blocks)
|
|
137
|
-
diagnostics = []
|
|
138
|
-
types = {}
|
|
139
|
-
|
|
140
|
-
blocks.each_with_index do |block, index|
|
|
141
|
-
block ||= {}
|
|
142
|
-
block = {} unless block.is_a?(Hash)
|
|
143
|
-
|
|
144
|
-
type = block["type"]
|
|
145
|
-
name = block["name"]
|
|
146
|
-
|
|
147
|
-
if !type
|
|
148
|
-
diagnostics << Diagnostic.new(
|
|
149
|
-
severity: "error",
|
|
150
|
-
message: "Error in blocks at index #{index}: missing required field 'type'"
|
|
151
|
-
)
|
|
152
|
-
elsif types.key?(type)
|
|
153
|
-
diagnostics << Diagnostic.new(
|
|
154
|
-
severity: "warning",
|
|
155
|
-
message: "Warning in blocks: duplicate type '#{type}' found"
|
|
156
|
-
)
|
|
157
|
-
else
|
|
158
|
-
types[type] = true
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
if !name
|
|
162
|
-
diagnostics << Diagnostic.new(
|
|
163
|
-
severity: "error",
|
|
164
|
-
message: "Error in block '#{type || index}': missing required field 'name'"
|
|
165
|
-
)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
if block["settings"].is_a?(Array)
|
|
169
|
-
diagnostics.concat(validate_settings(block["settings"]))
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
diagnostics
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
# Minimal token scanner:
|
|
177
|
-
# - detects duplicate "blocks" keys inside the same object
|
|
178
|
-
# - detects when "blocks" value starts with an array ([)
|
|
179
|
-
class JsonTokenScan
|
|
180
|
-
Token = Struct.new(:value)
|
|
181
|
-
|
|
182
|
-
attr_reader :duplicate_blocks_key_tokens, :blocks_array_value_tokens
|
|
183
|
-
|
|
184
|
-
def initialize
|
|
185
|
-
@duplicate_blocks_key_tokens = []
|
|
186
|
-
@blocks_array_value_tokens = []
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
def self.scan(json_text)
|
|
190
|
-
new.tap { |s| s.scan!(json_text) }
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
def scan!(s)
|
|
194
|
-
stack = []
|
|
195
|
-
pending_key = nil
|
|
196
|
-
i = 0
|
|
197
|
-
|
|
198
|
-
while i < s.length
|
|
199
|
-
ch = s.getbyte(i)
|
|
200
|
-
|
|
201
|
-
if whitespace?(ch)
|
|
202
|
-
i += 1
|
|
203
|
-
next
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
case ch
|
|
207
|
-
when 0x7B # {
|
|
208
|
-
stack << { type: :object, keys: {}, expecting_key: true }
|
|
209
|
-
pending_key = nil
|
|
210
|
-
i += 1
|
|
211
|
-
when 0x7D # }
|
|
212
|
-
stack.pop
|
|
213
|
-
pending_key = nil
|
|
214
|
-
i += 1
|
|
215
|
-
when 0x5B # [
|
|
216
|
-
if pending_key == "blocks"
|
|
217
|
-
@blocks_array_value_tokens << Token.new("blocks-array")
|
|
218
|
-
end
|
|
219
|
-
pending_key = nil
|
|
220
|
-
stack << { type: :array }
|
|
221
|
-
i += 1
|
|
222
|
-
when 0x5D # ]
|
|
223
|
-
stack.pop
|
|
224
|
-
pending_key = nil
|
|
225
|
-
i += 1
|
|
226
|
-
when 0x3A # :
|
|
227
|
-
# after colon, we are reading a value next
|
|
228
|
-
i += 1
|
|
229
|
-
when 0x2C # ,
|
|
230
|
-
if stack.last&.dig(:type) == :object
|
|
231
|
-
stack.last[:expecting_key] = true
|
|
232
|
-
end
|
|
233
|
-
pending_key = nil
|
|
234
|
-
i += 1
|
|
235
|
-
when 0x22 # "
|
|
236
|
-
str, i = read_string(s, i)
|
|
237
|
-
|
|
238
|
-
if stack.last&.dig(:type) == :object && stack.last[:expecting_key]
|
|
239
|
-
# this string is a key
|
|
240
|
-
if str == "blocks" && stack.last[:keys][str]
|
|
241
|
-
@duplicate_blocks_key_tokens << Token.new(str)
|
|
242
|
-
end
|
|
243
|
-
stack.last[:keys][str] = true
|
|
244
|
-
stack.last[:expecting_key] = false
|
|
245
|
-
pending_key = str
|
|
246
|
-
else
|
|
247
|
-
pending_key = nil
|
|
248
|
-
end
|
|
249
|
-
else
|
|
250
|
-
# literals / numbers / etc.
|
|
251
|
-
pending_key = nil
|
|
252
|
-
i += 1
|
|
253
|
-
end
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
def read_string(s, start)
|
|
258
|
-
i = start + 1
|
|
259
|
-
while i < s.length
|
|
260
|
-
break if s.getbyte(i) == 0x22 && s.getbyte(i - 1) != 0x5C
|
|
261
|
-
i += 1
|
|
262
|
-
end
|
|
263
|
-
[s[start + 1...i], i + 1]
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
def whitespace?(ch)
|
|
267
|
-
ch == 0x20 || ch == 0x0A || ch == 0x0D || ch == 0x09
|
|
268
|
-
end
|
|
269
|
-
end
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
class SchemaValidationError < StandardError; end
|
|
273
|
-
end
|
|
274
|
-
end
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module FluidCLI
|
|
4
|
-
module Theme
|
|
5
|
-
class Syncer
|
|
6
|
-
class Checksums
|
|
7
|
-
def initialize(theme)
|
|
8
|
-
@theme = theme
|
|
9
|
-
@checksum_by_key = {}
|
|
10
|
-
|
|
11
|
-
# Mutex used to coordinate changes in the checksums (shared accross `Syncer` threads)
|
|
12
|
-
@checksums_mutex = Mutex.new
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def has?(file)
|
|
16
|
-
checksum_by_key.key?(to_key(file))
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def file_has_changed?(file)
|
|
20
|
-
file.checksum != checksum_by_key[file.relative_path]
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def delete(file)
|
|
24
|
-
checksums_mutex.synchronize do
|
|
25
|
-
checksum_by_key.delete(to_key(file))
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def keys
|
|
30
|
-
checksum_by_key.keys
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def [](key)
|
|
34
|
-
checksum_by_key[key]
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def []=(key, value)
|
|
38
|
-
checksums_mutex.synchronize do
|
|
39
|
-
checksum_by_key[key] = value
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Generate .liquid asset files are reported twice in checksum:
|
|
44
|
-
# once of generated, once for .liquid. We only keep the .liquid, that's the one we have
|
|
45
|
-
# on disk.
|
|
46
|
-
def reject_duplicated_checksums!
|
|
47
|
-
checksums_mutex.synchronize do
|
|
48
|
-
checksum_by_key.reject! { |key, _| checksum_by_key.key?("#{key}.liquid") }
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
private
|
|
53
|
-
|
|
54
|
-
def to_key(file)
|
|
55
|
-
theme[file].relative_path
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Private getters only used in unit tests
|
|
59
|
-
|
|
60
|
-
attr_reader :checksum_by_key
|
|
61
|
-
attr_reader :theme
|
|
62
|
-
attr_reader :checksums_mutex
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "forwardable"
|
|
4
|
-
|
|
5
|
-
module FluidCLI
|
|
6
|
-
module Theme
|
|
7
|
-
class Syncer
|
|
8
|
-
class Downloader
|
|
9
|
-
extend Forwardable
|
|
10
|
-
|
|
11
|
-
attr_reader :syncer, :ctx
|
|
12
|
-
|
|
13
|
-
def_delegators :syncer,
|
|
14
|
-
:ctx,
|
|
15
|
-
:checksums,
|
|
16
|
-
:get_theme_resources!,
|
|
17
|
-
:wait!
|
|
18
|
-
|
|
19
|
-
def initialize(syncer, delete, &update_progress_bar_block)
|
|
20
|
-
@syncer = syncer
|
|
21
|
-
@delete = delete
|
|
22
|
-
@update_progress_bar_block = update_progress_bar_block
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def download!
|
|
26
|
-
get_theme_resources!
|
|
27
|
-
|
|
28
|
-
if delete_local_files?
|
|
29
|
-
to_be_deleted.each { |file| delete(file) }
|
|
30
|
-
end
|
|
31
|
-
wait!(&@update_progress_bar_block)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
def delete(file)
|
|
37
|
-
ctx.debug("[#{self.class}] rm #{file.relative_path}")
|
|
38
|
-
file.delete
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def delete_local_files?
|
|
42
|
-
@delete
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def to_be_deleted
|
|
46
|
-
@to_be_deleted ||= syncer
|
|
47
|
-
.theme
|
|
48
|
-
.theme_files
|
|
49
|
-
.reject { |file| checksums.has?(file) }.uniq
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|