Class: ShopifyCLI::Theme::DevServer
- Inherits:
-
Object
- Object
- ShopifyCLI::Theme::DevServer
- Includes:
- Singleton
- Defined in:
- lib/shopify_cli/theme/dev_server.rb,
lib/shopify_cli/theme/dev_server/sse.rb,
lib/shopify_cli/theme/dev_server/proxy.rb,
lib/shopify_cli/theme/dev_server/errors.rb,
lib/shopify_cli/theme/dev_server/watcher.rb,
lib/shopify_cli/theme/dev_server/cdn_fonts.rb,
lib/shopify_cli/theme/dev_server/hot_reload.rb,
lib/shopify_cli/theme/dev_server/web_server.rb,
lib/shopify_cli/theme/dev_server/header_hash.rb,
lib/shopify_cli/theme/dev_server/reload_mode.rb,
lib/shopify_cli/theme/dev_server/local_assets.rb,
lib/shopify_cli/theme/dev_server/remote_watcher.rb,
lib/shopify_cli/theme/dev_server/certificate_manager.rb,
lib/shopify_cli/theme/dev_server/proxy_param_builder.rb,
lib/shopify_cli/theme/dev_server/hooks/file_change_hook.rb,
lib/shopify_cli/theme/dev_server/hot_reload/sections_index.rb,
lib/shopify_cli/theme/dev_server/hot_reload/script_injector.rb,
lib/shopify_cli/theme/dev_server/hot_reload/remote_file_deleter.rb,
lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb,
lib/shopify_cli/theme/dev_server/remote_watcher/json_files_update_job.rb
Direct Known Subclasses
Defined Under Namespace
Modules: Hooks, WEBrickGenericServerThreadJoinWithTimeout Classes: CdnFonts, CertificateManager, Error, HeaderHash, HotReload, LocalAssets, Proxy, ProxyParamBuilder, ReloadMode, RemoteWatcher, SSE, Watcher, WebServer
Constant Summary collapse
- HOP_BY_HOP_HEADERS =
[ "connection", "keep-alive", "proxy-authenticate", "proxy-authorization", "te", "trailer", "transfer-encoding", "upgrade", "content-security-policy", "content-length", ]
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#editor_sync ⇒ Object
readonly
Returns the value of attribute editor_sync.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#ignores ⇒ Object
readonly
Returns the value of attribute ignores.
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#poll ⇒ Object
readonly
Returns the value of attribute poll.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#stable ⇒ Object
readonly
Returns the value of attribute stable.
-
#stopped ⇒ Object
readonly
Returns the value of attribute stopped.
-
#theme_identifier ⇒ Object
readonly
Returns the value of attribute theme_identifier.
Class Method Summary collapse
- .start(ctx, root, host: "127.0.0.1", theme: nil, port: 9292, poll: false, editor_sync: false, overwrite_json: false, stable: false, mode: ReloadMode.default, includes: nil, ignores: nil, &block) ⇒ Object
- .stop ⇒ Object
Instance Method Summary collapse
-
#setup(ctx, root, host, theme_identifier, port, poll, editor_sync, overwrite_json, stable, mode, includes, ignores, &block) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- #start ⇒ Object
- #stop(signal = nil) ⇒ Object
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def app @app end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def block @block end |
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def ctx @ctx end |
#editor_sync ⇒ Object (readonly)
Returns the value of attribute editor_sync.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def editor_sync @editor_sync end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def host @host end |
#ignores ⇒ Object (readonly)
Returns the value of attribute ignores.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def ignores @ignores end |
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def includes @includes end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def mode @mode end |
#poll ⇒ Object (readonly)
Returns the value of attribute poll.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def poll @poll end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def port @port end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def root @root end |
#stable ⇒ Object (readonly)
Returns the value of attribute stable.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def stable @stable end |
#stopped ⇒ Object (readonly)
Returns the value of attribute stopped.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def stopped @stopped end |
#theme_identifier ⇒ Object (readonly)
Returns the value of attribute theme_identifier.
32 33 34 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 32 def theme_identifier @theme_identifier end |
Class Method Details
.start(ctx, root, host: "127.0.0.1", theme: nil, port: 9292, poll: false, editor_sync: false, overwrite_json: false, stable: false, mode: ReloadMode.default, includes: nil, ignores: nil, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 36 def start( ctx, root, host: "127.0.0.1", theme: nil, port: 9292, poll: false, editor_sync: false, overwrite_json: false, stable: false, mode: ReloadMode.default, includes: nil, ignores: nil, &block ) instance.setup( ctx, root, host, theme, port, poll, editor_sync, overwrite_json, stable, mode, includes, ignores, &block ) instance.start end |
.stop ⇒ Object
69 70 71 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 69 def stop instance.stop end |
Instance Method Details
#setup(ctx, root, host, theme_identifier, port, poll, editor_sync, overwrite_json, stable, mode, includes, ignores, &block) ⇒ Object
rubocop:disable Metrics/ParameterLists
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 75 def setup( ctx, root, host, theme_identifier, port, poll, editor_sync, overwrite_json, stable, mode, includes, ignores, &block ) @ctx = ctx @root = root @host = host @theme_identifier = theme_identifier @port = port @poll = poll @editor_sync = editor_sync @overwrite_json = overwrite_json @stable = stable @mode = mode @includes = includes @ignores = ignores @block = block end |
#start ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/shopify_cli/theme/dev_server.rb', line 105 def start sync_theme # Handle process stop trap("INT") { stop("SIGINT") } trap("TERM") { stop("SIGTERM") } # Setup the middleware stack. Mimics Rack::Builder / config.ru, but in reverse order @app = middleware_stack # Start development server setup_server start_server teardown_server rescue ShopifyCLI::API::APIRequestForbiddenError, ShopifyCLI::API::APIRequestUnauthorizedError ctx.abort() rescue Errno::EADDRINUSE ctx.abort(, ) rescue Errno::EADDRNOTAVAIL ctx.abort() end |