codelation-cli 0.0.1 → 0.0.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
  SHA1:
3
- metadata.gz: 09edfdfc18951d9c6a9bdfe025aae8dd489193d3
4
- data.tar.gz: bbee352fbe4b608097e1685134a5e147f64f685a
3
+ metadata.gz: c85934c0306870e1f8d25b2138a30d43499766b7
4
+ data.tar.gz: 51a0e8d75c9f428478d595f2bec61e02bcad156f
5
5
  SHA512:
6
- metadata.gz: 0ef6f537aba1506cc1c39bb7e46c4a217b2e0a5e6c7c819ef138eb56ea92fc6f6b08a06b6b73a9f5c74329b3d71fc58d7ce3d6bed9077a1cd20f8fff4a5f0882
7
- data.tar.gz: 94a2d548fd67030ae455b05a6ccf27eca94998879102bbd6bfeb3a20a0fda9f744872481b52f4c72d70ea81d674f7479850f2c2ee60c7e56b7aa8fe64e66671d
6
+ metadata.gz: adbc4e22f3a81e94a8408dc6fe616c057976f4e14be51ae25313f3711c6eedebca5c7d502a21dbf7198dff3c7e336e44223cf9a1994e3fbbfd6d9a761ab3a1e5
7
+ data.tar.gz: 4d8af70a159d4892c7176ec86923da3bfe08992a7596ede7713a6efcf295faead3718e7326cc2b19960f21e93e5cd2105798f93647f42de6a65d4c5bf3d9cd97
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in dokku_installer_cli.gemspec
4
4
  gemspec
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- codelation (0.0.1)
5
- open_uri_redirections
6
- progressbar
7
- rubyzip
4
+ codelation-cli (0.0.2)
5
+ open_uri_redirections (~> 0.2)
6
+ progressbar (~> 0.21)
7
+ rubyzip (~> 1.1)
8
8
  thor (~> 0.19)
9
9
 
10
10
  GEM
@@ -19,4 +19,4 @@ PLATFORMS
19
19
  ruby
20
20
 
21
21
  DEPENDENCIES
22
- codelation!
22
+ codelation-cli!
data/README.md CHANGED
@@ -16,34 +16,10 @@ $ gem install codelation-cli
16
16
  $ codelation help
17
17
 
18
18
  Commands:
19
- dokku config # Display the app's environment variables
20
- dokku config:get KEY # Display an environment variable value
21
- dokku config:set KEY1=VALUE1 [KEY2=VALUE2 ...] # Set one or more environment variables
22
- dokku config:unset KEY1 [KEY2 ...] # Unset one or more environment variables
23
- dokku domains # Display the app's domains
24
- dokku domains:set DOMAIN1 [DOMAIN2 ...] # Set one or more domains
25
- dokku help [COMMAND] # Describe available commands or one specific command
26
- dokku logs [-t] # Show the last logs for the application (-t follows)
27
- dokku open # Open the application in your default browser
28
- dokku postgres:backups # List available PostgreSQL backups as a numbered list
29
- dokku postgres:backups:create # Create a new PostgreSQL backup
30
- dokku postgres:backups:disable # Disable daily PostgreSQL backups
31
- dokku postgres:backups:download <number> # Download the numbered PostgreSQL backup
32
- dokku postgres:backups:enable # Enable daily PostgreSQL backups
33
- dokku postgres:backups:restore <number> # Restore a numbered PostgreSQL backup
34
- dokku postgres:backups:restore:local <number> # Restore a numbered PostgreSQL backup locally
35
- dokku postgres:export <file.sql> # Export Postgres data to local file
36
- dokku postgres:import <file.sql> # Restore database data from a local file
37
- dokku restart # Restart the application
38
- dokku run <cmd> # Run a command in the environment of the application
39
- dokku ssh # Start an SSH session as root user
40
- dokku ssl:add CRT KEY # Add an SSL endpoint.
41
- dokku ssl:force DOMAIN # Force SSL on the given domain.
42
- dokku ssl:remove # Remove an SSL endpoint.
43
- dokku update # Update dokku-installer-cli to latest version
44
- dokku upgrade # Upgrade the Dokku install on your remote server
45
- dokku url # Show the URL for the application
46
- dokku version # Show version information
19
+ codelation development:install # Install the development tools used by Codelation
20
+ codelation help [COMMAND] # Describe available commands or one specific command
21
+ codelation update # Update codelation-cli to latest version
22
+ codelation version # Show version information
47
23
  ```
48
24
 
49
25
  ## Contributing
@@ -3,6 +3,8 @@ require_relative "codelation/development"
3
3
  require_relative "codelation/development/atom"
4
4
  require_relative "codelation/development/atom_packages"
5
5
  require_relative "codelation/development/dot_files"
6
+ require_relative "codelation/development/install_methods"
6
7
  require_relative "codelation/development/postgres"
7
- require_relative "codelation/development/rvm"
8
+ require_relative "codelation/development/ruby"
9
+ require_relative "codelation/development/sequel_pro"
8
10
  require_relative "codelation/version"
@@ -6,14 +6,20 @@ module Codelation
6
6
  class Cli < Thor
7
7
  private
8
8
 
9
+ # Print a heading to the terminal for commands that are going to be run.
10
+ # @param heading [String]
9
11
  def print_heading(heading)
10
12
  puts "-----> #{heading}"
11
13
  end
12
14
 
15
+ # Print a message to the terminal about a command that's going to run.
16
+ # @param command [String]
13
17
  def print_command(command)
14
18
  puts " #{command}"
15
19
  end
16
20
 
21
+ # Run a command with Bash after first printing the command to the terminal.
22
+ # @param command [String]
17
23
  def run_command(command)
18
24
  print_command(command)
19
25
  `#{command}`
@@ -1,27 +1,29 @@
1
- require "open-uri"
2
- require "open_uri_redirections"
3
- require "progressbar"
4
- require_relative "../progress_bar"
5
1
  require "thor"
6
2
 
7
3
  module Codelation
8
4
  class Cli < Thor
9
5
  desc "development:install", "Install the development tools used by Codelation"
10
6
  def development_install
11
- print_heading("Installing Atom.app")
12
- install_atom
7
+ # print_heading("Installing Atom.app")
8
+ # install_atom
9
+ #
10
+ # print_heading("Installing Atom Packages")
11
+ # install_atom_packages
12
+ #
13
+ # print_heading("Installing Dot Files")
14
+ # install_dot_files
15
+ #
16
+ # print_heading("Installing Postgres.app")
17
+ # install_postgres
13
18
 
14
- print_heading("Installing Atom Packages")
15
- install_atom_packages
19
+ print_heading("Installing Ruby")
20
+ install_ruby
16
21
 
17
- print_heading("Installing Dot Files")
18
- install_dot_files
19
-
20
- print_heading("Installing Postgres.app")
21
- install_postgres
22
-
23
- print_heading("Installing RVM")
24
- install_rvm
22
+ # print_heading("Installing Sequel Pro.app")
23
+ # install_sequel_pro
24
+ #
25
+ # print_heading("Installing Codelation CLI to PATH")
26
+ # install_codelation_cli
25
27
  end
26
28
  end
27
29
  end
@@ -1,7 +1,3 @@
1
- require "open-uri"
2
- require "open_uri_redirections"
3
- require "progressbar"
4
- require_relative "../../progress_bar"
5
1
  require "thor"
6
2
 
7
3
  module Codelation
@@ -12,51 +8,8 @@ module Codelation
12
8
 
13
9
  # Install Atom.app
14
10
  def install_atom
15
- print_command("Downloading from: #{ATOM_APP_DOWNLOAD_URL}")
16
- download_atom
17
- write_atom_zip
18
- extract_atom_zip
19
- end
20
-
21
- # Download Atom.app from https://atom.io
22
- def download_atom
23
- progress_bar = nil
24
- @atom_uri = open(ATOM_APP_DOWNLOAD_URL,
25
- allow_redirections: :all,
26
- content_length_proc: -> (content_length) {
27
- if content_length && content_length > 0
28
- progress_bar = ProgressBar.new(" ", content_length)
29
- progress_bar.file_transfer_mode
30
- end
31
- },
32
- progress_proc: -> (size) {
33
- progress_bar.set(size) if progress_bar
34
- }
35
- )
36
- puts "" # Needed to avoid progress bar weirdness
37
- end
38
-
39
- # Save the downloaded file for Atom.app
40
- # to resources/temp/atom.zip
41
- def write_atom_zip
42
- @atom_zip_file_path = File.join(Cli.source_root, "temp", "atom.zip")
43
- open(@atom_zip_file_path, "wb") do |file|
44
- file.write(@atom_uri.read)
45
- end
46
- end
47
-
48
- # Extract the zip file to /Applications and delete the temp file
49
- def extract_atom_zip
50
- print_command("Extracting Atom.app to /Applications")
51
-
52
- # Delete existing Atom.app
53
- FileUtils.rm_rf("/Applications/Atom.app") if Dir.exist?("/Applications/Atom.app")
54
-
55
- # Unzip temporary file to /Applications/Atom.app
56
- `unzip #{@atom_zip_file_path} -d /Applications`
57
-
58
- # Delete zip file
59
- File.delete(@atom_zip_file_path)
11
+ zip_file_path = download_file(ATOM_APP_DOWNLOAD_URL)
12
+ extract_app_from_zip("Atom.app", zip_file_path)
60
13
  end
61
14
  end
62
15
  end
@@ -6,12 +6,19 @@ module Codelation
6
6
 
7
7
  # Install dot files and load them into ~/.bash_profile
8
8
  def install_dot_files
9
- copy_file "dot_files/.codelation.bash", "~/.codelation.bash"
10
- copy_file "dot_files/.git-completion.bash", "~/.git-completion.bash"
11
- copy_file "dot_files/.git-prompt.sh", "~/.git-prompt.sh"
9
+ # Create the directory ~/.codelation/bash if it doesn't exist
10
+ FileUtils.mkdir_p("~/.codelation/bash")
11
+
12
+ # Copy dot files to ~/.codelation
13
+ copy_file "dot_files/.codelation.bash", "~/.codelation/bash/.codelation.bash"
14
+ copy_file "dot_files/.git-completion.bash", "~/.codelation/bash/.git-completion.bash"
15
+ copy_file "dot_files/.git-prompt.sh", "~/.codelation/bash/.git-prompt.sh"
12
16
  copy_file "dot_files/.jshintrc", "~/.jshintrc"
13
17
  copy_file "dot_files/.rubocop.yml", "~/.rubocop.yml"
14
18
  copy_file "dot_files/.scss-lint.yml", "~/.scss-lint.yml"
19
+
20
+ # Add `source ~/.codelation.bash` to ~/.bash_profile if it doesn't exist
21
+ append_to_file "~/.bash_profile", "source ~/.codelation/bash/.codelation.bash"
15
22
  end
16
23
  end
17
24
  end
@@ -0,0 +1,67 @@
1
+ require "fileutils"
2
+ require "open-uri"
3
+ require "open_uri_redirections"
4
+ require "progressbar"
5
+ require_relative "../../progress_bar"
6
+ require "thor"
7
+ require "zip"
8
+
9
+ module Codelation
10
+ class Cli < Thor
11
+ private
12
+
13
+ # Download a file with a progress bar.
14
+ # @param url [String] The url of the file to be downloaded
15
+ # @param file_name [String] The name of the file to be saved
16
+ def download_file(url)
17
+ print_command("Downloading from: #{url}")
18
+ progress_bar = nil
19
+ @download_uri = open(url,
20
+ allow_redirections: :all,
21
+ content_length_proc: -> (content_length) {
22
+ if content_length && content_length > 0
23
+ progress_bar = ProgressBar.new(" ", content_length)
24
+ progress_bar.file_transfer_mode
25
+ end
26
+ },
27
+ progress_proc: -> (size) {
28
+ progress_bar.set(size) if progress_bar
29
+ }
30
+ )
31
+ puts "" # Needed to avoid progress bar weirdness
32
+ write_downloaded_file(@download_uri)
33
+ end
34
+
35
+ # Save the file downloaded with #download_file to resources/temp.
36
+ # @param uri [URI] The URI of the file to be saved
37
+ def write_downloaded_file(uri)
38
+ file_name = File.basename(uri.path)
39
+ @downloaded_file_path = File.join(Cli.source_root, "temp", file_name)
40
+ open(@downloaded_file_path, "wb") do |file|
41
+ file.write(@download_uri.read)
42
+ end
43
+ @downloaded_file_path
44
+ end
45
+
46
+ # Extract an app from a zip file to /Applications and delete the zip file.
47
+ # @param app_name [String] The name of the app, including .app
48
+ # @param zip_file_path [String] The full path to the zip file containing the app
49
+ def extract_app_from_zip(app_name, zip_file_path)
50
+ print_command("Extracting #{app_name} to /Applications")
51
+
52
+ # Delete existing app
53
+ FileUtils.rm_rf("/Applications/#{app_name}") if Dir.exist?("/Applications/#{app_name}")
54
+
55
+ # Extract app from zip file to /Applications
56
+ extract_from_zip("/Applications", zip_file_path)
57
+ end
58
+
59
+ # Extract files from a zip file to the specified path and delete the zip file.
60
+ # @param unzip_path [String] The full path to unzip the files to
61
+ # @param zip_file_path [String] The full path to the zip file containing the app
62
+ def extract_from_zip(unzip_path, zip_file_path)
63
+ `unzip -o #{zip_file_path} -d #{unzip_path}`
64
+ File.delete(zip_file_path)
65
+ end
66
+ end
67
+ end
@@ -1,10 +1,4 @@
1
- require "fileutils"
2
- require "open-uri"
3
- require "open_uri_redirections"
4
- require "progressbar"
5
- require_relative "../../progress_bar"
6
1
  require "thor"
7
- require "zip"
8
2
 
9
3
  module Codelation
10
4
  class Cli < Thor
@@ -14,51 +8,8 @@ module Codelation
14
8
 
15
9
  # Install Postgres.app
16
10
  def install_postgres
17
- print_command("Downloading from: #{POSTGRES_APP_DOWNLOAD_URL}")
18
- download_postgres
19
- write_postgres_zip
20
- extract_postgres_zip
21
- end
22
-
23
- # Download Postgres.app from http://postgresapp.com
24
- def download_postgres
25
- progress_bar = nil
26
- @postgres_uri = open(POSTGRES_APP_DOWNLOAD_URL,
27
- allow_redirections: :all,
28
- content_length_proc: -> (content_length) {
29
- if content_length && content_length > 0
30
- progress_bar = ProgressBar.new(" ", content_length)
31
- progress_bar.file_transfer_mode
32
- end
33
- },
34
- progress_proc: -> (size) {
35
- progress_bar.set(size) if progress_bar
36
- }
37
- )
38
- puts "" # Needed to avoid progress bar weirdness
39
- end
40
-
41
- # Save the downloaded file for Postgres.app
42
- # to resources/temp/postgres.zip
43
- def write_postgres_zip
44
- @postgres_zip_file_path = File.join(Cli.source_root, "temp", "postgres.zip")
45
- open(@postgres_zip_file_path, "wb") do |file|
46
- file.write(@postgres_uri.read)
47
- end
48
- end
49
-
50
- # Extract the zip file to /Applications and delete the temp file
51
- def extract_postgres_zip
52
- print_command("Extracting Postgres.app to /Applications")
53
-
54
- # Delete existing Postgres.app
55
- FileUtils.rm_rf("/Applications/Postgres.app") if Dir.exist?("/Applications/Postgres.app")
56
-
57
- # Unzip temporary file to /Applications/Postgres.app
58
- `unzip #{@postgres_zip_file_path} -d /Applications`
59
-
60
- # Delete zip file
61
- File.delete(@postgres_zip_file_path)
11
+ zip_file_path = download_file(POSTGRES_APP_DOWNLOAD_URL)
12
+ extract_app_from_zip("Postgres.app", zip_file_path)
62
13
  end
63
14
  end
64
15
  end
@@ -0,0 +1,52 @@
1
+ require "fileutils"
2
+ require "thor"
3
+
4
+ module Codelation
5
+ class Cli < Thor
6
+ RUBY_INSTALL_VERSION = "0.5.0"
7
+ RUBY_INSTALL_URL = "https://github.com/postmodern/ruby-install/archive/v#{RUBY_INSTALL_VERSION}.tar.gz"
8
+ RUBY_VERSION = "2.2.0"
9
+
10
+ private
11
+
12
+ # Install Ruby binary and add it to PATH.
13
+ def install_ruby
14
+ puts RUBY_VERSION
15
+ return if `~/.codelation/ruby/bin/ruby -v`.include?(RUBY_VERSION)
16
+
17
+ print_command("Installing ruby-install")
18
+ install_ruby_install
19
+
20
+ print_command("Installing Ruby #{RUBY_VERSION} to ~/.codelation/ruby")
21
+ `ruby-install -i ~/.codelation/ruby ruby #{RUBY_VERSION}`
22
+
23
+ print_command("Installing Ruby gems")
24
+ install_gems
25
+
26
+ ruby_install_cleanup
27
+ end
28
+
29
+ # Install the Ruby gems needed for development.
30
+ def install_gems
31
+ `~/.codelation/ruby/bin/gem install bundler`
32
+ `~/.codelation/ruby/bin/gem install rubocop`
33
+ `~/.codelation/ruby/bin/gem install scss-lint`
34
+ end
35
+
36
+ # Install ruby-install from https://github.com/postmodern/ruby-install.
37
+ def install_ruby_install
38
+ @downloaded_file_path = File.join(Cli.source_root, "temp", "ruby-install.tar.gz")
39
+ `curl -L -o #{@downloaded_file_path} #{RUBY_INSTALL_URL}`
40
+ `tar -xzvf #{@downloaded_file_path} -C #{File.join(Cli.source_root, "temp")}`
41
+
42
+ @extracted_path = File.join(Cli.source_root, "temp", "ruby-install-#{RUBY_INSTALL_VERSION}")
43
+ `cd #{@extracted_path} && sudo make install`
44
+ end
45
+
46
+ # Delete temporary files from installing Ruby.
47
+ def ruby_install_cleanup
48
+ File.delete(@downloaded_file_path)
49
+ FileUtils.rm_rf(@extracted_path) if Dir.exist?(@extracted_path)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,15 @@
1
+ require "thor"
2
+
3
+ module Codelation
4
+ class Cli < Thor
5
+ SEQUEL_PRO_APP_DOWNLOAD_URL = "http://codelation-cli.s3.amazonaws.com/sequel-pro-1.0.2.zip"
6
+
7
+ private
8
+
9
+ # Install Sequel Pro.app
10
+ def install_sequel_pro
11
+ zip_file_path = download_file(SEQUEL_PRO_APP_DOWNLOAD_URL)
12
+ extract_app_from_zip("Sequel Pro.app", zip_file_path)
13
+ end
14
+ end
15
+ end
@@ -3,7 +3,7 @@ require "open-uri"
3
3
  require "thor"
4
4
 
5
5
  module Codelation
6
- VERSION = "0.0.1"
6
+ VERSION = "0.0.2"
7
7
 
8
8
  class Cli < Thor
9
9
  desc "update", "Update codelation-cli to latest version"
@@ -19,7 +19,7 @@ module Codelation
19
19
 
20
20
  # Grab the latest version of the RubyGem
21
21
  rubygems_json = open("https://rubygems.org/api/v1/gems/codelation-cli.json").read
22
- rubygems_version = "v#{JSON.parse(rubygems_json)["version"].strip}"
22
+ rubygems_version = "v#{JSON.parse(rubygems_json)['version'].strip}"
23
23
 
24
24
  upgrade_message = ""
25
25
  if gem_version != rubygems_version
@@ -12,10 +12,13 @@ alias sshdogids="ssh -R 52698:localhost:52698 -p 22711 root@dogids.com"
12
12
  # Add Postgres commands from Postgres.app
13
13
  PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
14
14
 
15
+ # Add Ruby binary to PATH first, overriding the system Ruby
16
+ PATH=~/.codelation/ruby/bin:$PATH
17
+
15
18
  # Git Completion & Repo State
16
19
  # http://neverstopbuilding.com/gitpro
17
- source ~/.git-completion.bash
18
- source ~/.git-prompt.sh
20
+ source ~/.codelation/bash/.git-completion.bash
21
+ source ~/.codelation/bash/.git-prompt.sh
19
22
 
20
23
  MAGENTA="\[\033[0;35m\]"
21
24
  YELLOW="\[\033[0;33m\]"
@@ -8,11 +8,17 @@ Style/AlignHash:
8
8
  EnforcedHashRocketStyle: table
9
9
  EnforcedColonStyle: table
10
10
 
11
+ Style/Blocks:
12
+ Enabled: false
13
+
11
14
  Style/RedundantSelf:
12
15
  Enabled: false
13
16
 
14
17
  Style/SingleSpaceBeforeFirstArg:
15
18
  Enabled: false
16
19
 
20
+ Style/SpaceInsideBlockBraces:
21
+ SpaceBeforeBlockParameters: false
22
+
17
23
  Style/StringLiterals:
18
24
  EnforcedStyle: double_quotes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codelation-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Pattison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-13 00:00:00.000000000 Z
11
+ date: 2015-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open_uri_redirections
@@ -87,8 +87,10 @@ files:
87
87
  - lib/codelation/development/atom.rb
88
88
  - lib/codelation/development/atom_packages.rb
89
89
  - lib/codelation/development/dot_files.rb
90
+ - lib/codelation/development/install_methods.rb
90
91
  - lib/codelation/development/postgres.rb
91
- - lib/codelation/development/rvm.rb
92
+ - lib/codelation/development/ruby.rb
93
+ - lib/codelation/development/sequel_pro.rb
92
94
  - lib/codelation/version.rb
93
95
  - lib/progress_bar.rb
94
96
  - resources/dot_files/.codelation.bash
@@ -1,12 +0,0 @@
1
- require "thor"
2
-
3
- module Codelation
4
- class Cli < Thor
5
- private
6
- # Install RVM from http://rvm.io
7
- def install_rvm
8
- run_command("\\curl -sSL https://get.rvm.io | bash -s stable --ruby=2.2.0")
9
- run_command("rvm install ruby-2.1.5")
10
- end
11
- end
12
- end