scatter_deploy 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +54 -0
  2. data/lib/scatter.rb +1 -1
  3. data/lib/scatter/cli.rb +18 -14
  4. metadata +1 -1
data/README.md CHANGED
@@ -1,3 +1,57 @@
1
1
  # Scatter
2
2
 
3
3
  A deploy helper.
4
+
5
+ ## Installation
6
+
7
+ `gem install scatter_deploy`
8
+
9
+ If your Gem directory is in your `PATH`, you'll now have access to the `scatter` command. Run `scatter help` for an overview.
10
+
11
+ ## Usage
12
+
13
+ You interact with Scatter through the `scatter` command. You can see a basic overview with `scatter help`.
14
+
15
+ ```
16
+ Tasks:
17
+ scatter cap COMMAND # Run arbitrary Capistrano commands.
18
+ scatter deploy # Run a deploy routine. This is the default task.
19
+ scatter execute COMMAND # Run arbitrary commands.
20
+ scatter help [TASK] # Describe available tasks or one specific task
21
+ scatter version # Show version.
22
+
23
+ Options:
24
+ -d, [--directory=DIRECTORY] # Specify a deploys directory.
25
+ # Default: /Users/evan/.deploys
26
+ -p, [--project=PROJECT] # Specify a project path, defaults to current Git repository root.
27
+ -s, [--shared=SHARED] # Use a deploy script in the __shared directory. The project path will automatically be passed as an argument
28
+ ```
29
+
30
+ All commands take three optional flags, `--directory`, `--project`, and `--shared`.
31
+
32
+ ## Flags
33
+
34
+ * `--directory`, `-d`: Specify the root of your deploys directory. Defaults to `~/.deploys`.
35
+ * `--project`, `-p`: Specify a path to a project (relative or absolute). Defaults to the root of the current Git repository, if one exists. If you're not in a Git repository you *must* pass this argument.
36
+ * `--shared`, `-s`: Specify a shared deploy command to use instead of a project-specific script. The absolute project path will be passed as an argument to the command.
37
+
38
+ ## Commands
39
+
40
+ ### `scatter` or `scatter deploy`
41
+
42
+ Scatter's default task is `deploy`, so running `scatter deploy` is exactly the same as running `scatter`. The `deploy` command will look first for an executable file called `deploy` in the project-specific deploy directory, then for a `Capfile`. If it finds an executable, it will run it. If no executable is found, but a `Capfile` is found, it will run `cap deploy`.
43
+
44
+ ### `scatter cap COMMAND`
45
+
46
+ Let's you run arbitrary Capistrano commands, e.g. `scatter cap nginx:restart`. All commands will be proxied to the project-specific deploy directory, which must contain a `Capfile` and config.
47
+
48
+ ### `scatter exec COMMAND`
49
+
50
+ Let's you run arbitrary shell commands in the project-specific deploy directory, e.g. `scatter exec ls`.
51
+
52
+ ## Examples
53
+
54
+ * `scatter`: Deploy the current project.
55
+ * `scatter -p projectname`: Deploy the project in `./projectname`.
56
+ * `scatter -p ~/projectname`: Deploy the project in your home directory's `projectname` directory.
57
+ * `scatter -s wp`: Deploy the current project by calling `~/.deploys/__shared/wp` and passing your current Git repository's root as an argument.
data/lib/scatter.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'scatter/cli'
2
2
 
3
3
  module Scatter
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/scatter/cli.rb CHANGED
@@ -12,12 +12,12 @@ module Scatter
12
12
  class_option :project,
13
13
  :aliases => "-p",
14
14
  :type => :string,
15
- :desc => "Specify a project, defaults to current Git root's basename."
15
+ :desc => "Specify a project path, defaults to current Git repository root."
16
16
 
17
17
  class_option :shared,
18
18
  :aliases => "-s",
19
19
  :type => :string,
20
- :desc => "Use a deploy script in the __shared directory. The project name will automatically be passed as an argument"
20
+ :desc => "Use a deploy script in the __shared directory. The project path will automatically be passed as an argument"
21
21
 
22
22
  desc "deploy", "Run a deploy routine. This is the default task."
23
23
  def deploy
@@ -27,11 +27,11 @@ module Scatter
27
27
 
28
28
  desc "cap COMMAND", "Run arbitrary Capistrano commands."
29
29
  def cap(*cmd)
30
- execute "cap", cmd
30
+ exec "cap", cmd
31
31
  end
32
32
 
33
- desc "execute COMMAND", "Run arbitrary commands."
34
- def execute(*cmd)
33
+ desc "exec COMMAND", "Run arbitrary commands."
34
+ def exec(*cmd)
35
35
  run cmd.join ' '
36
36
  end
37
37
 
@@ -46,14 +46,20 @@ module Scatter
46
46
  `git rev-parse --is-inside-work-tree 2>/dev/null`.match "^true"
47
47
  end
48
48
 
49
- def project_name
50
- return options.project if options.project
51
- File.basename `git rev-parse --show-toplevel`.chomp if git?
49
+ def project_path
50
+ if options.project
51
+ File.expand_path options.project
52
+ elsif git?
53
+ `git rev-parse --show-toplevel`.chomp
54
+ end
52
55
  end
53
56
 
54
57
  def project_deploy_dir
55
- return "#{options.directory}/__shared" if options.shared
56
- "#{options.directory}/#{project_name}"
58
+ if options.shared
59
+ "#{options.directory}/__shared"
60
+ elsif project_path
61
+ "#{options.directory}/#{File.basename project_path}"
62
+ end
57
63
  end
58
64
 
59
65
  def capfile?
@@ -66,7 +72,7 @@ module Scatter
66
72
  end
67
73
 
68
74
  def generate_command
69
- return "./#{options.shared} #{project_name}" if options.shared
75
+ return "./#{options.shared} #{project_path}" if options.shared
70
76
  return "./deploy" if executable?
71
77
  return "cap deploy" if capfile?
72
78
  end
@@ -77,9 +83,7 @@ module Scatter
77
83
  return
78
84
  end
79
85
 
80
- command = generate_command unless command
81
-
82
- unless command
86
+ unless command ||= generate_command
83
87
  say "No deploy command found"
84
88
  return
85
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scatter_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: