3
3
# This script simplifies the usage of `katapult` by grouping relevant actions
4
4
# that the user else had to perform manually.
5
5
6
- usage = 'Usage: katapult new APP_NAME | fire [path/to/model] | version'
7
-
8
6
require_relative '../lib/katapult/version'
9
7
require_relative '../lib/katapult/support/binary_util'
10
8
util = Katapult ::BinaryUtil
@@ -35,6 +33,25 @@ is not supported by this version of katapult.
35
33
Please switch to Ruby #{ supported_ruby } and run again.
36
34
MSG
37
35
36
+ # Prepare output ###############################################################
37
+
38
+ # This is also used as README heading
39
+ version = <<-VERSION
40
+ Katapult #{ Katapult ::VERSION }
41
+ Generating a Rails #{ Katapult ::RAILS_VERSION } app on Ruby #{ Katapult ::RUBY_VERSION } .
42
+ VERSION
43
+
44
+ usage = <<-USAGE
45
+ Usage: katapult <command>
46
+
47
+ Commands:
48
+ new APP_NAME Generate a configured Rails application
49
+ fire [PATH] Transform application model into code
50
+ Default path: lib/katapult/application_model.rb
51
+ templates Copy templates to lib/templates/katapult
52
+ version Print version
53
+ USAGE
54
+
38
55
39
56
case ARGV . shift
40
57
when 'new'
@@ -74,18 +91,20 @@ when 'new'
74
91
# Do not use `basics_command` as commit message, it contains the db password!
75
92
util . git_commit 'rails generate katapult:basics' , '--quiet'
76
93
77
- util . pink <<-' INSTRUCTIONS'
94
+ util . pink <<-INSTRUCTIONS
78
95
Application initialization done.
79
96
80
97
Next steps:
81
-
82
- - Run `bundle update` if you want to use the latest versions of all gems
83
- - Configure public/robots.txt
98
+ - \` cd #{ app_name } \`
99
+ - Customize Katapult's template files in lib/templates/katapult
84
100
- Model your application in lib/katapult/application_model.rb and transform it
85
- into code by running `katapult fire`
101
+ into code by running \` katapult fire\`
102
+ - Run \` bundle update\` if you want to use the latest versions of all gems
103
+ - Configure public/robots.txt
86
104
- Write a README
87
105
INSTRUCTIONS
88
106
107
+
89
108
when 'fire'
90
109
app_model_path = ARGV . shift || 'lib/katapult/application_model.rb'
91
110
transform_command = 'bin/rails generate katapult:transform ' + app_model_path
@@ -103,13 +122,18 @@ Now boot up your development server (e.g. with `rails server`) and try your
103
122
kickstarted application in the browser!
104
123
INSTRUCTIONS
105
124
106
- when 'version' , '-v'
107
- # This output is also used as README heading
108
- puts <<-VERSION
109
- Katapult #{ Katapult ::VERSION }
110
- Generating a Rails #{ Katapult ::RAILS_VERSION } app on Ruby #{ Katapult ::RUBY_VERSION } .
111
- VERSION
125
+
126
+ when 'templates'
127
+ util . run 'bundle exec rails generate katapult:templates'
128
+ util . pink 'Templates copied to lib/templates/katapult.'
129
+
130
+
131
+ when 'version'
132
+ puts version
133
+
112
134
113
135
else
136
+ puts version
137
+ puts
114
138
puts usage
115
139
end
0 commit comments