@@ -62,8 +62,6 @@ public function fetchStarterKit($starterkit = "") {
62
62
$ tempDirDist = $ tempDirSK .DIRECTORY_SEPARATOR ."dist " ;
63
63
$ tempComposerFile = $ tempDirSK .DIRECTORY_SEPARATOR ."composer.json " ;
64
64
65
- $ fs = new Filesystem ();
66
-
67
65
// figure out the options for the GH path
68
66
list ($ org ,$ repo ,$ tag ) = $ this ->getPackageInfo ($ starterkit );
69
67
@@ -103,40 +101,19 @@ public function fetchStarterKit($starterkit = "") {
103
101
if (file_exists ($ tempComposerFile )) {
104
102
105
103
$ tempComposerJSON = json_decode (file_get_contents ($ tempComposerFile ), true );
104
+
105
+ // see if it has a patternlab section that might define the files to move
106
106
if (isset ($ tempComposerJSON ["extra " ]) && isset ($ tempComposerJSON ["extra " ]["patternlab " ])) {
107
107
Console::writeInfo ("installing the starterkit... " );
108
108
InstallerUtil::parseComposerExtraList ($ tempComposerJSON ["extra " ]["patternlab " ], $ starterkit , $ tempDirDist );
109
109
Console::writeInfo ("installed the starterkit... " );
110
110
} else {
111
- Console:: writeError ( " the starterkit's composer.json file didn't have a valid format. missing patternlab directives... " );
111
+ $ this -> mirrorDist ( $ sourceDir , $ tempDirDist );
112
112
}
113
113
114
114
} else {
115
115
116
- // see if the source directory is empty
117
- $ emptyDir = true ;
118
- if (is_dir ($ sourceDir )) {
119
- $ objects = new \DirectoryIterator ($ sourceDir );
120
- foreach ($ objects as $ object ) {
121
- if (!$ object ->isDot () && ($ object ->getFilename () != "README " ) && ($ object ->getFilename () != ".DS_Store " )) {
122
- $ emptyDir = false ;
123
- }
124
- }
125
- }
126
-
127
- // if source directory isn't empty ask if it's ok to nuke what's there
128
- if (!$ emptyDir ) {
129
-
130
- $ prompt = "a starterkit is already installed. merge or replace? " ;
131
- $ options = "M/r " ;
132
- $ input = Console::promptInput ($ prompt ,$ options );
133
- $ options = ($ input == "r " ) ? array ("delete " => true , "override " => true ) : array ("delete " => false , "override " => false );
134
-
135
- }
136
-
137
- Console::writeInfo ("installing the starterkit files... " );
138
- $ fs ->mirror ($ tempDirDist , $ sourceDir , null , $ options );
139
- Console::writeInfo ("starterkit files have been installed... " );
116
+ $ this ->mirrorDist ($ sourceDir , $ tempDirDist );
140
117
141
118
}
142
119
@@ -177,4 +154,43 @@ protected function getPackageInfo($package) {
177
154
178
155
}
179
156
157
+ /**
158
+ * Force mirror the dist/ folder to source/
159
+ * @param {String} path to the source directory
160
+ * @param {String} path to the temp dist directory
161
+ */
162
+ protected function mirrorDist ($ sourceDir , $ tempDirDist ) {
163
+
164
+ // set default vars
165
+ $ fsOptions = array ();
166
+ $ emptyDir = true ;
167
+
168
+ // see if the source directory is empty
169
+ if (is_dir ($ sourceDir )) {
170
+ $ objects = new \DirectoryIterator ($ sourceDir );
171
+ foreach ($ objects as $ object ) {
172
+ if (!$ object ->isDot () && ($ object ->getFilename () != "README " ) && ($ object ->getFilename () != ".DS_Store " )) {
173
+ $ emptyDir = false ;
174
+ }
175
+ }
176
+ }
177
+
178
+ // if source directory isn't empty ask if it's ok to nuke what's there
179
+ if (!$ emptyDir ) {
180
+
181
+ $ prompt = "a starterkit is already installed. merge the new files with it or replace it? " ;
182
+ $ options = "M/r " ;
183
+ $ input = Console::promptInput ($ prompt ,$ options );
184
+ $ fsOptions = ($ input == "r " ) ? array ("delete " => true , "override " => true ) : array ("delete " => false , "override " => false );
185
+
186
+ }
187
+
188
+ // mirror dist to source
189
+ Console::writeInfo ("installing the starterkit files... " );
190
+ $ fs = new Filesystem ();
191
+ $ fs ->mirror ($ tempDirDist , $ sourceDir , null , $ options );
192
+ Console::writeInfo ("starterkit files have been installed... " );
193
+
194
+ }
195
+
180
196
}
0 commit comments