2
2
3
3
# This script simplifies the usage of `katapult` by grouping relevant actions
4
4
# that the user else had to perform manually.
5
- # See bottom for USAGE.
5
+
6
+ usage = <<-USAGE
7
+ Usage: katapult [new APP_NAME | fire [path/to/model] ]
8
+ Suppress database credentials prompt with `--non-interactive`
9
+ USAGE
6
10
7
11
require_relative '../lib/katapult/binary_util'
8
12
util = Katapult ::BinaryUtil
@@ -14,35 +18,35 @@ when 'new'
14
18
basics_command = 'bundle exec rails generate katapult:basics'
15
19
16
20
if interactive
17
- util . puts 'Please enter your database user: '
21
+ util . pink 'Please enter your database user: '
18
22
basics_command << ' --db-user ' << gets . chomp
19
23
20
- util . puts 'Please enter your database password: '
24
+ util . pink 'Please enter your database password: '
21
25
basics_command << ' --db-password ' << gets . chomp
22
26
end
23
27
24
- util . puts 'Creating new Rails application ...'
28
+ util . pink 'Creating new Rails application ...'
25
29
util . create_rails_app app_name
26
30
27
31
Dir . chdir app_name
28
32
29
- util . puts 'Initializing git repository ...'
33
+ util . pink 'Initializing git repository ...'
30
34
util . run 'git init --quiet'
31
35
util . git_commit "rails new #{ app_name } " , '--quiet'
32
36
33
- util . puts 'Installing katapult ...'
37
+ util . pink 'Installing katapult ...'
34
38
File . open ( 'Gemfile' , 'a' ) do |file |
35
39
file . puts "gem 'katapult'#{ ENV [ 'KATAPULT_GEMFILE_OPTIONS' ] } , group: :development"
36
40
end
37
41
util . run 'bundle install --quiet'
38
42
util . run 'bundle exec rails generate katapult:install'
39
43
util . git_commit 'rails generate katapult:install' , '--quiet'
40
44
41
- util . puts 'Generating katapult basics ...'
45
+ util . pink 'Generating katapult basics ...'
42
46
util . run basics_command
43
47
util . git_commit 'rails generate katapult:basics' , '--quiet'
44
48
45
- util . puts <<-INSTRUCTIONS
49
+ util . pink <<-INSTRUCTIONS
46
50
Application initialization done.
47
51
48
52
Next step: Model your application in lib/katapult/application_model.rb and
@@ -53,20 +57,17 @@ when 'fire'
53
57
app_model_path = ARGV . shift || 'lib/katapult/application_model.rb'
54
58
transform_command = 'bin/rails generate katapult:transform ' + app_model_path
55
59
56
- util . puts 'Loading katapult ...'
60
+ util . pink 'Loading katapult ...'
57
61
util . run transform_command
58
62
util . git_commit transform_command
59
63
60
- util . puts <<-INSTRUCTIONS
64
+ util . pink <<-INSTRUCTIONS
61
65
Model transformation done.
62
66
63
67
Now boot up your development server (e.g. with `rails server`) and try your
64
68
kickstarted application in the browser!
65
69
INSTRUCTIONS
66
70
67
71
else
68
- puts <<-USAGE
69
- Usage: katapult [new APP_NAME | fire [path/to/model] ]
70
- Suppress database credentials prompt with `--non-interactive`
71
- USAGE
72
+ puts usage
72
73
end
0 commit comments