rigit 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/bin/rig +4 -4
- data/lib/rigit/command_line.rb +1 -1
- data/lib/rigit/commands/build.rb +25 -21
- data/lib/rigit/commands/info.rb +8 -9
- data/lib/rigit/commands/install.rb +12 -13
- data/lib/rigit/commands/list.rb +4 -5
- data/lib/rigit/commands/new_rig.rb +7 -8
- data/lib/rigit/commands/uninstall.rb +11 -11
- data/lib/rigit/commands/update.rb +8 -8
- data/lib/rigit/config.rb +3 -3
- data/lib/rigit/errors.rb +2 -2
- data/lib/rigit/extensions/file_extension.rb +0 -1
- data/lib/rigit/git.rb +3 -5
- data/lib/rigit/prompt.rb +6 -4
- data/lib/rigit/rig.rb +15 -13
- data/lib/rigit/version.rb +2 -2
- data/lib/rigit.rb +1 -1
- metadata +23 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24849e982806b052f0852e0ef6cc392e527a2e08a51ab1c38ab0cb94c58a5903
|
4
|
+
data.tar.gz: 5a23c1af45686400e6211997f9fa72c7c17391235f69c11d789a29f13805a655
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89fd132a363d1a21673b12f7bdc275a16b9b4928a8c7f305de1463e5dfe2f34e99790688d91e06b5604a38e6bd37004a92dc1b46ab6ce5a9f1f14f9d553989e9
|
7
|
+
data.tar.gz: c92d7f4a103e44d3f660b0497798db6357046187ba62b56b8063dd66ad33654902561f10748255a0ce97eed06ede396b4b9cfe5a96725be70d0c0a305a6ea010
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@ Rigit
|
|
2
2
|
==================================================
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/rigit.svg)](https://badge.fury.io/rb/rigit)
|
5
|
-
[![Build Status](https://
|
5
|
+
[![Build Status](https://github.com/DannyBen/apicake/workflows/Test/badge.svg)](https://github.com/DannyBen/apicake/actions?query=workflow%3ATest)
|
6
6
|
[![Maintainability](https://api.codeclimate.com/v1/badges/d13abbe6f7601be78cf5/maintainability)](https://codeclimate.com/github/DannyBen/rigit/maintainability)
|
7
7
|
|
8
8
|
---
|
@@ -227,6 +227,10 @@ after:
|
|
227
227
|
"Install Dependencies": "bundle install"
|
228
228
|
"Initialize git repo": "git init"
|
229
229
|
|
230
|
+
# If set to true, continue running even if the folder is not empty.
|
231
|
+
# This has a similar effect to the --force command line flag.
|
232
|
+
force: false
|
233
|
+
|
230
234
|
# Specify file patterns that should be copoied as is (without variable
|
231
235
|
# replacements).
|
232
236
|
binaries:
|
@@ -269,7 +273,7 @@ you can use [color markers][colsole-colors]
|
|
269
273
|
Example:
|
270
274
|
|
271
275
|
```yaml
|
272
|
-
intro: Welcome to my blue
|
276
|
+
intro: Welcome to my blue b`rig`
|
273
277
|
outro: Installation completed successfully
|
274
278
|
```
|
275
279
|
|
data/bin/rig
CHANGED
@@ -10,12 +10,12 @@ rescue Rigit::Exit => e
|
|
10
10
|
say message unless message == 'Rigit::Exit'
|
11
11
|
exit 1
|
12
12
|
rescue Rigit::ConfigError => e
|
13
|
-
say "
|
13
|
+
say "r`#{e.class} - #{e.message}`"
|
14
14
|
exit 1
|
15
15
|
rescue Rigit::TemplateError => e
|
16
|
-
say "
|
17
|
-
say
|
16
|
+
say "r`#{e.class} - #{e.message}`\nin g`#{e.file}`"
|
17
|
+
say 'Are you escaping % characters as %%?' if e.message.include?('%')
|
18
18
|
rescue TTY::Reader::InputInterrupt
|
19
19
|
say "\nGoodbye"
|
20
20
|
exit 1
|
21
|
-
end
|
21
|
+
end
|
data/lib/rigit/command_line.rb
CHANGED
@@ -17,7 +17,7 @@ module Rigit
|
|
17
17
|
class CommandLine < SuperDocopt::Base
|
18
18
|
version VERSION
|
19
19
|
docopt File.expand_path 'docopt.txt', __dir__
|
20
|
-
subcommands [:build, :install, :uninstall, :update, :info, :list, new: :new_rig]
|
20
|
+
subcommands [:build, :install, :uninstall, :update, :info, :list, { new: :new_rig }]
|
21
21
|
|
22
22
|
include Commands::Build
|
23
23
|
include Commands::Install
|
data/lib/rigit/commands/build.rb
CHANGED
@@ -2,7 +2,6 @@ module Rigit::Commands
|
|
2
2
|
# The {Build} module provides the {#build} command for the {CommandLine}
|
3
3
|
# module.
|
4
4
|
module Build
|
5
|
-
|
6
5
|
# The command line +build+ command.
|
7
6
|
def build
|
8
7
|
BuildHandler.new(args).execute
|
@@ -18,28 +17,28 @@ module Rigit::Commands
|
|
18
17
|
def initialize(args)
|
19
18
|
@args = args
|
20
19
|
@rig_name = args['RIG']
|
21
|
-
@force = args['--force']
|
20
|
+
@force = args['--force'] || (config.has_key?(:force) && config.force)
|
22
21
|
@target_dir = '.'
|
23
22
|
end
|
24
23
|
|
25
24
|
def execute
|
26
|
-
say "Building
|
25
|
+
say "Building g`#{rig_name}`"
|
27
26
|
say config.intro if config.has_key? :intro
|
28
27
|
verify_dirs
|
29
28
|
arguments = prompt.get_input params
|
30
29
|
|
31
30
|
scaffold arguments
|
32
31
|
|
33
|
-
say config.has_key?(:outro) ? config.outro :
|
32
|
+
say config.has_key?(:outro) ? config.outro : 'Done'
|
34
33
|
end
|
35
34
|
|
36
|
-
|
35
|
+
private
|
37
36
|
|
38
37
|
# Call Rig#scaffold while checking each file to see if it should be
|
39
38
|
# overwritten or not.
|
40
39
|
def scaffold(arguments)
|
41
40
|
execute_actions config.before, arguments if config.has_key? :before
|
42
|
-
|
41
|
+
|
43
42
|
rig.scaffold arguments: arguments, target_dir: target_dir do |file|
|
44
43
|
overwrite_file? file
|
45
44
|
end
|
@@ -47,12 +46,12 @@ module Rigit::Commands
|
|
47
46
|
execute_actions config.after, arguments if config.has_key? :after
|
48
47
|
end
|
49
48
|
|
50
|
-
# Execute user-defined system commands.
|
49
|
+
# Execute user-defined system commands.
|
51
50
|
# Actions are expected to be provided as a hash (label=command) and
|
52
51
|
# both labels and commands accept string interpolation +%{tokens}+
|
53
52
|
def execute_actions(actions, arguments)
|
54
53
|
actions.each do |label, command|
|
55
|
-
say "
|
54
|
+
say "g`#{label}`" % arguments
|
56
55
|
system command % arguments
|
57
56
|
end
|
58
57
|
end
|
@@ -60,7 +59,7 @@ module Rigit::Commands
|
|
60
59
|
# Check various scenarios to decide if the file should be overwritten
|
61
60
|
# or not. These are the scenarios covered by this method:
|
62
61
|
# 1. The user provided +--focce+ in the command line
|
63
|
-
# 2. The user answered "overwrite all" or "skip all" when he asked
|
62
|
+
# 2. The user answered "overwrite all" or "skip all" when he asked
|
64
63
|
# about the first conflicting file.
|
65
64
|
# 3. In cases where an additive dir contains a file that was originally
|
66
65
|
# new, approved or rejected - we use this existing knowledge (which
|
@@ -70,7 +69,7 @@ module Rigit::Commands
|
|
70
69
|
|
71
70
|
response_log[file] = true
|
72
71
|
|
73
|
-
unless overwrite_all
|
72
|
+
unless overwrite_all || force
|
74
73
|
if skip_all
|
75
74
|
response_log[file] = false
|
76
75
|
elsif File.exist? file
|
@@ -82,12 +81,18 @@ module Rigit::Commands
|
|
82
81
|
end
|
83
82
|
|
84
83
|
def prompt_user_to_overwrite(file)
|
85
|
-
say "File
|
86
|
-
tty_prompt.expand
|
84
|
+
say "File g`#{file}` already exists."
|
85
|
+
tty_prompt.expand ' Overwrite?' do |menu|
|
87
86
|
menu.choice key: 'y', name: 'overwrite', value: true
|
88
87
|
menu.choice key: 'n', name: 'skip', value: false
|
89
|
-
menu.choice key: 'a', name: 'overwrite all' do
|
90
|
-
|
88
|
+
menu.choice key: 'a', name: 'overwrite all' do
|
89
|
+
@overwrite_all = true
|
90
|
+
true
|
91
|
+
end
|
92
|
+
menu.choice key: 's', name: 'skip all' do
|
93
|
+
@skip_all = true
|
94
|
+
false
|
95
|
+
end
|
91
96
|
end
|
92
97
|
end
|
93
98
|
|
@@ -135,16 +140,16 @@ module Rigit::Commands
|
|
135
140
|
end
|
136
141
|
|
137
142
|
def verify_target_dir
|
138
|
-
return if Dir.empty?(target_dir)
|
143
|
+
return if Dir.empty?(target_dir) || force
|
139
144
|
|
140
145
|
dirstring = target_dir == '.' ? 'Current directory' : "Directory '#{target_dir}'"
|
141
|
-
options = {
|
146
|
+
options = { 'Abort' => :abort, 'Continue here' => :continue, 'Continue in a sub directory' => :create }
|
142
147
|
response = tty_prompt.select "#{dirstring} is not empty.", options, symbols: { marker: '>' }
|
143
|
-
|
148
|
+
|
144
149
|
case response
|
145
150
|
when :abort
|
146
|
-
raise Rigit::Exit,
|
147
|
-
|
151
|
+
raise Rigit::Exit, 'Goodbye'
|
152
|
+
|
148
153
|
when :create
|
149
154
|
create_subdir
|
150
155
|
verify_target_dir
|
@@ -152,12 +157,11 @@ module Rigit::Commands
|
|
152
157
|
end
|
153
158
|
|
154
159
|
def create_subdir
|
155
|
-
folder = tty_prompt.ask
|
160
|
+
folder = tty_prompt.ask 'Sub directory to create:', default: 'app'
|
156
161
|
@target_dir = "#{target_dir}/#{folder}"
|
157
162
|
Dir.mkdir target_dir unless Dir.exist? target_dir
|
158
163
|
say "Creating in #{target_dir}"
|
159
164
|
end
|
160
|
-
|
161
165
|
end
|
162
166
|
end
|
163
167
|
end
|
data/lib/rigit/commands/info.rb
CHANGED
@@ -2,13 +2,12 @@ module Rigit::Commands
|
|
2
2
|
# The {Info} module provides the {#info} command for the {CommandLine}
|
3
3
|
# module.
|
4
4
|
module Info
|
5
|
-
|
6
5
|
# The command line +info+ command.
|
7
6
|
def info
|
8
7
|
InfoHandler.new(args).execute
|
9
8
|
end
|
10
9
|
|
11
|
-
# Internal class to handle the display of metadata about a rig for the
|
10
|
+
# Internal class to handle the display of metadata about a rig for the
|
12
11
|
# {CommandLine} class.
|
13
12
|
class InfoHandler
|
14
13
|
include Colsole
|
@@ -25,13 +24,13 @@ module Rigit::Commands
|
|
25
24
|
info
|
26
25
|
end
|
27
26
|
|
28
|
-
|
27
|
+
private
|
29
28
|
|
30
29
|
def info
|
31
30
|
rig.info.each do |key, value|
|
32
|
-
say "
|
31
|
+
say "g`#{key}`:"
|
33
32
|
say word_wrap " #{value}"
|
34
|
-
say
|
33
|
+
say ''
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
@@ -40,10 +39,10 @@ module Rigit::Commands
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def verify_presence
|
43
|
-
if
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
return if rig.exist?
|
43
|
+
|
44
|
+
say "Cannot find rig g`#{rig_name}`"
|
45
|
+
raise Rigit::Exit
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Rigit::Commands
|
2
|
-
# The {Install} module provides the {#install} command for the
|
2
|
+
# The {Install} module provides the {#install} command for the
|
3
3
|
# {CommandLine} module.
|
4
4
|
module Install
|
5
5
|
# The command line +install+ command.
|
@@ -24,23 +24,22 @@ module Rigit::Commands
|
|
24
24
|
install
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
private
|
28
28
|
|
29
29
|
def install
|
30
|
-
say "Installing
|
30
|
+
say "Installing g`#{repo}`"
|
31
31
|
FileUtils.mkdir_p target_path unless Dir.exist? target_path
|
32
32
|
success = Rigit::Git.clone repo, target_path
|
33
33
|
|
34
34
|
if success
|
35
|
-
say "Rig installed
|
35
|
+
say "Rig installed g`successfully` in g`#{target_path}`"
|
36
36
|
say "To build a new project with this rig, run this in any empty directory:\n"
|
37
|
-
say "
|
37
|
+
say " m`rig build #{rig_name}`\n"
|
38
38
|
else
|
39
39
|
# :nocov:
|
40
|
-
say
|
40
|
+
say 'r`Install failed`'
|
41
41
|
# :nocov:
|
42
42
|
end
|
43
|
-
|
44
43
|
end
|
45
44
|
|
46
45
|
def rig
|
@@ -52,12 +51,12 @@ module Rigit::Commands
|
|
52
51
|
end
|
53
52
|
|
54
53
|
def verify_dirs
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
return unless rig.exist?
|
55
|
+
|
56
|
+
say "Rig g`#{rig_name}` is already installed"
|
57
|
+
say "In order to update it from the source repository, run:\n"
|
58
|
+
say " m`rig update #{rig_name}`\n"
|
59
|
+
raise Rigit::Exit
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
data/lib/rigit/commands/list.rb
CHANGED
@@ -2,13 +2,12 @@ module Rigit::Commands
|
|
2
2
|
# The {List} module provides the {#list} command for the {CommandLine}
|
3
3
|
# module.
|
4
4
|
module List
|
5
|
-
|
6
5
|
# The command line +list+ command.
|
7
6
|
def list
|
8
7
|
ListHandler.new(args).execute
|
9
8
|
end
|
10
9
|
|
11
|
-
# Internal class to handle listing of available rigs for the
|
10
|
+
# Internal class to handle listing of available rigs for the
|
12
11
|
# {CommandLine} class.
|
13
12
|
class ListHandler
|
14
13
|
include Colsole
|
@@ -21,14 +20,14 @@ module Rigit::Commands
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def execute
|
24
|
-
prefix = subfolder ?
|
25
|
-
say "#{prefix} in
|
23
|
+
prefix = subfolder ? 'Subfolders' : 'Rigs'
|
24
|
+
say "#{prefix} in g`#{basedir}`:"
|
26
25
|
dirs.each do |file|
|
27
26
|
say "- #{file}"
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
|
-
|
30
|
+
private
|
32
31
|
|
33
32
|
def dirs
|
34
33
|
files = Dir["#{basedir}/*"]
|
@@ -2,13 +2,12 @@ module Rigit::Commands
|
|
2
2
|
# The {NewRIg} module provides the {#new_rig} command for the {CommandLine}
|
3
3
|
# module.
|
4
4
|
module NewRig
|
5
|
-
|
6
5
|
# The command line +new+ command.
|
7
6
|
def new_rig
|
8
7
|
NewRigHandler.new(args).execute
|
9
8
|
end
|
10
9
|
|
11
|
-
# Internal class to handle the creation of a new rig template for the
|
10
|
+
# Internal class to handle the creation of a new rig template for the
|
12
11
|
# {CommandLine} class.
|
13
12
|
class NewRigHandler
|
14
13
|
include Colsole
|
@@ -23,20 +22,20 @@ module Rigit::Commands
|
|
23
22
|
def execute
|
24
23
|
verify_presence
|
25
24
|
Rigit::Rig.create name
|
26
|
-
say "Rig template created in
|
25
|
+
say "Rig template created in g`#{rig.path}`"
|
27
26
|
end
|
28
27
|
|
29
|
-
|
28
|
+
private
|
30
29
|
|
31
30
|
def rig
|
32
31
|
@rig ||= Rigit::Rig.new name
|
33
32
|
end
|
34
33
|
|
35
34
|
def verify_presence
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
return unless rig.exist?
|
36
|
+
|
37
|
+
say "Rig g`#{name}` already exists, choose a different name"
|
38
|
+
raise Rigit::Exit
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Rigit::Commands
|
2
|
-
# The {Uninstall} module provides the {#uninstall} command for the
|
2
|
+
# The {Uninstall} module provides the {#uninstall} command for the
|
3
3
|
# {CommandLine} module.
|
4
4
|
module Uninstall
|
5
5
|
# The command line +uninstall+ command.
|
@@ -23,23 +23,23 @@ module Rigit::Commands
|
|
23
23
|
uninstall
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
private
|
27
27
|
|
28
28
|
def uninstall
|
29
|
-
say "This will remove
|
30
|
-
continue = tty_prompt.yes?
|
29
|
+
say "This will remove g`#{rig_name}` and delete\n#{target_path}"
|
30
|
+
continue = tty_prompt.yes? 'Continue?', default: false
|
31
31
|
uninstall! if continue
|
32
32
|
end
|
33
33
|
|
34
34
|
def uninstall!
|
35
|
-
say "Uninstalling
|
35
|
+
say "Uninstalling g`#{rig_name}`"
|
36
36
|
success = FileUtils.rm_rf target_path
|
37
37
|
|
38
38
|
if success
|
39
|
-
say
|
39
|
+
say 'Rig uninstalled g`successfully`'
|
40
40
|
else
|
41
41
|
# :nocov:
|
42
|
-
say
|
42
|
+
say 'r`Uninstall failed`'
|
43
43
|
# :nocov:
|
44
44
|
end
|
45
45
|
end
|
@@ -57,10 +57,10 @@ module Rigit::Commands
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def verify_dirs
|
60
|
-
if
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
return if rig.exist?
|
61
|
+
|
62
|
+
say "Rig g`#{rig_name}` is not installed"
|
63
|
+
raise Rigit::Exit
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -19,16 +19,16 @@ module Rigit::Commands
|
|
19
19
|
update
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
private
|
23
23
|
|
24
24
|
def update
|
25
|
-
say "Updating
|
25
|
+
say "Updating g`#{rig_name}`"
|
26
26
|
success = Rigit::Git.pull target_path
|
27
27
|
if success
|
28
|
-
say
|
28
|
+
say 'Rig updated g`successfully`'
|
29
29
|
else
|
30
30
|
# :nocov:
|
31
|
-
say
|
31
|
+
say 'r`Update failed`'
|
32
32
|
# :nocov:
|
33
33
|
end
|
34
34
|
end
|
@@ -42,10 +42,10 @@ module Rigit::Commands
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def verify_dirs
|
45
|
-
if
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
return if rig.exist?
|
46
|
+
|
47
|
+
say "Rig g`#{rig_name}` is not installed"
|
48
|
+
raise Rigit::Exit
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/rigit/config.rb
CHANGED
data/lib/rigit/errors.rb
CHANGED
data/lib/rigit/git.rb
CHANGED
@@ -3,25 +3,23 @@ module Rigit
|
|
3
3
|
class Git
|
4
4
|
# Clones a git repo.
|
5
5
|
def self.clone(repo, target_path)
|
6
|
-
execute %
|
6
|
+
execute %[git clone #{repo} "#{target_path}"]
|
7
7
|
end
|
8
8
|
|
9
9
|
# Pulls a git repo.
|
10
10
|
def self.pull(target_path)
|
11
11
|
Dir.chdir target_path do
|
12
|
-
execute %
|
12
|
+
execute %[git pull]
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
private
|
17
|
-
|
18
16
|
def self.execute(command)
|
19
17
|
if ENV['SIMULATE_GIT']
|
20
18
|
puts "Simulated Execute: #{command}"
|
21
19
|
true
|
22
20
|
else
|
23
21
|
system command
|
24
|
-
$?&.exitstatus
|
22
|
+
$?&.exitstatus&.zero?
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
data/lib/rigit/prompt.rb
CHANGED
@@ -3,7 +3,7 @@ require 'tty-prompt'
|
|
3
3
|
module Rigit
|
4
4
|
# Handles prompt request for user input in batch.
|
5
5
|
# This is a wrapper around +TTY::Prompt+ that gets all the params (typically
|
6
|
-
# from the rig config file), and asks the user for input one by one, while
|
6
|
+
# from the rig config file), and asks the user for input one by one, while
|
7
7
|
# considering prefilled values.
|
8
8
|
class Prompt
|
9
9
|
attr_reader :params, :input
|
@@ -15,16 +15,17 @@ module Rigit
|
|
15
15
|
# Asks the user for input. If a +prefill+ hash is provided, it will be
|
16
16
|
# used for values, and skip asking the user to provide answers for the
|
17
17
|
# ones that are prefilled.
|
18
|
-
def get_input(prefill={})
|
18
|
+
def get_input(prefill = {})
|
19
19
|
@input = {}
|
20
20
|
params.each do |key, spec|
|
21
21
|
next if skip_by_condition? spec
|
22
|
+
|
22
23
|
@input[key] = prefill.has_key?(key) ? prefill[key] : ask(spec)
|
23
24
|
end
|
24
25
|
@input
|
25
26
|
end
|
26
27
|
|
27
|
-
|
28
|
+
private
|
28
29
|
|
29
30
|
def ask(param)
|
30
31
|
text = param.prompt
|
@@ -46,6 +47,7 @@ module Rigit
|
|
46
47
|
|
47
48
|
def skip_by_condition?(spec)
|
48
49
|
return unless spec.has_key? :condition
|
50
|
+
|
49
51
|
key, value = spec.condition.split '='
|
50
52
|
input[key.to_sym] != value
|
51
53
|
end
|
@@ -54,4 +56,4 @@ module Rigit
|
|
54
56
|
@prompt ||= TTY::Prompt.new
|
55
57
|
end
|
56
58
|
end
|
57
|
-
end
|
59
|
+
end
|
data/lib/rigit/rig.rb
CHANGED
@@ -9,7 +9,7 @@ module Rigit
|
|
9
9
|
ENV['RIG_HOME'] ||= File.expand_path('.rigs', Dir.home)
|
10
10
|
end
|
11
11
|
|
12
|
-
# Sets the +RIG_HOME+ environment variable, and the new root path for
|
12
|
+
# Sets the +RIG_HOME+ environment variable, and the new root path for
|
13
13
|
# rigs.
|
14
14
|
def self.home=(path)
|
15
15
|
ENV['RIG_HOME'] = path
|
@@ -19,26 +19,26 @@ module Rigit
|
|
19
19
|
def self.create(name)
|
20
20
|
target_dir = "#{home}/#{name}"
|
21
21
|
template_file = File.expand_path 'template_config.yml', __dir__
|
22
|
-
|
22
|
+
|
23
23
|
FileUtils.mkdir_p "#{target_dir}/base"
|
24
24
|
FileUtils.cp template_file, "#{target_dir}/config.yml"
|
25
25
|
end
|
26
26
|
|
27
|
-
# Returns a new instance of Rig. The +name+ argument should be the name
|
27
|
+
# Returns a new instance of Rig. The +name+ argument should be the name
|
28
28
|
# of an existing (installed) rig.
|
29
29
|
def initialize(name)
|
30
30
|
@name = name
|
31
31
|
end
|
32
32
|
|
33
33
|
# Builds the project from the template rig.
|
34
|
-
def scaffold(arguments: {}, target_dir:'.', &block)
|
35
|
-
scaffold_dir dir: "#{path}/base", arguments: arguments,
|
34
|
+
def scaffold(arguments: {}, target_dir: '.', &block)
|
35
|
+
scaffold_dir dir: "#{path}/base", arguments: arguments,
|
36
36
|
target_dir: target_dir, &block
|
37
37
|
|
38
|
-
arguments.each do |key, value|
|
38
|
+
arguments.each do |key, value|
|
39
39
|
additive_dir = "#{path}/#{key}=#{value}"
|
40
40
|
if Dir.exist? additive_dir
|
41
|
-
scaffold_dir dir: additive_dir, arguments: arguments,
|
41
|
+
scaffold_dir dir: additive_dir, arguments: arguments,
|
42
42
|
target_dir: target_dir, &block
|
43
43
|
end
|
44
44
|
end
|
@@ -54,7 +54,7 @@ module Rigit
|
|
54
54
|
Dir.exist? path
|
55
55
|
end
|
56
56
|
|
57
|
-
# Returns true if the rig has a +config.yml+ file.
|
57
|
+
# Returns true if the rig has a +config.yml+ file.
|
58
58
|
def has_config?
|
59
59
|
File.exist? config_file
|
60
60
|
end
|
@@ -72,13 +72,13 @@ module Rigit
|
|
72
72
|
# Returns metadata about the rig, including all of its config values.
|
73
73
|
def info
|
74
74
|
{
|
75
|
-
name:
|
76
|
-
path:
|
77
|
-
config: (has_config? ? File.read(config_file) : '<empty>')
|
75
|
+
name: name,
|
76
|
+
path: path,
|
77
|
+
config: (has_config? ? File.read(config_file) : '<empty>'),
|
78
78
|
}
|
79
79
|
end
|
80
80
|
|
81
|
-
|
81
|
+
private
|
82
82
|
|
83
83
|
def scaffold_dir(dir:, arguments:, target_dir:)
|
84
84
|
files = Dir.glob("#{dir}/**/*", File::FNM_DOTMATCH) - %w[. ..]
|
@@ -86,7 +86,8 @@ module Rigit
|
|
86
86
|
|
87
87
|
files.each do |file|
|
88
88
|
target_file = get_target_filename file, arguments, target_dir, dir
|
89
|
-
next if block_given?
|
89
|
+
next if block_given? && !yield(target_file)
|
90
|
+
|
90
91
|
content = get_file_content file, arguments
|
91
92
|
File.deep_write target_file, content
|
92
93
|
end
|
@@ -114,6 +115,7 @@ module Rigit
|
|
114
115
|
|
115
116
|
def binary?(file)
|
116
117
|
return false unless config.binaries
|
118
|
+
|
117
119
|
config.binaries.each do |pattern|
|
118
120
|
return true if File.fnmatch pattern, file
|
119
121
|
end
|
data/lib/rigit/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Rigit
|
2
|
-
VERSION =
|
3
|
-
end
|
2
|
+
VERSION = '0.3.0'
|
3
|
+
end
|
data/lib/rigit.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rigit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: colsole
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.8.1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 0.8.1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: configatron
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,33 +45,33 @@ dependencies:
|
|
39
45
|
- !ruby/object:Gem::Version
|
40
46
|
version: '4.5'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
48
|
+
name: super_docopt
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
53
|
+
version: '0.1'
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
60
|
+
version: '0.1'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
62
|
+
name: tty-prompt
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
67
|
+
version: '0.19'
|
62
68
|
type: :runtime
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
74
|
+
version: '0.19'
|
69
75
|
description: Build project templates with ease
|
70
76
|
email: db@dannyben.com
|
71
77
|
executables:
|
@@ -96,7 +102,8 @@ files:
|
|
96
102
|
homepage: https://dannyben.github.io/rigit/
|
97
103
|
licenses:
|
98
104
|
- MIT
|
99
|
-
metadata:
|
105
|
+
metadata:
|
106
|
+
rubygems_mfa_required: 'true'
|
100
107
|
post_install_message:
|
101
108
|
rdoc_options: []
|
102
109
|
require_paths:
|
@@ -105,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
112
|
requirements:
|
106
113
|
- - ">="
|
107
114
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
115
|
+
version: '3.0'
|
109
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
117
|
requirements:
|
111
118
|
- - ">="
|
112
119
|
- !ruby/object:Gem::Version
|
113
120
|
version: '0'
|
114
121
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
122
|
+
rubygems_version: 3.4.10
|
116
123
|
signing_key:
|
117
124
|
specification_version: 4
|
118
125
|
summary: Zero-coding project scaffolding
|