9
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
|
# File 'lib/rubee/cli/project.rb', line 9
def project(argv)
project_name = argv[1]
if project_name.nil?
color_puts('Please indicate project name.', color: :red)
exit(1)
end
if project_name == 'rubee'
color_puts("Error: Project 'rubee' is reserved", color: :red)
exit(1)
end
source_dir = File.join(Rubee::ROOT_PATH, '/lib')
target_dir = File.expand_path("./#{project_name}", Dir.pwd)
if Dir.exist?(target_dir)
color_puts("Error: Project #{project_name} already exists!", color: :red)
exit(1)
end
FileUtils.mkdir_p(target_dir)
blacklist_files = %w[rubee.rb print_colors.rb version.rb config.ru test_helper.rb Gemfile.lock test.yml test.db
development.db production.db users_controller.rb users_controller.rb]
blacklist_dirs = %w[rubee tests .git .github .idea node_modules db inits]
copy_project_files(source_dir, target_dir, blacklist_files, blacklist_dirs)
setup_test_structure(target_dir, source_dir)
setup_db_structure(target_dir, source_dir)
FileUtils.mkdir_p("#{target_dir}/inits")
setup_gemfile(target_dir)
color_puts("Project #{project_name} created successfully at #{target_dir}", color: :green)
end
|