sitepress-cli 3.0.1 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sitepress/cli.rb +33 -16
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ee2bd48a67bc6bf606f7357f65fc6c920d3fb60801a5b0caac5d5b13fa2203b
4
- data.tar.gz: a69b8b963170095cf9aa92f17bccaf98608597b7e750f8a459ed9c035e233d05
3
+ metadata.gz: 32ceede4b8b6e20838b244f3444cd761c4d6ce253327fa2724150f37ad8a98b4
4
+ data.tar.gz: 98f84c60444f09321246f374c1a75de6f5313ae40a13546ec5a6afb7dd1beed3
5
5
  SHA512:
6
- metadata.gz: 4b45a55f55d40164976522ede44ffc0681519a1fcdf818106ca75c68c7358d26dd8958254a690770c7a2e75dc2a8e134ed89ef2a46247343bfd56c1f9cdbf3f6
7
- data.tar.gz: 263ec19e3a608254385a8a6aa8450e8f11062981b6e76153e3e9d929f5d8a6042ea9eefacbea43ed4dab0dfcef8db0fbb4a547d7ad10781d23db281760107c88
6
+ metadata.gz: 561ef4a45a3443b81bbae7e2a0c012b530324ccbfca314191e5773b77807b9989651be47e1b645a2310500803cf41c723ee7adf600380d02a02d5ea198264d2c
7
+ data.tar.gz: 6b72a7a76e1f59b3a11a329029e17c7986e3a8a78fa7abd3bab9b8decfe4759f48edd0f871bf0b6464f0c89bfb31677c2fe2b4b84257d379f385a3c0c3031217
data/lib/sitepress/cli.rb CHANGED
@@ -3,26 +3,43 @@ require "thor"
3
3
  module Sitepress
4
4
  # Command line interface for compiling Sitepress sites.
5
5
  class CLI < Thor
6
- SERVER_DEFAULT_PORT = 8080
7
- SERVER_DEFAULT_BIND_ADDRESS = "0.0.0.0".freeze
8
- COMPILE_DEFAULT_TARGET_PATH = "./build".freeze
6
+ # Default port address for server port.
7
+ SERVER_PORT = 8080
8
+
9
+ # Default address is public to all IPs.
10
+ SERVER_BIND_ADDRESS = "0.0.0.0".freeze
11
+
12
+ # Default build path for compiler.
13
+ COMPILE_TARGET_PATH = "./build".freeze
14
+
15
+ # Display detailed error messages to the developer. Useful for development environments
16
+ # where the error should be displayed to the developer so they can debug errors.
17
+ SERVER_SITE_ERROR_REPORTING = true
18
+
19
+ # Reload the site between requests, useful for development environments when
20
+ # the site has to be rebuilt between requests. Disable in production environments
21
+ # to run the site faster.
22
+ SERVER_SITE_RELOADING = true
9
23
 
10
24
  include Thor::Actions
11
25
 
12
26
  source_root File.expand_path("../../../templates/default", __FILE__)
13
27
 
14
- option :bind_address, default: SERVER_DEFAULT_BIND_ADDRESS, aliases: :a
15
- option :port, default: SERVER_DEFAULT_PORT, aliases: :p, type: :numeric
28
+ option :bind_address, default: SERVER_BIND_ADDRESS, aliases: :a
29
+ option :port, default: SERVER_PORT, aliases: :p, type: :numeric
30
+ option :site_reloading, default: SERVER_SITE_RELOADING, aliases: :r, type: :boolean
31
+ option :site_error_reporting, default: SERVER_SITE_ERROR_REPORTING, aliases: :e, type: :boolean
16
32
  desc "server", "Run preview server"
17
33
  def server
18
- initialize!
19
-
20
- # Enable Sitepress web error reporting so users have more friendly
21
- # error messages instead of seeing a Rails exception.
22
- app.config.enable_sitepress_error_reporting = true
23
-
24
- # Enable reloading the site between requests so we can see changes.
25
- app.config.enable_site_reloading = true
34
+ # Now boot everything for the Rack server to pickup.
35
+ initialize! do |app|
36
+ # Enable Sitepress web error reporting so users have more friendly
37
+ # error messages instead of seeing a Rails exception.
38
+ app.config.enable_site_error_reporting = options.fetch("site_error_reporting")
39
+
40
+ # Enable reloading the site between requests so we can see changes.
41
+ app.config.enable_site_reloading = options.fetch("site_reloading")
42
+ end
26
43
 
27
44
  # This will use whatever server is found in the user's Gemfile.
28
45
  Rack::Server.start app: app,
@@ -30,7 +47,7 @@ module Sitepress
30
47
  Host: options.fetch("bind_address")
31
48
  end
32
49
 
33
- option :output_path, default: COMPILE_DEFAULT_TARGET_PATH, type: :string
50
+ option :output_path, default: COMPILE_TARGET_PATH, type: :string
34
51
  desc "compile", "Compile project into static pages"
35
52
  def compile
36
53
  initialize!
@@ -90,9 +107,9 @@ module Sitepress
90
107
  rails.config.assets.precompile
91
108
  end
92
109
 
93
- def initialize!
110
+ def initialize!(&block)
94
111
  require_relative "boot"
95
- app.initialize!
112
+ app.tap(&block).initialize!
96
113
  end
97
114
 
98
115
  def app
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitepress-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-24 00:00:00.000000000 Z
11
+ date: 2022-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 3.0.1
47
+ version: 3.1.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 3.0.1
54
+ version: 3.1.1
55
55
  description:
56
56
  email:
57
57
  - bradgessler@gmail.com