utopia 2.22.1 → 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: 5346625f0101f4b3dee975979109f2ee037f0f988ad4e2f229dd4bdbb5c11ccb
4
- data.tar.gz: ca3605f007fb7d6652ca0b25602932b42aa77e2a1b2a16370fcfcd2f634b6f23
3
+ metadata.gz: bad66abbb1a3bfd34ad266594c8f79b713f6289e1e2e572280459bdf3fe3ac9b
4
+ data.tar.gz: 04b1e9a3831cbbfe5551838725fd58ae71e5b218eeaa6ff708450e3a82c5007a
5
5
  SHA512:
6
- metadata.gz: b9e41aeefc40579975116bb42d231de217f5409970647a0c0ac25568fd339ecf934280245996e4b46c49b2426c396c5b43d6d0bf1d83113f9dae71f8fc289c9b
7
- data.tar.gz: 6d1daec542aec32e68fa1954bb8bd7f4d29130d88cab7247e62d1a955b91d4117628611239f7d72b94864aae65c8788b0902b844d6a793e05d87a1880f5e97f3
6
+ metadata.gz: acee0556abc970a44077e739b344cd25f962b559d7238ae11535154e500bb3a529220970a031f437a5d37debc44edd1a279131680ae6cab012d1a404680d4628
7
+ data.tar.gz: d6056af6f2a3b59b5539444d3e7be38f82528dee5ec33e71d1dd8076eeb750f7e7fb388b8d574462b86d216f87653bd0b4663ee5dbf5a0d2e882f14ae5d459b8
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- ntݪ}�D�b���ݷ��� �
2
- woQ�k�T
3
- ��c�a���f���*L���z~̄��R����T�֊�:K��vt�9�3��P;���l�&��gs�R�� ?��+�&�>U�b�-��+��NXa�٠��@����t�CZ"*���)&�{bGr$� �m�8X��:�{\�_�b��#�Y�{=��~�}J �
1
+ hV� n�h�N���!#�aFۮ��\c^.h�Y��>w%1[m*����#܌#&c)[��Z��Q,@(/gD녊���Bћ�ch\t��ŧ�A�0�e����"ut�[�W7�%R�� ���� ��� �5���Ֆ?j��i� )G8�˺�{�r�Q���%*�M0���[�d��U}�
2
+ A?���uz&jm��>�B�3[�͸������gV<�73E_���WϞ@��tɣ�]%FRj&&Y�F�̹pM� �[k����6V���Gjuwm����Q1le]�<*���k�¦�;����.�[F�����v��bgN
@@ -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
@@ -20,7 +20,7 @@ SETUP_ROOT = File.expand_path("../../setup", __dir__)
20
20
  CONFIGURATION_FILES = ['.gitignore', 'config.ru', 'config/environment.rb', 'falcon.rb', 'gems.rb', 'Guardfile', 'bake.rb', 'test/website.rb', 'fixtures/website.rb']
21
21
 
22
22
  # Directories that should exist:
23
- DIRECTORIES = ["config", "lib", "pages", "public", "bake", "test"]
23
+ DIRECTORIES = ["config", "lib", "pages", "public", "bake", "fixtures", "test"]
24
24
 
25
25
  # Directories that should be removed during upgrade process:
26
26
  OLD_PATHS = ["access_log", "cache", "tmp", "Rakefile", "tasks", ".bowerrc"]
@@ -64,6 +64,8 @@ def create(root: context.root)
64
64
 
65
65
  system("bundle", "install", chdir: root) or warn "could not install bundled gems"
66
66
 
67
+ context.lookup('utopia:environment:setup').call(root: root)
68
+
67
69
  if !File.exist?('.git')
68
70
  Console.logger.info(self) {"Setting up git repository..."}
69
71
 
@@ -72,8 +74,6 @@ def create(root: context.root)
72
74
  system("git", "commit", "-q", "-m", "Initial Utopia v#{Utopia::VERSION} site.", chdir: root) or warn "could not commit files"
73
75
  end
74
76
 
75
- context.lookup('utopia:environment:defaults').call(root)
76
-
77
77
  name = `git config user.name || whoami`.chomp
78
78
 
79
79
  puts
@@ -92,36 +92,37 @@ end
92
92
 
93
93
  # Upgrade an existing site to use the latest configuration files from the template.
94
94
  def upgrade(root: context.root)
95
- branch_name = "utopia-upgrade-#{Utopia::VERSION}"
96
-
97
- $stderr.puts "Upgrading #{destination_root}..."
98
-
99
- system('git', 'checkout', '-b', branch_name, chdir: root) or fail "could not change branch"
100
-
101
- DIRECTORIES.each do |directory|
102
- FileUtils.mkdir_p(File.join(root, directory))
103
- end
95
+ message = "Upgrade to utopia v#{Utopia::VERSION}."
104
96
 
105
- OLD_PATHS.each do |path|
106
- path = File.join(root, path)
107
- Console.logger.info(self) {"Removing #{path}..."}
108
- FileUtils.rm_rf(path)
109
- end
97
+ Console.logger.info(self) {"Upgrading #{root}..."}
110
98
 
111
- CONFIGURATION_FILES.each do |configuration_file|
112
- source_path = File.join(SITE_ROOT, configuration_file)
113
- 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
114
103
 
115
- 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
116
112
 
117
- FileUtils.copy_entry(source_path, destination_path)
118
- buffer = File.read(destination_path).gsub('$UTOPIA_VERSION', Utopia::VERSION)
119
- File.open(destination_path, "w") { |file| file.write(buffer) }
120
- end
121
-
122
- 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)
123
125
 
124
- begin
125
126
  # Stage any files that have been changed or removed:
126
127
  system("git", "add", "-u", chdir: root) or fail "could not add files"
127
128
 
@@ -130,26 +131,27 @@ def upgrade(root: context.root)
130
131
 
131
132
  move_static!(root)
132
133
  update_gemfile!(root)
133
-
134
- # Commit all changes:
135
- system("git", "commit", "-m", "Upgrade to utopia #{Utopia::VERSION}.", chdir: root) or fail "could not commit changes"
136
-
137
- # Checkout main..
138
- system("git", "checkout", "main", chdir: root) or fail "could not checkout main"
139
-
140
- # and merge:
141
- system("git", "merge", "--squash", "--no-commit", branch_name, chdir: root) or fail "could not merge changes"
142
- rescue => error
143
- Console.logger.error(self, error) {"Upgrade failed."}
144
-
145
- system("git", "checkout", "master", chdir: root)
146
- ensure
147
- system("git", "branch", "-D", branch_name, chdir: root)
148
134
  end
149
135
  end
150
136
 
151
137
  private
152
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
+
153
155
  # Move legacy `pages/_static` to `public/_static`.
154
156
  def move_static!(root)
155
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.1"
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.1
4
+ version: 2.22.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file