utopia 2.26.1 → 2.27.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 551c3c8b726ab7536833053e35adf3e29612e9aaf6d6bffbcf31d84ee544204a
4
- data.tar.gz: 6c178df22c4f1b513e247aef14eaeaa225e7fb63abce9c4f4a3e604191b4e5a6
3
+ metadata.gz: 4d142b51cf9876426ffa4bba1a96f824ee893ed59dbebc5d55da8f1aa617518e
4
+ data.tar.gz: 05765bc2e4761191eea490c934bf2379bc8593eec31bd93cca22b26ef2009b6e
5
5
  SHA512:
6
- metadata.gz: b62e1d6c5a6bb5c12e7eecb8f1ca28f448585cac3f169c9b4356a3e41b692149026015decd376c223ddc0eb4168aed0a11960356db95e05df57cfc7a0a735408
7
- data.tar.gz: f6d18b82e0e4afe2fa1817b847ee9bc5ebfe1e73e34b40d4a9f7f10c41fa1fd2bcf9bc27b8b0b02ab92ba8cc10705955a1e0c0d56299b8bdff1968a49590bf3f
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
- package_paths = expand_package_paths(package_root)
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
- log_exception(env, exception)
31
+ Console.warn(self, "An error occurred while processing the request.", error: exception)
46
32
 
47
- # If the error occurred while accessing the error handler, we finish with a fatal error:
48
- if env[Rack::PATH_INFO] == @location
49
- return fatal_error(env, exception)
50
- else
51
- begin
52
- # We do an internal redirection to the error location:
53
- error_request = env.merge(Rack::PATH_INFO => @location, Rack::REQUEST_METHOD => Rack::GET)
54
- error_response = @app.call(error_request)
55
-
56
- return [500, error_response[1], error_response[2]]
57
- rescue Exception
58
- # If redirection fails, we also finish with a fatal error:
59
- return fatal_error(env, exception)
60
- end
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
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2009-2024, by Samuel Williams.
5
5
 
6
6
  module Utopia
7
- VERSION = "2.26.1"
7
+ VERSION = "2.27.0"
8
8
  end
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://socketry.github.io/utopia).
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
@@ -0,0 +1,6 @@
1
+ # Releases
2
+
3
+ ## v2.27.0
4
+
5
+ - Improved error logging using `Console` gem.
6
+ - Only install `npm ls --production` dependencies into \`public/\_components
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.26.1
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-01-28 00:00:00.000000000 Z
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