10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/whoosh/cli/project_generator.rb', line 10
def self.create(name, root: Dir.pwd, minimal: false, full: false)
dir = File.join(root, name)
FileUtils.mkdir_p(dir)
%w[config endpoints schemas models middleware db/migrations test/endpoints].each do |d|
FileUtils.mkdir_p(File.join(dir, d))
end
jwt_secret = SecureRandom.hex(32)
write(dir, "app.rb", app_rb(name))
write(dir, "config.ru", config_ru)
write(dir, "Gemfile", gemfile(minimal: minimal, full: full))
write(dir, "Rakefile", rakefile)
write(dir, "config/app.yml", app_yml(name))
write(dir, "config/plugins.yml", plugins_yml)
write(dir, "endpoints/health.rb", health_endpoint)
write(dir, "schemas/health.rb", health_schema)
write(dir, "test/test_helper.rb", test_helper)
write(dir, ".env", env_file(jwt_secret))
write(dir, ".env.example", env_example)
write(dir, ".gitignore", gitignore)
write(dir, ".rspec", rspec_config)
write(dir, "Dockerfile", dockerfile)
write(dir, ".dockerignore", dockerignore)
write(dir, ".rubocop.yml", rubocop_config)
write(dir, "README.md", readme(name))
write(dir, "CLAUDE.md", claude_md(name))
FileUtils.mkdir_p(File.join(dir, "db"))
puts "Created #{name}/"
puts ""
Dir.chdir(dir) do
puts "Installing dependencies..."
system("bundle install --quiet")
end
puts ""
puts " #{name}/ is ready!"
puts ""
puts " cd #{name}"
puts " whoosh s # start server at http://localhost:9292"
puts " whoosh s --reload # start with hot reload"
puts ""
puts " http://localhost:9292/health # health check"
puts " http://localhost:9292/healthz # health probes"
puts " http://localhost:9292/docs # Swagger UI"
puts " http://localhost:9292/metrics # Prometheus metrics"
puts ""
puts " whoosh ci # run lint + security + tests"
puts ""
end
|