fjords 1.0.3 → 1.1.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.
- data/LICENSE +20 -0
- data/fjords.gemspec +1 -1
- data/lib/fjords/cli/core.rb +192 -15
- data/lib/fjords/cli/runner.rb +62 -4
- data/lib/fjords/cli/usage.rb +17 -10
- data/lib/fjords/version.rb +1 -1
- metadata +7 -6
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Thomas Reynolds
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/fjords.gemspec
CHANGED
data/lib/fjords/cli/core.rb
CHANGED
@@ -62,7 +62,8 @@ class Fjords::Cli::Core
|
|
62
62
|
return if @help_only
|
63
63
|
require_login!
|
64
64
|
|
65
|
-
|
65
|
+
show_deleted = @options[:deleted] || false
|
66
|
+
sites = Fjords::Client.sites(show_deleted)
|
66
67
|
|
67
68
|
if sites.length > 0
|
68
69
|
rows = sites.map do |site|
|
@@ -70,16 +71,44 @@ class Fjords::Cli::Core
|
|
70
71
|
domain = site['internal_name']
|
71
72
|
domain = site['custom_name'] if site['custom_name'] != domain
|
72
73
|
|
73
|
-
|
74
|
+
if site['deleted_at']
|
75
|
+
d = DateTime.parse(site['deleted_at'])
|
76
|
+
deleting_at = time_to_expiry(d.to_time.to_i)
|
77
|
+
cdn_status = 'no'
|
78
|
+
else
|
79
|
+
d = DateTime.parse(site['created_at'])
|
80
|
+
deleting_at = site['type'] === 'temporary' ? time_to_expiry(d.to_time.to_i + (60 * 60 * 24 * 30)) : 'never'
|
81
|
+
|
82
|
+
cdn_status = if site['cdn_enabled']
|
83
|
+
# site['cdn_status']
|
84
|
+
'yes'
|
85
|
+
else
|
86
|
+
'no'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
74
90
|
[
|
75
91
|
domain,
|
76
|
-
site['type'],
|
92
|
+
site['type'] == 'with_dns' ? 'yes' : 'no',
|
93
|
+
site['gzip_assets'] ? 'yes' : 'no',
|
94
|
+
cdn_status,
|
77
95
|
cost,
|
78
|
-
|
96
|
+
deleting_at,
|
97
|
+
d
|
79
98
|
]
|
80
|
-
end
|
99
|
+
end.sort do |a, b|
|
100
|
+
if a[4] == 'never' && b[4] == 'never'
|
101
|
+
a[0] <=> b[0]
|
102
|
+
elsif a[4] == 'never'
|
103
|
+
-1
|
104
|
+
elsif b[4] == 'never'
|
105
|
+
1
|
106
|
+
else
|
107
|
+
a[5] <=> b[5]
|
108
|
+
end
|
109
|
+
end.map { |r| r[0...-1] }
|
81
110
|
|
82
|
-
rows.unshift ["Domain", "
|
111
|
+
rows.unshift ["Domain", "DNS?", "Gzip?", "CDN?", "Cost", "Expires"]
|
83
112
|
puts
|
84
113
|
print_table(rows, :indent => 2)
|
85
114
|
else
|
@@ -110,6 +139,62 @@ class Fjords::Cli::Core
|
|
110
139
|
true
|
111
140
|
end
|
112
141
|
|
142
|
+
def site_details(domain)
|
143
|
+
return if @help_only
|
144
|
+
require_login!
|
145
|
+
|
146
|
+
site = Fjords::Client.site_details(domain)
|
147
|
+
|
148
|
+
if site
|
149
|
+
cost = "$#{(site['cost'] / 100.00).to_i}"
|
150
|
+
domain = site['internal_name']
|
151
|
+
domain = site['custom_name'] if site['custom_name'] != domain
|
152
|
+
|
153
|
+
if site['deleted_at']
|
154
|
+
d = DateTime.parse(site['deleted_at'])
|
155
|
+
deleting_at = time_to_expiry(d.to_time.to_i)
|
156
|
+
cdn_status = 'no'
|
157
|
+
else
|
158
|
+
d = DateTime.parse(site['created_at'])
|
159
|
+
deleting_at = site['type'] === 'temporary' ? time_to_expiry(d.to_time.to_i + (60 * 60 * 24 * 30)) : 'never'
|
160
|
+
|
161
|
+
cdn_status = if site['cdn_enabled']
|
162
|
+
# site['cdn_status']
|
163
|
+
"yes ($#{(site['cost'] > 0 ? '2' : '0')})"
|
164
|
+
else
|
165
|
+
'no'
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
output = []
|
170
|
+
output << ["Domain:", domain]
|
171
|
+
output << ["Custom DNS:", site['type'] == 'with_dns' ? "yes ($#{(site['cost'] > 0 ? '2' : '0')})" : 'no']
|
172
|
+
|
173
|
+
if site['type'] == 'with_dns'
|
174
|
+
output << ["Point DNS At:", site['internal_name']]
|
175
|
+
end
|
176
|
+
|
177
|
+
output << ["CDN Enabled:", cdn_status]
|
178
|
+
if site['cdn_enabled']
|
179
|
+
output << ["Point CDN DNS At:", site['cdn_internal_name']]
|
180
|
+
end
|
181
|
+
|
182
|
+
output << ["Gzip Enabled:", site['gzip_assets'] ? 'yes' : 'no']
|
183
|
+
|
184
|
+
output << ["Expires At:", deleting_at]
|
185
|
+
|
186
|
+
output << ["Montly Cost:", cost]
|
187
|
+
|
188
|
+
puts
|
189
|
+
print_table(output, :indent => 2)
|
190
|
+
else
|
191
|
+
say %Q{Error: Could not find site "#{domain}".}
|
192
|
+
exit(0)
|
193
|
+
end
|
194
|
+
|
195
|
+
true
|
196
|
+
end
|
197
|
+
|
113
198
|
def push
|
114
199
|
return if @help_only
|
115
200
|
require_login!
|
@@ -323,6 +408,92 @@ class Fjords::Cli::Core
|
|
323
408
|
end
|
324
409
|
end
|
325
410
|
|
411
|
+
def enable_cdn(domain)
|
412
|
+
return if @help_only
|
413
|
+
require_login!
|
414
|
+
|
415
|
+
puts
|
416
|
+
|
417
|
+
has_cdn = Fjords::Client::has_cdn(domain)
|
418
|
+
|
419
|
+
if has_cdn
|
420
|
+
say %Q{Error: CDN already enabled for site "#{domain}".}
|
421
|
+
exit(0)
|
422
|
+
elsif site = Fjords::Client::enable_cdn(domain)
|
423
|
+
say %Q{Enabled CDN for "#{domain}".}
|
424
|
+
say "Deploying your files around the planet takes some time."
|
425
|
+
say "Please be patient."
|
426
|
+
puts
|
427
|
+
|
428
|
+
say "In the meantime,"
|
429
|
+
say "Make sure your CNAME points to: #{site["cdn_internal_name"]}"
|
430
|
+
|
431
|
+
true
|
432
|
+
else
|
433
|
+
say %Q{Error: Could not find site "#{domain}" to enable CDN for.}
|
434
|
+
exit(0)
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
def disable_cdn(domain)
|
439
|
+
return if @help_only
|
440
|
+
require_login!
|
441
|
+
|
442
|
+
puts
|
443
|
+
|
444
|
+
has_cdn = Fjords::Client::has_cdn(domain)
|
445
|
+
|
446
|
+
if !has_cdn
|
447
|
+
say %Q{Error: CDN is not enabled for site "#{domain}".}
|
448
|
+
exit(0)
|
449
|
+
elsif Fjords::Client::disable_cdn(domain)
|
450
|
+
say %Q{Disabled CDN for "#{domain}"}
|
451
|
+
true
|
452
|
+
else
|
453
|
+
say %Q{Error: Could not find site "#{domain}" to disable CDN for.}
|
454
|
+
exit(0)
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
458
|
+
def enable_gzip(domain)
|
459
|
+
return if @help_only
|
460
|
+
require_login!
|
461
|
+
|
462
|
+
puts
|
463
|
+
|
464
|
+
has_gzip = Fjords::Client::has_gzip(domain)
|
465
|
+
|
466
|
+
if has_gzip
|
467
|
+
say %Q{Error: Gzipping already enabled for site "#{domain}".}
|
468
|
+
exit(0)
|
469
|
+
elsif Fjords::Client::enable_gzip(domain)
|
470
|
+
say %Q{Enabled Gzipping Assets for "#{domain}".}
|
471
|
+
true
|
472
|
+
else
|
473
|
+
say %Q{Error: Could not find site "#{domain}" to enable Gzipping for.}
|
474
|
+
exit(0)
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
def disable_gzip(domain)
|
479
|
+
return if @help_only
|
480
|
+
require_login!
|
481
|
+
|
482
|
+
puts
|
483
|
+
|
484
|
+
has_gzip = Fjords::Client::has_gzip(domain)
|
485
|
+
|
486
|
+
if !has_gzip
|
487
|
+
say %Q{Error: Gzipping is not enabled for site "#{domain}".}
|
488
|
+
exit(0)
|
489
|
+
elsif Fjords::Client::disable_gzip(domain)
|
490
|
+
say %Q{Disabled Gzipping Assets for "#{domain}"}
|
491
|
+
true
|
492
|
+
else
|
493
|
+
say %Q{Error: Could not find site "#{domain}" to disable Gzipping for.}
|
494
|
+
exit(0)
|
495
|
+
end
|
496
|
+
end
|
326
497
|
private
|
327
498
|
|
328
499
|
def available_editor(preferred=nil)
|
@@ -439,16 +610,22 @@ private
|
|
439
610
|
def time_to_expiry(from_time)
|
440
611
|
to_time = DateTime.now.to_time.to_i
|
441
612
|
distance_in_minutes = (((from_time - to_time))/60).round
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
when
|
446
|
-
when
|
447
|
-
when
|
448
|
-
when
|
449
|
-
when
|
613
|
+
abs_distance_in_minutes = distance_in_minutes.abs
|
614
|
+
|
615
|
+
res = case abs_distance_in_minutes
|
616
|
+
when 0..1 then abs_distance_in_minutes == 0 ? "less than a minute" : "1 minute"
|
617
|
+
when 2..44 then "#{abs_distance_in_minutes} minutes"
|
618
|
+
when 45..89 then "1 hour"
|
619
|
+
when 90..1439 then "#{(abs_distance_in_minutes.to_f / 60.0).round} hours"
|
620
|
+
when 1440..2519 then "1 day"
|
450
621
|
else
|
451
|
-
"
|
622
|
+
"#{(abs_distance_in_minutes.to_f / 1440.0).round} days"
|
623
|
+
end
|
624
|
+
|
625
|
+
if distance_in_minutes > 0
|
626
|
+
"in #{res}"
|
627
|
+
else
|
628
|
+
"#{res} ago"
|
452
629
|
end
|
453
630
|
end
|
454
631
|
end
|
data/lib/fjords/cli/runner.rb
CHANGED
@@ -18,6 +18,7 @@ module Fjords::Cli::Runner
|
|
18
18
|
opts.on('--overwrite') { |overwrite| @options[:overwrite] = overwrite }
|
19
19
|
opts.on('--no-zip') { |no_zip| @options[:no_zip] = !no_zip }
|
20
20
|
opts.on('--no-progress') { |no_progress| @options[:no_progress] = !no_progress }
|
21
|
+
opts.on('--deleted') { |deleted| @options[:deleted] = deleted }
|
21
22
|
opts.on('--permanent') { |permanent| @options[:permanent] = permanent }
|
22
23
|
opts.on('--domain-file DOMAIN_FILE') { |domain_file| @options[:domain_file] = domain_file }
|
23
24
|
opts.on('-h', '--help') { puts "#{command_usage}\n"; exit }
|
@@ -34,12 +35,22 @@ module Fjords::Cli::Runner
|
|
34
35
|
help if @args.size == 0
|
35
36
|
@help_only = true
|
36
37
|
parse_command!
|
37
|
-
when 'nameservers'
|
38
|
-
|
39
|
-
|
38
|
+
# when 'nameservers'
|
39
|
+
# usage('fjords nameservers')
|
40
|
+
# nameservers
|
40
41
|
when 'sites'
|
41
|
-
usage('fjords sites')
|
42
|
+
usage('fjords sites [--deleted]')
|
42
43
|
sites
|
44
|
+
when 'site:details'
|
45
|
+
usage('fjords ite:details DOMAIN')
|
46
|
+
|
47
|
+
if !@args[0] || @args[0].length < 1
|
48
|
+
puts
|
49
|
+
puts "Error: DOMAIN argument required"
|
50
|
+
exit(0)
|
51
|
+
end
|
52
|
+
|
53
|
+
site_details(@args[0])
|
43
54
|
when 'push'
|
44
55
|
usage('fjords push [--path PATH] [--domain DOMAIN] [--domain-file DOMAIN_FILE]')
|
45
56
|
push
|
@@ -54,7 +65,54 @@ module Fjords::Cli::Runner
|
|
54
65
|
signup
|
55
66
|
when 'remove'
|
56
67
|
usage('fjords remove DOMAIN')
|
68
|
+
|
69
|
+
if !@args[0] || @args[0].length < 1
|
70
|
+
puts
|
71
|
+
puts "Error: DOMAIN argument required"
|
72
|
+
exit(0)
|
73
|
+
end
|
74
|
+
|
57
75
|
remove(@args[0])
|
76
|
+
when 'cdn:enable'
|
77
|
+
usage('fjords cdn:enable DOMAIN')
|
78
|
+
|
79
|
+
if !@args[0] || @args[0].length < 1
|
80
|
+
puts
|
81
|
+
puts "Error: DOMAIN argument required"
|
82
|
+
exit(0)
|
83
|
+
end
|
84
|
+
|
85
|
+
enable_cdn(@args[0])
|
86
|
+
when 'cdn:disable'
|
87
|
+
usage('fjords cdn:disable DOMAIN')
|
88
|
+
|
89
|
+
if !@args[0] || @args[0].length < 1
|
90
|
+
puts
|
91
|
+
puts "Error: DOMAIN argument required"
|
92
|
+
exit(0)
|
93
|
+
end
|
94
|
+
|
95
|
+
disable_cdn(@args[0])
|
96
|
+
when 'gzip:enable'
|
97
|
+
usage('fjords gzip:enable DOMAIN')
|
98
|
+
|
99
|
+
if !@args[0] || @args[0].length < 1
|
100
|
+
puts
|
101
|
+
puts "Error: DOMAIN argument required"
|
102
|
+
exit(0)
|
103
|
+
end
|
104
|
+
|
105
|
+
enable_gzip(@args[0])
|
106
|
+
when 'gzip:disable'
|
107
|
+
usage('fjords gzip:disable DOMAIN')
|
108
|
+
|
109
|
+
if !@args[0] || @args[0].length < 1
|
110
|
+
puts
|
111
|
+
puts "Error: DOMAIN argument required"
|
112
|
+
exit(0)
|
113
|
+
end
|
114
|
+
|
115
|
+
disable_gzip(@args[0])
|
58
116
|
when 'bugreport'
|
59
117
|
usage('fjords bugreport [--attach ERROR_FILE]')
|
60
118
|
bugreport
|
data/lib/fjords/cli/usage.rb
CHANGED
@@ -35,22 +35,29 @@ module Fjords::Cli::Usage
|
|
35
35
|
Currently available af commands are:
|
36
36
|
|
37
37
|
Getting Started
|
38
|
-
login
|
39
|
-
logout
|
40
|
-
signup
|
41
|
-
info
|
38
|
+
login Login to Fjords
|
39
|
+
logout Logout of Fjords
|
40
|
+
signup Create an account
|
41
|
+
info Get your account information, including costs
|
42
42
|
|
43
43
|
Sites
|
44
|
-
sites
|
45
|
-
|
44
|
+
sites List deployed sites
|
45
|
+
site:details DOMAIN Information about a specific domain
|
46
|
+
remove DOMAIN Remove a deployed site
|
47
|
+
|
48
|
+
Site Features
|
49
|
+
cdn:enable DOMAIN Enable the Content Delivery Network
|
50
|
+
cdn:disable DOMAIN Disable the Content Delivery Network
|
51
|
+
gzip:enable DOMAIN Enable Gzipping of assets (HTML, CSS, JS)
|
52
|
+
gzip:disable DOMAIN Disable Gzipping of assets (HTML, CSS, JS)
|
46
53
|
|
47
54
|
Site Creation
|
48
|
-
push
|
55
|
+
push Push a new site
|
49
56
|
|
50
57
|
Help
|
51
|
-
help [command]
|
52
|
-
help options
|
53
|
-
bugreport
|
58
|
+
help [command] Get general help or help on a specific command
|
59
|
+
help options Get help on available options
|
60
|
+
bugreport Send a bug-report
|
54
61
|
USAGE
|
55
62
|
|
56
63
|
end
|
data/lib/fjords/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fjords
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: highline
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - '='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.0
|
53
|
+
version: 1.1.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0
|
61
|
+
version: 1.1.0
|
62
62
|
description: Fjords.cc CLI
|
63
63
|
email:
|
64
64
|
- me@tdreyno.com
|
@@ -69,6 +69,7 @@ extra_rdoc_files: []
|
|
69
69
|
files:
|
70
70
|
- .gitignore
|
71
71
|
- Gemfile
|
72
|
+
- LICENSE
|
72
73
|
- Rakefile
|
73
74
|
- bin/fjords
|
74
75
|
- fjords.gemspec
|
@@ -92,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
93
|
version: '0'
|
93
94
|
segments:
|
94
95
|
- 0
|
95
|
-
hash: -
|
96
|
+
hash: -582392878008552670
|
96
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
98
|
none: false
|
98
99
|
requirements:
|
@@ -101,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
102
|
version: '0'
|
102
103
|
segments:
|
103
104
|
- 0
|
104
|
-
hash: -
|
105
|
+
hash: -582392878008552670
|
105
106
|
requirements: []
|
106
107
|
rubyforge_project:
|
107
108
|
rubygems_version: 1.8.23
|