@@ -35,8 +35,22 @@ pub fn create(
3535 ) ?;
3636
3737 write_pack_to_disk ( & new_pack) ?;
38- std:: fs:: create_dir_all ( new_pack_path. join ( "app/public/" ) )
39- . context ( "failed to create app/public" ) ?;
38+ let pack_name =
39+ & name. split ( '/' ) . last ( ) . context ( "unable to find pack name" ) ?;
40+ std:: fs:: create_dir_all ( new_pack_path. join ( "app/public/" ) . join ( pack_name) )
41+ . context ( format ! ( "failed to create app/public/{}" , & name) ) ?;
42+ std:: fs:: create_dir_all (
43+ new_pack_path. join ( "app/services/" ) . join ( pack_name) ,
44+ )
45+ . context ( format ! ( "failed to create app/services/{}" , & name) ) ?;
46+ if is_rails ( configuration) {
47+ std:: fs:: create_dir_all ( new_pack_path. join ( "app/controllers/" ) )
48+ . context ( "failed to create app/controllers" ) ?;
49+ }
50+ if is_rspec ( configuration) {
51+ std:: fs:: create_dir_all ( new_pack_path. join ( "spec" ) )
52+ . context ( "failed to create spec" ) ?;
53+ }
4054
4155 let readme = readme ( name) ;
4256 let readme_path = & new_pack_path. join ( "README.md" ) ;
@@ -65,3 +79,18 @@ See https://github.com/rubyatscale/pks#readme for more info!",
6579 pack_name
6680)
6781}
82+
83+ fn is_rails ( configuration : & Configuration ) -> bool {
84+ gemfile_contains ( configuration, "rails" )
85+ }
86+
87+ fn is_rspec ( configuration : & Configuration ) -> bool {
88+ gemfile_contains ( configuration, "rspec" )
89+ }
90+
91+ fn gemfile_contains ( configuration : & Configuration , val : & str ) -> bool {
92+ match std:: fs:: read_to_string ( configuration. absolute_root . join ( "Gemfile" ) ) {
93+ Ok ( as_string) => as_string. contains ( val) ,
94+ _ => false ,
95+ }
96+ }
0 commit comments