sapwood 0.0.0 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: caf4b14ba4f07c817b029f1339ed0a8b5d65d154
4
- data.tar.gz: 7eb909444c0c0268da09301c45cd7a4df6178c29
3
+ metadata.gz: ce6caa22fcd690eade509b6b045e16a2a36f2322
4
+ data.tar.gz: 2b419ae8327ca84ab1b6cd31751a0325c609e600
5
5
  SHA512:
6
- metadata.gz: 0ca475c48de4379a11261990a9fb7746877fc7e2303b3af40f6dcb43dbf66dd646ebacca687654a6edd4588b237d45a333b015b0052a170f30d9f649630e96c0
7
- data.tar.gz: fde67c17b93bb2b71f1c64efe8bdbb37b90d4c79aaf157d535bf632d2e361111c35b264a27e1622e7431e3cb373bdbc79c2bec024365698e86f960f2ed7667bf
6
+ metadata.gz: ba7d9565f1a10acd34fc33cc530da1033ea34f10de2f6bded0a96ca007a9a5d549c58f15bb68bfbc43f4db64d1badbc198ae5b9bbcfdbba75494aa981af8db0a
7
+ data.tar.gz: 3c85179041c023dfd9404f0ebddca89bd1c2796ac1c2c002d81b8a2ecfd325b19c1c8b470b34660a6bcc762b2df426a645f85feced9b154fa26391dfb202a673
data/README.md CHANGED
@@ -1,5 +1,136 @@
1
1
  Sapwood CLI
2
2
  ==========
3
3
 
4
- This gem will serve as the command-line interface for the Sapwood application.
5
- It will be documented upon initial release.
4
+ **WARNING! This is ready to be used, but it is built to work closely with
5
+ [Sapwood Developer](https://github.com/seancdavis/sapwood-developer), which is
6
+ not yet ready for use.**
7
+
8
+ Sapwood's command-line interface abstracts much of the maintenance of Sapwood
9
+ from your developers and designers, keeping them focused on developing and
10
+ designing.
11
+
12
+ This project is brand new, so there will exist some kinks to work out with
13
+ different environment setups.
14
+
15
+ Installation
16
+ ----------
17
+
18
+ Sapwood CLI is packaged as a Ruby Gem, and it's best to install it globally on
19
+ your machine.
20
+
21
+ ```text
22
+ $ gem install sapwood
23
+ ```
24
+
25
+ Usage
26
+ ----------
27
+
28
+ Sapwood CLI comes packaged with an executable (hence the *CLI*), as `sapwood`.
29
+ It will always take an *action* as its first argument, like this:
30
+
31
+ ```text
32
+ $ sapwood [ACTION]
33
+ ```
34
+
35
+ See below for details on the actions.
36
+
37
+ Actions
38
+ ----------
39
+
40
+ ### Install
41
+
42
+ Install will install the [Sapwood Developer
43
+ application](https://github.com/seancdavis/sapwood-developer) into
44
+ `~/.sapwood`. Therefore, *you only have to run this once*.
45
+
46
+ This will go through a series of questions to ensure it is installed properly.
47
+
48
+ > **WARNING! You must have a production Sapwood app and database running
49
+ > remotely before you can install Sapwood locally**.
50
+
51
+ ```text
52
+ $ sapwood install
53
+ ```
54
+
55
+ ### Start
56
+
57
+ This starts the Sapwood (Rails) server as a daemon on your local machine.
58
+
59
+ > *Note: It can take several seconds to get started, considering your database
60
+ > is remote.*
61
+
62
+ ```text
63
+ $ sapwood start
64
+ ```
65
+
66
+ > Pay attention to the output. The output will tell you how to access the
67
+ > Sapwood Developer application.
68
+
69
+ ### Stop
70
+
71
+ Stops the Sapwood (Rails) server (kills the daemon process).
72
+
73
+ ```text
74
+ $ sapwood stop
75
+ ```
76
+
77
+ ### Restart
78
+
79
+ Stops and then starts the Sapwood (Rails) server.
80
+
81
+ ```text
82
+ $ sapwood restart
83
+ ```
84
+
85
+ ### Update
86
+
87
+ Updates the Sapwood Developer application.
88
+
89
+ It's important that your developer application and the production application
90
+ are on the same major version (of which there is only one now). But it's also
91
+ good to stay updated so you get all the development features. This simply runs
92
+ a `git pull` on your Sapwood Developer repo.
93
+
94
+ ```text
95
+ $ sapwood update
96
+ ```
97
+
98
+ ### Link
99
+
100
+ Links a project to the Sapwood Developer application.
101
+
102
+ If you're familiar with Sapwood, then you know it's (currently) all about the
103
+ symlinks from a project directory to the necessary location in the rails app.
104
+ Nothing changes here. We're going to first symlink your project (from anywhere
105
+ on your machine) to the `~/.sapwood/projects` directory, and then into the
106
+ rails app itself.
107
+
108
+ **WARNING! This command MUST be run from inside a project directory of a
109
+ project that exists within the Sapwood database.**
110
+
111
+ *Note: Your local repository directory name MUST be named after either the slug
112
+ or the primary domain for that project. Otherwise, it will fail.*
113
+
114
+ ```text
115
+ $ cd /a/sapwood/project/directory
116
+ $ sapwood link
117
+ ```
118
+
119
+ ### Log
120
+
121
+ Tails the log for the Sapwood Developer application. It's like mimicking what
122
+ happens when you run the `rails server` command in the foreground.
123
+
124
+ You can quit this process with `Cmd`+`C`.
125
+
126
+ ```text
127
+ $ sapwood log
128
+ ```
129
+
130
+ Contributing
131
+ ----------
132
+
133
+ You're welcome to fix any bugs or add any small features to interact with the
134
+ developer app. However, at this point, if you want to be involved, I need much
135
+ more help with the Developer and Builder apps themselves, versus the interface
136
+ for working with them.
data/bin/sapwood ADDED
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'highline/import'
4
+ require 'fileutils'
5
+
6
+ action = ARGV[0].nil? ? nil : ARGV[0].downcase
7
+
8
+ def home
9
+ File.expand_path('~')
10
+ end
11
+
12
+ case action
13
+ # ======================================
14
+ # Install Development App
15
+ # ======================================
16
+ when 'install'
17
+ # verify existance of production database (by asking)
18
+ choose do |menu|
19
+ menu.prompt = "Do you have a production database installed and running? "
20
+ menu.choice("Fuck yeah!") do
21
+ say("\nAwesome! Let's get some info about that database...")
22
+ end
23
+ menu.choices("No, I have trouble reading directions.") do
24
+ msg = "\n<%= color('Oh no!', [:bold, :red]) %> "
25
+ msg += "You need to get your production app up and running first."
26
+ msg += "\nThis is just a way to access production data."
27
+ say(msg)
28
+ exit
29
+ end
30
+ end
31
+ # gather database info
32
+ db_host = ask("Host (production IP address): ")
33
+ db_port = ask("PostgreSQL Port (usually it's 5432): ")
34
+ db_name = ask("Database Name: ")
35
+ db_username = ask("PostgreSQL User: ")
36
+ db_password = ask("User's Password (will show as Xs): ") { |q| q.echo = "x" }
37
+ # clone the repo
38
+ say("Good stuff, bro! Now, I shall install the developer app...\n")
39
+ repo_url = 'https://github.com/seancdavis/sapwood-developer.git'
40
+ system "git clone #{repo_url} ~/.sapwood"
41
+ # write the database config
42
+ say("Adding database config...")
43
+ db_config = "development:\n adapter: postgresql\n encoding: unicode"
44
+ db_config += "\n pool: 5\n host: #{db_host}\n username: #{db_username}"
45
+ db_config += "\n password: #{db_password}\n port: #{db_port}"
46
+ db_config += "\n database: #{db_name}\n"
47
+ db_file = "#{home}/.sapwood/config/database.yml"
48
+ File.open(db_file, 'w+') { |f| f.write(db_config) }
49
+ # install gems
50
+ say("Installing gems...")
51
+ system("cd #{home}/.sapwood && bundle install")
52
+ # copying config (temp until config is killed)
53
+ say("Copying config...")
54
+ config_dir = "#{home}/.sapwood/config"
55
+ system("cp #{config_dir}/sapwood.sample.yml #{config_dir}/sapwood.yml")
56
+ # finish up
57
+ msg = "\nAll done! Just run <%= color('sapwood start', [:green, :bold]) %> "
58
+ msg += "to start the server."
59
+ say(msg)
60
+ # ======================================
61
+ # Start Rails Server
62
+ # ======================================
63
+ when 'start'
64
+ pwd = `pwd`.gsub(/\n/, '')
65
+ say("=> Booting Sapwood server...")
66
+ system("cd #{home}/.sapwood && bundle exec rails s -d -p 4141")
67
+ system("cd #{pwd}")
68
+ msg = "\nYou're up and running. Sapwood is now available at "
69
+ msg += "http://localhost:4141."
70
+ say(msg)
71
+ # ======================================
72
+ # Stop Rails Server
73
+ # ======================================
74
+ when 'stop'
75
+ say("=> Sapwood server going down...")
76
+ system("kill $(lsof -ti :4141)")
77
+ say("=> Done.")
78
+ # ======================================
79
+ # Restart Rails Server
80
+ # ======================================
81
+ when 'restart'
82
+ say("=> Sapwood server going down...")
83
+ system("kill $(lsof -ti :4141)")
84
+ say("=> Done.")
85
+ pwd = `pwd`.gsub(/\n/, '')
86
+ say("=> Booting Sapwood server...")
87
+ system("cd #{home}/.sapwood && bundle exec rails s -d -p 4141")
88
+ system("cd #{pwd}")
89
+ msg = "\nYou're up and running. Sapwood is now available at "
90
+ msg += "http://localhost:4141."
91
+ say(msg)
92
+ # ======================================
93
+ # Update Development App
94
+ # ======================================
95
+ when 'update'
96
+ pwd = `pwd`.gsub(/\n/, '')
97
+ system("cd #{home}/.sapwood && git fetch && git pull origin master")
98
+ system("cd #{home}/.sapwood && bundle install")
99
+ system("cd #{pwd}")
100
+ say("\nYou're all up to date!")
101
+ # ======================================
102
+ # Link Project to Sapwood
103
+ # ======================================
104
+ when 'link'
105
+ pwd = `pwd`.gsub(/\n/, '')
106
+ slug = pwd.split('/').last
107
+ sapwood = "#{home}/.sapwood"
108
+ system("ln -sv #{pwd} #{sapwood}/projects")
109
+ system("cd #{sapwood} && bundle exec rake sapwood:project:symlink[#{slug}]")
110
+ # ======================================
111
+ # Watch the Sapwood Log
112
+ # ======================================
113
+ when 'log'
114
+ system("tail -f #{home}/.sapwood/log/development.log")
115
+ # ======================================
116
+ # Missing Argument
117
+ # ======================================
118
+ when nil, ''
119
+ puts "Usage: sapwood [ACTION]"
120
+ exit
121
+ else
122
+ puts "Couldn't find the action: #{action}"
123
+ exit
124
+ end
data/lib/sapwood.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "sapwood/version"
2
2
 
3
3
  module Sapwood
4
- # Your code goes here...
5
4
  end
@@ -1,3 +1,3 @@
1
1
  module Sapwood
2
- VERSION = "0.0.0"
2
+ VERSION = "0.1.0"
3
3
  end
data/sapwood.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Sapwood::VERSION
9
9
  spec.authors = ["Sean C Davis"]
10
10
  spec.email = ["scdavis41@gmail.com"]
11
- spec.summary = %q{}
11
+ spec.summary = %q{Command-line interface for working with Sapwood}
12
12
  spec.description = %q{}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
@@ -20,4 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_dependency 'highline'
23
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapwood
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean C Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-19 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,10 +38,25 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: highline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: ''
42
56
  email:
43
57
  - scdavis41@gmail.com
44
- executables: []
58
+ executables:
59
+ - sapwood
45
60
  extensions: []
46
61
  extra_rdoc_files: []
47
62
  files:
@@ -50,6 +65,7 @@ files:
50
65
  - LICENSE.txt
51
66
  - README.md
52
67
  - Rakefile
68
+ - bin/sapwood
53
69
  - lib/sapwood.rb
54
70
  - lib/sapwood/version.rb
55
71
  - sapwood.gemspec
@@ -73,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
89
  version: '0'
74
90
  requirements: []
75
91
  rubyforge_project:
76
- rubygems_version: 2.2.0
92
+ rubygems_version: 2.4.6
77
93
  signing_key:
78
94
  specification_version: 4
79
- summary: ''
95
+ summary: Command-line interface for working with Sapwood
80
96
  test_files: []