utopia 2.22.0 → 2.22.2

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: 64d6cd31c0780c6d2071157034b6d125da0b4e6c3649affafb9338208b0467b7
4
- data.tar.gz: 9092ab79ee6fb441051e1114fefbe41761aa5339d2eee574d588729e7ea5c479
3
+ metadata.gz: bad66abbb1a3bfd34ad266594c8f79b713f6289e1e2e572280459bdf3fe3ac9b
4
+ data.tar.gz: 04b1e9a3831cbbfe5551838725fd58ae71e5b218eeaa6ff708450e3a82c5007a
5
5
  SHA512:
6
- metadata.gz: cd49ec085295dded939c0da489dfc6bb64a97207032bd3cf177b39cf84f131f00b935c96173c2c6196c50032a07f4786b2312144b776cbadd4c05840b96f9f70
7
- data.tar.gz: 5fc0e4c878dfa11693481cbaf560d9024f69c66c48db29cc5722a56757d216449c4026e59f534578a784f6484a94ee0bd894831e93bcddeb26830dcadf17be2b
6
+ metadata.gz: acee0556abc970a44077e739b344cd25f962b559d7238ae11535154e500bb3a529220970a031f437a5d37debc44edd1a279131680ae6cab012d1a404680d4628
7
+ data.tar.gz: d6056af6f2a3b59b5539444d3e7be38f82528dee5ec33e71d1dd8076eeb750f7e7fb388b8d574462b86d216f87653bd0b4663ee5dbf5a0d2e882f14ae5d459b8
checksums.yaml.gz.sig CHANGED
Binary file
@@ -15,8 +15,8 @@ end
15
15
  # Setup default environemnts "testing" and "development".
16
16
  # @parameter root [String] The root directory of the project.
17
17
  def setup(root: context.root)
18
- defaults(name: "testing", root: root)
19
- defaults(name: "development", root: root)
18
+ defaults("testing", root: root)
19
+ defaults("development", root: root)
20
20
  end
21
21
 
22
22
  # Setup the defaults for a specific environment.
@@ -24,6 +24,7 @@ end
24
24
  # @parameter root [String] The root directory of the project.
25
25
  def defaults(name, root: context.root)
26
26
  update_environment(root, name) do |store|
27
+ Console.logger.info(self) {"Setting up defaults for environment #{name}..."}
27
28
  # Set some useful defaults for the environment.
28
29
  store['UTOPIA_SESSION_SECRET'] ||= SecureRandom.hex(40)
29
30
  end
@@ -33,22 +34,23 @@ end
33
34
  # @parameter name [String] The name of the environment to update.
34
35
  # @parameter variables [Hash(String, String)] A list of environment KEY=VALUE pairs to set.
35
36
  def update(name, root: context.root, **variables)
36
- update_environment(root, name) do |store|
37
- variables&.each do |variable|
38
- key, value = variable.split('=', 2)
37
+ update_environment(root, name) do |store, _, path|
38
+ variables&.each do |key, value|
39
+ # Ensure the key is a string...
40
+ key = key.to_s
39
41
 
40
- if value
41
- puts "ENV[#{key.inspect}] will default to #{value.inspect} unless otherwise specified."
42
+ if value && !value.empty?
43
+ Console.logger.info(self) {"ENV[#{key.inspect}] will default to #{value.inspect} unless otherwise specified."}
42
44
  store[key] = value
43
45
  else
44
- puts "ENV[#{key.inspect}] will be unset unless otherwise specified."
46
+ Console.logger.info(self) {"ENV[#{key.inspect}] will be unset unless otherwise specified."}
45
47
  store.delete(key)
46
48
  end
47
49
  end
48
50
 
49
51
  yield store if block_given?
50
52
 
51
- Console.logger.debug(self) do |buffer|
53
+ Console.logger.info(self) do |buffer|
52
54
  buffer.puts "Environment #{name} (#{path}):"
53
55
  store.roots.each do |key|
54
56
  value = store[key]
data/bake/utopia/site.rb CHANGED
@@ -9,6 +9,8 @@ def initialize(...)
9
9
 
10
10
  require 'fileutils'
11
11
  require 'find'
12
+
13
+ require_relative '../../lib/utopia/version'
12
14
  end
13
15
 
14
16
  # The path to the setup directory in the gem:
@@ -18,7 +20,7 @@ SETUP_ROOT = File.expand_path("../../setup", __dir__)
18
20
  CONFIGURATION_FILES = ['.gitignore', 'config.ru', 'config/environment.rb', 'falcon.rb', 'gems.rb', 'Guardfile', 'bake.rb', 'test/website.rb', 'fixtures/website.rb']
19
21
 
20
22
  # Directories that should exist:
21
- DIRECTORIES = ["config", "lib", "pages", "public", "bake", "test"]
23
+ DIRECTORIES = ["config", "lib", "pages", "public", "bake", "fixtures", "test"]
22
24
 
23
25
  # Directories that should be removed during upgrade process:
24
26
  OLD_PATHS = ["access_log", "cache", "tmp", "Rakefile", "tasks", ".bowerrc"]
@@ -62,6 +64,8 @@ def create(root: context.root)
62
64
 
63
65
  system("bundle", "install", chdir: root) or warn "could not install bundled gems"
64
66
 
67
+ context.lookup('utopia:environment:setup').call(root: root)
68
+
65
69
  if !File.exist?('.git')
66
70
  Console.logger.info(self) {"Setting up git repository..."}
67
71
 
@@ -70,8 +74,6 @@ def create(root: context.root)
70
74
  system("git", "commit", "-q", "-m", "Initial Utopia v#{Utopia::VERSION} site.", chdir: root) or warn "could not commit files"
71
75
  end
72
76
 
73
- context.lookup('utopia:environment:defaults').call(root)
74
-
75
77
  name = `git config user.name || whoami`.chomp
76
78
 
77
79
  puts
@@ -90,36 +92,37 @@ end
90
92
 
91
93
  # Upgrade an existing site to use the latest configuration files from the template.
92
94
  def upgrade(root: context.root)
93
- branch_name = "utopia-upgrade-#{Utopia::VERSION}"
94
-
95
- $stderr.puts "Upgrading #{destination_root}..."
96
-
97
- system('git', 'checkout', '-b', branch_name, chdir: root) or fail "could not change branch"
98
-
99
- DIRECTORIES.each do |directory|
100
- FileUtils.mkdir_p(File.join(root, directory))
101
- end
95
+ message = "Upgrade to utopia v#{Utopia::VERSION}."
102
96
 
103
- OLD_PATHS.each do |path|
104
- path = File.join(root, path)
105
- Console.logger.info(self) {"Removing #{path}..."}
106
- FileUtils.rm_rf(path)
107
- end
97
+ Console.logger.info(self) {"Upgrading #{root}..."}
108
98
 
109
- CONFIGURATION_FILES.each do |configuration_file|
110
- source_path = File.join(SITE_ROOT, configuration_file)
111
- destination_path = File.join(root, configuration_file)
99
+ commit_changes(root, message) do
100
+ DIRECTORIES.each do |directory|
101
+ FileUtils.mkdir_p(File.join(root, directory))
102
+ end
112
103
 
113
- Console.logger.info(self) {"Updating #{destination_path}..."}
104
+ OLD_PATHS.each do |path|
105
+ path = File.join(root, path)
106
+
107
+ if File.exist?(path)
108
+ Console.logger.info(self) {"Removing #{path}..."}
109
+ FileUtils.rm_rf(path)
110
+ end
111
+ end
114
112
 
115
- FileUtils.copy_entry(source_path, destination_path)
116
- buffer = File.read(destination_path).gsub('$UTOPIA_VERSION', Utopia::VERSION)
117
- File.open(destination_path, "w") { |file| file.write(buffer) }
118
- end
119
-
120
- context.lookup('environment:defaults').call(root)
113
+ CONFIGURATION_FILES.each do |configuration_file|
114
+ source_path = File.join(SITE_ROOT, configuration_file)
115
+ destination_path = File.join(root, configuration_file)
116
+
117
+ Console.logger.info(self) {"Updating #{destination_path}..."}
118
+
119
+ FileUtils.copy_entry(source_path, destination_path)
120
+ buffer = File.read(destination_path).gsub('$UTOPIA_VERSION', Utopia::VERSION)
121
+ File.open(destination_path, "w") { |file| file.write(buffer) }
122
+ end
123
+
124
+ context.lookup('utopia:environment:setup').call(root: root)
121
125
 
122
- begin
123
126
  # Stage any files that have been changed or removed:
124
127
  system("git", "add", "-u", chdir: root) or fail "could not add files"
125
128
 
@@ -128,26 +131,27 @@ def upgrade(root: context.root)
128
131
 
129
132
  move_static!(root)
130
133
  update_gemfile!(root)
131
-
132
- # Commit all changes:
133
- system("git", "commit", "-m", "Upgrade to utopia #{Utopia::VERSION}.", chdir: root) or fail "could not commit changes"
134
-
135
- # Checkout main..
136
- system("git", "checkout", "main", chdir: root) or fail "could not checkout main"
137
-
138
- # and merge:
139
- system("git", "merge", "--squash", "--no-commit", branch_name, chdir: root) or fail "could not merge changes"
140
- rescue => error
141
- Console.logger.error(self, error) {"Upgrade failed."}
142
-
143
- system("git", "checkout", "master", chdir: root)
144
- ensure
145
- system("git", "branch", "-D", branch_name, chdir: root)
146
134
  end
147
135
  end
148
136
 
149
137
  private
150
138
 
139
+ def commit_changes(root, message)
140
+ # Ensure the current branch is clean:
141
+ system("git", "diff-index", "--quiet", "HEAD", chdir: root) or fail "current branch is not clean"
142
+
143
+ begin
144
+ yield
145
+ rescue
146
+ # Clear out the changes:
147
+ system("git", "reset", "--hard", "HEAD", chdir: root) or fail "could not reset changes"
148
+ raise
149
+ end
150
+
151
+ # Commit all changes:
152
+ system("git", "commit", "-m", message, chdir: root) or fail "could not commit changes"
153
+ end
154
+
151
155
  # Move legacy `pages/_static` to `public/_static`.
152
156
  def move_static!(root)
153
157
  old_static_path = File.expand_path('pages/_static', root)
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2009-2022, by Samuel Williams.
5
5
 
6
6
  module Utopia
7
- VERSION = "2.22.0"
7
+ VERSION = "2.22.2"
8
8
  end
data/setup/site/Guardfile CHANGED
@@ -8,22 +8,3 @@ group :development do
8
8
  notification :off
9
9
  end
10
10
  end
11
-
12
- group :test do
13
- # guard :rspec, cmd: 'rspec' do
14
- # # Notifications can get a bit tedious:
15
- # # notification :off
16
-
17
- # # Re-run specs if they are changed:
18
- # watch(%r{^spec/.+_spec\.rb$})
19
- # watch('spec/spec_helper.rb') {'spec'}
20
-
21
- # # Run relevent specs if files in `lib/` or `pages/` are changed:
22
- # watch(%r{^lib/(.+)\.rb$}) {|match| "spec/lib/#{match[1]}_spec.rb" }
23
- # watch(%r{^pages/(.+)\.(rb|xnode)$}) {|match| "spec/pages/#{match[1]}_spec.rb"}
24
- # watch(%r{^pages/(.+)controller\.rb$}) {|match| Dir.glob("spec/pages/#{match[1]}*_spec.rb")}
25
-
26
- # # If any files in pages changes, ensure the website still works:
27
- # watch(%r{^pages/.*}) {'spec/website_spec.rb'}
28
- # end
29
- end
data/setup/site/config.ru CHANGED
@@ -14,7 +14,7 @@ else
14
14
  use Rack::ShowExceptions unless UTOPIA.testing?
15
15
  end
16
16
 
17
- # serve static files from public/
17
+ # Serve static files from "public" directory:
18
18
  use Utopia::Static, root: 'public'
19
19
 
20
20
  use Utopia::Redirection::Rewrite, {
@@ -40,10 +40,10 @@ use Utopia::Session,
40
40
 
41
41
  use Utopia::Controller
42
42
 
43
- # serve static files from pages/
43
+ # Serve static files from "pages" directory:
44
44
  use Utopia::Static
45
45
 
46
- # Serve dynamic content
46
+ # Serve dynamic content:
47
47
  use Utopia::Content
48
48
 
49
49
  run lambda { |env| [404, {}, []] }
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.22.0
4
+ version: 2.22.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -411,7 +411,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
411
411
  - !ruby/object:Gem::Version
412
412
  version: '0'
413
413
  requirements: []
414
- rubygems_version: 3.5.0.dev
414
+ rubygems_version: 3.4.6
415
415
  signing_key:
416
416
  specification_version: 4
417
417
  summary: Utopia is a framework for building dynamic content-driven websites.
metadata.gz.sig CHANGED
Binary file