utopia 2.26.0 → 2.27.0
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
- checksums.yaml.gz.sig +0 -0
- data/bake/utopia/node.rb +29 -1
- data/lib/utopia/exceptions/handler.rb +19 -54
- data/lib/utopia/exceptions/mailer.rb +22 -0
- data/lib/utopia/version.rb +1 -1
- data/readme.md +13 -1
- data/releases.md +6 -0
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d142b51cf9876426ffa4bba1a96f824ee893ed59dbebc5d55da8f1aa617518e
|
4
|
+
data.tar.gz: 05765bc2e4761191eea490c934bf2379bc8593eec31bd93cca22b26ef2009b6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b06e3f6d0e6f2ccd664bb1e3eab879eb9aa6a5e7dda45983132dab7902c29f87f6f2723732da3e3848a2145c10022645485454125fb0a2c03ce585ae81f66c5
|
7
|
+
data.tar.gz: 4c916eef819a9760e8469d362daba187c168f8e5f5dee799fa5900c1a8a32f2b30aaccf2f8c0f3a263a4e470c92f8d599af6b99d3bbd80b0227d3a73d7869e99
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bake/utopia/node.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2016-2025, by Samuel Williams.
|
5
5
|
|
6
|
+
NPM = ENV["NPM"] || "npm"
|
7
|
+
|
6
8
|
def update
|
7
9
|
require "fileutils"
|
8
10
|
require "utopia/path"
|
@@ -17,7 +19,11 @@ def update
|
|
17
19
|
|
18
20
|
install_root = root + "public/_components"
|
19
21
|
|
20
|
-
|
22
|
+
# Fetch only production dependencies using `npm ls --production`
|
23
|
+
production_packages = fetch_production_packages(package_root)
|
24
|
+
package_paths = expand_package_paths(package_root).select do |path|
|
25
|
+
production_packages.include?(path.basename.to_s)
|
26
|
+
end
|
21
27
|
|
22
28
|
package_paths.each do |package_path|
|
23
29
|
package_directory = package_path.relative_path_from(package_root)
|
@@ -41,6 +47,28 @@ end
|
|
41
47
|
|
42
48
|
private
|
43
49
|
|
50
|
+
def fetch_production_packages(package_root)
|
51
|
+
require "json"
|
52
|
+
require "open3"
|
53
|
+
|
54
|
+
stdout, _status = Open3.capture2(NPM, "ls", "--production", "--json", chdir: package_root.to_s)
|
55
|
+
|
56
|
+
json = JSON.parse(stdout)
|
57
|
+
|
58
|
+
flatten_package_dependencies(json).sort.uniq
|
59
|
+
end
|
60
|
+
|
61
|
+
def flatten_package_dependencies(json, into = [])
|
62
|
+
if json["dependencies"]
|
63
|
+
json["dependencies"].each do |name, details|
|
64
|
+
into << name
|
65
|
+
flatten_package_dependencies(details, into)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
return into
|
70
|
+
end
|
71
|
+
|
44
72
|
def expand_package_paths(root, into = [])
|
45
73
|
paths = root.children.select(&:directory?)
|
46
74
|
|
@@ -3,6 +3,8 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2014-2025, by Samuel Williams.
|
5
5
|
|
6
|
+
require 'console'
|
7
|
+
|
6
8
|
module Utopia
|
7
9
|
module Exceptions
|
8
10
|
# A middleware which catches exceptions and performs an internal redirect.
|
@@ -22,68 +24,31 @@ module Utopia
|
|
22
24
|
super
|
23
25
|
end
|
24
26
|
|
25
|
-
# Generate a very simple fatal error response. This function should be unlikely to fail. Additionally, it generates a lowest common denominator response which should be suitable as a response to any kind of request. Ideally, this response is also not good or useful for any kind of higher level browser or API client, as this is not a normal error path but one that represents broken behaviour.
|
26
|
-
def fatal_error(env, exception)
|
27
|
-
body = StringIO.new
|
28
|
-
|
29
|
-
write_exception_to_stream(body, env, exception)
|
30
|
-
body.rewind
|
31
|
-
|
32
|
-
return [500, {HTTP::CONTENT_TYPE => "text/plain"}, body]
|
33
|
-
end
|
34
|
-
|
35
|
-
def log_exception(env, exception)
|
36
|
-
# An error has occurred, log it:
|
37
|
-
output = env["rack.errors"] || $stderr
|
38
|
-
write_exception_to_stream(output, env, exception, true)
|
39
|
-
end
|
40
|
-
|
41
27
|
def call(env)
|
42
28
|
begin
|
43
29
|
return @app.call(env)
|
44
30
|
rescue Exception => exception
|
45
|
-
|
31
|
+
Console.warn(self, "An error occurred while processing the request.", error: exception)
|
46
32
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
33
|
+
begin
|
34
|
+
# We do an internal redirection to the error location:
|
35
|
+
error_request = env.merge(
|
36
|
+
Rack::PATH_INFO => @location,
|
37
|
+
Rack::REQUEST_METHOD => Rack::GET,
|
38
|
+
"utopia.exception" => exception,
|
39
|
+
)
|
40
|
+
|
41
|
+
error_response = @app.call(error_request)
|
42
|
+
error_response[0] = 500
|
43
|
+
|
44
|
+
return error_response
|
45
|
+
rescue Exception => exception
|
46
|
+
# If redirection fails, we also finish with a fatal error:
|
47
|
+
Console.error(self, "An error occurred while invoking the error handler.", error: exception)
|
48
|
+
return [500, {"content-type" => "text/plain"}, ["An error occurred while processing the request."]]
|
61
49
|
end
|
62
50
|
end
|
63
51
|
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def write_exception_to_stream(stream, env, exception, include_backtrace = false)
|
68
|
-
buffer = []
|
69
|
-
|
70
|
-
buffer << "While requesting resource #{env[Rack::PATH_INFO].inspect}, a fatal error occurred:"
|
71
|
-
|
72
|
-
while exception != nil
|
73
|
-
buffer << "\t#{exception.class.name}: #{exception.to_s}"
|
74
|
-
|
75
|
-
if include_backtrace
|
76
|
-
exception.backtrace.each do |line|
|
77
|
-
buffer << "\t\t#{line}"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
exception = exception.cause
|
82
|
-
end
|
83
|
-
|
84
|
-
# We do this in one go so that lines don't get mixed up.
|
85
|
-
stream.puts buffer.join("\n")
|
86
|
-
end
|
87
52
|
end
|
88
53
|
end
|
89
54
|
end
|
@@ -66,6 +66,21 @@ module Utopia
|
|
66
66
|
:user_agent,
|
67
67
|
]
|
68
68
|
|
69
|
+
ENV_KEYS = [
|
70
|
+
"PATH_INFO",
|
71
|
+
"REQUEST_METHOD",
|
72
|
+
"REQUEST_PATH",
|
73
|
+
"REQUEST_URI",
|
74
|
+
"SCRIPT_NAME",
|
75
|
+
"QUERY_STRING",
|
76
|
+
"SERVER_PROTOCOL",
|
77
|
+
"SERVER_NAME",
|
78
|
+
"SERVER_PORT",
|
79
|
+
"REMOTE_ADDR",
|
80
|
+
"CONTENT_TYPE",
|
81
|
+
"CONTENT_LENGTH",
|
82
|
+
]
|
83
|
+
|
69
84
|
def generate_backtrace(io, exception, prefix: "Exception")
|
70
85
|
io.puts "#{prefix} #{exception.class.name}: #{exception.to_s}"
|
71
86
|
|
@@ -104,6 +119,13 @@ module Utopia
|
|
104
119
|
|
105
120
|
io.puts
|
106
121
|
|
122
|
+
ENV_KEYS.each do |key|
|
123
|
+
value = env[key]
|
124
|
+
io.puts "env[#{key.inspect}]: #{value.inspect}"
|
125
|
+
end
|
126
|
+
|
127
|
+
io.puts
|
128
|
+
|
107
129
|
env.select{|key,_| key.start_with? "HTTP_"}.each do |key, value|
|
108
130
|
io.puts "#{key}: #{value.inspect}"
|
109
131
|
end
|
data/lib/utopia/version.rb
CHANGED
data/readme.md
CHANGED
@@ -13,7 +13,19 @@ Utopia is a website generation framework which provides a robust set of tools to
|
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
16
|
-
Please see the [project documentation](https://
|
16
|
+
Please see the [project documentation](https://github.com/ioquatix/utopia) for more details.
|
17
|
+
|
18
|
+
- [Getting Started](https://github.com/ioquatix/utopiaguides/getting-started/index) - This guide explains how to set up a `utopia` website for local development and deployment.
|
19
|
+
|
20
|
+
- [Middleware](https://github.com/ioquatix/utopiaguides/middleware/index) - This guide gives an overview of the different Rack middleware used by Utopia.
|
21
|
+
|
22
|
+
- [Server Setup](https://github.com/ioquatix/utopiaguides/server-setup/index) - This guide explains how to deploy a `utopia` web application.
|
23
|
+
|
24
|
+
- [Installing JavaScript Libraries](https://github.com/ioquatix/utopiaguides/integrating-with-javascript/index) - Utopia integrates with Yarn and provides a [bake task](https://github.com/ioquatix/bake) to simplify deployment packages distributed using `yarn` that implement the `dist` sub-directory convention.
|
25
|
+
|
26
|
+
- [What is XNode?](https://github.com/ioquatix/utopiaguides/what-is-xnode/index) - This guide explains the `xnode` view layer and how it can be used to build efficient websites.
|
27
|
+
|
28
|
+
- [Updating Utopia](https://github.com/ioquatix/utopiaguides/updating-utopia/index) - This guide explains how to update existing `utopia` websites.
|
17
29
|
|
18
30
|
## See Also
|
19
31
|
|
data/releases.md
ADDED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -40,7 +40,7 @@ cert_chain:
|
|
40
40
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
41
41
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
42
42
|
-----END CERTIFICATE-----
|
43
|
-
date: 2025-
|
43
|
+
date: 2025-02-12 00:00:00.000000000 Z
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: bake
|
@@ -277,6 +277,7 @@ files:
|
|
277
277
|
- lib/utopia/version.rb
|
278
278
|
- license.md
|
279
279
|
- readme.md
|
280
|
+
- releases.md
|
280
281
|
- setup/server/git/hooks/post-receive
|
281
282
|
- setup/site/.gitignore
|
282
283
|
- setup/site/Guardfile
|
metadata.gz.sig
CHANGED
Binary file
|