codelation-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +22 -0
- data/LICENSE +8 -0
- data/README.md +55 -0
- data/bin/codelation +30 -0
- data/codelation_cli.gemspec +23 -0
- data/lib/codelation.rb +8 -0
- data/lib/codelation/base.rb +22 -0
- data/lib/codelation/development.rb +27 -0
- data/lib/codelation/development/atom.rb +62 -0
- data/lib/codelation/development/atom_packages.rb +37 -0
- data/lib/codelation/development/dot_files.rb +17 -0
- data/lib/codelation/development/postgres.rb +64 -0
- data/lib/codelation/development/rvm.rb +12 -0
- data/lib/codelation/version.rb +36 -0
- data/lib/progress_bar.rb +27 -0
- data/resources/dot_files/.codelation.bash +40 -0
- data/resources/dot_files/.git-completion.bash +2663 -0
- data/resources/dot_files/.git-prompt.sh +445 -0
- data/resources/dot_files/.jshintrc +32 -0
- data/resources/dot_files/.rubocop.yml +18 -0
- data/resources/dot_files/.scss-lint.yml +211 -0
- data/resources/temp/.keep +0 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 09edfdfc18951d9c6a9bdfe025aae8dd489193d3
|
4
|
+
data.tar.gz: bbee352fbe4b608097e1685134a5e147f64f685a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0ef6f537aba1506cc1c39bb7e46c4a217b2e0a5e6c7c819ef138eb56ea92fc6f6b08a06b6b73a9f5c74329b3d71fc58d7ce3d6bed9077a1cd20f8fff4a5f0882
|
7
|
+
data.tar.gz: 94a2d548fd67030ae455b05a6ccf27eca94998879102bbd6bfeb3a20a0fda9f744872481b52f4c72d70ea81d674f7479850f2c2ee60c7e56b7aa8fe64e66671d
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
codelation (0.0.1)
|
5
|
+
open_uri_redirections
|
6
|
+
progressbar
|
7
|
+
rubyzip
|
8
|
+
thor (~> 0.19)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
open_uri_redirections (0.2.1)
|
14
|
+
progressbar (0.21.0)
|
15
|
+
rubyzip (1.1.7)
|
16
|
+
thor (0.19.1)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
codelation!
|
data/LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Name: dokku-installer-cli
|
2
|
+
Copyright (c) 2014 Brian Pattison
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Codelation CLI
|
2
|
+
|
3
|
+
Command line tool for Codelation tasks.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
$ gem install codelation-cli
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```
|
16
|
+
$ codelation help
|
17
|
+
|
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
|
47
|
+
```
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it ( https://github.com/[my-github-username]/codelation-cli/fork )
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create a new Pull Request
|
data/bin/codelation
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require_relative "../lib/codelation"
|
5
|
+
|
6
|
+
module Codelation
|
7
|
+
class Cli < Thor
|
8
|
+
include Thor::Actions
|
9
|
+
# Add the ablitity to run commands like:
|
10
|
+
# `heroku config:set`
|
11
|
+
# This would run the defined method:
|
12
|
+
# `config_set`
|
13
|
+
def method_missing(method, *args, &block)
|
14
|
+
if method.to_s.split(":").length >= 2
|
15
|
+
self.send(method.to_s.gsub(":", "_"), *args)
|
16
|
+
elsif method == :run
|
17
|
+
self.walk(*args)
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# This is the directory where your templates should be placed.
|
24
|
+
def self.source_root
|
25
|
+
File.expand_path("../../resources", __FILE__)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Codelation::Cli.start(ARGV)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "codelation/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "codelation-cli"
|
8
|
+
spec.version = Codelation::VERSION
|
9
|
+
spec.authors = ["Brian Pattison"]
|
10
|
+
spec.email = ["brian@brianpattison.com"]
|
11
|
+
spec.summary = "Command line tool for Codelation tasks"
|
12
|
+
spec.homepage = "https://github.com/codelation/codelation-cli"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "open_uri_redirections", "~> 0.2"
|
20
|
+
spec.add_dependency "progressbar", "~> 0.21"
|
21
|
+
spec.add_dependency "rubyzip", "~> 1.1"
|
22
|
+
spec.add_dependency "thor", "~> 0.19"
|
23
|
+
end
|
data/lib/codelation.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative "codelation/base"
|
2
|
+
require_relative "codelation/development"
|
3
|
+
require_relative "codelation/development/atom"
|
4
|
+
require_relative "codelation/development/atom_packages"
|
5
|
+
require_relative "codelation/development/dot_files"
|
6
|
+
require_relative "codelation/development/postgres"
|
7
|
+
require_relative "codelation/development/rvm"
|
8
|
+
require_relative "codelation/version"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "json"
|
2
|
+
require "net/http"
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module Codelation
|
6
|
+
class Cli < Thor
|
7
|
+
private
|
8
|
+
|
9
|
+
def print_heading(heading)
|
10
|
+
puts "-----> #{heading}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def print_command(command)
|
14
|
+
puts " #{command}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def run_command(command)
|
18
|
+
print_command(command)
|
19
|
+
`#{command}`
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
require "open_uri_redirections"
|
3
|
+
require "progressbar"
|
4
|
+
require_relative "../progress_bar"
|
5
|
+
require "thor"
|
6
|
+
|
7
|
+
module Codelation
|
8
|
+
class Cli < Thor
|
9
|
+
desc "development:install", "Install the development tools used by Codelation"
|
10
|
+
def development_install
|
11
|
+
print_heading("Installing Atom.app")
|
12
|
+
install_atom
|
13
|
+
|
14
|
+
print_heading("Installing Atom Packages")
|
15
|
+
install_atom_packages
|
16
|
+
|
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
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
require "open_uri_redirections"
|
3
|
+
require "progressbar"
|
4
|
+
require_relative "../../progress_bar"
|
5
|
+
require "thor"
|
6
|
+
|
7
|
+
module Codelation
|
8
|
+
class Cli < Thor
|
9
|
+
ATOM_APP_DOWNLOAD_URL = "https://atom.io/download/mac"
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Install Atom.app
|
14
|
+
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)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
require "open_uri_redirections"
|
3
|
+
require "progressbar"
|
4
|
+
require_relative "../../progress_bar"
|
5
|
+
require "thor"
|
6
|
+
|
7
|
+
module Codelation
|
8
|
+
class Cli < Thor
|
9
|
+
private
|
10
|
+
|
11
|
+
# Install an Atom package
|
12
|
+
# @param [String] package
|
13
|
+
def apm_install(package)
|
14
|
+
print_command("Installing #{package}")
|
15
|
+
`/Applications/Atom.app/Contents/Resources/app/apm/bin/apm install #{package}`
|
16
|
+
end
|
17
|
+
|
18
|
+
# Install Atom.app Packages
|
19
|
+
def install_atom_packages
|
20
|
+
packages = %w(
|
21
|
+
color-picker
|
22
|
+
erb-snippets
|
23
|
+
linter
|
24
|
+
linter-csslint
|
25
|
+
linter-erb
|
26
|
+
linter-jshint
|
27
|
+
linter-php
|
28
|
+
linter-ruby
|
29
|
+
linter-scss-lint
|
30
|
+
remote-atom
|
31
|
+
)
|
32
|
+
packages.each do |package|
|
33
|
+
apm_install(package)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Codelation
|
4
|
+
class Cli < Thor
|
5
|
+
private
|
6
|
+
|
7
|
+
# Install dot files and load them into ~/.bash_profile
|
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"
|
12
|
+
copy_file "dot_files/.jshintrc", "~/.jshintrc"
|
13
|
+
copy_file "dot_files/.rubocop.yml", "~/.rubocop.yml"
|
14
|
+
copy_file "dot_files/.scss-lint.yml", "~/.scss-lint.yml"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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
|
+
POSTGRES_APP_DOWNLOAD_URL = "https://github.com/PostgresApp/PostgresApp/releases/download/9.4.1.0/Postgres-9.4.1.0.zip"
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# Install Postgres.app
|
16
|
+
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)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,12 @@
|
|
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
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "json"
|
2
|
+
require "open-uri"
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module Codelation
|
6
|
+
VERSION = "0.0.1"
|
7
|
+
|
8
|
+
class Cli < Thor
|
9
|
+
desc "update", "Update codelation-cli to latest version"
|
10
|
+
def update
|
11
|
+
command = "gem install codelation-cli"
|
12
|
+
puts "Running #{command}..."
|
13
|
+
exec(command)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "version", "Show version information"
|
17
|
+
def version
|
18
|
+
gem_version = "v#{Codelation::VERSION}"
|
19
|
+
|
20
|
+
# Grab the latest version of the RubyGem
|
21
|
+
rubygems_json = open("https://rubygems.org/api/v1/gems/codelation-cli.json").read
|
22
|
+
rubygems_version = "v#{JSON.parse(rubygems_json)["version"].strip}"
|
23
|
+
|
24
|
+
upgrade_message = ""
|
25
|
+
if gem_version != rubygems_version
|
26
|
+
upgrade_message = " Run `codelation update` to install"
|
27
|
+
end
|
28
|
+
|
29
|
+
puts
|
30
|
+
puts "Codelation CLI"
|
31
|
+
puts " Installed: #{gem_version}"
|
32
|
+
puts " Latest: #{rubygems_version}#{upgrade_message}"
|
33
|
+
puts
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|