skypager 0.0.6 → 0.0.8

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
  SHA1:
3
- metadata.gz: 1255f32a2f558cf91cb1daa447d209759f6b62be
4
- data.tar.gz: 0e16117f9435562cdb26e69f5b1fc2481b3e6635
3
+ metadata.gz: 549d7187a816f502b9db66fa489f87e2c4bcff72
4
+ data.tar.gz: d6c2388c6c5565f73a86eb0be6c16294f92b7a0f
5
5
  SHA512:
6
- metadata.gz: 927b6be93828744586b80f58ca22ea43dea43b754dd9bc6296d7127b4ae703aa4555951141af205ecf8d818ffe140168f18b056d958d27e89ab97c0fb42b9951
7
- data.tar.gz: bdc5da28ff702873819cf6edc7f5c4340212e28d10dd81ea1b07024ea54dc079b3964b742e3b13d3908b5f77d1d46c096bdd4014a6e0afe7ebcdcbcee4a7aa49
6
+ metadata.gz: 633189ac4c391ebf5048cd4e597ce94c1c518f23136e3cf0193a06f41b39215f7f42bfe10b66465fe28cb06fe304f94df253441484b26e0f71d932f66dfef587
7
+ data.tar.gz: 9d589905c390eede65e3dccde8fc36575d83b93cd381afd7109827a8e84204e7fdd2fe27dee744e8d92d541d852aec98bbba4538ace4bda55621b3c7acfd9ace
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -eo pipefail
4
+ export DEBIAN_FRONTEND=noninteractive
5
+ export SKYPAGER_REPO=${SKYPAGER_REPO:-"https://github.com/architects/skypager.git"}
6
+
7
+ if ! command -v apt-get &>/dev/null
8
+ then
9
+ echo "This installation script requires apt-get. For manual installation instructions, consult https://github.com/progrium/dokku ."
10
+ exit 1
11
+ fi
12
+
13
+ apt-get update
14
+ apt-get install -qq -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
15
+ apt-get install -qq -y git make curl software-properties-common man-db
16
+
17
+ cd ~
18
+ git clone git://github.com/sstephenson/rbenv.git .rbenv
19
+ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
20
+ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
21
+ exec $SHELL
22
+
23
+ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
24
+ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
25
+ exec $SHELL
26
+
27
+ rbenv install 2.1.3
28
+ rbenv global 2.1.3
29
+ ruby -v
@@ -8,6 +8,8 @@ command 'build' do |c|
8
8
 
9
9
  c.option "--force", nil, 'Whether or not we should force a build'
10
10
 
11
+ $enable_skypager_sync_from_command = true
12
+
11
13
  c.action do |args, options|
12
14
  require 'rack/test'
13
15
  require 'skypager/builder'
@@ -46,3 +48,17 @@ command 'run build server' do |c|
46
48
 
47
49
  end
48
50
  end
51
+
52
+ command 'generate builder crontab' do |c|
53
+ c.syntax = 'skypager generate builder crontab'
54
+ c.description = 'generates a crontab which will build sites that are marked to be built'
55
+
56
+ c.action do |args, options|
57
+ lines = Skypager::Site.sites.map do |site|
58
+ "*/5 * * * * cd #{ site.root } && bundle exec skypager build"
59
+ end
60
+
61
+ puts "== run 'crontab -e' as root and add the following content:\n\n\n"
62
+ puts lines.join("\n")
63
+ end
64
+ end
@@ -3,11 +3,16 @@ command 'deploy' do |c|
3
3
  c.description = 'deploy this site'
4
4
 
5
5
  c.option '--verbose', nil, 'Display verbose status information'
6
+ c.option '--full', nil, 'Ignore the build manifest, deploy everything'
6
7
 
7
8
  c.action do |args, options|
8
9
  app = Skypager.app
9
10
  site = app.site
10
11
 
12
+ if options.full.present?
13
+ site.remove_build_manifest
14
+ end
15
+
11
16
  site.deploy(app.build_path)
12
17
 
13
18
  if site.use_cdn?
@@ -19,9 +24,13 @@ command 'deploy' do |c|
19
24
 
20
25
  begin
21
26
  service = cdn.service
22
- puts "Posting CDN Invalidations"
23
- puts paths.inspect
24
- service.post_invalidation cdn, paths
27
+
28
+ puts "== Posting CDN Invalidations"
29
+ paths.each do |path|
30
+ puts "==== #{ path }"
31
+ end
32
+
33
+ service.post_invalidation cdn.id, paths
25
34
  rescue => e
26
35
  puts "Error invalidating the CDN: #{ e.message }"
27
36
  end
@@ -14,6 +14,13 @@ command 'setup' do |c|
14
14
 
15
15
  require 'dnsimple'
16
16
  Skypager.dns.setup unless options.skip_dns || Skypager.config.dnsimple_setup?
17
+
18
+ want_to_setup_deployment = agree("Want to setup deployment right now? This will make your site available in the clouds. type yes/no")
19
+
20
+ if want_to_setup_deployment
21
+ puts "== This might take a minute."
22
+ Skypager::DeploymentSetup.run(options)
23
+ end
17
24
  end
18
25
  end
19
26
 
@@ -45,55 +52,7 @@ command 'setup deployment' do |c|
45
52
  secret_access_key: options.secret_access_key)
46
53
 
47
54
 
48
- app = Skypager.app
49
-
50
- if !Skypager.config.dnsimple_setup?
51
- if agree("Do you want to setup DNSimple integration?")
52
- Skypager.dns.setup()
53
- end
54
- end
55
-
56
- custom_domain = app.deploy_options[:custom_domain] || options.custom_domain || ask("Enter a custom domain name to deploy to. Leave blank if you don't want to use this.")
57
-
58
- if custom_domain.to_s.length > 0
59
- app.site.set :custom_domain, custom_domain
60
- app.site.set :use_cdn, true
61
- @custom_domain = custom_domain
62
- end
63
-
64
- unless @custom_domain || app.deploy_options[:use_cdn] == true
65
- if agree("Do you want to use a CDN? Answer yes if you want to use a custom domain, or SSL for this site")
66
- app.site.set :use_cdn, true
67
- end
68
- end
69
-
70
- bucket_name = app.deploy_options[:bucket_name] || options.create_bucket || ask("Enter a name for this bucket. Leave blank to use #{ app.site.name }.#{ Skypager.config.domain}")
71
- bucket_name = app.site_name + "." + Skypager.config.domain if bucket_name.to_s.length == 0
72
-
73
- if bucket_name
74
- if bucket = Skypager.amazon.find_or_create_bucket(bucket_name)
75
- app.site.set :bucket_key, bucket.key
76
- app.site.set :bucket_name, bucket.key
77
- end
78
- end
79
-
80
- config_path = Pathname(app.root).join("config.rb")
81
- config_text = config_path.read rescue ""
82
-
83
- app.site.after_setup
84
-
85
- unless config_text.match(/deploy_to\(\:amazon/)
86
- puts "Adding the following to your config.rb:\n\n\t#{ line = app.site.deploy_options_config_string }"
87
- config_path.open("a+") {|fh| fh.write(line) }
88
- end
89
-
90
- site = app.site
91
-
92
- puts "Site Info:"
93
- puts "Bucket Name: #{ site.bucket_name }"
94
- puts "Bucket URL: #{ site.bucket_url }"
95
- puts "CDN URL: #{ site.cname_value }" if site.has_cdn?
96
- puts "Custom Domain: #{ site.custom_domain }" if site.custom_domain?
55
+ Skypager::DeploymentSetup.run(options)
97
56
  end
98
57
  end
99
58
 
@@ -135,3 +94,60 @@ command 'setup github' do |c|
135
94
  end
136
95
 
137
96
 
97
+ module Skypager
98
+ class DeploymentSetup
99
+ def self.run(options)
100
+ app = Skypager.app
101
+
102
+ if !Skypager.config.dnsimple_setup?
103
+ if agree("Do you want to setup DNSimple integration?")
104
+ Skypager.dns.setup()
105
+ end
106
+ end
107
+
108
+ custom_domain = app.deploy_options[:custom_domain] || options.custom_domain || ask("Enter a custom domain name to deploy to. Leave blank if you don't want to use this.")
109
+
110
+ if custom_domain.to_s.length > 0
111
+ app.site.set :custom_domain, custom_domain
112
+ app.site.set :use_cdn, true
113
+ @custom_domain = custom_domain
114
+ end
115
+
116
+ unless @custom_domain || app.deploy_options[:use_cdn] == true
117
+ if agree("Do you want to use a CDN? Answer yes if you want to use a custom domain, or SSL for this site")
118
+ app.site.set :use_cdn, true
119
+ end
120
+ end
121
+
122
+ bucket_name = app.deploy_options[:bucket_name] || options.create_bucket || ask("Enter a name for this bucket. Leave blank to use #{ app.site.name }.#{ Skypager.config.domain}")
123
+ bucket_name = app.site_name + "." + Skypager.config.domain if bucket_name.to_s.length == 0
124
+
125
+ if bucket_name
126
+ if bucket = Skypager.amazon.find_or_create_bucket(bucket_name)
127
+ app.site.set :bucket_key, bucket.key
128
+ app.site.set :bucket_name, bucket.key
129
+ end
130
+ end
131
+
132
+ config_path = Pathname(app.root).join("config.rb")
133
+ config_text = config_path.read rescue ""
134
+
135
+ app.site.after_setup
136
+
137
+ unless config_text.match(/deploy_to\(\:amazon/)
138
+ puts "Adding the following to your config.rb:\n\n\t#{ line = app.site.deploy_options_config_string }"
139
+ config_path.open("a+") {|fh| fh.write(line) }
140
+ end
141
+
142
+ site = app.site
143
+
144
+ puts "Site Info:"
145
+ puts "Bucket Name: #{ site.bucket_name }"
146
+ puts "Bucket URL: #{ site.bucket_url }"
147
+ puts "CDN URL: #{ site.cname_value }" if site.has_cdn?
148
+ puts "Custom Domain: #{ site.custom_domain }" if site.custom_domain?
149
+ end
150
+ end
151
+ end
152
+
153
+
@@ -1,11 +1,13 @@
1
1
  command 'sync' do |c|
2
2
  c.action do |args, options|
3
+ $enable_skypager_sync_from_command = true
4
+
3
5
  app = ::Middleman::Application.server.inst do
4
6
  set :environment, 'development'
5
7
  end
6
8
 
7
9
  app.synced_folders.each do |name, folder|
8
- puts "Syncing #{ name }"
10
+ puts "== Syncing #{ name }"
9
11
  folder.sync()
10
12
  end
11
13
 
@@ -26,7 +26,7 @@ module Skypager
26
26
  app.set(key, value)
27
27
  end
28
28
 
29
- unless $skypager_command || ENV['DISABLE_SKYPAGER_SYNC']
29
+ unless ($skypager_command || ENV['DISABLE_SKYPAGER_SYNC']) && !$enable_skypager_sync_from_command
30
30
  app.ready do
31
31
  sync_folders()
32
32
  load_stores()
@@ -36,15 +36,25 @@ module Skypager
36
36
  # In development, we will try to refresh remote data stores (e.g. google spreadsheets)
37
37
  # before every request once every minute or so
38
38
  app.before do
39
+ if !Skypager.config.dropbox_setup? && !Skypager.config.google_setup? && !Skypager.config.amazon_setup?
40
+ puts "\n\n== Use Skypager's one time setup script to automate huge parts of your workflow!"
41
+ puts "Run 'skypager setup' now"
42
+ puts "\n\n\n"
43
+ raise 'Run skypager setup first'
44
+ end
45
+
39
46
  data_sources.values.each do |data_source|
40
47
  data_source.refresh_if_stale?
41
48
  end if development?
42
49
  end
43
50
  end
44
51
 
52
+ app.before_configuration do
53
+ end
54
+
45
55
  app.after_build do
46
- app.site.requires_build!(false)
47
- app.deploy! if app.auto_deploy?
56
+ site.requires_build!(false)
57
+ deploy! if auto_deploy?
48
58
  end
49
59
 
50
60
  app.after_configuration do
@@ -192,6 +192,12 @@ module Skypager
192
192
  def deploy(build_dir)
193
193
  target = bucket || Skypager.amazon.s3_bucket
194
194
 
195
+ if target.to_s.match(/there is no bucket named/i)
196
+ puts "== The S3 Bucket is not setup for this site."
197
+ puts "==== Please run 'bundle exec skypager setup deployment' to begin this process"
198
+ return
199
+ end
200
+
195
201
  payload = prepare_deploy(build_dir)
196
202
 
197
203
  if payload.empty?
@@ -199,9 +205,11 @@ module Skypager
199
205
  end
200
206
 
201
207
  payload.each do |hash|
202
- if target.files.create(key: hash[:key], body: File.open(hash[:node]), public: true)
208
+ body = hash[:node].read
209
+
210
+ if target.files.create(key: hash[:key], body: body, public: true)
203
211
  rel = hash[:key]
204
- puts "== Deployed #{rel}"
212
+ puts "== Deployed #{ body.length } bytes to #{rel}"
205
213
  build_manifest[rel] = hash[:digest]
206
214
  end
207
215
  end
@@ -211,7 +219,11 @@ module Skypager
211
219
  end
212
220
 
213
221
  def use_cdn?
214
- get(:use_cdn) == true || get(:use_cdn) == "yes" || get(:use_cdn) == "true"
222
+ deploy_options.fetch(:custom_domain).to_s.length > 0 || (get(:use_cdn) == true || get(:use_cdn) == "yes" || get(:use_cdn) == "true")
223
+ end
224
+
225
+ def remove_build_manifest
226
+ set(:build_manifest, @build_manifest = {})
215
227
  end
216
228
 
217
229
  # TODO
@@ -56,8 +56,12 @@ module Skypager
56
56
  end
57
57
 
58
58
  def sync
59
- return dropbox_pull if dropbox?
60
- return google_sync if google?
59
+ if dropbox?
60
+ dropbox_pull
61
+ dropbox_push_sync
62
+ elsif google?
63
+ google_sync
64
+ end
61
65
  end
62
66
 
63
67
  def dropbox_pull
@@ -67,15 +71,15 @@ module Skypager
67
71
  local = matching_local_path_for(entry.path)
68
72
 
69
73
  if entry.is_deleted
70
- puts "Removing #{ local }"
74
+ puts "== Removing #{ local }"
71
75
  local.rmtree if local.exist?
72
76
  elsif entry.is_dir == true
73
77
  unless local.exist?
74
- puts "Creating #{ local } directory"
78
+ puts "== Creating #{ local } directory"
75
79
  local.mkdir
76
80
  end
77
81
  elsif entry.is_dir == false || entry.is_dir == nil
78
- puts "Downloading #{ entry.size } bytes to #{ local }"
82
+ puts "== Downloading #{ local }"
79
83
  local.open('wb+') do |fh|
80
84
  fh.write(entry.download)
81
85
  end
@@ -90,6 +94,24 @@ module Skypager
90
94
  # Implement google drive folder cloning
91
95
  end
92
96
 
97
+ def files_map
98
+ remotes = all_remote_files
99
+
100
+ fmap = {}
101
+
102
+ if dropbox?
103
+ all_local_files.each do |e|
104
+ remote = remotes.find do |x|
105
+ "#{x[:path]}".match(/#{ e[:path] }$/)
106
+ end
107
+
108
+ fmap[e[:path]] = {local: e, remote: remote}
109
+ end
110
+ end
111
+
112
+ fmap
113
+ end
114
+
93
115
  def newer_local_files
94
116
  remotes = all_remote_files
95
117
 
@@ -189,7 +211,12 @@ module Skypager
189
211
  newer_local_files.each do |entry|
190
212
  target = "#{ path_prefix }/#{ entry[:path] }"
191
213
  target = target.gsub(/^\//,'')
192
- api.upload(target, entry[:realpath].read, overwrite: true)
214
+
215
+ puts "== Attempting to sync #{ entry[:realpath] } to #{ target }"
216
+
217
+ if entry[:realpath].file?
218
+ api.upload(target, entry[:realpath].read, overwrite: true)
219
+ end
193
220
  end
194
221
  end
195
222
 
@@ -1,3 +1,3 @@
1
1
  module Skypager
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'hashie'
22
22
  spec.add_dependency 'commander'
23
23
  spec.add_dependency 'fog'
24
- spec.add_dependency 'dropbox-api'
24
+ spec.add_dependency 'dropbox-api', '>= 0.4.3'
25
25
  spec.add_dependency 'google_drive'
26
26
  spec.add_dependency 'middleman'
27
27
  spec.add_dependency 'rack-contrib'
@@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'dnsimple-ruby'
33
33
  spec.add_dependency 'rack-proxy'
34
34
  spec.add_dependency 'octokit', '>= 3.0.0'
35
- spec.add_dependency 'whenever'
36
35
 
37
36
  # If I ever wanted to try and bundle up the build server
38
37
  # sweep utility, instead of making it an external cron job
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skypager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-02 00:00:00.000000000 Z
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.4.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.4.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: google_drive
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -206,20 +206,6 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: 3.0.0
209
- - !ruby/object:Gem::Dependency
210
- name: whenever
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - ">="
214
- - !ruby/object:Gem::Version
215
- version: '0'
216
- type: :runtime
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - ">="
221
- - !ruby/object:Gem::Version
222
- version: '0'
223
209
  - !ruby/object:Gem::Dependency
224
210
  name: aws-sdk-core
225
211
  requirement: !ruby/object:Gem::Requirement
@@ -322,6 +308,7 @@ description: Skypager is for launching your websites
322
308
  email:
323
309
  - jonathan.soeder@gmail.com
324
310
  executables:
311
+ - bootstrap.sh
325
312
  - skypager
326
313
  extensions: []
327
314
  extra_rdoc_files: []
@@ -335,6 +322,7 @@ files:
335
322
  - README.md
336
323
  - Rakefile
337
324
  - VISION.md
325
+ - bin/bootstrap.sh
338
326
  - bin/skypager
339
327
  - examples/.gitignore
340
328
  - examples/blog-site/.gitignore