codelation-cli 0.0.22 → 0.0.23

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: 12774d4ed85f0f9b46f5747ba47e50e0d427896c
4
- data.tar.gz: d6a0d0bb94b6f1fd94f5fffcc0d9de8e1fa531a1
3
+ metadata.gz: 1c49983fc19dcc6cb44a85ec6be53849d4ce7ade
4
+ data.tar.gz: 5342566b55f72e156a2b549e2669a199dbd010d3
5
5
  SHA512:
6
- metadata.gz: 60db40d76f8fc874d3131996fd94027b585f4f66f73a5ff3ef7b917af9a3570e2ad020ac35a24e3a8720a60b7894479f637c197dae1302ddc7fb5f8eae8dcd56
7
- data.tar.gz: a2da3604a5c291402fc49eab984f3bf7c2f547dca96fabe122b876255b46d26bd1fec0aabdecd31a074547dccb1b507b868012bff130ebf273c1c15a1a1a95d1
6
+ metadata.gz: 287cc8a88a1448cea11bbcf58bb644defa6fa99463d500192f4191f0f3e7a08beea22d864e06a853acd3e8a5b3f498c3f94d50e3acef3c71ced818a13f9bd14f
7
+ data.tar.gz: b38b75e8e4a852c58063b9a359372df3a8b02ffd67c31c980af25792d373a08be2221073de6ff9a92431ecd231d7a95d62c78e0d5d7ac9266398d10ed8f070d2
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- codelation-cli (0.0.2)
4
+ codelation-cli (0.0.22)
5
+ activesupport (~> 4.2)
5
6
  open_uri_redirections (~> 0.2)
6
7
  progressbar (~> 0.21)
7
8
  rubyzip (~> 1.1)
@@ -10,13 +11,28 @@ PATH
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
14
+ activesupport (4.2.5)
15
+ i18n (~> 0.7)
16
+ json (~> 1.7, >= 1.7.7)
17
+ minitest (~> 5.1)
18
+ thread_safe (~> 0.3, >= 0.3.4)
19
+ tzinfo (~> 1.1)
20
+ i18n (0.7.0)
21
+ json (1.8.3)
22
+ minitest (5.8.3)
13
23
  open_uri_redirections (0.2.1)
14
24
  progressbar (0.21.0)
15
25
  rubyzip (1.1.7)
16
26
  thor (0.19.1)
27
+ thread_safe (0.3.5)
28
+ tzinfo (1.2.2)
29
+ thread_safe (~> 0.1)
17
30
 
18
31
  PLATFORMS
19
32
  ruby
20
33
 
21
34
  DEPENDENCIES
22
35
  codelation-cli!
36
+
37
+ BUNDLED WITH
38
+ 1.11.2
data/README.md CHANGED
@@ -16,6 +16,7 @@ $ codelation help
16
16
  Commands:
17
17
  codelation development:install # Install the development tools used by Codelation
18
18
  codelation help [COMMAND] # Describe available commands or one specific command
19
+ codelation rails:new # Generate a new app using Codelation's Rails project template
19
20
  codelation update # Update codelation-cli to latest version
20
21
  codelation version # Show version information
21
22
  ```
@@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
+ spec.add_dependency "activesupport", "~> 4.2"
19
20
  spec.add_dependency "open_uri_redirections", "~> 0.2"
20
21
  spec.add_dependency "progressbar", "~> 0.21"
21
22
  spec.add_dependency "rubyzip", "~> 1.1"
data/lib/codelation.rb CHANGED
@@ -9,4 +9,5 @@ require_relative "codelation/development/postgres"
9
9
  require_relative "codelation/development/psequel"
10
10
  require_relative "codelation/development/ruby"
11
11
  require_relative "codelation/development/sequel_pro"
12
+ require_relative "codelation/rails/new"
12
13
  require_relative "codelation/version"
@@ -48,6 +48,9 @@ module Codelation
48
48
  end
49
49
 
50
50
  `source ~/.bash_profile`
51
+
52
+ print_heading("Adding $PATH to Atom Init Script")
53
+ add_atom_init_script
51
54
  end
52
55
  end
53
56
  end
@@ -2,10 +2,18 @@ require "thor"
2
2
 
3
3
  module Codelation
4
4
  class Cli < Thor
5
- ATOM_APP_DOWNLOAD_URL = "https://atom.io/download/mac"
5
+ ATOM_APP_DOWNLOAD_URL = "https://atom.io/download/mac".freeze
6
6
 
7
7
  private
8
8
 
9
+ # Add the path to the Atom Init Script
10
+ def add_atom_init_script
11
+ init_path = File.expand_path("~/.atom/init.coffee")
12
+ return if File.read(init_path).include?("process.env.PATH")
13
+ path = `echo $PATH`.strip
14
+ append_to_file "~/.atom/init.coffee", "process.env.PATH = \"#{path}\""
15
+ end
16
+
9
17
  # Install Atom.app
10
18
  def install_atom
11
19
  zip_file_path = download_file(ATOM_APP_DOWNLOAD_URL)
@@ -12,16 +12,20 @@ module Codelation
12
12
  sleep 3
13
13
  exec('ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
14
14
  end
15
+ run_command("brew update")
16
+ formulas = %w(bash chruby git heroku-toolbelt imagemagick node openssl ruby-install shellcheck v8 wget)
17
+ formulas.each do |formula|
18
+ brew_install(formula)
19
+ end
20
+ end
21
+
22
+ def brew_install(formula)
23
+ run_command("brew unlink #{formula}") if outdated_formulas.include?("#{formula}\n")
24
+ run_command("brew install #{formula}")
25
+ end
15
26
 
16
- run_command("brew install bash")
17
- run_command("brew install git")
18
- run_command("brew install heroku")
19
- run_command("brew install imagemagick")
20
- run_command("brew install node")
21
- run_command("brew install openssl")
22
- run_command("brew install shellcheck")
23
- run_command("brew install v8")
24
- run_command("brew install wget")
27
+ def outdated_formulas
28
+ @outdated_formulas ||= `brew outdated`
25
29
  end
26
30
  end
27
31
  end
@@ -2,7 +2,7 @@ require "thor"
2
2
 
3
3
  module Codelation
4
4
  class Cli < Thor
5
- POSTGRES_APP_DOWNLOAD_URL = "https://github.com/PostgresApp/PostgresApp/releases/download/9.4.1.0/Postgres-9.4.1.0.zip"
5
+ POSTGRES_APP_DOWNLOAD_URL = "https://github.com/PostgresApp/PostgresApp/releases/download/9.4.1.0/Postgres-9.4.1.0.zip".freeze
6
6
 
7
7
  private
8
8
 
@@ -2,7 +2,7 @@ require "thor"
2
2
 
3
3
  module Codelation
4
4
  class Cli < Thor
5
- PSEQUEL_APP_DOWNLOAD_URL = "http://www.psequel.com/download?version=latest"
5
+ PSEQUEL_APP_DOWNLOAD_URL = "http://www.psequel.com/download?version=latest".freeze
6
6
 
7
7
  private
8
8
 
@@ -3,57 +3,36 @@ require "thor"
3
3
 
4
4
  module Codelation
5
5
  class Cli < Thor
6
- RUBY_INSTALL_VERSION = "0.6.0"
7
- RUBY_INSTALL_URL = "https://github.com/postmodern/ruby-install/archive/v#{RUBY_INSTALL_VERSION}.tar.gz"
8
- RUBY_VERSION = "2.3.0"
6
+ RUBY_INSTALL_VERSION = "0.6.0".freeze
7
+ RUBY_INSTALL_URL = "https://github.com/postmodern/ruby-install/archive/v#{RUBY_INSTALL_VERSION}.tar.gz".freeze
8
+ RUBY_VERSION = "2.3.0".freeze
9
9
 
10
10
  private
11
11
 
12
12
  # Install Ruby binary and add it to PATH.
13
13
  def install_ruby
14
- return if `~/.codelation/ruby/bin/ruby -v`.include?(RUBY_VERSION)
14
+ return if `ruby -v`.include?(RUBY_VERSION)
15
+
16
+ # Make sure chruby is loaded
17
+ `source ~/.bash_profile`
15
18
 
16
19
  # Remove existing Ruby install from older version
17
20
  ruby_directory = File.expand_path("~/.codelation/ruby")
18
21
  FileUtils.rm_rf(ruby_directory) if Dir.exist?(ruby_directory)
19
22
 
20
- # Create the directory ~/.codelation/temp if it doesn't exist
21
- FileUtils.mkdir_p(File.expand_path("~/.codelation/temp"))
22
-
23
- print_command("Installing ruby-install")
24
- install_ruby_install
25
-
26
- print_command("Installing Ruby #{RUBY_VERSION} to ~/.codelation/ruby")
27
- `ruby-install -i ~/.codelation/ruby ruby #{RUBY_VERSION}`
23
+ print_command("Installing Ruby #{RUBY_VERSION}")
24
+ `ruby-install ruby #{RUBY_VERSION}`
28
25
 
29
26
  print_heading("Installing Ruby Gems")
30
27
  install_gems
31
-
32
- ruby_install_cleanup
33
28
  end
34
29
 
35
30
  # Install the Ruby gems needed for development.
36
31
  def install_gems
37
- %w(bundler codelation-cli dogids-cli rubocop scss-lint).each do |gem|
32
+ %w(bundler codelation-cli dogids-cli rubocop scss_lint).each do |gem|
38
33
  print_command("gem install #{gem}")
39
- `~/.codelation/ruby/bin/gem install #{gem}`
34
+ `gem install #{gem}`
40
35
  end
41
36
  end
42
-
43
- # Install ruby-install from https://github.com/postmodern/ruby-install.
44
- def install_ruby_install
45
- @downloaded_file_path = File.expand_path(File.join("~/.codelation", "temp", "ruby-install.tar.gz"))
46
- `curl -L -o #{@downloaded_file_path} #{RUBY_INSTALL_URL}`
47
- `tar -xzvf #{@downloaded_file_path} -C #{File.expand_path(File.join("~/.codelation", "temp"))}`
48
-
49
- @extracted_path = File.expand_path(File.join("~/.codelation", "temp", "ruby-install-#{RUBY_INSTALL_VERSION}"))
50
- `cd #{@extracted_path} && sudo make install`
51
- end
52
-
53
- # Delete temporary files from installing Ruby.
54
- def ruby_install_cleanup
55
- File.delete(@downloaded_file_path)
56
- FileUtils.rm_rf(@extracted_path) if Dir.exist?(@extracted_path)
57
- end
58
37
  end
59
38
  end
@@ -2,7 +2,7 @@ require "thor"
2
2
 
3
3
  module Codelation
4
4
  class Cli < Thor
5
- SEQUEL_PRO_APP_DOWNLOAD_URL = "http://codelation-cli.s3.amazonaws.com/sequel-pro-1.0.2.zip"
5
+ SEQUEL_PRO_APP_DOWNLOAD_URL = "http://codelation-cli.s3.amazonaws.com/sequel-pro-1.0.2.zip".freeze
6
6
 
7
7
  private
8
8
 
@@ -0,0 +1,93 @@
1
+ require "fileutils"
2
+ require "thor"
3
+ require "active_support"
4
+ require "active_support/core_ext"
5
+
6
+ module Codelation
7
+ class Cli < Thor
8
+ desc "rails:new", "Generate a new app using Codelation's Rails project template"
9
+ long_desc <<-LONGDESC
10
+ Generates a new app using Codelation's Rails project template
11
+ - https://github.com/codelation/rails-project-template.git
12
+ LONGDESC
13
+ def rails_new
14
+ github_url = ask("Enter the project's GitHub URL (or enter an app name):")
15
+ return if github_url.blank?
16
+
17
+ print_heading("Generating New Rails Application")
18
+ app_name = github_url.split("/").last.gsub(".git", "")
19
+
20
+ print_command("Cloning the Rails project template")
21
+ run_command("git clone https://github.com/codelation/rails-project-template.git #{app_name}")
22
+
23
+ print_command("Deleting the template's git history")
24
+ FileUtils.rm_rf("./#{app_name}/.git")
25
+
26
+ print_command("Configuring your application")
27
+ replace_app_name(app_name)
28
+ generate_secret_tokens(app_name)
29
+
30
+ Dir.chdir(app_name) do
31
+ print_command("Initializing git repository")
32
+ run_command("git init")
33
+ run_command("git remote add origin #{github_url}.git")
34
+ run_command("git add .")
35
+ run_command('git commit -m "Initial commit"')
36
+
37
+ print_command("Installing dependencies")
38
+ run_command("bundle install")
39
+
40
+ return if no?("-----> Setup database? [y/N]")
41
+ run_command("rake db:setup")
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ # Generate secret tokens for development and test environments
48
+ def generate_secret_tokens(app_name)
49
+ secrets_path = "./#{app_name}/config/secrets.yml"
50
+ original_text = File.read(secrets_path)
51
+ File.open(secrets_path, "w") do |file|
52
+ file.puts original_text
53
+ .gsub("development_secret_key_base", SecureRandom.hex(64))
54
+ .gsub("test_secret_key_base", SecureRandom.hex(64))
55
+ end
56
+ end
57
+
58
+ # The files that contain any version of "Rails Project Template" that need
59
+ # to be replaced with the new app's name.
60
+ # @return [Array]
61
+ def rails_project_template_files
62
+ [
63
+ "config/initializers/active_admin.rb",
64
+ "config/initializers/session_store.rb",
65
+ "config/locales/en.yml",
66
+ "config/application.rb",
67
+ "config/database.yml",
68
+ "config/routes.rb",
69
+ "README.md"
70
+ ]
71
+ end
72
+
73
+ # Replaces all versions of "Rails Project Template" with the app name equivalent.
74
+ # @param app_name [String]
75
+ def replace_app_name(app_name)
76
+ app_title = app_name.titleize
77
+ app_class_name = app_name.underscore.camelize
78
+ app_underscored_name = app_name.underscore
79
+
80
+ rails_project_template_files.each do |file_path|
81
+ relative_path = File.join("./#{app_name}", file_path)
82
+ original_text = File.read(relative_path)
83
+ File.open(relative_path, "w") do |file|
84
+ file.puts original_text
85
+ .gsub("Rails Project Template", app_title)
86
+ .gsub("RailsProjectTemplate", app_class_name)
87
+ .gsub("rails_project_template", app_underscored_name)
88
+ .gsub("rails-project-template", app_name)
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -3,7 +3,7 @@ require "open-uri"
3
3
  require "thor"
4
4
 
5
5
  module Codelation
6
- VERSION = "0.0.22"
6
+ VERSION = "0.0.23".freeze
7
7
 
8
8
  class Cli < Thor
9
9
  desc "update", "Update codelation-cli to latest version"
@@ -11,8 +11,14 @@ alias ss="bundle exec rake start"
11
11
  # Add Postgres commands from Postgres.app
12
12
  PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
13
13
 
14
- # Add Ruby binary to PATH first, overriding the system Ruby
15
- PATH=./bin:~/.codelation/ruby/bin:$PATH
14
+ # Add ./bin to make running Rails commands with Spring the default
15
+ PATH=./bin:$PATH
16
+
17
+ # Include chruby for switching between Ruby versions
18
+ source /usr/local/opt/chruby/share/chruby/chruby.sh
19
+
20
+ # Set the default Ruby version
21
+ chruby ruby-2.3.0
16
22
 
17
23
  # Git Completion & Repo State
18
24
  # http://neverstopbuilding.com/gitpro
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codelation-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Pattison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-08 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: open_uri_redirections
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +107,7 @@ files:
93
107
  - lib/codelation/development/psequel.rb
94
108
  - lib/codelation/development/ruby.rb
95
109
  - lib/codelation/development/sequel_pro.rb
110
+ - lib/codelation/rails/new.rb
96
111
  - lib/codelation/version.rb
97
112
  - lib/progress_bar.rb
98
113
  - resources/dot_files/.codelation.bash