22
33namespace PotetoDev \LaravelUiStisla ;
44
5+ use Illuminate \Filesystem \Filesystem ;
56use Laravel \Ui \Presets \Preset ;
67
78class StislaPreset extends Preset
89{
10+ const RESOURCE_PATH = __DIR__ .'/../resources/ ' ;
11+
912 /**
1013 * Install the preset.
1114 *
@@ -14,7 +17,11 @@ class StislaPreset extends Preset
1417 public static function install ()
1518 {
1619 static ::updatePackages ();
17- // TODO: Add some preset
20+
21+ static ::updateScripts ();
22+ static ::updateStyles ();
23+ static ::updateLayoutViews ();
24+
1825 static ::removeNodeModules ();
1926 }
2027
@@ -34,4 +41,61 @@ protected static function updatePackageArray(array $packages)
3441 'bootstrap-vue ' => '^2.0.1 ' ,
3542 ] + $ packages ;
3643 }
44+
45+ /**
46+ * Update the JS
47+ *
48+ * @return void
49+ */
50+ protected static function updateScripts ()
51+ {
52+ (new Filesystem )->deleteDirectory (resource_path ('js ' ));
53+
54+ static ::copyDirectory (static ::RESOURCE_PATH .'js ' , resource_path ('js ' ));
55+ }
56+
57+ /**
58+ * Update the SCSS
59+ *
60+ * @return void
61+ */
62+ protected static function updateStyles ()
63+ {
64+ (new Filesystem )->deleteDirectory (resource_path ('sass ' ));
65+
66+ static ::copyDirectory (static ::RESOURCE_PATH .'sass ' , resource_path ('sass ' ));
67+ }
68+
69+ /**
70+ * Update the default layout
71+ */
72+ protected static function updateLayoutViews ()
73+ {
74+ static ::copyDirectory (static ::RESOURCE_PATH .'views/layouts ' , resource_path ('views/layouts ' ));
75+ static ::copyDirectory (static ::RESOURCE_PATH .'views/partials ' , resource_path ('views/partials ' ));
76+ static ::copyDirectory (static ::RESOURCE_PATH .'views/app ' , resource_path ('views/app ' ));
77+ }
78+
79+ /**
80+ * Delete a file
81+ *
82+ * @param $source
83+ * @return void
84+ */
85+ private static function delete ($ source )
86+ {
87+ (new Filesystem )->delete (base_path ($ source ));
88+ }
89+
90+ /**
91+ * Copy a directory
92+ *
93+ * @param $source
94+ * @param $destination
95+ * @return void
96+ */
97+ private static function copyDirectory ($ source , $ destination )
98+ {
99+ (new Filesystem )->copyDirectory ($ source , $ destination );
100+ }
37101}
0 commit comments