utopia 2.21.0 → 2.22.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/environment.rb +90 -0
- data/bake/utopia/server.rb +61 -0
- data/bake/utopia/site.rb +188 -0
- data/lib/utopia/version.rb +1 -1
- data/license.md +2 -2
- data/readme.md +1 -1
- data/setup/site/.gitignore +0 -1
- data/setup/site/Guardfile +13 -13
- data/setup/site/config/{README.md → readme.md} +0 -0
- data/setup/site/config/sus.rb +10 -0
- data/setup/site/fixtures/website.rb +39 -0
- data/setup/site/gems.rb +6 -8
- data/setup/site/{README.md → readme.md} +0 -0
- data/setup/site/test/website.rb +28 -0
- data.tar.gz.sig +0 -0
- metadata +27 -32
- metadata.gz.sig +0 -0
- data/bake/utopia/test.rb +0 -12
- data/bin/utopia +0 -25
- data/lib/utopia/command/environment.rb +0 -76
- data/lib/utopia/command/server.rb +0 -100
- data/lib/utopia/command/site.rb +0 -217
- data/lib/utopia/command.rb +0 -51
- data/setup/site/.rspec +0 -4
- data/setup/site/spec/spec_helper.rb +0 -19
- data/setup/site/spec/website_context.rb +0 -57
- data/setup/site/spec/website_spec.rb +0 -28
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
- Huba Nagy
|
9
9
|
- Michael Adams
|
10
10
|
- Olle Jonsson
|
11
|
-
-
|
11
|
+
- Pierre Montelle
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain:
|
@@ -41,7 +41,7 @@ cert_chain:
|
|
41
41
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
42
42
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
43
43
|
-----END CERTIFICATE-----
|
44
|
-
date:
|
44
|
+
date: 2023-02-21 00:00:00.000000000 Z
|
45
45
|
dependencies:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: concurrent-ruby
|
@@ -49,14 +49,14 @@ dependencies:
|
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '1.
|
52
|
+
version: '1.2'
|
53
53
|
type: :runtime
|
54
54
|
prerelease: false
|
55
55
|
version_requirements: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '1.
|
59
|
+
version: '1.2'
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: console
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,7 +212,7 @@ dependencies:
|
|
212
212
|
- !ruby/object:Gem::Version
|
213
213
|
version: '0.1'
|
214
214
|
- !ruby/object:Gem::Dependency
|
215
|
-
name: async-
|
215
|
+
name: async-websocket
|
216
216
|
requirement: !ruby/object:Gem::Requirement
|
217
217
|
requirements:
|
218
218
|
- - ">="
|
@@ -226,7 +226,7 @@ dependencies:
|
|
226
226
|
- !ruby/object:Gem::Version
|
227
227
|
version: '0'
|
228
228
|
- !ruby/object:Gem::Dependency
|
229
|
-
name:
|
229
|
+
name: bake
|
230
230
|
requirement: !ruby/object:Gem::Requirement
|
231
231
|
requirements:
|
232
232
|
- - ">="
|
@@ -240,7 +240,7 @@ dependencies:
|
|
240
240
|
- !ruby/object:Gem::Version
|
241
241
|
version: '0'
|
242
242
|
- !ruby/object:Gem::Dependency
|
243
|
-
name:
|
243
|
+
name: bundler
|
244
244
|
requirement: !ruby/object:Gem::Requirement
|
245
245
|
requirements:
|
246
246
|
- - ">="
|
@@ -254,7 +254,7 @@ dependencies:
|
|
254
254
|
- !ruby/object:Gem::Version
|
255
255
|
version: '0'
|
256
256
|
- !ruby/object:Gem::Dependency
|
257
|
-
name:
|
257
|
+
name: covered
|
258
258
|
requirement: !ruby/object:Gem::Requirement
|
259
259
|
requirements:
|
260
260
|
- - ">="
|
@@ -268,7 +268,7 @@ dependencies:
|
|
268
268
|
- !ruby/object:Gem::Version
|
269
269
|
version: '0'
|
270
270
|
- !ruby/object:Gem::Dependency
|
271
|
-
name:
|
271
|
+
name: falcon
|
272
272
|
requirement: !ruby/object:Gem::Requirement
|
273
273
|
requirements:
|
274
274
|
- - ">="
|
@@ -282,7 +282,7 @@ dependencies:
|
|
282
282
|
- !ruby/object:Gem::Version
|
283
283
|
version: '0'
|
284
284
|
- !ruby/object:Gem::Dependency
|
285
|
-
name:
|
285
|
+
name: sus
|
286
286
|
requirement: !ruby/object:Gem::Requirement
|
287
287
|
requirements:
|
288
288
|
- - ">="
|
@@ -296,37 +296,33 @@ dependencies:
|
|
296
296
|
- !ruby/object:Gem::Version
|
297
297
|
version: '0'
|
298
298
|
- !ruby/object:Gem::Dependency
|
299
|
-
name:
|
299
|
+
name: sus-fixtures-async-http
|
300
300
|
requirement: !ruby/object:Gem::Requirement
|
301
301
|
requirements:
|
302
|
-
- - "
|
302
|
+
- - ">="
|
303
303
|
- !ruby/object:Gem::Version
|
304
|
-
version: '
|
304
|
+
version: '0'
|
305
305
|
type: :development
|
306
306
|
prerelease: false
|
307
307
|
version_requirements: !ruby/object:Gem::Requirement
|
308
308
|
requirements:
|
309
|
-
- - "
|
309
|
+
- - ">="
|
310
310
|
- !ruby/object:Gem::Version
|
311
|
-
version: '
|
311
|
+
version: '0'
|
312
312
|
description:
|
313
313
|
email:
|
314
|
-
executables:
|
315
|
-
- utopia
|
314
|
+
executables: []
|
316
315
|
extensions: []
|
317
316
|
extra_rdoc_files: []
|
318
317
|
files:
|
319
318
|
- bake/utopia.rb
|
319
|
+
- bake/utopia/environment.rb
|
320
320
|
- bake/utopia/node.rb
|
321
|
+
- bake/utopia/server.rb
|
321
322
|
- bake/utopia/shell.rb
|
323
|
+
- bake/utopia/site.rb
|
322
324
|
- bake/utopia/static.rb
|
323
|
-
- bake/utopia/test.rb
|
324
|
-
- bin/utopia
|
325
325
|
- lib/utopia.rb
|
326
|
-
- lib/utopia/command.rb
|
327
|
-
- lib/utopia/command/environment.rb
|
328
|
-
- lib/utopia/command/server.rb
|
329
|
-
- lib/utopia/command/site.rb
|
330
326
|
- lib/utopia/content.rb
|
331
327
|
- lib/utopia/content/document.rb
|
332
328
|
- lib/utopia/content/link.rb
|
@@ -372,14 +368,14 @@ files:
|
|
372
368
|
- readme.md
|
373
369
|
- setup/server/git/hooks/post-receive
|
374
370
|
- setup/site/.gitignore
|
375
|
-
- setup/site/.rspec
|
376
371
|
- setup/site/Guardfile
|
377
|
-
- setup/site/README.md
|
378
372
|
- setup/site/bake.rb
|
379
373
|
- setup/site/config.ru
|
380
|
-
- setup/site/config/README.md
|
381
374
|
- setup/site/config/environment.rb
|
375
|
+
- setup/site/config/readme.md
|
376
|
+
- setup/site/config/sus.rb
|
382
377
|
- setup/site/falcon.rb
|
378
|
+
- setup/site/fixtures/website.rb
|
383
379
|
- setup/site/gems.rb
|
384
380
|
- setup/site/lib/readme.txt
|
385
381
|
- setup/site/pages/_heading.xnode
|
@@ -393,9 +389,8 @@ files:
|
|
393
389
|
- setup/site/public/_static/utopia-background.svg
|
394
390
|
- setup/site/public/_static/utopia.svg
|
395
391
|
- setup/site/public/readme.txt
|
396
|
-
- setup/site/
|
397
|
-
- setup/site/
|
398
|
-
- setup/site/spec/website_spec.rb
|
392
|
+
- setup/site/readme.md
|
393
|
+
- setup/site/test/website.rb
|
399
394
|
homepage: https://github.com/ioquatix/utopia
|
400
395
|
licenses:
|
401
396
|
- MIT
|
@@ -409,14 +404,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
409
404
|
requirements:
|
410
405
|
- - ">="
|
411
406
|
- !ruby/object:Gem::Version
|
412
|
-
version: '2.
|
407
|
+
version: '2.7'
|
413
408
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
414
409
|
requirements:
|
415
410
|
- - ">="
|
416
411
|
- !ruby/object:Gem::Version
|
417
412
|
version: '0'
|
418
413
|
requirements: []
|
419
|
-
rubygems_version: 3.
|
414
|
+
rubygems_version: 3.5.0.dev
|
420
415
|
signing_key:
|
421
416
|
specification_version: 4
|
422
417
|
summary: Utopia is a framework for building dynamic content-driven websites.
|
metadata.gz.sig
CHANGED
Binary file
|
data/bake/utopia/test.rb
DELETED
data/bin/utopia
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require_relative '../lib/utopia/command'
|
24
|
-
|
25
|
-
Utopia::Command.call
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-2022, by Samuel Williams.
|
5
|
-
|
6
|
-
require 'securerandom'
|
7
|
-
require 'yaml/store'
|
8
|
-
require 'console'
|
9
|
-
|
10
|
-
module Utopia
|
11
|
-
module Command
|
12
|
-
# Set environment variables within the server deployment.
|
13
|
-
class Environment < Samovar::Command
|
14
|
-
self.description = "Update environment variables in config/environment.yaml"
|
15
|
-
|
16
|
-
options do
|
17
|
-
option '-e/--environment-name <name>', "The environment file to modify.", default: 'environment'
|
18
|
-
option '-d/--defaults', "Initialize any recommended defaults."
|
19
|
-
end
|
20
|
-
|
21
|
-
many :variables, "A list of environment KEY=VALUE pairs to set."
|
22
|
-
|
23
|
-
def self.defaults(destination_root)
|
24
|
-
# Set some useful defaults for the environment.
|
25
|
-
self["--environment-name", "testing", "--defaults"].call(destination_root)
|
26
|
-
self["--environment-name", "development", "--defaults"].call(destination_root)
|
27
|
-
end
|
28
|
-
|
29
|
-
def environment_name
|
30
|
-
@options[:environment_name]
|
31
|
-
end
|
32
|
-
|
33
|
-
# Setup `config/environment.yaml` according to specified options.
|
34
|
-
def update_environment(root, name = self.environment_name)
|
35
|
-
environment_path = File.join(root, "config", "#{name}.yaml")
|
36
|
-
FileUtils.mkpath File.dirname(environment_path)
|
37
|
-
|
38
|
-
store = YAML::Store.new(environment_path)
|
39
|
-
|
40
|
-
store.transaction do
|
41
|
-
yield store, name, environment_path
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def call(root = parent.root)
|
46
|
-
update_environment(root) do |store, name, path|
|
47
|
-
if @options[:defaults]
|
48
|
-
# Set some useful defaults for the environment.
|
49
|
-
store['UTOPIA_SESSION_SECRET'] ||= SecureRandom.hex(40)
|
50
|
-
end
|
51
|
-
|
52
|
-
variables&.each do |variable|
|
53
|
-
key, value = variable.split('=', 2)
|
54
|
-
|
55
|
-
if value
|
56
|
-
puts "ENV[#{key.inspect}] will default to #{value.inspect} unless otherwise specified."
|
57
|
-
store[key] = value
|
58
|
-
else
|
59
|
-
puts "ENV[#{key.inspect}] will be unset unless otherwise specified."
|
60
|
-
store.delete(key)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
Console.logger.debug(self) do |buffer|
|
65
|
-
buffer.puts "Environment #{name} (#{path}):"
|
66
|
-
store.roots.each do |key|
|
67
|
-
value = store[key]
|
68
|
-
|
69
|
-
buffer.puts "#{key}=#{value.inspect}"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2017-2022, by Samuel Williams.
|
5
|
-
|
6
|
-
require_relative 'site'
|
7
|
-
|
8
|
-
require 'fileutils'
|
9
|
-
require 'socket'
|
10
|
-
|
11
|
-
require 'samovar'
|
12
|
-
|
13
|
-
module Utopia
|
14
|
-
module Command
|
15
|
-
# Server setup commands.
|
16
|
-
class Server < Samovar::Command
|
17
|
-
# Create a server.
|
18
|
-
class Create < Samovar::Command
|
19
|
-
self.description = "Create a remote Utopia website suitable for deployment using git."
|
20
|
-
|
21
|
-
def hostname
|
22
|
-
Socket.gethostname
|
23
|
-
end
|
24
|
-
|
25
|
-
def call
|
26
|
-
destination_root = parent.root
|
27
|
-
|
28
|
-
FileUtils.mkdir_p File.join(destination_root, "public")
|
29
|
-
|
30
|
-
Update[parent: parent].call
|
31
|
-
|
32
|
-
# Print out helpful git remote add message:
|
33
|
-
puts "Now add the git remote to your local repository:\n\tgit remote add production ssh://#{hostname}#{destination_root}"
|
34
|
-
puts "Then push to it:\n\tgit push --set-upstream production master"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# Update a server.
|
39
|
-
class Update < Samovar::Command
|
40
|
-
self.description = "Update the git hooks in an existing server repository."
|
41
|
-
|
42
|
-
def template_root
|
43
|
-
# The root directory of the template server deployment:
|
44
|
-
File.join(SETUP_ROOT, 'server')
|
45
|
-
end
|
46
|
-
|
47
|
-
def call
|
48
|
-
destination_root = parent.root
|
49
|
-
|
50
|
-
Dir.chdir(destination_root) do
|
51
|
-
# It's okay to call this on an existing repo, it will only update config as required to enable --shared.
|
52
|
-
# --shared allows multiple users to access the site with the same group.
|
53
|
-
system("git", "init", "--shared") or fail "could not initialize repository"
|
54
|
-
|
55
|
-
system("git", "config", "receive.denyCurrentBranch", "ignore") or fail "could not set configuration"
|
56
|
-
system("git", "config", "core.worktree", destination_root) or fail "could not set configuration"
|
57
|
-
|
58
|
-
# Doing this invokes a lot of behaviour that isn't always ideal...
|
59
|
-
# system("bundle", "config", "set", "--local", "deployment", "true")
|
60
|
-
system("bundle", "config", "set", "--local", "without", "development")
|
61
|
-
|
62
|
-
# In theory, to convert from non-shared to shared:
|
63
|
-
# chgrp -R <group-name> . # Change files and directories' group
|
64
|
-
# chmod -R g+w . # Change permissions
|
65
|
-
# chmod g-w .git/objects/pack/* # Git pack files should be immutable
|
66
|
-
# chmod g+s `find . -type d` # New files get group id of directory
|
67
|
-
end
|
68
|
-
|
69
|
-
# Set some useful defaults for the environment.
|
70
|
-
environment = Environment[]
|
71
|
-
environment.update_environment(destination_root) do |store|
|
72
|
-
store['VARIANT'] ||= 'production'
|
73
|
-
store['UTOPIA_SESSION_SECRET'] ||= SecureRandom.hex(40)
|
74
|
-
end
|
75
|
-
|
76
|
-
# Copy git hooks:
|
77
|
-
system("cp", "-r", File.join(template_root, 'git', 'hooks'), File.join(destination_root, '.git')) or fail "could not copy git hooks"
|
78
|
-
# finally set everything in the .git directory to be group writable
|
79
|
-
# This failed for me and I had to do sudo chown http:http .git -R first.
|
80
|
-
system("chmod", "-Rf", "g+w", File.join(destination_root, '.git')) or fail "could not update permissions of .git directory"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
self.description = "Manage server deployments."
|
85
|
-
|
86
|
-
nested :command, {
|
87
|
-
'create' => Create,
|
88
|
-
'update' => Update
|
89
|
-
}
|
90
|
-
|
91
|
-
def root
|
92
|
-
@parent.root
|
93
|
-
end
|
94
|
-
|
95
|
-
def call
|
96
|
-
@command.call
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
data/lib/utopia/command/site.rb
DELETED
@@ -1,217 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2017-2022, by Samuel Williams.
|
5
|
-
# Copyright, 2020, by Michael Adams.
|
6
|
-
|
7
|
-
require 'fileutils'
|
8
|
-
require 'find'
|
9
|
-
|
10
|
-
require 'samovar'
|
11
|
-
|
12
|
-
module Utopia
|
13
|
-
module Command
|
14
|
-
# This path must point to utopia/setup in the gem source.
|
15
|
-
SETUP_ROOT = File.expand_path("../../../setup", __dir__)
|
16
|
-
|
17
|
-
# Local site setup commands.
|
18
|
-
class Site < Samovar::Command
|
19
|
-
# Configuration files which should be installed/updated:
|
20
|
-
CONFIGURATION_FILES = ['.gitignore', 'config.ru', 'config/environment.rb', 'falcon.rb', 'gems.rb', 'Guardfile', 'bake.rb', 'spec/spec_helper.rb', 'spec/website_context.rb', 'spec/website_spec.rb']
|
21
|
-
|
22
|
-
# Directories that should exist:
|
23
|
-
DIRECTORIES = ["config", "lib", "pages", "public", "tasks", "spec"]
|
24
|
-
|
25
|
-
# Directories that should be removed during upgrade process:
|
26
|
-
OLD_PATHS = ["access_log", "cache", "tmp", "Rakefile", "tasks", ".bowerrc"]
|
27
|
-
|
28
|
-
# The root directory of the template site:
|
29
|
-
ROOT = File.join(SETUP_ROOT, 'site')
|
30
|
-
|
31
|
-
# Create a local site.
|
32
|
-
class Create < Samovar::Command
|
33
|
-
self.description = "Create a new local Utopia website using the default template."
|
34
|
-
|
35
|
-
def call
|
36
|
-
destination_root = parent.root
|
37
|
-
|
38
|
-
$stderr.puts "Setting up initial site in #{destination_root} for Utopia v#{Utopia::VERSION}..."
|
39
|
-
|
40
|
-
DIRECTORIES.each do |directory|
|
41
|
-
FileUtils.mkdir_p(File.join(destination_root, directory))
|
42
|
-
end
|
43
|
-
|
44
|
-
Find.find(ROOT) do |source_path|
|
45
|
-
# What is this doing?
|
46
|
-
destination_path = File.join(destination_root, source_path[ROOT.size..-1])
|
47
|
-
|
48
|
-
if File.directory?(source_path)
|
49
|
-
FileUtils.mkdir_p(destination_path)
|
50
|
-
else
|
51
|
-
unless File.exist? destination_path
|
52
|
-
FileUtils.copy_entry(source_path, destination_path)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
CONFIGURATION_FILES.each do |configuration_file|
|
58
|
-
destination_path = File.join(destination_root, configuration_file)
|
59
|
-
|
60
|
-
if File.exist?(destination_path)
|
61
|
-
buffer = File.read(destination_path).gsub('$UTOPIA_VERSION', Utopia::VERSION)
|
62
|
-
File.open(destination_path, "w") { |file| file.write(buffer) }
|
63
|
-
else
|
64
|
-
warn "Could not open #{destination_path}, maybe it should be removed from CONFIGURATION_FILES?"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
Dir.chdir(destination_root) do
|
69
|
-
puts "Setting up site in #{destination_root}..."
|
70
|
-
|
71
|
-
if `which bundle`.strip != ''
|
72
|
-
puts "Generating initial package list with bundle..."
|
73
|
-
system("bundle", "install") or fail "could not install bundled gems"
|
74
|
-
end
|
75
|
-
|
76
|
-
if `which git`.strip == ""
|
77
|
-
$stderr.puts "Now is a good time to learn about git: http://git-scm.com/"
|
78
|
-
elsif !File.exist?('.git')
|
79
|
-
puts "Setting up git repository..."
|
80
|
-
system("git", "init") or fail "could not create git repository"
|
81
|
-
system("git", "add", ".") or fail "could not add all files"
|
82
|
-
system("git", "commit", "-q", "-m", "Initial Utopia v#{Utopia::VERSION} site.") or fail "could not commit files"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
Environment.defaults(destination_root)
|
87
|
-
|
88
|
-
name = `git config user.name || whoami`.chomp
|
89
|
-
|
90
|
-
puts
|
91
|
-
puts " #{name},".ljust(78)
|
92
|
-
puts "Thank you for using Utopia!".center(78)
|
93
|
-
puts "We sincerely hope that Utopia helps to".center(78)
|
94
|
-
puts "make your life easier and more enjoyable.".center(78)
|
95
|
-
puts ""
|
96
|
-
puts "To start the development server, run:".center(78)
|
97
|
-
puts "bake utopia:development".center(78)
|
98
|
-
puts ""
|
99
|
-
puts "For extreme productivity, please consult the online documentation".center(78)
|
100
|
-
puts "https://github.com/socketry/utopia".center(78)
|
101
|
-
puts " ~ Samuel. ".rjust(78)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
# Update a local site.
|
106
|
-
class Update < Samovar::Command
|
107
|
-
self.description = "Upgrade an existing site to use the latest configuration files from the template."
|
108
|
-
|
109
|
-
# Move legacy `pages/_static` to `public/_static`.
|
110
|
-
def move_static!
|
111
|
-
# If public/_static doens't exist, we are done.
|
112
|
-
return unless File.exist? 'pages/_static'
|
113
|
-
|
114
|
-
if File.exist? 'public/_static'
|
115
|
-
if File.lstat("public/_static").symlink?
|
116
|
-
FileUtils.rm_f "public/_static"
|
117
|
-
else
|
118
|
-
warn "Can't move pages/_static to public/_static, destination already exists."
|
119
|
-
return
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
# One more sanity check:
|
124
|
-
if File.directory? 'pages/_static'
|
125
|
-
system("git", "mv", "pages/_static", "public/")
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
# Move `Gemfile` to `gems.rb`.
|
130
|
-
def update_gemfile!
|
131
|
-
# If `Gemfile` doens't exist, we are done:
|
132
|
-
return unless File.exist?('Gemfile')
|
133
|
-
|
134
|
-
system("git", "mv", "Gemfile", "gems.rb")
|
135
|
-
system("git", "mv", "Gemfile.lock", "gems.locked")
|
136
|
-
end
|
137
|
-
|
138
|
-
def call
|
139
|
-
destination_root = parent.root
|
140
|
-
branch_name = "utopia-upgrade-#{Utopia::VERSION}"
|
141
|
-
|
142
|
-
$stderr.puts "Upgrading #{destination_root}..."
|
143
|
-
|
144
|
-
Dir.chdir(destination_root) do
|
145
|
-
system('git', 'checkout', '-b', branch_name) or fail "could not change branch"
|
146
|
-
end
|
147
|
-
|
148
|
-
DIRECTORIES.each do |directory|
|
149
|
-
FileUtils.mkdir_p(File.join(destination_root, directory))
|
150
|
-
end
|
151
|
-
|
152
|
-
OLD_PATHS.each do |path|
|
153
|
-
path = File.join(destination_root, path)
|
154
|
-
$stderr.puts "\tRemoving #{path}..."
|
155
|
-
FileUtils.rm_rf(path)
|
156
|
-
end
|
157
|
-
|
158
|
-
CONFIGURATION_FILES.each do |configuration_file|
|
159
|
-
source_path = File.join(Site::ROOT, configuration_file)
|
160
|
-
destination_path = File.join(destination_root, configuration_file)
|
161
|
-
|
162
|
-
$stderr.puts "Updating #{destination_path}..."
|
163
|
-
|
164
|
-
FileUtils.copy_entry(source_path, destination_path)
|
165
|
-
buffer = File.read(destination_path).gsub('$UTOPIA_VERSION', Utopia::VERSION)
|
166
|
-
File.open(destination_path, "w") { |file| file.write(buffer) }
|
167
|
-
end
|
168
|
-
|
169
|
-
Environment.defaults(destination_root)
|
170
|
-
|
171
|
-
begin
|
172
|
-
Dir.chdir(destination_root) do
|
173
|
-
# Stage any files that have been changed or removed:
|
174
|
-
system("git", "add", "-u") or fail "could not add files"
|
175
|
-
|
176
|
-
# Stage any new files that we have explicitly added:
|
177
|
-
system("git", "add", *Site::CONFIGURATION_FILES) or fail "could not add files"
|
178
|
-
|
179
|
-
move_static!
|
180
|
-
update_gemfile!
|
181
|
-
|
182
|
-
# Commit all changes:
|
183
|
-
system("git", "commit", "-m", "Upgrade to utopia #{Utopia::VERSION}.") or fail "could not commit changes"
|
184
|
-
|
185
|
-
# Checkout master..
|
186
|
-
system("git", "checkout", "master") or fail "could not checkout master"
|
187
|
-
|
188
|
-
# and merge:
|
189
|
-
system("git", "merge", "--squash", "--no-commit", branch_name) or fail "could not merge changes"
|
190
|
-
end
|
191
|
-
rescue RuntimeError
|
192
|
-
$stderr.puts "** Detected error with upgrade, reverting changes. Some new files may still exist in tree. **"
|
193
|
-
|
194
|
-
system("git", "checkout", "master")
|
195
|
-
ensure
|
196
|
-
system("git", "branch", "-D", branch_name)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
nested :command, {
|
202
|
-
'create' => Create,
|
203
|
-
'update' => Update
|
204
|
-
}
|
205
|
-
|
206
|
-
self.description = "Manage local utopia sites."
|
207
|
-
|
208
|
-
def root
|
209
|
-
@parent.root
|
210
|
-
end
|
211
|
-
|
212
|
-
def call
|
213
|
-
@command.call
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
data/lib/utopia/command.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2016-2022, by Samuel Williams.
|
5
|
-
# Copyright, 2017, by Huba Nagy.
|
6
|
-
|
7
|
-
require_relative 'version'
|
8
|
-
|
9
|
-
require_relative 'command/site'
|
10
|
-
require_relative 'command/server'
|
11
|
-
require_relative 'command/environment'
|
12
|
-
|
13
|
-
module Utopia
|
14
|
-
module Command
|
15
|
-
def self.call(*arguments)
|
16
|
-
Top.call(*arguments)
|
17
|
-
end
|
18
|
-
|
19
|
-
# The top level utopia command.
|
20
|
-
class Top < Samovar::Command
|
21
|
-
self.description = "A website development and deployment framework."
|
22
|
-
|
23
|
-
options do
|
24
|
-
option '-i/--in/--root <path>', "Work in the given root directory."
|
25
|
-
option '-h/--help', "Print out help information."
|
26
|
-
option '-v/--version', "Print out the application version."
|
27
|
-
end
|
28
|
-
|
29
|
-
nested :command, {
|
30
|
-
'site' => Site,
|
31
|
-
'server' => Server,
|
32
|
-
'environment' => Environment
|
33
|
-
}
|
34
|
-
|
35
|
-
# The root directory for the site.
|
36
|
-
def root
|
37
|
-
File.expand_path(@options.fetch(:root, ''), Dir.getwd)
|
38
|
-
end
|
39
|
-
|
40
|
-
def call
|
41
|
-
if @options[:version]
|
42
|
-
puts "#{self.name} v#{VERSION}"
|
43
|
-
elsif @options[:help]
|
44
|
-
print_usage(output: $stdout)
|
45
|
-
else
|
46
|
-
@command.call
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/setup/site/.rspec
DELETED